diff --git a/app/app.js b/app/app.js index 4d84da6..b4773da 100644 --- a/app/app.js +++ b/app/app.js @@ -1,5 +1,95 @@ 'use strict' +function getClassXMLDir(){ + // // Use a real directory + // var classXMLDirValue = "'/home/walid/shared_on_wifi/xml/'" + // // Use null to be translated to None by the json parser + // // Follow https://docs.python.org/2/library/json.html#encoders-and-decoders + // classXMLDirValue = "null" + + var classXMLDir = ""; + + var checkboxValue = document.getElementById('class_xml_dir_check').checked; + if (checkboxValue == true) { + var classXMLDirValue; + + var textValue = document.getElementById('class_xml_dir_text').value; + if (textValue == '') { + classXMLDirValue = "null"; + } + else { + classXMLDirValue = "\""+ textValue +"\""; + } + + classXMLDir = '\"classXMLDir\":' + classXMLDirValue; + } + + return classXMLDir; +} + +function getClassXML(){ + var classXML = ""; + + var checkboxValue = document.getElementById('class_xml_check').checked; + if (checkboxValue == true) { + var classXMLValue; + + var textValue = document.getElementById('class_xml_text').value; + if (textValue == '') { + classXMLValue = "null"; + } + else { + classXMLValue = "\""+ textValue +"\""; + } + + classXML = '\"classXML\":' + classXMLValue; + } + + return classXML; +} + +function getNamespacePlaceholder(){ + var namespacePlaceholder = ""; + + var checkboxValue = document.getElementById('namespace_placeholder_check').checked; + if (checkboxValue == true) { + var namespacePlaceholderValue; + + var textValue = document.getElementById('namespace_placeholder_text').value; + if (textValue == '') { + namespacePlaceholderValue = "null"; + } + else { + namespacePlaceholderValue = "\""+ textValue +"\""; + } + + namespacePlaceholder = '\"NAMESPACE_PLACEHOLDER\":' + namespacePlaceholderValue; + } + + return namespacePlaceholder; +} + +function getOutputDir(){ + var outputDir = ""; + + var checkboxValue = document.getElementById('output_dir_check').checked; + if (checkboxValue == true) { + var outputDirValue; + + var textValue = document.getElementById('output_dir_text').value; + if (textValue == '') { + outputDirValue = "null"; + } + else { + outputDirValue = "\""+ textValue +"\""; + } + + outputDir = '\"OUTPUT_DIR\":' + outputDirValue; + } + + return outputDir; +} + function attachDOMListeners(){ document.getElementById('run_langform').addEventListener('click', () => { //langform_start @@ -10,16 +100,21 @@ function attachDOMListeners(){ var executablePath = "/home/walid/Documents/python_shell_simple_com/zmq_client"; - // Use a real directory - var classXMLDirValue = "'/home/walid/shared_on_wifi/xml/'" - // Use null to be translated to None by the json parser - // Follow https://docs.python.org/2/library/json.html#encoders-and-decoders - classXMLDirValue = "null" - - var classXMLDir = '\"classXMLDir\":' + classXMLDirValue +'' + var classXMLDir = getClassXMLDir(); + var classXML = getClassXML(); + var namespacePlaceholder = getNamespacePlaceholder(); + var outputDir = getOutputDir(); var settings = "\"settings\": {" - settings += classXMLDir + + if (classXMLDir != "" && classXML != "") + settings += classXMLDir + ", "; + if (classXML != "" && namespacePlaceholder != "") + settings += classXML + ", "; + if (namespacePlaceholder != "" && outputDir != "") + settings += namespacePlaceholder + ", "; + settings += outputDir; + settings += "}" var msg = "{" + settings + "}" @@ -29,7 +124,6 @@ function attachDOMListeners(){ var parameters = ["--msg="+msg, "--localhost="+localhost, "--port="+port]; - console.log("Set to send: "+ msg +" over "+ localhost +":"+ port +"."); var fs = require('fs'); diff --git a/index.html b/index.html index 1685bf7..39b4c29 100644 --- a/index.html +++ b/index.html @@ -15,10 +15,30 @@

Set Langform Settings and Run:


-
+
- + +
+ +
+ + + +
+ +
+ + + +
+ +
+ + + +
+