2021-02-27 02:32:34 +03:00
|
|
|
"use strict";const pageCredits='\t<p class="text-center">Font F5.6 by\t\t<a href="http://dotcolon.net/">DOT COLON</a>\t</p>\t\t<p class="text-center">UI by\t\t<a href="https://jenil.github.io/chota/">chota.css</a>\t</p>';"use strict";const pageStatistics='\t<table>\t\t<caption>User statistics</caption>\t\t<thead>\t\t\t<tr>\t\t\t\t<th>Name</th>\t\t\t\t<th>Value</th>\t\t\t</tr>\t\t</thead>\t\t<tbody>\t\t\t<tr>\t\t\t\t<th>Total games</th>\t\t\t\t<th id="stTotalGames">...</th>\t\t\t</tr>\t\t\t<tr>\t\t\t\t<th>Guess words</th>\t\t\t\t<th id="stWinWords">...</th>\t\t\t</tr>\t\t\t<tr>\t\t\t\t<th>% Win</th>\t\t\t\t<th id="stWinPercentage">...</th>\t\t\t</tr>\t\t\t<tr>\t\t\t\t<th>Total letters clicked</th>\t\t\t\t<th id="stLetterClick">...</th>\t\t\t</tr>\t\t\t<tr>\t\t\t\t<th>Correctly guessed letters</th>\t\t\t\t<th id="stCorrLetter">...</th>\t\t\t</tr>\t\t\t<tr>\t\t\t\t<th>% correctly letters</th>\t\t\t\t<th id="stWinLetterPercent">...</th>\t\t\t</tr>\t\t</tbody>\t</table>\t<p class="text-center">\t\t<buttton class="button error" onclick="localStorage.clear();">Clear statistics</buttton>\t</p>';function updateStatsPage(){let stTotalGames=localStorage.getItem("stTotalGames");let stWinWords=localStorage.getItem("stWinWords");let stWinPercentage=localStorage.getItem("stWinPercentage");let stLetterClick=localStorage.getItem("stLetterClick");let stCorrLetter=localStorage.getItem("stCorrLetter");let stWinLetterPercent=localStorage.getItem("stWinLetterPercent");document.querySelector("#stTotalGames").innerHTML=stTotalGames;document.querySelector("#stWinWords").innerHTML=stWinWords;document.querySelector("#stWinPercentage").innerHTML=Math.round(stWinWords/stTotalGames*100);document.querySelector("#stLetterClick").innerHTML=stLetterClick;document.querySelector("#stCorrLetter").innerHTML=stCorrLetter;document.querySelector("#stWinLetterPercent").innerHTML=Math.round(stCorrLetter/stLetterClick*100)}"use strict";function updateStats(statParameter){let stTotalGames=JSON.parse(localStorage.getItem("stTotalGames"));let stWinWords=JSON.parse(localStorage.getItem("stWinWords"));let stLetterClick=JSON.parse(localStorage.getItem("stLetterClick"));let stCorrLetter=JSON.parse(localStorage.getItem("stCorrLetter"));switch(statParameter){case"stTotalGames":localStorage.setItem("stTotalGames",stTotalGames+1);break;case"stWinWords":localStorage.setItem("stTotalGames",stTotalGames+1);localStorage.setItem("stWinWords",stWinWords+1);break;case"stLetterClick":localStorage.setItem("stLetterClick",stLetterClick+1);break;case"stCorrLetter":localStorage.setItem("stLetterClick",stLetterClick+1);localStorage.setItem("stCorrLetter",stCorrLetter+1);break;case"stCheck":if(stTotalGames==null){localStorage.setItem("stTotalGames",0)}if(stWinWords==null){localStorage.setItem("stWinWords",0)}if(stLetterClick==null){localStorage.setItem("stLetterClick",0)}if(stCorrLetter==null){localStorage.setItem("stCorrLetter",0)}break}}"use strict";const keyboardLayouts={usQwertyKeyboard:"abcdefghijklmnopqrstuvwxyz".toUpperCase(),ruQwertyKeyboard:"йцукеёнгшщзхъфывапролджэячсмитьбю".toUpperCase()};const words=["google","speed","design","forest","forever","love","horizon","defect"];let gameWord=words[Math.floor(Math.random()*words.length)].toUpperCase();let gameAnswered=new Array(gameWord.length+1).join("-");let lives=6;function generateKeyboard(layout){let keyboardHtmlStr="";layout.split("").forEach(function(letter){keyboardHtmlStr=keyboardHtmlStr+'<button class="button clear is-marginless" id="'+letter+'" onclick="letterClick(\''+letter+"')\"> "+letter+"</button>"});let keyboard=document.querySelector("#keyboard");keyboard.classList.remove("is-hidden");document.querySelector("#keyboard").innerHTML=keyboardHtmlStr}function letterClick(letter){let charButton=document.getElementById(letter);charButton.disabled=true;let indices=[];let idx=gameWord.split("").indexOf(letter);if(idx==-1){wrongLetter();updateStats("stLetterClick");return}while(idx!=-1){indices.push(idx);idx=gameWord.split("").indexOf(letter,idx+1)}indices.forEach(function(item,indices){let wor
|