Update web/templates/search.html

This commit is contained in:
Joshua Laymon 2025-08-17 21:09:17 +00:00
parent 0e10a3c930
commit 82f7ce6ed5

View File

@ -59,11 +59,11 @@
<!-- ===== History Dropdown ===== --> <!-- ===== History Dropdown ===== -->
<div class="card" style="padding:0; margin:16px 0 12px;"> <div class="card" style="padding:0; margin:16px 0 12px;">
<h1 class="page-title dropdown-toggle history-title" <h1 class="page-title dropdown-toggle history-title"
data-target="#history-panel" data-target="#history-panel"
role="button" role="button"
aria-expanded="false"> aria-expanded="false">
Search History <span class="chevron"></span> Search History <span class="chevron"></span>
</h1> </h1>
<div id="history-panel" class="dropdown-panel"> <div id="history-panel" class="dropdown-panel">
<hr style="border:none; border-top:1px solid var(--border); margin:12px 0;"> <hr style="border:none; border-top:1px solid var(--border); margin:12px 0;">
@ -116,11 +116,18 @@
root.classList.remove('fs-small','fs-default','fs-large','fs-xlarge'); root.classList.remove('fs-small','fs-default','fs-large','fs-xlarge');
root.classList.add('fs-'+size); root.classList.add('fs-'+size);
} }
fetch("{% url 'api_get_prefs' %}").then(r=>r.json()).then(j=>{ fetch("{% url 'api_get_prefs' %}", { cache: 'no-store', credentials: 'same-origin' })
if (j.ok) applyFont(j.font_size || 'default'); .then(r=>r.json()).then(j=>{
}).catch(()=>{}); if (j.ok) applyFont(j.font_size || 'default');
}).catch(()=>{});
// Search history (PUT BACK selected-fields subtitle) // Small helper to add a cache-busting param
function bust(url){
const sep = url.includes('?') ? '&' : '?';
return url + sep + 't=' + Date.now();
}
// Search history (keeps selected-fields subtitle)
function renderHistory(items){ function renderHistory(items){
const list = document.getElementById('searchHistoryList'); const list = document.getElementById('searchHistoryList');
const empty = document.getElementById('searchHistoryEmpty'); const empty = document.getElementById('searchHistoryEmpty');
@ -140,9 +147,13 @@
list.appendChild(li); list.appendChild(li);
}); });
} }
fetch("{% url 'api_get_search_history' %}").then(r=>r.json()).then(j=>{ fetch(bust("{% url 'api_get_search_history' %}"), {
if (j.ok) renderHistory(j.items); cache: 'no-store',
}).catch(()=>{}); credentials: 'same-origin'
})
.then(r=>r.json()).then(j=>{
if (j.ok) renderHistory(j.items);
}).catch(()=>{});
// Recently viewed // Recently viewed
function renderRecent(items){ function renderRecent(items){
@ -163,9 +174,13 @@
list.appendChild(li); list.appendChild(li);
}); });
} }
fetch("{% url 'api_get_recent_views' %}").then(r=>r.json()).then(j=>{ fetch(bust("{% url 'api_get_recent_views' %}"), {
if (j.ok) renderRecent(j.items); cache: 'no-store',
}).catch(()=>{}); credentials: 'same-origin'
})
.then(r=>r.json()).then(j=>{
if (j.ok) renderRecent(j.items);
}).catch(()=>{});
// Dropdown toggle for History // Dropdown toggle for History
document.querySelectorAll('.dropdown-toggle').forEach(btn=>{ document.querySelectorAll('.dropdown-toggle').forEach(btn=>{
@ -224,19 +239,15 @@
} }
.page-title.open .chevron { transform: rotate(180deg); } .page-title.open .chevron { transform: rotate(180deg); }
.dropdown-toggle { cursor:pointer; } .dropdown-toggle { cursor:pointer; }
</style>
<style> /* Keep the chevron next to the text */
/* ...keep your existing styles... */
/* Ensure the history heading keeps the chevron next to the text */
.history-title{ .history-title{
display:inline-flex !important; /* don't stretch full width */ display:inline-flex !important;
align-items:center; align-items:center;
justify-content:flex-start !important; justify-content:flex-start !important;
gap:8px; /* space between text and chevron */ gap:8px;
padding:10px 16px; /* left/right white space */ padding:10px 16px;
margin:0; /* remove default h1 margin */ margin:0;
} }
</style> </style>
{% endblock %} {% endblock %}