Показать сообщение отдельно
  #11 (permalink)  
Старый 31.08.2016, 15:57
Интересующийся
Отправить личное сообщение для кирикала Посмотреть профиль Найти все сообщения от кирикала
 
Регистрация: 03.08.2016
Сообщений: 21

<script>
function give(val) {
switch (true) {
   case (val=='boxA'):
if (localStorage.getItem('i') == 1) {
localStorage.setItem('count0', 'boxA'); localStorage.setItem('i', '0');
} else {
localStorage.setItem('count1', 'boxA'); localStorage.setItem('i', '1');
}
   break;
   case (val=='boxB'):
if (localStorage.getItem('i') == 1) {
localStorage.setItem('count0', 'boxB'); localStorage.setItem('i', '0');
} else {
localStorage.setItem('count1', 'boxB'); localStorage.setItem('i', '1');
}
   break;
   case (val=='boxC'):
if (localStorage.getItem('i') == 1) {
localStorage.setItem('count0', 'boxC'); localStorage.setItem('i', '0');
} else {
localStorage.setItem('count1', 'boxC'); localStorage.setItem('i', '1');
}
   break; 
}
if (localStorage.getItem('count0') == 'boxA') {var bbb = "<div class='drag' id='boxA'></div>"} else if (localStorage.getItem('count0') == 'boxB') {var bbb = "<div class='drag' id='boxB'></div>"} else if (localStorage.getItem('count0') == 'boxC') {var bbb = "<div class='drag' id='boxC'></div>"}
if (localStorage.getItem('count1') == 'boxA') {var aaa = "<div class='drag' id='boxA'></div>"} else if (localStorage.getItem('count1') == 'boxB') {var aaa = "<div class='drag' id='boxB'></div>"} else if (localStorage.getItem('count1') == 'boxC') {var aaa = "<div class='drag' id='boxC'></div>"}
document.getElementById("big").innerHTML = bbb + aaa;}

function someFunc(){
var timestake = document.getElementById("timestake").value;
if (localStorage.getItem('count0') == "boxA") {var stake0 = timestake;} else if (localStorage.getItem('count0') == "boxB") {var stake1 = timestake;} else if (localStorage.getItem('count0') == "boxC") {var stake2 = timestake;}
if (localStorage.getItem('count1') == "boxA") {var stake0 = timestake;} else if (localStorage.getItem('count1') == "boxB") {var stake1 = timestake;} else if (localStorage.getItem('count1') == "boxC") {var stake2 = timestake;}
document.getElementById("textstake").innerHTML= stake0 + "<br>" + stake1 + "<br>" + stake2;
localStorage.removeItem('count0');localStorage.removeItem('count1');localStorage.removeItem('i');document.getElementById("big").innerHTML = " ";
}
</script>

явно конечно с точки зрения веб программиста код кривой
Ответить с цитированием