From e18b509bb9749c3768046fc71b43e56663db2a66 Mon Sep 17 00:00:00 2001 From: Nirmal Palanichamy Date: Wed, 28 Jul 2021 23:13:01 +0530 Subject: [PATCH 1/3] Disabled right click context menu within board Previously, right click on the board would open up the context menu. This is unnecessary and so it is disabled. --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 6ac8fdd..352e728 100644 --- a/index.html +++ b/index.html @@ -89,7 +89,7 @@
This short tutorial will walk you through all of the features of this applic
Pick an algorithm and visualize it!
- +
From 3a076f4094a4f4adf4bb5d22ea5cc95ba0bca702 Mon Sep 17 00:00:00 2001 From: Nirmal Palanichamy Date: Wed, 28 Jul 2021 23:21:34 +0530 Subject: [PATCH 2/3] Separated left and right mouse button functionalities Previously, both left and right mouse buttons could add as well as delete walls. Now, left mouse button will only be able to add walls and right mouse button will only be able to delete walls. --- public/browser/bundle.js | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/public/browser/bundle.js b/public/browser/bundle.js index 13b5b69..6a2856f 100644 --- a/public/browser/bundle.js +++ b/public/browser/bundle.js @@ -405,11 +405,12 @@ Board.prototype.addEventListeners = function() { e.preventDefault(); if (this.buttonsOn) { board.mouseDown = true; + board.buttonType = e.button; if (currentNode.status === "start" || currentNode.status === "target" || currentNode.status === "object") { board.pressedNodeStatus = currentNode.status; } else { board.pressedNodeStatus = "normal"; - board.changeNormalNode(currentNode); + board.changeNormalNode(currentNode,board.buttonType); } } } @@ -447,7 +448,7 @@ Board.prototype.addEventListeners = function() { } } } else if (board.mouseDown) { - board.changeNormalNode(currentNode); + board.changeNormalNode(currentNode,board.buttonType); } } } @@ -498,16 +499,24 @@ Board.prototype.changeSpecialNode = function(currentNode) { } }; -Board.prototype.changeNormalNode = function(currentNode) { +Board.prototype.changeNormalNode = function(currentNode,buttonType) { let element = document.getElementById(currentNode.id); let relevantStatuses = ["start", "target", "object"]; let unweightedAlgorithms = ["dfs", "bfs"] if (!this.keyDown) { if (!relevantStatuses.includes(currentNode.status)) { - element.className = currentNode.status !== "wall" ? - "wall" : "unvisited"; - currentNode.status = element.className !== "wall" ? - "unvisited" : "wall"; + if(currentNode.status !== "wall" && buttonType === 0){ + element.className = "wall"; + } + else if(currentNode.status === "wall" && buttonType === 2){ + element.className = "unvisited"; + } + if(element.className === "wall" && buttonType === 0){ + currentNode.status = "wall"; + } + else if(element.className !== "wall" && buttonType === 2){ + currentNode.status = "unvisited"; + } currentNode.weight = 0; } } else if (this.keyDown === 87 && !unweightedAlgorithms.includes(this.currentAlgorithm)) { From f11aa418dc49ec38a1b17bd77996eb6957911695 Mon Sep 17 00:00:00 2001 From: Nirmal Palanichamy Date: Wed, 28 Jul 2021 23:27:27 +0530 Subject: [PATCH 3/3] Added mouseup and mousedown functions on body Previously, when creating walls, it seemed to be kind of buggy. Also, when the user drags out of the page, on bringing the cursor back, it would continue to create walls. Now, mouseup function has been added to body to reduce buggy feeling and also, mouseleave function has been added to stop creating walls after leaving the page and returning back. NOTE: This was only done for normal elements and NOT special elements. --- public/browser/bundle.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/public/browser/bundle.js b/public/browser/bundle.js index 6a2856f..27a0604 100644 --- a/public/browser/bundle.js +++ b/public/browser/bundle.js @@ -461,6 +461,17 @@ Board.prototype.addEventListeners = function() { } } } + const body = document.querySelector("body"); + body.onmouseup = () => { + if(board.pressedNodeStatus === "normal"){ + this.mouseDown = false + } + } + body.onmouseleave = () => { + if(board.pressedNodeStatus === "normal"){ + this.mouseDown = false + } + } }; Board.prototype.getNode = function(id) {