-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
124 lines (118 loc) · 3.2 KB
/
app.js
File metadata and controls
124 lines (118 loc) · 3.2 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
124
const hamburger = document.querySelector(".hamburger");
const up = document.querySelector(".up");
const right = document.querySelector(".right");
const upList = document.querySelectorAll(".up>.head>.content>ul>li");
const rightList = document.querySelectorAll(".right>.head>.content>ul>li");
const exploring = document.querySelector(".exp");
const sortButton = document.querySelectorAll(".content>ul>li");
sortButton.forEach((ele) => {
ele.addEventListener("click", (e) => {
window.localStorage.setItem("sort", e.target.innerText);
SortName = e.target.innerText;
hamburger.querySelector(".menu").click();
});
});
function sortingFunction(name) {
if (name.includes("Merge")) {
mergeSort();
} else if (name.includes("Heap")) {
heapSort();
} else if (name.includes("Bubble")) {
bubbleSort();
} else if (name.includes("Insertion")) {
insertionSort();
} else if (name.includes("Selection")) {
selectionSort();
} else if (name.includes("Quick")) {
quickSort();
}
}
gsap.from(hamburger, {
duration: 0.5,
x: -100,
ease: "power4.out",
});
const heading = document.querySelectorAll(".sortingHeading>.heading>h1");
let arr = [
"siucs",
"dugcdh",
"aiuhfeg",
"efgudjhcms",
"efiugng",
"scusuyhms",
"auiugng",
"wtcusuthms",
"efiugng",
"sccusuitms",
"axting",
"ugsxrithms",
"sorting",
"algorithms",
];
let index = 0;
document.addEventListener("DOMContentLoaded", () => {
if (!location.href.includes("Sortx")) {
console.log("amit");
let interval = setInterval(() => {
if (index > 6) {
clearInterval(interval);
} else {
heading[0].innerText = arr[index * 2];
heading[1].innerText = arr[index * 2 + 1];
index++;
}
}, 100);
}
if (location.href.includes("Sortx")) {
const start = document.getElementById("start");
const random = document.getElementById("random");
let sort = localStorage.getItem("sort");
pageUpdation(sort);
start.addEventListener("click", () => {
size.setAttribute("disabled", "true");
speed.setAttribute("disabled", "true");
random.setAttribute("disabled", "true");
sortingFunction(sort);
});
random.addEventListener("click", () => {
let widthDiv = width / Number(size.value);
formationOfBars(size.value, widthDiv);
});
}
if (location.href.includes("index")) {
localStorage.clear();
}
});
function navigationOpen() {
gsap.to(".up", { duration: 1, top: "0%", ease: "power3.out" });
gsap.to(".right", { duration: 1, right: "0%", ease: "power3.out" });
gsap.from(upList, {
duration: 1,
y: -30,
opacity: 0,
stagger: 0.5,
delay: 0.5,
ease: "power1.out",
});
gsap.from(rightList, {
duration: 1,
x: 30,
opacity: 0,
stagger: 0.5,
delay: 0.1,
ease: "power1.out",
});
}
function navigationClose() {
gsap.to(".up", { duration: 1, top: "-100%", ease: "power3.out" });
gsap.to(".right", { duration: 1, right: "-100%", ease: "power3.out" });
}
hamburger.addEventListener("click", () => {
if (hamburger.classList.contains("on")) {
hamburger.classList.remove("on");
navigationClose();
} else {
hamburger.classList.add("on");
navigationOpen();
}
});