-
Notifications
You must be signed in to change notification settings - Fork 0
/
Hangman.html
162 lines (147 loc) · 6.53 KB
/
Hangman.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Hangman</title>
<script src="jquery.js"></script>
<script src="jquery-3.2.1.min.js"></script>
<style>
.divider {
width:15px;
height:auto;
display:inline-block;
}
.home-line1 {
display: inline;
}
button {
background-color:#ff8000;
}
textarea {
width:25px;
height:30px;
display:inline-block;
text-align:center;
vertical-align: middle;
font-size: 16px;
border: none;
resize:none;
font-weight:bold;
text-decoration:underline;
text-transform:uppercase;
}
#Espace {
width:auto;
height:50px;
}
#EwBank {
width:500px;
height:100px;
vertical-align:top;
}
</style>
<script>
$(document).ready(function() {
$("#example").hide();
$("#bExample").hover(function() {
$(this).focus();
$(this).css("background-color", "#00cc99");
}, function(){
$(this).css("background-color", "#ff8000");
});
$("#bExample").click(function () {
$("#home").hide();
$("#example").show();
var fruit = ["my","favorite","fruit","is","strawberry"];
localStorage.setItem("example", fruit);
function brakeExWords() {
var fragment = document.createDocumentFragment();
for (var i = 0; i < fruit.length; i++) {
var word = fruit[i];
var word1 = word.toUpperCase();
for (var k = 0; k < word1.length; k++) {
var res = word1.charAt(k);
var txtArea = document.createElement("TEXTAREA");
txtArea.setAttribute("placeholder", "_");
txtArea.setAttribute("maxlength", "1");
txtArea.setAttribute("id", "TxtE" + i + "" + k);
txtArea.addEventListener("change", verifyEx);
// txtarea.onchange = verifyEx;
fragment.appendChild(txtArea);
}
var d = document.createElement("DIV");
d.setAttribute("class", "divider");
fragment.appendChild(d);
}
printExLetter(fragment);
}
function printExLetter(fragment) {
var box = document.getElementById("Ewords");
box.appendChild(fragment);
}
brakeExWords();
});
function verifyEx() {
var fruit = localStorage.getItem("example");
var EwR = fruit.split(",");
for (var i = 0; i < fruit.length; i++) {
var Eword = EwR[i];
var Eword1 = Eword.toUpperCase();
for (var k = 0; k < Eword1.length; k++) {
var exLetter = document.getElementById("TxtE" + i + "" + k);
if (exLetter != null && exLetter != undefined && exLetter.value != "") {
var res = Eword1.charAt(k);
var v = exLetter.value;
var eL = v.toUpperCase();
if (res != eL) {
var wrong = document.createTextNode(eL + ", ");
var Ebank = document.getElementById("EwBank").value;
if (Ebank == "") {
var nEbank = eL + ", ";
document.getElementById("EwBank").value = nEbank;
exLetter.value = "";
alert("Incorrect Lettter: " + eL + "!");
} else{
var nEbank = Ebank + eL + ", ";
document.getElementById("EwBank").value = nEbank;
exLetter.value = "";
alert("Incorrect Lettter: " + eL + "!");
}
} else {
continue;
}
} else {
continue;
}
}
}
}
$("#bPlay").hover(function() {
$(this).focus();
$(this).css("background-color", "#00cc99");
}, function(){
$(this).css("background-color", "#ff8000");
});
$("#bMyWords").hover(function() {
$(this).focus();
$(this).css("background-color", "#00cc99");
}, function(){
$(this).css("background-color", "#ff8000");
});
});
</script>
</head>
<body>
<div id="home">
<div id="Example" class="home-line1"><button id="bExample" value="Example">Example</button></div>
<div id="playG" class="home-line1"><button id="bPlay" value="Play!">Play!</button></div>
<div id="myWords" class="home-line1"><button id="bMyWords" value="My Words">My Words</button></div>
<div id="settings" class="home-line2"><button id="Bsettings">Setings</button></div>
</div>
<div id="example">
<div id="Ewords"></div> <div id="Eman"></div>
<div id="Espace"></div>
<div id="Ebank"><input type="textarea" id="EwBank" value="" disabled></input></div>
<div id="Eback"><button id="EbBack" value="back">Back</button></div>
</div>
</body>
</html>