Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions application/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,16 @@ 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) => {
console.log('error');
console.log(e);
});
}, 10000);
}
Expand Down Expand Up @@ -1108,6 +1109,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 @@ -1138,8 +1140,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 @@ -1230,6 +1233,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 @@ -1264,8 +1268,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 @@ -1339,9 +1344,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 @@ -3840,6 +3852,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 @@ -5420,7 +5435,7 @@ let interval = () => {
interval_is_running = false;
style_calendar_cell(currentYear, currentMonth);
sort_array(parsed_events, 'dateStartUnix', 'number');
console.log(page_add_events);
console.log('page_add_events');
clearInterval(waitForNoMessages);
}
}, checkMessagesInterval);
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