Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redesign domain search input field #2957

Merged
merged 3 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions scripts/pi-hole/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ $(function () {
}
});

function eventsource(partial) {
function doSearch() {
const ta = $("#output");
// process with the current visible domain input field
const q = $("input[id^='domain']:visible").val().trim().toLowerCase();
const N = $("#number").val();
// Partial matching?
const partial = $("#partialMatch").is(":checked");

if (q.length === 0) {
return;
Expand Down Expand Up @@ -197,17 +199,11 @@ function eventsource(partial) {
$("#domain").on("keypress", function (e) {
if (e.which === 13) {
// Enter was pressed, and the input has focus
eventsource(false);
doSearch();
}
});

// Handle search buttons
$("button[id^='btnSearch']").on("click", function () {
var partial = false;

if (!this.id.match("^btnSearchExact")) {
partial = true;
}

eventsource(partial);
$("button[id='btnSearch']").on("click", function () {
doSearch();
});
22 changes: 15 additions & 7 deletions search.lp
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,29 @@ mg.include('scripts/pi-hole/lua/header_authenticated.lp','r')
<div class="col-md-12">
<div class="box">
<div class="box-header">
<!-- domain-search-block - Single search field mobile/desktop -->
<div id="domain-search-block" class="input-group">
<input id="domain" type="url" class="form-control" placeholder="Domain to look for (example.com or sub.example.com)" autocomplete="off" spellcheck="false" autocapitalize="none" autocorrect="off">
<input id="quiet" type="hidden" value="no">
<span class="input-group-btn">
<button type="button" id="btnSearch" class="btn btn-default">Search partial match</button>
<button type="button" id="btnSearchExact" class="btn btn-default">Search exact match</button>
<button type="button" id="btnSearch" class="btn btn-default">Search</button>
</span>
</div>
</div>
<div class="box-body">
<!-- /domain-search-block -->
<div id="limitbox-block" class="form-inline">
<input class="form-control input-sm" type="number" min="0" value="20" id="number">
<label for="number">Maximum of results to be returned</label>
<div class="row">
<div class="col-md-4">
<div>
<input type="checkbox" id="partialMatch" data-key="partialMatch">
<label for="partialMatch"><strong>Use partial matching</strong></label>
</div>
</div>
<br class="hidden-md hidden-lg">
<div class="col-md-8">
<div id="domain-limitbox-block" class="form-inline">
<label for="number">Maximum number of results to be returned:&nbsp;</label>
<input class="form-control input-sm" type="number" min="0" value="20" id="number">
</div>
</div>
</div>
</div>
</div>
Expand Down
24 changes: 11 additions & 13 deletions style/pi-hole.css
Original file line number Diff line number Diff line change
Expand Up @@ -562,19 +562,6 @@ td.details-control {
}

@media screen and (max-width: 991px) {
#domain-search-block {
display: block;
}
#domain {
margin: 5px 0;
}
#domain-search-block .input-group-btn {
display: inline-block;
}
#domain-search-block .input-group-btn button {
margin: 0 5px 0 0;
border-radius: 3px;
}
.settings-container {
--number-of-columns: 1;
}
Expand Down Expand Up @@ -1478,3 +1465,14 @@ table.dataTable tbody > tr > .selected {
overflow-wrap: break-word;
inline-size: auto;
}

/* Search page options */
#domain-limitbox-block {
/* Add margin to match the other component (icheck) height */
margin: 3px 0;
}
@media (min-width: 992px) {
#domain-limitbox-block {
text-align: right;
}
}
Loading