SomethingThatDoesntSuck/Src/assets/js/changetheme.js

26 lines
1.0 KiB
JavaScript

var elForm,elSelectedTheme1,elSelectedTheme2,currentTheme
mainbody = document.getElementById('mainbody');
currentTheme = document.getElementById('mainbody').getAttribute('class');
elForm = document.getElementById('form-theme');
elSelectedTheme1 = document.getElementById('exampleRadios1');
elSelectedTheme2 = document.getElementById('exampleRadios2');
console.log(elForm,elSelectedTheme1,elSelectedTheme2,currentTheme);
// document.querySelector('input[name="Theme"]:checked').value;
function selectTheme(e){
if(!elSelectedTheme1.checked && !elSelectedTheme2.checked){
// elSelectThemeHint.textContent = 'Devi selezionare almeno un tema!'
console.log('Devi selezionare almeno un tema!');
}else if (!elSelectedTheme2.checked){
var selectedTheme = elSelectedTheme1.value;
mainbody.className = selectedTheme;
}else{
var selectedTheme = elSelectedTheme2.value;
mainbody.className = selectedTheme;
}
}
elForm.addEventListener('change',function(e){
selectTheme(e)},
false);