-
Notifications
You must be signed in to change notification settings - Fork 0
/
pashtoTyping.html
478 lines (441 loc) · 15.7 KB
/
pashtoTyping.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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>Pashto Typing - پښتو ټایپنګ</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="Keywords" content="typing,pashto typing,pashto typing test, پښتو ټایپنګ, پشتو ټایپنګ ټیسڼ">
<meta name="Description" content="test your typing test">
</head>
<style>
#container {
margin: 10px auto;
width: 1100px;
}
#keyboard {
margin-top: 40px;
padding: 0;
list-style: none;
}
#keyboard li {
float: left;
width: 68.57px;
height: 6%;
line-height: 40px;
text-align: center;
background: #d4edda;
border: 2px solid white;
color: white;
font-weight: bold;
}
#keyboard li span {
font-size: 24px;
color: black;
font-weight: bold;
}
.capslock, .tab, .left-shift {
clear: left;
}
#keyboard .tab, #keyboard .delete {
width: 100.59px;
}
#keyboard .capslock {
width: 120.865px;
}
#keyboard .return {
width: 120.865px;
}
#keyboard .left-shift {
width: 159.15px;
}
#keyboard .right-shift {
width: 159.15px;
}
.lastitem {
margin-right: 0;
}
.uppercase {
text-transform: uppercase;
}
#keyboard .space {
width: 298px;
}
.on {
display: none;
}
#keyboard li:hover {
position: relative;
top: 1px;
left: 1px;
border-color: #e5e5e5;
cursor: pointer;
}
div.typingtest {
background-color: #d4edda;
text-align:center;
font-family:Roboto;
}
.typingtest h1, .typingtest h2 {
font-family:Roboto;
}
.typingtest #words,.typingtest #time {
font-size:50px;
}
.typingtest #characters,.typingtest #errors {
font-size:30px;
}
.typingtest .corchar {
color:rgba(30, 144, 255,0.5);
}
.typingtest .errchar {
color:rgba(0,0,0,0.5);
background-color:rgba(255, 0, 0,0.2);
}
.typingtest #atext,.typingtest #btext,.typingtest #ctext,.typingtest #dtext {
font-family:Roboto Mono;
font-size:28px;
padding:15px;
text-align:right;
}
.w3-btn, .w3-button {
border: none;
display: inline-block;
padding: 8px 16px;
vertical-align: middle;
overflow: hidden;
text-decoration: none;
color: #FFFFFF;
background-color: #4CAF50;
text-align: center;
cursor: pointer;
white-space: nowrap;
}
.typingtest #btext,.typingtest #ctext,.typingtest #dtext {
position:absolute;
}
.typingtest #dtext {
padding-top:0;
padding-bottom:0;
height:auto;
visibility:hidden;
}
.typingtest .donechars {
color:transparent;
}
.typingtest #timefooter {
opacity:0.5;
}
#finishdiv {
display:none;
}
#phonebutton {
display:none;
}
@media (max-width:600px) {
.typingtest #atext,.typingtest #btext,.typingtest #ctext,.typingtest #dtext {
font-size:24px;
padding:15px;
}
.w3-info {
padding:1px;
}
#ctext {
caret-color:transparent;
}
.typingtest #words,.typingtest #time {
font-size:30px;
}
.typingtest #characters,.typingtest #errors {
font-size:20px;
}
h1 {
font-size:24px;
}
.typingtest #timefooter {
font-size:14px;
}
#phonebutton {
display:block;
font-size:12px;
opacity:0.5;
}
}
#showTypeText {
position: relative;
width: 100%;
}
#showTypeText #ctext{
width: 100% !important;
}
</style>
<body spellcheck="false">
<div id='container'>
<div class="typingtest w3-panel w3-info intro">
<br>
<span id='note' style="color:red;">
<p>په خپل کمپیوټر کې ترې استفاده وکړئ</p>
<p>for better performance use PC</p>
</span>
<h1>خپل د لیکلو سرعت معلوم کړئ</h1>
<div class="w3-row">
<div id="finishdiv">
<div>
لغات په دقیقه کې:
<span class="bench" id="words">0</span>
</div>
<div class="w3-half">
حرفونه:
<span class="bench" id="characters">0</span>
</div>
<div class="w3-half">
غلطۍ:
<span class="bench" id="errors">0</span>
</div>
<button type="button" class="w3-btn" onclick="goAgain()">بیا پیل</button>
</div>
</div>
<div id="startdiv" class="w3-row">
وخت:
<span class="bench" id="time">60</span><br>
<span id="timefooter">کله چې لیکل شروع کړئ وخت پیل کیږي</span>
<div id="phonebutton">
د مبایل او ټابلیټ استفاده کوونکو په لاندې خط باندې کلیک وکړئ
</div>
</div>
<br class="w3-hide-small">
<br>
<div id='showTypeText'>
<div id="btext" style="color:transparent;" contenteditable="true" onclick="clickc()"></div>
<div id="ctext" autocomplete="off" autocorrect="off" autocapitalize="off" onmouseup="clickc()" onblur="unfocus()" onkeydown="kd(event)" onkeyup="ku(event)" style="outline: 0 solid transparent;color:transparent;" contenteditable="true" spellcheck="false"></div>
<div id="dtext" contenteditable="true"></div>
<div id="atext" style="background-color:white;color:rgba(0,0,0,0.3);" contenteditable="true"></div>
</div>
<ul id="keyboard">
<li class="symbol"><span></span><span style="color:white;">ٔ </span></li>
<li class="symbol"><span>۱</span><span style="color:white;"> !</span></li>
<li class="symbol"><span>۲</span><span style="color:white;"> ٬</span></li>
<li class="symbol"><span>۳</span><span style="color:white;"> ٫</span></li>
<li class="symbol"><span>۴</span><span style="color:white;"> ؋</span></li>
<li class="symbol"><span>۵</span><span style="color:white;"> ٪</span></li>
<li class="symbol"><span>۶</span><span style="color:white;"> ×</span></li>
<li class="symbol"><span>۷</span><span style="color:white;"> »</span></li>
<li class="symbol"><span>۸</span><span style="color:white;"> «</span></li>
<li class="symbol"><span>۹</span><span style="color:white;"> )</span></li>
<li class="symbol"><span>۰</span><span style="color:white;"> (</span></li>
<li class="symbol"><span>-</span><span style="color:white;"> ـ</span></li>
<li class="symbol"><span>=</span><span style="color:white;"> +</span></li>
<li class="delete lastitem">Backspace</li>
<li class="tab">tab</li>
<li class="symbol"><span>ض</span><span style="color:white;"> </span></li>
<li class="symbol"><span>ص</span><span style="color:white;">ٌ </span></li>
<li class="symbol"><span>ث</span><span style="color:white;">ٍ </span></li>
<li class="symbol"><span>ق</span><span style="color:white;">ً </span></li>
<li class="symbol"><span>ف</span><span style="color:white;">ُ </span></li>
<li class="symbol"><span>غ</span><span style="color:white;">ِ </span></li>
<li class="symbol"><span>ع</span><span style="color:white;">َ </span></li>
<li class="symbol"><span>ه</span><span style="color:white;">ّ </span></li>
<li class="symbol"><span>خ</span><span style="color:white;"> ځ</span></li>
<li class="symbol"><span>ح</span><span style="color:white;"> څ</span></li>
<li class="symbol"><span>ج</span><span style="color:white;"> ]</span></li>
<li class="symbol"><span>چ</span><span style="color:white;"> [</span></li>
<li class="symbol lastitem"><span>\</span><span style="color:white;"> *</span></li>
<li class="capslock">Caps Lock</li>
<li class="symbol"><span>ش</span><span style="color:white;"> ښ</span></li>
<li class="symbol"><span>س</span><span style="color:white;"> ۍ</span></li>
<li class="symbol"><span>ی</span><span style="color:white;"> ي</span></li>
<li class="symbol"><span>ب</span><span style="color:white;"> پ</span></li>
<li class="symbol"><span>ل</span><span style="color:white;"> أ</span></li>
<li class="symbol"><span>ا</span><span style="color:white;"> آ</span></li>
<li class="symbol"><span>ت</span><span style="color:white;"> ټ</span></li>
<li class="symbol"><span>ن</span><span style="color:white;"> ڼ</span></li>
<li class="symbol"><span>م</span><span style="color:white;"> ة</span></li>
<li class="symbol"><span>ک</span><span style="color:white;"> :</span></li>
<li class="symbol"><span>ګ</span><span style="color:white;"> ؛</span></li>
<li class="return lastitem">Enter</li>
<li class="left-shift">Shift</li>
<li class="symbol"><span>ظ</span><span style="color:white;"> ئ</span></li>
<li class="symbol"><span>ط</span><span style="color:white;"> ې</span></li>
<li class="symbol"><span>ز</span><span style="color:white;"> ژ</span></li>
<li class="symbol"><span>ر</span><span style="color:white;"> ء</span></li>
<li class="symbol"><span>ذ</span><span style="color:white;"> </span></li>
<li class="symbol"><span>د</span><span style="color:white;"> ډ</span></li>
<li class="symbol"><span>ړ</span><span style="color:white;"> ؤ</span></li>
<li class="symbol"><span>و</span><span style="color:white;"> ،</span></li>
<li class="symbol"><span>ږ</span><span style="color:white;"> .</span></li>
<li class="symbol"><span>/</span><span style="color:white;"> ؟</span></li>
<li class="right-shift lastitem">Shift</li>
</ul>
</div>
<script>
var myVar = setInterval(hideE, 3000);
function hideE() {
document.getElementById('note').style.display = "none";
}
function goAgain() {
window.location = "pashtoTyping.html";
}
document.getElementById("ctext").addEventListener("focus", function() {
setBlink();
});
window.addEventListener("load", function() {
var x = ['برګ','صابر','شین','زینه','ړوند','ظاهر','ږلۍ','طوطي','ډنډکی','ذلت','دال','ځاله','چوکۍ','څاروي','خاوره','حلوا','جوار','ثواب','ټال','تور','پښتانه','آسمان','روژه','قیچي','غلام','فضل','علم','وګورئ','هیلې','برګ','صابر','شین','زینه','ړوند','ظاهر','ږلۍ','طوطي','ډنډکی','ذلت','دال','ځاله','چوکۍ','څاروي','خاوره','حلوا','جوار','ثواب','ټال','تور','پښتانه','آسمان','روژه','قیچي','غلام','فضل','علم','وګورئ','هیلې'];
x = x.toString().replace(/,/g, " ");
document.getElementById("atext").innerHTML = x;
document.getElementById("ctext").focus();
document.getElementById("ctext").style.height = w3_getStyleValue(document.getElementById("atext"), "height");
});
function clickc() {
var c = document.getElementById("ctext");
var caretPos = c.innerText.length;
var el = c;
var range = document.createRange();
var sel = window.getSelection();
if (el.childNodes[0]) {
range.setStart(el.childNodes[0], caretPos);
range.collapse(true);
sel.removeAllRanges();
sel.addRange(range);
}
}
var blinktimeout, blinkstyle = "";
var cursorPos = 0;
function setBlink(a) {
var n = cursorPos;
if (blinkstyle == "") blinkstyle = "background-color:rgba(30, 144, 255,0.2)";
if (a == "stop") blinkstyle = "";
document.getElementById("atext").innerHTML = document.getElementById("atext").innerText.substr(0, n) + "<span style='" + blinkstyle + "'>" + document.getElementById("atext").innerText.substr(n, 1) + "</span>" + document.getElementById("atext").innerText.substr(n + 1);
if (a == "stop") return false;
if (blinkstyle == "background-color:rgba(30, 144, 255,0.2)") {
blinkstyle = "background-color:none";
} else {
blinkstyle = "background-color:rgba(30, 144, 255,0.2)";
}
blinktimeout = window.setTimeout(setBlink, 530);
}
var dheight = w3_getStyleValue(document.getElementById("dtext"), "height");
function checkScroll() {
var c = document.getElementById("ctext");
var d = document.getElementById("dtext");
var wh = window.innerHeight;
d.innerText = c.innerText + " passeord ";
new_dheight = w3_getStyleValue(document.getElementById("dtext"), "height");
var x = dheight.replace("px", "");
var y = new_dheight.replace("px", "");
if (y > x && ((Number(y) + Number(750))) > wh) {
window.scrollBy(0, y-x);
}
dheight = w3_getStyleValue(document.getElementById("dtext"), "height");
}
var start = 0, keycount = 0, wcount, charcount, errcount;
function ku(e) {
wcount = 0, charcount = 0, errcount = 0;
keycount++;
if (start == 0) {
initCount();
start = 1;
}
var a, b, c, i, txt = "", aARR, cARR;
checkScroll();
a = document.getElementById("atext").innerText;
b = document.getElementById("btext").innerText;
c = document.getElementById("ctext").innerText;
if ((keycount + 5) < c.length) {
c = "";
document.getElementById("ctext").innerText = c;
}
cursorPos = c.length;
window.clearTimeout(blinktimeout);
blinkstyle = "";
setBlink();
for (i = 0; i < c.length; i++) {
if (a[i] == c[i] || (a[i].charCodeAt(0) == 32 && c[i].charCodeAt(0) == 160)) {
charcount++;
txt += "<span class='corchar'>" + a[i] + "</span>";
} else {
errcount++;
txt += "<span class='errchar'>" + a[i] + "</span>";
}
if (a[i] == " ") {c = c.substr(0, i) + "|" + c.substr(i+1);}
}
document.getElementById("btext").innerHTML = txt + a.substr(i);
document.getElementById("characters").innerHTML = charcount;
document.getElementById("errors").innerHTML = errcount;
aARR = a.split(" ");
cARR = c.split("|");
for (i = 0; i < cARR.length; i++) {
if (cARR[i].trim() == aARR[i].trim()) {
wcount++;
}
}
document.getElementById("words").innerHTML = wcount;
}
timelength = 60;
var ttimer;
function initCount() {
document.getElementById("timefooter").innerHTML = " ";
document.getElementById("time").innerHTML = timelength;
ttimer = window.setInterval(updateTimer, 1000);
}
function updateTimer() {
timelength--;
document.getElementById("time").innerHTML = timelength;
if (timelength == 0) {
stopTyping();
window.clearInterval(ttimer);
displayScore();
}
}
function displayScore() {
document.getElementById("startdiv").style.display = "none";
document.getElementById("finishdiv").style.display = "block";
window.scrollTo(0, 0);
}
function stopTyping() {
document.getElementById("ctext").contentEditable = false;
window.addEventListener("keydown", function(e) {
if(window.event) { // IE
keynum = e.keyCode;
} else if(e.which){
keynum = e.which;
}
if (keynum == 32) {
e.preventDefault();
return false;
}
});
}
function kd(e) {
var cARR = [33,34,35,36,37,38,39,40];
if(window.event) { // IE
keynum = e.keyCode;
} else if(e.which){
keynum = e.which;
}
if (cARR.indexOf(keynum) > -1) {
e.preventDefault();
return false;
}
if (keynum == 86 && e.ctrlKey) {
e.preventDefault();
return false;
}
}
function unfocus() {
window.clearTimeout(blinktimeout);
setBlink("stop");
}
function dblclickc() {
document.getElementById("ctext").click();
}
function w3_getStyleValue(elmnt,style) {
if (window.getComputedStyle) {
return window.getComputedStyle(elmnt,null).getPropertyValue(style);
} else {
return elmnt.currentStyle[style];
}
}
</script>
</div>
</div>
</body>
</html>