]> code.delx.au - comingnext/blobdiff - comingNext/index.html
added enableLogging setting, made logging optional (might improve speed)
[comingnext] / comingNext / index.html
index 7e774b94776fc97fb990360e248f64f20c02d9f6..2dd85d774b2fcfc8b6515d92378694cd1f36200d 100644 (file)
@@ -57,6 +57,7 @@ var config = {
        hideWidgetOnCalendarOpen: { Type: 'Bool', Default: false, Value: false,},\r
        showCalendarIndicator: { Type: 'Bool', Default: true, Value: true,},\r
        excludedCalendars: { Type: 'Array', Default: [], Value: [],},\r
+       enableLogging: { Type: 'Bool', Default: false, Value: false,},
        cssStyle_background: { Type: 'String', Default: 'color:#ffffff; background-color:#000000', Value: 'color:#ffffff; background-color:#000000',},\r
        cssStyle_backgroundFullscreen: { Type: 'String', Default: 'color:#ffffff; background-color:#000000', Value: 'color:#ffffff; background-color:#000000',},\r
        cssStyle_weekDay: { Type: 'String', Default: '', Value: '',},\r
@@ -290,7 +291,7 @@ function collectLocales()
                                month = tmp;\r
                        }\r
 \r
-                       console.info(entry.StartTime + ' -> ' + month + ' ' + counter);\r
+                       log(entry.StartTime + ' -> ' + month + ' ' + counter);
                        ids[counter] = entry.id;\r
                        months_translated[month] = counter + 1;\r
                        counter++;\r
@@ -299,7 +300,7 @@ function collectLocales()
                error(e + ', line ' + e.line);\r
                return;\r
        }\r
-       console.info(ids);\r
+       log(ids);
        try {\r
                var criteria = new Object();\r
                criteria.Type = "CalendarEntry";\r
@@ -363,13 +364,13 @@ function cancelNotification()
 \r
 function callback(transId, eventCode, result)\r
 {\r
-       console.info("callback(): panelNum: %d  transId: %d  eventCode: %d result.ErrorCode: %d", panelNum, transId, eventCode, result.ErrorCode);\r
+       log("callback(): panelNum: %d  transId: %d  eventCode: %d result.ErrorCode: %d", panelNum, transId, eventCode, result.ErrorCode);
        updateData();\r
 }\r
 \r
 function settingsCallback(transId, eventCode, result)\r
 {\r
-       console.info("settingsCallback(): panelNum: %d  transId: %d  eventCode: %d result.ErrorCode: %d", panelNum, transId, eventCode, result.ErrorCode);\r
+       log("settingsCallback(): panelNum: %d  transId: %d  eventCode: %d result.ErrorCode: %d", panelNum, transId, eventCode, result.ErrorCode);
        loadSettings();\r
 }\r
 \r
@@ -437,11 +438,11 @@ function parseDate(dateString)
                // work around bug in Nokias calendar api resulting in dates within a different DST to be off by 1 hour\r
                if (summertime && !dateSummerTime) {\r
                        result = new Date(result.getTime() - 1000 * 60 * 60 * config['daylightSavingOffset'].Value); // -1 hour\r
-                       console.info('parseDate(): fixing time -1h: ' + result);\r
+                       log('parseDate(): fixing time -1h: ' + result);
                }\r
                else if (!summertime && dateSummerTime) {\r
                        result = new Date(result.getTime() + 1000 * 60 * 60 * config['daylightSavingOffset'].Value); // +1 hour\r
-                       console.info('parseDate(): fixing time +1h: ' + result);\r
+                       log('parseDate(): fixing time +1h: ' + result);
                }\r
        }\r
 \r
@@ -518,7 +519,7 @@ function formatTime(date)
 \r
 function updateData()\r
 {\r
-       console.info('updateData()');\r
+       log('updateData()');
        if (errorOccured) {\r
                return;\r
        }\r
@@ -645,18 +646,18 @@ function updateData()
                                                entryInfo += entryFields[k] + "=" + entry[entryFields[k]] + ",";\r
                                        }\r
                                }\r
-                               console.info(entryInfo);\r
+                               log(entryInfo);
 \r
                                // we don't want ToDos when includeTodos == false or when they are completed\r
                                if (entry.Type == 'ToDo' && (entry.Status == "TodoCompleted" || !config['includeTodos'].Value)) {\r
-                                       console.info('skipping ' + entry.id );\r
+                                       log('skipping ' + entry.id );
                                        counter--;\r
                                        continue;\r
                                }\r
 \r
                                // make sure that we don't include an event twice (useful for ToDos that might come up twice)\r
                                if (eventIds[entry.id] == 1 && entry.Type == 'ToDo') {\r
-                                       console.info('skipped (already included) ' + entry.id);\r
+                                       log('skipped (already included) ' + entry.id);
                                        counter--;\r
                                        continue;\r
                                } else\r
