37 lines
1.4 KiB
JavaScript
37 lines
1.4 KiB
JavaScript
const express = require('express');
|
|
const router = express.Router();
|
|
const db = require('../db');
|
|
|
|
router.get('/', (req, res) => {
|
|
res.render('layout_editor', { overlayLayout: db.getLayout(), settings: db.getSettings() });
|
|
});
|
|
|
|
router.post('/', (req, res) => {
|
|
const b = req.body;
|
|
const int = (v, d) => { const n = parseInt(v, 10); return isNaN(n) ? d : n; };
|
|
const flt = (v, d) => { const n = parseFloat(v); return isNaN(n) ? d : n; };
|
|
db.updateLayout({
|
|
chat_left: flt(b.chat_left, 2.0),
|
|
chat_top: flt(b.chat_top, 60.0),
|
|
chat_width: flt(b.chat_width, 25.0),
|
|
chat_height: flt(b.chat_height, 35.0),
|
|
alert_left: flt(b.alert_left, 50.0),
|
|
alert_top: flt(b.alert_top, 40.0),
|
|
chat_font_size: int(b.chat_font_size, 15),
|
|
chat_font_family: b.chat_font_family || 'Inter, sans-serif',
|
|
chat_bg_opacity: flt(b.chat_bg_opacity, 0.45),
|
|
chat_text_color: b.chat_text_color || '#ffffff',
|
|
chat_border_radius: int(b.chat_border_radius, 8),
|
|
alert_font_size: int(b.alert_font_size, 32),
|
|
alert_bg_opacity: flt(b.alert_bg_opacity, 0.7),
|
|
alert_text_color: b.alert_text_color || '#ffffff',
|
|
});
|
|
res.redirect('/layout');
|
|
});
|
|
|
|
router.post('/positions', (req, res) => {
|
|
db.updateLayoutPositions(req.body);
|
|
res.json({ ok: true });
|
|
});
|
|
|
|
module.exports = router;
|