diff --git a/source/Styles/xb3/jst/actionHandler/ajaxSet_mta_Line_Diagnostics.jst b/source/Styles/xb3/jst/actionHandler/ajaxSet_mta_Line_Diagnostics.jst index 1a626ec..2cafb40 100644 --- a/source/Styles/xb3/jst/actionHandler/ajaxSet_mta_Line_Diagnostics.jst +++ b/source/Styles/xb3/jst/actionHandler/ajaxSet_mta_Line_Diagnostics.jst @@ -22,60 +22,69 @@ if ($_SESSION["loginuser"] == "" || $_SESSION["loginuser"] == false || (!isset($ echo( ''); exit(0); } -function TransEmpty($v) -{ - return (""==$v) ? "Failed" : $v; -} +var $LineTableNumberOfEntries = Number(getStr("Device.X_CISCO_COM_MTA.LineTableNumberOfEntries")); var $arConfig = {}; if (isset($_GET['get_statusx'])) { - $line1hook = getStr("Device.X_CISCO_COM_MTA.LineTable.1.Status"); - $line2hook = getStr("Device.X_CISCO_COM_MTA.LineTable.2.Status"); - $linexhook = "On-Hook"; - sleep(2); - if ("Off-Hook"==$line1hook || "Off-Hook"==$line2hook){ - $linexhook = "Off-Hook"; + $linexhook = "On-Hook"; + for ($i = 1; $i <= $LineTableNumberOfEntries; $i++) { + $lineHook = getStr("Device.X_CISCO_COM_MTA.LineTable."+$i+".Status"); + if ($lineHook === "Off-Hook") { + $linexhook = "Off-Hook"; + break; // no need to check further + } } - // $linexhook = "Off-Hook"; - $arConfig = {'linexhook':$linexhook}/*p2j-array*/; -} -else if (isset($_GET['get_status1'])) -{ - $line1hook = getStr("Device.X_CISCO_COM_MTA.LineTable.1.Status"); sleep(2); - // $line1hook = "On-Hook"; - $arConfig = {'line1hook':$line1hook}/*p2j-array*/; -} -else if (isset($_GET['get_status2'])) -{ - $line2hook = getStr("Device.X_CISCO_COM_MTA.LineTable.2.Status"); - sleep(2); - // $line2hook = "Off-Hook"; - $arConfig = {'line2hook':$line2hook}/*p2j-array*/; -} -else if (isset($_GET['start_diagnostics1'])) -{ - setStr("Device.X_CISCO_COM_MTA.LineTable.1.TriggerDiagnostics", "true", true); - LogStr( " : webui_event:MTA_line1_diag" ); - sleep(15); - $line1hp = getStr("Device.X_CISCO_COM_MTA.LineTable.1.HazardousPotential"); - $line1femf = getStr("Device.X_CISCO_COM_MTA.LineTable.1.ForeignEMF"); - $line1rf = getStr("Device.X_CISCO_COM_MTA.LineTable.1.ResistiveFaults"); - $line1roh = getStr("Device.X_CISCO_COM_MTA.LineTable.1.ReceiverOffHook"); - $line1re = getStr("Device.X_CISCO_COM_MTA.LineTable.1.RingerEquivalency"); - $arConfig = {'line1hp':$line1hp, 'line1femf':$line1femf, 'line1rf':$line1rf, 'line1roh':$line1roh, 'line1re':$line1re}/*p2j-array*/; + $arConfig = {'linexhook':$linexhook}/*p2j-array*/; } -else if (isset($_GET['start_diagnostics2'])) -{ - setStr("Device.X_CISCO_COM_MTA.LineTable.2.TriggerDiagnostics", "true", true); - LogStr( " : webui_event:MTA_line2_diag" ); - sleep(15); - $line2hp = getStr("Device.X_CISCO_COM_MTA.LineTable.2.HazardousPotential"); - $line2femf = getStr("Device.X_CISCO_COM_MTA.LineTable.2.ForeignEMF"); - $line2rf = getStr("Device.X_CISCO_COM_MTA.LineTable.2.ResistiveFaults"); - $line2roh = getStr("Device.X_CISCO_COM_MTA.LineTable.2.ReceiverOffHook"); - $line2re = getStr("Device.X_CISCO_COM_MTA.LineTable.2.RingerEquivalency"); - $arConfig = {'line2hp':$line2hp, 'line2femf':$line2femf, 'line2rf':$line2rf, 'line2roh':$line2roh, 'line2re':$line2re}/*p2j-array*/; +else { + $line = null; + $action = null; + + /* Detect line number using explicit isset checks (ES5-compatible) */ + for ($i = 1; $i <= $LineTableNumberOfEntries; $i++) { + if (isset($_GET["get_status"+$i])) { + $line = $i; + $action = "get_status"; + break; + } else if (isset($_GET["start_diagnostics"+$i])) { + $line = $i; + $action = "start_diagnostics"; + break; + } + } + + if ($line !== null && $action !== null) { + + /* ===== GET STATUS ===== */ + if ($action == "get_status") { + + $linehook = getStr("Device.X_CISCO_COM_MTA.LineTable."+$line+".Status"); + sleep(2); + + $arConfig["line"+$line+"hook"] = $linehook; + } + + /* ===== START DIAGNOSTICS ===== */ + else if ($action == "start_diagnostics") { + + setStr( + "Device.X_CISCO_COM_MTA.LineTable."+$line+".TriggerDiagnostics", + "true", + true + ); + + LogStr(" : webui_event:MTA_line"+$line+"_diag"); + + sleep(15); + + $arConfig["line"+$line+"hp"] = getStr("Device.X_CISCO_COM_MTA.LineTable."+$line+".HazardousPotential"); + $arConfig["line"+$line+"femf"] = getStr("Device.X_CISCO_COM_MTA.LineTable."+$line+".ForeignEMF"); + $arConfig["line"+$line+"rf"] = getStr("Device.X_CISCO_COM_MTA.LineTable."+$line+".ResistiveFaults"); + $arConfig["line"+$line+"roh"] = getStr("Device.X_CISCO_COM_MTA.LineTable."+$line+".ReceiverOffHook"); + $arConfig["line"+$line+"re"] = getStr("Device.X_CISCO_COM_MTA.LineTable."+$line+".RingerEquivalency"); + } + } } header("Content-Type: application/json"); $jsConfig = json_encode($arConfig); diff --git a/source/Styles/xb3/jst/locale/global.js b/source/Styles/xb3/jst/locale/global.js index 77946af..755bfe1 100755 --- a/source/Styles/xb3/jst/locale/global.js +++ b/source/Styles/xb3/jst/locale/global.js @@ -643,22 +643,31 @@ $("#mocadiagmess17").text($.i18n("MoCA Network Diagram")); $("#refresh").prop("value", $.i18n('Refresh')); $("#mtalinhead").text($.i18n("Gateway > Connection > MTA > Line Diagnostics")); $("#mtalintip1").text($.i18n("Information related to the MTA Line Diagnostics.")); -$("#mtalinmess1").text($.i18n("MTA Line 1 Diagnostics")); $("[id^='mtalinmess2']").text($.i18n("Hazardous Potential:")); -$("#line1hp,#line1hp,#line1femf,#line1rf,#line1roh,#line1re,#line2hp,#line2femf,#line2rf,#line2roh,#line2re").text($.i18n("Not Started")); +$("[id^='line'][id$='hp'],[id^='line'][id$='femf'],[id^='line'][id$='rf'],[id^='line'][id$='roh'],[id^='line'][id$='re']").val($.i18n("Not Started")); $("[id^='mtalinmess3']").text($.i18n("Foreign EMF:")); $("[id^='mtalinmess4']").text($.i18n("Receiver Off Hook:")); $("[id^='mtalinmess5']").text($.i18n("Ringer Equivalency:")); -$("#start_diagnostics1,#start_diagnostics2").prop("value", $.i18n('Start Diagnostics')); -$("#mtalinmess6").text($.i18n("MTA Line 2 Diagnostics")); -$("#mtalinmess6").text($.i18n("MTA Line 2 Diagnostics")); -$("#mtalinmess6").text($.i18n("MTA Line 2 Diagnostics")); -$("#mtalinmess6").text($.i18n("MTA Line 2 Diagnostics")); +$("[id^='start_diagnostics']").prop("value", $.i18n('Start Diagnostics')); +$("#mtalinediag1").text($.i18n("MTA Line 1 Diagnostics")); +$("#mtalinediag2").text($.i18n("MTA Line 2 Diagnostics")); +$("#mtalinediag3").text($.i18n("MTA Line 3 Diagnostics")); +$("#mtalinediag4").text($.i18n("MTA Line 4 Diagnostics")); +$("#mtalinediag5").text($.i18n("MTA Line 5 Diagnostics")); +$("#mtalinediag6").text($.i18n("MTA Line 6 Diagnostics")); +$("#mtalinediag7").text($.i18n("MTA Line 7 Diagnostics")); +$("#mtalinediag8").text($.i18n("MTA Line 8 Diagnostics")); $("#mtalinstathead").text($.i18n("Gateway > Connection > MTA > Line Status")); $("#mtalinstattip1").text($.i18n("Information related to the MTA Line Status.")); $("#mtalinstatmess1").text($.i18n("MTA Line Status")); $("#mtalinstatmess2").text($.i18n("Line 1 Status:")); $("#mtalinstatmess3").text($.i18n("Line 2 Status:")); +$("#mtalinstatmess4").text($.i18n("Line 3 Status:")); +$("#mtalinstatmess5").text($.i18n("Line 4 Status:")); +$("#mtalinstatmess6").text($.i18n("Line 5 Status:")); +$("#mtalinstatmess7").text($.i18n("Line 6 Status:")); +$("#mtalinstatmess8").text($.i18n("Line 7 Status:")); +$("#mtalinstatmess9").text($.i18n("Line 8 Status:")); $("#mtasiplogmess1").text($.i18n("MTA SIP Packet Log")); $("#mtasiploghead").text($.i18n("Gateway > Connection > MTA >SIP Packet Log")); $("#mtasiplogtip1").text($.i18n("Information related to the SIP Packet Log.")); diff --git a/source/Styles/xb3/jst/mta_Line_Diagnostics.jst b/source/Styles/xb3/jst/mta_Line_Diagnostics.jst index 4275e75..7ddf63c 100644 --- a/source/Styles/xb3/jst/mta_Line_Diagnostics.jst +++ b/source/Styles/xb3/jst/mta_Line_Diagnostics.jst @@ -32,129 +32,62 @@ $(document).ready(function() { gateway.page.init("Gateway > Connection > MTA > Line Diagnostics", "nav-mta-line-diagnostics"); - var token = ""; - $("#start_diagnostics1").click(function(){ - var isTest1 = true; - document.getElementById('line1hp').value = "InProgress"; - document.getElementById('line1femf').value = "InProgress"; - document.getElementById('line1rf').value = "InProgress"; - document.getElementById('line1roh').value = "InProgress"; - document.getElementById('line1re').value = "InProgress"; + + var voiceLines = ; + $("[id^='start_diagnostics']").on("click", function () { + var line = parseInt(this.id.replace("start_diagnostics", ""), 10); + + if (isNaN(line) || line < 1 || line > voiceLines) return; + + // Set all fields to InProgress + ["hp", "femf", "rf", "roh", "re"].forEach(function (item) { + document.getElementById("line" + line + item).value = "InProgress"; + }); + jProgress($.i18n("Check telephony line status, please wait..."), 60); + $.get( "actionHandler/ajaxSet_mta_Line_Diagnostics.jst", - {"get_status1":"true"}, - function(msg) - { + { ["get_status"+line]: "true" }, + function (msg) { jHide(); - if ("Off-Hook" == msg.line1hook){ + + if (msg["line"+line+"hook"] === "Off-Hook") { jConfirm( - $.i18n("Phone is Off-Hook, do you want to start the test anyway?") - ,$.i18n("Are you sure?") - , function(ret){ - if(ret){ - jProgress($.i18n("This may take several seconds."), 60); - $.get( - "actionHandler/ajaxSet_mta_Line_Diagnostics.jst", - {"start_diagnostics1":"true"}, - function(msg) - { - document.getElementById('line1hp').value = msg.line1hp; - document.getElementById('line1femf').value = msg.line1femf; - document.getElementById('line1rf').value = msg.line1rf; - document.getElementById('line1roh').value = msg.line1roh; - document.getElementById('line1re').value = msg.line1re; - jHide(); - }, - "json" - ); + $.i18n("Phone is Off-Hook, do you want to start the test anyway?"), + $.i18n("Are you sure?"), + function (ret) { + if (ret) { + startDiagnostics(line); + } } - }); - } - else{ - jProgress($.i18n("This may take several seconds..."), 60); - $.get( - "actionHandler/ajaxSet_mta_Line_Diagnostics.jst", - {"start_diagnostics1":"true"}, - function(msg) - { - document.getElementById('line1hp').value = msg.line1hp; - document.getElementById('line1femf').value = msg.line1femf; - document.getElementById('line1rf').value = msg.line1rf; - document.getElementById('line1roh').value = msg.line1roh; - document.getElementById('line1re').value = msg.line1re; - jHide(); - }, - "json" ); + } else { + startDiagnostics(line); } }, - "json" + "json" ); }); - $("#start_diagnostics2").click(function(){ - document.getElementById('line2hp').value = "InProgress"; - document.getElementById('line2femf').value = "InProgress"; - document.getElementById('line2rf').value = "InProgress"; - document.getElementById('line2roh').value = "InProgress"; - document.getElementById('line2re').value = "InProgress"; - jProgress($.i18n("Check telephony line status, please wait..."), 60); + + function startDiagnostics(line) { + jProgress($.i18n("This may take several seconds..."), 60); + $.get( "actionHandler/ajaxSet_mta_Line_Diagnostics.jst", - {"get_status2":"true"}, - function(msg) - { + { ["start_diagnostics"+line]: "true" }, + function (msg) { + ["hp", "femf", "rf", "roh", "re"].forEach(function (item) { + document.getElementById("line" + line + item).value = + msg["line" + line + item]; + }); jHide(); - if ("Off-Hook" == msg.line2hook){ - jConfirm( - $.i18n("Phone is Off-Hook, do you want to start the test anyway?") - , $.i18n("Are you sure?") - , function(ret){ - if(ret){ - jProgress($.i18n("This may take several seconds..."), 60); - $.get( - "actionHandler/ajaxSet_mta_Line_Diagnostics.jst", - {"start_diagnostics2":"true"}, - function(msg) - { - document.getElementById('line2hp').value = msg.line2hp; - document.getElementById('line2femf').value = msg.line2femf; - document.getElementById('line2rf').value = msg.line2rf; - document.getElementById('line2roh').value = msg.line2roh; - document.getElementById('line2re').value = msg.line2re; - jHide(); - }, - "json" - ); - } - }); - } - else{ - jProgress($.i18n("This may take several seconds..."), 60); - $.get( - "actionHandler/ajaxSet_mta_Line_Diagnostics.jst", - {"start_diagnostics2":"true"}, - function(msg) - { - document.getElementById('line2hp').value = msg.line2hp; - document.getElementById('line2femf').value = msg.line2femf; - document.getElementById('line2rf').value = msg.line2rf; - document.getElementById('line2roh').value = msg.line2roh; - document.getElementById('line2re').value = msg.line2re; - jHide(); - }, - "json" - ); - } }, - "json" + "json" ); - }); + } }); -

Router > Connection > MTA > Line Diagnostics

@@ -164,75 +97,43 @@ $(document).ready(function() {

Information related to the MTA Line Diagnostics.

+
- -

MTA Line 1 Diagnostics

+ +

MTA Line Diagnostics

-Hazardous Potential: - - -
-
-
Foreign EMF:
- - -
-
-
Resistive Faults:
- - -
-
-
Receiver Off Hook:
- - -
-
-
Ringer Equivalency:
- - -
-
- -
- -
- 1) { ?> -
- - - -

MTA Line 2 Diagnostics

-
-
Hazardous Potential:
- - + Hazardous Potential: + +
Foreign EMF:
- - + +
Resistive Faults:
- - + +
Receiver Off Hook:
- - + +
Ringer Equivalency:
- - + +
- +
diff --git a/source/Styles/xb3/jst/mta_Line_Status.jst b/source/Styles/xb3/jst/mta_Line_Status.jst index 07697b9..88d4525 100644 --- a/source/Styles/xb3/jst/mta_Line_Status.jst +++ b/source/Styles/xb3/jst/mta_Line_Status.jst @@ -33,9 +33,6 @@ $(document).ready(function() { }); -

Router > Connection > MTA > Line Status

@@ -47,16 +44,17 @@ $(document).ready(function() {

MTA Line Status

-
- Line 1 Status: - -
- 1) { ?> -
- Line 2 Status: - -
- + '); + echo('Line ' + $i + ' Status:'); + echo('' + $status + ''); + echo('
'); + } + ?>
diff --git a/source/Styles/xb3/jst/qos.jst b/source/Styles/xb3/jst/qos.jst index 05d9684..3728f21 100644 --- a/source/Styles/xb3/jst/qos.jst +++ b/source/Styles/xb3/jst/qos.jst @@ -140,20 +140,18 @@ function set_config(jsConfig) CallP State Loop Current - - 1 - - - - - 1) { ?> - - 2 - - - - - + '); + echo('' + $i + ''); + echo(''+ getStr("Device.X_CISCO_COM_MTA.LineTable."+$i+".CALLP.LCState") +''); + echo(''+ getStr("Device.X_CISCO_COM_MTA.LineTable."+$i+".CALLP.CallPState") +''); + echo(''+ getStr("Device.X_CISCO_COM_MTA.LineTable."+$i+".CALLP.LoopCurrent") +''); + echo(''); + } + ?>
diff --git a/source/Styles/xb3/jst/voice_quality_metrics.jst b/source/Styles/xb3/jst/voice_quality_metrics.jst index a7790f5..0e687ae 100644 --- a/source/Styles/xb3/jst/voice_quality_metrics.jst +++ b/source/Styles/xb3/jst/voice_quality_metrics.jst @@ -30,10 +30,10 @@ $call = "table"; $action = "display"; if (isset($_GET['line'])) { - //line only 1, 2 are allowed + //line must be a positive integer within LineTableNumberOfEntries //call only 1, 50 are allowed //action only display, clear_line, clear_all are allowed - if (($_GET['line'] == '1' || $_GET['line'] == '2') && + if ((isset($_GET['line']) && preg_match('/^[1-9]\d*$/', $_GET['line']) && Number($_GET['line']) <= Number(getStr("Device.X_CISCO_COM_MTA.LineTableNumberOfEntries"))) && ((preg_match('/^(50|[1234][0-9]|[1-9])$/', $_GET['call'])) || $_GET['call'] == 'all' || $_GET['call'] == 'table') && ($_GET['action'] == 'display' || $_GET['action'] == 'clear_line' || $_GET['action'] == 'clear_all') ){ @@ -102,9 +102,6 @@ $(document).ready(function() { }); }); -

Router > Connection > Voice Quality Metrics

@@ -121,9 +118,10 @@ $(document).ready(function() { Call Number @@ -147,8 +145,10 @@ $(document).ready(function() { - - +
There is no data to display for Line '+$m+'.
'); + ?>