helpcenter/Web/js/help/ports_script.js
2019-07-26 18:44:43 +03:00

57 lines
2.2 KiB
JavaScript

function buildPortTable(serverName, serverID) {
if(typeof portListLocale != 'undefined') {
portList = _.merge(portList,portListLocale);
}
serverName.sort(function sortNumber(a,b){return a - b;});
var curServObj = {};
for(var x = 0; x < serverName.length; x++){
for(var key in portList){
if(key == serverName[x]) {
curServObj[key] = portList[key];
}
}
}
var notes = [];
for(var key in curServObj){
if (typeof curServObj[key]["note"] != 'undefined') {
notes.push(curServObj[key]["note"]["mark"]);
}
}
notes = _.uniq(notes);
var templateHtml = $("#ports-template-list-item").html(),
listHtml = "",
noteSign = "",
noteSigned = [];
for(var i = 0; i < notes.length; i++){
noteSign += "*";
noteSigned.push([notes[i], noteSign]);
}
for(var key in curServObj){
var inOutValue = [];
for(var i = 0; i < curServObj[key][serverID].length; i++){
if(typeof curServObj[key]["note"] != 'undefined' && curServObj[key]["note"]["to"] == i){
for(var y = 0; y < noteSigned.length; y++) {
if (noteSigned[y][0] == curServObj[key]["note"]["mark"]) {
var curNote = noteSigned[y][1];
}
}
} else {
var curNote = "";
}
if (curServObj[key][serverID][i] == 0) {
inOutValue.push("<span class=\"no\"></span>" + curNote);
} else {
inOutValue.push("<span class=\"yes\"></span>" + curNote);
}
}
listHtml += templateHtml.replace(/{{table_port}}/g, key)
.replace(/{{table_service}}/g, curServObj[key]["service"])
.replace(/{{table_description}}/g, curServObj[key]["description"])
.replace(/{{table_int}}/g, inOutValue[0])
.replace(/{{table_extin}}/g, inOutValue[1])
.replace(/{{table_extout}}/g, inOutValue[2]);
}
$(".common_ports tbody").append(listHtml);
}