Recount-Server/web/static/index.js

52 lines
1.3 KiB
JavaScript
Raw Normal View History

2024-01-12 20:50:41 -08:00
2024-01-15 19:26:51 -08:00
function debounce(func, delay) {
let timeoutId;
return function (...args) {
clearTimeout(timeoutId);
timeoutId = setTimeout(() => {
func.apply(this, args);
}, delay);
};
2024-01-12 20:50:41 -08:00
}
function register_nav_links() {
var navAnchors = document.querySelectorAll("nav a");
navAnchors.forEach(function (a_el) {
2024-01-15 19:26:51 -08:00
a_el.addEventListener("click", function(event) {
var active_anchor = document.querySelector("nav a.active");
active_anchor.classList.remove("active");
var clicked = event.target;
clicked.classList.add("active");
});
});
}
2024-01-15 19:26:51 -08:00
function register_handlers() {
register_nav_links();
}
function load_in_table() {
var rows = Array.from(document.querySelectorAll(".row_awaiting_processing"));
rows.sort((a, b) => b.dataset.rcntTransactionRowPos - a.dataset.rcntTransactionRowPos);
2024-01-15 19:26:51 -08:00
const processElement = (element, index) => {
element.classList.remove('row_awaiting_processing');
setTimeout(() => {
if (index < rows.length - 1) {
processElement(rows[index + 1], index + 1);
}
}, 25); // 1000 milliseconds (1 second) delay, adjust as needed
};
processElement(rows[0], 0);
}
2024-01-15 19:26:51 -08:00
const trigger_table_animation = debounce(load_in_table, 100);
export {register_handlers, trigger_table_animation};