#Added JS Code for Change the Current Theme

Test
Lucio Vignotto 2020-07-14 18:58:57 +02:00
parent 97257af968
commit 797be71a1a
2 changed files with 41 additions and 1 deletions

View File

@ -0,0 +1,24 @@
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',selectTheme,false);

View File

@ -164,6 +164,21 @@
<div class="col-lg-8"> <div class="col-lg-8">
<h3 class="text-center spacename">NOME PROFILO</h3> <h3 class="text-center spacename">NOME PROFILO</h3>
<br> <br>
<form class="form-group text-center" id="form-theme">
<div class="form-check">
<input class="form-check-input" type="radio" name="Theme" id="exampleRadios1" value="DefaultTheme">
<label class="form-check-label" for="exampleRadios1">
Default Theme
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="Theme" id="exampleRadios2" value="NightMidnight">
<label class="form-check-label" for="exampleRadios2">
Night Midnight
</label>
</div>
</form>
<br>
<p id="biografia">Lorem ipsum dolor sit amet consectetur adipisicing elit. Eveniet dolorum unde ea laborum eum iure beatae totam assumenda, quisquam architecto nemo, quod blanditiis asperiores magnam commodi exercitationem excepturi dolorem a!</p> <p id="biografia">Lorem ipsum dolor sit amet consectetur adipisicing elit. Eveniet dolorum unde ea laborum eum iure beatae totam assumenda, quisquam architecto nemo, quod blanditiis asperiores magnam commodi exercitationem excepturi dolorem a!</p>
</div> </div>
</div> <!-- FINE ROW --> </div> <!-- FINE ROW -->
@ -307,5 +322,6 @@
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script> <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
</body> <script src="./assets/js/changetheme.js"></script>
</body>
</html> </html>