mirror of
https://github.com/pi-hole/web.git
synced 2024-12-06 19:36:21 +01:00
Adjust to CSP
This commit is contained in:
+1
-51
@@ -24,57 +24,7 @@
|
||||
<script src="js/other/dataTables.bootstrap.min.js"></script>
|
||||
<script src="js/other/Chart.min.js"></script>
|
||||
|
||||
<script>
|
||||
// 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("<?php echo substr($piholeVersion, 1); ?>", 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("<?php echo substr($webVersion, 1); ?>", json.tag_name.slice(1)) < 0) {
|
||||
// Alert user
|
||||
$("#alWebUpdate").show();
|
||||
if(!$("#dropdown-menu").hasClass("open")) {
|
||||
$("#dropdown-menu").addClass("open");
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<script src="js/pihole/footer.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self' 'unsafe-eval'; style-src 'self' 'unsafe-inline'">
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self' https://api.github.com; script-src 'self' 'unsafe-eval'; style-src 'self' 'unsafe-inline'">
|
||||
<title>Pi-hole Admin Console</title>
|
||||
<!-- Tell the browser to be responsive to screen width -->
|
||||
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
|
||||
|
||||
@@ -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("<?php echo substr($piholeVersion, 1); ?>", 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("<?php echo substr($webVersion, 1); ?>", json.tag_name.slice(1)) < 0) {
|
||||
// Alert user
|
||||
$("#alWebUpdate").show();
|
||||
if(!$("#dropdown-menu").hasClass("open")) {
|
||||
$("#dropdown-menu").addClass("open");
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user