Merge branch 'develop' of github.com:RiV-chain/RiV-mesh into develop

This commit is contained in:
vadym 2022-12-03 17:22:18 +02:00
commit cd6257bfa3

View file

@ -22,40 +22,33 @@
if(value === "-1"){ if(value === "-1"){
var peerAddress = document.getElementById("label_"+peer); var peerAddress = document.getElementById("label_"+peer);
peerAddress.style.color = "rgba(250,250,250,.5)"; peerAddress.style.color = "rgba(250,250,250,.5)";
moveRowToEnd(peerTable, peerCell.parentNode); } else {
return; cellText = document.createTextNode(value);
peerCell.appendChild(cellText);
var peerCellTime = document.getElementById("time_"+peer);
var cellTextTime = document.createTextNode("ms");
peerCellTime.appendChild(cellTextTime);
} }
peerCell.parentNode.classList.remove("is-hidden");
cellText = document.createTextNode(value);
peerCell.appendChild(cellText);
var peerCellTime = document.getElementById("time_"+peer);
var cellTextTime = document.createTextNode("ms");
peerCellTime.appendChild(cellTextTime);
//sort table //sort table
sortTable(peerTable, 2, false); moveRowToOrderPos(peerTable, 2, peerCell.parentNode)
} }
function sortTable(table, col, reverse) { function cmpTime(a, b) {
var tb = table.tBodies[0], // use `<tbody>` to ignore `<thead>` and `<tfoot>` rows return a.textContent.trim() === "" ? 1 : (a.textContent.trim() // using `.textContent.trim()` for test
tr = Array.prototype.slice.call(tb.rows, 0), // put rows into array .localeCompare(b.textContent.trim(), 'en', {numeric: true}))
i;
reverse = -((+reverse) || -1);
tr = tr.sort(function (a, b) { // sort rows
// `-1 *` if want opposite order
return reverse * (a.cells[col].textContent.trim() // using `.textContent.trim()` for test
.localeCompare(b.cells[col].textContent.trim(), 'en', {numeric: true})
);
});
for(i = 0; i < tr.length; ++i) tb.appendChild(tr[i]); // append each row in order
} }
function moveRowToEnd(table, row) { function moveRowToOrderPos(table, col, row) {
var tb = table.tBodies[0]; // use `<tbody>` to ignore `<thead>` and `<tfoot>` rows var tb = table.tBodies[0], tr = tb.rows;
var rowIndex = row.rowIndex; var i = 0;
table.deleteRow(rowIndex); for(; i < tr.length && cmpTime(row.cells[col], tr[i].cells[col]) >= 0; ++i);
tb.appendChild(row); // append each row in order if(i < tr.length && i != row.rowIndex) {
tb.deleteRow(row.rowIndex);
tb.insertBefore(row, tr[i]);
}
} }
function openTab(element, tabName) { function openTab(element, tabName) {
@ -141,11 +134,13 @@
button_info_close.onclick = function() { button_info_close.onclick = function() {
message.value = ""; message.value = "";
info.className = "notification is-primary is-hidden"; info.className = "notification is-primary is-hidden";
//document.getElementById("peer_list").remove();
}; };
var button_window_close = document.getElementById("window_close"); var button_window_close = document.getElementById("window_close");
button_window_close.onclick = function() { button_window_close.onclick = function() {
message.value = ""; message.value = "";
info.className = "notification is-primary is-hidden"; info.className = "notification is-primary is-hidden";
//document.getElementById("peer_list").remove();
}; };
var button_window_save = document.getElementById("window_save"); var button_window_save = document.getElementById("window_save");
button_window_save.onclick = function() { button_window_save.onclick = function() {
@ -162,6 +157,7 @@
} }
} }
savePeers(JSON.stringify(peer_list)); savePeers(JSON.stringify(peer_list));
//document.getElementById("peer_list").remove();
}; };
} }
@ -197,6 +193,7 @@
peers.push(peer); peers.push(peer);
// creates a table row // creates a table row
var row = document.createElement("tr"); var row = document.createElement("tr");
row.className = "is-hidden";
var imgElement = document.createElement("td"); var imgElement = document.createElement("td");
clone = flag.cloneNode(false); clone = flag.cloneNode(false);
imgElement.appendChild(clone); imgElement.appendChild(clone);