X-Git-Url: https://code.delx.au/comingnext/blobdiff_plain/1e409f4b962c7083ecb0fb8ebdb0d00f2c821f03..16c0fb97d87271e97f3b81bfce529be9c81fba18:/comingNext/index.html diff --git a/comingNext/index.html b/comingNext/index.html index 6ac4e42..ce12153 100644 --- a/comingNext/index.html +++ b/comingNext/index.html @@ -67,7 +67,7 @@ var config = { // Nothing of interest from here on... //------------------------------------------------------- var panelNum = 0; // use 1 for second panel -var version = "1.26"; +var version = "1.28"; var versionURL = "http://comingnext.sourceforge.net/version.xml"; var calendarService = null; var cacheEntriesHtml = []; @@ -76,12 +76,30 @@ var orientation = ''; var now = new Date(); var mode = 0; // 0 = homescreen, 1 = fullscreen, 2 = settings, 3 = about, 4 = check for update var reqV = null; +var settingsCalEntryId = null; +var settingsCache = null; +var notificationRequest1; +var notificationRequest2; +var calendarList = []; // vars for daylight saving time var daylightsavingWinter = 0; var daylightsavingSummer = 0; var summertime = false; +// this is a list of data fields a calendar event can have +var entryFields = [ + "id", + "Type", + "Summary", + "Location", + "Status", + "StartTime", + "EndTime", + "InstanceStartTime", + "InstanceEndTime" +]; + window.onload = init; window.onresize = updateScreen; window.onshow = updateScreen; @@ -277,9 +295,23 @@ function requestNotification() criteria.Type = "CalendarEntry"; try { - var result = calendarService.IDataSource.RequestNotification(criteria, callback); - if (result.ErrorCode) - error('loading Calendar items list'); + notificationRequest1 = calendarService.IDataSource.RequestNotification(criteria, callback); + if (notificationRequest1.ErrorCode) + error('requestNotification failed with error code ' + notificationRequest1.ErrorCode); + } catch (e) { + error("requestNotification: " + e + ', line ' + e.line); + } + + var criteria2 = new Object(); + criteria2.Type = "CalendarEntry"; + criteria2.Filter = new Object(); + criteria2.Filter.LocalIdList = new Array(); + criteria2.Filter.LocalIdList[0] = settingsCalEntryId; + + try { + notificationRequest2 = calendarService.IDataSource.RequestNotification(criteria2, settingsCallback); + if (notificationRequest2.ErrorCode) + error('requestNotification failed with error code ' + notificationRequest2.ErrorCode); } catch (e) { error("requestNotification: " + e + ', line ' + e.line); } @@ -287,9 +319,16 @@ function requestNotification() function callback(transId, eventCode, result) { + console.info("callback(): panelNum: %d transId: %d eventCode: %d result.ErrorCode: %d", panelNum, transId, eventCode, result.ErrorCode); updateData(); } +function settingsCallback(transId, eventCode, result) +{ + console.info("settingsCallback(): panelNum: %d transId: %d eventCode: %d result.ErrorCode: %d", panelNum, transId, eventCode, result.ErrorCode); + loadSettings(); +} + function parseDate(dateString) { /* @@ -433,31 +472,43 @@ function updateData() // meetings have time // note: anniveraries have a start time of 12:00am. So since we want to include them, we have to query the whole day and check if events have passed later now = new Date(); - var meetingListFiltering = { - Type:'CalendarEntry', - Filter:{ - StartRange: (new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0)), - EndRange: (new Date(now.getFullYear(), now.getMonth() + config['monthRange'].Value, now.getDate(), 0, 0, 0)) + var meetingList = []; + for(var i=0; i < calendarList.length; i++) { + var meetingListFiltering = { + Type:'CalendarEntry', + Filter:{ + CalendarName: calendarList[i], + StartRange: (new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0)), + EndRange: (new Date(now.getFullYear(), now.getMonth() + config['monthRange'].Value, now.getDate(), 0, 0, 0)) + } } + var meetingResult = calendarService.IDataSource.GetList(meetingListFiltering); + if (meetingResult.ErrorCode != 0) + throw("Error fetching calendar data: " + meetingResult.ErrorCode + ': ' + meetingResult.ErrorMessage); + var list = meetingResult.ReturnValue; + meetingList = meetingList.concat(listToArray(list)); } - var meetingResult = calendarService.IDataSource.GetList(meetingListFiltering); - if (meetingResult.ErrorCode != 0) - throw("Error fetching calendar data: " + meetingResult.ErrorCode + ': ' + meetingResult.ErrorMessage); - var meetingList = meetingResult.ReturnValue; + meetingList.sort(sortCalendarEntries); // todos don't, they start on 00:00 hrs., but should be visible anyway // this will generate a list of passed todos. We have to check if they have been marked as "done" yet if (config['includeTodos'].Value) { - var todayTodoListFiltering = { - Type:'CalendarEntry', - Filter:{ - Type: 'ToDo', - StartRange: (new Date(now.getFullYear() - 1, now.getMonth(), now.getDate(), 0, 0, 0)), - EndRange: (new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 1)) + var todayTodoList = []; + for(var i=0; i < calendarList.length; i++) { + var todayTodoListFiltering = { + Type:'CalendarEntry', + Filter:{ + CalendarName: calendarList[i], + Type: 'ToDo', + StartRange: (new Date(now.getFullYear() - 1, now.getMonth(), now.getDate(), 0, 0, 0)), + EndRange: (new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 1)) + } } + var todayTodoResult = calendarService.IDataSource.GetList(todayTodoListFiltering); + var list = todayTodoResult.ReturnValue; + todayTodoList = todayTodoList.concat(listToArray(list)); } - var todayTodoResult = calendarService.IDataSource.GetList(todayTodoListFiltering); - var todayTodoList = todayTodoResult.ReturnValue; + todayTodoList.sort(sortCalendarEntries); var entryLists = [todayTodoList, meetingList]; } else { var entryLists = [meetingList]; @@ -499,7 +550,8 @@ function updateData() // the first outer loop iteration is for passed ToDos, the second loop is for all upcomming events (may also include ToDos) for (var i=0; counter < max && i < entryLists.length; i++) { - while (counter < max && (entry = entryLists[i].getNext()) != undefined) { + for (var j=0; (counter < max) && (j < entryLists[i].length); j++) { + entry = entryLists[i][j]; counter++; // output event info for debugging @@ -602,7 +654,7 @@ function updateData() // mark overdue todos var overdue = false; - if (entry.Type == 'ToDo') { + 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()) { @@ -712,15 +764,20 @@ function init() return; } + calendarList = listCalendars(); loadSettings(); - updateCssClasses(); collectLocales(); //updateData(); requestNotification(); window.setInterval('updateData()', 1000 * 60 * config['updateDataInterval'].Value); + document.getElementById("settingsTitle").innerHTML = getLocalizedText('menu.settings'); - mode = 0; - showHomescreen(); + if (window.innerHeight > 91) { + mode = 0; // we're starting fullscreen, we set mode to homescreen in order to let updateScreen() do all the work for us + } + else { + mode = 1; + } updateScreen(); if (config['useBackgroundImage'].Value) // check for screen rotation every 1 secs @@ -790,8 +847,12 @@ function showSettings() var settingsHtml = '