Skip to content

Commit

Permalink
fix: minor
Browse files Browse the repository at this point in the history
  • Loading branch information
akurilov committed Mar 18, 2024
1 parent b8103a1 commit d679586
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
16 changes: 11 additions & 5 deletions web/pub-src-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,7 @@ async function loadSource() {
if (counts != null && Object.keys(counts).length > 0) {
document.getElementById("wait").style.display = "block";
document.body.classList.add('waiting-cursor');
// simulate a blocking I/O to redraw before
fetch("https://awakari.com", {
method: "GET",
cache: "default",
}).finally(() => drawFreqChart(addr, counts));
await drawFreqChart(addr, counts);
}
}

Expand All @@ -164,7 +160,17 @@ async function drawFreqChart(addr, counts) {
const avg = countSum / weekMinutes;
document.getElementById("freq-charts").style.display = "block";
const stepY = freqChartHeight / countMax;
let prevHour = -1;
for (const [t, c] of Object.entries(counts)) {
const weekHour = Math.floor(t / 60);
if (prevHour !== weekHour) {
prevHour = weekHour;
// simulate a blocking I/O to redraw before
await fetch("https://awakari.com", {
method: "GET",
cache: "force-cache",
}).finally(() => console.log(`draw char for the next hour ${weekHour}`));
}
const dayNum = Math.floor(t / dayMinutes);
let chartElement = document.getElementById(`chart-freq-${dayNum}`);
const h = stepY * c;
Expand Down
6 changes: 3 additions & 3 deletions web/pub.html
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
<input id="filter"
type="search"
class="ml-1 border-0 outline-none w-64 dark:bg-gray-800"
oninput="loadSources(new URLSearchParams(window.location.search).get('cursor'), this.value, document.getElementById('src_type').value, document.getElementById('own').checked)"/>
oninput="loadSources('', this.value, document.getElementById('src_type').value, document.getElementById('own').checked)"/>
</div>
</div>
</div>
Expand All @@ -155,13 +155,13 @@
</div>
</div>
<div class="flex items-center justify-center space-x-4 mt-2">
<button id="button-prev" type="button" class="flex justify-center text-center w-[100px] h-6 hover:bg-blue-200">
<button id="button-prev" type="button" class="flex justify-center text-center w-[80px] h-6 hover:bg-blue-200">
<svg width="24px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M6 12H18M6 12L11 7M6 12L11 17" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
<span class="mt-1">Back</span>
</button>
<button id="button-next" type="button" class="flex justify-center text-center w-[100px] h-6 hover:bg-blue-200">
<button id="button-next" type="button" class="flex justify-center text-center w-[80px] h-6 hover:bg-blue-200">
<span class="mt-1">Next</span>
<svg width="24px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M6 12H18M18 12L13 7M18 12L13 17" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
Expand Down
2 changes: 1 addition & 1 deletion web/pub.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ function loadSources(cursor, filter, srcType, own) {
} else if (data != null) {
btnPrev.removeAttribute("disabled");
btnPrev.onclick = () => {
window.location.assign(`pub.html?cursor=${encodeURIComponent(data[0])}&order=DESC&filter=${encodeURIComponent(filter)}&srcType=${srcType}&own=${own}`)
window.location.assign(`pub.html?cursor=${encodeURIComponent(data[0])}&order=DESC&filter=${encodeURIComponent(filter)}&srcType=${srcType}&own=${own}`);
};
}

Expand Down

0 comments on commit d679586

Please sign in to comment.