Use two different divs for mobile and desktop instead of a JS solution

Signed-off-by: Th3M3 <the_me@outlook.de>
Co-Authored-By: XhmikosR <xhmikosr@gmail.com>
This commit is contained in:
Th3M3
2020-05-13 13:07:45 +02:00
parent 9c6a582cb2
commit 38e7cb8e73
2 changed files with 32 additions and 41 deletions

View File

@@ -50,7 +50,8 @@ function httpGet(ta, quiet, theUrl) {
function eventsource() {
var ta = $("#output");
var domain = $("#domain").val().trim();
// process with the current visible domain input field
var domain = $("input[id^='domain']:visible").val().trim();
var q = $("#quiet");
if (domain.length === 0) {
@@ -68,7 +69,7 @@ function eventsource() {
httpGet(
ta,
quiet,
"scripts/pi-hole/php/queryads.php?domain=" + domain.toLowerCase() + exact + "&IE"
"scripts/pi-hole/php/queryads.php?domain=" + domain.toLowerCase() + "&" + exact + "&IE"
);
return;
}
@@ -106,41 +107,22 @@ function eventsource() {
exact = "";
}
// Handle enter button
$(document).keypress(function (e) {
if (e.which === 13 && $("#domain").is(":focus")) {
// Handle enter key
$("#domain_1, #domain_2").keypress(function (e) {
if (e.which === 13) {
// Enter was pressed, and the input has focus
exact = "";
eventsource();
}
});
// Handle button
$("#btnSearch").on("click", function () {
exact = "";
eventsource();
});
// Handle exact button
$("#btnSearchExact").on("click", function () {
exact = "exact";
eventsource();
});
// Wrap form-group's buttons to next line when viewed on a small screen
$(window).on("resize", function () {
if ($(window).width() < 991) {
$(".form-group.input-group").removeClass("input-group").addClass("input-group-block");
$(".form-group.input-group-block > input").css("margin-bottom", "5px");
$(".form-group.input-group-block > .input-group-btn")
.removeClass("input-group-btn")
.addClass("btn-block text-center");
} else {
$(".form-group.input-group-block").removeClass("input-group-block").addClass("input-group");
$(".form-group.input-group > input").css("margin-bottom", "");
$(".form-group.input-group > .btn-block.text-center")
.removeClass("btn-block text-center")
.addClass("input-group-btn");
// Handle search buttons
$("button[id^='btnSearch']").on("click", function () {
exact = "";
if (this.id.match("^btnSearchExact")) {
exact = "exact";
}
});
$(document).ready(function () {
$(window).trigger("resize");
eventsource();
});