-
Notifications
You must be signed in to change notification settings - Fork 0
/
ascii.js
58 lines (47 loc) · 1.65 KB
/
ascii.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
47
48
49
50
51
52
53
54
55
56
57
58
/*jshint esversion: 6 */
window.onload = function () {
"use strict";
let animationType = document.getElementById("animation");
let displayFont = document.getElementById("fontsize");
let turboMode = document.getElementById("turbo");
let startButton = document.getElementById("start");
let stopButton = document.getElementById("stop");
let animationArea = document.getElementById("text-area");
let animationIndex = 0;
let animationArr;
let timeOut = 200;
let timerId;
let fontSize = '12px';
//*******************************************************************
startButton.onclick = animate;
stopButton.onclick = stopAnimation;
animationType.onchange = getSelectedAnimation;
turboMode.onchange = () => {
timeOut = 50;
};
displayFont.onchange = ()=>{
animationArea.style.fontSize = FONTSIZE[displayFont.options[displayFont.selectedIndex].value];
};
function getSelectedAnimation() {
animationArr = ANIMATIONS[animationType.options[animationType.selectedIndex].value].split("=====\n");
animationArea.value = animationArr[animationIndex];
}
function animate() {
timerId = setInterval(display, timeOut);
}
function display() {
if (animationIndex < animationArr.length) {
animationArea.value = animationArr[animationIndex];
animationIndex++;
} else {
animationIndex = 0;
animationArea.value = animationArr[animationIndex];
}
}
function stopAnimation() {
animationIndex = 0;
timeOut = 200;
display();
clearInterval(timerId);
}
};