From 6602d5f34313cda36366fc544f39f1f05593c534 Mon Sep 17 00:00:00 2001 From: Michael Prager Date: Sun, 24 Jan 2010 18:45:49 +0100 Subject: [PATCH] added "check for updates" feature --- comingNext/Info.plist | 2 +- comingNext/de.lproj/localizedTextStrings.js | 9 ++ comingNext/fr.lproj/localizedTextStrings.js | 9 ++ comingNext/index.html | 100 ++++++++++++++++--- comingNext/localizedTextStrings.js | 9 ++ comingNextB/Info.plist | 2 +- comingNextB/de.lproj/localizedTextStrings.js | 9 ++ comingNextB/fr.lproj/localizedTextStrings.js | 9 ++ comingNextB/index.html | 100 ++++++++++++++++--- comingNextB/localizedTextStrings.js | 9 ++ 10 files changed, 228 insertions(+), 30 deletions(-) diff --git a/comingNext/Info.plist b/comingNext/Info.plist index 199b9dc..3aa5d5b 100644 --- a/comingNext/Info.plist +++ b/comingNext/Info.plist @@ -6,7 +6,7 @@ Identifier ar.com.cochambre.symbian.wrt.comingnext Version 1.25 MainHTML index.html - AllowNetworkAccess + AllowNetworkAccess MiniViewEnabled diff --git a/comingNext/de.lproj/localizedTextStrings.js b/comingNext/de.lproj/localizedTextStrings.js index fc52b4a..753988c 100644 --- a/comingNext/de.lproj/localizedTextStrings.js +++ b/comingNext/de.lproj/localizedTextStrings.js @@ -3,6 +3,9 @@ var localizedText = new Array(); localizedText['menu.settings'] = 'Einstellungen'; localizedText['menu.openCalendarApp'] = 'Öffne Kalender'; localizedText['menu.about'] = 'Über'; +localizedText['menu.update'] = 'Nach Updates suchen'; + +localizedText['softkey.back'] = 'Zurück'; localizedText['settings.restoreDefaults'] = 'Standardeinstellungen wiederherstellen'; localizedText['settings.help'] = 'Hilfe'; @@ -75,3 +78,9 @@ localizedText['settings.info.cssStyle_description'] = 'Definiert das Aussehen de localizedText['settings.name.cssStyle_icon'] = '.icon'; localizedText['settings.info.cssStyle_icon'] = 'Definiert das Aussehen Icons'; +localizedText['update.current'] = 'Deine Version: '; +localizedText['update.checking'] = 'suche nach Updates...'; +localizedText['update.download'] = 'Aktuelle Version: %1
neue Version herunterladen'; +localizedText['update.nonewversion'] = 'keine neue Version verfügbar'; +localizedText['update.error'] = 'Verbindungsfehler: '; +localizedText['update.checknow'] = 'Jetzt prüfen'; diff --git a/comingNext/fr.lproj/localizedTextStrings.js b/comingNext/fr.lproj/localizedTextStrings.js index 07dc31d..dd0e4d7 100644 --- a/comingNext/fr.lproj/localizedTextStrings.js +++ b/comingNext/fr.lproj/localizedTextStrings.js @@ -3,6 +3,9 @@ var localizedText = new Array(); localizedText['menu.settings'] = 'Parametres'; localizedText['menu.openCalendarApp'] = 'Ouvrir Calendrier'; localizedText['menu.about'] = 'A propos'; +localizedText['menu.update'] = 'Check for new version'; + +localizedText['softkey.back'] = 'Back'; localizedText['settings.restoreDefaults'] = 'Restore Defaults'; localizedText['settings.help'] = 'Aide'; @@ -75,3 +78,9 @@ localizedText['settings.info.cssStyle_description'] = 'Définit l\'apparen localizedText['settings.name.cssStyle_icon'] = '.icon'; localizedText['settings.info.cssStyle_icon'] = 'Définit la taille des icones'; +localizedText['update.current'] = 'Your version: '; +localizedText['update.checking'] = 'checking for updates...'; +localizedText['update.download'] = 'Current version: %1
download new version'; +localizedText['update.nonewversion'] = 'no new versions available'; +localizedText['update.error'] = 'connection error: '; +localizedText['update.checknow'] = 'Check now'; diff --git a/comingNext/index.html b/comingNext/index.html index 965702f..09e6658 100644 --- a/comingNext/index.html +++ b/comingNext/index.html @@ -57,17 +57,20 @@ var config = { } + //------------------------------------------------------- // Nothing of interest from here on... //------------------------------------------------------- var panelNum = 0; // use 1 for second panel var version = "1.25"; +var versionURL = "http://comingnext.sourceforge.net/version.xml"; var calendarService = null; var cacheEntriesHtml = []; var months_translated = []; var orientation = ''; var now = new Date(); -var mode = 0; // 0 = homescreen, 1 = fullscreen, 2 = settings, 3 = about +var mode = 0; // 0 = homescreen, 1 = fullscreen, 2 = settings, 3 = about, 4 = check for update +var reqV = null; // vars for daylight saving time var daylightsavingWinter = 0; @@ -693,22 +696,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; @@ -849,14 +853,12 @@ function printHintBox(text) function showAbout() { mode = 3; - document.getElementById("homescreenView").style.display = "none"; - document.getElementById("fullscreenView").style.display = "none"; + hideViews(); document.getElementById("aboutView").style.display = "block"; - document.getElementById("settingsView").style.display = "none"; document.onclick = null; window.menu.setLeftSoftkeyLabel(" ", function(){}); - window.menu.setRightSoftkeyLabel("Back", function() + window.menu.setRightSoftkeyLabel(getLocalizedText('softkey.back'), function() { mode = 1; showFullscreen(); @@ -872,10 +874,8 @@ function updateFullscreen() function showFullscreen() { - document.getElementById("homescreenView").style.display = "none"; + hideViews(); document.getElementById("fullscreenView").style.display = "block"; - document.getElementById("aboutView").style.display = "none"; - document.getElementById("settingsView").style.display = "none"; document.getElementById('body').className = "backgroundFullscreen"; document.onclick = launchCalendar; createMenu(); @@ -908,10 +908,8 @@ function updateHomescreen() function showHomescreen() { + hideViews(); document.getElementById("homescreenView").style.display = "block"; - document.getElementById("fullscreenView").style.display = "none"; - document.getElementById("aboutView").style.display = "none"; - document.getElementById("settingsView").style.display = "none"; document.getElementById('body').className = "background"; document.onclick = null; updateData(); @@ -924,6 +922,72 @@ function getLocalizedText(p_Txt) else return 'ERROR: missing translation for ' + p_Txt; } + +function showUpdate() +{ + mode = 4; + hideViews(); + document.getElementById("updateView").style.display = "block"; + document.onclick = null; + + window.menu.setLeftSoftkeyLabel(getLocalizedText('update.checknow'), function(){ + checkForUpdate(); + }); + window.menu.setRightSoftkeyLabel(getLocalizedText('softkey.back'), function() + { + mode = 1; + showFullscreen(); + }); + + document.getElementById("currentVersion").innerHTML = getLocalizedText("update.current") + version; + checkForUpdate(); +} + +function checkForUpdate() +{ + // asynch XHR to server url + reqV = new XMLHttpRequest(); + reqV.onreadystatechange = checkForUpdateCallback; + document.getElementById("updateDiv").innerHTML = getLocalizedText("update.checking"); + reqV.open("GET", versionURL, true); + reqV.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" ); // disable caching + reqV.send(null); +} + +function checkForUpdateCallback() +{ + if (reqV.readyState == 4) { + if (reqV.status == 200) { + // little overhead here, one could use also string for version info + var resultXml = reqV.responseText; + if (resultXml) { + var div = document.getElementById("tmp"); + div.innerHTML = resultXml; + var newVersion = div.getElementsByTagName('version')[0].innerHTML; + var newVersionURL = div.getElementsByTagName('url')[0].innerHTML; + div.innerHTML = ""; + if (version != newVersion) { + document.getElementById("updateDiv").innerHTML = getLocalizedText("update.download").replace(/%1/, newVersion).replace(/%2/, newVersionURL); + } + else { + document.getElementById("updateDiv").innerHTML = getLocalizedText("update.nonewversion"); + } + } + } + else { + document.getElementById("updateDiv").innerHTML = getLocalizedText("update.error") + reqV.status + " " + reqV.responseText; + } + } +} + +function hideViews() +{ + document.getElementById("homescreenView").style.display = "none"; + document.getElementById("fullscreenView").style.display = "none"; + document.getElementById("aboutView").style.display = "none"; + document.getElementById("settingsView").style.display = "none"; + document.getElementById("updateView").style.display = "none"; +}