From 071ad79415bc16d7740d3a9902c3207945f387d7 Mon Sep 17 00:00:00 2001 From: Ryan Nematz Date: Thu, 12 Oct 2017 14:25:47 -0400 Subject: [PATCH] more updater stuff --- update/currentReleaseVersion.js | 2 +- xpfe/global/resources/content/aboutHome.css | 9 ++++ xpfe/global/resources/content/aboutHome.html | 3 ++ xpfe/global/resources/content/aboutHome.js | 47 ++++++++++++++++++++ 4 files changed, 60 insertions(+), 1 deletion(-) diff --git a/update/currentReleaseVersion.js b/update/currentReleaseVersion.js index 312a9f71..9532de45 100644 --- a/update/currentReleaseVersion.js +++ b/update/currentReleaseVersion.js @@ -1,3 +1,3 @@ function currentReleaseVersion() { - return 2.0; + return 200; } \ No newline at end of file diff --git a/xpfe/global/resources/content/aboutHome.css b/xpfe/global/resources/content/aboutHome.css index 0873e328..e370beb0 100644 --- a/xpfe/global/resources/content/aboutHome.css +++ b/xpfe/global/resources/content/aboutHome.css @@ -31,6 +31,15 @@ body, html { #rzFooterText { text-align: center; } + /* updater styles */ +#updateNotifier { + display:none; +} + +.showUpdate { + display: block !important; +} + a:link { color: blue; } a:hover { color: blue; } a:active { color: blue; } diff --git a/xpfe/global/resources/content/aboutHome.html b/xpfe/global/resources/content/aboutHome.html index 376b0e70..296131f1 100644 --- a/xpfe/global/resources/content/aboutHome.html +++ b/xpfe/global/resources/content/aboutHome.html @@ -18,6 +18,9 @@
+

+ new version available +

RetroZilla diff --git a/xpfe/global/resources/content/aboutHome.js b/xpfe/global/resources/content/aboutHome.js index 525ffe6a..c229cc58 100644 --- a/xpfe/global/resources/content/aboutHome.js +++ b/xpfe/global/resources/content/aboutHome.js @@ -4,11 +4,28 @@ // about:home JS + +/* + +WORK THAT NEEDS TO BE DONE HERE: +================================ +- the current version is taken from prefs and stored in cUV (ln 28) +- a way needs to be found to access cUV from a function +- source code from test needs to be incorporated into here and the .html +- a more elaborate update notification needs to be designed and properly placed in the rzHome page +- then it needs to be hidden +- build and test this source code +- bitch at XUL when it tells you that you can't access outside scripts from a chrome process (hopefully not, but it's likely) +- once this all works clean up this clusterfuck of a script + +*/ + // XPCOM preferences integration var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch); var aboutHomeAutofocus = prefs.getBoolPref("rzHome.autofocus"); var searchEngineURL = prefs.getCharPref("keyword.URL"); +var currentUsedVersion = prefs.getIntPref("retrozilla.version"); //check to see if custom search pref url exists var prefServiceBranch = Components.classes["@mozilla.org/preferences-service;1"] @@ -26,15 +43,45 @@ function autoFocus() { document.getElementById("rzSearch").focus(); } +// update checker function +function checkForUpdate() { + var img = document.createElement("img"); + img.onload = function() { + // connected + + // add JS file with newest version # to page + var h = document.getElementsByTagName('head').item(0); + var newScript = document.createElement('script'); + newScript.src = "https://raw.githubusercontent.com/rn10950/RetroZilla/master/update/currentReleaseVersion.js"; + h.appendChild(newScript); + // wait for script to load + setTimeout(function () { + //alert(currentReleaseVersion()); + var currentUsedVersionn = 1; + if(currentUsedVersionn < currentReleaseVersion()) { + // used version older or equal + alert("using older version"); + document.getElementById("updateNotifier").setAttribute("class", "showUpdate"); + } + }, 500); + }; + img.onerror = function() { + // not connected + }; + img.src = "https://raw.githubusercontent.com/rn10950/RetroZilla/master/update/ping.gif"; +} + // onload function (used to allow for autofocus) window.onload = function() { if (aboutHomeAutofocus == true) { autoFocus(); } + alert(currentUsedVersion); // set current year var d = new Date(); var cYear = d.getFullYear(); document.getElementById("currentYear").innerHTML = cYear; + checkForUpdate(); }; // function that runs when the "Search" button is clicked