diff --git a/js/vis_scripts.js b/js/vis_scripts.js index 20defcc..9c3c5c1 100644 --- a/js/vis_scripts.js +++ b/js/vis_scripts.js @@ -1,6 +1,25 @@ /*global window, $, vis, document, event, console */ /*jslint es6 */ - +const componentOptions = ["headphones", + "phone", + "pc", + "dac", + "amp", + "speakers"]; + +const connectorOptions = ["rca-rca", + "rca<>rca", + "rca<->rca", + "rca", + "speaker cable", + "optical"]; + +const destinationOptions = ["headphones", + "phone", + "pc", + "dac", + "amp", + "speakers"]; function countBodyRows(tableBody) { "use strict"; @@ -43,7 +62,7 @@ function makeSourceBox(value, number) { function makeDestinationBox(value, number) { "use strict"; - return makeTextInput("dest", "components", value, number); + return makeTextInput("dest", "destination", value, number); } @@ -127,17 +146,26 @@ function graphFromTable(tableObj) { // If source is not in nodes already, add it const srcID = addNodeFromCell(srcTD, nodes); + // Add the new source to the components list + addNewDataListItem('components', srcID); + // Get dest const dstTD = tableRow.children("td").eq(2); // If dest is not in nodes already, add it const dstID = addNodeFromCell(dstTD, nodes); + // Add the new destination to the components list + addNewDataListItem('destination', dstID); + // Find label from drop-down const connTD = tableRow.children("td").eq(1); const connLabel = connTD.children("input").first().val(); + // Add the new connection to the components list + addNewDataListItem('connectors', connLabel); + // Add edge edges.push({from: srcID, to: dstID, @@ -474,16 +502,10 @@ function makeTable(tableID) { function makeComponentsDatalist() { "use strict"; - const options = ["headphones", - "phone", - "pc", - "dac", - "amp", - "speakers"]; let datalistString = ""; - options.sort().forEach(function(option){ + componentOptions.sort().forEach(function(option){ datalistString += "