-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
38 lines (32 loc) · 842 Bytes
/
main.js
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
function $(elid) {
return document.getElementById(elid);
}
var cursor;
window.onload = init;
function init() {
cursor = $("cursor");
cursor.style.left = "0px";
}
function n12br(txt) {
return txt.replace(/\n/g, '');
}
function typeIt(from, e) {
e = e || window.event;
var w = $("typer");
var tw = from.value;
if (!pw) {
w.innerHTML = n12br(tw);
}
}
function moveIt(count, e) {
e = e || window.event;
var keycode = e.keycode || e.which;
if (keycode == 37 && parseInt(cursor.style.left) >= (0-((count - 1) * 10))) {
cursor.style.left = parseInt(cursor.style.left) - 10 + "px";
} else if (keycode == 39 && (parseInt(cursor.style.left) + 10) <= 0) {
cursor.style.left = parseInt(cursor.style.left) + 10 + "px";
}
}
function alert (txt) {
console.log(txt);
}