-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
200 lines (200 loc) · 9.14 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
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<!DOCTYPE html>
<html>
<head>
<title>LibSort.js</title>
<script type="text/javascript" src="lib/libsort.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.4/lodash.min.js"></script>
<link rel="stylesheet" type="text/css" href="demo/index.css">
<script type="text/javascript" src="demo/index.js"></script>
</head>
<body>
<section id="visualizeSection">
<h2>Visualize LibSort.js</h2>
<div>
<label>
Mode:
<select id="visualizeMode">
<option value="height">Bar</option>
<option value="line">Line</option>
<option value="color">Color Wheel</option>
<option value="colorTilt">Color Wheel Tilt</option>
<option value="grayscale">Gray Wheel</option>
<option value="grayscaleTilt">Gray Wheel Tilt</option>
<option value="numbers">Numbers</option>
</select>
</label>
<select id="visualizeType">
<option value="shuffled">Shuffled</option>
<option value="sorted">Sorted</option>
<option value="nearly">Nearly</option>
<option value="reversed">Reversed</option>
<option value="random">Random</option>
</select>
<label>
Sync: <input type="checkbox" id="visualizeSync" onchange="document.getElementById('visualizeDelay').disabled = this.checked" />
</label>
<label>
Delay: <input type="number" id="visualizeDelay" min="1" value="10" />
</label>
<label>
Sort:
<select id="visualizeSort" onchange="
document.getElementById('visualizeMaxDelta').disabled = ['quicksort', 'mergesort'].indexOf(this.value) === -1;
document.getElementById('visualizeSwitchLimit').disabled = document.getElementById('visualizeSwitchFunction').disabled = ['quicksort', 'shellsort'].indexOf(this.value) === -1;
">
<option value="quicksort">Quicksort</option>
<option value="mergesort">Merge Sort</option>
<option value="heapsort">Heapsort</option>
<option value="redblacksort">Red-Black Sort</option>
<option value="shellsort">Shellsort</option>
<option value="selectionsort">Selection Sort</option>
<option value="insertionsort">Insertion Sort</option>
<option value="oddevensort">Odd-Even Sort</option>
<option value="cocktailshakersort">Cocktail Sort</option>
<option value="bubblesort">Bubble Sort</option>
<option value="bogosort">Bogosort</option>
<option value="bogobogosort">Bogobogosort</option>
</select>
</label>
<label>
Items: <input type="number" id="visualizeElements" min="0" value="100" />
</label>
<label>
Max Delta: <input type="number" id="visualizeMaxDelta" min="-1" value="0" />
</label>
<label>
Switch Limit: <input type="number" id="visualizeSwitchLimit" min="0" value="0" />
</label>
<label>
Switch Sort:
<select id="visualizeSwitchFunction">
<option value="quicksort">Quicksort</option>
<option value="mergesort">Merge Sort</option>
<option value="heapsort">Heapsort</option>
<option value="redblacksort">Red-Black Sort</option>
<option value="shellsort" selected>Shellsort</option>
<option value="selectionsort">Selection Sort</option>
<option value="insertionsort">Insertion Sort</option>
<option value="oddevensort">Odd-Even Sort</option>
<option value="cocktailshakersort">Cocktail Sort</option>
<option value="bubblesort">Bubble Sort</option>
<option value="bogosort">Bogosort</option>
<option value="bogobogosort">Bogobogosort</option>
</select>
</label>
<button onclick="doVisualize()">GO</button>
</div>
<div id="visualizeContainer">
<div id="visualize"></div>
<div id="visualizeStats">
<div>
<span id="visualizeStatSort">Quicksort</span><span id="visualizeStatSwitchContainer" style="display: none;">, until <span id="visualizeStatSwitchLimit">0</span> items, then <span id="visualizeStatSwitchSort">Insertion Sort</span></span><span id="visualizeStatDelayContainer" style="display: none;">, with <span id="visualizeStatDelay">0</span>ms delay</span>
</div>
<div>
Array Length: <span id="visualizeStatLength">0</span>
Comparisons: <span id="visualizeStatComparisons">0</span>
<span id="visualizeStatsOperationLabel">Swaps</span>: <span id="visualizeStatSwaps">0</span>
</div>
</div>
</div>
</section>
<section id="compareSection">
<h2>Compare Sorting Algorithms</h2>
<div>
<label>
Sort 1:
<select id="compareSort1" onchange="document.getElementById('compareSwitchLimit1').disabled = document.getElementById('compareSwitchFunction1').disabled = ['quicksort', 'shellsort'].indexOf(this.value) === -1;">
<option value="quicksort">Quicksort</option>
<option value="mergesort">Merge Sort</option>
<option value="heapsort">Heapsort</option>
<option value="redblacksort">Red-Black Sort</option>
<option value="shellsort">Shellsort</option>
<option value="selectionsort">Selection Sort</option>
<option value="insertionsort">Insertion Sort</option>
<option value="oddevensort">Odd-Even Sort</option>
<option value="cocktailshakersort">Cocktail Sort</option>
<option value="bubblesort">Bubble Sort</option>
<option value="bogosort">Bogosort</option>
<option value="bogobogosort">Bogobogosort</option>
<option value="native">Native (Browser)</option>
</select>
</label>
<label>
Switch Limit: <input type="number" id="compareSwitchLimit1" min="0" value="100" />
</label>
<label>
Switch Sort:
<select id="compareSwitchFunction1">
<option value="quicksort">Quicksort</option>
<option value="mergesort">Merge Sort</option>
<option value="heapsort">Heapsort</option>
<option value="redblacksort">Red-Black Sort</option>
<option value="shellsort" selected>Shellsort</option>
<option value="selectionsort">Selection Sort</option>
<option value="insertionsort">Insertion Sort</option>
<option value="oddevensort">Odd-Even Sort</option>
<option value="cocktailshakersort">Cocktail Sort</option>
<option value="bubblesort">Bubble Sort</option>
<option value="bogosort">Bogosort</option>
<option value="bogobogosort">Bogobogosort</option>
</select>
</label>
<br /><br />
<label>
Sort 2:
<select id="compareSort2" onchange="document.getElementById('compareSwitchLimit2').disabled = document.getElementById('compareSwitchFunction2').disabled = ['quicksort', 'shellsort'].indexOf(this.value) === -1;">
<option value="quicksort">Quicksort</option>
<option value="mergesort">Merge Sort</option>
<option value="heapsort">Heapsort</option>
<option value="redblacksort">Red-Black Sort</option>
<option value="shellsort">Shellsort</option>
<option value="selectionsort">Selection Sort</option>
<option value="insertionsort">Insertion Sort</option>
<option value="oddevensort">Odd-Even Sort</option>
<option value="cocktailshakersort">Cocktail Sort</option>
<option value="bubblesort">Bubble Sort</option>
<option value="bogosort">Bogosort</option>
<option value="bogobogosort">Bogobogosort</option>
<option value="native" selected>Native (Browser)</option>
</select>
</label>
<label>
Switch Limit: <input type="number" id="compareSwitchLimit2" min="0" value="0" disabled />
</label>
<label>
Switch Sort:
<select id="compareSwitchFunction2" disabled>
<option value="quicksort">Quicksort</option>
<option value="mergesort">Merge Sort</option>
<option value="heapsort">Heapsort</option>
<option value="redblacksort">Red-Black Sort</option>
<option value="shellsort" selected>Shellsort</option>
<option value="selectionsort">Selection Sort</option>
<option value="insertionsort">Insertion Sort</option>
<option value="oddevensort">Odd-Even Sort</option>
<option value="cocktailshakersort">Cocktail Sort</option>
<option value="bubblesort">Bubble Sort</option>
<option value="bogosort">Bogosort</option>
<option value="bogobogosort">Bogobogosort</option>
</select>
</label>
<br /><br />
<label>
Items: <input type="number" id="compareElements" min="1" value="100000" />
</label>
<label>
Rounds: <input type="number" id="compareRounds" min="1" value="4" />
</label>
<button onclick="doCompare()">GO</button>
</div>
<div id="outputContainer">
<div id="output">
<h3 id="outputHeader"></h3>
<pre name="sort1"></pre>
<pre name="sort2"></pre>
<pre name="debug"></pre>
</div>
</div>
</section>
</body>
</html>