Skip to content
Open
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
31 changes: 26 additions & 5 deletions Pages/packages/details.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,13 @@ else
<small style="color:#777;">@((package.Content.Sum(x=>x.SizeInBytes)+package.Tools.Sum(x=>x.SizeInBytes)).ToString("#,0")) bytes</small>
}

<form class="form-inline" style="margin-top: 0.5em;">
<input id="asearch" type="search" class="form-control" placeholder="Search"
autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
style="margin-bottom:1em;" />
<form id="asearchform" class="form-inline" style="margin-top: 0.5em;">
<div class="form-group has-feedback">
<input id="asearch" type="search" class="form-control" placeholder="Search"
autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"
style="margin-bottom: 1em;"/>
<span id="asearchloading" class="loader form-control-feedback hidden"></span>
</div>
</form>

<nav id="anav">
Expand Down Expand Up @@ -593,10 +596,22 @@ else
var packageDescription = @Html.Raw(Json.Serialize(package.Description));

var asearch = document.getElementById("asearch");
var asearchloading = document.getElementById("asearchloading");
var asearchform = document.getElementById("asearchform");
var anav = document.getElementById("anav");
if (asearch && anav) {
var searchResults = {};
var rhtml = null;
function showSearchLoading() {
if (asearchloading.classList.contains("hidden")) {
asearchloading.classList.remove("hidden");
}
}
function hideSearchLoading() {
if (!asearchloading.classList.contains("hidden")) {
asearchloading.classList.add("hidden");
}
}
function showResults(r) {
function c(t) { return document.createElement(t); }
function getIcon(t) {
Expand Down Expand Up @@ -637,11 +652,13 @@ else
ul.appendChild(li);
});
anav.hidden = true;
asearch.parentElement.appendChild (rhtml);
asearchform.appendChild (rhtml);
hideSearchLoading();
}
function hideResults() {
if (rhtml) rhtml.remove ();
anav.hidden = false;
hideSearchLoading();
}
function queryResults(text, k) {
var req = new XMLHttpRequest();
Expand All @@ -655,6 +672,7 @@ else
req.send();
}
function doSearch() {
showSearchLoading();
var text = (asearch.value+"").trim();
if (text.length == 0) {
hideResults();
Expand All @@ -674,5 +692,8 @@ else
asearch.addEventListener("input", function (e) {
doSearch();
});
asearchform.addEventListener("submit", function(e) {
e?.preventDefault();
});
}
</script>
19 changes: 19 additions & 0 deletions wwwroot/css/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,26 @@ a .boxcontents {
opacity: 65%;
}

.loader {
width: 34px;
height: 34px;
border: 4px solid #449d44;
border-bottom-color: transparent;
border-radius: 50%;
display: inline-block;
box-sizing: border-box;
animation: rotation 1s linear infinite;
}

@keyframes rotation {
0% {
transform: rotate(0deg);
}

100% {
transform: rotate(360deg);
}
}

@media (prefers-color-scheme: dark) {
body, .dropdown-menu, ul.dropdown-menu>li>a {
Expand Down