-
Notifications
You must be signed in to change notification settings - Fork 0
/
puzzle.html
170 lines (111 loc) · 3.25 KB
/
puzzle.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
163
164
165
166
167
168
169
170
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<div style="position:relative;">
<h1 id="exp" onmouseup="myFunction(0)" >ABCDEFGH</h1>
<img id="left" onclick="myFunction(1)" src="leftarrow.png" onmouseover="hover(this, 'leftarrowhover.png');" onmouseout="unhover(this, 'leftarrow.png');" width="25" />
<img id="right" onclick="myFunction(2)" src="rightarrow.png" onmouseover="hover(this, 'rightarrowhover.png');" onmouseout="unhover(this, 'rightarrow.png');" width="25" />
</div>
Puzzle String: <input type="text" name="istr" ><br>
<button type="button" onclick="setString()">Set Puzzle String</button>
<br /> <br /> <br />
Copy paste the puzzles into the above input box and set the puzzle string.
<br /> <br /> <br />
<table style="width:25%" border="1">
<tr>
<th align="left">Puzzle</th>
<th align="left">Solution</th>
</tr>
<tr>
<td>LSIMPE</td>
<td>SIMPLE</td>
</tr>
<tr>
<td>NDRKI</td>
<td>DRINK</td>
</tr>
<tr>
<td>URNEAT</td>
<td>NATURE</td>
</tr>
<tr>
<td>OMZIEB</td>
<td>ZOMBIE</td>
</tr>
<tr>
<td>PSMLYI</td>
<td>SIMPLY</td>
</tr>
<tr>
<td>RYGADET</td>
<td>TRAGEDY</td>
</tr>
<tr>
<td>IISSSPMET</td>
<td>PESSIMIST</td>
</tr>
<tr>
<td>IIMSOPTT</td>
<td>OPTIMIST</td>
</tr>
</table>
<script>
function setString()
{
var x = document.getElementsByName("istr")[0];
text = x.value;
if (text.length < 3){
alert("Please enter a string > 3");
return;
}
ele = document.getElementById("exp");
ele.innerHTML = text.toUpperCase();
}
function myFunction(flag) {
// make sure something is seleccted and that more than one letter is selected
if( window.getSelection().getRangeAt(0) && window.getSelection().getRangeAt(0).toString().length > 1 ){
var p = window.getSelection().getRangeAt(0) ;
var text = p.toString();
var r=p.getBoundingClientRect();
var relative=document.getElementById("exp").getBoundingClientRect();
//alert("You selected some text! : "+ text + r.top + "<br />" + r.bottom + "<br />" + r.left + "<br />" + r.right);
var leftimage = document.getElementById("left");
setPostion(leftimage , r.bottom - relative.top, r.left - relative.left);
var rightimage = document.getElementById("right");
setPostion(rightimage , r.bottom - relative.top , r.right - 25 - relative.left);
if (flag == 1){
p.deleteContents();
firstLetter = text.charAt(0);
text2 = text.slice(1);
text2 = text2 + firstLetter;
textNode = new Text(text2);
p.insertNode(textNode);
}
if (flag == 2){
p.deleteContents();
lastLetter = text.charAt(text.length-1);
text2 = text.slice(0, -1)
text2 = lastLetter + text2 ;
textNode = new Text(text2);
p.insertNode(textNode);
}
}
}
function setPostion(ele, top, left)
{
ele.style.position = "absolute"
ele.style.top = top + 'px';
ele.style.left = left + 'px';
}
function hover(element , src) {
element.setAttribute('src', src);
}
function unhover(element, src) {
element.setAttribute('src', src);
}
</script>
</body>
</html>