added keyboard generation

This commit is contained in:
Alexander Popov 2017-02-26 02:04:29 +03:00
parent 026a55c558
commit dd38b4f5f6
4 changed files with 40 additions and 6 deletions

13
html/Play/play.css Normal file
View File

@ -0,0 +1,13 @@
@font-face {
font-family: 'Play';
src: url('Play-Regular.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: 'Play';
src: url('Play-Bold.ttf') format('truetype');
font-weight: bold;
font-style: normal;
}

View File

@ -4,8 +4,29 @@ var lives = 6;
var gameWord = words[Math.floor(Math.random() * words.length)].toUpperCase();
var gameAnswered = new Array(gameWord.length + 1).join('-');
var keyboardLayouts = {
'usQwertyKeyboard' : 'abcdefghijklmnopqrstuvwxyz'.toUpperCase(),
'ruQwertyKeyboard' : 'йцукеёнгшщзхъфывапролджэячсмитьбю'.toUpperCase()
}
// Функция генерации html кода клавиатуры
function generateKeyboard(layout)
{
var htmlKeyboardStr = '';
keyboardLayouts[layout].split('').forEach(function(word)
{
htmlKeyboardStr = htmlKeyboardStr + '<button id="' + word +
'" onclick="offChar(\'' + word + '\')">' + word + '</button>';
})
document.getElementById("keyboard").innerHTML = htmlKeyboardStr;
}
window.onload = function()
{
generateKeyboard('usQwertyKeyboard');
console.log(gameWord) // for DEBUG
document.getElementById("WORD").innerHTML = gameAnswered;
document.getElementById("lives").innerHTML = 'Lives ' + lives;

View File

@ -10,7 +10,7 @@
<title>hgman</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" type="text/css" href="styles.css">
<link rel="stylesheet" type="text/css" href="Vegur/vegur.css">
<link rel="stylesheet" type="text/css" href="Play/play.css">
</head>
<body>
@ -23,11 +23,11 @@
...
</div>
<div class="keyboard">
<button id="A" onclick="offChar('A')">A</button><button id="B" onclick="offChar('B')">B</button><button id="C" onclick="offChar('C')">C</button><button id="D" onclick="offChar('D')">D</button><button id="E" onclick="offChar('E')">E</button><button id="F" onclick="offChar('F')">F</button><button id="G" onclick="offChar('G')">G</button><button id="H" onclick="offChar('H')">H</button><button id="I" onclick="offChar('I')">I</button><button id="J" onclick="offChar('J')">J</button><button id="K" onclick="offChar('K')">K</button><button id="L" onclick="offChar('L')">L</button><button id="M" onclick="offChar('M')">M</button><button id="N" onclick="offChar('N')">N</button><button id="O" onclick="offChar('O')">O</button><button id="P" onclick="offChar('P')">P</button><button id="Q" onclick="offChar('Q')">Q</button><button id="R" onclick="offChar('R')">R</button><button id="S" onclick="offChar('S')">S</button><button id="T" onclick="offChar('T')">T</button><button id="U" onclick="offChar('U')">U</button><button id="V" onclick="offChar('V')">V</button><button id="W" onclick="offChar('W')">W</button><button id="X" onclick="offChar('X')">X</button><button id="Y" onclick="offChar('Y')">Y</button><button id="Z" onclick="offChar('Z')">Z</button>
<div id="keyboard" class="keyboard">
...
</div>
<footer>2017 by iiiypuk</footer>
<footer>2017 by iiiypuk<br>ver: 0.2.0</footer>
</div>
<script type="text/javascript" src="game.js"></script>

View File

@ -7,7 +7,7 @@
body {
color: #032137;
background-color: #29516D;
font-family: 'Vegur';
font-family: 'Play';
font-size: 32px;
}
@ -35,7 +35,7 @@ div.keyboard {
div.keyboard button {
color: #032137;
font-family: 'Vegur';
font-family: 'Play';
border-radius: 4px;
font-size: 16px;
background-color: #708EA4;