diff --git a/html/eee.js b/html/eee.js index cb40329..c5140eb 100644 --- a/html/eee.js +++ b/html/eee.js @@ -1,8 +1,9 @@ function createEEE() { var tbl = document.getElementById('eeetable'); - if (tbl.rows.length <= 2) { + if (tbl.rows.length <= 2 && numPorts) { + clearInterval(createEEEInterval); console.log("CREATING TABLE ", tbl.rows.length); - for (let i = 2; i < 8; i++) { + for (let i = 2; i < 2 + numPorts; i++) { console.log("Table row: " + i + "pState: " + pState[i-2]); const tr = tbl.insertRow(); let td = tr.insertCell(); td.appendChild(document.createTextNode(`Port ${i-1}`)); @@ -20,8 +21,8 @@ function getEEE() { const s = JSON.parse(xhttp.responseText); console.log("EEE: ", JSON.stringify(s)); var tbl = document.getElementById('eeetable'); - if (tbl.rows.length > 2) { - for (let i = 2; i < 8; i++) { + if (tbl.rows.length > 2 && numPorts) { + for (let i = 2; i < 2 + numPorts; i++) { p = s[i-2]; let n = p.portNum; console.log("Table Update row: " + i + " portNum is " + n + ", pState is " + pState[i-2]); @@ -46,4 +47,4 @@ window.addEventListener("load", function() { getEEE(); const iCount = setInterval(getEEE, 2000); }); -const stat = setInterval(createEEE, 1000); +const createEEEInterval = setInterval(createEEE, 1000); diff --git a/html/main.js b/html/main.js index 5a7473d..6e8bceb 100644 --- a/html/main.js +++ b/html/main.js @@ -5,9 +5,10 @@ var rxB = new BigInt64Array(10); const linkS = ["Disabled", "No Link", "100M", "1000M", "500M", "10G", "2.5G", "5G"]; var pState = new Int8Array(10); var pIsSFP = new Int8Array(10); +var pAdvertised = new Int8Array(10); var numPorts = 0; -const logToPhysPort = [0, 0, 0, 5, 1, 2, 3, 4, 6]; -const physToLogPort = [ 4, 5, 6, 7, 3, 8]; +var logToPhysPort = new Int8Array(10); +var physToLogPort = new Int8Array(10); function drawPorts() { var f = document.getElementById('ports'); console.log("DRAWING PORTS: ", numPorts); @@ -54,6 +55,8 @@ function update() { for (let i = 0; i < s.length; i++) { p = s[i]; let n = p.portNum; + logToPhysPort[p.logPort] = n; + physToLogPort[n-1] = p.logPort; let pid = "port" + n; let ttid = "tt_" + n; n--; @@ -84,6 +87,7 @@ function update() { var iHTML = "
| Link speed | : | " + linkS[p.link + 1] + " |
| Vendor | : | " + p.sfp_vendor + " |
| Model | : | " + p.sfp_model + " |
| Serial | : | " + p.sfp_serial + " |
| TX-Power | : | " + (Number(p.sfp_txpower) / 10.0).toFixed(0) + " mW |
| RX-Power | : | " + (Number(p.sfp_rxpower) / 10.0).toFixed(0) + " mW |