This repository was archived by the owner on Apr 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 105
Expand file tree
/
Copy pathindex.js
More file actions
123 lines (107 loc) · 2.56 KB
/
index.js
File metadata and controls
123 lines (107 loc) · 2.56 KB
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
const Typer = {
text: '',
accessCountimer: null,
index: 0,
speed: 2,
file: '',
accessCount: 0,
deniedCount: 0,
init: function () {
this.accessCountimer = setInterval(() => {
this.updLstChr();
}, 500);
fetch(this.file)
.then(response => response.text())
.then(data => {
this.text = data.slice(0, -1);
});
},
content: function () {
return $('#console').html();
},
write: function (str) {
$('#console').append(str);
return false;
},
addText: function (key) {
if (key.keyCode === 18) {
this.accessCount++;
if (this.accessCount >= 3) {
this.makeAccess();
}
} else if (key.keyCode === 20) {
this.deniedCount++;
if (this.deniedCount >= 3) {
this.makeDenied();
}
} else if (key.keyCode === 27) {
this.hidepop();
} else if (this.text) {
const cont = this.content();
if (cont.endsWith('|')) {
$('#console').html(cont.slice(0, -1));
}
if (key.keyCode !== 8) {
this.index += this.speed;
} else {
if (this.index > 0) {
this.index -= this.speed;
}
}
const text = this.text.substring(0, this.index);
const rtn = /\n/g;
$('#console').html(text.replace(rtn, '<br/>'));
window.scrollBy(0, 50);
}
if (key.preventDefault && key.keyCode !== 122) {
key.preventDefault();
}
if (key.keyCode !== 122) {
// prevent default behavior for other keys
key.returnValue = false;
}
},
updLstChr: function () {
const cont = this.content();
if (cont.endsWith('|')) {
$('#console').html(cont.slice(0, -1));
} else {
this.write('|');
}
},
makeAccess: function () {
// Implement the makeAccess function as needed
},
makeDenied: function () {
// Implement the makeDenied function as needed
},
hidepop: function () {
// Implement the hidepop function as needed
}
};
function replaceUrls(text) {
const http = text.indexOf('http://');
const space = text.indexOf('.me ', http);
if (space !== -1) {
const url = text.slice(http, space - 1);
return text.replace(url, `<a href="${url}">${url}</a>`);
} else {
return text;
}
}
Typer.speed = 3;
Typer.file = 'CodeNerve.txt';
Typer.init();
const timer = setInterval(t, 30);
function t() {
Typer.addText({ keyCode: 123748 });
if (Typer.index > Typer.text.length) {
clearInterval(timer);
}
}
document.addEventListener('keydown', function (e) {
if (e.keyCode === 27) {
// fast forward text
Typer.index = Typer.text.length;
}
});