refactor: replace the javascript popup with sweetalert which prevent some devices to purchase data plans and packages via captive portal, clean up footer template and improve script formatting
This commit is contained in:
parent
27fd677a0a
commit
0a29ec9a86
@ -160,21 +160,40 @@
|
||||
});
|
||||
|
||||
function ask(field, text) {
|
||||
var txt = field.innerHTML;
|
||||
if (confirm(text)) {
|
||||
const txt = field.innerHTML;
|
||||
|
||||
field.innerHTML = `<span class="loading"></span>`;
|
||||
field.setAttribute("disabled", true);
|
||||
|
||||
Swal.fire({
|
||||
title: 'Are you sure?',
|
||||
text: text,
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: 'Yes, proceed',
|
||||
cancelButtonText: 'Cancel',
|
||||
}).then((result) => {
|
||||
let delay = result.isConfirmed ? 400 : 500;
|
||||
|
||||
setTimeout(() => {
|
||||
field.innerHTML = field.innerHTML.replace(`<span class="loading"></span>`, txt);
|
||||
field.innerHTML = txt;
|
||||
field.removeAttribute("disabled");
|
||||
}, 5000);
|
||||
return true;
|
||||
|
||||
if (result.isConfirmed) {
|
||||
const form = field.closest('form');
|
||||
if (form) {
|
||||
form.submit(); // manually submit the form
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
field.innerHTML = field.innerHTML.replace(`<span class="loading"></span>`, txt);
|
||||
field.removeAttribute("disabled");
|
||||
}, 500);
|
||||
return false;
|
||||
//fallback if not in a form
|
||||
const href = field.getAttribute("href") || field.dataset.href;
|
||||
if (href) window.location.href = href;
|
||||
}
|
||||
}
|
||||
}, delay);
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function setCookie(name, value, days) {
|
||||
var expires = "";
|
||||
|
Loading…
x
Reference in New Issue
Block a user