devshort

private self-hosted shortlink service
git clone https://git.clttr.info/devshort.git
Log (Feed) | Files | Refs (Tags) | README | LICENSE

commit 1aee26df4fb7e98ef8790bfa746013554a9f4efc
parent 3708545f0d294b8cc50a6aa56d83e781fc2e2a6d
Author: Florian <flokX@users.noreply.github.com>
Date:   Tue, 17 Dec 2019 15:41:17 +0100

Add search

Diffstat:
Madmin/index.php | 8++++++++
Madmin/main.js | 15++++++++++++++-
2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/admin/index.php b/admin/index.php @@ -82,6 +82,14 @@ if ($config_content["settings"]["custom_links"]) { </form> </div> </div> + <div class="card mb-3"> + <div class="card-body"> + <h5 class="card-title">Search</h5> + <form> + <input class="form-control" id="search-bar" type="text"> + </form> + </div> + </div> <div class="d-flex justify-content-center"> <div class="spinner-border text-primary" id="spinner" role="status"> <span class="sr-only">Loading...</span> diff --git a/admin/main.js b/admin/main.js @@ -43,6 +43,19 @@ document.getElementById('add-form').addEventListener('submit', function (event) spinner.style.display = 'none'; }); +var searchBox = document.getElementById('search-bar'); +searchBox.addEventListener('input', function (event) { + 'use strict'; + for (let node of chartsDiv.childNodes) { + let linkName = node.firstElementChild.innerHTML.toLowerCase(); + if (linkName.includes(searchBox.value.toLowerCase())) { + node.style.display = 'block'; + } else { + node.style.display = 'none'; + } + } +}); + document.getElementById('refresh').addEventListener('click', function (event) { 'use strict'; event.preventDefault(); @@ -51,7 +64,7 @@ document.getElementById('refresh').addEventListener('click', function (event) { function getCharts() { 'use strict'; - spinner.style.display = ''; + spinner.style.display = 'block'; while (chartsDiv.firstChild) { chartsDiv.firstChild.remove(); }