/* 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. */ /* global utils:false */ var table; var groups = []; var token = $("#token").text(); var GETDict = {}; function getGroups() { $.post( "scripts/pi-hole/php/groups.php", { action: "get_groups", token: token }, function (data) { groups = data.data; initTable(); }, "json" ); } $(function () { window.location.search .substr(1) .split("&") .forEach(function (item) { GETDict[item.split("=")[0]] = item.split("=")[1]; }); // sync description fields, reset inactive inputs on tab change $('a[data-toggle="tab"]').on("shown.bs.tab", function () { var tabHref = $(this).attr("href"); var val; if (tabHref === "#tab_domain") { val = $("#new_regex_comment").val(); $("#new_domain_comment").val(val); $("#new_regex").val(""); } else if (tabHref === "#tab_regex") { val = $("#new_domain_comment").val(); $("#new_regex_comment").val(val); $("#new_domain").val(""); $("#wildcard_checkbox").prop("checked", false); } clearTimeout(suggestTimeout); $("#suggest_domains").hide(); }); $("#add2black, #add2white").on("click", addDomain); var suggestTimeout; $("#new_domain").on("input", function (e) { hideSuggestDomains(); clearTimeout(suggestTimeout); suggestTimeout = setTimeout(showSuggestDomains, 1000, e.target.value); }); utils.setBsSelectDefaults(); getGroups(); }); function showSuggestDomains(value) { function createButton(hostname) { // Purposefully omit 'btn' class to save space on padding return $('