-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
98 lines (84 loc) · 2.51 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Visulize</title>
<link rel="stylesheet" href="/css/BubbleSort.css">
<style>
span {
.algorithm {
display: inline-block;
white-space: nowrap;
overflow: hidden;
animation: typing 5s steps(50, end), blink-caret 0.75s step-end infinite;
}
@keyframes typing {
from { width: 0; }
to { width: 100%; }
}
@keyframes blink-caret {
from, to { border-color: transparent; }
50% { border-color: black; }
}
</style>
</head>
<body>
<div>
<input type="text" placeholder="Enter Arrays Elements">
<button id="sortbutton" onclick="getNumbers()">Sort</button>
<div class="inputArray">inputArray
<div class="input-elements"></div>
</div>
</div>
<div class="main-output">output</div>
<div class="output">
</div>
<div id="sortAlgorithms"></div>
<div id="sortAlgorithms" class="algorithm"></div>
<script >
const algorithms = ["selection sort", "bubble sort", "merge sort", "quick sort", "insertion sort", "shell sort"];
const parentElement = document.getElementById('sortAlgorithms');
let algorithmIndex = 0;
let charIndex = 0;
let isDisplaying = false;
let isRemoving = false;
function displayAlgorithms() {
if (!isDisplaying && !isRemoving) {
isDisplaying = true;
const algorithm = algorithms[algorithmIndex];
const interval = setInterval(() => {
if (charIndex <= algorithm.length) {
parentElement.textContent = algorithm.substring(0, charIndex);
charIndex++;
} else {
clearInterval(interval);
isDisplaying = false;
isRemoving = true;
setTimeout(() => {
removeCharacters();
}, 1000);
}
}, 100);
}
}
function removeCharacters() {
const interval = setInterval(() => {
if (charIndex >= 0) {
parentElement.textContent = algorithms[algorithmIndex].substring(0, charIndex);
charIndex--;
} else {
clearInterval(interval);
algorithmIndex = (algorithmIndex + 1) % algorithms.length;
charIndex = 0;
isRemoving = false;
setTimeout(() => {
displayAlgorithms();
}, 500);
}
}, 50);
}
setInterval(displayAlgorithms, 6000);
</script>
</body>
</html>