mirror of
https://github.com/pi-hole/web.git
synced 2026-04-19 16:30:52 +01:00
@@ -1,73 +1,80 @@
|
||||
/* Pi-hole: A black hole for Internet advertisements
|
||||
* (c) 2017 Pi-hole, LLC (https://pi-hole.net)
|
||||
* Network-wide ad blocking via your own hardware.
|
||||
*
|
||||
* This file is copyright under the latest version of the EUPL.
|
||||
* Please see LICENSE file for your rights under this license. */
|
||||
* (c) 2017 Pi-hole, LLC (https://pi-hole.net)
|
||||
* Network-wide ad blocking via your own hardware.
|
||||
*
|
||||
* This file is copyright under the latest version of the EUPL.
|
||||
* Please see LICENSE file for your rights under this license. */
|
||||
|
||||
function eventsource() {
|
||||
var alInfo = $("#alInfo");
|
||||
var alSuccess = $("#alSuccess");
|
||||
var ta = $("#output");
|
||||
var alInfo = $("#alInfo");
|
||||
var alSuccess = $("#alSuccess");
|
||||
var ta = $("#output");
|
||||
|
||||
// IE does not support EventSource - exit early
|
||||
if (typeof EventSource !== "function") {
|
||||
ta.show();
|
||||
ta.html("Updating lists of ad-serving domains is not supported with this browser!");
|
||||
return;
|
||||
}
|
||||
var source = new EventSource("scripts/pi-hole/php/gravity.sh.php");
|
||||
|
||||
ta.html("");
|
||||
// IE does not support EventSource - exit early
|
||||
if (typeof EventSource !== "function") {
|
||||
ta.show();
|
||||
alInfo.show();
|
||||
alSuccess.hide();
|
||||
ta.html("Updating lists of ad-serving domains is not supported with this browser!");
|
||||
return;
|
||||
}
|
||||
|
||||
source.addEventListener("message", function(e) {
|
||||
if(e.data.indexOf("Pi-hole blocking is") !== -1)
|
||||
{
|
||||
alSuccess.show();
|
||||
}
|
||||
var source = new EventSource("scripts/pi-hole/php/gravity.sh.php");
|
||||
|
||||
// Detect ${OVER}
|
||||
if(e.data.indexOf("<------") !== -1)
|
||||
{
|
||||
ta.text(ta.text().substring(0, ta.text().lastIndexOf("\n")) + "\n");
|
||||
var new_string = e.data.replace("<------", "");
|
||||
ta.append(new_string);
|
||||
}
|
||||
else
|
||||
{
|
||||
ta.append(e.data);
|
||||
}
|
||||
ta.html("");
|
||||
ta.show();
|
||||
alInfo.show();
|
||||
alSuccess.hide();
|
||||
|
||||
}, false);
|
||||
source.addEventListener(
|
||||
"message",
|
||||
function(e) {
|
||||
if (e.data.indexOf("Pi-hole blocking is") !== -1) {
|
||||
alSuccess.show();
|
||||
}
|
||||
|
||||
// Will be called when script has finished
|
||||
source.addEventListener("error", function() {
|
||||
alInfo.delay(1000).fadeOut(2000, function() { alInfo.hide(); });
|
||||
source.close();
|
||||
$("#gravityBtn").removeAttr("disabled");
|
||||
}, false);
|
||||
// Detect ${OVER}
|
||||
if (e.data.indexOf("<------") !== -1) {
|
||||
ta.text(ta.text().substring(0, ta.text().lastIndexOf("\n")) + "\n");
|
||||
var new_string = e.data.replace("<------", "");
|
||||
ta.append(new_string);
|
||||
} else {
|
||||
ta.append(e.data);
|
||||
}
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
// Will be called when script has finished
|
||||
source.addEventListener(
|
||||
"error",
|
||||
function() {
|
||||
alInfo.delay(1000).fadeOut(2000, function() {
|
||||
alInfo.hide();
|
||||
});
|
||||
source.close();
|
||||
$("#gravityBtn").removeAttr("disabled");
|
||||
},
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
$("#gravityBtn").on("click", function(){
|
||||
$("#gravityBtn").attr("disabled", true);
|
||||
eventsource();
|
||||
$("#gravityBtn").on("click", function() {
|
||||
$("#gravityBtn").attr("disabled", true);
|
||||
eventsource();
|
||||
});
|
||||
|
||||
// Handle hiding of alerts
|
||||
$(function(){
|
||||
$("[data-hide]").on("click", function(){
|
||||
$(this).closest("." + $(this).attr("data-hide")).hide();
|
||||
});
|
||||
$(function() {
|
||||
$("[data-hide]").on("click", function() {
|
||||
$(this)
|
||||
.closest("." + $(this).attr("data-hide"))
|
||||
.hide();
|
||||
});
|
||||
|
||||
// Do we want to start updating immediately?
|
||||
// gravity.php?go
|
||||
var searchString = window.location.search.substring(1);
|
||||
if(searchString.indexOf("go") !== -1)
|
||||
{
|
||||
$("#gravityBtn").attr("disabled", true);
|
||||
eventsource();
|
||||
}
|
||||
// Do we want to start updating immediately?
|
||||
// gravity.php?go
|
||||
var searchString = window.location.search.substring(1);
|
||||
if (searchString.indexOf("go") !== -1) {
|
||||
$("#gravityBtn").attr("disabled", true);
|
||||
eventsource();
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user