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.
This commit is contained in:
Mcat12
2016-05-26 17:21:39 -04:00
parent 541afbb8c9
commit c537327fbc
2 changed files with 7 additions and 4 deletions
+2 -2
View File
@@ -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");
?>
<b>Pi-hole Version </b> <?php echo $piholeVersion; ?>
<b>Web Interface Version </b> <?php echo $webVersion; ?>
<b>Pi-hole Version </b> <div id="piholeVersion" style="display: inline"><?php echo $piholeVersion; ?></div>
<b>Web Interface Version </b> <div id="webVersion" style="display: inline"><?php echo $webVersion; ?></div>
</div>
<i class="fa fa-github"></i> <strong><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=3J2L3Z4DHW9UY">Donate</a></strong> if you found this useful.
</footer>
+5 -2
View File
@@ -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("<?php echo substr($piholeVersion, 1); ?>", 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("<?php echo substr($webVersion, 1); ?>", json.tag_name.slice(1)) < 0) {
if(versionCompare(webVersion, json.tag_name.slice(1)) < 0) {
// Alert user
$("#alWebUpdate").show();
if(!$("#dropdown-menu").hasClass("open")) {