I have a problem with my code:
var llistaColors = ["grey", "black", "blue", "yellow","red","purple", "green", "white", "orange", "pink"];
var llistaNomColors =["Gris", "negre", "blau", "Groc", "Vermell", "lila", "Verd", "blanc", "Taronja", "rosa"];
function iniColors(){
for (i=0; i<llistaColors.length;i++){
pintaColors(i, llistaColors[i]);
}
}
function mouColorsEsquerra(){
llistaColors.unshift(llistaColors.pop());
llistaNomColors.unshift(llistaNomColors.pop());
updateColorName(llistaNomColors[0]);
iniColors();
desaPrimerColor();
}
function pintaColors(i, color){
var colorDivs = document.querySelectorAll('.colordiv');
colorDivs[i].style.backgroundColor = color;
}
function updateColorName(name){
var currentColor = document.getElementById('primerColor');
currentColor.textContent = name;
}
function desaPrimerColor(){
localStorage.setItem("color", "primerColor");
}
function recuperaPrimerColor(){
var color = localStorage.getItem("primerColor");
}
document.addEventListener('DOMContentLoaded', function() {
var btnRotate = document.getElementById('brotar1');
//btnRotate.addEventListener('click', mouColorsEsquerra);
});
The problem points out to me in the next part:
function desaPrimerColor(){
localStorage.setItem("color", "primerColor");
}
Tells me "Unknown error"
It has to be simple but I do not clarify anything ..
I have to have two functions.
The first is to say the function DesaPrimerColor () keeps the last color of the rotation. That is to say when we close the explorer must have kept in what color I have stayed ..
The second is to say the function RecoverFirstColor () You have to return it when you restart Windows ...
But I can not get out because I do not know where I'm wrong ..
Haber if you can help me ..: (