@@ -679,15 +680,15 @@ function updateData()
 \r
                                // Convert date/time string to Date object\r
                                var date = parseDate(entryDate);\r
-                               console.info('date: ' + date);\r
+                               log('date: ' + date);
                                var endDate = ((entryEndTime == null) ? null : parseDate(entryEndTime));\r
-                               console.info('endDate: ' + endDate);\r
+                               log('endDate: ' + endDate);
 \r
                                // check if meeting event has already passed\r
                                if (entry.Type == 'Meeting') {\r
                                        var compareTime = ((endDate == null) ? date.getTime() : endDate.getTime());\r
                                        if (now.getTime() > compareTime) {\r
-                                               console.info('skipping Meeting (already passed) ' + entry.id);\r
+                                               log('skipping Meeting (already passed) ' + entry.id);
                                                counter--;\r
                                                eventIds[entry.id] = 0;\r
                                                continue;\r
@@ -698,7 +699,7 @@ function updateData()
                                if (entry.Type == 'Anniversary') {\r
                                        var tmp = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0,0,0);\r
                                        if (date.getTime() < tmp.getTime()) {\r
-                                               console.info('skipping Anniversary (already passed) ' + entry.id);\r
+                                               log('skipping Anniversary (already passed) ' + entry.id);
                                                counter--;\r
                                                eventIds[entry.id] = 0;\r
                                                continue;\r
@@ -708,9 +709,9 @@ function updateData()
                                // fix DayEvents end time. End times are off by 1 Second. It's possible that the event has already passed\r
                                if (entry.Type == 'DayEvent' && endDate != null) {\r
                                        endDate.setMinutes(endDate.getMinutes() - 1);\r
-                                       console.info('fixing DayEvent endDate: ' + endDate);\r
+                                       log('fixing DayEvent endDate: ' + endDate);
                                        if (now.getTime() > endDate.getTime()) {\r
-                                               console.info('event already passed ' + entry.id);\r
+                                               log('event already passed ' + entry.id);
                                                counter--;\r
                                                eventIds[entry.id] = 0;\r
                                                continue;\r
@@ -722,13 +723,13 @@ function updateData()
                                        // check if we are between start and endtime\r
                                        if ((date.getTime() < now.getTime()) && (now.getTime() < endDate.getTime())) {\r
                                                date = now; // change appointment date/time to now\r
-                                               console.info('event is currently taking place: ' + date);\r
+                                               log('event is currently taking place: ' + date);
                                        }\r
                                }\r
 \r
                                // skip events for the first panel in case this is the second one and we're not in fullscreen mode\r
                                if (mode == 0 && panelNum > 0 && counter < panelNum * config['eventsPerWidget'].Value + 1) {\r
-                                       console.info('skipping (already in first widget) ' + entry.id);\r
+                                       log('skipping (already in first widget) ' + entry.id);
                                        continue;\r
                                }\r
                                \r
@@ -824,7 +825,7 @@ function updateScreen()
        \r
        var time = new Date();\r
        if (time.getTime() - lastUpdateTime.getTime() > config['updateDataInterval'].Value * 60 * 1000) {\r
-               console.info('updateScreen(): force updateData() because last update was too long ago (' + (time.getTime() - lastUpdateTime.getTime()) / 1000 + 's)');\r
+               log('updateScreen(): force updateData() because last update was too long ago (' + (time.getTime() - lastUpdateTime.getTime()) / 1000 + 's)');
                clearUpdateTimer();\r
                updateData();\r
                setUpdateTimer(); // reinitialize update timer\r
@@ -845,7 +846,7 @@ function launchCalendar()
 \r
 function init()\r
 {\r
-       console.info('New widget instance starting up...');\r
+       log('New widget instance starting up...');
        \r
        try {\r
                // call calendar service\r
@@ -872,12 +873,12 @@ function init()
        else {\r
                mode = 1;\r
        }\r
-       console.info("init(): updateScreen()");\r
+       log("init(): updateScreen()");
        updateScreen();\r
        if (config['useBackgroundImage'].Value)\r
                // check for screen rotation every 1 secs\r
                screenRotationTimer = window.setInterval('updateScreen()', 1000 * 1);\r
-       console.info("init(): finished...");\r
+       log("init(): finished...");
 }\r
 \r
 function setUpdateTimer()\r
@@ -892,7 +893,7 @@ function clearUpdateTimer()
 \r
 function updateTimerCallback()\r
 {\r
-       console.info("updateTimerCallback()");\r
+       log("updateTimerCallback()");
        updateData();\r
 }\r
 \r
@@ -1049,7 +1050,7 @@ function getSettingsCalEntryId()
                var entry = list.getNext();\r
                if (entry != undefined) {\r
                        settingsCalEntryId = entry.LocalId;\r
-                       console.info("settingsCalEntryId=" + settingsCalEntryId);\r
+                       log("settingsCalEntryId=" + settingsCalEntryId);
                }\r
                else { // create settings item\r
                        var item = new Object();\r
@@ -1096,7 +1097,7 @@ function loadSettings()
        }\r
        var entry = result.ReturnValue.getNext();\r
        if (entry != undefined) {\r
-               console.info("Loading Settings...");\r
+               log("Loading Settings...");
                // only reload settings if they chanced since the last reload\r
                if (settingsCache != entry.Summary)\r
                {\r
@@ -1107,7 +1108,7 @@ function loadSettings()
                                var pair = stringlist[i].split('=');\r
                                var key = pair[0];\r
                                var value = pair[1];\r
-                               console.info('stringlist: ' + key + '=\'' + value + '\'');\r
+                               log('stringlist: ' + key + '=\'' + value + '\'');
                                if (config[key].Type == 'Int')\r
                                        config[key].Value = Number(value);\r
                                else if (config[key].Type == 'String')\r
@@ -1129,7 +1130,7 @@ function loadSettings()
                        updateCssClasses();\r
                }\r
                else {\r
-                       console.info("Settings already cached and did not change");\r
+                       log("Settings already cached and did not change");
                }\r
        }\r
        else {\r
@@ -1166,7 +1167,7 @@ function saveSettings()
        criteria.Type = "CalendarEntry";\r
        criteria.Item = item;\r
 \r
-       console.info("Saving settings to calendar entry: " + item.Summary);\r
+       log("Saving settings to calendar entry: " + item.Summary);
        try {\r
                var result = calendarService.IDataSource.Add(criteria);\r
                if (result.ErrorCode)\r
@@ -1223,7 +1224,7 @@ function updateFullscreen()
 \r
 function showFullscreen()\r
 {\r
-       console.info("showFullscreen()");\r
+       log("showFullscreen()");
        hideViews();\r
        document.getElementById("fullscreenView").style.display = "block";\r
        document.getElementById('body').className = "backgroundFullscreen";\r
@@ -1271,7 +1272,7 @@ function updateHomescreen()
 \r
 function showHomescreen()\r
 {\r
-       console.info("showHomescreen()");\r
+       log("showHomescreen()");
        hideViews();\r
        document.getElementById("homescreenView").style.display = "block";\r
        document.getElementById('body').className = "background";\r
@@ -1373,7 +1374,7 @@ function listCalendars()
                while (( item = calendarListIterator.getNext()) != undefined ) {\r
                        calendars[count++] = item;\r
                }\r
-               console.info("Available Calendars: " + calendars.join(", "));\r
+               log("Available Calendars: " + calendars.join(", "));
                return calendars;\r
        } catch(e) {\r
                error('listing calendars:' + e + ', line ' + e.line);\r
@@ -1400,14 +1401,14 @@ function listToArray(list, calendarName)
                array.push(itemCopy);\r
                txt += array[array.length - 1].Summary + ", ";\r
        }\r
-       console.info("listToArray(): " + txt);\r
+       log("listToArray(): " + txt);
        return array;\r
 }\r
 \r
 function sortCalendarEntries(a, b)\r
 {\r
        var atime, btime;\r
-       console.info("sortCalendarEntries(" + a.Summary + "," + b.Summary + ")");\r
+       log("sortCalendarEntries(" + a.Summary + "," + b.Summary + ")");
        \r
        if (a.InstanceStartTime != null) {\r
                atime = a.InstanceStartTime;\r
@@ -1502,13 +1503,19 @@ function updateCalendarColors()
        var maxColors = 6;\r
        calendarColors = [];\r
        if (calendarList.length > maxColors) {\r
-               console.info("updateCalendarColors(): Warning: more calendars than available indicator colors");\r
+               log("updateCalendarColors(): Warning: more calendars than available indicator colors");
        }\r
        for(var i=0; i < calendarList.length; i++) {\r
                calendarColors[calendarList[i]] = (i % maxColors) + 1;\r
        }\r
 }\r
 \r
+function log(message) {
+       if (config['enableLogging'].Value) {
+               console.info(message);
+       }
+}
+
 </script>\r
 \r
 <style type="text/css">\r