12345678910111213141516171819202122232425262728 |
- axios.defaults.withCredentials = true;
- let appearance = {};
- appearance.sheetElement = null;
- appearance.textElement = null;
- appearance.prepare = () => {
- appearance.sheetElement = document.getElementById('appearance-sheet');
- appearance.textElement = document.getElementById('appearance-text');
- let lightbulb = document.getElementById('appearance-switch');
- lightbulb.addEventListener('click', appearance.toggleLightMode);
- };
- appearance.toggleLightMode = (e) => {
- e.preventDefault();
- axios.post('/api/appearance/toggle').then(res => {
- let newStyle = res.data.currentStyle;
- appearance.sheetElement.setAttribute("href", `/css/style_${newStyle}.css`);
- appearance.currentStyle = newStyle;
- appearance.textElement.textContent = newStyle;
- });
- };
- window.addEventListener('load', () => {
- appearance.prepare();
- });
|