From 36639e162a4d8bb99c583512e1576b605911a6da Mon Sep 17 00:00:00 2001 From: Michael Prager Date: Tue, 29 Mar 2011 02:37:22 +0200 Subject: [PATCH 1/1] added enableLogging setting, made logging optional (might improve speed) --- comingNext/de.lproj/localizedTextStrings.js | 2 + comingNext/es.lproj/localizedTextStrings.js | 2 + comingNext/fr.lproj/localizedTextStrings.js | 2 + comingNext/index.html | 75 ++++++++++--------- comingNext/it.lproj/localizedTextStrings.js | 2 + .../pt-BR.lproj/localizedTextStrings.js | 2 + comingNext/ru.lproj/localizedTextStrings.js | 2 + 7 files changed, 53 insertions(+), 34 deletions(-) diff --git a/comingNext/de.lproj/localizedTextStrings.js b/comingNext/de.lproj/localizedTextStrings.js index faf9a0a..cde5a25 100644 --- a/comingNext/de.lproj/localizedTextStrings.js +++ b/comingNext/de.lproj/localizedTextStrings.js @@ -76,6 +76,8 @@ localizedText['settings.name.showCalendarIndicator'] = 'Zeige Farbindikator für localizedText['settings.info.showCalendarIndicator'] = 'falls mehrere Kalender benutzt werden, wird mit Hilfe eines Farbbalkens angezeigt, zu welchem Kalender ein Ereignis gehört'; localizedText['settings.name.excludedCalendars'] = 'Anzuzeigende Kalender'; localizedText['settings.info.excludedCalendars'] = 'falls du mehrere Kalender angelegt hast, kannst du hier festlegen, welche Kalender angezeigt werden sollen'; +localizedText['settings.name.enableLogging'] = 'Enable Logging'; +localizedText['settings.info.enableLogging'] = 'write debug information to C:\\Data\\jslog_widget.log. Note: Javascript error logging to file needs to be enabled in your browser settings for this.'; localizedText['settings.name.cssStyle_background'] = '.background'; localizedText['settings.info.cssStyle_background'] = 'Definiert den Hintergrund des Widgets. Falls Sie ein Hintergrundbild verwenden möchten, aktivieren Sie die Einstellung "Benutze Hintergrundbild". Für die Standardthemes des N97 ("schwarz", "grau" und "helles Blau") lauten die Farbcodes #292029, #e7dfe7 und #009aef.'; localizedText['settings.name.cssStyle_backgroundFullscreen'] = '.backgroundFullscreen'; diff --git a/comingNext/es.lproj/localizedTextStrings.js b/comingNext/es.lproj/localizedTextStrings.js index ca6df21..48b0410 100644 --- a/comingNext/es.lproj/localizedTextStrings.js +++ b/comingNext/es.lproj/localizedTextStrings.js @@ -76,6 +76,8 @@ localizedText['settings.name.showCalendarIndicator'] = 'Mostrar indicador de cal localizedText['settings.info.showCalendarIndicator'] = 'Si se usan varios calendarios simultáneamente, se usará una pequeña barra de color para indicar a cuál de los calendarios pertenece un evento'; localizedText['settings.name.excludedCalendars'] = 'Calendarios incluidos'; localizedText['settings.info.excludedCalendars'] = 'Aquí se puede especificar qué calendarios se mostrarán si se han definido varios calendarios'; +localizedText['settings.name.enableLogging'] = 'Enable Logging'; +localizedText['settings.info.enableLogging'] = 'write debug information to C:\\Data\\jslog_widget.log. Note: Javascript error logging to file needs to be enabled in your browser settings for this.'; localizedText['settings.name.cssStyle_background'] = '.background'; localizedText['settings.info.cssStyle_background'] = 'Define el fondo de aplicación del widget. Para usar una imagen de fondo personalizada, ponga useBackgroundImage = true debajo. Para el temo por defecto, negro, gris, y azul claro, los códigos son #292029, #e7dfe7, #009aef'; localizedText['settings.name.cssStyle_backgroundFullscreen'] = '.backgroundFullscreen'; diff --git a/comingNext/fr.lproj/localizedTextStrings.js b/comingNext/fr.lproj/localizedTextStrings.js index 4fa7447..ab8d34e 100644 --- a/comingNext/fr.lproj/localizedTextStrings.js +++ b/comingNext/fr.lproj/localizedTextStrings.js @@ -76,6 +76,8 @@ localizedText['settings.name.showCalendarIndicator'] = 'Show Calendar Indicator' localizedText['settings.info.showCalendarIndicator'] = 'if multiple calendars are used, a small color bar will be shown to indicate to which calendar an event belongs'; localizedText['settings.name.excludedCalendars'] = 'Included Calendars'; localizedText['settings.info.excludedCalendars'] = 'here you can specify which calendars should be displayed if multiple calendars have been defined'; +localizedText['settings.name.enableLogging'] = 'Enable Logging'; +localizedText['settings.info.enableLogging'] = 'write debug information to C:\\Data\\jslog_widget.log. Note: Javascript error logging to file needs to be enabled in your browser settings for this.'; localizedText['settings.name.cssStyle_background'] = '.background'; localizedText['settings.info.cssStyle_background'] = 'Definit le style CSS du fond du widget. Si vous voulez mettre une image de fond, cocher "Utiliser Background Image". Pour le thème par défaut, noir, gris, and bleu, les codes sont #292029, #e7dfe7, #009aef'; localizedText['settings.name.cssStyle_backgroundFullscreen'] = '.backgroundFullscreen'; diff --git a/comingNext/index.html b/comingNext/index.html index 7e774b9..2dd85d7 100644 --- a/comingNext/index.html +++ b/comingNext/index.html @@ -57,6 +57,7 @@ var config = { hideWidgetOnCalendarOpen: { Type: 'Bool', Default: false, Value: false,}, showCalendarIndicator: { Type: 'Bool', Default: true, Value: true,}, excludedCalendars: { Type: 'Array', Default: [], Value: [],}, + enableLogging: { Type: 'Bool', Default: false, Value: false,}, cssStyle_background: { Type: 'String', Default: 'color:#ffffff; background-color:#000000', Value: 'color:#ffffff; background-color:#000000',}, cssStyle_backgroundFullscreen: { Type: 'String', Default: 'color:#ffffff; background-color:#000000', Value: 'color:#ffffff; background-color:#000000',}, cssStyle_weekDay: { Type: 'String', Default: '', Value: '',}, @@ -290,7 +291,7 @@ function collectLocales() month = tmp; } - console.info(entry.StartTime + ' -> ' + month + ' ' + counter); + log(entry.StartTime + ' -> ' + month + ' ' + counter); ids[counter] = entry.id; months_translated[month] = counter + 1; counter++; @@ -299,7 +300,7 @@ function collectLocales() error(e + ', line ' + e.line); return; } - console.info(ids); + log(ids); try { var criteria = new Object(); criteria.Type = "CalendarEntry"; @@ -363,13 +364,13 @@ function cancelNotification() function callback(transId, eventCode, result) { - console.info("callback(): panelNum: %d transId: %d eventCode: %d result.ErrorCode: %d", panelNum, transId, eventCode, result.ErrorCode); + log("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); + log("settingsCallback(): panelNum: %d transId: %d eventCode: %d result.ErrorCode: %d", panelNum, transId, eventCode, result.ErrorCode); loadSettings(); } @@ -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 if (summertime && !dateSummerTime) { result = new Date(result.getTime() - 1000 * 60 * 60 * config['daylightSavingOffset'].Value); // -1 hour - console.info('parseDate(): fixing time -1h: ' + result); + log('parseDate(): fixing time -1h: ' + result); } else if (!summertime && dateSummerTime) { result = new Date(result.getTime() + 1000 * 60 * 60 * config['daylightSavingOffset'].Value); // +1 hour - console.info('parseDate(): fixing time +1h: ' + result); + log('parseDate(): fixing time +1h: ' + result); } } @@ -518,7 +519,7 @@ function formatTime(date) function updateData() { - console.info('updateData()'); + log('updateData()'); if (errorOccured) { return; } @@ -645,18 +646,18 @@ function updateData() entryInfo += entryFields[k] + "=" + entry[entryFields[k]] + ","; } } - console.info(entryInfo); + log(entryInfo); // we don't want ToDos when includeTodos == false or when they are completed if (entry.Type == 'ToDo' && (entry.Status == "TodoCompleted" || !config['includeTodos'].Value)) { - console.info('skipping ' + entry.id ); + log('skipping ' + entry.id ); counter--; continue; } // make sure that we don't include an event twice (useful for ToDos that might come up twice) if (eventIds[entry.id] == 1 && entry.Type == 'ToDo') { - console.info('skipped (already included) ' + entry.id); + log('skipped (already included) ' + entry.id); counter--; continue; } else @@ -679,15 +680,15 @@ function updateData() // Convert date/time string to Date object var date = parseDate(entryDate); - console.info('date: ' + date); + log('date: ' + date); var endDate = ((entryEndTime == null) ? null : parseDate(entryEndTime)); - console.info('endDate: ' + endDate); + log('endDate: ' + endDate); // check if meeting event has already passed if (entry.Type == 'Meeting') { var compareTime = ((endDate == null) ? date.getTime() : endDate.getTime()); if (now.getTime() > compareTime) { - console.info('skipping Meeting (already passed) ' + entry.id); + log('skipping Meeting (already passed) ' + entry.id); counter--; eventIds[entry.id] = 0; continue; @@ -698,7 +699,7 @@ function updateData() if (entry.Type == 'Anniversary') { var tmp = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0,0,0); if (date.getTime() < tmp.getTime()) { - console.info('skipping Anniversary (already passed) ' + entry.id); + log('skipping Anniversary (already passed) ' + entry.id); counter--; eventIds[entry.id] = 0; continue; @@ -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 if (entry.Type == 'DayEvent' && endDate != null) { endDate.setMinutes(endDate.getMinutes() - 1); - console.info('fixing DayEvent endDate: ' + endDate); + log('fixing DayEvent endDate: ' + endDate); if (now.getTime() > endDate.getTime()) { - console.info('event already passed ' + entry.id); + log('event already passed ' + entry.id); counter--; eventIds[entry.id] = 0; continue; @@ -722,13 +723,13 @@ function updateData() // check if we are between start and endtime if ((date.getTime() < now.getTime()) && (now.getTime() < endDate.getTime())) { date = now; // change appointment date/time to now - console.info('event is currently taking place: ' + date); + log('event is currently taking place: ' + date); } } // skip events for the first panel in case this is the second one and we're not in fullscreen mode if (mode == 0 && panelNum > 0 && counter < panelNum * config['eventsPerWidget'].Value + 1) { - console.info('skipping (already in first widget) ' + entry.id); + log('skipping (already in first widget) ' + entry.id); continue; } @@ -824,7 +825,7 @@ function updateScreen() var time = new Date(); if (time.getTime() - lastUpdateTime.getTime() > config['updateDataInterval'].Value * 60 * 1000) { - console.info('updateScreen(): force updateData() because last update was too long ago (' + (time.getTime() - lastUpdateTime.getTime()) / 1000 + 's)'); + log('updateScreen(): force updateData() because last update was too long ago (' + (time.getTime() - lastUpdateTime.getTime()) / 1000 + 's)'); clearUpdateTimer(); updateData(); setUpdateTimer(); // reinitialize update timer @@ -845,7 +846,7 @@ function launchCalendar() function init() { - console.info('New widget instance starting up...'); + log('New widget instance starting up...'); try { // call calendar service @@ -872,12 +873,12 @@ function init() else { mode = 1; } - console.info("init(): updateScreen()"); + log("init(): updateScreen()"); updateScreen(); if (config['useBackgroundImage'].Value) // check for screen rotation every 1 secs screenRotationTimer = window.setInterval('updateScreen()', 1000 * 1); - console.info("init(): finished..."); + log("init(): finished..."); } function setUpdateTimer() @@ -892,7 +893,7 @@ function clearUpdateTimer() function updateTimerCallback() { - console.info("updateTimerCallback()"); + log("updateTimerCallback()"); updateData(); } @@ -1049,7 +1050,7 @@ function getSettingsCalEntryId() var entry = list.getNext(); if (entry != undefined) { settingsCalEntryId = entry.LocalId; - console.info("settingsCalEntryId=" + settingsCalEntryId); + log("settingsCalEntryId=" + settingsCalEntryId); } else { // create settings item var item = new Object(); @@ -1096,7 +1097,7 @@ function loadSettings() } var entry = result.ReturnValue.getNext(); if (entry != undefined) { - console.info("Loading Settings..."); + log("Loading Settings..."); // only reload settings if they chanced since the last reload if (settingsCache != entry.Summary) { @@ -1107,7 +1108,7 @@ function loadSettings() var pair = stringlist[i].split('='); var key = pair[0]; var value = pair[1]; - console.info('stringlist: ' + key + '=\'' + value + '\''); + log('stringlist: ' + key + '=\'' + value + '\''); if (config[key].Type == 'Int') config[key].Value = Number(value); else if (config[key].Type == 'String') @@ -1129,7 +1130,7 @@ function loadSettings() updateCssClasses(); } else { - console.info("Settings already cached and did not change"); + log("Settings already cached and did not change"); } } else { @@ -1166,7 +1167,7 @@ function saveSettings() criteria.Type = "CalendarEntry"; criteria.Item = item; - console.info("Saving settings to calendar entry: " + item.Summary); + log("Saving settings to calendar entry: " + item.Summary); try { var result = calendarService.IDataSource.Add(criteria); if (result.ErrorCode) @@ -1223,7 +1224,7 @@ function updateFullscreen() function showFullscreen() { - console.info("showFullscreen()"); + log("showFullscreen()"); hideViews(); document.getElementById("fullscreenView").style.display = "block"; document.getElementById('body').className = "backgroundFullscreen"; @@ -1271,7 +1272,7 @@ function updateHomescreen() function showHomescreen() { - console.info("showHomescreen()"); + log("showHomescreen()"); hideViews(); document.getElementById("homescreenView").style.display = "block"; document.getElementById('body').className = "background"; @@ -1373,7 +1374,7 @@ function listCalendars() while (( item = calendarListIterator.getNext()) != undefined ) { calendars[count++] = item; } - console.info("Available Calendars: " + calendars.join(", ")); + log("Available Calendars: " + calendars.join(", ")); return calendars; } catch(e) { error('listing calendars:' + e + ', line ' + e.line); @@ -1400,14 +1401,14 @@ function listToArray(list, calendarName) array.push(itemCopy); txt += array[array.length - 1].Summary + ", "; } - console.info("listToArray(): " + txt); + log("listToArray(): " + txt); return array; } function sortCalendarEntries(a, b) { var atime, btime; - console.info("sortCalendarEntries(" + a.Summary + "," + b.Summary + ")"); + log("sortCalendarEntries(" + a.Summary + "," + b.Summary + ")"); if (a.InstanceStartTime != null) { atime = a.InstanceStartTime; @@ -1502,13 +1503,19 @@ function updateCalendarColors() var maxColors = 6; calendarColors = []; if (calendarList.length > maxColors) { - console.info("updateCalendarColors(): Warning: more calendars than available indicator colors"); + log("updateCalendarColors(): Warning: more calendars than available indicator colors"); } for(var i=0; i < calendarList.length; i++) { calendarColors[calendarList[i]] = (i % maxColors) + 1; } } +function log(message) { + if (config['enableLogging'].Value) { + console.info(message); + } +} +