summaryrefslogtreecommitdiffstats
path: root/dgbuilder/public/util/js/sliValues.js
blob: 4c0230b0c42f830e9976d43b2cac95965f75eb8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

@media only all and (prefers-color-scheme: dark) {
.highlight .hll { background-color: #49483e }
.highlight .c { color: #75715e } /* Comment */
.highlight .err { color: #960050; background-color: #1e0010 } /* Error */
.highlight .k { color: #66d9ef } /* Keyword */
.highlight .l { color: #ae81ff } /* Literal */
.highlight .n { color: #f8f8f2 } /* Name */
.highlight .o { color: #f92672 } /* Operator */
.highlight .p { color: #f8f8f2 } /* Punctuation */
.highlight .ch { color: #75715e } /* Comment.Hashbang */
.highlight .cm { color: #75715e } /* Comment.Multiline */
.highlight .cp { color: #75715e } /* Comment.Preproc */
.highlight .cpf { color: #75715e } /* Comment.PreprocFile */
.highlight .c1 { color: #75715e } /* Comment.Single */
.highlight .cs { color: #75715e } /* Comment.Special */
.highlight .gd { color: #f92672 } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gi { color: #a6e22e } /* Generic.Inserted */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #75715e } /* Generic.Subheading */
.highlight .kc { color: #66d9ef } /* Keyword.Constant */
.highlight .kd { color: #66d9ef } /* Keyword.Declaration */
.highlight .kn { color: #f92672 } /* Keyword.Namespace */
.highlight .kp { color: #66d9ef } /* Keyword.Pseudo */
.highlight .kr { color: #66d9ef } /* Keyword.Reserved */
.highlight .kt { color: #66d9ef } /* Keyword.Type */
.highlight .ld { color: #e6db74 } /* Literal.Date */
.highlight .m { color: #ae81ff } /* Literal.Number */
.highlight .s { color: #e6db74 } /* Literal.String */
.highlight .na { color: #a6e22e } /* Name.Attribute */
.highlight .nb { color: #f8f8f2 } /* Name.Builtin */
.highlight .nc { color: #a6e22e } /* Name.Class */
.highlight .no { color: #66d9ef } /* Name.Constant */
.highlight .nd { color: #a6e22e } /* Name.Decorator */
.highlight .ni { color: #f8f8f2 } /* Name.Entity */
.highlight .ne { color: #a6e22e } /* Name.Exception */
.highlight .nf { color: #a6e22e } /* Name.Function */
.highlight .nl { color: #f8f8f2 } /* Name.Label */
.highlight .nn { color: #f8f8f2 } /* Name.Namespace */
.highlight .nx { color: #a6e22e } /* Name.Other */
.highlight .py { color: #f8f8f2 } /* Name.Property */
.highlight .nt { color: #f92672 } /* Name.Tag */
.highlight .nv { color: #f8f8f2 } /* Name.Variable */
.highlight .ow { color: #f92672 } /* Operator.Word */
.highlight .w { color: #f8f8f2 } /* Text.Whitespace */
.highlight .mb { color: #ae81ff } /* Literal.Number.Bin */
.highlight .mf { color: #ae81ff } /* Literal.Number.Float */
.highlight .mh { color: #ae81ff } /* Literal.Number.Hex */
.highlight .mi { color: #ae81ff } /* Literal.Number.Integer */
.highlight .mo { color: #ae81ff } /* Literal.Number.Oct */
.highlight .sa { color: #e6db74 } /* Literal.String.Affix */
.highlight .sb { color: #e6db74 } /* Literal.String.Backtick */
.highlight .sc { color: #e6db74 } /* Literal.String.Char */
.highlight .dl { color: #e6db74 } /* Literal.String.Delimiter */
.highlight .sd { color: #e6db74 } /* Literal.String.Doc */
.highlight .s2 { color: #e6db74 } /* Literal.String.Double */
.highlight .se { color: #ae81ff } /* Literal.String.Escape */
.highlight .sh { color: #e6db74 } /* Literal.String.Heredoc */
.highlight .si { color: #e6db74 } /* Literal.String.Interpol */
.highlight .sx { color: #e6db74 } /* Literal.String.Other */
.highlight .sr { color: #e6db74 } /* Literal.String.Regex */
.highlight .s1 { color: #e6db74 } /* Literal.String.Single */
.highlight .ss { color: #e6db74 } /* Literal.String.Symbol */
.highlight .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #a6e22e } /* Name.Function.Magic */
.highlight .vc { color: #f8f8f2 } /* Name.Variable.Class */
.highlight .vg { color: #f8f8f2 } /* Name.Variable.Global */
.highlight .vi { color: #f8f8f2 } /* Name.Variable.Instance */
.highlight .vm { color: #f8f8f2 } /* Name.Variable.Magic */
.highlight .il { color: #ae81ff } /* Literal.Number.Integer.Long */
}
@media (prefers-color-scheme: light) {
.highlight .hll { background-color: #ffffcc }
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #aa0000 } /* Generic.Error */
.highlight .gh { color: #333333 } /* Generic.Heading */
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #555555 } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #666666 } /* Generic.Subheading */
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #008800 } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */
.highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */
.highlight .na { color: #336699 } /* Name.Attribute */
.highlight .nb { color: #003388 } /* Name.Builtin */
.highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */
.highlight .no { color: #003366; font-weight: bold } /* Name.Constant */
.highlight .nd { color: #555555 } /* Name.Decorator */
.highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */
.highlight .nl { color: #336699; font-style: italic } /* Name.Label */
.highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */
.highlight .py { color: #336699; font-weight: bold } /* Name.Property */
.highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #336699 } /* Name.Variable */
.highlight .ow { color: #008800 } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */
.highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */
.highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */
.highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
.highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */
.highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */
.highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */
.highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */
.highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */
.highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */
.highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */
.highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */
.highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */
.highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */
.highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */
.highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */
.highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */
.highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */
.highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */
.highlight .vc { color: #336699 } /* Name.Variable.Class */
.highlight .vg { color: #dd7700 } /* Name.Variable.Global */
.highlight .vi { color: #3333bb } /* Name.Variable.Instance */
.highlight .vm { color: #336699 } /* Name.Variable.Magic */
.highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
}
{
	"name": "value"
}
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190
/*
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);
	//console.log(global_editor.getText());
	if(global_added_obj["a" + idVal] != undefined &&  global_added_obj["a" + idVal] != null){
		global_added_obj["a" + idVal]= global_added_obj["a" + idVal]+1;
		$("#addCnt" +  + idVal).text("added " + global_added_obj["a" + idVal] + " times");
	}else{
		global_added_obj["a" + idVal]= 1;
		$("#addCnt" +  + idVal).text("added " + global_added_obj["a" + idVal] + " time");
	}
	var nameVal = document.getElementById("a" + idVal).value;
	var valueBoxVal = document.getElementById("valbox" + idVal).value;
	//$("#btn" + idVal).val('Added');
	//$("#btn" + idVal).attr('disabled','disabled'); 
	//console.dir(nameVal);
	//console.dir(valueBoxVal);


	var paramElement = "<parameter name='" + nameVal + "' value='" + valueBoxVal + "'/>\n";
	global_editor.setText(global_editor.getText() + paramElement);
}

var g_currValuesObj={};

function filterValues(filterVal){
	global_added_obj={};
	var matchedCnt =0;
	var valuesObj = g_currValuesObj;
	var newValuesObj ={};
	var searchValues =[];
	if(filterVal != null && filterVal != undefined){
		filterVal=filterVal.trim();
	}	
	searchValues = filterVal.split(/ /);
	//console.log("filterVal:" + filterVal);
	if(searchValues != null && searchValues != undefined){	
        	for (var key in valuesObj) {
             		if (valuesObj.hasOwnProperty(key)) {
				var newArrObj = [];
                   		if(Array.isArray(valuesObj[key])){
                      			var arrObj=valuesObj[key];
					var cnt=1;
                      			for(var i=0;i<arrObj.length;i++){
						var foundCount = 0;
						for(var k=0;k<searchValues.length;k++){
							if(arrObj[i].indexOf(searchValues[k]) != -1){
								foundCount++;
							}
						}
						if(foundCount == searchValues.length){
							matchedCnt++;
							newArrObj.push(arrObj[i]);
						}
		      			}	
					newValuesObj[key] =  newArrObj;
		   		}		
			}
		}
		$("#matchedCntId").html(matchedCnt);
	}else{
		newValuesObj = valuesObj;
	}
	var valuesHtml=buildValuesHtml(newValuesObj);	
        valuesHtml+="</div>";
	$("#sli-values-div").html(valuesHtml);
}

function buildValuesHtml(valuesObj){
	var idCounter=0;
	var htmlVal = "";
	
        for (var key in valuesObj) {
             if (valuesObj.hasOwnProperty(key)) {
                   var v = "<div style='font-weight:bold;font-size:1.0em;'><label>" + key + "<b/label>";
                   if(Array.isArray(valuesObj[key])){
                      var arrObj=valuesObj[key];
			var cnt=1;
                      for(var i=0;i<arrObj.length;i++){
				var idVal = idCounter++;
			 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>";
			var variableBox = "";
			var valBox = "<input id='valbox" + idVal + "' type='text' style='width:500px;height:30px;' value=''>";
			if(arrObj[i] != undefined && arrObj[i].length <150){
                         	//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] + "' >" ;
                         	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] + "' >" ;
				variableBox = "<input style='width:1125px' id='variableBox" + idVal + "' type='text' value='`$" + arrObj[i] + "`'>";
			}else{
                         	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>";
				variableBox = "<textarea style='width:1125px' id='variableBox" + idVal + "' >`$" + arrObj[i] + "`'</textarea>";
			}
			  v += "<div id='valAddDiv" +  idVal + "' style='display:none;'>" +  valBox + "&nbsp;&nbsp;" + addBtn + "</div>" +
		           "<div id='variableBoxDiv" + idVal + "' style='display:none;color:rgb(32, 45, 87);'>Display as a variable<br>" + variableBox + "</div>" + "</div>";
			cnt++;
                      }
                      htmlVal+= v + "</div>";
                                }
                   }
             }
	return htmlVal;
}


function getModuleName(){
	var activeWorkspace=RED.view.getWorkspace();
	var moduleName="";
	RED.nodes.eachNode(function(n) {
		if (n.z == activeWorkspace) {
			if(n.type == 'service-logic'){
				//console.log("getModuleName():<" + n.module + ">");
				moduleName=n.module;
			}
               	}
       	});
	return moduleName;
}
var global_added_obj={};
var displayingRpcs = false;
function showRpcsValuesBox(editor,valuesObj){
	displayingRpcs = true;
	showValuesBox(editor,valuesObj);
}

function showValuesBox(editor,valuesObj){
	var moduleName = getModuleName();	
	var obj = valuesObj[moduleName];
	//console.dir(valuesObj);
	//console.dir(obj);
	var moduleObj ={};
	if(obj == undefined){
		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."];	
	}else{
		moduleObj[moduleName] = obj;
	}
	showValuesBoxForModule(editor,moduleObj,moduleName);	
}

function showValuesBoxForModule(editor,valuesObj,moduleName){
	global_editor=editor;
	g_currValuesObj = valuesObj;
	//console.log(editor.getText());
	//populate the valid SLI values
	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;'>" ;
	valuesHtml+=buildValuesHtml(valuesObj);	
       valuesHtml+="</div>";
	global_added_obj={};

	
 var title = "SLI Values for Module " + moduleName;	
	if(displayingRpcs){
		title = "RPCs for Module " + moduleName;
	}
	$('#sli-values-dialog').dialog({
                       modal: false,
                       title: title,
                       width: 1200,
		       height: 500,
		       dialogClass: 'color-dialog',
                       open: function () {
				$("#sli-values-dialog").dialog("widget").find(".ui-dialog-buttonpane").css({'background': 'aliceblue'});
                                $(this).html(valuesHtml);
                       },
                       buttons: {
                           Close: function () {
				displayingRpcs = false;
                              //$(this).dialog("close");
                              $(this).dialog("destroy");
                           }
                       },
			close: function(ev,ui){
				displayingRpcs = false;
				$(this).dialog("destroy");
			}
        }); // end dialog div
}

function showCommentsBox(){
	var comments = $("#node-input-comments").val();
	var commentsBoxHtml="<div><textarea style='font-size:18px;height:150px;width:390px;' id='taCommentId'>" + comments + "</textarea></div>" ;

	var nodeName=$("#node-input-name").val();
	$('#comments-dialog').dialog({
                       modal: true,
                       title: "Add comments for Node " + nodeName,
                       width: 450,
		       height: 300,	
			/*	
                       open: function () {
                                $(this).html(commentsBoxHtml);
                       },
			*/
                       buttons: {
                           "Save Comments": function () {
				var v=$("#taCommentId").val();
				if(v != null){
					v = v.trim();
					if(v != ''){
						$("#node-input-btnComments").html("<span style='color:blue;'><b>View Comments</b></span>");
					}else{
						$("#node-input-btnComments").html("<b>Add Comments</b>");
					}
				}
				//console.log("value from text area" + v);
				$("#node-input-comments").val(v);
				$(this).dialog("close");
                              //$(this).dialog("destroy");
                           },
                           Cancel: function () {
				var v=$("#taCommentId").val();
				if(v != null){
					v = v.trim();
					if(v != ''){
						$("#node-input-btnComments").html("<span style='color:blue;'><b>View Comments</b></span>");
					}else{
						$("#node-input-btnComments").html("<b>Add Comments</b>");
					}
				}
				$(this).dialog("close");
                              //$(this).dialog("destroy");
                           }
                       },
			close: function(ev,ui){
				//console.log("closing..");
				$(this).dialog("destroy");
			}
        }).html(commentsBoxHtml);

	//console.log("done");
/*	
	function functionDialogResize(ev,ui) {
		console.log("ui.size.height:" + ui.size.height);
                $(this).css("height",(ui.size.height-275)+"px");
        };

        $( this ).on("dialogresize", functionDialogResize);


	$( this ).one("dialogopen", function(ev) {
                var size = $( "#sliValDiv" ).dialog('option','sizeCache-function');
                if (size) {
                    functionDialogResize(null,{size:size});
                }
         });
*/

}

function selectText(objId,groupVal){
	//console.log(objId + groupVal);	
	//console.log(objId + groupVal);	
	$(document).ready(function(){
		//console.log("doc ready");
		//console.dir($('#valAddDiv' +  objId));
		if ($('#valAddDiv' +  objId).is(":visible")) {
			$("#variableBoxDiv" +  objId ).hide("slow");
			//$("#a" +  objId ).css({"background": "rgb(223, 191, 191)",
			//			"color": "rgb(32, 45, 87)"});
			$("#a" +  objId ).css({"background": "aliceblue",
						"color": "rgb(32, 45, 87)"});
						/*"color": "rgb(32, 45, 87)"});*/
			$("#valAddDiv" +  objId ).hide("slow");
			$("#valueBoxDiv" +objId).css({"border-color": "aliceblue",
             						"border-width":"1px", 
             						"background-color":"aliceblue",
             						"border-style":"solid"});
			//$("#valAddDiv" +  objId ).fadeOut("slow");
    		} else{
			$("#variableBoxDiv" +  objId ).show("slow");
			$("#valAddDiv" +  objId).show("slow");
			/*$("#valueBoxDiv" +objId).css({"border-color": "rgb(75, 111, 147)",
             						"border-width":"5px", 
             						"background-color": "rgb(223, 191, 191)",
             						"border-style":"solid",
							"border-bottom": "5px solid rgb(75, 111, 147)"});
			*/
			$("#valueBoxDiv" +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)"});
			/*$("#a" +  objId ).css({"background": "rgb(223, 191, 191)",
						"color": "rgb(75, 111, 147)"});
			*/
			$("#a" +  objId ).css({"background": "aliceblue",
						"color": "rgb(75, 111, 147)"});
    		}
		$("#a" +  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 hidePrevGroup(objId){
//	console.log("mouseout" );
//	var obj= document.getElementById("group-heading" +  objId);
//	obj.innerText = "";
}
/*
function fixDiv() {
    var $cache = $('#getFixed');
    if ($(window).scrollTop() > 100)
      $cache.css({
        'position': 'fixed',
        'top': '10px'
      });
    else
      $cache.css({
        'position': 'relative',
        'top': 'auto'
      });
 }

$(window).scroll(fixDiv);

function isScrolledIntoView(elem)
{
    var $elem = $(elem);
    var $window = $(window);

    var docViewTop = $window.scrollTop();
    var docViewBottom = docViewTop + $window.height();

    var elemTop = $elem.offset().top;
    var elemBottom = elemTop + $elem.height();

    return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop));
}
*/

function getCommits(filePath){
var urlPath="/getCommitsInfo";
$.get(urlPath,{"filePath" : filePath })
	.done(function( data ) {
		if(data != undefined && data != null){
			//console.log(data.stdout);
			var jsonObj = JSON.parse(data.stdout);
			var codeCloudFilesHtmlStr = $( "#codecloud-browser-dialog" ).html();
			var htmlStr = getCCFileHtmlStr(filePath,jsonObj,codeCloudFilesHtmlStr);
			$( "#codecloud-browser-dialog" ).html(htmlStr);
			/*
			for(var i=0;i<jsonObj.length;i++){
				console.log("commit:" + jsonObj[i].commit);	
				console.log("date:" + jsonObj[i].date);	
				console.log("author:" + jsonObj[i].author);	
				console.log("comment:" + jsonObj[i].comment);	
			}
			*/
		}
	})
	.fail(function(err) {
	})
	.always(function() {
	});
}


function getCCFileHtmlStr(filePath,rows,codeCloudFilesHtmlStr){
	var styleStr = "<style> " + 
			"table#cct01 { width:100%; } \n" +
				"table#cct01 th,table#cct01 td { border: 1px solid black; border-collapse: collapse; } \n" +
				"table#cct01 th,table#cct01 td { padding: 5px; text-align: left; } \n" +
				"table#cct01 tr:nth-child(even) { background-color: #eee; }\n" +
				"table#cct01 tr:nth-child(odd) { background-color:#fff; }\n" +
				"table#cct01 th	{ background-color: #65a9d7; color: white; }\n" +
				"table#cct01 a { color: #337ab7; }\n" +
				"table#cct01 a:link { color: #65a9d7; }\n" +
				"table#cct01 a:visited { color: #636; }\n" + 
				"table#cct01 a:hover { color: #3366CC; cursor: pointer }\n" + 
				"table#cct01 a:active { color: #65a9d7 }\n" +
				"table#cct01 caption { display: table-caption; text-align: center;  background: #eee; font-weight: bold; font-size: 1.1em; border: 1px solid black; }\n" + 
				"</style>";
			var htmlStr="";
			//console.dir(rows);	
			if(rows != null && rows.length >0){
				var alertDialog = '<div id="ccAlertdialog"></div>';
				htmlStr= alertDialog +  "<div style='width:1050;height:650'>" + styleStr;
				htmlStr += "<table id='cct01' >";
				htmlStr += "<caption id='ccCaptionId'>" + filePath + "</caption>";
				htmlStr += "<tr>";
				htmlStr += "<th>Commit ID</th>" ;
				htmlStr += "<th>Date</th>" ;
				htmlStr += "<th>Author</th>" ;
				htmlStr += "<th>Comment</th>" ;
				htmlStr += "</tr>";
				if(rows != null && rows.length == 0){
					htmlStr += "<tr>";
					htmlStr += "<td><b>No rows found</b></td>";
					htmlStr += "</tr></table></div>";
					return htmlStr;
				}
				for(var i=0;i<rows.length;i++){
					var row = rows[i];
					var _commitId = row.commit;
					var dt = row.date;
					var author = row.author;
					var comment = row.comment;
					htmlStr += "<tr>";
					htmlStr += "<td><a onclick=\"javascript:importCCFlow('" + _commitId + "','" + filePath + "')\">" + _commitId + "</a></td>";
					htmlStr += "<td>" + dt + "</td>";
					htmlStr += "<td>" + author + "</td>";
					htmlStr += "<td>" + comment + "</td>"; 
					htmlStr += "</tr>";
				}
				htmlStr += "</table>";
				htmlStr += "</div>";
			}
	//console.log(htmlStr);
	return htmlStr;
}


var gitLocalFlowFiles=[];
function filterGitLocalFlows(filterVal){
	
	var matchedCnt =0;
	var valuesObj = gitLocalFlowFiles;
	//console.dir(codeCloudFlowFiles);
	var updatedValuesObj =[];
	var searchValues =[];
	if(filterVal != null && filterVal != undefined){
		filterVal=filterVal.trim();
	}	
	searchValues = filterVal.split(/ /);
	//console.log("filterVal:" + filterVal);
	//console.dir(searchValues);
	if(searchValues != null && searchValues != undefined){	
		var foundCount = 0;
		for(var k=0;k<searchValues.length;k++){
			if(foundCount >0){
				valuesObj=updatedValuesObj;
			}
			updatedValuesObj=[];
			for(var i=0;i<valuesObj.length;i++){
				var patt = new RegExp(searchValues[k],"gi");
				if(patt.test(valuesObj[i])){
					foundCount++;
					updatedValuesObj.push(valuesObj[i]);
				}
			}
		}
	}else{
		updatedValuesObj = valuesObj;
	}
	//console.dir(updatedValuesObj);
	var html="<ul>";
	if(updatedValuesObj != null){
		var files=updatedValuesObj;
		//console.dir(files);
		files.sort(function (a,b){
			if(a > b){
				return 1;
			}else if(a <  b){
				return -1;
			}else{	
				return 0;
			}
		});
		for(var i=0;files != null && i<files.length;i++){
			html+="<li><a href=\"#\" onclick=\"importGitLocalFlow('" + files[i] + "')\">" + files[i] + "</a></li>";
		}
	}
					html+="</ul>";
					html+="</div>";
    	$( "#gitlocal-data-container" ).html(html);
}

var codeCloudFlowFiles=[];
function filterFlows(filterVal){
	
	var matchedCnt =0;
	var valuesObj = codeCloudFlowFiles;
	//console.dir(codeCloudFlowFiles);
	var updatedValuesObj =[];
	var searchValues =[];
	if(filterVal != null && filterVal != undefined){
		filterVal=filterVal.trim();
	}	
	searchValues = filterVal.split(/ /);
	//console.log("filterVal:" + filterVal);
	//console.dir(searchValues);
	if(searchValues != null && searchValues != undefined){	
		var foundCount = 0;
		for(var k=0;k<searchValues.length;k++){
			for(var i=0;i<valuesObj.length;i++){
				var patt = new RegExp(searchValues[k],"gi");
				if(patt.test(valuesObj[i])){
					foundCount++;
					updatedValuesObj.push(valuesObj[i]);
				}
			}
		}
	}else{
		updatedValuesObj = valuesObj;
	}
	//console.dir(updatedValuesObj);
	var html="<ul>";
	if(updatedValuesObj != null){
		var files=updatedValuesObj;
		//console.dir(files);
		files.sort(function (a,b){
			if(a > b){
				return 1;
			}else if(a <  b){
				return -1;
			}else{	
				return 0;
			}
		});
		for(var i=0;files != null && i<files.length;i++){
			html+="<li><a href=\"#\" onclick=\"getCommits('" + files[i] + "')\">" + files[i] + "</a></li>";
		}
	}
					html+="</ul>";
					html+="</div>";
    	$( "#codecloud-data-container" ).html(html);
}

var yangFilesList=[];
/*
function filterYangFiles(filterVal){
	
	var matchedCnt =0;
	var valuesObj = yangFilesList;
	var updatedValuesObj =[];
	var searchValues =[];
	if(filterVal != null && filterVal != undefined){
		filterVal=filterVal.trim();
	}	
	searchValues = filterVal.split(/ /);
	if(searchValues != null && searchValues != undefined){	
		var foundCount = 0;
		for(var k=0;k<searchValues.length;k++){
			for(var i=0;i<valuesObj.length;i++){
				var patt = new RegExp(searchValues[k],"gi");
				if(patt.test(valuesObj[i])){
					foundCount++;
					updatedValuesObj.push(valuesObj[i]);
				}
			}
		}
	}else{
		updatedValuesObj = valuesObj;
	}
	//console.dir(updatedValuesObj);
	var html="<ul>";
	if(updatedValuesObj != null){
		var files=updatedValuesObj;
		//console.dir(files);
		files.sort(function (a,b){
			if(a > b){
				return 1;
			}else if(a <  b){
				return -1;
			}else{	
				return 0;
			}
		});
		for(var i=0;files != null && i<files.length;i++){
			html+="<li><a href=\"#\" onclick=\"getYangFile('" + files[i] + "')\">" + files[i] + "</a></li>";
		}
	}
					html+="</ul>";
					html+="</div>";
    	$( "#list-yang-data-container" ).html(html);
}
*/

function filterYangFiles(filterVal){
	var matchedCnt =0;
	var valuesObj = yangFilesList;
	var updatedValuesObj =[];
	var searchValues =[];
	if(filterVal != null && filterVal != undefined){
		filterVal=filterVal.trim();
	}	
	searchValues = filterVal.split(/ /);
	if(searchValues != null && searchValues != undefined){	
		var foundCount = 0;
		for(var k=0;k<searchValues.length;k++){
			for(var i=0;i<valuesObj.length;i++){
				var patt = new RegExp(searchValues[k],"gi");
				if(patt.test(valuesObj[i])){
					foundCount++;
					updatedValuesObj.push(valuesObj[i]);
				}
			}
		}
	}else{
		updatedValuesObj = valuesObj;
	}
	//console.dir(updatedValuesObj);
	var html="<table id='yang-file-list-table'  border=1>";
            html+="<tr>";
            html+="<th>File</th>";
            html+="<th>Delete</th>";
            html+="</tr>";
	
	if(updatedValuesObj != null){
		var files=updatedValuesObj;
		//console.dir(files);
		files.sort(function (a,b){
			if(a > b){
				return 1;
			}else if(a <  b){
				return -1;
			}else{	
				return 0;
			}
		});
		for(var i=0;files != null && i<files.length;i++){
			 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>";
		}
	}
	html+="</table>";
        html+="</div>";

    	$( "#yang-files-data-container" ).html(html);
}

function getYangFile(fileName){
	$("#dwnldYangFormId").remove();
        //using form to submit
        var form = $('<form id="dwnldYangFormId" method="POST" action="/downloadYang"></form>');
        form.append('<input type="hidden" name="fileName" value="' + fileName + '"/>');
        form.appendTo('body');
        $("#dwnldYangFormId").submit();

}
function deleteYangFile(fileName){
	var reqData= {"fileName":fileName};
	 $.post( "/deleteYangFile",reqData )
                      .done(function( data ) {
                      })
                      .fail(function(err) {
                          console.log( "error" + err );
                       })
                       .always(function() {
                              $("#list-yang-browser-dialog").dialog("close");
				$("#btn-list-yang-files").trigger("click");
                       });
}

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);
			$( "#codecloud-browser-dialog" ).dialog("close");
			RED.view.importNodes(JSON.stringify(jsonObj));
		}
	})
	.fail(function(err) {
		RED.notify("Could not import flow from code cloud.");	
		$( "#codecloud-browser-dialog").dialog("close");
     		console.log( "error occured importing flow.");
	})
	.always(function() {
	});
}

function importGitLocalFlow(filePath){
var urlPath="/importGitLocalFlow";
$.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;
			try{
				jsonObj = JSON.parse(data.stdout);
				$( "#gitlocal-browser-dialog" ).dialog("close");
				RED.view.importNodes(JSON.stringify(jsonObj));
			}catch(err){
				RED.notify("Could not import flow from Local Git Repository.");	
				$( "#gitlocal-browser-dialog").dialog("close");
     				console.log( "error occured importing flow." + err);
			}
		}else{
			RED.notify("Could not import flow from Local Git Repository.");	
			$( "#gitlocal-browser-dialog").dialog("close");
     			console.log( "error occured importing flow." + err);
		}
	})
	.fail(function(err) {
		RED.notify("Could not import flow from Local Git Repository.");	
		$( "#gitlocal-browser-dialog").dialog("close");
     		console.log( "error occured importing flow.");
	})
	.always(function() {
	});
}

var availableYangModules=[];
function filterYangModules(filterVal){
	
	var matchedCnt =0;
	var valuesObj = availableYangModules ;
	//console.dir(codeCloudFlowFiles);
	var updatedValuesObj =[];
	var searchValues =[];
	if(filterVal != null && filterVal != undefined){
		filterVal=filterVal.trim();
	}	
	searchValues = filterVal.split(/ /);
	//console.log("filterVal:" + filterVal);
	//console.dir(searchValues);
	if(searchValues != null && searchValues != undefined){	
		var foundCount = 0;
		for(var k=0;k<searchValues.length;k++){
			if(foundCount >0){
				valuesObj=updatedValuesObj;
			}
			updatedValuesObj=[];
			for(var i=0;i<valuesObj.length;i++){
				var patt = new RegExp(searchValues[k],"gi");
				if(patt.test(valuesObj[i])){
					foundCount++;
					updatedValuesObj.push(valuesObj[i]);
				}
			}
		}
	}else{
		updatedValuesObj = valuesObj;
	}
	//console.dir(updatedValuesObj);
	var html="";
	html+="<table border=1>";
        html+="<tr>";
        html+="<th>#</th>";
        html+="<th>Load</th>";
        html+="<th>Module</th>";
        html+="</tr>";

	if(updatedValuesObj != null){
		var files=updatedValuesObj;
		//console.dir(files);
		files.sort(function (a,b){
			if(a > b){
				return 1;
			}else if(a <  b){
				return -1;
			}else{	
				return 0;
			}
		});
		var count=1;
		for(var i=0;files != null && i<files.length;i++){
			var val = files[i].replace(/:.*/,"");
			if(files[i].indexOf(":checked") != -1){
                          	html+="<tr><td>" + count +  "</td><td><input type='checkbox' checked value='" + val + "'></td><td>" + val + "</td></tr>";
                        }else{
                                html+="<tr><td>" + count +   "</td><td><input type='checkbox' value='" + val + "'></td><td>" + val + "</td></tr>";
                        }
			count++;
		}
	}
	html+="</table>";
	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>&nbsp;string" +
					"&nbsp;<input name='typeBtns-new' type='radio'  value='int'>&nbsp;int" +
					"&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" + "\")'>";
	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 + "\")'>&nbsp;&nbsp;<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>&nbsp;string" +
					"&nbsp;<input name='typeBtns" + idVal + "' type='radio'  value='int'>&nbsp;int" +
					"&nbsp;<input name='typeBtns" + idVal + "' type='radio'  value='boolean'>&nbsp;boolean"; 
				if(intChecked){
					typeBtns = "<input name='typeBtns" + idVal + "' type='radio'  value='string'>&nbsp;string" +
					"&nbsp;<input name='typeBtns" + idVal + "' type='radio'  value='int' checked>&nbsp;int" +
					"&nbsp;<input name='typeBtns" + idVal + "' type='radio'  value='boolean'>&nbsp;boolean"; 
				}else if(booleanChecked){
					typeBtns = "<input name='typeBtns" + idVal + "' type='radio'  value='string'>&nbsp;string" +
					"&nbsp;<input name='typeBtns" + idVal + "' type='radio'  value='int'>&nbsp;int" +
					"&nbsp;<input name='typeBtns" + idVal + "' type='radio'  value='boolean' checked>&nbsp;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 + "&nbsp;&nbsp;<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 + "\")'>&nbsp;&nbsp;<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();
			})
	}