-
Notifications
You must be signed in to change notification settings - Fork 0
/
DacteeloJs.js
46 lines (44 loc) · 1.14 KB
/
DacteeloJs.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
39
40
41
42
43
44
45
46
function ZTF(selector) {
const self = {
el: document.querySelector(selector),
html: () => self.el.innerText,
on: (event, callback) => {
self.el.addEventListener(event, callback);
},
attr: (name, value) => {
if (value == null) self.el.getAttribute(name);
else self.el.setAttribute(name, value);
},
type: (speed, delspeed) => {
let i = 0;
let txt = "\xa0" + self.el.innerHTML + "\xa0";
self.el.innerHTML = "";
function go() {
if (i < txt.length) {
self.el.innerHTML += txt.charAt(i);
i++;
setTimeout(go, speed);
} else {
setTimeout(backtrack, speed);
}
}
go();
function backtrack() {
if (i >= 0) {
let tmp = txt.substring(0, i);
self.el.innerHTML = tmp;
i--;
setTimeout(backtrack, speed - delspeed);
} else {
setTimeout(go, speed);
}
}
},
blink: (interval) => {
setInterval(function () {
self.el.style.display = self.el.style.display == "none" ? "" : "none";
}, interval);
},
};
return self;
}