Skip to content

Commit

Permalink
Merge remote-tracking branch 'zeekoe/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
strukturart committed Feb 23, 2024
2 parents 836fade + 6779b2d commit 71396e8
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 70 deletions.
36 changes: 27 additions & 9 deletions application/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,17 @@ try {
localforage
.getItem('events')
.then((e) => {
console.log(e.length);
if (e == null || e.length == 0) return false;
console.log(e.length);
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) => {});
.catch((e) => {
console.log('error');
console.log(e);
});
}, 10000);
}
} catch (e) {
Expand Down Expand Up @@ -1158,6 +1161,7 @@ let rrule_check = function (date) {
let c = new Date(date).getTime();
let d = parsed_events[t].RRULE.freq;
let e = parsed_events[t].RRULE;
let rcur_interval = parsed_events[t].RRULE.interval;

if (e !== undefined && e !== null) {
//recurrences
Expand Down Expand Up @@ -1188,8 +1192,9 @@ let rrule_check = function (date) {

if (d == 'WEEKLY') {
if (
new Date(parsed_events[t].dateStart).getDay() ===
new Date(date).getDay()
((rcur_interval == null || rcur_interval == 1)
&& new Date(parsed_events[t].dateStart).getDay() === new Date(date).getDay())
|| Math.floor((c - a) / (24 * 60 * 60 * 1000)) % (rcur_interval * 7) == 0
) {
feedback.rrule = true;
feedback.event = true;
Expand Down Expand Up @@ -1280,6 +1285,7 @@ let event_slider = function (date) {
let b = new Date(parsed_events[i].dateEnd).getTime();
let c = new Date(date).getTime();
let d = parsed_events[i].RRULE.freq;
let rcur_interval = parsed_events[t].RRULE.interval;

if (d === 'none' || d === '' || d === undefined || d === null) {
if (a === c || (a <= c && b >= c)) {
Expand Down Expand Up @@ -1314,8 +1320,9 @@ let event_slider = function (date) {
//WEEK
if (d == 'WEEKLY') {
if (
new Date(parsed_events[i].dateStart).getDay() ==
new Date(date).getDay()
((rcur_interval == null || rcur_interval == 1)
&& new Date(parsed_events[t].dateStart).getDay() === new Date(date).getDay())
|| Math.floor((c - a) / (24 * 60 * 60 * 1000)) % (rcur_interval * 7) == 0
) {
slider.push(parsed_events[i]);
}
Expand Down Expand Up @@ -1389,9 +1396,16 @@ let event_slider = function (date) {
} else {
document.getElementById('event-slider-indicator').style.opacity = 1;
document.querySelector('div#event-slider article').style.display = 'block';
document
.querySelectorAll('div#event-slider .indicator')[0]
.style.classList.add('active');
try {
document
.querySelectorAll('div#event-slider .indicator')[0]
.style.classList.add('active');
} catch(e) {
// This seems to be needed for desktop browser:
document
.querySelectorAll('div#event-slider-indicator .indicator')[0]
.classList.add('active');
}
}
};

Expand Down Expand Up @@ -3890,6 +3904,9 @@ let store_account = function (edit, id) {
type: 'basic',
});
} else {
if (accounts == null) {
accounts = [];
}
accounts.push({
server_url: document.getElementById('account-url').value,
user: document.getElementById('account-username').value,
Expand Down Expand Up @@ -5481,6 +5498,7 @@ let interval = () => {
interval_is_running = false;
style_calendar_cell(currentYear, currentMonth);
sort_array(parsed_events, 'dateStartUnix', 'number');
console.log('page_add_events');
clearInterval(waitForNoMessages);
//cache parsed data
cache_caldav_events();
Expand Down
127 changes: 66 additions & 61 deletions application/sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function parse_ics(
rr_until = new Date('3000-01-01').getTime();

if (rrule && typeof rrule === 'object' && rrule.freq) {
n = rrule;
let n = rrule;
rr_until = n.until || '';
}

Expand Down Expand Up @@ -134,74 +134,79 @@ function parse_ics(
}
}

//date start
let dateStart, timeStart, dateStartUnix;
if (date_start) {
let a = dayjs(date_start);
dateStart = a.format('YYYY-MM-DD');
timeStart = a.format('HH:mm:ss');
dateStartUnix = a.unix();
}
try {
//date start
let dateStart, timeStart, dateStartUnix;
if (date_start) {
let a = dayjs(date_start);
dateStart = a.format('YYYY-MM-DD');
timeStart = a.format('HH:mm:ss');
dateStartUnix = a.unix();
}

//date end
let dateEnd, timeEnd, dateEndUnix;
//date end
let dateEnd, timeEnd, dateEndUnix;

if (date_end) {
let a = dayjs(date_end);
if (date_end) {
let a = dayjs(date_end);

if (rr_until != '') {
a = dayjs(rr_until);
}
if (rr_until != '') {
a = dayjs(rr_until);
}

if (allday) {
a = a.subtract(1, 'day');
}
if (allday) {
a = a.subtract(1, 'day');
}

dateEnd = a.format('YYYY-MM-DD');
timeEnd = a.format('HH:mm:ss');
dateEndUnix = a.unix();
}
dateEnd = a.format('YYYY-MM-DD');
timeEnd = a.format('HH:mm:ss');
dateEndUnix = a.unix();
}

imp = {
UID: ite.getFirstPropertyValue('uid') || '',
SUMMARY: ite.getFirstPropertyValue('summary') || '',
LOCATION: ite.getFirstPropertyValue('location') || '',
DESCRIPTION: ite.getFirstPropertyValue('description') || '',
CATEGORIES: ite.getFirstPropertyValue('categories') || '',
RRULE: ite.getFirstPropertyValue('rrule') || '',
// 'LAST-MODIFIED': ite.getFirstPropertyValue('last-modified') || '',
CLASS: ite.getFirstPropertyValue('class') || '',
// DTSTAMP: ite.getFirstPropertyValue('dtstamp') || '',
DTSTART: date_start,
DTEND: date_end,
isSubscription: isSubscription,
isCaldav: isCaldav,
allDay: allday,
dateStart: dateStart,
dateStartUnix: dateStartUnix,
dateEndUnix: dateEndUnix,
dateEnd: dateEnd,
time_start: timeStart,
time_end: timeEnd,
alarm: alarm || 'none',
etag: etag || '',
url: url || '',
calendar_name: comp.getFirstPropertyValue('x-wr-calname') || '',
id: account_id,
modified: ite.getFirstPropertyValue('last-modified').toString(),
};
//when importing data callback to store
let a = { parsed_data: imp };
if (store) {
a.raw_data = data;
a.uid = imp.UID;
}
imp = {
UID: ite.getFirstPropertyValue('uid') || '',
SUMMARY: ite.getFirstPropertyValue('summary') || '',
LOCATION: ite.getFirstPropertyValue('location') || '',
DESCRIPTION: ite.getFirstPropertyValue('description') || '',
CATEGORIES: ite.getFirstPropertyValue('categories') || '',
RRULE: ite.getFirstPropertyValue('rrule') || '',
'LAST-MODIFIED': ite.getFirstPropertyValue('last-modified') || '',
CLASS: ite.getFirstPropertyValue('class') || '',
DTSTAMP: ite.getFirstPropertyValue('dtstamp') || '',
DTSTART: date_start,
DTEND: date_end,
isSubscription: isSubscription,
isCaldav: isCaldav,
allDay: allday,
dateStart: dateStart,
dateStartUnix: dateStartUnix,
dateEndUnix: dateEndUnix,
dateEnd: dateEnd,
time_start: timeStart,
time_end: timeEnd,
alarm: alarm || 'none',
etag: etag || '',
url: url,
calendar_name: comp.getFirstPropertyValue('x-wr-calname') || '',
id: account_id,
modified: ite.getFirstPropertyValue('last-modified') == null ? '' : ite.getFirstPropertyValue('last-modified').toString(),
};
//when importing data callback to store
let a = {parsed_data: imp};
if (store) {
a.raw_data = data;
a.uid = imp.UID;
}

//callback or not
if (callback) {
a.calback = true;
//callback or not
if (callback) {
a.calback = true;
}
return_array.push(a);
} catch (e) {
console.log(e);
console.log(ite);
}
return_array.push(a);
});
return return_array;
}
Expand Down

0 comments on commit 71396e8

Please sign in to comment.