ui: name the theme-toggle handler instead of an inline IIFE

The theme toggle's onclick attribute held a 140-character inline
IIFE that was hard to read amongst the other named-function
handlers in the same header. Promoted it to cassandraToggleTheme()
alongside cassandraSetTone / cassandraSetLang.
This commit is contained in:
Giorgio Gilestro 2026-05-27 20:41:31 +02:00
parent eedd32b885
commit b13caa4c51

View file

@ -135,6 +135,13 @@
});
};
window.cassandraToggleTheme = function () {
var d = document.documentElement;
var t = d.dataset.theme === 'light' ? 'dark' : 'light';
d.dataset.theme = t;
try { localStorage.setItem('cassandra.theme', t); } catch (e) {}
};
window.cassandraSetLang = async function (newLang) {
var pill = document.getElementById('lang-toggle');
if (!pill) return;
@ -204,7 +211,7 @@
onclick="cassandraSetTone('INTERMEDIATE')">Intermediate</button>
</div>
<button class="theme-toggle" type="button" aria-label="Toggle theme"
onclick="(function(){var d=document.documentElement;var t=d.dataset.theme==='light'?'dark':'light';d.dataset.theme=t;try{localStorage.setItem('cassandra.theme',t);}catch(e){}})()">
onclick="cassandraToggleTheme()">
<span class="theme-toggle__label"></span>
</button>
{% set cu = request.state.current_user if request.state and request.state.current_user is defined else None %}