mirror of
https://github.com/pi-hole/web.git
synced 2024-12-06 19:36:21 +01:00
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:
+2
-2
@@ -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&hosted_button_id=3J2L3Z4DHW9UY">Donate</a></strong> if you found this useful.
|
||||
</footer>
|
||||
|
||||
+5
-2
@@ -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")) {
|
||||
|
||||
Reference in New Issue
Block a user