From: Jonas Jelonek Date: Thu, 9 Jan 2025 11:52:27 +0000 (+0100) Subject: luci-mod-status: 29_ports.js: improve speed formatting X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=20bf9a4b179cda8eb99559faa76093c958f37bd9;p=project%2Fluci.git luci-mod-status: 29_ports.js: improve speed formatting Improve speed formatting to make it more flexible and support speeds beyond 40 GbE. Signed-off-by: Jonas Jelonek --- diff --git a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/29_ports.js b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/29_ports.js index 3718d70ccf..c0f69a7b65 100644 --- a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/29_ports.js +++ b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/include/29_ports.js @@ -214,16 +214,20 @@ function formatSpeed(carrier, speed, duplex) { var d = (duplex == 'half') ? '\u202f(H)' : '', e = E('span', { 'title': _('Speed: %d Mibit/s, Duplex: %s').format(speed, duplex) }); - switch (speed) { - case 10: e.innerText = '10\u202fM' + d; break; - case 100: e.innerText = '100\u202fM' + d; break; - case 1000: e.innerText = '1\u202fGbE' + d; break; - case 2500: e.innerText = '2.5\u202fGbE'; break; - case 5000: e.innerText = '5\u202fGbE'; break; - case 10000: e.innerText = '10\u202fGbE'; break; - case 25000: e.innerText = '25\u202fGbE'; break; - case 40000: e.innerText = '40\u202fGbE'; break; - default: e.innerText = '%d\u202fMbE%s'.format(speed, d); + switch (true) { + case (speed < 1000): + e.innerText = '%d\u202fM%s'.format(speed, d); + break; + case (speed == 1000): + e.innerText = '1\u202fGbE' + d; + break; + case (speed >= 1e6 && speed < 1e9): + e.innerText = '%f\u202fTbE'.format(speed / 1e6); + break; + case (speed >= 1e9): + e.innerText = '%f\u202fPbE'.format(speed / 1e9); + break; + default: e.innerText = '%f\u202fGbE'.format(speed / 1000); } return e;