Updated JS stuffs.

This commit is contained in:
flash 2025-03-20 21:49:41 +00:00
commit 452eeb22d6
Signed by: flash
GPG key ID: 2C9C2C574D47FE3E
21 changed files with 267 additions and 412 deletions

24
assets/makai.js/csrf.js Normal file
View file

@ -0,0 +1,24 @@
#include html.js
const $csrf = (() => {
let elem;
const getElement = () => {
if(elem === undefined)
elem = $query('meta[name="csrf-token"]');
return elem;
};
return {
get token() {
return getElement()?.content ?? '';
},
set token(token) {
if(typeof token !== 'string')
throw 'token must be a string';
const elem = getElement();
if(elem instanceof HTMLMetaElement)
elem.content = token;
},
};
})();