//DISCLAIMER HERE// //Main Execution $(document).ready(function() { console.log("initial state is " + connectState); defaultViewState(); updateLog("v6 Webclient is loaded."); //Non Stop Events setInterval("Loop();", sampleRate); //Listeners $("#updateConfig").click(function() { getUserInputs(); updateLog("Connecting as " + userName + "..."); readProj(); $("#deleteChannel").show(); $("#deleteDevice").show(); }); //Main Nav $("#v6Configurator").click(function() { $("#v6Configurator").addClass("active"); $("#useCase1").removeClass("active"); $("#iotGateway").removeClass("active"); $("#configurator").show(); $("#deviceList").show(); $("#jsonObject").show(); $("#useCase1Panel").hide(); $("#iotGatewayPanel").hide(); }); $("#useCase1").click(function() { $("#v6Configurator").removeClass("active"); $("#useCase1").addClass("active"); $("#iotGateway").removeClass("active"); $("#configurator").hide(); $("#deviceList").show(); $("#jsonObject").show(); $("#useCase1Panel").show(); $("#iotGatewayPanel").hide(); }); $("#iotGateway").click(function() { $("#v6Configurator").removeClass("active"); $("#useCase1").removeClass("active"); $("#iotGateway").addClass("active"); $("#configurator").hide(); $("#deviceList").show(); $("#jsonObject").show(); $("#useCase1Panel").hide(); $("#iotGatewayPanel").show(); }); //ZE BUTTONS $("#createCh").click(function() { if (connectState) { getUserInputs(); updateLog("Creating a " + inputChannelType + " named " + inputChannel); createChannel(inputServer, inputChannelType, inputChannel); } else { updateLog("Please connect the server first"); } }); $("#createDevice").click(function() { if (connectState) { getUserInputs(); updateLog("Creating " + inputDevice + " with ID " + inputDevID + "for driver" + inputDriver); createDevice(inputServer, inputChannel, inputDevID, inputDevice, inputDriver); } else { updateLog("Please connect the server first"); } }); $("#createTag").click(function() { if (connectState) { getUserInputs(); updateLog("Creating " + inputTag + " with address " + inputTagAddr); createTag(inputServer, inputChannel, inputDevice, inputTag, inputTagAddr); getTags(inputDevice, inputChannel); } else { updateLog("Please connect the server first"); } }); $("#readProjObj").click(function() { updateLog("Reading ProjObj..."); if (projObj === null) { updateLog("ProjObj is not Loaded. Please connect to Server first"); // your code here. } else { editor.set(projObj); var stringJson = JSON.stringify(projObj, null, 2); //Stringify it and update into the text area updateText(stringJson); updateLog("Please view in in the editor panel"); } }); $("#getJSON").click(function() { updateLog("Getting the Obj"); var textInput = document.getElementById("textJsonInput").value; var jsonInput = JSON.parse(textInput); console.log(jsonInput); setJson(jsonInput); }); //Nav Menus $("#displayText").click(function() { //Text for the Json Object Viewer $("#displayText").addClass("active"); $("#displayTree").removeClass("active"); $("#displayTagList").removeClass("active"); $("#textJsonEditor").show(); $("#jsonEditorContainer").hide(); $("#tagListContainer").hide(); }); $("#displayTree").click(function() { //jsTree for the Json object view $("#displayTree").addClass("active"); $("#displayText").removeClass("active"); $("#displayTagList").removeClass("active"); $("#textJsonEditor").hide(); $("#jsonEditorContainer").show(); $("#tagListContainer").hide(); }); $("#displayTagList").click(function() { $("#displayTagList").addClass("active"); $("#displayText").removeClass("active"); $("#displayTree").removeClass("active"); $("#textJsonEditor").hide(); $("#jsonEditorContainer").hide(); $("#tagListContainer").show(); }); $("#displayChannelPanel").click(function() { $("#displayChannelPanel").addClass("active"); $("#displayDevicePanel").removeClass("active"); $("#displayTagPanel").removeClass("active"); $("#channelPanel").show(); $("#devicePanel").hide(); $("#tagPanel").hide(); }); $("#displayDevicePanel").click(function() { $("#displayChannelPanel").removeClass("active"); $("#displayDevicePanel").addClass("active"); $("#displayTagPanel").removeClass("active"); $("#channelPanel").hide(); $("#devicePanel").show(); $("#tagPanel").hide(); }); $("#displayTagPanel").click(function() { $("#displayChannelPanel").removeClass("active"); $("#displayDevicePanel").removeClass("active"); $("#displayTagPanel").addClass("active"); $("#channelPanel").hide(); $("#devicePanel").hide(); $("#tagPanel").show(); }); $("#drawTree").click(function() { console.log(channelList); drawTree(channelList); }); $("#createDeviceTree").click(function() { addChild(); }); $("#deleteChannel").click(function() { delChannel(cselected); }); $("#deleteDevice").click(function() { delDevice(dselected, cselected); }); $('#deleteTag').click(function() { delTag(dselected, cselected, tselected); updateTags(dselected, cselected); }); $("#importMdbsJSON").click(function() { updateLog("Loading file..."); $('input[type=file]').trigger('click'); loadMdbsFile(); updateLog("File loaded successfully, click the Create button."); }); $("#importABJSON").click(function() { updateLog("Loading file..."); $('input[type=file]').trigger('click'); loadABFile(); updateLog("File loaded successfully, click the Create button."); }); $("#modCh").click(function() { updateLog("Attempting to modify object for " + cselected); modChannel(cselected); }); $("#modDev").click(function() { updateLog("Attempting to modify object for " + dselected); modDevice(dselected); }); $("#modTag").click(function() { updateLog("Attempting to modify object for " + tselected); modTag(tselected, taddrselected); }); $("#createAll").click(function() { updateLog("Attempting to create all objects in template"); if (connectState) { getUserInputs(); //createChannel(inputServer, inputChannelType, inputChannel); //getUserInputs(); func1 = createChannel(inputServer, inputChannelType, inputChannel); func2 = createDevice(inputServer, inputChannel, inputDevID, inputDevice, inputDriver); func3 = createTag(inputServer, inputChannel, inputDevice, inputTag, inputTagAddr); $when(func1).done($when(func2).done(func3)); getTags(inputDevice, inputChannel); } else { updateLog("Please connect the server first"); } }); $('#tagReadResults').on('click', 'tr', function() { $("#displayChannelPanel").removeClass("active"); $("#displayDevicePanel").removeClass("active"); $("#displayTagPanel").addClass("active"); $("#channelPanel").hide(); $("#devicePanel").hide(); $("#tagPanel").show(); var td = this.cells[0]; // the first