-
Notifications
You must be signed in to change notification settings - Fork 0
/
event.js
76 lines (76 loc) · 2.16 KB
/
event.js
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
$(function () {
var t = document.getElementById("tableid");
$("#dijkstra").click(function () {
// alert($(this).text());
algorithm = $(this).text();
$("#visualize").html("Visualise " + algorithm);
// alert(algorithm);
});
$("#bfs").click(function () {
// alert($(this).text());
algorithm = $(this).text();
$("#visualize").html("Visualise " + algorithm);
});
$("#dfs").click(function () {
// alert($(this).text());
algorithm = $(this).text();
$("#visualize").html("Visualise " + algorithm);
});
$("#clearpath").click(function () {
visualised = false;
console.log("in clearpath");
for (var row = 0; row < 20; row++) {
for (var col = 0; col < 60; col++) {
cell = new node(row, col);
element = getCell(cell);
element.classList.remove("visited");
element.classList.remove("path");
}
}
});
$("#clearboard").click(function () {
visualised = false;
for (var row = 0; row < 20; row++) {
for (var col = 0; col < 60; col++) {
cell = new node(row, col);
element = getCell(cell);
element.classList.remove("visited");
element.classList.remove("path");
element.classList.remove("blocked");
}
}
});
// $('td').on({
// mouseenter: function(){
// $(this).css("background-color", "lightgray");
// },
// mouseleave: function(){
// $(this).css("background-color", "lightblue");
// },
// click: function(){
// $(this).css("background-color", "yellow");
// }
// });
$("#visualize").click(function () {
console.log("Visualizing ", start, end);
if (algorithm == null) {
alert('Please select an algorithm');
return;
// algo(relstart, relend);
}
$("#clearpath").trigger("click");
visualised = true;
if (algorithm == "dijkstra") {
console.log("Visualise " + algorithm);
}
else if (algorithm == "bfs") {
callbfs();
}
else if (algorithm == "dfs") {
console.log("Visualise " + algorithm);
}
else {
alert("Unknown " + algorithm);
}
});
});