const pageCredits='\t

Font F5.6 by\t\tDOT COLON\t

\t\t

UI by\t\tchota.css\t

';const pageStatistics='\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t
User statistics
NameValue
Total games...
Guess words...
% Win...
Total letters clicked...
Correctly guessed letters...
% correctly letters...
\t

\t\tClear statistics\t

';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)}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+=``});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 wordArray=gameAnswered.split("");wordArray[item]=letter;gameAnswered=wordArray.join("");document.querySelector("#word").innerHTML=gameAnswered;updateStats("stCorrLetter")});if(gameAnswered.split("").indexOf("-")==-1){updateStats("stWinWords");document.querySelector("#keyboard").innerHTML='\t\t\t\t

Your winner!!

\t\t'}}function wrongLetter(){if(lives<=0){updateStats("stTotalGames");document.querySelector("#word").innerHTML=gameWord;document.querySelector("#word").classList.add("text-success");document.querySelector("#keyboard").innerHTML='\t\t\t\t

Your lose!!

\t\t'}lives-=1;document.querySelector("#lives").innerHTML="Lives "+lives}function showPage(element,pageName){["gameButton","statsButton","creditsButton"].forEach(function(item){document.querySelector("#"+item).classList.remove("active")});document.querySelector("#"+element.id).classList.add("active");document.querySelector("#content").innerHTML=pageName;if(pageName==pageStatistics){updateStatsPage()}}window.onload=function(){updateStats("stCheck");generateKeyboard(keyboardLayouts["usQwertyKeyboard"]);document.querySelector("#lives").innerHTML="Lives "+lives;console.log("Word:",gameWord.toLowerCase());document.querySelector("#word").innerHTML=gameAnswered;if(window.screen.availWidth<=599){document.querySelector("#lives").classList.remove("error");document.querySelector("#lives").classList.add("dark")}};