var exact = ""; // Credit: http://stackoverflow.com/a/10642418/2087442 function httpGet(ta,theUrl) { var xmlhttp; if (window.XMLHttpRequest) { // code for IE7+ xmlhttp=new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState === 4 && xmlhttp.status === 200) { ta.show(); ta.html(xmlhttp.responseText); } }; xmlhttp.open("GET", theUrl, false); xmlhttp.send(); } function eventsource() { var ta = $("#output"); var domain = $("#domain"); var q = $("#quiet"); if(domain.val().length === 0) { return; } var quiet = false; if(q.val() === "yes") { quiet = true; exact = "exact"; } // IE does not support EventSource - load whole content at once if (typeof EventSource !== "function") { httpGet(ta,"/admin/scripts/pi-hole/php/queryads.php?domain="+domain.val().toLowerCase()+"&"+exact); return; } var host = window.location.host; var source = new EventSource("/admin/scripts/pi-hole/php/queryads.php?domain="+domain.val().toLowerCase()+"&"+exact); // Reset and show field ta.empty(); ta.show(); source.addEventListener("message", function(e) { if(!quiet) { ta.append(e.data); } else { var lines = e.data.split("\n"); for(var i = 0;i