Skip to content

Commit 55c22d3

Browse files
author
Savina Shen (Manpower Services Taiwan Co Ltd)
committed
fix search results
1 parent dc6abd3 commit 55c22d3

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

‎Static/index.html‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@
120120
<div id="cookie-banner"></div>
121121
</div>
122122

123+
<div id="resultsCount" aria-live="polite" style="opacity: 0; width: 0.1px; height: 0.1px"></div>
124+
123125
<main id="main">
124126

125127
<div class="container px-4 py-5">

‎Static/samples.js‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ function showSearchFromUrl() {
4141

4242
var query = search.toLowerCase();
4343
var found = false;
44+
var count = 0;
4445

4546
$.each(data.Categories, function (index, value) {
4647
$.each(value.Samples, function (index, value) {
@@ -50,11 +51,14 @@ function showSearchFromUrl() {
5051
$('#sampleList').append(`<div class="col"><div class="card shadow-sm"><img class="card-img-top" src="${value.Path}/${value.Screenshot}" loading="lazy" alt="${value.Title}" /><div class="card-body"><h5 class="card-title">${value.Title}</h5><p class="card-text">${value.Description}</p><div class="d-flex justify-content-between align-items-center"><div class="btn-group"><button type="button" class="btn btn-sm btn-outline-secondary" data-bs-toggle="modal" data-bs-target="#sampleModal" data-bs-id="${value.Id}" data-bs-title="${value.Title}" data-bs-path="${value.Path}" data-bs-source="${data.GitHub}${value.Source}")"><small>Run Sample</small></button><a href="${value.Path}" target="_blank" class="btn btn-sm btn-outline-secondary" role="button"><small>Open In New Tab</small></a><a href="${data.GitHub}${value.Source}" target="_blank" class="btn btn-sm btn-outline-secondary" role="button"><small>Source Code</small></a></div></div></div></div></div>`);
5152

5253
found = true;
54+
count += 1;
5355
}
5456
});
5557
});
5658

5759
if (!found) $("#sampleList").append('<div class="w-100"><div class="alert alert-warning" role="alert">Sorry, no samples matching your search criteria were found.</div></div>');
60+
61+
$('#resultsCount').html(count > 0 ? `<p>${count} result${count == 1 ? ' is' :'s are'} available, use tab key to navigate.</p>`: '');
5862
}
5963
}
6064

0 commit comments

Comments
 (0)