]> code.delx.au - comingnext/blobdiff - comingNext/index.html
Work around for bug by fixing the current Date rather than amending calendar dates
[comingnext] / comingNext / index.html
index 6a4ec989adb87a936535d473676bc8fcf7a42628..1d45580d63d013d6d51dc91e79dfecb5c112fdc2 100644 (file)
@@ -34,6 +34,7 @@ var config = {
        fontsize: { Type: 'Enum', Default: 'auto', Value: 'auto', ValidValues: ['auto', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28'],},\r
        eventsPerWidget: { Type: 'Int', Default: 4, Value: 4,},\r
        monthRange: { Type: 'Int', Default: 2, Value: 2,},\r
+       maxNumberOfEventsOnFullscreen: { Type: 'Int', Default: 30, Value: 30,},\r
        includeTodos: { Type: 'Bool', Default: true, Value: true,},\r
        useBackgroundImage: { Type: 'Bool', Default: true, Value: true,},\r
        backgroundImageLocation: { Type: 'Enum', Default: 'internal', Value: 'internal', ValidValues: ['internal', 'external']},\r
@@ -60,6 +61,7 @@ var config = {
        showCalendarIndicator: { Type: 'Bool', Default: true, Value: true,},\r
        excludedCalendars: { Type: 'Array', Default: [], Value: [],},\r
        enableLogging: { Type: 'Bool', Default: false, Value: false,},\r
+       anonymizeLogging: { Type: 'Bool', Default: false, Value: false,},\r
        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
@@ -84,6 +86,18 @@ var config = {
 //-------------------------------------------------------\r
 // Nothing of interest from here on...\r
 //-------------------------------------------------------\r
+\r
+function fixDate(d) {\r
+       if (d.getTimezoneOffset() < -12*60) {\r
+               d = new Date((new Date(d.getTime()-24*3600*1000)).toLocaleString());\r
+       }\r
+       return d\r
+}\r
+\r
+function newDate() {\r
+       return fixDate(new Date());\r
+}\r
+\r
 var panelNum = 0; // use 1 for second panel\r
 var version = "1.37";\r
 var versionURL = "http://comingnext.sourceforge.net/version.xml";\r
@@ -92,7 +106,7 @@ var cacheEntriesHtml = [];
 var months_translated = [];\r
 var weekdays_translated = [];\r
 var orientation = '';\r
-var now = new Date();\r
+var now = newDate();\r
 var mode = 0; // 0 = homescreen, 1 = fullscreen, 2 = settings, 3 = about, 4 = check for update\r
 var reqV = null; \r
 var settingsCalEntryId = null;\r
@@ -253,7 +267,7 @@ function collectLocales()
                }\r
        }\r
        for (weekday = 0; weekday < 7; weekday++) {\r
-               var startDate = new Date(2000, 0, 2 + weekday); // date that we know for sure is a sunday\r
+               var startDate = new Date(2000, 0, 2 + weekday, 12); // date that we know for sure is a sunday\r
 \r
                var item = new Object();\r
                item.Type = "DayEvent";\r
@@ -666,7 +680,7 @@ function updateData()
                lastReloadTime = null; // force calendar data reload on this update\r
        }\r
 \r
-       now = new Date();\r
+       now = newDate();\r
        \r
        // only reload calendar data every 6 hours, visual updates occure more often\r
        if (!lastReloadTime || now.getTime() - lastReloadTime.getTime() > reloadInterval) {\r
@@ -724,7 +738,7 @@ function updateData()
                        } else {\r
                                entryLists = [meetingList];\r
                        }\r
-                       lastReloadTime = new Date();\r
+                       lastReloadTime = newDate();\r
                } catch(e) {\r
                        error('loading Calendar items list:' + e + ', line ' + e.line);\r
                        return;\r
@@ -741,14 +755,14 @@ function updateData()
                if (mode == 0) {\r
                        if (config['fontsize'].Value == config['fontsize'].ValidValues[0]) {\r
                                fontsize = parseInt(72 / config['eventsPerWidget'].Value) + 'px';\r
-                               lineheight = parseInt(82 / config['eventsPerWidget'].Value) + 'px';\r
+                               lineheight = parseInt(72 / config['eventsPerWidget'].Value) + 'px';\r
                        }\r
                }\r
                if (config['fontsize'].Value != config['fontsize'].ValidValues[0]) {\r
                        fontsize = config['fontsize'].Value + 'px';\r
                        lineheight = fontsize;\r
                }\r
-               changeCssClass('.icon', config['cssStyle_icon'].Value + '; width:' + lineheight + '; height:' + lineheight + ';');\r
+               changeCssClass('.icon', config['cssStyle_icon'].Value + '; width:' + fontsize + '; height:' + fontsize + ';');\r
                var entriesHtml = '<table style="font-size:' + fontsize + '; line-height:' + lineheight + ';">';\r
                if (mode == 0)\r
                        entriesHtml = '<table width="307" height="82"><tr><td>' + entriesHtml; // this is needed to center the actual content vertically\r
@@ -757,7 +771,7 @@ function updateData()
                if (mode == 0)\r
                        max = (panelNum + 1) * config['eventsPerWidget'].Value;\r
                else\r
-                       max = 30; // we can display a lot more events in fullscreen mode\r
+                       max = config["maxNumberOfEventsOnFullscreen"].Value; // we can display a lot more events in fullscreen mode\r
 \r
                if (config['enableLogging'].Value) {\r
                        var listinfo = "";\r
@@ -893,7 +907,7 @@ function updateData()
                                // generate html output\r
                                entriesHtml += '<tr>';\r
                                if (config['showCalendarIndicator'].Value && calendarList.length - config['excludedCalendars'].Value.length > 1) {\r
-                                       entriesHtml += '<td><span class="calendar' + calendarColors[entry.CalendarName] + '">&nbsp;</span></td>';\r
+                                       entriesHtml += '<td><div class="calendar' + calendarColors[entry.CalendarName] + '" style="height:' + (lineheight.split("px")[0] - 1) + 'px; width:4px;"></div></td>';\r
                                }\r
                                if (config['showIcons'].Value)\r
                                        entriesHtml += '<td><img class="icon" align="top" src="' + entry.Type + '.png" /></td>';\r
@@ -951,7 +965,7 @@ function updateData()
                        cacheEntriesHtml = entriesHtml;\r
                }\r
                \r
-               lastUpdateTime = new Date();\r
+               lastUpdateTime = newDate();\r
        } catch(e) {\r
                error('displaying list:' + e + ', line ' + e.line);\r
                return;\r
@@ -991,7 +1005,7 @@ function handleOnShow()
 {\r
        updateScreen();\r
 \r
-       var time = new Date();\r
+       var time = newDate();\r
        if (time.getTime() - lastUpdateTime.getTime() > config['updateDataInterval'].Value * 60 * 1000) {\r
                log('updateScreen(): force updateData() because last update was too long ago (' + (time.getTime() - lastUpdateTime.getTime()) / 1000 + 's)');\r
                clearUpdateTimer();\r
@@ -1618,6 +1632,12 @@ function listToArray(list, calendarName)
                if (!itemCopy['CalendarName']) {\r
                        itemCopy['CalendarName'] = calendarName;\r
                }\r
+               if (config['anonymizeLogging'].Value && config['enableLogging'].Value) {\r
+                       if (itemCopy['Summary'])\r
+                               itemCopy['Summary'] = getHashForString(itemCopy['Summary']);\r
+                       if (itemCopy['Location'])\r
+                               itemCopy['Location'] = getHashForString(itemCopy['Location']);\r
+               }\r
                array.push(itemCopy);\r
                txt += array[array.length - 1].Summary + ", ";\r
        }\r
@@ -1752,6 +1772,17 @@ function getDefaultFontSize()
        return defaultFontSize;\r
 }\r
 \r
+function getHashForString(string)\r
+{\r
+       // cheap hashing, loosly based on Java's String.hashCode()\r
+       for (var hash = 0, i = 0; i < string.length; i++)\r
+               hash = (hash << 5) - hash + string.charCodeAt(i);\r
+       hash = hash & hash; // Convert to 32bit integer\r
+       if (hash < 0)\r
+               hash = -hash;\r
+       return hash.toString(16).toUpperCase();\r
+}\r
+\r
 </script>\r
 \r
 <style type="text/css">\r