diff options
Diffstat (limited to 'dgbuilder/public/util/js')
-rw-r--r-- | dgbuilder/public/util/js/dgeToXml.js | 15 | ||||
-rw-r--r-- | dgbuilder/public/util/js/sliValues.js | 429 | ||||
-rw-r--r-- | dgbuilder/public/util/js/validateNodeXml.js | 175 |
3 files changed, 615 insertions, 4 deletions
diff --git a/dgbuilder/public/util/js/dgeToXml.js b/dgbuilder/public/util/js/dgeToXml.js index 7582d275..e99d6495 100644 --- a/dgbuilder/public/util/js/dgeToXml.js +++ b/dgbuilder/public/util/js/dgeToXml.js @@ -695,7 +695,12 @@ function getNodeToXml(inputNodeSet){ } xmlStr+=node.xml; startTag = getStartTag(node); - fullXmlStr +=xmlStr; + //special handling for break node + if(xmlStr != undefined && xmlStr != null && xmlStr.trim() == "<break>"){ + fullXmlStr += "<break/>"; + }else{ + fullXmlStr +=xmlStr; + } /* if(level > 0){ var spacing = Array(level).join(" "); @@ -737,7 +742,9 @@ function getNodeToXml(inputNodeSet){ //append end tag if(startTag != ""){ - fullXmlStr += "</" + startTag + ">"; + if(startTag != "break"){ + fullXmlStr += "</" + startTag + ">"; + } /* if(level >0){ var spacing = Array(level).join(" "); @@ -1280,6 +1287,8 @@ function migrateNodes(jsonStr){ } }else if(node.xml != undefined && node.xml != null && node.xml.indexOf("<exists") != -1){ node.type="exists"; + }else if(node.xml != undefined && node.xml != null && node.xml.indexOf("<break") != -1){ + node.type="break"; }else if(node.xml != undefined && node.xml != null && node.xml.indexOf("<block") != -1){ node.type="block"; var atomic=getAttributeValue(node.xml,"atomic"); @@ -1293,6 +1302,8 @@ function migrateNodes(jsonStr){ } }else if(node.xml != undefined && node.xml != null && node.xml.indexOf("<save") != -1){ node.type="save"; + }else if(node.xml != undefined && node.xml != null && node.xml.indexOf("<while") != -1){ + node.type="while"; }else if(node.xml != undefined && node.xml != null && node.xml.indexOf("<switch") != -1){ node.type="switchNode"; }else if(node.xml != undefined && node.xml != null && node.xml.indexOf("<record") != -1){ diff --git a/dgbuilder/public/util/js/sliValues.js b/dgbuilder/public/util/js/sliValues.js index eae10601..4c0230b0 100644 --- a/dgbuilder/public/util/js/sliValues.js +++ b/dgbuilder/public/util/js/sliValues.js @@ -1,3 +1,21 @@ +/* +var sliValuesObj = {}; +var rpcValues = {}; +$(function(){ + $.get("/loadJSFiles") + .done(function( data ) { + if(data != undefined && data != null){ + console.dir(data.sliValuesObj[0]['AicHoming_PROPS']); + console.dir(data.sliValuesObj[0]['AicHoming_RPCS']); + } + + }) + .fail(function(err) { + }) + .always(function() { + }); +}); +*/ var global_editor ; function addParam(idVal){ //console.log(val); @@ -100,6 +118,7 @@ function buildValuesHtml(valuesObj){ return htmlVal; } + function getModuleName(){ var activeWorkspace=RED.view.getWorkspace(); var moduleName=""; @@ -646,6 +665,11 @@ function importCCFlow(commitId,filePath){ var urlPath="/importCodeCloudFlow"; $.get(urlPath,{"commitId" : commitId,"filePath" : filePath }) .done(function( data ) { + var nodeSet = getCurrentFlowNodeSet(); + //console.dir(nodeSet); + if(nodeSet != null && nodeSet.length == 0){ + RED.view.setIsImportAction(true); + } if(data != undefined && data != null){ //console.log(data.stdout); var jsonObj = JSON.parse(data.stdout); @@ -664,8 +688,13 @@ $.get(urlPath,{"commitId" : commitId,"filePath" : filePath }) function importGitLocalFlow(filePath){ var urlPath="/importGitLocalFlow"; -$.get(urlPath,{"filePath" : filePath }) +$.get(urlPath,{"filePath" : filePath}) .done(function( data ) { + var nodeSet = getCurrentFlowNodeSet(); + //console.dir(nodeSet); + if(nodeSet != null && nodeSet.length == 0){ + RED.view.setIsImportAction(true); + } if(data != undefined && data != null){ //console.log(data.stdout); var jsonObj; @@ -761,3 +790,401 @@ function filterYangModules(filterVal){ html+="</div>"; $( "#yang-modules-data-container" ).html(html); } +function filterCtxVariables(filterVal){ + var matchedCnt =0; + var valuesObj = dgParsedParameters; + var newValuesObj ={}; + var searchValues =[]; + if(filterVal != null && filterVal != undefined){ + filterVal=filterVal.trim(); + } + searchValues = filterVal.split(/ /); + //console.log("filterVal:" + filterVal); + //console.log("searchValues:" + searchValues); + if(searchValues != undefined && searchValues != null && searchValues != ""){ + for (var key in valuesObj) { + if (valuesObj.hasOwnProperty(key)) { + key = key.replace(/\$/g,""); + var foundCount=0; + for(var k=0;k<searchValues.length;k++){ + if(key.indexOf(searchValues[k]) != -1){ + //console.log("key:" +key + " searchValues:" + searchValues[k]); + foundCount++; + } + } + if(foundCount == searchValues.length){ + matchedCnt++; + newValuesObj[key] = ""; + } + } + } + $("#ctxCountId").html(matchedCnt); + }else{ + newValuesObj = dgParsedParameters; + $("#ctxCountId").html(Object.keys(newValuesObj).length); + } + //console.log("Object key length:" + Object.keys(g_currCtxVariables).length); + var valuesHtml=buildCtxValuesHtml(newValuesObj); + valuesHtml+="</div>"; + $("#ctx-values-div").html(valuesHtml); +} + +function selectCtxText(objId,groupVal){ + $(document).ready(function(){ + if ($('#ctxValAddDiv' + objId).is(":visible")) { + $("#aCtx" + objId ).css({"background": "aliceblue", + "color": "rgb(32, 45, 87)"}); + /*"color": "rgb(32, 45, 87)"});*/ + $("#ctxValAddDiv" + objId ).hide("slow"); + $("#ctxValueBoxDiv" +objId).css({"border-color": "aliceblue", + "border-width":"1px", + "background-color":"aliceblue", + "border-style":"solid"}); + //$("#valAddDiv" + objId ).fadeOut("slow"); + } else{ + $("#ctxValAddDiv" + objId).show("slow"); + $("#ctxValueBoxDiv" +objId).css({"border-color": "rgb(75, 111, 147)", + "border-width":"3px", + "background-color": "aliceblue", + "border-style":"solid", + "border-bottom": "3px solid rgb(75, 111, 147)"}); + $("#aCtx" + objId ).css({"background": "aliceblue", + "color": "rgb(75, 111, 147)"}); + } + $("#aCtx" + objId).select(); + }); + //console.log("group-heading" + objId); +// var obj= document.getElementById("group-heading" + objId); +// obj.innerText = groupVal; +// obj.style.color = "blue"; +// console.dir(obj); +} +function buildCtxValuesHtml(valuesObj){ + var idCounter=0; + var htmlVal = ""; + + var cnt=1; + var idVal = 0; + var v=""; + var newParameterRow = "New Parameter Name:<input style='width:500px' id='aCtx-new' type='text' value='' placeholder='Enter new parameter name'>Value:<input style='width:100px' id='avalbox-new' type='text' value=''> <input name='typeBtns-new' type='radio' value='string' checked> string" + + " <input name='typeBtns-new' type='radio' value='int'> int" + + " <input name='typeBtns-new' type='radio' value='boolean'> boolean " + "<input id='abtn-new' type='button' style='background-color:#D6EBFF;' value='Add'" + "onclick='addNewParameter(\"" + "-new" + "\")'>"; + htmlVal = "<div style='font-weight:bold;font-size:1.0em;'>" + newParameterRow + "</div>"; + for (var key in valuesObj) { + if (valuesObj.hasOwnProperty(key)) { + key = key.replace(/\$/g,""); + var inputStr = $("#test-dg-request").val(); + var inputObj = JSON.parse(inputStr); + var paramsArrObj = inputObj["input"]["sli-parameter"]; + var alreadyAdded = false; + var intChecked = false; + var booleanChecked = false; + var prevValue=""; + for(var i=0;paramsArrObj != null && i<paramsArrObj.length ;i++){ + if(paramsArrObj[i]["parameter-name"] == key){ + if (paramsArrObj[i].hasOwnProperty("string-value")) { + prevValue=paramsArrObj[i]["string-value"]; + }else if(paramsArrObj[i].hasOwnProperty("int-value")) { + intChecked = true; + prevValue=paramsArrObj[i]["int-value"]; + }else if(paramsArrObj[i].hasOwnProperty("boolean-value")) { + booleanChecked = true; + prevValue=paramsArrObj[i]["boolean-value"]; + } + alreadyAdded = true; + } + } + } + + var idVal = idCounter++; + v="<div style='font-weight:bold;font-size:1.0em;'>"; + var addBtn =""; + if(alreadyAdded){ + addBtn = "<input id='ubtn" + idVal + "' type='button' style='background-color:#D6EBFF;' value='Update'" + "onclick='updateParamVal(\"" + idVal + "\")'> <input id='abtn" + idVal + "' type='button' style='background-color:#D6EBFF;' value='Delete'" + "onclick='updateParam(\"" + idVal + "\")'>"; + }else{ + addBtn = "<input id='abtn" + idVal + "' type='button' style='background-color:#D6EBFF;' value='Add'" + "onclick='updateParam(\"" + idVal + "\")'>"; + } + + var typeBtns = "<input name='typeBtns" + idVal + "' type='radio' value='string' checked> string" + + " <input name='typeBtns" + idVal + "' type='radio' value='int'> int" + + " <input name='typeBtns" + idVal + "' type='radio' value='boolean'> boolean"; + if(intChecked){ + typeBtns = "<input name='typeBtns" + idVal + "' type='radio' value='string'> string" + + " <input name='typeBtns" + idVal + "' type='radio' value='int' checked> int" + + " <input name='typeBtns" + idVal + "' type='radio' value='boolean'> boolean"; + }else if(booleanChecked){ + typeBtns = "<input name='typeBtns" + idVal + "' type='radio' value='string'> string" + + " <input name='typeBtns" + idVal + "' type='radio' value='int'> int" + + " <input name='typeBtns" + idVal + "' type='radio' value='boolean' checked> boolean"; + } + var valBox =typeBtns + "<br><br>" + "<input id='avalbox" + idVal + "' type='text' style='width:500px;height:30px;' value='" + prevValue + "'>"; + + if(key.length <150){ + v += "<div style='width:1150px;background:aliceblue;border-color:aliceblue' class='ctxValueBoxDiv' id='ctxValueBoxDiv" + idVal + "'>" + "<input style='width:1125px;background:aliceblue;color:rgb(32, 45, 87);' type='text' readonly='1' id='aCtx" + idVal + "' onclick='selectCtxText(\"" + idVal+"\",\"" + key + "\")' value='" + key + "' title='" + key + "' >" ; + }else{ + v+= "<div style='width:1150px;background:aliceblue;border-color:aliceblue' class='ctxValueBoxDiv' id='ctxValueBoxDiv" + idVal + "'>" + "<textarea style='width:1125px;background:aliceblue;color:rgb(32, 45, 87);' readonly='1' id='actx" + idVal + "' onclick='selectCtxText(\"" + idVal+"\",\"" + key + "\")' title='" + key + "' >" + key + "</textarea></div>"; + } + v += "<div id='ctxValAddDiv" + idVal + "' style='display:none;'>" + valBox + " <div id='btnsDivId" + idVal + "' style='display:inline'> " + addBtn + "</div></div></div>"; + cnt++; + htmlVal+= v + "</div>"; + } + return htmlVal; +} + +function updateParam(idVal){ + var action = $("#abtn" + idVal).val(); + if(action == "Delete"){ + var nameVal = document.getElementById("aCtx" + idVal).value; + var valueBoxVal = document.getElementById("avalbox" + idVal).value; + //$("#addCnt" + idVal).text("added"); + var addBtn = "<input id='abtn" + idVal + "' type='button' style='background-color:#D6EBFF;' value='Add'" + "onclick='updateParam(\"" + idVal + "\")'>"; + $("#btnsDivId" + idVal).html(addBtn); + var inputStr = $("#test-dg-request").val(); + var inputObj = JSON.parse(inputStr); + var paramsArrObj = inputObj["input"]["sli-parameter"]; + var index = -1; + for(var i=0;paramsArrObj != null && i<paramsArrObj.length ;i++){ + if(paramsArrObj[i]["parameter-name"] == nameVal){ + index = i; + break; + } + } + + if(index != -1){ + inputObj["input"]["sli-parameter"].splice(index,1); + } + var newInputStr = JSON.stringify(inputObj,null,4); + $("#test-dg-request").val(newInputStr); + }else{ + var nameVal = document.getElementById("aCtx" + idVal).value; + var valueBoxVal = document.getElementById("avalbox" + idVal).value; + //$("#addCnt" + idVal).text("added"); + var addBtn = "<input id='ubtn" + idVal + "' type='button' style='background-color:#D6EBFF;' value='Update'" + "onclick='updateParamVal(\"" + idVal + "\")'> <input id='abtn" + idVal + "' type='button' style='background-color:#D6EBFF;' value='Delete'" + "onclick='updateParam(\"" + idVal + "\")'>"; + $("#btnsDivId" + idVal).html(addBtn); + var inputStr = $("#test-dg-request").val(); + var inputObj = {}; + try{ + inputObj = JSON.parse(inputStr); + }catch(e){ + $("#test-dg-response").val("Json parsing error" + e); + return false; + } + var typeVal = "input[name=typeBtns" + idVal + "]:checked"; + var valType =$(typeVal).val(); + //console.log(valType); + var parameterObj ={}; + if(valType == "string"){ + parameterObj = { "parameter-name" : nameVal, "string-value": valueBoxVal}; + }else if(valType == "int"){ + var intValue = 0; + try{ + intValue = parseInt(valueBoxVal); + }catch(e){ + } + parameterObj = { "parameter-name" : nameVal, "int-value": intValue}; + }else if(valType == "boolean"){ + var booleanValue = false; + try{ + booleanValue = JSON.parse(valueBoxVal); + }catch(e){ + } + parameterObj = { "parameter-name" : nameVal, "boolean-value": booleanValue}; + } + inputObj["input"]["sli-parameter"].push(parameterObj); + var newInputStr =""; + try{ + newInputStr = JSON.stringify(inputObj,null,4); + }catch(e){ + } + $("#test-dg-request").val(newInputStr); + //console.log("newInputStr:" + newInputStr); + } +} + +function addNewParameter(idVal){ + var nameVal = document.getElementById("aCtx" + idVal).value; + var valueBoxVal = document.getElementById("avalbox" + idVal).value; + var inputStr = $("#test-dg-request").val(); + var inputObj = {}; + try{ + inputObj = JSON.parse(inputStr); + }catch(e){ + $("#test-dg-response").val("Json parsing error" + e); + return false; + } + var typeVal = "input[name=typeBtns" + idVal + "]:checked"; + var valType =$(typeVal).val(); + //console.log(valType); + var parameterObj ={}; + if(valType == "string"){ + parameterObj = { "parameter-name" : nameVal, "string-value": valueBoxVal}; + }else if(valType == "int"){ + var intValue = 0; + try{ + intValue = parseInt(valueBoxVal); + }catch(e){ + } + parameterObj = { "parameter-name" : nameVal, "int-value": intValue}; + }else if(valType == "boolean"){ + var booleanValue = false; + try{ + booleanValue = JSON.parse(valueBoxVal); + }catch(e){ + } + parameterObj = { "parameter-name" : nameVal, "boolean-value": booleanValue}; + } + inputObj["input"]["sli-parameter"].push(parameterObj); + var newInputStr =""; + try{ + newInputStr = JSON.stringify(inputObj,null,4); + }catch(e){ + } + $("#test-dg-request").val(newInputStr); + $( "#ctx-values-dialog" ).dialog("close"); + $('.ui-button:contains("$Variables")').click(); + //console.log("newInputStr:" + newInputStr); +} + +function updateParamVal(idVal){ + var nameVal = document.getElementById("aCtx" + idVal).value; + //var valueBoxVal = document.getElementById("avalbox" + idVal).value; + var valueBoxVal = $("#avalbox" + idVal).val(); + var inputStr = $("#test-dg-request").val(); + var inputObj = {}; + try{ + inputObj = JSON.parse(inputStr); + }catch(e){ + $("#test-dg-response").val("Json parsing error" + e); + return false; + } + var paramsArrObj = inputObj["input"]["sli-parameter"]; + var index = -1; + for(var i=0;paramsArrObj != null && i<paramsArrObj.length ;i++){ + if(paramsArrObj[i]["parameter-name"] == nameVal){ + var typeVal = "input[name=typeBtns" + idVal + "]:checked"; + var valType =$(typeVal).val(); + var parameterObj ={}; + if(valType == "string"){ + try{ + delete paramsArrObj[i]["int-value"]; + delete paramsArrObj[i]["boolean-value"]; + }catch(e){ + } + paramsArrObj[i]["string-value"] = valueBoxVal; + }else if(valType == "int"){ + var intValue = 0; + try{ + intValue = parseInt(valueBoxVal); + }catch(e){ + } + try{ + delete paramsArrObj[i]["string-value"]; + delete paramsArrObj[i]["boolean-value"]; + }catch(e){ + } + paramsArrObj[i]["int-value"] = intValue; + }else if(valType == "boolean"){ + var booleanValue = false; + try{ + booleanValue = JSON.parse(valueBoxVal); + }catch(e){ + } + try{ + delete paramsArrObj[i]["int-value"]; + delete paramsArrObj[i]["string-value"]; + }catch(e){ + } + paramsArrObj[i]["boolean-value"] = booleanValue; + } + break; + } + } + var newInputStr =""; + try{ + newInputStr = JSON.stringify(inputObj,null,4); + }catch(e){ + } + $("#test-dg-request").val(newInputStr); +} + +function showCtxVariables(moduleName,rpcName){ + var valuesHtml="<style>.color-dialog {background:aliceblue;border-color:lightgrey;border-width:3px;border-style:solid; }</style><div style='float:left;width:1200px;background:aliceblue'><input style='width:1125px' id='ctx-filter-id' type='text' value='' placeholder='To filter the values type words seperated by space in this box' onkeyup='filterCtxVariables(this.value)'></div><div style='float:left;color:green;font-size:0.8em' id='ctxCountId'></div><div style='clear:both'></div><div id='ctx-values-div' style='width:1200px;'>" ; + + var currInput = $("#test-dg-request").val(); + var currInputObj =null; + try{ + currInputObj = JSON.parse(currInput); + }catch(e){ + $("#test-dg-response").val("Json parsing error" + e); + return false; + } + var cParams = null; + if(currInputObj != null){ + try{ + cParams = currInputObj["input"]["sli-parameter"]; + }catch(e){ + } + } + + for(var i=0;cParams != null && i<cParams.length;i++){ + var pName = cParams[i]["parameter-name"]; + if(pName != undefined && pName != null && !dgParsedParameters.hasOwnProperty("$" + pName)){ + dgParsedParameters[pName] = ""; + } + } + valuesHtml+=buildCtxValuesHtml(dgParsedParameters); + valuesHtml+="</div>"; + + + var title = "Context Variables used in this DG for Module: " + moduleName + " RPC: " + rpcName; + $('#ctx-values-dialog').dialog({ + modal: false, + title: title, + width: 1200, + height: 500, + dialogClass: 'color-dialog', + open: function () { + $("#ctx-values-dialog").dialog("widget").find(".ui-dialog-buttonpane").css({'background': 'aliceblue'}); + $(this).html(valuesHtml); + }, + buttons: { + Close: function () { + $(this).dialog("destroy"); + } + }, + close: function(ev,ui){ + $(this).dialog("destroy"); + } + }); // end dialog div + } + function loadInputFile(fileName){ + var reqData = {'fileName' :fileName}; + $.post("/loadInputFile",reqData) + .done(function( data ) { + if(data != undefined && data != null){ + //console.log("data" ); + //console.dir(data); + $("#test-dg-request").val(data.input); + } + }) + .fail(function(err) { + $("#test-dg-response").val("could not load input file" + fileName); + console.log( "failed to load input. " + err ); + }) + .always(function() { + $( "#list-input-browser-dialog" ).dialog("close"); + }) + } + + function deleteInputFile(fileName){ + var reqData = {'fileName' :fileName}; + $.post("/deleteInputFile",reqData) + .done(function( data ) { + }) + .fail(function(err) { + }) + .always(function() { + $( "#list-input-browser-dialog" ).dialog("close"); + $('.ui-button:contains("Load")').click(); + }) + } diff --git a/dgbuilder/public/util/js/validateNodeXml.js b/dgbuilder/public/util/js/validateNodeXml.js index 2291d865..d57ba0d7 100644 --- a/dgbuilder/public/util/js/validateNodeXml.js +++ b/dgbuilder/public/util/js/validateNodeXml.js @@ -190,7 +190,7 @@ function validateXML(xmlStr){ resp=true; errList=[]; elementCount=0; - //console.log("In validateXML xmlStr:" + xmlStr); + console.log("In validateXML xmlStr:" + xmlStr); //var xmlStr = $("#node-input-xml-editor").text(); if(xmlStr == null || xmlStr == undefined){ xmlStr = $("#node-input-xml-editor").text(); @@ -323,3 +323,176 @@ function showErrors() { } }); // end dialog div } + +var dgParsedParameters ; +var dgProcessNode ; +var callNodes ; +function extractSliParameters(xmlNode){ + if(xmlNode == null) return; + if(xmlNode.nodeName != "parsererror" && xmlNode.nodeName != "#text"){ + dgProcessNode = xmlNode.nodeName; + } + //console.log("processedNode:" + processedNode); + switch(xmlNode.nodeType){ + case 1: + elementCount++; + //ELEMENT_NODE + console.log(xmlNode.nodeName); + if(xmlNode.nodeName == "parsererror"){ + return; + } + dgProcessNode = xmlNode.nodeName; + if(dgProcessNode == "call"){ + var attrs1 = xmlNode.attributes; + var moduleName = ""; + var rpcName = ""; + for(var i=0;i<attrs1.length;i++){ + if(attrs1[i].nodeName == "module"){ + moduleName = attrs1[i].value; + }else if(attrs1[i].nodeName == "rpc"){ + rpcName = attrs1[i].value; + } + } + console.log(moduleName + "_" + rpcName); + callNodes[moduleName + "_" + rpcName] = ""; + }else if(dgProcessNode == "set"){ + //console.log("found set node"); + var childNodes = xmlNode.childNodes; + //console.dir(childNodes); + for(var k=0;k<childNodes.length;k++){ + if(childNodes[k].nodeName == "parameter"){ + var parameterName=""; + var parameterValue=""; + var attrs2 = childNodes[k].attributes; + for(var i=0;i<attrs2.length;i++){ + if(attrs2[i].nodeName == "name"){ + parameterName = attrs2[i].value; + }else if(attrs2[i].nodeName == "value"){ + parameterValue = attrs2[i].value; + } + } + //console.log("PARAMETER:" + parameterName + ":" + parameterValue ); + } + } + }else{ + var attrs = xmlNode.attributes; + for(var i=0;i<attrs.length;i++){ + //console.log("Attribute:" + attrs[i].nodeName); + //console.log("Value:" + attrs[i].value); + if(attrs[i].value != "" && attrs[i].value.indexOf("$")){ + var attributeValue = attrs[i].value.trim().replace(/`/g, ""); + var splitVariables = attributeValue.split(" "); + for(var k=0;k<splitVariables.length;k++){ + var v = splitVariables[k].trim(); + //check if + if(v.indexOf("$") == 0){ + dgParsedParameters[v] = ""; + } + } + + } + } + + var childNodes = xmlNode.childNodes; + for(var k=0;k<childNodes.length;k++){ + extractSliParameters(childNodes[k]); + } + break; + } + case 2: + //ATTRIBUTE_NODE + //console.log(xmlNode.nodeName); + break; + case 3: + //TEXT_NODE + //console.log(xmlNode.nodeValue); + break; + case 4: + //CDATA_SECTION_NODE + console.log("CDATA_SECTION_NODE"); + break; + case 5: + //ENTITY_REFERENCE_NODE + console.log("ENTITY_REFERENCE_NODE"); + break; + case 6: + //ENTITY_NODE + console.log("ENTITY_NODE"); + break; + case 7: + //PROCESSING_INSTRUCTION_NODE + console.log("PROCESSING_INSTRUCTION_NODE"); + break; + case 8: + //COMMENT_NODE + console.log("COMMENT_NODE"); + break; + case 9: + //DOCUMENT_NODE + console.log("DOCUMENT_NODE"); + break; + case 10: + //DOCUMENT_TYPE_NODE + console.log("DOCUMENT_TYPE_NODE"); + break; + case 11: + //DOCUMENT_TYPE_NODE + console.log("DOCUMENT_FRAGMENT_NODE"); + break; + case 12: + //NOTATION_NODE + console.log("DOCUMENT_FRAGMENT_NODE"); + break; + } +} + +function getSliParametersFromDG(xmlStr){ + dgProcessNode=""; + dgParsedParameters = {}; + callNodes ={} ; + //var exportableNodeSet = getCurrentFlowNodeSet(); + if(xmlStr == undefined || xmlStr == ""){ + xmlStr = getNodeToXml(); + //console.log("xmlStr:" + xmlStr); + } + if(xmlStr == null || xmlStr == "") return true; + xmlStr = xmlStr.trim(); + try{ + var xmlDoc; + if (window.DOMParser){ + try{ + var parser=new DOMParser(); + xmlDoc=parser.parseFromString(xmlStr,'text/xml'); + //console.log("Not IE"); + var n = xmlDoc.documentElement.nodeName; + if(n == "html"){ + resp=false; + console.log("Error parsing"); + return resp; + } + }catch(e){ + console.log("Error parsing" +e); + return false; + } + }else{ + try{ + //console.log("IE"); + // code for IE + xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); + xmlDoc.async=false; + xmlDoc.loadXMLString(xmlStr); + }catch(e){ + console.log("Error parsing" +e); + return false; + } + } + + //console.dir(xmlDoc); + extractSliParameters(xmlDoc.documentElement); + //console.dir(dgParsedParameters); + }catch(e){ + console.log("error:" +e); + RED.notify("<strong>XML validation</strong>: FAILED","error"); + return resp; + } +} |