mirror of
https://github.com/pi-hole/web.git
synced 2025-12-24 20:55:28 +00:00
@@ -22,17 +22,17 @@ function piholeChanged(action)
|
||||
|
||||
switch(action) {
|
||||
case "enabled":
|
||||
status.html("<i class='fa fa-circle' style='color:#7FFF00'></i> Active");
|
||||
ena.hide();
|
||||
dis.show();
|
||||
dis.removeClass("active");
|
||||
break;
|
||||
status.html("<i class='fa fa-circle' style='color:#7FFF00'></i> Active");
|
||||
ena.hide();
|
||||
dis.show();
|
||||
dis.removeClass("active");
|
||||
break;
|
||||
|
||||
case "disabled":
|
||||
status.html("<i class='fa fa-circle' style='color:#FF0000'></i> Offline");
|
||||
ena.show();
|
||||
dis.hide();
|
||||
break;
|
||||
status.html("<i class='fa fa-circle' style='color:#FF0000'></i> Offline");
|
||||
ena.show();
|
||||
dis.hide();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -44,32 +44,76 @@ function piholeChange(action, duration)
|
||||
|
||||
switch(action) {
|
||||
case "enable":
|
||||
btnStatus = $("#flip-status-enable");
|
||||
btnStatus.html("<i class='fa fa-spinner'> </i>");
|
||||
$.getJSON("api.php?enable&token=" + token, function(data) {
|
||||
if(data.status === "enabled") {
|
||||
btnStatus.html("");
|
||||
piholeChanged("enabled");
|
||||
}
|
||||
});
|
||||
break;
|
||||
btnStatus = $("#flip-status-enable");
|
||||
btnStatus.html("<i class='fa fa-spinner'> </i>");
|
||||
$.getJSON("api.php?enable&token=" + token, function(data) {
|
||||
if(data.status === "enabled") {
|
||||
btnStatus.html("");
|
||||
piholeChanged("enabled");
|
||||
}
|
||||
});
|
||||
break;
|
||||
|
||||
case "disable":
|
||||
btnStatus = $("#flip-status-disable");
|
||||
btnStatus.html("<i class='fa fa-spinner'> </i>");
|
||||
$.getJSON("api.php?disable=" + duration + "&token=" + token, function(data) {
|
||||
if(data.status === "disabled") {
|
||||
btnStatus.html("");
|
||||
piholeChanged("disabled");
|
||||
}
|
||||
});
|
||||
break;
|
||||
btnStatus = $("#flip-status-disable");
|
||||
btnStatus.html("<i class='fa fa-spinner'> </i>");
|
||||
$.getJSON("api.php?disable=" + duration + "&token=" + token, function(data) {
|
||||
if(data.status === "disabled") {
|
||||
btnStatus.html("");
|
||||
piholeChanged("disabled");
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//The following three functions allow us to display time until pi-hole is enabled after disabling.
|
||||
//Works between all pages
|
||||
|
||||
|
||||
function setCountdownTarget(seconds){
|
||||
var target = new Date();
|
||||
target = new Date(target.getTime() + seconds * 1000);
|
||||
localStorage.setItem("countDownTarget", target);
|
||||
}
|
||||
|
||||
function secondsTimeSpanToHMS(s) {
|
||||
var h = Math.floor(s/3600); //Get whole hours
|
||||
s -= h*3600;
|
||||
var m = Math.floor(s/60); //Get remaining minutes
|
||||
s -= m*60;
|
||||
return h+":"+(m < 10 ? "0"+m : m)+":"+(s < 10 ? "0"+s : s); //zero padding on minutes and seconds
|
||||
}
|
||||
|
||||
function countDown(){
|
||||
var ena = $("#enableLabel");
|
||||
var target = new Date(localStorage.getItem("countDownTarget"));
|
||||
var seconds = Math.round((target.getTime() - new Date().getTime()) / 1000);
|
||||
|
||||
if(seconds > 0){
|
||||
setTimeout(countDown,1000);
|
||||
ena.text("Enable (" + secondsTimeSpanToHMS(seconds) + ")");
|
||||
}
|
||||
else
|
||||
{
|
||||
ena.text("Enable");
|
||||
piholeChanged("enabled");
|
||||
localStorage.removeItem("countDownTarget");
|
||||
}
|
||||
}
|
||||
|
||||
$( document ).ready(function() {
|
||||
var countDownTarget = localStorage.getItem("countDownTarget");
|
||||
if (countDownTarget != null)
|
||||
{
|
||||
setTimeout(countDown,1000);
|
||||
}
|
||||
});
|
||||
|
||||
// Handle Enable/Disable
|
||||
$("#pihole-enable").on("click", function(e){
|
||||
e.preventDefault();
|
||||
localStorage.removeItem("countDownTarget");
|
||||
piholeChange("enable","");
|
||||
});
|
||||
$("#pihole-disable-permanently").on("click", function(e){
|
||||
@@ -79,18 +123,30 @@ $("#pihole-disable-permanently").on("click", function(e){
|
||||
$("#pihole-disable-10s").on("click", function(e){
|
||||
e.preventDefault();
|
||||
piholeChange("disable","10");
|
||||
setTimeout(function(){piholeChanged("enabled");},10000);
|
||||
setCountdownTarget(10);
|
||||
setTimeout(countDown,1000);
|
||||
});
|
||||
$("#pihole-disable-30s").on("click", function(e){
|
||||
e.preventDefault();
|
||||
piholeChange("disable","30");
|
||||
setTimeout(function(){piholeChanged("enabled");},30000);
|
||||
setCountdownTarget(30);
|
||||
setTimeout(countDown,1000);
|
||||
});
|
||||
$("#pihole-disable-5m").on("click", function(e){
|
||||
e.preventDefault();
|
||||
piholeChange("disable","300");
|
||||
setTimeout(function(){piholeChanged("enabled");},300000);
|
||||
setCountdownTarget(300);
|
||||
setTimeout(countDown,1000);
|
||||
});
|
||||
$("#pihole-disable-custom").on("click", function(e){
|
||||
e.preventDefault();
|
||||
var custVal = $("#customTimeout").val();
|
||||
custVal = $("#btnMins").hasClass("active") ? custVal * 60 : custVal;
|
||||
piholeChange("disable",custVal);
|
||||
setCountdownTarget(custVal);
|
||||
setTimeout(countDown,1000);
|
||||
});
|
||||
|
||||
|
||||
var piholeVersion = $("#piholeVersion").html();
|
||||
var webVersion = $("#webVersion").html();
|
||||
@@ -200,15 +256,15 @@ else
|
||||
// Hide "exact match" button on queryads.php page if version is 2.9.5 or lower
|
||||
if(versionCompare(piholeVersion, "v2.9.5") < 1)
|
||||
{
|
||||
$("#btnSearchExact").hide();
|
||||
$("#btnSearchExact").hide();
|
||||
}
|
||||
|
||||
// Handle Strg + Enter button on Login page
|
||||
$(document).keypress(function(e) {
|
||||
if((e.keyCode === 10 || e.keyCode === 13) && e.ctrlKey && $("#loginpw").is(":focus")) {
|
||||
$("#loginform").attr("action", "settings.php");
|
||||
$("#loginform").submit();
|
||||
}
|
||||
if((e.keyCode === 10 || e.keyCode === 13) && e.ctrlKey && $("#loginpw").is(":focus")) {
|
||||
$("#loginform").attr("action", "settings.php");
|
||||
$("#loginform").submit();
|
||||
}
|
||||
});
|
||||
|
||||
function testCookies()
|
||||
|
||||
Reference in New Issue
Block a user