Skip to content

Commit d6acbe4

Browse files
committed
Added algorithm tooltip
1 parent 302a8b3 commit d6acbe4

3 files changed

Lines changed: 11 additions & 6 deletions

File tree

index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,22 +94,22 @@
9494
Select at least 1 algorithm
9595
</a>
9696
</li>
97-
<li class="list-group-item">
97+
<li class="list-group-item" tabindex="0" data-bs-toggle="popover" data-bs-trigger="hover" data-bs-content="Uses priority queue and Manhattan distance.">
9898
<input class="form-check-input me-1" type="checkbox" value="" id="AStar"
9999
onchange="changeAlgorithm('AStar')">
100100
<label class="form-check-label" for="AStar">A* Search</label>
101101
</li>
102-
<li class="list-group-item">
102+
<li class="list-group-item" tabindex="0" data-bs-toggle="popover" data-bs-trigger="hover" data-bs-content="Uses priority queue and tentative distance.">
103103
<input class="form-check-input me-1" type="checkbox" value="" id="Dijkstra"
104104
onchange="changeAlgorithm('Dijkstra')">
105105
<label class="form-check-label" for="Dijkstra">Dijkstra's Algorithm</label>
106106
</li>
107-
<li class="list-group-item">
107+
<li class="list-group-item" tabindex="0" data-bs-toggle="popover" data-bs-trigger="hover" data-bs-content="Search all nodes at the present depth first.">
108108
<input class="form-check-input me-1" type="checkbox" value="" id="BFS"
109109
onchange="changeAlgorithm('BFS')">
110110
<label class="form-check-label" for="BFS">Breadth-first Search (BFS)</label>
111111
</li>
112-
<li class="list-group-item">
112+
<li class="list-group-item" tabindex="0" data-bs-toggle="popover" data-bs-trigger="hover" data-bs-content="Search all nodes with the largest depth first.">
113113
<input class="form-check-input me-1" type="checkbox" value="" id="DFS"
114114
onchange="changeAlgorithm('DFS')">
115115
<label class="form-check-label" for="DFS">Depth-first Search (DFS)</label>

js/grid.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class GRID {
8383
}
8484

8585
taxiCabDistanceToTarget(pos) {
86-
return Math.abs(pos[0] - this.target[0]) + Math.abs(pos[1] - this.target[1])
86+
return Math.abs(pos[0] - this.target[0]) + Math.abs(pos[1] - this.target[1]) - 1
8787
}
8888

8989
print() {

js/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ let PositionText
1111
let Algorithms = []
1212

1313
function init() {
14+
15+
// Init algorithm tool tips
16+
const popoverTriggerList = document.querySelectorAll('[data-bs-toggle="popover"]')
17+
const popoverList = [...popoverTriggerList].map(popoverTriggerEl => new bootstrap.Popover(popoverTriggerEl))
18+
1419
let gridString = sessionStorage.getItem("grid")
1520
let algorithmString = sessionStorage.getItem("algorithms")
1621
let benchmark = JSON.parse(sessionStorage.getItem("benchmark"))
@@ -198,7 +203,7 @@ function addEventListeners() {
198203
PositionViewer.show()
199204
})
200205
gridPreview.addEventListener("mouseleave", function () {
201-
PositionViewer.hide()
206+
PositionViewer.hide()
202207
})
203208
}
204209

0 commit comments

Comments
 (0)