-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
68 lines (52 loc) · 1.63 KB
/
script.js
File metadata and controls
68 lines (52 loc) · 1.63 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
let array = [0, 1, 2];
let arrayLength = 10;
const barMin = 1;
const barMax = 100;
const algorithms = {
"bubble": {
"name": "Bubble Sort",
"description": "",
"time_complexity": ""
}
}
const algorithmSelect = document.getElementById("algorithm-select")
const arrayLengthSlider = document.getElementById("array-length-slider");
const generateArrayButton = document.getElementById("generate-array-button");
const arrayInput = document.getElementById("array-input");
const sortButton = document.getElementById("sort-button");
const pauseButton = document.getElementById("pause-button");
const arrayLengthLabel = document.getElementById("array-length");
const barContainer = document.getElementById("bar-container");
algorithmSelect.addEventListener("input", () => {
setAlgorithm();
})
arrayLengthSlider.addEventListener("input", () => {
arrayLength = arrayLengthSlider.value;
arrayLengthLabel.textContent = arrayLength;
})
generateArrayButton.addEventListener("click", () => {
array = generateRandomArray();
renderBars();
})
sortButton.addEventListener("click", () => {
})
pauseButton.addEventListener("click", () => {
})
function generateRandomArray() {
const randomArray = Array.from({ length: arrayLength}, () => {
return Math.floor(Math.random() * (barMax - barMin + 1) + barMin);
})
arrayInput.value = randomArray;
console.log(randomArray);
return randomArray
}
function setAlgorithm() {
}
function renderBars() {
let barWidth = (100/arrayLength) + '%';
array.forEach()
barContainer.appendChild(bar)
}
function bubbleSort(array) {
return array
}