more updater stuff

This commit is contained in:
Ryan Nematz 2017-10-12 14:25:47 -04:00
parent d6446d2bfb
commit 071ad79415
4 changed files with 60 additions and 1 deletions

View File

@ -1,3 +1,3 @@
function currentReleaseVersion() { function currentReleaseVersion() {
return 2.0; return 200;
} }

View File

@ -31,6 +31,15 @@ body, html {
#rzFooterText { #rzFooterText {
text-align: center; text-align: center;
} }
/* updater styles */
#updateNotifier {
display:none;
}
.showUpdate {
display: block !important;
}
a:link { color: blue; } a:link { color: blue; }
a:hover { color: blue; } a:hover { color: blue; }
a:active { color: blue; } a:active { color: blue; }

View File

@ -18,6 +18,9 @@
<button id="rzSearchSubmit" onClick="rzSearch();">Search</button> <button id="rzSearchSubmit" onClick="rzSearch();">Search</button>
</div> </div>
<div id="rzFooter"> <div id="rzFooter">
<p id="updateNotifier">
new version available
</p>
<p id="rzFooterText"> <p id="rzFooterText">
<a href="http://retrozilla.no-ip.org" class="rzFooterlink"> <a href="http://retrozilla.no-ip.org" class="rzFooterlink">
RetroZilla RetroZilla

View File

@ -4,11 +4,28 @@
// about:home JS // 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 // XPCOM preferences integration
var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch); var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
var aboutHomeAutofocus = prefs.getBoolPref("rzHome.autofocus"); var aboutHomeAutofocus = prefs.getBoolPref("rzHome.autofocus");
var searchEngineURL = prefs.getCharPref("keyword.URL"); var searchEngineURL = prefs.getCharPref("keyword.URL");
var currentUsedVersion = prefs.getIntPref("retrozilla.version");
//check to see if custom search pref url exists //check to see if custom search pref url exists
var prefServiceBranch = Components.classes["@mozilla.org/preferences-service;1"] var prefServiceBranch = Components.classes["@mozilla.org/preferences-service;1"]
@ -26,15 +43,45 @@ function autoFocus() {
document.getElementById("rzSearch").focus(); 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) // onload function (used to allow for autofocus)
window.onload = function() { window.onload = function() {
if (aboutHomeAutofocus == true) { if (aboutHomeAutofocus == true) {
autoFocus(); autoFocus();
} }
alert(currentUsedVersion);
// set current year // set current year
var d = new Date(); var d = new Date();
var cYear = d.getFullYear(); var cYear = d.getFullYear();
document.getElementById("currentYear").innerHTML = cYear; document.getElementById("currentYear").innerHTML = cYear;
checkForUpdate();
}; };
// function that runs when the "Search" button is clicked // function that runs when the "Search" button is clicked