diff --git a/footer.php b/footer.php index 4a7e59f4..b52bec47 100644 --- a/footer.php +++ b/footer.php @@ -24,57 +24,7 @@ - + diff --git a/header.html b/header.html index e249930a..95fdb976 100644 --- a/header.html +++ b/header.html @@ -2,7 +2,7 @@ - + Pi-hole Admin Console diff --git a/js/pihole/footer.js b/js/pihole/footer.js new file mode 100644 index 00000000..1ee06d80 --- /dev/null +++ b/js/pihole/footer.js @@ -0,0 +1,49 @@ +// User menu toggle +$("#dropdown-menu a").on("click", function(event) { + $(this).parent().toggleClass("open"); +}); +$("body").on("click", function(event) { + if(!$("#dropdown-menu").is(event.target) && $("#dropdown-menu").has(event.target).length === 0) { + $("#dropdown-menu").removeClass("open"); + } +}); + +// Credit for following function: https://gist.github.com/alexey-bass/1115557 +function versionCompare(left, right) { + if (typeof left + typeof right != 'stringstring') + return false; + + var a = left.split('.') + , b = right.split('.') + , i = 0, len = Math.max(a.length, b.length); + + for (; i < len; i++) { + if ((a[i] && !b[i] && parseInt(a[i]) > 0) || (parseInt(a[i]) > parseInt(b[i]))) { + return 1; + } else if ((b[i] && !a[i] && parseInt(b[i]) > 0) || (parseInt(a[i]) < parseInt(b[i]))) { + return -1; + } + } + + return 0; +} + +// Update check +$.getJSON("https://api.github.com/repos/pi-hole/pi-hole/releases/latest", function(json) { + if(versionCompare("", json.tag_name.slice(1)) < 0) { + // Alert user + $("#alPiholeUpdate").show(); + if(!$("#dropdown-menu").hasClass("open")) { + $("#dropdown-menu").addClass("open"); + } + } +}); +$.getJSON("https://api.github.com/repos/pi-hole/AdminLTE/releases/latest", function(json) { + if(versionCompare("", json.tag_name.slice(1)) < 0) { + // Alert user + $("#alWebUpdate").show(); + if(!$("#dropdown-menu").hasClass("open")) { + $("#dropdown-menu").addClass("open"); + } + } +}); \ No newline at end of file