From c537327fbc62dbb35819d25e7111c8c69f52b76d Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Thu, 26 May 2016 17:21:39 -0400 Subject: [PATCH] Pass version info from php to js Since PHP doesn't run in the sourced js files, it needs to send the version numbers a different way. --- footer.php | 4 ++-- js/pihole/footer.js | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/footer.php b/footer.php index b52bec47..879b60c9 100644 --- a/footer.php +++ b/footer.php @@ -8,8 +8,8 @@ $piholeVersion = exec("cd /etc/.pihole/ && git describe --tags --abbrev=0"); $webVersion = exec("cd /var/www/html/admin/ && git describe --tags --abbrev=0"); ?> - Pi-hole Version - Web Interface Version + Pi-hole Version
+ Web Interface Version
Donate if you found this useful. diff --git a/js/pihole/footer.js b/js/pihole/footer.js index 1ee06d80..a2ec3f78 100644 --- a/js/pihole/footer.js +++ b/js/pihole/footer.js @@ -8,6 +8,9 @@ $("body").on("click", function(event) { } }); +var piholeVersion = $("#piholeVersion").html(); +var webVersion = $("#webVersion").html(); + // Credit for following function: https://gist.github.com/alexey-bass/1115557 function versionCompare(left, right) { if (typeof left + typeof right != 'stringstring') @@ -30,7 +33,7 @@ function versionCompare(left, right) { // Update check $.getJSON("https://api.github.com/repos/pi-hole/pi-hole/releases/latest", function(json) { - if(versionCompare("", json.tag_name.slice(1)) < 0) { + if(versionCompare(piholeVersion, json.tag_name.slice(1)) < 0) { // Alert user $("#alPiholeUpdate").show(); if(!$("#dropdown-menu").hasClass("open")) { @@ -39,7 +42,7 @@ $.getJSON("https://api.github.com/repos/pi-hole/pi-hole/releases/latest", functi } }); $.getJSON("https://api.github.com/repos/pi-hole/AdminLTE/releases/latest", function(json) { - if(versionCompare("", json.tag_name.slice(1)) < 0) { + if(versionCompare(webVersion, json.tag_name.slice(1)) < 0) { // Alert user $("#alWebUpdate").show(); if(!$("#dropdown-menu").hasClass("open")) {