-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
154 lines (151 loc) · 6.97 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
<html style="width:100%">
<head>
<meta charset="utf-8"/>
<!--Imported-->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="css/style.css" media="screen" />
<link rel="stylesheet" type="text/css" href="css/mb.slider.css" media="screen" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/jquery.metadata/2.0/jquery.metadata.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="js/jquery.mb.slider.js"></script>
<script src="js/d3.min.js"></script>
<!-- My Scripts -->
<script src="js/algorithms.js"></script>
<script src="js/visualization.js"></script>
<script src="js/songs.js"></script>
<script src="js/misc.js"></script>
<script>
//Global variables
var sliderVal = 10;//Speeds up and slows down frame draw loop
var paused = true;//Keeps graph from being drawn in frame draw loop
var stepActive = false;//When active, draws a single frame then becomes inactive
var frames = [];//Stores frames to draw
var frame = 0;//Stores current frame
var runningAlgorithm = "";
var song = songs.CMajorPent3Oct;
var currLoop = 0; //Used to breakout of draw loops
</script>
<script>
window.onload = function(){
//Initialize the speed slider
$("#speedSlider").mbSlider({
showVal: true,
formatValue: function (val) {
//console.log(val);
var formatVal = "Speed: " + val/10 + "x";
sliderVal = val/10;
return formatVal;
}
});
$("#pauseButton").click(function() {
if ($(this).text() == "Pause") {
$(this).text("Play");
paused = true;
}
else {
$(this).text("Pause");
paused = false;
}
});
$("#stepButton").click(function() {
stepActive = true;
});
$("#bubbleSort").click(function () {
playAlgorithm(bubblesort, 'bubbleSort');
});
$("#mergeSort").click(function () {
playAlgorithm(mergesort, 'mergeSort');
});
$("#quickSort").click(function () {
playAlgorithm(quicksort, 'quickSort');
});
$("#insertSort").click(function () {
playAlgorithm(insertsort, 'insertSort');
});
$("#selectSort").click(function () {
playAlgorithm(selectsort, 'selectSort');
});
$("#cocktailSort").click(function () {
playAlgorithm(cocktailsort, 'cocktailSort');
});
//Resets current sort by setting frame back to 0 and pausing
$("#resetButton").click(function(){
if (runningAlgorithm == "bubbleSort") {
$("#bubbleSort").trigger("click");
}
if (runningAlgorithm == "mergeSort") {
$("#mergeSort").trigger("click");
}
if (runningAlgorithm == "quickSort") {
$("#quickSort").trigger("click");
}
if (runningAlgorithm == "insertSort") {
$("#insertSort").trigger("click");
}
if (runningAlgorithm == "selectSort") {
$("#selectSort").trigger("click");
}
if (runningAlgorithm == "cocktailSort") {
$("#cocktailSort").trigger("click");
}
});
};
</script>
</head>
<body style="width:100%; margin:0px">
<div class="header">
<img class = "logo" src="misc/logo.png"/>
<div class="sortFunctionButtons">
<span class="sortFunctionButton" id="bubbleSort">BUBBLE</span>
<span class="sortFunctionButton" id="mergeSort">MERGE</span>
<span class="sortFunctionButton" id="quickSort">QUICK</span>
<span class="sortFunctionButton" id="insertSort">INSERT</span>
<span class="sortFunctionButton" id="selectSort">SELECT</span>
<span class="sortFunctionButton" id="cocktailSort">COCKTAIL</span>
</div>
</div>
<div class="mainArea">
<div style="width:55%; height:100%; float:left; margin-top:50px; padding-left:100px;" id="myDiv"></div>
<div style="width:45%; height:100%; float:right; overflow:auto; padding-top: 100px;" id="algStepsDiv"></div>
</div>
<div class="footer">
<div class="controls">
<div class="dropup" style="display: inline-block;">
<button class="btn btn-default dropdown-toggle footerButton" type="button" id="dropdownMenu2" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Choose Song
<span class="caret"></span>
</button>
<ul class="dropdown-menu" style="background-color:#F80A94;" aria-labelledby="dropdownMenu2">
<li class="songName" onclick="selectSong('harderBetterFasterStronger')">Harder Better Faster Stronger</li>
<li class="songName" onclick="selectSong('chromatic3Oct')">Chromatic 3 Oct</li>
<li class="songName" onclick="selectSong('CMajor3Oct')">C Major 3 Oct</li>
<li class="songName" onclick="selectSong('CMinor3Oct')">C Minor 3 Oct</li>
<li class="songName" onclick="selectSong('CMinorPent3Oct')">C Minor Pent 3 Oct</li>
<li class="songName" onclick="selectSong('MarioTheme')">Mario Theme</li>
<li class="songName" onclick="selectSong('DearlyBeloved')">Dearly Beloved</li>
<li class="songName" onclick="selectSong('ThemeOfThief')">Theme of Thief</li>
<li class="songName" onclick="selectSong('LostWoods')">Lost Woods</li>
<li class="songName" onclick="selectSong('CMajorPent3Oct')">C Major Pent 3 Oct</li>
<li class="songName" onclick="selectSong('CshMajorPent3Oct')">C# Major Pent 3 Oct</li>
<li class="songName" onclick="selectSong('DMajorPent3Oct')">D Major Pent 3 Oct</li>
<li class="songName" onclick="selectSong('DshMajorPent3Oct')">D# Major Pent 3 Oct</li>
<li class="songName" onclick="selectSong('EMajorPent3Oct')">E Major Pent 3 Oct</li>
<li class="songName" onclick="selectSong('FMajorPent3Oct')">F Major Pent 3 Oct</li>
<li class="songName" onclick="selectSong('FshMajorPent3Oct')">F# Major Pent 3 Oct</li>
<li class="songName" onclick="selectSong('GMajorPent3Oct')">G Major Pent 3 Oct</li>
<li class="songName" onclick="selectSong('GshMajorPent3Oct')">G# Major Pent 3 Oct</li>
<li class="songName" onclick="selectSong('AMajorPent3Oct')">A Major Pent 3 Oct</li>
<li class="songName" onclick="selectSong('BbMajorPent3Oct')">Bb Major Pent 3 Oct</li>
<li class="songName" onclick="selectSong('BMajorPent3Oct')">B Major Pent 3 Oct</li>
</ul>
</div>
<div id="speedSlider" style="float: left" data-property="{rangeColor:'#F80A94',negativeColor:'#F80A94', startAt:50, grid:1, maxVal:50, minVal:1}"></div>
<button type="button" class="btn footerButton" id="pauseButton">Play</button>
<button type="button" class="btn footerButton" id="stepButton">Step</button>
<button type="button" class="btn footerButton" id="resetButton">Reset</button>
<!--<button type="button" class="btn footerButton" id="songButton">Choose Song</button>-->
</div>
</div>
</body>
</html>