102 lines
2.3 KiB
JavaScript
102 lines
2.3 KiB
JavaScript
var log4js = require('log4js');
|
|
var logger = log4js.getLogger();
|
|
|
|
var calHandler = require('./today/calHandler');
|
|
|
|
require('sugar-date');
|
|
|
|
var cal = { 'today': [], 'tomorrow': [], 'week': [] };
|
|
var _cal_tmp = { 'today': [], 'tomorrow': [], 'week': [] };
|
|
|
|
/*
|
|
for (var t = 0; t < calHandler.calendars.length;t++)
|
|
calHandler.getAdvancedCalV3(calHandler.calendars[t])
|
|
.then((d) => {
|
|
'use strict';
|
|
// cal.today = cal.today.concat(d.today);
|
|
// cal.tomorrow = cal.tomorrow.concat(d.tomorrow);
|
|
cal.week = cal.week.concat(d.week);
|
|
|
|
logger.info(cal);
|
|
})
|
|
.catch((e) => {
|
|
'use strict';
|
|
logger.error(e);
|
|
});
|
|
*/
|
|
|
|
/* for (const item of calHandler.calendars)
|
|
calHandler.getAdvancedCalV3(item)
|
|
.then((d) => {
|
|
'use strict';
|
|
// cal.today = cal.today.concat(d.today);
|
|
// cal.tomorrow = cal.tomorrow.concat(d.tomorrow);
|
|
cal.week = cal.week.concat(d.week);
|
|
|
|
console.dir(cal);
|
|
})
|
|
.catch((e) => {
|
|
'use strict';
|
|
logger.error(e);
|
|
});*/
|
|
|
|
/* calHandler.getSimpleCalV3(
|
|
'http://www.pogdesign.co.uk/cat/download_ics/60cfdff469d0490545d33d7e3b5c0bcc')
|
|
.then((d) => {
|
|
'use strict';
|
|
let tv = d;
|
|
|
|
logger.info(tv);
|
|
})
|
|
.catch((e) => {
|
|
'use strict';
|
|
logger.error(e);
|
|
});*/
|
|
|
|
/* calHandler.getAdvancedCalV3(calHandler.calendars[4])
|
|
.then((d) => {
|
|
'use strict';
|
|
// cal.today = cal.today.concat(d.today);
|
|
// cal.tomorrow = cal.tomorrow.concat(d.tomorrow);
|
|
cal.week = cal.week.concat(d.week);
|
|
|
|
logger.error(cal);
|
|
})
|
|
.catch((e) => {
|
|
'use strict';
|
|
logger.error(e);
|
|
});*/
|
|
|
|
async function AsyncTest() {
|
|
|
|
function compare(a, b) {
|
|
if (a.ts < b.ts) {
|
|
return -1;
|
|
}
|
|
if (a.ts > b.ts) {
|
|
return 1;
|
|
}
|
|
return 0;
|
|
}
|
|
for (const item of calHandler.calendars)
|
|
await calHandler.getAdvancedCalV3(item)
|
|
.then((d) => {
|
|
'use strict';
|
|
// cal.today = cal.today.concat(d.today);
|
|
// cal.tomorrow = cal.tomorrow.concat(d.tomorrow);
|
|
cal.week = cal.week.concat(d.week);
|
|
|
|
// console.dir(cal);
|
|
})
|
|
.catch((e) => {
|
|
'use strict';
|
|
logger.error(e);
|
|
});
|
|
|
|
cal.week = cal.week.sort(compare);
|
|
console.log('COMPLETE!!');
|
|
console.log(cal.week);
|
|
}
|
|
|
|
AsyncTest();
|