Created
December 24, 2010 14:07
-
-
Save follesoe/754257 to your computer and use it in GitHub Desktop.
FreeSMS gadget updated
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /////////////////////////////////////////////////////////////// | |
| // | |
| // Function checking if there is a new version available. | |
| // | |
| /////////////////////////////////////////////////////////////// | |
| function isUpdateAvailable() | |
| { | |
| //Show progress | |
| imgProgress.style.visibility = "visible"; | |
| //Url with version information. | |
| var url = "http://static.follesoe.no/gadgets/gratissms/versioninfo.xml"; | |
| var xmlHttp = new XMLHttpRequest(); | |
| xmlHttp.open("GET", url, true); | |
| xmlHttp.onreadystatechange = function() | |
| { | |
| // Makes sure the document is ready to parse. | |
| if (xmlHttp.readyState === 4) | |
| { | |
| //Hide progress. | |
| imgProgress.style.visibility = "hidden"; | |
| // Makes sure it found the file. | |
| if (xmlHttp.status === 200) | |
| { | |
| var currentVersion = System.Gadget.version; | |
| var newVersion = xmlHttp.responseXML.getElementsByTagName("version")[0].firstChild.nodeValue; | |
| var updateUrl = xmlHttp.responseXML.getElementsByTagName("url")[0].firstChild.nodeValue; | |
| var comment = xmlHttp.responseXML.getElementsByTagName("comment")[0].firstChild.nodeValue; | |
| //Remove dots from the version number and convert it to int. | |
| var nNew = parseInt(removeDots(newVersion)); | |
| var nCur = parseInt(removeDots(currentVersion)); | |
| if(nNew > nCur) | |
| { | |
| showErrorDiv(true); | |
| hrefUpdate.href = updateUrl; | |
| imgError.src = "images/newversion.png"; | |
| imgError.alt = "Last ned ny versjon (" + newVersion + ")\n" + comment; | |
| } | |
| else | |
| { | |
| checkSettings(); | |
| } | |
| } | |
| else | |
| { | |
| showErrorDiv(true); | |
| hrefUpdate.onclick = test; | |
| hrefUpdate.href = ""; | |
| imgError.src = "images/largewarning.png"; | |
| imgError.alt= "Fikk ikke kontakt med oppdateringsserver.\nSjekk internett oppkoblingen din.\nKlikk på ikonet for å ignorere feilmeldingen."; | |
| } | |
| } | |
| } | |
| xmlHttp.send(null); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment