From caa7874bb36f3cc75423bce7b26cfde60eb8bc3d Mon Sep 17 00:00:00 2001 From: eraiza0816 <10572974+eraiza0816@users.noreply.github.com> Date: Tue, 11 Aug 2026 05:40:01 +0900 Subject: [PATCH] feat(webui): consolidate the page scripts into a single main.js bundle All 17 page scripts (i18n, shared helpers, navigation and the per-page scripts) are merged into one html/main.js that every page loads as its only script, so the browser fetches it once and gzip can compress across all of it. The page-specific initialisation is guarded by the presence of the matching page elements (it used to be selected implicitly by which script a page loaded); the sidebar fill and the stat popup wiring moved into DOMContentLoaded handlers because the bundle loads in , before the body exists. tools/httpd_sim.h: BUFFER_SIZE 24000 -> 131072 so the simulator can serve the larger bundle (the firmware is unaffected, it serves the gzip'd bundle of ~17 KB). Measured (make MACHINE=KP_9000_6XHML_X2): the JS drops from 23,302 to 16,948 bytes gzip; the whole Web UI from 34,784 to 28,200 bytes (25.3 % of the raw 111,280); the data block ends at 0x46e28. Verified with a headless browser against httpd_sim and against a real PCB-K0402WS-V3: all pages render, the sidebar and the port strip are drawn, no JavaScript errors. --- html/bandwidth.html | 3 - html/bandwidth.js | 138 --- html/config.js | 111 --- html/eee.html | 4 - html/eee.js | 52 -- html/eee_sub.js | 18 - html/i18n.js | 603 ------------ html/index.html | 3 - html/l2.html | 3 - html/l2.js | 194 ---- html/lag.html | 3 - html/lag.js | 81 -- html/login.html | 2 +- html/main.js | 2166 +++++++++++++++++++++++++++++++++++++++++++ html/main_info.js | 22 - html/mirror.html | 4 - html/mirror.js | 64 -- html/mirror_sub.js | 43 - html/navigation.js | 20 - html/ports.html | 3 - html/ports.js | 149 --- html/stat.html | 3 - html/stat.js | 207 ----- html/system.html | 5 +- html/system.js | 208 ----- html/update.html | 3 +- html/vlan.html | 4 - html/vlan.js | 211 ----- html/vlan_sub.js | 36 - tools/httpd_sim.h | 2 +- 30 files changed, 2170 insertions(+), 2195 deletions(-) delete mode 100644 html/bandwidth.js delete mode 100644 html/config.js delete mode 100644 html/eee.js delete mode 100644 html/eee_sub.js delete mode 100644 html/i18n.js delete mode 100644 html/l2.js delete mode 100644 html/lag.js delete mode 100644 html/main_info.js delete mode 100644 html/mirror.js delete mode 100644 html/mirror_sub.js delete mode 100644 html/navigation.js delete mode 100644 html/ports.js delete mode 100644 html/stat.js delete mode 100644 html/system.js delete mode 100644 html/vlan.js delete mode 100644 html/vlan_sub.js diff --git a/html/bandwidth.html b/html/bandwidth.html index 9b6b96f8..57ce9459 100644 --- a/html/bandwidth.html +++ b/html/bandwidth.html @@ -1,7 +1,6 @@ - Ingress and Egress Bandwidth @@ -14,8 +13,6 @@ Ingress Egress Port Limit Bandwidth [kBit/s] Flow Control Limit Bandwidth [kBit/s] Apply - - diff --git a/html/bandwidth.js b/html/bandwidth.js deleted file mode 100644 index 1c020ef1..00000000 --- a/html/bandwidth.js +++ /dev/null @@ -1,138 +0,0 @@ -const iLayout = '" type="number" maxlength="10" size="10" onfocus="inputFocus('; -function createBW() { - var tbl = document.getElementById('bwtable'); - const limit = '' - if (tbl.rows.length <= 2 && numPorts) { - console.log("CREATING TABLE ", tbl.rows.length); - for (let i = 2; i < 2 + numPorts; i++) { - const tr = tbl.insertRow(); - let td = tr.insertCell(); td.appendChild(document.createTextNode(t('common_port') + (i-1))); - td = tr.insertCell(); - td.innerHTML = limit.replaceAll("limit_port", "ilimit_port_" + i).replace("exec()", "iClicked(" + i + ")"); - td = tr.insertCell(); - td.innerHTML = t('bw_unlimited'); - td = tr.insertCell(); - td.innerHTML = limit.replaceAll("limit_port", "fc_port_" + i).replace("exec()", "document.getElementById('bwapply_" + i + "').disabled=false;"); - td = tr.insertCell(); - td.innerHTML = limit.replaceAll("limit_port", "elimit_port_" + i).replace("exec()", "eClicked(" + i + ")"); - td = tr.insertCell(); - td.innerHTML = t('bw_unlimited'); - var button = ''; - td = tr.insertCell(); - td.innerHTML = button; - document.getElementById("bwapply_" + i).disabled = true; - } - } -} - -function iClicked(i) -{ - document.getElementById("bwapply_" + i).disabled=false; - var tbl = document.getElementById('bwtable'); - var tr = tbl.rows[i]; - if (!document.getElementById("ilimit_port_" + i).checked) { - tr.cells[2].innerHTML = t('bw_unlimited'); - document.getElementById("fc_port_" + i).disabled = true; - document.getElementById("fc_port_" + i).checked = true; - } else { - tr.cells[2].innerHTML = ''; - document.getElementById("fc_port_" + i).disabled = false; - document.getElementById("fc_port_" + i).checked = true; - } -} - -function eClicked(i) -{ - document.getElementById("bwapply_" + i).disabled=false; - var tbl = document.getElementById('bwtable'); - var tr = tbl.rows[i]; - if (!document.getElementById("elimit_port_" + i).checked) { - tr.cells[5].innerHTML = t('bw_unlimited'); - } else { - tr.cells[5].innerHTML = ''; - } -} - -function inputFocus(i) -{ - document.getElementById("bwapply_" + i).disabled=false; -} - -async function doCMD(cmd) -{ - console.log("Sending >" + cmd + "<"); - try { - const response = await fetch('/cmd', { - method: 'POST', - body: cmd - }); - console.log('Completed!', response); - } catch(err) { - console.error(`Error: ${err}`); - } -} - -async function applyBandwidth(i) { - var tbl = document.getElementById('bwtable'); - var tr = tbl.rows[i]; - var cmd = "bw in " + (i-1) + " off"; - if (document.getElementById("ilimit_port_" + i).checked) - cmd = 'bw in ' + (i-1) + ' ' + parseInt(document.getElementById("ibw_" + i).value).toString(16).padStart(4, "0");; - doCMD(cmd); - if (document.getElementById("ilimit_port_" + i).checked) { - if (!document.getElementById("fc_port_" + i).checked) - cmd = "bw in " + (i-1) + " drop"; - doCMD(cmd); - } - var cmd = "bw out " + (i-1) + " off"; - if (document.getElementById("elimit_port_" + i).checked) - cmd = 'bw out ' + (i-1) + ' ' + parseInt(document.getElementById("ebw_" + i).value).toString(16).padStart(4, "0");; - doCMD(cmd); -} - -function getBW() { - var xhttp = new XMLHttpRequest(); - xhttp.onreadystatechange = function() { - console.log("IN getBW "); - if (this.readyState == 4 && this.status == 200) { - const s = JSON.parse(xhttp.responseText); - console.log("BW: ", JSON.stringify(s)); - var tbl = document.getElementById('bwtable'); - if (tbl.rows.length > 2 && numPorts) { - for (let i = 2; i < 2 + numPorts; i++) { - p = s[i-2]; - let n = p.portNum; - let tr = tbl.rows[n+1]; - if (!document.getElementById("bwapply_" + (n+1)).disabled) - continue; - console.log("Table Update row: " + i + " portNum is " + n + ", pState is " + pState[i-2] + ", row number is " + (n+1)); - let iBW = parseInt(p.iBW,16) * 16; let eBW = parseInt(p.eBW,16) * 16; - document.getElementById("ilimit_port_" + (n+1)).checked = p.iLimited; - document.getElementById("elimit_port_" + (n+1)).checked = p.eLimited; - if (!p.iLimited) { - tr.cells[2].innerHTML = t('bw_unlimited'); - } else { - tr.cells[2].innerHTML = ''; - } - if (!p.eLimited) { - tr.cells[5].innerHTML = t('bw_unlimited'); - } else { - tr.cells[5].innerHTML = ''; - } - document.getElementById("fc_port_" + (n+1)).checked = p.iFC==1?true:false; - document.getElementById("fc_port_" + (n+1)).disabled = p.iLimited==1?false:true; - } - } - } - }; - xhttp.open("GET", "/bandwidth.json", true); - xhttp.timeout = 1500; sendXHTTP(xhttp); -} - -window.addEventListener("load", function() { - update( () => { - createBW(); - getBW(); - const interval = setInterval(update, 2000); - }); -}); diff --git a/html/config.js b/html/config.js deleted file mode 100644 index 8af3fbaa..00000000 --- a/html/config.js +++ /dev/null @@ -1,111 +0,0 @@ -var configInterval = Number(); -var configuration = []; -const conf_cmds = [ - /^ip\s+(\d{1,3}\.){3}\d{1,3}$/, - /^ip\s+dhcp$/, - /^gw\s+(\d{1,3}\.){3}\d{1,3}$/, - /^netmask\s+(\d{1,3}\.){3}\d{1,3}$/, - /^syslog\s+(on|off)$/, - /^syslog\s+ip\s+(\d{1,3}\.){3}\d{1,3}$/, - /^passwd\s+\S+$/, - /^vlan\s+\d{1,4}\s+d$/, - /^vlan\s+\d{1,4}\s+mgmt$/, - /^vlan\s+\d{1,4}(\s+[a-zA-Z]\w*)?(\s+\d{1,2}[tu]?)+$/, - /^pvid\s+\d{1,2}\s+\d{1,4}$/, - /^ingress(\s+\d{1,2}[tua])+$/, - /^ingress\s+[tua]$/, - /^port\s+\d{1,2}\s+(10m|100m|1g|2g5|5g|10g|auto|on|off)(\s+(half|full))?$/, - /^port\s+\d{1,2}\s+name\s+\S+$/, - /^eee(\s+\d{1,2})?\s+(on|off)$/, - /^mirror(\s+\d{1,2})(\s+\d{1,2}[tr]?)+$/, - /^lag\s+\d(\s+\d{1,2})+$/, - /^laghash\s+\d(\s+\w+)+$/, - /^isolate\s+\d{1,2}(\s+(off|\d{1,2}))+$/, - /^stp\s+(on|off)$/, - /^igmp\s+(on|off)$/, - /^mtu\s+\d{1,2}\s+\d+$/, - /^bw\s+(in|out)\s+\d{1,2}\s+\S+$/, - /^hostname\s+.{1,23}$/, -]; -const conf_overwrite = [ - /^ip\b/, - /^gw\b/, - /^netmask\b/, - /^syslog\s+ip\b/, - /^syslog\b/, - /^passwd\b/, - /^vlan\s+\d{1,4}\s+mgmt$/, - /^vlan\s+\d{1,4}(?!\s+mgmt\b)/, - /^pvid\s+\d{1,2}\b/, - /^ingress\b/, - /^port\s+\d{1,2}(?!\s+name\b)/, - /^port\s+\d{1,2}\s+name\b/, - /^eee\s+\d{1,2}\b/, - /^eee\b/, - /^mirror\b/, - /^lag\s+\d+\b/, - /^laghash\b/, - /^isolate\s+\d{1,2}\b/, - /^stp\b/, - /^igmp\b/, - /^mtu\s+\d{1,2}\b/, - /^bw\s+(in|out)\s+\d{1,2}\b/, - /^hostname\b/, -]; - -function parseConf(s){ - var a = s.split(/\r\n|\n/); - for (var l = 0; l < a.length; l++) { - var line = a[l].trim().replace(/\s+/g, ' '); - if (!line.length) continue; - const deleteMatch = line.match(/^vlan\s+(\d{1,4})\s+d$/); - if (deleteMatch) { - const prefix = "vlan " + deleteMatch[1] + " "; - configuration = configuration.filter(c => !c.startsWith(prefix)); - continue; - } - console.log(l + ' --> ' + line); - var ignore = true; - for (const x of conf_cmds) - if (x.test(line)) { ignore = false; break; } - if (ignore) continue; - for (const x of conf_overwrite) { - if (x.test(line)) { - let m = line.match(x); - let matchStr = m[0]; - configuration = configuration.filter(item => - !(item === matchStr || (item.startsWith(matchStr + " ") && !item.endsWith(" mgmt") && !item.startsWith(matchStr + " name ")))); - break; - } - } - // Only one management VLAN can be active, so drop any previous mgmt entry - if (/^vlan\s+\d{1,4}\s+mgmt$/.test(line)) - configuration = configuration.filter(item => !/^vlan\s+\d{1,4}\s+mgmt$/.test(item)); - configuration.push(line); - } - console.log("Configuration now:"); - for (const x of configuration) { console.log(x); } -} - -async function fetchConfig() { - try { - const response = await fetch('/config'); - console.log("CONFIG: ", response); - const t = await response.text(); - return t; - } catch(err) { - console.error("Error: ", err); - } -} - -async function fetchCmdLog() { - try { - const response = await fetch('/cmd_log'); - console.log("CMD-Log: ", response); - const t = await response.text(); - return t; - } catch(err) { - console.error("Error: ", err); - return ""; - } -} diff --git a/html/eee.html b/html/eee.html index 499c223a..a2c10eca 100644 --- a/html/eee.html +++ b/html/eee.html @@ -1,7 +1,6 @@ - EEE Configuration @@ -18,9 +17,6 @@ - - - diff --git a/html/eee.js b/html/eee.js deleted file mode 100644 index 9225569b..00000000 --- a/html/eee.js +++ /dev/null @@ -1,52 +0,0 @@ -function createEEE() { - var tbl = document.getElementById('eeetable'); - if (tbl.rows.length <= 2 && numPorts) { - console.log("CREATING TABLE ", tbl.rows.length); - 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(t('common_port') + (i-1))); - for (let j = 0; j < 7; j++) { - td = tr.insertCell(); td.appendChild(document.createTextNode(" ")); - } - } - } -} - -function getEEE() { - var xhttp = new XMLHttpRequest(); - xhttp.onreadystatechange = function() { - if (this.readyState == 4 && this.status == 200) { - const s = JSON.parse(xhttp.responseText); - console.log("EEE: ", JSON.stringify(s)); - var tbl = document.getElementById('eeetable'); - 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]); - let tr = tbl.rows[n+1]; - if (!p.isSFP) { - let eee = parseInt(p.eee,2); let lp = parseInt(p.eee_lp,2); - tr.cells[1].innerHTML = `${eee&4?t('eee_on'):t('eee_off')}`; tr.cells[2].innerHTML = `${eee&2?t('eee_on'):t('eee_off')}`; tr.cells[3].innerHTML = `${eee&1?t('eee_on'):t('eee_off')}`; - tr.cells[4].innerHTML = `${lp&4?t('eee_on'):t('eee_off')}`; tr.cells[5].innerHTML = `${lp&2?t('eee_on'):t('eee_off')}`; tr.cells[6].innerHTML = `${lp&1?t('eee_on'):t('eee_off')}`; - tr.cells[7].innerHTML = `${p.active}`; - tr.classList.toggle('disabled', pState[i-2] < 0); tr.classList.toggle('isNOK', !p.active); tr.classList.toggle('isOK', p.active); - } - tr.classList.toggle('isSFP', p.isSFP); - } - } - } - }; - xhttp.open("GET", "/eee.json", true); - xhttp.timeout = 1500; sendXHTTP(xhttp); -} - -window.addEventListener("load", function() { - update( () => { - createEEE(); - getEEE(); - const interval = setInterval(update, 2000); - const iCount = setInterval(getEEE, 2000); - }); -}); diff --git a/html/eee_sub.js b/html/eee_sub.js deleted file mode 100644 index 6a72f92d..00000000 --- a/html/eee_sub.js +++ /dev/null @@ -1,18 +0,0 @@ -async function eeeSub(port, enable) { - var cmd = "eee "; - if (enable) - cmd = cmd + "on"; - else - cmd = cmd + "off"; - console.log("eeeSub port " + port, ", value " + enable); - try { - const response = await fetch('/cmd', { - method: 'POST', - body: cmd - }); - console.log('Completed!', response); - } catch(err) { - console.error(`Error: ${err}`); - } -} - diff --git a/html/i18n.js b/html/i18n.js deleted file mode 100644 index 850d9ac1..00000000 --- a/html/i18n.js +++ /dev/null @@ -1,603 +0,0 @@ -var LANG = { - en: { - nav_overview: 'Overview', - nav_port_config: 'Port Configuration', - nav_port_stat: 'Port Statistics', - nav_l2: 'L2 Configuration', - nav_mirror: 'Mirroring', - nav_lag: 'Link Aggregation', - nav_eee: 'EEE', - nav_bandwidth: 'Bandwidth Limits', - nav_system: 'System Settings', - nav_fw_update: 'Firmware Update', - - port_name: 'Name', - port_status: 'Status', - port_not_enabled: 'Not enabled.', - port_link_speed: 'Link speed', - port_vendor: 'Vendor', - port_model: 'Model', - port_serial: 'Serial', - port_temp: 'Temp', - port_vcc: 'Vcc', - port_tx_fault: 'TX-Fault', - port_tx_disabled: 'TX-Disabled', - port_tx_bias: 'TX-Bias', - port_tx_power: 'TX-Power', - port_rx_power: 'RX-Power', - port_rx_los: 'RX-LOS', - - speed_disabled: 'Disabled', - speed_down: 'Down', - - port_title: 'FreeSwitchOS Port Configuration', - port_heading: 'Port Configuration', - port_col_port: 'Port', - port_col_name: 'Name', - port_col_speed: 'Current Link Speed', - port_col_set_speed: 'Set Speed', - port_col_disabled: 'Disabled', - port_col_apply: 'Apply', - port_mtu_heading: 'Configure Maximum Frame Size (MTU) forwarded at Port', - port_auto: 'Auto', - port_2500m: '2500MBit/Full', - port_1000m: '1000MBit/Full', - port_100m_f: '100MBit/Full', - port_100m_h: '100MBit/Half', - port_10m_f: '10MBit/Full', - port_10m_h: '10MBit/Half', - port_apply: 'Apply', - - stat_title: 'FreeSwitchOS Port Statistics', - stat_heading: 'Port Statistics', - stat_detailed: 'Detailed Port Statistics', - stat_close: 'Close', - stat_col_port: 'Port', - stat_col_name: 'Name', - stat_col_link: 'link', - stat_col_tx_good: 'TX Good', - stat_col_tx_bad: 'TX Bad', - stat_col_rx_good: 'RX Good', - stat_col_rx_bad: 'RX Bad', - stat_col_all: 'All Counters', - stat_counter: 'Counter', - stat_value: 'Value', - stat_show: 'Show', - - vlan_title: 'FreeSwitchOS VLAN Configuration', - vlan_heading: 'VLAN Configuration', - vlan_select: 'VLAN Select:', - vlan_choose: '— VLAN Choose —', - vlan_id: 'VLAN ID:', - vlan_get_config: 'Get Configuration', - vlan_name: 'VLAN Name:', - vlan_tagged: 'Tagged Ports', - vlan_untagged: 'Untagged Ports', - vlan_select_all: 'Select all', - vlan_pvid: 'Use as default VLAN for incoming traffic (PVID)', - vlan_update: 'Update / Create', - vlan_configured: 'Configured VLANs', - vlan_col_name: 'Name', - vlan_col_member: 'Member Ports', - vlan_col_tagged: 'Tagged Ports', - vlan_col_untagged: 'Untagged Ports', - vlan_col_pvid: 'PVID Ports', - vlan_col_delete: 'Delete', - vlan_set_id_first: 'Set VLAN ID first', - vlan_delete_confirm: 'Delete VLAN ', - - lag_title: 'Link Aggregation Configuration', - lag_heading: 'Link Aggregation Groups Configuration', - lag_update: 'Update / Create', - - mirror_title: 'Mirror Configuration', - mirror_heading: 'Mirror Configuration', - mirror_enabled: 'Enabled:', - mirror_port: 'Mirroring Port:', - mirror_tx: 'Mirrored Ports (TX)', - mirror_rx: 'Mirrored Ports (RX)', - mirror_update: 'Update / Create', - mirror_disable: 'Disable Mirroring', - mirror_set_port_first: 'Set Mirroring Port first', - mirror_select_ports: 'Select Mirrored Ports', - - eee_title: 'EEE Configuration', - eee_heading: 'EEE Status', - eee_advertising: 'Advertising', - eee_partner: 'Link-Partner advertises', - eee_port: 'Port', - eee_active: 'Active?', - eee_enable: 'Enable EEE', - eee_disable: 'Disable EEE', - eee_on: 'ON', - eee_off: 'OFF', - - l2_title: 'FreeSwitchOS L2 Configuration', - l2_heading: 'L2 Configuration', - l2_col_port: 'Port', - l2_col_type: 'Type', - l2_col_remove: 'Remove Entry', - l2_shown: 'Shown:', - l2_delete: 'Delete', - l2_static: 'static', - l2_learned: 'learned', - - bw_title: 'Ingress and Egress Bandwidth', - bw_heading: 'Ingress and Egress Bandwidth', - bw_ingress: 'Ingress', - bw_egress: 'Egress', - bw_col_port: 'Port', - bw_col_limit: 'Limit', - bw_col_bandwidth: 'Bandwidth [kBit/s]', - bw_col_flow: 'Flow Control', - bw_col_apply: 'Apply', - bw_unlimited: 'UNLIMITED', - - sys_title: 'System Settings', - sys_tab_system: 'System', - sys_tab_advanced: 'Advanced', - sys_tab_console: 'Console', - sys_heading: 'System Settings', - sys_ip: 'IP address:', - sys_model: 'Model:', - sys_hostname: 'Hostname:', - sys_apply: 'Apply', - sys_netmask: 'Netmask:', - sys_gateway: 'Gateway:', - sys_language: 'Language:', - sys_mgmt_vlan: 'Management VLAN:', - sys_mgmt_untagged: 'untagged', - sys_mgmt_confirm: 'Move switch management to VLAN ', - sys_mgmt_warn: 'The switch will start tagging its own traffic with that VLAN. If the port you are connected through does not carry it, this page becomes unreachable and the setting can only be undone over the console. Continue?', - sys_ip_note: 'When updating the above settings, remember to point your browser to the new IP afterwards:', - sys_update: 'Update Settings', - sys_save_label: 'Save all current settings to Flash:', - sys_save: 'Save Settings to Flash', - sys_advanced: 'Advanced Settings', - sys_startup_config: 'Startup configuration:', - sys_startup_warn: 'Be careful when saving the directly edited startup configuration, you can lock yourself out:', - sys_clear_config: 'Clear Startup Config', - sys_save_startup: 'Save Startup Settings to Flash', - sys_reset: 'Reset Switch', - sys_console: 'Console Command', - sys_enter_cmd: 'Enter command:', - sys_send_cmd: 'Send Command', - sys_console_warn: 'Be careful when entering console commands, you can lock yourself out!', - sys_invalid_ip: 'Invalid ip:', - sys_reset_confirm: 'Are you sure you want to reset the switch?', - sys_resetting: 'Switch is resetting. Please wait and refresh the page.', - - login_title: 'RTL Switch Login', - login_heading: 'RTL Switch Login', - login_wrong: 'Wrong password!', - login_password: 'Password', - login_login: 'Login', - - index_title: 'FreeSwitchOS Main Page', - index_heading: 'Switch Configuration', - index_settings: 'Settings', - - update_title: 'Firmware update', - update_heading: 'Firmware Update', - update_instruction: 'Choose a firmware update file to upload:', - update_upload: 'Upload File', - - common_port: 'Port ', - common_pkts: ' pkts', - }, - - ja: { - nav_overview: '概要', - nav_port_config: 'ポート設定', - nav_port_stat: 'ポート統計', - nav_l2: 'L2 設定', - nav_mirror: 'ミラーリング', - nav_lag: 'リンクアグリゲーション', - nav_eee: 'EEE', - nav_bandwidth: '帯域制限', - nav_system: 'システム設定', - nav_fw_update: 'ファームウェア更新', - - port_name: '名前', - port_status: '状態', - port_not_enabled: '無効', - port_link_speed: 'リンク速度', - port_vendor: 'ベンダー', - port_model: 'モデル', - port_serial: 'シリアル', - port_temp: '温度', - port_vcc: '電圧', - port_tx_fault: 'TX 障害', - port_tx_disabled: 'TX 無効', - port_tx_bias: 'TX バイアス', - port_tx_power: 'TX 電力', - port_rx_power: 'RX 電力', - port_rx_los: 'RX 信号ロス', - - speed_disabled: '無効', - speed_down: 'リンクダウン', - - port_title: 'FreeSwitchOS ポート設定', - port_heading: 'ポート設定', - port_col_port: 'ポート', - port_col_name: '名前', - port_col_speed: '現在のリンク速度', - port_col_set_speed: '速度設定', - port_col_disabled: '無効', - port_col_apply: '適用', - port_mtu_heading: 'ポートの最大フレームサイズ (MTU) 設定', - port_auto: '自動', - port_2500m: '2500Mbps/全二重', - port_1000m: '1000Mbps/全二重', - port_100m_f: '100Mbps/全二重', - port_100m_h: '100Mbps/半二重', - port_10m_f: '10Mbps/全二重', - port_10m_h: '10Mbps/半二重', - port_apply: '適用', - - stat_title: 'FreeSwitchOS ポート統計', - stat_heading: 'ポート統計', - stat_detailed: '詳細ポート統計', - stat_close: '閉じる', - stat_col_port: 'ポート', - stat_col_name: '名前', - stat_col_link: 'リンク', - stat_col_tx_good: 'TX 正常', - stat_col_tx_bad: 'TX 異常', - stat_col_rx_good: 'RX 正常', - stat_col_rx_bad: 'RX 異常', - stat_col_all: '全カウンタ', - stat_counter: 'カウンタ', - stat_value: '値', - stat_show: '表示', - - vlan_title: 'FreeSwitchOS VLAN 設定', - vlan_heading: 'VLAN 設定', - vlan_select: 'VLAN 選択:', - vlan_choose: '— VLAN 選択 —', - vlan_id: 'VLAN ID:', - vlan_get_config: '設定取得', - vlan_name: 'VLAN 名:', - vlan_tagged: 'タグ付きポート', - vlan_untagged: 'タグ無しポート', - vlan_select_all: 'すべて選択', - vlan_pvid: '受信トラフィックのデフォルト VLAN (PVID)', - vlan_update: '更新 / 作成', - vlan_configured: '設定済み VLAN', - vlan_col_name: '名前', - vlan_col_member: 'メンバーポート', - vlan_col_tagged: 'タグ付きポート', - vlan_col_untagged: 'タグ無しポート', - vlan_col_pvid: 'PVID ポート', - vlan_col_delete: '削除', - vlan_set_id_first: 'VLAN ID を先に設定してください', - vlan_delete_confirm: 'VLAN 削除 ', - - lag_title: 'リンクアグリゲーション設定', - lag_heading: 'リンクアグリゲーショングループ設定', - lag_update: '更新 / 作成', - - mirror_title: 'ミラーリング設定', - mirror_heading: 'ミラーリング設定', - mirror_enabled: '有効:', - mirror_port: 'ミラーポート:', - mirror_tx: 'ミラー元ポート (TX)', - mirror_rx: 'ミラー元ポート (RX)', - mirror_update: '更新 / 作成', - mirror_disable: 'ミラーリング無効化', - mirror_set_port_first: 'ミラーポートを先に設定してください', - mirror_select_ports: 'ミラー元ポートを選択してください', - - eee_title: 'EEE 設定', - eee_heading: 'EEE 状態', - eee_advertising: 'EEE アドバタイジング', - eee_partner: 'リンクパートナー広告', - eee_port: 'ポート', - eee_active: '有効?', - eee_enable: 'EEE 有効化', - eee_disable: 'EEE 無効化', - eee_on: 'オン', - eee_off: 'オフ', - - l2_title: 'FreeSwitchOS L2 設定', - l2_heading: 'L2 設定', - l2_col_port: 'ポート', - l2_col_type: 'タイプ', - l2_col_remove: 'エントリ削除', - l2_shown: 'Shown:', - l2_delete: '削除', - l2_static: '静的', - l2_learned: '学習', - - bw_title: '入力/出力帯域制限', - bw_heading: '入力/出力帯域制限', - bw_ingress: '入力', - bw_egress: '出力', - bw_col_port: 'ポート', - bw_col_limit: '制限', - bw_col_bandwidth: '帯域 [kbps]', - bw_col_flow: 'フロー制御', - bw_col_apply: '適用', - bw_unlimited: '制限無し', - - sys_title: 'システム設定', - sys_tab_system: 'システム', - sys_tab_advanced: '詳細設定', - sys_tab_console: 'コンソール', - sys_heading: 'システム設定', - sys_ip: 'IP アドレス:', - sys_model: 'モデル:', - sys_hostname: 'ホスト名:', - sys_apply: '適用', - sys_netmask: 'ネットマスク:', - sys_gateway: 'ゲートウェイ:', - sys_language: '言語:', - sys_mgmt_vlan: 'Management VLAN:', - sys_mgmt_untagged: 'untagged', - sys_mgmt_confirm: 'Move switch management to VLAN ', - sys_mgmt_warn: 'The switch will start tagging its own traffic with that VLAN. If the port you are connected through does not carry it, this page becomes unreachable and the setting can only be undone over the console. Continue?', - sys_ip_note: '上記設定を変更した場合は、ブラウザで新しい IP にアクセスしてください:', - sys_update: '設定更新', - sys_save_label: '現在の設定をフラッシュに保存:', - sys_save: '設定をフラッシュに保存', - sys_advanced: '詳細設定', - sys_startup_config: '起動設定:', - sys_startup_warn: '起動設定を直接編集する際は注意してください。ロックアウトされる可能性があります:', - sys_clear_config: '起動設定クリア', - sys_save_startup: '起動設定をフラッシュに保存', - sys_reset: 'スイッチ再起動', - sys_console: 'コンソールコマンド', - sys_enter_cmd: 'コマンド入力:', - sys_send_cmd: 'コマンド送信', - sys_console_warn: 'コンソールコマンドは注意して入力してください。ロックアウトされる可能性があります!', - sys_invalid_ip: '無効な IP: ', - sys_reset_confirm: 'スイッチを再起動してもよろしいですか?', - sys_resetting: 'スイッチを再起動中です。しばらく待ってからページをリロードしてください。', - - login_title: 'RTL スイッチ ログイン', - login_heading: 'RTL スイッチ ログイン', - login_wrong: 'パスワードが違います!', - login_password: 'パスワード', - login_login: 'ログイン', - - index_title: 'FreeSwitchOS メインページ', - index_heading: 'スイッチ設定', - index_settings: '設定', - - update_title: 'ファームウェア更新', - update_heading: 'ファームウェア更新', - update_instruction: 'アップロードするファームウェアファイルを選択:', - update_upload: 'ファイルをアップロード', - - common_port: 'ポート ', - common_pkts: ' pkts', - }, - - zh: { - nav_overview: '概览', - nav_port_config: '端口配置', - nav_port_stat: '端口统计', - nav_l2: 'L2 配置', - nav_mirror: '端口镜像', - nav_lag: '链路聚合', - nav_eee: 'EEE', - nav_bandwidth: '带宽限制', - nav_system: '系统设置', - nav_fw_update: '固件升级', - - port_name: '名称', - port_status: '状态', - port_not_enabled: '未启用。', - port_link_speed: '链路速率', - port_vendor: '厂商', - port_model: '型号', - port_serial: '序列号', - port_temp: '温度', - port_vcc: '供电电压', - port_tx_fault: 'TX 故障', - port_tx_disabled: 'TX 禁用', - port_tx_bias: 'TX 偏置电流', - port_tx_power: 'TX 光功率', - port_rx_power: 'RX 光功率', - port_rx_los: 'RX 信号丢失', - - speed_disabled: '禁用', - speed_down: '未连接', - - port_title: 'FreeSwitchOS 端口配置', - port_heading: '端口配置', - port_col_port: '端口', - port_col_name: '名称', - port_col_speed: '当前链路速率', - port_col_set_speed: '设置速率', - port_col_disabled: '禁用', - port_col_apply: '应用', - port_mtu_heading: '配置端口转发的最大帧大小 (MTU)', - port_auto: '自动', - port_2500m: '2500Mbps/全双工', - port_1000m: '1000Mbps/全双工', - port_100m_f: '100Mbps/全双工', - port_100m_h: '100Mbps/半双工', - port_10m_f: '10Mbps/全双工', - port_10m_h: '10Mbps/半双工', - port_apply: '应用', - - stat_title: 'FreeSwitchOS 端口统计', - stat_heading: '端口统计', - stat_detailed: '详细端口统计', - stat_close: '关闭', - stat_col_port: '端口', - stat_col_name: '名称', - stat_col_link: '链路', - stat_col_tx_good: 'TX 正常包', - stat_col_tx_bad: 'TX 错误包', - stat_col_rx_good: 'RX 正常包', - stat_col_rx_bad: 'RX 错误包', - stat_col_all: '所有计数器', - stat_counter: '计数器', - stat_value: '值', - stat_show: '查看', - - vlan_title: 'FreeSwitchOS VLAN 配置', - vlan_heading: 'VLAN 配置', - vlan_select: 'VLAN 选择:', - vlan_choose: '-- 请选择 VLAN --', - vlan_id: 'VLAN ID:', - vlan_get_config: '获取配置', - vlan_name: 'VLAN 名称:', - vlan_tagged: 'Tagged 端口', - vlan_untagged: 'Untagged 端口', - vlan_select_all: '全选', - vlan_pvid: '作为入方向流量的默认 VLAN (PVID)', - vlan_update: '更新 / 创建', - vlan_configured: '已配置 VLAN', - vlan_col_name: '名称', - vlan_col_member: '成员端口', - vlan_col_tagged: 'Tagged 端口', - vlan_col_untagged: 'Untagged 端口', - vlan_col_pvid: 'PVID 端口', - vlan_col_delete: '删除', - vlan_set_id_first: '请先设置 VLAN ID', - vlan_delete_confirm: '删除 VLAN ', - - lag_title: '链路聚合配置', - lag_heading: '链路聚合组配置', - lag_update: '更新 / 创建', - - mirror_title: '端口镜像配置', - mirror_heading: '端口镜像配置', - mirror_enabled: '启用:', - mirror_port: '镜像目的端口:', - mirror_tx: '被镜像端口 (TX)', - mirror_rx: '被镜像端口 (RX)', - mirror_update: '更新 / 创建', - mirror_disable: '禁用端口镜像', - mirror_set_port_first: '请先设置镜像目的端口', - mirror_select_ports: '请选择被镜像端口', - - eee_title: 'EEE 配置', - eee_heading: 'EEE 状态', - eee_advertising: '本端通告', - eee_partner: '链路伙伴通告', - eee_port: '端口', - eee_active: '已生效?', - eee_enable: '启用 EEE', - eee_disable: '禁用 EEE', - eee_on: '开', - eee_off: '关', - - l2_title: 'FreeSwitchOS L2 配置', - l2_heading: 'L2 配置', - l2_col_port: '端口', - l2_col_type: '类型', - l2_col_remove: '删除条目', - l2_shown: 'Shown:', - l2_delete: '删除', - l2_static: '静态', - l2_learned: '动态学习', - - bw_title: '入方向/出方向带宽限制', - bw_heading: '入方向/出方向带宽限制', - bw_ingress: '入方向', - bw_egress: '出方向', - bw_col_port: '端口', - bw_col_limit: '限速', - bw_col_bandwidth: '带宽 [kbit/s]', - bw_col_flow: '流量控制', - bw_col_apply: '应用', - bw_unlimited: '不限速', - - sys_title: '系统设置', - sys_tab_system: '系统', - sys_tab_advanced: '高级', - sys_tab_console: '控制台', - sys_heading: '系统设置', - sys_ip: 'IP 地址:', - sys_model: '型号:', - sys_hostname: '主机名:', - sys_apply: '应用', - sys_netmask: '子网掩码:', - sys_gateway: '网关:', - sys_language: '语言:', - sys_mgmt_vlan: 'Management VLAN:', - sys_mgmt_untagged: 'untagged', - sys_mgmt_confirm: 'Move switch management to VLAN ', - sys_mgmt_warn: 'The switch will start tagging its own traffic with that VLAN. If the port you are connected through does not carry it, this page becomes unreachable and the setting can only be undone over the console. Continue?', - sys_ip_note: '更新上述设置后,请使用新的 IP 地址重新访问管理界面:', - sys_update: '更新设置', - sys_save_label: '将当前全部设置保存到 Flash:', - sys_save: '保存设置到 Flash', - sys_advanced: '高级设置', - sys_startup_config: '启动配置:', - sys_startup_warn: '直接编辑启动配置时请谨慎,错误配置可能导致无法访问设备:', - sys_clear_config: '清除启动配置', - sys_save_startup: '保存启动配置到 Flash', - sys_reset: '重启交换机', - sys_console: '控制台命令', - sys_enter_cmd: '输入命令:', - sys_send_cmd: '发送命令', - sys_console_warn: '输入控制台命令时请谨慎,错误命令可能导致无法访问设备!', - sys_invalid_ip: '无效 IP: ', - sys_reset_confirm: '确定要重启交换机吗?', - sys_resetting: '交换机正在重启。请稍候并刷新页面。', - - login_title: 'RTL 交换机登录', - login_heading: 'RTL 交换机登录', - login_wrong: '密码错误!', - login_password: '密码', - login_login: '登录', - - index_title: 'FreeSwitchOS 主页', - index_heading: '交换机配置', - index_settings: '设置', - - update_title: '固件升级', - update_heading: '固件升级', - update_instruction: '请选择要上传的固件文件:', - update_upload: '上传文件', - - common_port: '端口 ', - common_pkts: ' 个包', - } -}; - -var rtlLang = (function() { - var saved = localStorage.getItem('rtl_lang'); - if (saved && LANG[saved]) return saved; - var browser = (navigator.language || navigator.userLanguage || 'en').substring(0, 2); - return LANG[browser] ? browser : 'en'; -})(); - -function t(key) { - return LANG[rtlLang][key] || LANG['en'][key] || key; -} - -function setLang(lang) { - if (LANG[lang]) { - localStorage.setItem('rtl_lang', lang); - rtlLang = lang; - document.querySelectorAll('[data-i18n]').forEach(function(el) { - applyTranslation(el); - }); - } -} - -function applyTranslation(el) { - var key = el.getAttribute('data-i18n'); - if (!key) return; - if (el.tagName === 'INPUT' && (el.type === 'submit' || el.type === 'button')) { - el.value = t(key); - } else if (el.tagName === 'OPTION') { - el.textContent = t(key); - } else if (el.tagName === 'TITLE') { - el.textContent = t(key); - } else { - el.innerHTML = t(key); - } -} - -document.addEventListener('DOMContentLoaded', function() { - document.querySelectorAll('[data-i18n]').forEach(function(el) { - applyTranslation(el); - }); -}); diff --git a/html/index.html b/html/index.html index 4975df2b..e0de34ab 100644 --- a/html/index.html +++ b/html/index.html @@ -1,8 +1,6 @@ - - diff --git a/html/l2.html b/html/l2.html index 61343725..7ba2e1d1 100644 --- a/html/l2.html +++ b/html/l2.html @@ -1,7 +1,6 @@ - FreeSwitchOS L2 Configuration @@ -22,9 +21,7 @@ Type
Remove Entry - - diff --git a/html/l2.js b/html/l2.js deleted file mode 100644 index d3a058bc..00000000 --- a/html/l2.js +++ /dev/null @@ -1,194 +0,0 @@ -var l2GetInterval; -var l2Entries = []; -var l2CurrentEntry = 0; - -function fillStats() { - var tbl = document.getElementById('statstable'); - if (!numPorts) - return; - if (tbl.rows.length > 1) { - for (let i = 0; i < numPorts; i++) { - console.log("Table Update row: " + i + " state " + pState[i] + " is " + linkS[pState[i] +1]); - tbl.rows[i+1].cells[1].innerHTML = linkText(pState[i]+1); - tbl.rows[i+1].cells[2].innerHTML = `${txG[i]}` + t('common_pkts'); - tbl.rows[i+1].cells[3].innerHTML = `${txB[i]}` + t('common_pkts'); - tbl.rows[i+1].cells[4].innerHTML = `${rxG[i]}` + t('common_pkts'); - tbl.rows[i+1].cells[5].innerHTML = `${rxB[i]}` + t('common_pkts'); - } - } else { - for (let i = 0; i < numPorts; i++) { - console.log("Table row: " + i); - const tr = tbl.insertRow(); - let td = tr.insertCell(); td.appendChild(document.createTextNode(t('common_port') + (i+1))); - td = tr.insertCell(); td.appendChild(document.createTextNode(linkText(pState[i]+1))); - td = tr.insertCell(); td.appendChild(document.createTextNode(`${txG[i]}` + t('common_pkts'))); - td = tr.insertCell();td.appendChild(document.createTextNode(`${txB[i]}` + t('common_pkts'))); - td = tr.insertCell();td.appendChild(document.createTextNode(`${rxG[i]}` + t('common_pkts'))); - td = tr.insertCell();td.appendChild(document.createTextNode(`${rxB[i]}` + t('common_pkts'))); - } - } -} - -function l2CMP(a, b) -{ - if (a.port < b.port) - return -1; - if (a.port > b.port) - return 1; - if (a.mac < b.mac) - return -1; - if (a.mac > b.mac) - return 1; - if (a.vlan < b.vlan) - return -1; - if (a.vlan > b.vlan) - return 1; - return 0; -} - -function uniq(a) { - return a.filter(function(item, pos, ary) { - return !pos || item.idx != ary[pos - 1].idx; - }); -} - -function delL2(idx) { - var xhttp = new XMLHttpRequest(); - xhttp.onreadystatechange = function() { - if (this.readyState == 4 && this.status == 200) { - var s = JSON.parse(xhttp.responseText); - console.log("Entry deletion result: ", s.result); - } - }; - xhttp.open("GET", "/l2_del.json?idx=" + idx, true); - xhttp.timeout = 1500; xhttp.send(); -} - -var l2All = []; -const l2Cols = ['port', 'mac', 'vlan', 'type']; -var l2SortCol = 'port'; -var l2SortDir = 1; - -function l2Key(e, col) { - if (col === 'port') return e.port === 'CPU' ? Number.MAX_SAFE_INTEGER : Number(e.port); - if (col === 'vlan') return Number(e.vlan); - return String(e[col]).toLowerCase(); -} - -function l2SortBy(col) { - l2SortDir = (col === l2SortCol) ? -l2SortDir : 1; - l2SortCol = col; - renderL2(); -} - -function l2FilterChanged() { renderL2(); } - -function renderL2() { - var tbl = document.getElementById('l2table'); - if (!tbl) return; - var f = {}; - l2Cols.forEach(function(c) { - var el = document.getElementById('l2f_' + c); - f[c] = el ? el.value.trim().toLowerCase() : ''; - }); - var rows = l2All.filter(function(e) { - return l2Cols.every(function(c) { - return !f[c] || String(e[c]).toLowerCase().indexOf(f[c]) !== -1; - }); - }); - rows.sort(function(a, b) { - var x = l2Key(a, l2SortCol), y = l2Key(b, l2SortCol); - return (x < y ? -1 : x > y ? 1 : 0) * l2SortDir; - }); - l2Cols.forEach(function(c) { - var a = document.getElementById('l2a_' + c); - if (a) a.textContent = (c === l2SortCol) ? (l2SortDir > 0 ? ' \u25b2' : ' \u25bc') : ' \u21c5'; - }); - paintL2(tbl, rows); - var cnt = document.getElementById('l2count'); - if (cnt) cnt.textContent = rows.length + ' / ' + l2All.length; -} - -function fillL2(s) -{ - var tbl = document.getElementById('l2table'); - if (!s.length) - return; - s.sort(l2CMP); - s = uniq(s); - l2All = s; - renderL2(); - l2Entries = []; -} - -function paintL2(tbl, s) -{ - console.log("L2: ", JSON.stringify(s)); - for (let i = 0; i < s.length; i++) { - var e = s[i]; - console.log(i, e); - if (tbl.rows[i+1]) { - tbl.rows[i+1].cells[0].innerHTML = `${e.port}`; - tbl.rows[i+1].cells[1].innerHTML = `${e.mac}`; - tbl.rows[i+1].cells[2].innerHTML = `${e.vlan}`; - tbl.rows[i+1].cells[3].innerHTML = `${e.type}`; - tbl.rows[i+1].cells[4].innerHTML = ''; - } else { - const tr = tbl.insertRow(); - let td = tr.insertCell(); td.innerHTML = `${e.port}`; - td = tr.insertCell(); td.innerHTML = `${e.mac}`; - td = tr.insertCell(); td.innerHTML = `${e.vlan}`; - td = tr.insertCell(); td.innerHTML = `${e.type}`; - td = tr.insertCell(); td.innerHTML = ''; - } - } - for (let i = tbl.rows.length - 1; i > s.length; i--) - tbl.deleteRow(i); -} - -function getL2() { - var xhttp = new XMLHttpRequest(); - xhttp.onreadystatechange = function() { - if (this.readyState == 4 && this.status == 200) { - var s = JSON.parse(xhttp.responseText); - var s = s.map(function(e) { - e.vlan = parseInt(e.vlan, 16); - e.idx = parseInt(e.idx, 16); - e.type = e.type == "s" ? t('l2_static') : t('l2_learned'); - e.port = e.port == 9 ? 'CPU' : logToPhysPort[e.port]; - return e; - }); - l2Entries.push(...s); - if (l2Entries >= 4096) { - l2Entries = []; - l2CurrentEntry = 0; - clearInterval(l2GetInterval); - return; - } - var w = 0; - for (var i = l2Entries.length-1; i > 0; i--) { - if (l2Entries[0].idx == l2Entries[i].idx) { - w = 1; - break; - } - } - if (w) { - l2CurrentEntry = 0; - fillL2(l2Entries); - } else { - l2CurrentEntry = s[s.length-1].idx + 1; - } - } - }; - xhttp.open("GET", "/l2.json?idx=" + l2CurrentEntry, true); - xhttp.timeout = 1500; sendXHTTP(xhttp); -} - -window.addEventListener("load", function() { - update( () => { - getL2(); - const interval = setInterval(update, 2000); - l2GetInterval = setInterval(getL2, 1000); - });; -}); - diff --git a/html/lag.html b/html/lag.html index 7a5e5f76..8e3e9cbc 100644 --- a/html/lag.html +++ b/html/lag.html @@ -1,7 +1,6 @@ - Link Aggregation Configuration @@ -21,8 +20,6 @@

LAG 4

- - diff --git a/html/lag.js b/html/lag.js deleted file mode 100644 index 2c56d1a5..00000000 --- a/html/lag.js +++ /dev/null @@ -1,81 +0,0 @@ -var lagInterval = Number(); - -function lagForm() { - if (!numPorts) - return; - for (let j=0; j < 4; j++) { - var lag = "mLAG" + j - console.log("Adding LAG " + lag) - var m = document.getElementById(lag); - for (let i = 1; i <= numPorts; i++) { - const d = document.createElement("div"); - d.classList.add("cbgroup"); - const l = document.createElement("label"); - l.innerHTML = "" + i; - l.classList.add("cbgroup"); - const inp = document.createElement("input"); - inp.type = "checkbox"; inp.setAttribute("class","psel"); - inp.id = "p_" + lag + "_" + i; - const o = document.createElement("img"); - if (pIsSFP[i - 1]) { - o.src = "sfp.svg"; o.width ="60"; o.height ="60"; - } else { - o.src = "port.svg"; o.width = "40"; o.height = "40"; - } - l.appendChild(inp); l.appendChild(o); - d.appendChild(l) - m.appendChild(d); - } - } - fetchLag(); -} - -function setL(p, c){ - console.log("LAG setting: ", p, " to ", c); - document.getElementById(p).checked=c; -} - -function fetchLag() { - var xhttp = new XMLHttpRequest(); - xhttp.onreadystatechange = function() { - if (this.readyState == 4 && this.status == 200) { - const s = JSON.parse(xhttp.responseText); - console.log("LAG: ", JSON.stringify(s)); - for (let l = 0; l < 4; l++) { - let members = parseInt(s[l].members, 2); - let hash = parseInt(s[l].hash, 16); - for (let i = 1; i <= numPorts; i++) { - let p = i - 1; - if (numPorts < 9) - p = physToLogPort[p]; - setL("p_mLAG"+l+"_"+i, members & (1< { - lagForm(); - const interval = setInterval(update, 2000); - }); -}); diff --git a/html/login.html b/html/login.html index 119a9339..fda7f070 100644 --- a/html/login.html +++ b/html/login.html @@ -2,7 +2,7 @@ RTL Switch Login - + - Mirror Configuration @@ -19,9 +18,6 @@

- - - diff --git a/html/mirror.js b/html/mirror.js deleted file mode 100644 index d09a7b09..00000000 --- a/html/mirror.js +++ /dev/null @@ -1,64 +0,0 @@ -var mirrorInterval = Number(); -const mirrors = ["mPortsTX", "mPortsRX"]; - -function mirrorForm() { - if (!numPorts) - return; - for (let j=0; j < mirrors.length; j++) { - console.log("Adding Mirror " + j) - var m = document.getElementById(mirrors[j]); - for (let i = 1; i <= numPorts; i++) { - const d = document.createElement("div"); - d.classList.add("cbgroup"); - const l = document.createElement("label"); - l.innerHTML = "" + i; - l.classList.add("cbgroup"); - const inp = document.createElement("input"); - inp.type = "checkbox"; inp.setAttribute("class","psel"); - inp.id = mirrors[j] + i; - const o = document.createElement("img"); - if (pIsSFP[i - 1]) { - o.src = "sfp.svg"; o.width ="60"; o.height ="60"; - } else { - o.src = "port.svg"; o.width = "40"; o.height = "40"; - } - l.appendChild(inp); l.appendChild(o); - d.appendChild(l) - m.appendChild(d); - } - } - fetchMirror(); -} - -function setM(p, c){ - document.getElementById(p).checked=c; -} - -function fetchMirror() { - var xhttp = new XMLHttpRequest(); - xhttp.onreadystatechange = function() { - if (this.readyState == 4 && this.status == 200) { - const s = JSON.parse(xhttp.responseText); - console.log("MIRROR: ", JSON.stringify(s)); - document.getElementById('me').checked = s.enabled; - document.getElementById('mp').value = s.mPort; - let m_tx = parseInt(s.mirror_tx, 2); - let m_rx = parseInt(s.mirror_rx, 2); - for (let i = 1; i <= numPorts; i++) { - let p = i - 1; - if (numPorts < 9) - p = physToLogPort[p]; - setM("mPortsTX"+i, m_tx&(1< { - mirrorForm(); - const interval = setInterval(update, 2000); - }); -}); diff --git a/html/mirror_sub.js b/html/mirror_sub.js deleted file mode 100644 index da5b6cd1..00000000 --- a/html/mirror_sub.js +++ /dev/null @@ -1,43 +0,0 @@ -async function mirrorSub() { - var cmd = "mirror "; - var mp=document.getElementById('mp').value - if (!mp) { - alert(t('mirror_set_port_first')); - return; - } - document.getElementById(mirrors[0]+mp).checked=false;document.getElementById(mirrors[1]+mp).checked=false; - cmd = cmd + mp; - for (let i = 1; i <= numPorts; i++) { - if (document.getElementById(mirrors[0] + i).checked && document.getElementById(mirrors[1] + i).checked) - cmd = cmd + ` ${i}`; - else if (document.getElementById(mirrors[0] + i).checked) - cmd = cmd + ` ${i}t`; - else if (document.getElementById(mirrors[1] + i).checked) - cmd = cmd + ` ${i}r`; - } - if (cmd.length < 10) { - alert(t('mirror_select_ports')); - return; - } - try { - const response = await fetch('/cmd', { - method: 'POST', - body: cmd - }); - console.log('Completed!', response); - } catch(err) { - console.error(`Error: ${err}`); - } -} -async function mirrorDel() { - var cmd = "mirror off"; -try { - const response = await fetch('/cmd', { - method: 'POST', - body: cmd - }); - location.reload(); - } catch(err) { - console.error(`Error: ${err}`); - } -} diff --git a/html/navigation.js b/html/navigation.js deleted file mode 100644 index b42f8fd6..00000000 --- a/html/navigation.js +++ /dev/null @@ -1,20 +0,0 @@ -document.getElementById('sidebar').innerHTML = - ""; - -document.addEventListener('DOMContentLoaded', function() { - var links = document.querySelectorAll('#sidebar a[data-i18n]'); - links.forEach(function(el) { - var key = el.getAttribute('data-i18n'); - if (key) el.textContent = t(key); - }); -}); diff --git a/html/ports.html b/html/ports.html index 8d9409f2..233be139 100644 --- a/html/ports.html +++ b/html/ports.html @@ -1,7 +1,6 @@ - FreeSwitchOS Port Configuration @@ -17,9 +16,7 @@

Configure Maximum Frame Size (MTU) forwarded at Port

- - diff --git a/html/ports.js b/html/ports.js deleted file mode 100644 index 9079ca1d..00000000 --- a/html/ports.js +++ /dev/null @@ -1,149 +0,0 @@ -var mtus = new Int16Array(10); -var clicked = new Int8Array(10); -function createPortTable() { - var tbl = document.getElementById('speedtable'); - if (tbl.rows.length <= 2 && numPorts) { - const sSelect = ''; - const dSwitch = '' - for (let i = 1; i <= numPorts; i++) { - if (pIsSFP[i-1]) - continue; - console.log("Table row: " + i + "pState: " + pState[i-2]); - const tr = tbl.insertRow(); - let td = tr.insertCell(); td.appendChild(document.createTextNode(t('common_port') + i)); - let portName = portNames[physToLogPort[i-1]] || ''; - td = tr.insertCell(); td.appendChild(document.createTextNode(portName)); - td = tr.insertCell(); td.innerHTML = linkText(pState[i] + 1); - td = tr.insertCell(); td.innerHTML = sSelect.replaceAll("speed_sel", "speed_sel_" + i); - td = tr.insertCell(); td.innerHTML = dSwitch.replaceAll("disable_port", "disable_port_" + i) - .replace("portOnOff()", "portOnOff(" + i + ")"); - var button = ''; - td = tr.insertCell(); - td.innerHTML = button; - } - } - tbl = document.getElementById('mtutable'); - if (tbl.rows.length <= 2 && numPorts) { - const mSelect = ''; - var tr = tbl.insertRow(); - for (let i = 1; i <= numPorts; i++) { - let td = tr.insertCell(); - if (pIsSFP[i-1]) - td.innerHTML = '' - else - td.innerHTML = '' - } - tr = tbl.insertRow(); - for (let i = 1; i <= numPorts; i++) { - let td = tr.insertCell(); - td.innerHTML = mSelect.replaceAll("mtu_sel", "mtu_sel_" + i); - } - tr = tbl.insertRow(); - for (let i = 1; i <= numPorts; i++) { - let td = tr.insertCell(); - td.innerHTML = ''; - } - } -} - -function updatePortTable() { - console.log("updatePortTable called"); - var tbl = document.getElementById('speedtable'); - if (tbl.rows.length <= 2 || !numPorts) - return; - for (let i = 1; i <= numPorts ; i++) { - if (pIsSFP[i-1]) - continue; - tbl.rows[i].cells[2].innerHTML = linkText(pState[i-1]+1); - if (!clicked[i] && pState[i - 1] < 0) { - document.getElementById('speed_sel_' + i).disabled = true; - document.getElementById('disable_port_' + i).checked = true; - } - } -} - -async function applySpeed(port) { - var speed = document.getElementById('speed_sel_' + port).value; - var disabled = document.getElementById('disable_port_' + port).checked; - var cmd = "port " + port + " "; - if (!disabled) - cmd = cmd + speed; - else - cmd = cmd + "off"; - console.log("CMD: " + cmd); - try { - const response = await fetch('/cmd', { - method: 'POST', - body: cmd - }); - console.log('Completed!', response); - } catch(err) { - console.error(`Error: ${err}`); - } -} - -async function portOnOff(p) { - var disabled = document.getElementById('disable_port_' + p).checked; - document.getElementById('speed_sel_' + p).disabled = disabled; - clicked[p] = 1; -} - -async function applyMTU(port) { - var mtu = document.getElementById('mtu_sel_' + port).value; - var cmd = "mtu " + port + " " + mtu; - try { - const response = await fetch('/cmd', { - method: 'POST', - body: cmd - }); - console.log('MTU Completed!', response); - getMTUs(); - } catch(err) { - console.error(`Error: ${err}`); - } -} - -function getMTUs() { - var xhttp = new XMLHttpRequest(); - xhttp.onreadystatechange = function() { - if (this.readyState == 4 && this.status == 200) { - const s = JSON.parse(xhttp.responseText); - console.log("MTUS: ", JSON.stringify(s)); - for (let i = 0; i < s.length; i++) { - p = s[i]; - let n = p.portNum; - mtus[n] = parseInt(p.mtu, 16); - var mtu = document.getElementById('mtu_sel_' + n); - if (!mtu) - continue; - mtu.value = mtus[n]; - } - } - }; - xhttp.open("GET", "/mtu.json", true); - xhttp.timeout = 1500; sendXHTTP(xhttp); -} - -window.addEventListener("load", function() { - update( () => { - createPortTable(); - updatePortTable(); - getMTUs() - const interval = setInterval(update, 2000); - const updatePortTableInterval = setInterval(updatePortTable, 1000); - }); -}); diff --git a/html/stat.html b/html/stat.html index 993eeded..ba114fcd 100644 --- a/html/stat.html +++ b/html/stat.html @@ -1,7 +1,6 @@ - FreeSwitchOS Port Statistics