removed dependency on built-editor.min.js
[ccsdk/distribution.git] / dgbuilder / public / util / js / sliValues.js
1 /*
2 var sliValuesObj = {};
3 var rpcValues = {};
4 $(function(){
5  $.get("/loadJSFiles")
6         .done(function( data ) {
7                 if(data != undefined && data != null){
8                         console.dir(data.sliValuesObj[0]['AicHoming_PROPS']);
9                         console.dir(data.sliValuesObj[0]['AicHoming_RPCS']);
10                 }
11                         
12         })
13         .fail(function(err) {
14         })
15         .always(function() {
16         });
17 });
18 */
19 var global_editor ; 
20 function addParam(idVal){
21         //console.log(val);
22         //console.log(global_editor.getText());
23         if(global_added_obj["a" + idVal] != undefined &&  global_added_obj["a" + idVal] != null){
24                 global_added_obj["a" + idVal]= global_added_obj["a" + idVal]+1;
25                 $("#addCnt" +  + idVal).text("added " + global_added_obj["a" + idVal] + " times");
26         }else{
27                 global_added_obj["a" + idVal]= 1;
28                 $("#addCnt" +  + idVal).text("added " + global_added_obj["a" + idVal] + " time");
29         }
30         var nameVal = document.getElementById("a" + idVal).value;
31         var valueBoxVal = document.getElementById("valbox" + idVal).value;
32         //$("#btn" + idVal).val('Added');
33         //$("#btn" + idVal).attr('disabled','disabled'); 
34         //console.dir(nameVal);
35         //console.dir(valueBoxVal);
36
37
38         var paramElement = "<parameter name='" + nameVal + "' value='" + valueBoxVal + "'/>\n";
39         global_editor.setText(global_editor.getText() + paramElement);
40 }
41
42 var g_currValuesObj={};
43
44 function filterValues(filterVal){
45         global_added_obj={};
46         var matchedCnt =0;
47         var valuesObj = g_currValuesObj;
48         var newValuesObj ={};
49         var searchValues =[];
50         if(filterVal != null && filterVal != undefined){
51                 filterVal=filterVal.trim();
52         }       
53         searchValues = filterVal.split(/ /);
54         //console.log("filterVal:" + filterVal);
55         if(searchValues != null && searchValues != undefined){  
56                 for (var key in valuesObj) {
57                         if (valuesObj.hasOwnProperty(key)) {
58                                 var newArrObj = [];
59                                 if(Array.isArray(valuesObj[key])){
60                                         var arrObj=valuesObj[key];
61                                         var cnt=1;
62                                         for(var i=0;i<arrObj.length;i++){
63                                                 var foundCount = 0;
64                                                 for(var k=0;k<searchValues.length;k++){
65                                                         if(arrObj[i].indexOf(searchValues[k]) != -1){
66                                                                 foundCount++;
67                                                         }
68                                                 }
69                                                 if(foundCount == searchValues.length){
70                                                         matchedCnt++;
71                                                         newArrObj.push(arrObj[i]);
72                                                 }
73                                         }       
74                                         newValuesObj[key] =  newArrObj;
75                                 }               
76                         }
77                 }
78                 $("#matchedCntId").html(matchedCnt);
79         }else{
80                 newValuesObj = valuesObj;
81         }
82         var valuesHtml=buildValuesHtml(newValuesObj);   
83         valuesHtml+="</div>";
84         $("#sli-values-div").html(valuesHtml);
85 }
86
87 function buildValuesHtml(valuesObj){
88         var idCounter=0;
89         var htmlVal = "";
90         
91         for (var key in valuesObj) {
92              if (valuesObj.hasOwnProperty(key)) {
93                    var v = "<div style='font-weight:bold;font-size:1.0em;'><label>" + key + "<b/label>";
94                    if(Array.isArray(valuesObj[key])){
95                       var arrObj=valuesObj[key];
96                         var cnt=1;
97                       for(var i=0;i<arrObj.length;i++){
98                                 var idVal = idCounter++;
99                          var addBtn = "<input id='btn" + idVal + "' type='button' style='background-color:#D6EBFF;' value='Add as Parameter'" + "onclick='addParam(\"" + idVal + "\")'><div style='float:right' id='addCnt" + idVal + "'></div>";
100                         var variableBox = "";
101                         var valBox = "<input id='valbox" + idVal + "' type='text' style='width:500px;height:30px;' value=''>";
102                         if(arrObj[i] != undefined && arrObj[i].length <150){
103                                 //v += "<div style='width:1150px;background:aliceblue;border-color:aliceblue' class='valueBoxDiv' id='valueBoxDiv" + idVal +  "'>"  + "<input style='width:1125px;background:rgb(223, 191, 191);color:rgb(32, 45, 87);' type='text' readonly='1'  id='a" + idVal + "' onclick='selectText(\"" + idVal+"\",\"" + key + "\")' value='" +arrObj[i] + "' title='" + arrObj[i] + "' >" ;
104                                 v += "<div style='width:1150px;background:aliceblue;border-color:aliceblue' class='valueBoxDiv' id='valueBoxDiv" + idVal +  "'>"  + "<input style='width:1125px;background:aliceblue;color:rgb(32, 45, 87);' type='text' readonly='1'  id='a" + idVal + "' onclick='selectText(\"" + idVal+"\",\"" + key + "\")' value='" +arrObj[i] + "' title='" + arrObj[i] + "' >" ;
105                                 variableBox = "<input style='width:1125px' id='variableBox" + idVal + "' type='text' value='`$" + arrObj[i] + "`'>";
106                         }else{
107                                 v+= "<div style='width:1150px;background:aliceblue;border-color:aliceblue' class='valueBoxDiv' id='valueBoxDiv" + idVal +  "'>"  + "<textarea style='width:1125px;background:aliceblue;color:rgb(32, 45, 87);' readonly='1'  id='a" + idVal + "' onclick='selectText(\"" + idVal+"\",\"" + key + "\")' title='" + arrObj[i] + "' >"  + arrObj[i] + "</textarea>";
108                                 variableBox = "<textarea style='width:1125px' id='variableBox" + idVal + "' >`$" + arrObj[i] + "`'</textarea>";
109                         }
110                           v += "<div id='valAddDiv" +  idVal + "' style='display:none;'>" +  valBox + "&nbsp;&nbsp;" + addBtn + "</div>" +
111                            "<div id='variableBoxDiv" + idVal + "' style='display:none;color:rgb(32, 45, 87);'>Display as a variable<br>" + variableBox + "</div>" + "</div>";
112                         cnt++;
113                       }
114                       htmlVal+= v + "</div>";
115                                 }
116                    }
117              }
118         return htmlVal;
119 }
120
121
122 function getModuleName(){
123         var activeWorkspace=RED.view.getWorkspace();
124         var moduleName="";
125         RED.nodes.eachNode(function(n) {
126                 if (n.z == activeWorkspace) {
127                         if(n.type == 'service-logic'){
128                                 //console.log("getModuleName():<" + n.module + ">");
129                                 moduleName=n.module;
130                         }
131                 }
132         });
133         return moduleName;
134 }
135 var global_added_obj={};
136 var displayingRpcs = false;
137 function showRpcsValuesBox(editor,valuesObj){
138         displayingRpcs = true;
139         showValuesBox(editor,valuesObj);
140 }
141
142 function showValuesBox(editor,valuesObj){
143         var moduleName = getModuleName();       
144         var obj = valuesObj[moduleName];
145         //console.dir(valuesObj);
146         //console.dir(obj);
147         var moduleObj ={};
148         if(obj == undefined){
149                 moduleObj[moduleName] = ["No SLI values setup for this module " + moduleName + ".Upload the yang file for this module or if already uploaded ,load it from the Available Modules from the Menu."];      
150         }else{
151                 moduleObj[moduleName] = obj;
152         }
153         showValuesBoxForModule(editor,moduleObj,moduleName);    
154 }
155
156 function showValuesBoxForModule(editor,valuesObj,moduleName){
157         global_editor=editor;
158         g_currValuesObj = valuesObj;
159         //console.log(editor.getText());
160         //populate the valid SLI values
161         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='filter-id' type='text' value='' placeholder='To filter the values type words seperated by space in this box' onkeyup='filterValues(this.value)'></div><div style='float:left;color:green;font-size:0.8em' id='matchedCntId'></div><div style='clear:both'></div><div id='sli-values-div' style='width:1200px;'>" ;
162         valuesHtml+=buildValuesHtml(valuesObj); 
163        valuesHtml+="</div>";
164         global_added_obj={};
165
166         
167  var title = "SLI Values for Module " + moduleName;     
168         if(displayingRpcs){
169                 title = "RPCs for Module " + moduleName;
170         }
171         $('#sli-values-dialog').dialog({
172                        modal: false,
173                        title: title,
174                        width: 1200,
175                        height: 500,
176                        dialogClass: 'color-dialog',
177                        open: function () {
178                                 $("#sli-values-dialog").dialog("widget").find(".ui-dialog-buttonpane").css({'background': 'aliceblue'});
179                                 $(this).html(valuesHtml);
180                        },
181                        buttons: {
182                            Close: function () {
183                                 displayingRpcs = false;
184                               //$(this).dialog("close");
185                               $(this).dialog("destroy");
186                            }
187                        },
188                         close: function(ev,ui){
189                                 displayingRpcs = false;
190                                 $(this).dialog("destroy");
191                         }
192         }); // end dialog div
193 }
194
195 function showCommentsBox(){
196         var comments = $("#node-input-comments").val();
197         var commentsBoxHtml="<div><textarea style='font-size:18px;height:150px;width:390px;' id='taCommentId'>" + comments + "</textarea></div>" ;
198
199         var nodeName=$("#node-input-name").val();
200         $('#comments-dialog').dialog({
201                        modal: true,
202                        title: "Add comments for Node " + nodeName,
203                        width: 450,
204                        height: 300,     
205                         /*      
206                        open: function () {
207                                 $(this).html(commentsBoxHtml);
208                        },
209                         */
210                        buttons: {
211                            "Save Comments": function () {
212                                 var v=$("#taCommentId").val();
213                                 if(v != null){
214                                         v = v.trim();
215                                         if(v != ''){
216                                                 $("#node-input-btnComments").html("<span style='color:blue;'><b>View Comments</b></span>");
217                                         }else{
218                                                 $("#node-input-btnComments").html("<b>Add Comments</b>");
219                                         }
220                                 }
221                                 //console.log("value from text area" + v);
222                                 $("#node-input-comments").val(v);
223                                 $(this).dialog("close");
224                               //$(this).dialog("destroy");
225                            },
226                            Cancel: function () {
227                                 var v=$("#taCommentId").val();
228                                 if(v != null){
229                                         v = v.trim();
230                                         if(v != ''){
231                                                 $("#node-input-btnComments").html("<span style='color:blue;'><b>View Comments</b></span>");
232                                         }else{
233                                                 $("#node-input-btnComments").html("<b>Add Comments</b>");
234                                         }
235                                 }
236                                 $(this).dialog("close");
237                               //$(this).dialog("destroy");
238                            }
239                        },
240                         close: function(ev,ui){
241                                 //console.log("closing..");
242                                 $(this).dialog("destroy");
243                         }
244         }).html(commentsBoxHtml);
245
246         //console.log("done");
247 /*      
248         function functionDialogResize(ev,ui) {
249                 console.log("ui.size.height:" + ui.size.height);
250                 $(this).css("height",(ui.size.height-275)+"px");
251         };
252
253         $( this ).on("dialogresize", functionDialogResize);
254
255
256         $( this ).one("dialogopen", function(ev) {
257                 var size = $( "#sliValDiv" ).dialog('option','sizeCache-function');
258                 if (size) {
259                     functionDialogResize(null,{size:size});
260                 }
261          });
262 */
263
264 }
265
266 function selectText(objId,groupVal){
267         //console.log(objId + groupVal);        
268         //console.log(objId + groupVal);        
269         $(document).ready(function(){
270                 //console.log("doc ready");
271                 //console.dir($('#valAddDiv' +  objId));
272                 if ($('#valAddDiv' +  objId).is(":visible")) {
273                         $("#variableBoxDiv" +  objId ).hide("slow");
274                         //$("#a" +  objId ).css({"background": "rgb(223, 191, 191)",
275                         //                      "color": "rgb(32, 45, 87)"});
276                         $("#a" +  objId ).css({"background": "aliceblue",
277                                                 "color": "rgb(32, 45, 87)"});
278                                                 /*"color": "rgb(32, 45, 87)"});*/
279                         $("#valAddDiv" +  objId ).hide("slow");
280                         $("#valueBoxDiv" +objId).css({"border-color": "aliceblue",
281                                                         "border-width":"1px", 
282                                                         "background-color":"aliceblue",
283                                                         "border-style":"solid"});
284                         //$("#valAddDiv" +  objId ).fadeOut("slow");
285                 } else{
286                         $("#variableBoxDiv" +  objId ).show("slow");
287                         $("#valAddDiv" +  objId).show("slow");
288                         /*$("#valueBoxDiv" +objId).css({"border-color": "rgb(75, 111, 147)",
289                                                         "border-width":"5px", 
290                                                         "background-color": "rgb(223, 191, 191)",
291                                                         "border-style":"solid",
292                                                         "border-bottom": "5px solid rgb(75, 111, 147)"});
293                         */
294                         $("#valueBoxDiv" +objId).css({"border-color": "rgb(75, 111, 147)",
295                                                         "border-width":"3px", 
296                                                         "background-color": "aliceblue",
297                                                         "border-style":"solid",
298                                                         "border-bottom": "3px solid rgb(75, 111, 147)"});
299                         /*$("#a" +  objId ).css({"background": "rgb(223, 191, 191)",
300                                                 "color": "rgb(75, 111, 147)"});
301                         */
302                         $("#a" +  objId ).css({"background": "aliceblue",
303                                                 "color": "rgb(75, 111, 147)"});
304                 }
305                 $("#a" +  objId).select();
306         });
307         //console.log("group-heading" + objId);
308 //      var obj= document.getElementById("group-heading" +  objId);
309 //      obj.innerText = groupVal;
310 //      obj.style.color = "blue";
311 //      console.dir(obj);
312 }
313
314 function hidePrevGroup(objId){
315 //      console.log("mouseout" );
316 //      var obj= document.getElementById("group-heading" +  objId);
317 //      obj.innerText = "";
318 }
319 /*
320 function fixDiv() {
321     var $cache = $('#getFixed');
322     if ($(window).scrollTop() > 100)
323       $cache.css({
324         'position': 'fixed',
325         'top': '10px'
326       });
327     else
328       $cache.css({
329         'position': 'relative',
330         'top': 'auto'
331       });
332  }
333
334 $(window).scroll(fixDiv);
335
336 function isScrolledIntoView(elem)
337 {
338     var $elem = $(elem);
339     var $window = $(window);
340
341     var docViewTop = $window.scrollTop();
342     var docViewBottom = docViewTop + $window.height();
343
344     var elemTop = $elem.offset().top;
345     var elemBottom = elemTop + $elem.height();
346
347     return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop));
348 }
349 */
350
351 function getCommits(filePath){
352 var urlPath="/getCommitsInfo";
353 $.get(urlPath,{"filePath" : filePath })
354         .done(function( data ) {
355                 if(data != undefined && data != null){
356                         //console.log(data.stdout);
357                         var jsonObj = JSON.parse(data.stdout);
358                         var codeCloudFilesHtmlStr = $( "#codecloud-browser-dialog" ).html();
359                         var htmlStr = getCCFileHtmlStr(filePath,jsonObj,codeCloudFilesHtmlStr);
360                         $( "#codecloud-browser-dialog" ).html(htmlStr);
361                         /*
362                         for(var i=0;i<jsonObj.length;i++){
363                                 console.log("commit:" + jsonObj[i].commit);     
364                                 console.log("date:" + jsonObj[i].date); 
365                                 console.log("author:" + jsonObj[i].author);     
366                                 console.log("comment:" + jsonObj[i].comment);   
367                         }
368                         */
369                 }
370         })
371         .fail(function(err) {
372         })
373         .always(function() {
374         });
375 }
376
377
378 function getCCFileHtmlStr(filePath,rows,codeCloudFilesHtmlStr){
379         var styleStr = "<style> " + 
380                         "table#cct01 { width:100%; } \n" +
381                                 "table#cct01 th,table#cct01 td { border: 1px solid black; border-collapse: collapse; } \n" +
382                                 "table#cct01 th,table#cct01 td { padding: 5px; text-align: left; } \n" +
383                                 "table#cct01 tr:nth-child(even) { background-color: #eee; }\n" +
384                                 "table#cct01 tr:nth-child(odd) { background-color:#fff; }\n" +
385                                 "table#cct01 th { background-color: #65a9d7; color: white; }\n" +
386                                 "table#cct01 a { color: #337ab7; }\n" +
387                                 "table#cct01 a:link { color: #65a9d7; }\n" +
388                                 "table#cct01 a:visited { color: #636; }\n" + 
389                                 "table#cct01 a:hover { color: #3366CC; cursor: pointer }\n" + 
390                                 "table#cct01 a:active { color: #65a9d7 }\n" +
391                                 "table#cct01 caption { display: table-caption; text-align: center;  background: #eee; font-weight: bold; font-size: 1.1em; border: 1px solid black; }\n" + 
392                                 "</style>";
393                         var htmlStr="";
394                         //console.dir(rows);    
395                         if(rows != null && rows.length >0){
396                                 var alertDialog = '<div id="ccAlertdialog"></div>';
397                                 htmlStr= alertDialog +  "<div style='width:1050;height:650'>" + styleStr;
398                                 htmlStr += "<table id='cct01' >";
399                                 htmlStr += "<caption id='ccCaptionId'>" + filePath + "</caption>";
400                                 htmlStr += "<tr>";
401                                 htmlStr += "<th>Commit ID</th>" ;
402                                 htmlStr += "<th>Date</th>" ;
403                                 htmlStr += "<th>Author</th>" ;
404                                 htmlStr += "<th>Comment</th>" ;
405                                 htmlStr += "</tr>";
406                                 if(rows != null && rows.length == 0){
407                                         htmlStr += "<tr>";
408                                         htmlStr += "<td><b>No rows found</b></td>";
409                                         htmlStr += "</tr></table></div>";
410                                         return htmlStr;
411                                 }
412                                 for(var i=0;i<rows.length;i++){
413                                         var row = rows[i];
414                                         var _commitId = row.commit;
415                                         var dt = row.date;
416                                         var author = row.author;
417                                         var comment = row.comment;
418                                         htmlStr += "<tr>";
419                                         htmlStr += "<td><a onclick=\"javascript:importCCFlow('" + _commitId + "','" + filePath + "')\">" + _commitId + "</a></td>";
420                                         htmlStr += "<td>" + dt + "</td>";
421                                         htmlStr += "<td>" + author + "</td>";
422                                         htmlStr += "<td>" + comment + "</td>"; 
423                                         htmlStr += "</tr>";
424                                 }
425                                 htmlStr += "</table>";
426                                 htmlStr += "</div>";
427                         }
428         //console.log(htmlStr);
429         return htmlStr;
430 }
431
432
433 var gitLocalFlowFiles=[];
434 function filterGitLocalFlows(filterVal){
435         
436         var matchedCnt =0;
437         var valuesObj = gitLocalFlowFiles;
438         //console.dir(codeCloudFlowFiles);
439         var updatedValuesObj =[];
440         var searchValues =[];
441         if(filterVal != null && filterVal != undefined){
442                 filterVal=filterVal.trim();
443         }       
444         searchValues = filterVal.split(/ /);
445         //console.log("filterVal:" + filterVal);
446         //console.dir(searchValues);
447         if(searchValues != null && searchValues != undefined){  
448                 var foundCount = 0;
449                 for(var k=0;k<searchValues.length;k++){
450                         if(foundCount >0){
451                                 valuesObj=updatedValuesObj;
452                         }
453                         updatedValuesObj=[];
454                         for(var i=0;i<valuesObj.length;i++){
455                                 var patt = new RegExp(searchValues[k],"gi");
456                                 if(patt.test(valuesObj[i])){
457                                         foundCount++;
458                                         updatedValuesObj.push(valuesObj[i]);
459                                 }
460                         }
461                 }
462         }else{
463                 updatedValuesObj = valuesObj;
464         }
465         //console.dir(updatedValuesObj);
466         var html="<ul>";
467         if(updatedValuesObj != null){
468                 var files=updatedValuesObj;
469                 //console.dir(files);
470                 files.sort(function (a,b){
471                         if(a > b){
472                                 return 1;
473                         }else if(a <  b){
474                                 return -1;
475                         }else{  
476                                 return 0;
477                         }
478                 });
479                 for(var i=0;files != null && i<files.length;i++){
480                         html+="<li><a href=\"#\" onclick=\"importGitLocalFlow('" + files[i] + "')\">" + files[i] + "</a></li>";
481                 }
482         }
483                                         html+="</ul>";
484                                         html+="</div>";
485         $( "#gitlocal-data-container" ).html(html);
486 }
487
488 var codeCloudFlowFiles=[];
489 function filterFlows(filterVal){
490         
491         var matchedCnt =0;
492         var valuesObj = codeCloudFlowFiles;
493         //console.dir(codeCloudFlowFiles);
494         var updatedValuesObj =[];
495         var searchValues =[];
496         if(filterVal != null && filterVal != undefined){
497                 filterVal=filterVal.trim();
498         }       
499         searchValues = filterVal.split(/ /);
500         //console.log("filterVal:" + filterVal);
501         //console.dir(searchValues);
502         if(searchValues != null && searchValues != undefined){  
503                 var foundCount = 0;
504                 for(var k=0;k<searchValues.length;k++){
505                         for(var i=0;i<valuesObj.length;i++){
506                                 var patt = new RegExp(searchValues[k],"gi");
507                                 if(patt.test(valuesObj[i])){
508                                         foundCount++;
509                                         updatedValuesObj.push(valuesObj[i]);
510                                 }
511                         }
512                 }
513         }else{
514                 updatedValuesObj = valuesObj;
515         }
516         //console.dir(updatedValuesObj);
517         var html="<ul>";
518         if(updatedValuesObj != null){
519                 var files=updatedValuesObj;
520                 //console.dir(files);
521                 files.sort(function (a,b){
522                         if(a > b){
523                                 return 1;
524                         }else if(a <  b){
525                                 return -1;
526                         }else{  
527                                 return 0;
528                         }
529                 });
530                 for(var i=0;files != null && i<files.length;i++){
531                         html+="<li><a href=\"#\" onclick=\"getCommits('" + files[i] + "')\">" + files[i] + "</a></li>";
532                 }
533         }
534                                         html+="</ul>";
535                                         html+="</div>";
536         $( "#codecloud-data-container" ).html(html);
537 }
538
539 var yangFilesList=[];
540 /*
541 function filterYangFiles(filterVal){
542         
543         var matchedCnt =0;
544         var valuesObj = yangFilesList;
545         var updatedValuesObj =[];
546         var searchValues =[];
547         if(filterVal != null && filterVal != undefined){
548                 filterVal=filterVal.trim();
549         }       
550         searchValues = filterVal.split(/ /);
551         if(searchValues != null && searchValues != undefined){  
552                 var foundCount = 0;
553                 for(var k=0;k<searchValues.length;k++){
554                         for(var i=0;i<valuesObj.length;i++){
555                                 var patt = new RegExp(searchValues[k],"gi");
556                                 if(patt.test(valuesObj[i])){
557                                         foundCount++;
558                                         updatedValuesObj.push(valuesObj[i]);
559                                 }
560                         }
561                 }
562         }else{
563                 updatedValuesObj = valuesObj;
564         }
565         //console.dir(updatedValuesObj);
566         var html="<ul>";
567         if(updatedValuesObj != null){
568                 var files=updatedValuesObj;
569                 //console.dir(files);
570                 files.sort(function (a,b){
571                         if(a > b){
572                                 return 1;
573                         }else if(a <  b){
574                                 return -1;
575                         }else{  
576                                 return 0;
577                         }
578                 });
579                 for(var i=0;files != null && i<files.length;i++){
580                         html+="<li><a href=\"#\" onclick=\"getYangFile('" + files[i] + "')\">" + files[i] + "</a></li>";
581                 }
582         }
583                                         html+="</ul>";
584                                         html+="</div>";
585         $( "#list-yang-data-container" ).html(html);
586 }
587 */
588
589 function filterYangFiles(filterVal){
590         var matchedCnt =0;
591         var valuesObj = yangFilesList;
592         var updatedValuesObj =[];
593         var searchValues =[];
594         if(filterVal != null && filterVal != undefined){
595                 filterVal=filterVal.trim();
596         }       
597         searchValues = filterVal.split(/ /);
598         if(searchValues != null && searchValues != undefined){  
599                 var foundCount = 0;
600                 for(var k=0;k<searchValues.length;k++){
601                         for(var i=0;i<valuesObj.length;i++){
602                                 var patt = new RegExp(searchValues[k],"gi");
603                                 if(patt.test(valuesObj[i])){
604                                         foundCount++;
605                                         updatedValuesObj.push(valuesObj[i]);
606                                 }
607                         }
608                 }
609         }else{
610                 updatedValuesObj = valuesObj;
611         }
612         //console.dir(updatedValuesObj);
613         var html="<table id='yang-file-list-table'  border=1>";
614             html+="<tr>";
615             html+="<th>File</th>";
616             html+="<th>Delete</th>";
617             html+="</tr>";
618         
619         if(updatedValuesObj != null){
620                 var files=updatedValuesObj;
621                 //console.dir(files);
622                 files.sort(function (a,b){
623                         if(a > b){
624                                 return 1;
625                         }else if(a <  b){
626                                 return -1;
627                         }else{  
628                                 return 0;
629                         }
630                 });
631                 for(var i=0;files != null && i<files.length;i++){
632                          html+="<tr><td><a href=\"#\" onclick=\"getYangFile('" + files[i] + "')\">" + files[i] + "</a></td><td>" + "<input type='button'  onclick='deleteYangFile(\"" + files[i]  + "\")' value='Delete'></td></td></td></tr>";
633                 }
634         }
635         html+="</table>";
636         html+="</div>";
637
638         $( "#yang-files-data-container" ).html(html);
639 }
640
641 function getYangFile(fileName){
642         $("#dwnldYangFormId").remove();
643         //using form to submit
644         var form = $('<form id="dwnldYangFormId" method="POST" action="/downloadYang"></form>');
645         form.append('<input type="hidden" name="fileName" value="' + fileName + '"/>');
646         form.appendTo('body');
647         $("#dwnldYangFormId").submit();
648
649 }
650 function deleteYangFile(fileName){
651         var reqData= {"fileName":fileName};
652          $.post( "/deleteYangFile",reqData )
653                       .done(function( data ) {
654                       })
655                       .fail(function(err) {
656                           console.log( "error" + err );
657                        })
658                        .always(function() {
659                               $("#list-yang-browser-dialog").dialog("close");
660                                 $("#btn-list-yang-files").trigger("click");
661                        });
662 }
663
664 function importCCFlow(commitId,filePath){
665 var urlPath="/importCodeCloudFlow";
666 $.get(urlPath,{"commitId" : commitId,"filePath" : filePath })
667         .done(function( data ) {
668                 var nodeSet = getCurrentFlowNodeSet();
669                 //console.dir(nodeSet);
670                 if(nodeSet != null && nodeSet.length == 0){
671                         RED.view.setIsImportAction(true);
672                 }
673                 if(data != undefined && data != null){
674                         //console.log(data.stdout);
675                         var jsonObj = JSON.parse(data.stdout);
676                         $( "#codecloud-browser-dialog" ).dialog("close");
677                         RED.view.importNodes(JSON.stringify(jsonObj));
678                 }
679         })
680         .fail(function(err) {
681                 RED.notify("Could not import flow from code cloud.");   
682                 $( "#codecloud-browser-dialog").dialog("close");
683                 console.log( "error occured importing flow.");
684         })
685         .always(function() {
686         });
687 }
688
689 function importGitLocalFlow(filePath){
690 var urlPath="/importGitLocalFlow";
691 $.get(urlPath,{"filePath" : filePath})
692         .done(function( data ) {
693                 var nodeSet = getCurrentFlowNodeSet();
694                 //console.dir(nodeSet);
695                 if(nodeSet != null && nodeSet.length == 0){
696                         RED.view.setIsImportAction(true);
697                 }
698                 if(data != undefined && data != null){
699                         //console.log(data.stdout);
700                         var jsonObj;
701                         try{
702                                 jsonObj = JSON.parse(data.stdout);
703                                 $( "#gitlocal-browser-dialog" ).dialog("close");
704                                 RED.view.importNodes(JSON.stringify(jsonObj));
705                         }catch(err){
706                                 RED.notify("Could not import flow from Local Git Repository."); 
707                                 $( "#gitlocal-browser-dialog").dialog("close");
708                                 console.log( "error occured importing flow." + err);
709                         }
710                 }else{
711                         RED.notify("Could not import flow from Local Git Repository."); 
712                         $( "#gitlocal-browser-dialog").dialog("close");
713                         console.log( "error occured importing flow." + err);
714                 }
715         })
716         .fail(function(err) {
717                 RED.notify("Could not import flow from Local Git Repository."); 
718                 $( "#gitlocal-browser-dialog").dialog("close");
719                 console.log( "error occured importing flow.");
720         })
721         .always(function() {
722         });
723 }
724
725 var availableYangModules=[];
726 function filterYangModules(filterVal){
727         
728         var matchedCnt =0;
729         var valuesObj = availableYangModules ;
730         //console.dir(codeCloudFlowFiles);
731         var updatedValuesObj =[];
732         var searchValues =[];
733         if(filterVal != null && filterVal != undefined){
734                 filterVal=filterVal.trim();
735         }       
736         searchValues = filterVal.split(/ /);
737         //console.log("filterVal:" + filterVal);
738         //console.dir(searchValues);
739         if(searchValues != null && searchValues != undefined){  
740                 var foundCount = 0;
741                 for(var k=0;k<searchValues.length;k++){
742                         if(foundCount >0){
743                                 valuesObj=updatedValuesObj;
744                         }
745                         updatedValuesObj=[];
746                         for(var i=0;i<valuesObj.length;i++){
747                                 var patt = new RegExp(searchValues[k],"gi");
748                                 if(patt.test(valuesObj[i])){
749                                         foundCount++;
750                                         updatedValuesObj.push(valuesObj[i]);
751                                 }
752                         }
753                 }
754         }else{
755                 updatedValuesObj = valuesObj;
756         }
757         //console.dir(updatedValuesObj);
758         var html="";
759         html+="<table border=1>";
760         html+="<tr>";
761         html+="<th>#</th>";
762         html+="<th>Load</th>";
763         html+="<th>Module</th>";
764         html+="</tr>";
765
766         if(updatedValuesObj != null){
767                 var files=updatedValuesObj;
768                 //console.dir(files);
769                 files.sort(function (a,b){
770                         if(a > b){
771                                 return 1;
772                         }else if(a <  b){
773                                 return -1;
774                         }else{  
775                                 return 0;
776                         }
777                 });
778                 var count=1;
779                 for(var i=0;files != null && i<files.length;i++){
780                         var val = files[i].replace(/:.*/,"");
781                         if(files[i].indexOf(":checked") != -1){
782                                 html+="<tr><td>" + count +  "</td><td><input type='checkbox' checked value='" + val + "'></td><td>" + val + "</td></tr>";
783                         }else{
784                                 html+="<tr><td>" + count +   "</td><td><input type='checkbox' value='" + val + "'></td><td>" + val + "</td></tr>";
785                         }
786                         count++;
787                 }
788         }
789         html+="</table>";
790         html+="</div>";
791         $( "#yang-modules-data-container" ).html(html);
792 }
793 function filterCtxVariables(filterVal){
794         var matchedCnt =0;
795         var valuesObj = dgParsedParameters;
796         var newValuesObj ={};
797         var searchValues =[];
798         if(filterVal != null && filterVal != undefined){
799                 filterVal=filterVal.trim();
800         }       
801         searchValues = filterVal.split(/ /);
802         //console.log("filterVal:" + filterVal);
803         //console.log("searchValues:" + searchValues);
804         if(searchValues != undefined && searchValues != null  && searchValues != ""){   
805                 for (var key in valuesObj) {
806                         if (valuesObj.hasOwnProperty(key)) {
807                                 key = key.replace(/\$/g,"");
808                                 var foundCount=0;
809                                 for(var k=0;k<searchValues.length;k++){
810                                         if(key.indexOf(searchValues[k]) != -1){
811                                                 //console.log("key:" +key  + " searchValues:" + searchValues[k]);
812                                                 foundCount++;
813                                         }
814                                 }
815                                 if(foundCount == searchValues.length){
816                                                 matchedCnt++;
817                                                 newValuesObj[key] =  "";
818                                 }
819                         }
820                 }
821                 $("#ctxCountId").html(matchedCnt);
822         }else{
823                 newValuesObj = dgParsedParameters;
824                 $("#ctxCountId").html(Object.keys(newValuesObj).length);
825         }
826         //console.log("Object key length:" + Object.keys(g_currCtxVariables).length);
827         var valuesHtml=buildCtxValuesHtml(newValuesObj);        
828         valuesHtml+="</div>";
829         $("#ctx-values-div").html(valuesHtml);
830 }
831
832 function selectCtxText(objId,groupVal){
833         $(document).ready(function(){
834                 if ($('#ctxValAddDiv' +  objId).is(":visible")) {
835                         $("#aCtx" +  objId ).css({"background": "aliceblue",
836                                                 "color": "rgb(32, 45, 87)"});
837                                                 /*"color": "rgb(32, 45, 87)"});*/
838                         $("#ctxValAddDiv" +  objId ).hide("slow");
839                         $("#ctxValueBoxDiv" +objId).css({"border-color": "aliceblue",
840                                                         "border-width":"1px", 
841                                                         "background-color":"aliceblue",
842                                                         "border-style":"solid"});
843                         //$("#valAddDiv" +  objId ).fadeOut("slow");
844                 } else{
845                         $("#ctxValAddDiv" +  objId).show("slow");
846                         $("#ctxValueBoxDiv" +objId).css({"border-color": "rgb(75, 111, 147)",
847                                                         "border-width":"3px", 
848                                                         "background-color": "aliceblue",
849                                                         "border-style":"solid",
850                                                         "border-bottom": "3px solid rgb(75, 111, 147)"});
851                         $("#aCtx" +  objId ).css({"background": "aliceblue",
852                                                 "color": "rgb(75, 111, 147)"});
853                 }
854                 $("#aCtx" +  objId).select();
855         });
856         //console.log("group-heading" + objId);
857 //      var obj= document.getElementById("group-heading" +  objId);
858 //      obj.innerText = groupVal;
859 //      obj.style.color = "blue";
860 //      console.dir(obj);
861 }
862 function buildCtxValuesHtml(valuesObj){
863         var idCounter=0;
864         var htmlVal = "";
865         
866         var cnt=1;
867         var idVal = 0;
868         var v="";
869         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>&nbsp;string" +
870                                         "&nbsp;<input name='typeBtns-new' type='radio'  value='int'>&nbsp;int" +
871                                         "&nbsp;<input name='typeBtns-new' type='radio'  value='boolean'>&nbsp;boolean &nbsp;&nbsp;" +  "<input id='abtn-new' type='button' style='background-color:#D6EBFF;' value='Add'" + "onclick='addNewParameter(\"" + "-new" + "\")'>";
872         htmlVal = "<div  style='font-weight:bold;font-size:1.0em;'>" + newParameterRow + "</div>";
873         for (var key in valuesObj) {
874                 if (valuesObj.hasOwnProperty(key)) {
875                         key = key.replace(/\$/g,"");
876                         var inputStr = $("#test-dg-request").val();
877                         var inputObj = JSON.parse(inputStr);
878                         var paramsArrObj = inputObj["input"]["sli-parameter"];
879                         var alreadyAdded = false; 
880                         var intChecked = false;
881                         var booleanChecked = false;
882                         var prevValue="";
883                         for(var i=0;paramsArrObj != null && i<paramsArrObj.length ;i++){
884                                 if(paramsArrObj[i]["parameter-name"] == key){
885                                         if (paramsArrObj[i].hasOwnProperty("string-value")) {
886                                                 prevValue=paramsArrObj[i]["string-value"];
887                                         }else if(paramsArrObj[i].hasOwnProperty("int-value")) {
888                                                 intChecked = true;
889                                                 prevValue=paramsArrObj[i]["int-value"];
890                                         }else if(paramsArrObj[i].hasOwnProperty("boolean-value")) {
891                                                 booleanChecked = true;
892                                                 prevValue=paramsArrObj[i]["boolean-value"];
893                                         }
894                                         alreadyAdded = true;
895                                 }
896                         }
897                 }
898
899                         var idVal = idCounter++;
900                         v="<div  style='font-weight:bold;font-size:1.0em;'>";
901                         var addBtn ="";
902                         if(alreadyAdded){
903                                 addBtn = "<input id='ubtn" + idVal + "' type='button' style='background-color:#D6EBFF;' value='Update'" + "onclick='updateParamVal(\"" + idVal + "\")'>&nbsp;&nbsp;<input id='abtn" + idVal + "' type='button' style='background-color:#D6EBFF;' value='Delete'" + "onclick='updateParam(\"" + idVal + "\")'>";
904                         }else{
905                                 addBtn = "<input id='abtn" + idVal + "' type='button' style='background-color:#D6EBFF;' value='Add'" + "onclick='updateParam(\"" + idVal + "\")'>";
906                         }
907
908                         var typeBtns = "<input name='typeBtns" + idVal + "' type='radio'  value='string' checked>&nbsp;string" +
909                                         "&nbsp;<input name='typeBtns" + idVal + "' type='radio'  value='int'>&nbsp;int" +
910                                         "&nbsp;<input name='typeBtns" + idVal + "' type='radio'  value='boolean'>&nbsp;boolean"; 
911                                 if(intChecked){
912                                         typeBtns = "<input name='typeBtns" + idVal + "' type='radio'  value='string'>&nbsp;string" +
913                                         "&nbsp;<input name='typeBtns" + idVal + "' type='radio'  value='int' checked>&nbsp;int" +
914                                         "&nbsp;<input name='typeBtns" + idVal + "' type='radio'  value='boolean'>&nbsp;boolean"; 
915                                 }else if(booleanChecked){
916                                         typeBtns = "<input name='typeBtns" + idVal + "' type='radio'  value='string'>&nbsp;string" +
917                                         "&nbsp;<input name='typeBtns" + idVal + "' type='radio'  value='int'>&nbsp;int" +
918                                         "&nbsp;<input name='typeBtns" + idVal + "' type='radio'  value='boolean' checked>&nbsp;boolean"; 
919                                 }
920                         var valBox =typeBtns + "<br><br>" +  "<input id='avalbox" + idVal + "' type='text' style='width:500px;height:30px;' value='" + prevValue + "'>";
921                         
922                         if(key.length <150){
923                                 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 + "' >" ;
924                         }else{
925                                 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>";
926                         }
927                          v += "<div id='ctxValAddDiv" +  idVal + "' style='display:none;'>" +  valBox + "&nbsp;&nbsp;<div  id='btnsDivId" + idVal + "' style='display:inline'> " + addBtn + "</div></div></div>"; 
928                         cnt++;
929                         htmlVal+= v + "</div>";
930            }
931         return htmlVal;
932 }
933
934 function updateParam(idVal){
935         var action = $("#abtn" + idVal).val();
936         if(action == "Delete"){
937                 var nameVal = document.getElementById("aCtx" + idVal).value;
938                 var valueBoxVal = document.getElementById("avalbox" + idVal).value;
939                 //$("#addCnt" + idVal).text("added");
940                 var addBtn = "<input id='abtn" + idVal + "' type='button' style='background-color:#D6EBFF;' value='Add'" + "onclick='updateParam(\"" + idVal + "\")'>";
941                 $("#btnsDivId" + idVal).html(addBtn);
942                 var inputStr = $("#test-dg-request").val();
943                 var inputObj = JSON.parse(inputStr);
944                 var paramsArrObj = inputObj["input"]["sli-parameter"];
945                 var index = -1;
946                 for(var i=0;paramsArrObj != null && i<paramsArrObj.length ;i++){
947                         if(paramsArrObj[i]["parameter-name"] == nameVal){
948                                 index = i;
949                                 break;
950                         } 
951                 }
952
953                 if(index != -1){
954                         inputObj["input"]["sli-parameter"].splice(index,1);
955                 }
956                 var newInputStr = JSON.stringify(inputObj,null,4);
957                 $("#test-dg-request").val(newInputStr);
958         }else{
959                 var nameVal = document.getElementById("aCtx" + idVal).value;
960                 var valueBoxVal = document.getElementById("avalbox" + idVal).value;
961                 //$("#addCnt" + idVal).text("added");
962                 var addBtn = "<input id='ubtn" + idVal + "' type='button' style='background-color:#D6EBFF;' value='Update'" + "onclick='updateParamVal(\"" + idVal + "\")'>&nbsp;&nbsp;<input id='abtn" + idVal + "' type='button' style='background-color:#D6EBFF;' value='Delete'" + "onclick='updateParam(\"" + idVal + "\")'>";
963                 $("#btnsDivId" + idVal).html(addBtn);
964                 var inputStr = $("#test-dg-request").val();
965                 var inputObj = {};
966                 try{
967                         inputObj = JSON.parse(inputStr);
968                 }catch(e){
969                         $("#test-dg-response").val("Json parsing error" + e);
970                         return false;
971                 }
972                 var typeVal = "input[name=typeBtns" + idVal + "]:checked";
973                 var valType =$(typeVal).val();
974                 //console.log(valType);
975                 var parameterObj ={};
976                 if(valType == "string"){
977                         parameterObj = { "parameter-name" : nameVal, "string-value": valueBoxVal};      
978                 }else if(valType == "int"){
979                         var intValue = 0;
980                         try{
981                                 intValue = parseInt(valueBoxVal);
982                         }catch(e){
983                         }
984                         parameterObj = { "parameter-name" : nameVal, "int-value": intValue};    
985                 }else if(valType == "boolean"){
986                         var booleanValue = false;
987                         try{
988                                 booleanValue = JSON.parse(valueBoxVal);
989                         }catch(e){
990                         }
991                         parameterObj = { "parameter-name" : nameVal, "boolean-value": booleanValue};    
992                 }
993                 inputObj["input"]["sli-parameter"].push(parameterObj);
994                 var newInputStr ="";
995                 try{
996                  newInputStr = JSON.stringify(inputObj,null,4);
997                 }catch(e){
998                 }
999                 $("#test-dg-request").val(newInputStr);
1000                 //console.log("newInputStr:" + newInputStr);
1001         }
1002 }       
1003
1004 function addNewParameter(idVal){
1005                 var nameVal = document.getElementById("aCtx" + idVal).value;
1006                 var valueBoxVal = document.getElementById("avalbox" + idVal).value;
1007                 var inputStr = $("#test-dg-request").val();
1008                 var inputObj = {};
1009                 try{
1010                         inputObj = JSON.parse(inputStr);
1011                 }catch(e){
1012                         $("#test-dg-response").val("Json parsing error" + e);
1013                         return false;
1014                 }
1015                 var typeVal = "input[name=typeBtns" + idVal + "]:checked";
1016                 var valType =$(typeVal).val();
1017                 //console.log(valType);
1018                 var parameterObj ={};
1019                 if(valType == "string"){
1020                         parameterObj = { "parameter-name" : nameVal, "string-value": valueBoxVal};      
1021                 }else if(valType == "int"){
1022                         var intValue = 0;
1023                         try{
1024                                 intValue = parseInt(valueBoxVal);
1025                         }catch(e){
1026                         }
1027                         parameterObj = { "parameter-name" : nameVal, "int-value": intValue};    
1028                 }else if(valType == "boolean"){
1029                         var booleanValue = false;
1030                         try{
1031                                 booleanValue = JSON.parse(valueBoxVal);
1032                         }catch(e){
1033                         }
1034                         parameterObj = { "parameter-name" : nameVal, "boolean-value": booleanValue};    
1035                 }
1036                 inputObj["input"]["sli-parameter"].push(parameterObj);
1037                 var newInputStr ="";
1038                 try{
1039                  newInputStr = JSON.stringify(inputObj,null,4);
1040                 }catch(e){
1041                 }
1042                 $("#test-dg-request").val(newInputStr);
1043                 $( "#ctx-values-dialog" ).dialog("close");
1044                 $('.ui-button:contains("$Variables")').click();
1045                 //console.log("newInputStr:" + newInputStr);
1046 }
1047
1048 function updateParamVal(idVal){
1049                 var nameVal = document.getElementById("aCtx" + idVal).value;
1050                 //var valueBoxVal = document.getElementById("avalbox" + idVal).value;
1051                 var valueBoxVal = $("#avalbox" + idVal).val();
1052                 var inputStr = $("#test-dg-request").val();
1053                 var inputObj = {};
1054                 try{
1055                         inputObj = JSON.parse(inputStr);
1056                 }catch(e){
1057                         $("#test-dg-response").val("Json parsing error" + e);
1058                         return false;
1059                 }
1060                 var paramsArrObj = inputObj["input"]["sli-parameter"];
1061                 var index = -1;
1062                 for(var i=0;paramsArrObj != null && i<paramsArrObj.length ;i++){
1063                         if(paramsArrObj[i]["parameter-name"] == nameVal){
1064                                 var typeVal = "input[name=typeBtns" + idVal + "]:checked";
1065                                 var valType =$(typeVal).val();
1066                                 var parameterObj ={};
1067                                 if(valType == "string"){
1068                                         try{
1069                                                 delete paramsArrObj[i]["int-value"]; 
1070                                                 delete paramsArrObj[i]["boolean-value"]; 
1071                                         }catch(e){
1072                                         }
1073                                         paramsArrObj[i]["string-value"] = valueBoxVal;
1074                                 }else if(valType == "int"){
1075                                         var intValue = 0;
1076                                         try{
1077                                                 intValue = parseInt(valueBoxVal);
1078                                         }catch(e){
1079                                         }
1080                                         try{
1081                                                 delete paramsArrObj[i]["string-value"]; 
1082                                                 delete paramsArrObj[i]["boolean-value"]; 
1083                                         }catch(e){
1084                                         }
1085                                         paramsArrObj[i]["int-value"] = intValue;
1086                                 }else if(valType == "boolean"){
1087                                         var booleanValue = false;
1088                                         try{
1089                                                 booleanValue = JSON.parse(valueBoxVal);
1090                                         }catch(e){
1091                                         }
1092                                         try{
1093                                                 delete paramsArrObj[i]["int-value"]; 
1094                                                 delete paramsArrObj[i]["string-value"]; 
1095                                         }catch(e){
1096                                         }
1097                                         paramsArrObj[i]["boolean-value"] = booleanValue;
1098                                 }
1099                                 break;
1100                         } 
1101                 }
1102                 var newInputStr ="";
1103                 try{
1104                  newInputStr = JSON.stringify(inputObj,null,4);
1105                 }catch(e){
1106                 }
1107                 $("#test-dg-request").val(newInputStr);
1108 }       
1109
1110 function showCtxVariables(moduleName,rpcName){
1111         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;'>" ;
1112
1113         var currInput = $("#test-dg-request").val();
1114         var currInputObj =null;
1115         try{
1116                 currInputObj = JSON.parse(currInput);
1117         }catch(e){
1118                 $("#test-dg-response").val("Json parsing error" + e);
1119                 return false;
1120         }
1121         var cParams = null;
1122         if(currInputObj != null){
1123                 try{
1124                         cParams = currInputObj["input"]["sli-parameter"];
1125                 }catch(e){
1126                 }
1127         }
1128
1129         for(var i=0;cParams != null && i<cParams.length;i++){
1130                 var pName = cParams[i]["parameter-name"];
1131                 if(pName != undefined && pName != null && !dgParsedParameters.hasOwnProperty("$" + pName)){
1132                         dgParsedParameters[pName] = "";
1133                 }
1134         }
1135         valuesHtml+=buildCtxValuesHtml(dgParsedParameters);     
1136         valuesHtml+="</div>";
1137
1138         
1139         var title = "Context Variables used in this DG for Module: " + moduleName + " RPC: " + rpcName; 
1140         $('#ctx-values-dialog').dialog({
1141                        modal: false,
1142                        title: title,
1143                        width: 1200,
1144                        height: 500,
1145                        dialogClass: 'color-dialog',
1146                        open: function () {
1147                                 $("#ctx-values-dialog").dialog("widget").find(".ui-dialog-buttonpane").css({'background': 'aliceblue'});
1148                                 $(this).html(valuesHtml);
1149                        },
1150                        buttons: {
1151                            Close: function () {
1152                               $(this).dialog("destroy");
1153                            }
1154                        },
1155                         close: function(ev,ui){
1156                                 $(this).dialog("destroy");
1157                         }
1158         }); // end dialog div
1159       }
1160         function loadInputFile(fileName){
1161                 var reqData = {'fileName' :fileName};
1162                 $.post("/loadInputFile",reqData)
1163                       .done(function( data ) { 
1164                         if(data != undefined && data != null){
1165                                 //console.log("data" );
1166                                 //console.dir(data);
1167                                 $("#test-dg-request").val(data.input);
1168                         }
1169                         })
1170                         .fail(function(err) {
1171                                 $("#test-dg-response").val("could not load input file" + fileName);
1172                                 console.log( "failed to load input. " + err );
1173                         })
1174                         .always(function() {
1175                                 $( "#list-input-browser-dialog" ).dialog("close");
1176                         })
1177         }
1178
1179         function deleteInputFile(fileName){
1180                 var reqData = {'fileName' :fileName};
1181                 $.post("/deleteInputFile",reqData)
1182                       .done(function( data ) { 
1183                         })
1184                         .fail(function(err) {
1185                         })
1186                         .always(function() {
1187                                 $( "#list-input-browser-dialog" ).dialog("close");
1188                                 $('.ui-button:contains("Load")').click();
1189                         })
1190         }