Skip to content

Commit

Permalink
backup events - version changment
Browse files Browse the repository at this point in the history
  • Loading branch information
strukturart committed Feb 19, 2024
1 parent 5c608e4 commit 7e3406c
Show file tree
Hide file tree
Showing 5 changed files with 310 additions and 106 deletions.
58 changes: 41 additions & 17 deletions application/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,26 @@ localforage.getItem('subscriptions').then((e) => {
console.log(e);
});

//store events
//version changment
//export events
try {
localforage
.getItem('events')
.then((e) => {
console.log(e);
export_ical_versionChangment('greg-backup.ics', e);
})
.catch((e) => {
console.log('error');
});
if (localStorage.getItem('export_versionChangment') != '1') {
setTimeout(() => {
localforage
.getItem('events')
.then((e) => {
console.log(e.length);
if (e == null || e.length == 0) return false;
export_ical_versionChangment('greg-backup.ics', e);
alert(
"In the new app version, events in the local calendar are saved differently. That's why it was exported and saved on your device. You can now import it again, please use the import button in the settings area. I apologize for the circumstances."
);
})
.catch((e) => {
console.log('error');
});
}, 10000);
}
} catch (e) {
console.log(e);
}
Expand All @@ -83,6 +92,16 @@ const intro_animation = () => {
document.querySelector('#intro img').classList.add('intro-img-anmation');
};

const show_success_animation = () => {
setTimeout(() => {
document.querySelector('.success-checkmark').style.display = 'block';
}, 2000);

setTimeout(() => {
document.querySelector('.success-checkmark').style.display = 'none';
}, 4000);
};

//back to last view
let view_history = [];
let view_history_update = () => {
Expand Down Expand Up @@ -799,14 +818,15 @@ export let delete_caldav = async function (etag, url, account_id, uid) {

if (status.shortCut == false) {
get_last_view();
} else {
show_success_animation();
}
}
} else {
side_toaster(
'There was a problem deleting, please try again later.',
5000
);
setTimeout(function () {}, 5000);
}
} catch (e) {
console.log(e);
Expand Down Expand Up @@ -3615,8 +3635,6 @@ let callback_getfile = function (result) {
store: true,
});
}

side_toaster('event imported', 3000);
} catch (e) {
alert(
'event could not be imported because the file content is invalid' + e
Expand Down Expand Up @@ -4752,6 +4770,9 @@ let delete_event = function (etag, url, account_id, uid) {
if (etag) {
delete_caldav(etag, url, account_id, uid).then((e) => {});
} else {
console.log(local_account.data);
console.log(parsed_events);

// Find the index of the object with the matching UID
const index = local_account.data.findIndex((item) => item.uid === uid);
if (index !== -1) {
Expand All @@ -4762,6 +4783,8 @@ let delete_event = function (etag, url, account_id, uid) {
.setItem('local_account', local_account)
.then(function () {
if (!status.shortCut) get_last_view();
show_success_animation();

style_calendar_cell(currentYear, currentMonth);
})
.catch(function (err) {});
Expand Down Expand Up @@ -5344,28 +5367,29 @@ channel.addEventListener('message', (event) => {
) === -1)
) {
parsed_events.push(event.data.content.parsed_data);
console.log(parsed_events);

//notify user when data stored

if (event.data.content.callback) {
side_toaster('event imported', 5000);
show_success_animation();
}
//store data
//when importing data
//When importing, the data is first parsed and then the RAW and parsed data are returned
if (event.data.content.raw_data) {
local_account.data.push({
UID: uid(32),
uid: event.data.content.uid,
data: event.data.content.raw_data,
});

localforage
.setItem('local_account', local_account)
.then(() => {
console.log('stored');
show_success_animation();
})
.catch(() => {
console.log(e);
side_toaster('problem', 5000);
});
}
} else {
Expand Down
158 changes: 158 additions & 0 deletions application/assets/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -1176,3 +1176,161 @@ div#time {
transform: translateY(-30px);
}
}

/*Success animation*/

.success-checkmark {
width: 40px; /* Half the width */
height: 57.5px; /* Half the height */
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
display: none;
z-index: 50000;
animation: hide ease-in forwards;
animation-duration: 6.25s;
}

.success-checkmark .check-icon {
width: 40px; /* Half the width */
height: 40px; /* Half the height */
position: relative;
border-radius: 50%;
box-sizing: content-box;
border: 3px solid #4caf50; /* Half the border thickness */
}

.success-checkmark .check-icon::before {
top: 1.5px; /* Half the value */
left: -1px; /* Half the value */
width: 15px; /* Half the width */
transform-origin: 100% 50%;
border-radius: 50px 0 0 50px;
}

.success-checkmark .check-icon::after {
top: 0;
left: 15px;
width: 30px; /* Half the width */
transform-origin: 0 50%;
border-radius: 0 50px 50px 0;
}

.success-checkmark .check-icon::before,
.success-checkmark .check-icon::after {
content: '';
height: 50px; /* Half the height */
position: absolute;
background: #ffffff;
transform: rotate(-45deg);
}

.success-checkmark .check-icon .icon-line {
height: 2.5px; /* Half the height */
background-color: #1a721d;
display: block;
border-radius: 1px; /* Half the value */
position: absolute;
z-index: 10;
}

.success-checkmark .check-icon .icon-line.line-tip {
top: 23px;
left: 7px;
width: 12.5px;
transform: rotate(45deg);
animation: icon-line-tip 0.75s forwards;
}

.success-checkmark .check-icon .icon-line.line-long {
top: 19px;
right: 4px;
width: 23.5px;
transform: rotate(-45deg);
animation: icon-line-long 0.75s;
}

.success-checkmark .check-icon .icon-circle {
top: -2px;
left: -2px;
z-index: 10;
width: 40px; /* Half the width */
height: 40px; /* Half the height */
border-radius: 50%;
position: absolute;
box-sizing: content-box;
border: 3px solid rgba(76, 175, 80, 0.5);
}

.success-checkmark .check-icon .icon-fix {
top: 4px;
width: 2.5px; /* Half the width */
left: 13px;
z-index: 1;
height: 42.5px;
position: absolute;
transform: rotate(-45deg);
background-color: #ffffff;
}

@keyframes icon-line-tip {
0% {
width: 0;
left: 0.5px;
top: 9.5px;
}
54% {
width: 0;
left: 0.5px;
top: 9.5px;
}
70% {
width: 25px;
left: -4px;
top: 18.5px;
}
84% {
width: 8.5px;
left: 10.5px;
top: 24px;
}
100% {
width: 12.5px;
left: 7px;
top: 22.5px;
}
}

@keyframes icon-line-long {
0% {
width: 0;
right: 23px;
top: 27px;
}
65% {
width: 0;
right: 23px;
top: 27px;
}
84% {
width: 27.5px;
right: 0px;
top: 17.5px;
}
100% {
width: 23.5px;
right: 4px;
top: 19px;
}
}

@keyframes hide {
0% {
display: 100;
}

100% {
opacity: 0;
}
}
Loading

0 comments on commit 7e3406c

Please sign in to comment.