fix: filter killed contract processes in backend unless NodePortal calls listContractProcess

This commit is contained in:
Frank.R.Wu 2021-06-21 17:23:41 +08:00
parent 0fddac2519
commit ecb922b3ae
2 changed files with 510 additions and 507 deletions

View File

@ -1,16 +1,17 @@
var loadContractInstances = function(event) { var loadContractInstances = function (event) {
console.log("loadContractInstances"+event); console.log("loadContractInstances" + event);
listContractProcess(); listContractProcess();
}; };
var listContractProcess = function(event) { var listContractProcess = function (event) {
console.log("listContractProcess"+event); console.log("listContractProcess" + event);
setTimeout(function() { setTimeout(function () {
var param = {}; var param = {};
param.action = "listContractProcess"; param.action = "listContractProcess";
// param.data = event; // param.data = event;
param.fromNodePortal = true;
global.wssocket.send(JSON.stringify(param)); global.wssocket.send(JSON.stringify(param));
var request2 = {}; var request2 = {};
@ -19,8 +20,8 @@ var listContractProcess = function(event) {
}, 300); }, 300);
}; };
var onListContractProcess1 = function(obj) { var onListContractProcess1 = function (obj) {
console.log("+++++++++="+obj.data); console.log("+++++++++=" + obj.data);
var table = JSON.parse(obj.data); var table = JSON.parse(obj.data);
global.contractList = table; global.contractList = table;
drawContractInstanceStatusPie(table); drawContractInstanceStatusPie(table);
@ -35,7 +36,7 @@ var onListContractProcess1 = function(obj) {
global.permissionNameMap = {}; global.permissionNameMap = {};
for (var i = 0; i < table.length; i++) { for (var i = 0; i < table.length; i++) {
if (table[i].contractStatus=="KILLED") { if (table[i].contractStatus == "KILLED") {
continue; continue;
} }
var option = document.createElement("option"); var option = document.createElement("option");
@ -48,36 +49,36 @@ var onListContractProcess1 = function(obj) {
} }
}; };
var drawciTable = function(table) { var drawciTable = function (table) {
if ($("#ciTabDiv").css("height") == "0px") { if ($("#ciTabDiv").css("height") == "0px") {
console.log("drawciTabDiv: ignore"); console.log("drawciTabDiv: ignore");
return; return;
} }
var dtLang = { var dtLang = {
"sProcessing" : "处理中...", "sProcessing": "处理中...",
"lengthMenu" : '显示 <select>' + '<option value="10">10</option>' "lengthMenu": '显示 <select>' + '<option value="10">10</option>'
+ '<option value="50">50</option>' + '<option value="50">50</option>'
+ '<option value="100">100</option>' + '<option value="100">100</option>'
+ '<option value="-1">全部</option>' + '</select> 项结果', + '<option value="-1">全部</option>' + '</select> 项结果',
"sZeroRecords" : "没有匹配结果", "sZeroRecords": "没有匹配结果",
"sInfo" : "显示第 _START_ 至 _END_ 项结果,共 _TOTAL_ 项", "sInfo": "显示第 _START_ 至 _END_ 项结果,共 _TOTAL_ 项",
"sInfoEmpty" : "显示第 0 至 0 项结果,共 0 项", "sInfoEmpty": "显示第 0 至 0 项结果,共 0 项",
"sInfoFiltered" : "(由 _MAX_ 项结果过滤)", "sInfoFiltered": "(由 _MAX_ 项结果过滤)",
"sInfoPostFix" : "", "sInfoPostFix": "",
"sSearch" : "搜索:", "sSearch": "搜索:",
"sUrl" : "", "sUrl": "",
"sEmptyTable" : "表中数据为空", "sEmptyTable": "表中数据为空",
"sLoadingRecords" : "载入中...", "sLoadingRecords": "载入中...",
"sInfoThousands" : ",", "sInfoThousands": ",",
"oPaginate" : { "oPaginate": {
"sFirst" : "首页", "sFirst": "首页",
"sPrevious" : "上页", "sPrevious": "上页",
"sNext" : "下页", "sNext": "下页",
"sLast" : "末页" "sLast": "末页"
}, },
"oAria" : { "oAria": {
"sSortAscending" : ": 以升序排列此列", "sSortAscending": ": 以升序排列此列",
"sSortDescending" : ": 以降序排列此列" "sSortDescending": ": 以降序排列此列"
} }
}; };
var tableHead = "<table id='ciTabDivTab' class='table display row-border' style='word-break:normal; word-break:keep-all'><thead><tr><th>序号</th><th>ID</th><th>名称</th><th>状态</th><th>端口</th><th>类型</th><th>通讯</th><th>共识</th><th>统计</th><th>次数</th><th>流量</th><th>内存</th><th>管理</th></tr></thead><tbody>"; var tableHead = "<table id='ciTabDivTab' class='table display row-border' style='word-break:normal; word-break:keep-all'><thead><tr><th>序号</th><th>ID</th><th>名称</th><th>状态</th><th>端口</th><th>类型</th><th>通讯</th><th>共识</th><th>统计</th><th>次数</th><th>流量</th><th>内存</th><th>管理</th></tr></thead><tbody>";
@ -100,10 +101,10 @@ var drawciTable = function(table) {
html += "</td><td>"; html += "</td><td>";
html += table[i].type; html += table[i].type;
html += "</td> <td>"; html += "</td> <td>";
html += table[i].networkType == 0?"TCP":"P2P"; html += table[i].networkType == 0 ? "TCP" : "P2P";
html += "</td><td>"; html += "</td><td>";
var consensusType; var consensusType;
switch(table[i].consensusType) { switch (table[i].consensusType) {
case 0: case 0:
consensusType = "无"; consensusType = "无";
break; break;
@ -120,7 +121,7 @@ var drawciTable = function(table) {
html += consensusType; html += consensusType;
html += "</td><td>"; html += "</td><td>";
var responseType; var responseType;
switch(table[i].responseType) { switch (table[i].responseType) {
case 0: case 0:
responseType = "ALL"; responseType = "ALL";
break; break;
@ -140,7 +141,7 @@ var drawciTable = function(table) {
html += "</td> <td>"; html += "</td> <td>";
html += table[i].storage; html += table[i].storage;
html += "</td> <td style='padding:2px 12px 2px 12px'>"; html += "</td> <td style='padding:2px 12px 2px 12px'>";
html +="<button onclick='stopContractByID(\""+table[i].id+"\")' class='btn btn-secondary'>"+"停止</button>" html += "<button onclick='stopContractByID(\"" + table[i].id + "\")' class='btn btn-secondary'>" + "停止</button>"
//table[i].resultCheck; //table[i].resultCheck;
// html += "</td> <td>"; // html += "</td> <td>";
// html += "<button class='btn btn-outline-secondary' type='button' // html += "<button class='btn btn-outline-secondary' type='button'
@ -149,30 +150,30 @@ var drawciTable = function(table) {
html += "</td> </tr>"; html += "</td> </tr>";
} }
html += tableTail; html += tableTail;
html = "<h5 class='card-title'>合约实例列表</h5>"+html; html = "<h5 class='card-title'>合约实例列表</h5>" + html;
$("#ciTabDiv").html(html); $("#ciTabDiv").html(html);
$("#ciTabDivTab").DataTable( $("#ciTabDivTab").DataTable(
{ {
"language" : dtLang, "language": dtLang,
"rowCallback" : function(row, data, displayNum, displayIndex, "rowCallback": function (row, data, displayNum, displayIndex,
dataIndex) { dataIndex) {
}, },
"headerCallback" : function(thead, data, start, end, display) { "headerCallback": function (thead, data, start, end, display) {
$(thead).css("background", primaryColor); $(thead).css("background", primaryColor);
$(thead).css("color", "white"); $(thead).css("color", "white");
$(thead).children().css("background", primaryColor); $(thead).children().css("background", primaryColor);
$(thead).children().css("color", "white"); $(thead).children().css("color", "white");
}, },
scrollCollapse : false, scrollCollapse: false,
paging : true, paging: true,
pageLength : 10, pageLength: 10,
order : [ [ 0, 'desc' ] ], order: [[0, 'desc']],
"columnDefs" : [ "columnDefs": [
{ {
"targets" : 1, "targets": 1,
"render" : function(data, type, row, meta) { "render": function (data, type, row, meta) {
if (data.length > 8) if (data.length > 8)
return "<span title='" + data + "'>" return "<span title='" + data + "'>"
+ data.substring(0, 8) + data.substring(0, 8)
@ -184,9 +185,9 @@ var drawciTable = function(table) {
},] },]
}); });
}; };
var stopContractByID = function(contractID){ var stopContractByID = function (contractID) {
$("#dialogBodyDiv").html("是否停止合约ContractID:"+contractID); $("#dialogBodyDiv").html("是否停止合约ContractID:" + contractID);
showDialog("请确认",function(){ showDialog("请确认", function () {
var request = {}; var request = {};
request.action = "killContractProcess"; request.action = "killContractProcess";
request.requestID = new Date().getTime() + ""; request.requestID = new Date().getTime() + "";
@ -194,7 +195,7 @@ var stopContractByID = function(contractID){
global.wssocket.send(JSON.stringify(request)); global.wssocket.send(JSON.stringify(request));
}); });
}; };
var drawContractInstanceStatusPie = function(table) { var drawContractInstanceStatusPie = function (table) {
if ($("#ciStatusPieDiv").css("height") == "0px") { if ($("#ciStatusPieDiv").css("height") == "0px") {
console.log("drawContractInstanceStatusPie: ignore"); console.log("drawContractInstanceStatusPie: ignore");
return; return;
@ -213,7 +214,7 @@ var drawContractInstanceStatusPie = function(table) {
global.result = result; global.result = result;
var dataList = []; var dataList = [];
var valDataList = []; var valDataList = [];
for ( var key in result) { for (var key in result) {
dataList.push(key); dataList.push(key);
var l = {}; var l = {};
l.name = key l.name = key
@ -223,45 +224,45 @@ var drawContractInstanceStatusPie = function(table) {
var myChart = echarts.init($("#ciStatusPieDivCanv")[0], 'walden'); var myChart = echarts.init($("#ciStatusPieDivCanv")[0], 'walden');
var option222 = { var option222 = {
tooltip : { tooltip: {
trigger : 'item', trigger: 'item',
formatter : '{a} <br/>{b}: {c} ({d}%)' formatter: '{a} <br/>{b}: {c} ({d}%)'
}, },
legend : { legend: {
orient : 'vertical', orient: 'vertical',
left : 10, left: 10,
data : dataList data: dataList
}, },
series : [ { series: [{
name : '合约实例状态', name: '合约实例状态',
type : 'pie', type: 'pie',
radius : [ '50%', '70%' ], radius: ['50%', '70%'],
avoidLabelOverlap : false, avoidLabelOverlap: false,
label : { label: {
normal : { normal: {
show : false, show: false,
position : 'center' position: 'center'
}, },
emphasis : { emphasis: {
show : true, show: true,
textStyle : { textStyle: {
fontSize : '15', fontSize: '15',
fontWeight : 'bold' fontWeight: 'bold'
} }
} }
}, },
labelLine : { labelLine: {
normal : { normal: {
show : false show: false
} }
}, },
data : valDataList data: valDataList
} ] }]
}; };
myChart.setOption(option222); myChart.setOption(option222);
}; };
var drawContractInstanceTimesPie = function(table) { var drawContractInstanceTimesPie = function (table) {
if ($("#ciTimesPieDiv").css("height") == "0px") { if ($("#ciTimesPieDiv").css("height") == "0px") {
console.log("drawContractInstanceTimesPie: ignore"); console.log("drawContractInstanceTimesPie: ignore");
return; return;
@ -277,7 +278,7 @@ var drawContractInstanceTimesPie = function(table) {
global.result = result; global.result = result;
var dataList = []; var dataList = [];
var valDataList = []; var valDataList = [];
for ( var key in result) { for (var key in result) {
dataList.push(key); dataList.push(key);
var l = {}; var l = {};
l.name = key l.name = key
@ -288,49 +289,49 @@ var drawContractInstanceTimesPie = function(table) {
var myChart = echarts.init($("#ciTimesPieDivCanv")[0], 'walden'); var myChart = echarts.init($("#ciTimesPieDivCanv")[0], 'walden');
var option222 = { var option222 = {
tooltip : { tooltip: {
trigger : 'item', trigger: 'item',
formatter : '{a} <br/>{b}: {c} ({d}%)' formatter: '{a} <br/>{b}: {c} ({d}%)'
}, },
legend : { legend: {
orient : 'vertical', orient: 'vertical',
left : 10, left: 10,
data : dataList data: dataList
}, },
series : [ { series: [{
name : '实例调用次数', name: '实例调用次数',
type : 'pie', type: 'pie',
radius : [ '50%', '70%' ], radius: ['50%', '70%'],
avoidLabelOverlap : false, avoidLabelOverlap: false,
label : { label: {
normal : { normal: {
show : false, show: false,
position : 'center' position: 'center'
}, },
emphasis : { emphasis: {
show : true, show: true,
textStyle : { textStyle: {
fontSize : '15', fontSize: '15',
fontWeight : 'bold' fontWeight: 'bold'
} }
} }
}, },
labelLine : { labelLine: {
normal : { normal: {
show : false show: false
} }
}, },
data : valDataList data: valDataList
} ] }]
}; };
myChart.setOption(option222); myChart.setOption(option222);
}; };
var changeContractInstance = function(obj) { var changeContractInstance = function (obj) {
console.log(obj); console.log(obj);
global.contractInstance = obj; global.contractInstance = obj;
console.log(typeof(obj)); console.log(typeof (obj));
showPermissionList(global.contractInstance); showPermissionList(global.contractInstance);
var contract; var contract;
@ -360,12 +361,12 @@ var changeContractInstance = function(obj) {
} }
}; };
var changeMemeryFiles = function(obj) { var changeMemeryFiles = function (obj) {
console.log(obj); console.log(obj);
global.memoryFile = obj; global.memoryFile = obj;
}; };
var executeContractWithDynamicResult = function() { var executeContractWithDynamicResult = function () {
console.log("executeContractWithDynamicResult"); console.log("executeContractWithDynamicResult");
var request = {}; var request = {};
request.action = "executeContract"; request.action = "executeContract";
@ -385,12 +386,12 @@ var executeContractWithDynamicResult = function() {
request.withDyanmicAnalysis = true; request.withDyanmicAnalysis = true;
request.signature = sm2.doSignature(request.contractID + "|" + operation request.signature = sm2.doSignature(request.contractID + "|" + operation
+ "|" + $("#arg")[0].value + "|" + global.sm2Key.publicKey, + "|" + $("#arg")[0].value + "|" + global.sm2Key.publicKey,
global.sm2Key.privateKey,{hash:true,der:true}); global.sm2Key.privateKey, {hash: true, der: true});
localStorage.setItem("persisArg", JSON.stringify(request)); localStorage.setItem("persisArg", JSON.stringify(request));
global.wssocket.send(JSON.stringify(request)); global.wssocket.send(JSON.stringify(request));
}; };
var executeContract = function() { var executeContract = function () {
var request = {}; var request = {};
request.action = "executeContract"; request.action = "executeContract";
request.requestID = new Date().getTime() + ""; request.requestID = new Date().getTime() + "";
@ -401,18 +402,18 @@ var executeContract = function() {
return; return;
} }
request.operation = operation; request.operation = operation;
request.arg = $("#arg")[0].value ; request.arg = $("#arg")[0].value;
request.pubkey = global.sm2Key.publicKey; request.pubkey = global.sm2Key.publicKey;
request.isDebug = executeContractAsDebug.checked; request.isDebug = executeContractAsDebug.checked;
console.log(request.arg); console.log(request.arg);
request.signature = sm2.doSignature(request.contractID + "|" + operation request.signature = sm2.doSignature(request.contractID + "|" + operation
+ "|" + $("#arg")[0].value + "|" + global.sm2Key.publicKey, + "|" + $("#arg")[0].value + "|" + global.sm2Key.publicKey,
global.sm2Key.privateKey,{hash:true,der:true}); global.sm2Key.privateKey, {hash: true, der: true});
localStorage.setItem("persisArg", JSON.stringify(request)); localStorage.setItem("persisArg", JSON.stringify(request));
global.wssocket.send(JSON.stringify(request)); global.wssocket.send(JSON.stringify(request));
}; };
var onExecuteResult = function(obj) { var onExecuteResult = function (obj) {
console.log("onExecuteResult obj.data", obj.data); console.log("onExecuteResult obj.data", obj.data);
try { try {
var result = obj; var result = obj;
@ -422,14 +423,14 @@ var onExecuteResult = function(obj) {
$("#responseArea")[0].value = "执行结果:" + result.result + "\n动态分析结果:" $("#responseArea")[0].value = "执行结果:" + result.result + "\n动态分析结果:"
+ result.analysis; + result.analysis;
} else { } else {
if (result.result instanceof Object){ if (result.result instanceof Object) {
$("#responseArea")[0].value = JSON.stringify(result.result); $("#responseArea")[0].value = JSON.stringify(result.result);
styleTail = "<br>JSON格式"; styleTail = "<br>JSON格式";
} else } else
$("#responseArea")[0].value = result.result; $("#responseArea")[0].value = result.result;
} }
$("#responseID").html("请求ID:" + obj.responseID); $("#responseID").html("请求ID:" + obj.responseID);
$("#responseTime").html("响应时间:" + obj.executeTime + ("ms")+styleTail); $("#responseTime").html("响应时间:" + obj.executeTime + ("ms") + styleTail);
} catch (e) { } catch (e) {
$("#responseStatus").html("执行状态:Fail"); $("#responseStatus").html("执行状态:Fail");
$("#responseArea")[0].value = obj.data; $("#responseArea")[0].value = obj.data;
@ -439,10 +440,12 @@ var onExecuteResult = function(obj) {
}; };
var onHashResult = function(obj) { $("#hashResult").html("数链指纹:" + obj.data); }; var onHashResult = function (obj) {
$("#hashResult").html("数链指纹:" + obj.data);
};
var drawCPTable = function(table) { var drawCPTable = function (table) {
console.log("drawCPTable"); console.log("drawCPTable");
global.contractprocess = table.data; global.contractprocess = table.data;
if ($("#ciTabDiv").css("height") == "0px") { if ($("#ciTabDiv").css("height") == "0px") {
@ -450,30 +453,30 @@ var drawCPTable = function(table) {
return; return;
} }
var dtLang = { var dtLang = {
"sProcessing" : "处理中...", "sProcessing": "处理中...",
"lengthMenu" : '显示 <select>' + '<option value="10">10</option>' "lengthMenu": '显示 <select>' + '<option value="10">10</option>'
+ '<option value="50">50</option>' + '<option value="50">50</option>'
+ '<option value="100">100</option>' + '<option value="100">100</option>'
+ '<option value="-1">全部</option>' + '</select> 项结果', + '<option value="-1">全部</option>' + '</select> 项结果',
"sZeroRecords" : "没有匹配结果", "sZeroRecords": "没有匹配结果",
"sInfo" : "显示第 _START_ 至 _END_ 项结果,共 _TOTAL_ 项", "sInfo": "显示第 _START_ 至 _END_ 项结果,共 _TOTAL_ 项",
"sInfoEmpty" : "显示第 0 至 0 项结果,共 0 项", "sInfoEmpty": "显示第 0 至 0 项结果,共 0 项",
"sInfoFiltered" : "(由 _MAX_ 项结果过滤)", "sInfoFiltered": "(由 _MAX_ 项结果过滤)",
"sInfoPostFix" : "", "sInfoPostFix": "",
"sSearch" : "搜索:", "sSearch": "搜索:",
"sUrl" : "", "sUrl": "",
"sEmptyTable" : "表中数据为空", "sEmptyTable": "表中数据为空",
"sLoadingRecords" : "载入中...", "sLoadingRecords": "载入中...",
"sInfoThousands" : ",", "sInfoThousands": ",",
"oPaginate" : { "oPaginate": {
"sFirst" : "首页", "sFirst": "首页",
"sPrevious" : "上页", "sPrevious": "上页",
"sNext" : "下页", "sNext": "下页",
"sLast" : "末页" "sLast": "末页"
}, },
"oAria" : { "oAria": {
"sSortAscending" : ": 以升序排列此列", "sSortAscending": ": 以升序排列此列",
"sSortDescending" : ": 以降序排列此列" "sSortDescending": ": 以降序排列此列"
} }
}; };
var tableHead = "<table id='cpTabDivTab' class='table display row-border'><thead><tr><th>序号</th><th>PID</th><th>是否泄漏</th><th>启动时间</th><th>CPUUser</th><th>CPUSyss</th><th>resident</th><th>memory</th><th>管理</th></tr></thead><tbody>"; var tableHead = "<table id='cpTabDivTab' class='table display row-border'><thead><tr><th>序号</th><th>PID</th><th>是否泄漏</th><th>启动时间</th><th>CPUUser</th><th>CPUSyss</th><th>resident</th><th>memory</th><th>管理</th></tr></thead><tbody>";
@ -495,11 +498,11 @@ var drawCPTable = function(table) {
html += "</td> <td>"; html += "</td> <td>";
html += table[i].cpuSys; html += table[i].cpuSys;
html += "</td> <td>"; html += "</td> <td>";
html += ((table[i].resident)/(1024*1024)).toFixed(2)+"MB"; html += ((table[i].resident) / (1024 * 1024)).toFixed(2) + "MB";
html += "</td><td>"; html += "</td><td>";
html += ((table[i].memsize)/(1024*1024)).toFixed(2)+"MB"; html += ((table[i].memsize) / (1024 * 1024)).toFixed(2) + "MB";
html += "</td> <td style='padding:2px 12px 2px 12px'>"; html += "</td> <td style='padding:2px 12px 2px 12px'>";
html +="<button onclick='stopContractByPID(\""+table[i].pid+"\")' class='btn btn-secondary'>"+"停止</button>" html += "<button onclick='stopContractByPID(\"" + table[i].pid + "\")' class='btn btn-secondary'>" + "停止</button>"
//table[i].resultCheck; //table[i].resultCheck;
// html += "</td> <td>"; // html += "</td> <td>";
// html += "<button class='btn btn-outline-secondary' type='button' // html += "<button class='btn btn-outline-secondary' type='button'
@ -508,30 +511,30 @@ var drawCPTable = function(table) {
html += "</td> </tr>"; html += "</td> </tr>";
} }
html += tableTail; html += tableTail;
html = "<h5 class='card-title'>合约进程列表</h5>"+html; html = "<h5 class='card-title'>合约进程列表</h5>" + html;
$("#cpTabDiv").html(html); $("#cpTabDiv").html(html);
$("#cpTabDivTab").DataTable( $("#cpTabDivTab").DataTable(
{ {
"language" : dtLang, "language": dtLang,
"rowCallback" : function(row, data, displayNum, displayIndex, "rowCallback": function (row, data, displayNum, displayIndex,
dataIndex) { dataIndex) {
}, },
"headerCallback" : function(thead, data, start, end, display) { "headerCallback": function (thead, data, start, end, display) {
$(thead).css("background", primaryColor); $(thead).css("background", primaryColor);
$(thead).css("color", "white"); $(thead).css("color", "white");
$(thead).children().css("background", primaryColor); $(thead).children().css("background", primaryColor);
$(thead).children().css("color", "white"); $(thead).children().css("color", "white");
}, },
scrollCollapse : false, scrollCollapse: false,
paging : true, paging: true,
pageLength : 10, pageLength: 10,
order : [ [ 0, 'desc' ] ], order: [[0, 'desc']],
"columnDefs" : [ "columnDefs": [
{ {
"targets" : 1, "targets": 1,
"render" : function(data, type, row, meta) { "render": function (data, type, row, meta) {
if (data.length > 10) if (data.length > 10)
// return "<span title='" + data + "'>" // return "<span title='" + data + "'>"
// + data.substring(0, 10) // + data.substring(0, 10)
@ -544,9 +547,9 @@ var drawCPTable = function(table) {
},] },]
}); });
}; };
var stopContractByPID = function(pid){ var stopContractByPID = function (pid) {
$("#dialogBodyDiv").html("是否停止PID:"+pid); $("#dialogBodyDiv").html("是否停止PID:" + pid);
showDialog("请确认",function(){ showDialog("请确认", function () {
var request = {}; var request = {};
request.action = "killProcessByPID"; request.action = "killProcessByPID";
request.pid = pid; request.pid = pid;

View File

@ -300,7 +300,7 @@ function onGetNodeSessionID(data) {
global.session = data.session; global.session = data.session;
global.wssocket.send(JSON.stringify({ global.wssocket.send(JSON.stringify({
pubKey: global.sm2Key.publicKey, pubKey: global.sm2Key.publicKey,
signature: sm2.doSignature(global.session, global.sm2Key.privateKey,{hash:true,der:true}), signature: sm2.doSignature(global.session, global.sm2Key.privateKey, {hash: true, der: true}),
action: "login" action: "login"
})); }));
} }
@ -498,25 +498,25 @@ function addNodeUnit(obj) {
if (!global.units) { if (!global.units) {
global.units = {}; global.units = {};
} }
var x=document.getElementById("selectUnits"); var x = document.getElementById("selectUnits");
for (i = 0; i < x.length; ++i){ for (i = 0; i < x.length; ++i) {
if (x.options[i].value == obj.key){ if (x.options[i].value == obj.key) {
return; return;
} }
} }
var option=document.createElement("option"); var option = document.createElement("option");
var type = obj.type; var type = obj.type;
if (type == "TCP") { if (type == "TCP") {
var at_ = obj.key.indexOf("_"); var at_ = obj.key.indexOf("_");
var key = obj.key.substr(at_+1); var key = obj.key.substr(at_ + 1);
global.units[key] = obj.value; global.units[key] = obj.value;
option.text = obj.type + ":" + key; option.text = obj.type + ":" + key;
} else { } else {
global.units[obj.key] = obj.value; global.units[obj.key] = obj.value;
option.text = obj.type + ":" + obj.key + ":" +obj.value.length + "nodes"; option.text = obj.type + ":" + obj.key + ":" + obj.value.length + "nodes";
} }
option.value = obj.key; option.value = obj.key;
x.add(option,null); x.add(option, null);
} }