Files
kupshop/admin/static/js/wpj.buttonLoading.js
2025-08-02 16:30:27 +02:00

37 lines
1.1 KiB
JavaScript

$(()=> {
$('body').on('click', '[data-submit-loading]', function() {
$(this).addClass('is-submitting');
});
$('body').on('click', '[data-request-recieved-loading]', function() {
function setCookie(c_name, value, time) {
var exTime = new Date();
exTime.setTime(exTime.getTime() + (time * 1000));
var c_value = encodeURIComponent(value) + '; path=/' + (exTime == null ? '' : '; expires=' + exTime.toUTCString());
document.cookie = c_name + '=' + c_value;
}
function getCookie(name) {
const value = '; ' + document.cookie;
const parts = value.split('; ' + name + '=');
if (parts.length === 2) return parts.pop().split(';').shift();
}
const timeout = 15 * 60;
const startTime = Date.now();
var interval = 0;
interval = setInterval(() => {
if (!getCookie('wpjRequestNotFinished') || (startTime + timeout * 1000) < Date.now()) {
clearInterval(interval);
$(this).removeClass('is-submitting');
}
}, 500);
setCookie('wpjRequestNotFinished', Date.now(), timeout);
return true;
});
});