diff --git a/src/App.vue b/src/App.vue index 7fd7d85..c7f378a 100644 --- a/src/App.vue +++ b/src/App.vue @@ -26,7 +26,7 @@ let currentlySelected= null; let vertices= []; // [cx, xy, selected, name] let edges= []; // ["x1,y1", "x2,y2", forth, weight, v1, v2, passing] - + let currentlyLinked= []; return { placing, linking, @@ -35,6 +35,7 @@ currentlySelected, vertices, edges, + currentlyLinked } }, // computed: { @@ -86,7 +87,7 @@ }, unfocus() { // Remove the selection from the current Vertex - if (this.currentlySelected !== null) { + if (this.vertices.length && this.currentlySelected !== null) { // Take off the currentlySelected one this.vertices[this.currentlySelected][2]= false; } @@ -149,6 +150,13 @@ // The evaluation //let output= mooreDijkstra(this.getMatrix(), _from); // let result= mooreDijkstra(this.getMatrix(), _from)[`to-${_to}`]; // Get the path from _from to _to + + // We takeout all focuses + this.placing= false; + this.linking= false; + this.removing= false; + this.unfocus(); + let matrix= this.getMatrix(); let result= mooreDijkstra(matrix, _from)[`to-${_to}`]; if (result[1] == Infinity) @@ -156,6 +164,11 @@ else this.shortest= result[1]; // Color the path + if (this.currentlyLinked.includes(`${_from},${_to}`)) + // Reevaluate the path if it has already been calculated + this.clearPath(); + else + this.currentlyLinked.push(`${_from},${_to}`); // Save the already calculated path this.drawPath(result[0], color); }, drawPath(result, color) { @@ -179,6 +192,12 @@ }); } }, + clearPath() { + // Reset path colors + this.edges.forEach((edge) => { + edge[6]= false; + }); + }, donePlacing() { this.placing= false; this.unfocus(); diff --git a/src/components/SideBar.vue b/src/components/SideBar.vue index c7c0b3a..cd20608 100644 --- a/src/components/SideBar.vue +++ b/src/components/SideBar.vue @@ -86,8 +86,8 @@ let _to= document.getElementById('to'); if (parseInt(_from.value) == parseInt(_to.value)) alert("Please select two different vertices"); // Same vertex - else - this.$emit('evaluate', parseInt(_from.value), parseInt(_to.value), document.getElementById('color').value); + else if (_from.value !== "") + this.$emit('evaluate', parseInt(_from.value), parseInt(_to.value), document.getElementById('color').value); } }, } @@ -102,6 +102,10 @@ font-weight: 900; border-radius: 10px; } + button:hover { + background: #999999; + color: #ffffff; + } select { margin: 2px; cursor: pointer; @@ -114,7 +118,7 @@ bottom: 5px; } #submit:hover { - background: #4444ff; + background: #3333ff; } #submitter { position: absolute; @@ -125,10 +129,16 @@ color: #ffffff; margin-bottom: 20px; } + .removal:hover { + background: #ee0000; + } .active { background: #00bb00; color: #ffffff; } + .active:hover { + background: #009900; + } #sidebar { display: block; position: absolute;