Revert "Add Edge - Alpha"
This reverts commit ac6d0c560e04e10e2a06302d1887725a45a369c7.
diff --git a/js/autocomplete.js b/js/autocomplete.js
index 4c32827..351c786 100644
--- a/js/autocomplete.js
+++ b/js/autocomplete.js
@@ -46,53 +46,20 @@
case "search":
// Move camera to desired node
cameraGoto(obj[n].x, obj[n].y);
- // Close the search box
- var searchBox = document.getElementById('searchBox');
- searchBox.style.display = "none";
-
- // Empty the input bar
- var searchInput = document.getElementById('searchInput');
- searchInput.value = "";
break;
- case "addEdge":
+ case "addEdge":
// Add an edge between A and B
- var sourceID = document.getElementById("node-id").innerText.substr(1);
- var edgeName = Math.min(sourceID, n) + "_" + Math.max(sourceID, n);
- if (!graf.edges[edgeName]) {
- graf.edges[edgeName] = {
- a: Math.min(sourceID, n),
- b: Math.max(sourceID, n),
- votes: 1
- };
-
- // Temporary fix, just for testing
- s.graph.addEdge({
- id: edgeName,
- source: sourceID,
- target: n,
- size: 0.5
- });
-
- clickNode(s, sourceID, s.graph.neighbors(sourceID));
- dialog.max();
-
- // Give a message of validation
- var edgeMSG = document.querySelector("#addedge-msg");
- addedEdgeMSG(edgeMSG);
-
- } else {
- alert("Edge already exists");
- }
-
- // Empty the input bar
- var addEdgeInput = document.getElementById('addedge-input');
- addEdgeInput.value = "";
-
- // Return to default view
- document.querySelector("#addedge-input").style.display = "none";
- document.querySelector("#edge-list").style.display = "block";
+ alert(obj[n].name);
break;
}
+
+ // Close the search box
+ var searchBox = document.getElementById('searchBox');
+ searchBox.style.display = "none";
+
+ // Empty the input bar
+ var searchInput = document.getElementById('searchInput');
+ searchInput.value = "";
/*close the list of autocompleted values,
(or any other open lists of autocompleted values:*/
@@ -178,22 +145,3 @@
closeAllLists(e.target);
});
}
-
-function addedEdgeMSG(edgeMSG) {
- var opacity = 8;
- edgeMSG.style.display = "block";
-
- var opacityChange = window.setInterval(function() {
- edgeMSG.style.color = "rgba(0,0,0, "+ opacity/10 +")";
- var edgeList = document.querySelector("#edge-list ul");
- edgeList.style.backgroundColor = "rgba(0,200,0, "+ opacity/10 +")";
- --opacity;
- console.log(opacity);
- }, 100);
-
- var backToDef = window.setTimeout(function() {
- edgeMSG.style.display = "none";
- edgeMSG.style.color = "black";
- window.clearInterval(opacityChange);
- }, 1000);
-}
\ No newline at end of file
diff --git a/js/modal.js b/js/modal.js
index 179e936..4138fde 100644
--- a/js/modal.js
+++ b/js/modal.js
@@ -9,7 +9,6 @@
// When the user clicks the button, open the box
searchButton.onclick = function() {
- dialog.close();
searchBox.style.display = "block";
// Focus on the search input bar
document.getElementById("searchInput").focus();
diff --git a/js/script.js b/js/script.js
index 6fcf868..5d7a5e4 100644
--- a/js/script.js
+++ b/js/script.js
@@ -63,7 +63,6 @@
s.graph.nodes().forEach(function(n) {
n.color = n.originalColor;
- n.label = n.originalLabel;
});
s.graph.edges().forEach(function(e) {
@@ -79,13 +78,6 @@
min: function() {
document.querySelector("#dialog").style.display = "none";
document.querySelector("#summary-dialog").style.display = "block";
- },
- addEdge: function() {
- document.querySelector("#addedge-input").style.display = "block";
- document.querySelector("#edge-list").style.display = "none";
- autocomplete(document.getElementById("addedge-input"), graf.nodes, "addEdge");
- // Focus on the addEdge input bar
- document.getElementById("addedge-input").focus();
}
};
@@ -130,7 +122,6 @@
s.graph.addNode({
id: graf.nodes[i].id,
label: graf.nodes[i].name,
- originalLabel: graf.nodes[i].name,
x: graf.nodes[i].x,
y: graf.nodes[i].y,
size: 10,
@@ -152,14 +143,32 @@
var nodeId = e.data.node.id,
toKeep = s.graph.neighbors(nodeId);
//toKeep[nodeId] = e.data.node;
- clickNode(s, nodeId, toKeep);
+
+ s.graph.nodes().forEach(function(n) {
+ if (toKeep[n.id] || n.id == nodeId) {
+ n.color = n.originalColor;
+ } else {
+ n.color = '#333';
+ }
+ });
+
+ s.graph.edges().forEach(function(e) {
+ if ((e.source == nodeId || e.target == nodeId) && (toKeep[e.source] || toKeep[e.target])) {
+ e.color = '#fff';
+ } else {
+ e.color = '#333';
+ }
+ });
+
+ s.refresh();
+
+ dialog.show(nodeId, toKeep);
});
document.querySelector("#quit-dialog").addEventListener("click", dialog.close);
document.querySelector("#quit2-dialog").addEventListener("click", dialog.close);
document.querySelector("#max-dialog").addEventListener("click", dialog.max);
document.querySelector("#min-dialog").addEventListener("click", dialog.min);
- document.querySelector("#addedge-button").addEventListener("click", dialog.addEdge);
document.querySelector("#zoomin").addEventListener("click", function() {
s.camera.goTo({
@@ -185,29 +194,4 @@
);
}
-function clickNode(s, nodeId, toKeep) {
- s.graph.nodes().forEach(function(n) {
- if (toKeep[n.id] || n.id == nodeId) {
- n.color = n.originalColor;
- n.label = n.originalLabel;
- console.log("Hola");
- } else {
- n.color = '#333';
- n.label = '';
- }
- });
-
- s.graph.edges().forEach(function(e) {
- if ((e.source == nodeId || e.target == nodeId) && (toKeep[e.source] || toKeep[e.target])) {
- e.color = '#fff';
- } else {
- e.color = '#333';
- }
- });
-
- s.refresh();
-
- dialog.show(nodeId, toKeep);
-}
-
window.addEventListener("load", init);