June 25 - Optimize codes

This commit is contained in:
2026-06-25 16:40:10 -04:00
parent b4cb292afa
commit ea3648ad90
10 changed files with 85 additions and 56 deletions
+20 -2
View File
@@ -293,13 +293,22 @@ document.getElementById('site-list').addEventListener('click', function(e) {
method: 'POST', credentials: 'same-origin',
headers: {'Content-Type': 'application/x-www-form-urlencoded', 'X-CSRFToken': getCsrfToken()},
body: 'user_note='
}).then(function() {
}).then(function(r) {
if (!r.ok) throw new Error('Server error ' + r.status);
var toast = document.createElement('div');
toast.className = 'alert alert-success';
toast.style.cssText = 'position:fixed;top:1rem;right:1rem;z-index:9999;min-width:220px;box-shadow:var(--shadow)';
toast.textContent = '✔ ' + siteName + ' marked checked';
document.body.appendChild(toast);
setTimeout(function() { location.reload(); }, 700);
}).catch(function(err) {
btn.disabled = false;
var toast = document.createElement('div');
toast.className = 'alert alert-danger';
toast.style.cssText = 'position:fixed;top:1rem;right:1rem;z-index:9999;min-width:220px;box-shadow:var(--shadow)';
toast.textContent = '✖ Failed to mark checked. Please try again.';
document.body.appendChild(toast);
setTimeout(function() { toast.remove(); }, 4000);
});
return;
}
@@ -353,13 +362,22 @@ document.getElementById('site-list').addEventListener('click', function(e) {
method: 'POST', credentials: 'same-origin',
headers: {'Content-Type': 'application/x-www-form-urlencoded', 'X-CSRFToken': getCsrfToken()},
body: ''
}).then(function() {
}).then(function(r) {
if (!r.ok) throw new Error('Server error ' + r.status);
var toast = document.createElement('div');
toast.className = 'alert alert-info';
toast.style.cssText = 'position:fixed;top:1rem;right:1rem;z-index:9999;min-width:220px;box-shadow:var(--shadow)';
toast.textContent = '↩ Check removed for ' + siteName;
document.body.appendChild(toast);
setTimeout(function() { location.reload(); }, 700);
}).catch(function(err) {
btn.disabled = false;
var toast = document.createElement('div');
toast.className = 'alert alert-danger';
toast.style.cssText = 'position:fixed;top:1rem;right:1rem;z-index:9999;min-width:220px;box-shadow:var(--shadow)';
toast.textContent = '✖ Failed to remove check. Please try again.';
document.body.appendChild(toast);
setTimeout(function() { toast.remove(); }, 4000);
});
return;
}