78 lines
3.1 KiB
JavaScript
78 lines
3.1 KiB
JavaScript
// Generated, do not edit. sha256:57b15ebfb354db8adff68add2532edc1829f9c3b7ed8450a9de6ff4be9df9286
|
|||
|
|
(function () {
|
||
|
|
try {
|
||
|
|
var naam = localStorage.getItem('portfolio_active');
|
||
|
|
if (naam) {
|
||
|
|
document.documentElement.dataset.portfolio = naam;
|
||
|
|
document.documentElement.style.setProperty('--portfolio-name', JSON.stringify(naam));
|
||
|
|
}
|
||
|
|
} catch (e0) { }
|
||
|
|
try {
|
||
|
|
var achtervoegsel = document.documentElement.dataset.portfolio
|
||
|
|
? ':' + document.documentElement.dataset.portfolio : '';
|
||
|
|
var theme = localStorage.getItem('ui_theme' + achtervoegsel);
|
||
|
|
var accent = localStorage.getItem('ui_accent' + achtervoegsel);
|
||
|
|
var depth = localStorage.getItem('ui_depth' + achtervoegsel);
|
||
|
|
if (theme === 'dark' || theme === 'light') document.documentElement.dataset.theme = theme;
|
||
|
|
if (accent) document.documentElement.dataset.accent = accent;
|
||
|
|
if (depth === 'flat' || depth === 'deep') document.documentElement.dataset.depth = depth;
|
||
|
|
} catch (e1) { }
|
||
|
|
try {
|
||
|
|
var look = JSON.parse(localStorage.getItem('ui_look' + achtervoegsel) || '{}');
|
||
|
|
var LOOK_ATTRS = ['profile', 'glow', 'glowshape', 'motion', 'rowsel', 'render'];
|
||
|
|
for (var i = 0; i < LOOK_ATTRS.length; i++) {
|
||
|
|
var v = look && look[LOOK_ATTRS[i]];
|
||
|
|
if (typeof v === 'string' && /^[a-z]+$/.test(v)) document.documentElement.dataset[LOOK_ATTRS[i]] = v;
|
||
|
|
}
|
||
|
|
var LOOK_TOKENS = ['--glass-transparency', '--glass-frost', '--dialog-transparency'];
|
||
|
|
for (var j = 0; j < LOOK_TOKENS.length; j++) {
|
||
|
|
var w = look && look[LOOK_TOKENS[j]];
|
||
|
|
if (typeof w === 'string' && /^\d{1,3}(%|px)?$/.test(w)) document.documentElement.style.setProperty(LOOK_TOKENS[j], w);
|
||
|
|
}
|
||
|
|
} catch (e2) { }
|
||
|
|
|
||
|
|
document.addEventListener('DOMContentLoaded', function () {
|
||
|
|
var form = document.getElementById('login-form');
|
||
|
|
var veld = document.getElementById('login-password');
|
||
|
|
var knop = document.getElementById('login-submit');
|
||
|
|
var fout = document.getElementById('login-error');
|
||
|
|
if (!form || !veld || !knop || !fout) return;
|
||
|
|
|
||
|
|
function melding(antwoord) {
|
||
|
|
var wacht = antwoord && antwoord.retryAfterMs;
|
||
|
|
if (wacht > 0) {
|
||
|
|
var seconden = Math.ceil(wacht / 1000);
|
||
|
|
return 'Te veel pogingen. Probeer het over ' + seconden
|
||
|
|
+ (seconden === 1 ? ' seconde' : ' seconden') + ' opnieuw.';
|
||
|
|
}
|
||
|
|
return 'Onjuist wachtwoord.';
|
||
|
|
}
|
||
|
|
|
||
|
|
form.addEventListener('submit', function (e) {
|
||
|
|
e.preventDefault();
|
||
|
|
fout.textContent = '';
|
||
|
|
knop.disabled = true;
|
||
|
|
|
||
|
|
fetch('/api/login', {
|
||
|
|
method: 'POST',
|
||
|
|
headers: { 'Content-Type': 'application/json' },
|
||
|
|
body: JSON.stringify({ password: veld.value }),
|
||
|
|
}).then(function (res) {
|
||
|
|
return res.json().catch(function () { return null; }).then(function (json) {
|
||
|
|
return { ok: res.ok, json: json };
|
||
|
|
});
|
||
|
|
}).then(function (uit) {
|
||
|
|
if (uit.ok) {
|
||
|
|
location.replace('/');
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
knop.disabled = false;
|
||
|
|
fout.textContent = melding(uit.json);
|
||
|
|
veld.select();
|
||
|
|
}).catch(function () {
|
||
|
|
knop.disabled = false;
|
||
|
|
fout.textContent = 'Geen verbinding met de server.';
|
||
|
|
});
|
||
|
|
});
|
||
|
|
});
|
||
|
|
})();
|