forked from kevinowino869/mitrobill
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:
@ -160,21 +160,40 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
function ask(field, text) {
|
function ask(field, text) {
|
||||||
var txt = field.innerHTML;
|
const txt = field.innerHTML;
|
||||||
if (confirm(text)) {
|
|
||||||
|
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(() => {
|
setTimeout(() => {
|
||||||
field.innerHTML = field.innerHTML.replace(`<span class="loading"></span>`, txt);
|
field.innerHTML = txt;
|
||||||
field.removeAttribute("disabled");
|
field.removeAttribute("disabled");
|
||||||
}, 5000);
|
|
||||||
return true;
|
if (result.isConfirmed) {
|
||||||
|
const form = field.closest('form');
|
||||||
|
if (form) {
|
||||||
|
form.submit(); // manually submit the form
|
||||||
} else {
|
} else {
|
||||||
setTimeout(() => {
|
//fallback if not in a form
|
||||||
field.innerHTML = field.innerHTML.replace(`<span class="loading"></span>`, txt);
|
const href = field.getAttribute("href") || field.dataset.href;
|
||||||
field.removeAttribute("disabled");
|
if (href) window.location.href = href;
|
||||||
}, 500);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}, delay);
|
||||||
|
});
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
function setCookie(name, value, days) {
|
function setCookie(name, value, days) {
|
||||||
var expires = "";
|
var expires = "";
|
||||||
|
Reference in New Issue
Block a user