|
|
|
|
|
|
|
|
|
|
|
//store form's value in localStorage
|
|
|
|
|
|
|
|
var f = document.querySelector("form#avatar_form")
|
|
|
|
f.onchange = updateAvatar
|
|
|
|
f.checked = updateAvatar
|
|
|
|
|
|
|
|
/*
|
|
|
|
document.querySelector("#player1").onchange = updateAvatar
|
|
|
|
document.querySelector("#player1").checked = updateAvatar
|
|
|
|
document.querySelector("#player2").onchange = updateAvatar
|
|
|
|
document.querySelector("#player3").onchange = updateAvatar
|
|
|
|
document.querySelector("#player4").onchange = updateAvatar
|
|
|
|
document.querySelector("#player5").onchange = updateAvatar
|
|
|
|
document.querySelector("#player6").onchange = updateAvatar
|
|
|
|
document.querySelector("#player7").onchange = updateAvatar
|
|
|
|
document.querySelector("#player8").onchange = updateAvatar
|
|
|
|
document.querySelector("#player9").onchange = updateAvatar
|
|
|
|
document.querySelector("#player10").onchange = updateAvatar
|
|
|
|
document.querySelector("#player11").onchange = updateAvatar
|
|
|
|
document.querySelector("#player12").onchange = updateAvatar*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function updateAvatar () {
|
|
|
|
//console.log("CHANGE");
|
|
|
|
var fd = new FormData(f);
|
|
|
|
var avatar=fd.get("player_avatar")
|
|
|
|
console.log("avatar", avatar);
|
|
|
|
localStorage.myavatar=avatar;
|
|
|
|
}
|
|
|
|
|
|
|
|
// store username in local storage + make sure the player added their preferences, if yes it redirect to the following page
|
|
|
|
|
|
|
|
function storeName(){
|
|
|
|
var inputPlayer = document.querySelector('#player_name').value;
|
|
|
|
localStorage.playerName=inputPlayer;
|
|
|
|
|
|
|
|
if (document.querySelector('#player_name').value === '') {
|
|
|
|
alert('Please insert you name and choose your avatar');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
window.location.href = "park.html";
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|