';
var eventIds = [];
var max;
if (mode == 0)
- max = ((panelNum == 0) ? config['eventsPerWidget'].Value : 2 * config['eventsPerWidget'].Value);
+ max = (panelNum + 1) * config['eventsPerWidget'].Value;
else
max = 30; // we can display a lot more events in fullscreen mode
@@ -492,7 +523,7 @@ function updateData()
}
// make sure that we don't include an event twice (useful for ToDos that might come up twice)
- if (eventIds[entry.id] == 1) {
+ if (eventIds[entry.id] == 1 && entry.Type == 'ToDo') {
console.info('skipped (already included) ' + entry.id);
counter--;
continue;
@@ -564,10 +595,20 @@ function updateData()
}
// skip events for the first panel in case this is the second one and we're not in fullscreen mode
- if (mode == 0 && panelNum == 1 && counter < config['eventsPerWidget'].Value + 1) {
+ if (mode == 0 && panelNum > 0 && counter < panelNum * config['eventsPerWidget'].Value + 1) {
console.info('skipping (already in first widget) ' + entry.id);
continue;
}
+
+ // mark overdue todos
+ var overdue = false;
+ if (entry.Type == 'ToDo' && date != null) {
+ var tmp1 = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0,0,0);
+ var tmp2 = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0,0,0);
+ if (tmp1.getTime() < tmp2.getTime()) {
+ overdue = true;
+ }
+ }
// generate html output
entriesHtml += '
';
@@ -578,7 +619,10 @@ function updateData()
var weekDay = date.toLocaleDateString().substr(0,config['weekDayLength'].Value);
var time = formatTime(date);
var dateStr = formatDate(date, entryDate);
- if (entry.Type == 'ToDo' || entry.Type == 'Anniversary' || entry.Type == 'DayEvent' || entry.Type == 'Reminder') {
+ if (entry.Type == 'ToDo' && overdue && config['markOverdueTodos'].Value) {
+ dateStr = 'Overdue';
+ entriesHtml += '
' + dateStr + ' ';
+ } else if (entry.Type == 'ToDo' || entry.Type == 'Anniversary' || entry.Type == 'DayEvent' || entry.Type == 'Reminder') {
if ((isToday(date) || isTomorrow(date)) && config['showTodayAsText'].Value) // show weekday if the date string is not text. looks odd otherwise
entriesHtml += '
' + dateStr + ' ';
else
@@ -655,11 +699,16 @@ function launchCalendar()
function init()
{
+ console.info('New widget instance starting up...');
+
try {
// call calendar service
- calendarService = device.getServiceObject("Service.Calendar", "IDataSource");
+ if (device != "undefined")
+ calendarService = device.getServiceObject("Service.Calendar", "IDataSource");
+ else
+ throw('device object does not exist');
} catch(e) {
- error('loading Calendar service');
+ error('loading Calendar service: ' + e + ', line ' + e.line);
return;
}
@@ -685,22 +734,23 @@ function createMenu()
var id = 0;
var menuSettings = new MenuItem(getLocalizedText('menu.settings'), id++);
var menuCallApp = new MenuItem(getLocalizedText('menu.openCalendarApp'), id++);
+ var menuUpdate = new MenuItem(getLocalizedText('menu.update'), id++);
var menuAbout = new MenuItem(getLocalizedText('menu.about'), id++);
menuSettings.onSelect = showSettings;
menuAbout.onSelect = showAbout;
menuCallApp.onSelect = launchCalendar;
+ menuUpdate.onSelect = showUpdate;
window.menu.clear();
window.menu.append(menuCallApp);
window.menu.append(menuSettings);
+ window.menu.append(menuUpdate);
window.menu.append(menuAbout);
}
function showSettings()
{
mode = 2;
- document.getElementById("homescreenView").style.display = "none";
- document.getElementById("fullscreenView").style.display = "none";
- document.getElementById("aboutView").style.display = "none";
+ hideViews();
document.getElementById("settingsView").style.display = "block";
document.onclick = null;
@@ -751,7 +801,7 @@ function showSettings()
else if (config[key].Type == 'Enum') {
settingsHtml += '