05/24 Enhance functionalities 2

This commit is contained in:
2026-05-24 23:04:55 -04:00
parent cb98c7e222
commit 13f8ba124d
11 changed files with 309 additions and 77 deletions
+31 -2
View File
@@ -3,7 +3,18 @@
{% block content %}
<div class="page-header">
<h1 class="page-title">Website Link Management</h1>
<button class="btn btn-primary" onclick="openModal('modal-create-site')"> Add Website</button>
<div style="display:flex;gap:.5rem;align-items:center">
<div class="search-wrap" style="max-width:220px">
<span class="search-icon">🔍</span>
<input type="text" id="site-search" placeholder="Search name or URL…" autocomplete="off">
</div>
<select id="site-type-filter" class="form-control" style="width:auto">
<option value="">All types</option>
<option value="daily">Daily</option>
<option value="weekly">Weekly</option>
</select>
<button class="btn btn-primary" onclick="openModal('modal-create-site')"> Add Website</button>
</div>
</div>
<div class="card">
@@ -13,7 +24,9 @@
</thead>
<tbody>
{% for w in websites %}
<tr class="{{ 'row-weekly' if w.check_type == 'weekly' else '' }}">
<tr class="{{ 'row-weekly' if w.check_type == 'weekly' else '' }} site-row"
data-name="{{ w.name | lower }}" data-url="{{ w.url | lower }}"
data-type="{{ w.check_type }}">
<td>{{ w.id }}</td>
<td><strong>{{ w.name }}</strong></td>
<td><span class="badge badge-{{ 'warn' if w.check_type == 'weekly' else 'neutral' }}">{{ w.check_type }}</span></td>
@@ -172,5 +185,21 @@ function addCredRow(btn) {
}
function removeRow(btn) { btn.closest('.cred-row').remove(); }
function esc(s) { return (s||'').replace(/&/g,'&amp;').replace(/"/g,'&quot;').replace(/</g,'&lt;'); }
(function() {
var searchEl = document.getElementById('site-search');
var typeEl = document.getElementById('site-type-filter');
function filterSites() {
var q = searchEl.value.trim().toLowerCase();
var type = typeEl.value;
document.querySelectorAll('.site-row').forEach(function(row) {
var nameMatch = !q || row.dataset.name.includes(q) || row.dataset.url.includes(q);
var typeMatch = !type || row.dataset.type === type;
row.style.display = (nameMatch && typeMatch) ? '' : 'none';
});
}
searchEl.addEventListener('input', filterSites);
typeEl.addEventListener('change', filterSites);
})();
</script>
{% endblock %}