Files
f0ckv2/src/inc/routes/theme.mjs
Flummi 84104b58bc
All checks were successful
fetch npm modules / f0ck the f0cker (push) Successful in 32s
toggle fullscreen
2023-05-06 06:54:09 +02:00

31 lines
799 B
JavaScript

import cfg from "../config.mjs";
export default (router, tpl) => {
router.get(/^\/theme\//, async (req, res) => {
let theme = req.url.split[1] ?? cfg.websrv.themes[0];
if(!cfg.websrv.themes.includes(theme))
theme = cfg.websrv.themes[0];
return res.writeHead(301, {
"Cache-Control": "no-cache, public",
"Set-Cookie": `theme=${theme}; Path=/`,
"Location": req.headers.referer ?? "/"
}).end();
});
router.get(/^\/tfull\//, async (req, res) => {
let full = req.session.fullscreen;
if(full == 1)
full = 0;
else
full = 1;
return res.writeHead(301, {
"Cache-Control": "no-cache, public",
"Set-Cookie": `theme=${full}; Path=/`,
"Location": req.headers.referer ?? "/"
}).end();
});
return router;
};