From bef71b246ab4b7ca3e318fadd141651c69370014 Mon Sep 17 00:00:00 2001 From: dg9vh Date: Fri, 7 Oct 2016 19:24:26 +0000 Subject: [PATCH] begining code optimization, ajax-reload of lh-list and localtx, speeding up refresh - no reload of whole page, only reload of subtables --- ajax.php | 37 ++++++++++++++++++++++++++ include/functions.php | 16 +++++++++--- include/init.php | 10 +++---- include/lh_ajax.php | 33 +++++++++++++++++++++++ include/localtx.php | 54 +++++++++++++++++++------------------- include/localtx_ajax.php | 33 +++++++++++++++++++++++ index.php | 56 ++++++++++++++++++++++++++++++++-------- txinfo.php | 16 ++++++++---- version.php | 2 +- 9 files changed, 205 insertions(+), 52 deletions(-) create mode 100644 ajax.php create mode 100644 include/lh_ajax.php create mode 100644 include/localtx_ajax.php diff --git a/ajax.php b/ajax.php new file mode 100644 index 0000000..6b41af9 --- /dev/null +++ b/ajax.php @@ -0,0 +1,37 @@ +".str_replace("0","Ø",$listElem[2]).""; + } else { + $listElem[2] = "".$listElem[2].""; + } + array_push($lastHeard, $listElem); + } +} + echo '{"data": '.json_encode($lastHeard)."}"; +} + +?> \ No newline at end of file diff --git a/include/functions.php b/include/functions.php index ebf2a34..8bb86a4 100644 --- a/include/functions.php +++ b/include/functions.php @@ -277,7 +277,8 @@ function getHeardList($logLines, $onlyLast) { // Callsign or ID should be less than 11 chars long, otherwise it could be errorneous if ( strlen($callsign) < 11 ) { - array_push($heardList, array($timestamp, $mode, $callsign, $id, $target, $source, $duration, $loss, $ber)); + $name = "";//getName($callsign); + array_push($heardList, array($timestamp, $mode, $callsign, $name, $id, $target, $source, $duration, $loss, $ber)); $duration = ""; $loss =""; $ber = ""; @@ -297,8 +298,17 @@ function getLastHeard($logLines, $onlyLast) { $counter = 0; foreach ($heardList as $listElem) { if ( ($listElem[1] == "D-Star") || ($listElem[1] == "YSF") || ($listElem[1] == "P25") || (startsWith($listElem[1], "DMR")) ) { - if(!(array_search($listElem[2]."#".$listElem[1].$listElem[3], $heardCalls) > -1)) { - array_push($heardCalls, $listElem[2]."#".$listElem[1].$listElem[3]); + if(!(array_search($listElem[2]."#".$listElem[1].$listElem[4], $heardCalls) > -1)) { + array_push($heardCalls, $listElem[2]."#".$listElem[1].$listElem[4]); + + $listElem[3] = getName($listElem[2]); + + if (constant("SHOWQRZ") && $listElem[2] !== "??????????" && !is_numeric($listElem[2])) { + $listElem[2] = "".str_replace("0","Ø",$listElem[2]).""; + } else { + $listElem[2] = "".$listElem[2].""; + } + array_push($lastHeard, $listElem); $counter++; } diff --git a/include/init.php b/include/init.php index e5d1718..a3aec85 100644 --- a/include/init.php +++ b/include/init.php @@ -2,14 +2,14 @@ //Some basic inits $mmdvmconfigs = getMMDVMConfig(); $logLinesMMDVM = getMMDVMLog(); +$_SESSION['logLinesMMDVM'] = $logLinesMMDVM; $reverseLogLinesMMDVM = $logLinesMMDVM; array_multisort($reverseLogLinesMMDVM,SORT_DESC); +$_SESSION['reverseLogLinesMMDVM'] = $reverseLogLinesMMDVM; $lastHeard = getLastHeard($reverseLogLinesMMDVM, FALSE); +$_SESSION['lastHeard'] = $lastHeard; + if (defined("ENABLEYSFGATEWAY")) { - $YSFGatewayconfigs = getYSFGatewayConfig(); - $logLinesYSFGateway = getYSFGatewayLog(); - $reverseLogLinesYSFGateway = $logLinesYSFGateway; - array_multisort($reverseLogLinesYSFGateway,SORT_DESC); - $activeYSFReflectors = getActiveYSFReflectors($reverseLogLinesYSFGateway); + $activeYSFReflectors = getActiveYSFReflectors(); } ?> diff --git a/include/lh_ajax.php b/include/lh_ajax.php new file mode 100644 index 0000000..df63327 --- /dev/null +++ b/include/lh_ajax.php @@ -0,0 +1,33 @@ + +
+ +
Last Heard List of today's callsigns.
+ +
+ + + + + + + + + + + + + + + + + +
Time (UTC)ModeCallsignNameDSTAR-IDTargetSourceDur (s)LossBER
+
+
+ diff --git a/include/localtx.php b/include/localtx.php index 04d71a3..5fa49f2 100644 --- a/include/localtx.php +++ b/include/localtx.php @@ -1,6 +1,6 @@ @@ -33,34 +33,34 @@ $localTXList = getHeardList($reverseLogLinesMMDVM, FALSE); "; - echo"$listElem[0]"; - echo"$listElem[1]"; - if (constant("SHOWQRZ") && $listElem[2] !== "??????????" && !is_numeric($listElem[2])) { - echo"".str_replace("0","Ø",$listElem[2]).""; - } else { - echo"".$listElem[2].""; - } - if (defined("ENABLEXTDLOOKUP")) { - echo "".getName($listElem[2]).""; - } - echo"$listElem[3]"; - echo"$listElem[4]"; - echo"$listElem[5]"; - if ($listElem[6] == null) { - echo'in TX'; - } else if ($listElem[6] == "SMS") { - echo'sending or receiving SMS'; - } else { - echo"$listElem[6]"; - echo"$listElem[7]"; - echo"$listElem[8]"; - } - echo"\n"; + $listElem = $localTXList[$i]; + if ($listElem[6] == "RF" && ($listElem[1]=="D-Star" || startsWith($listElem[1], "DMR") || $listElem[1]=="YSF" || $listElem[1]=="P25")) { + echo""; + echo"$listElem[0]"; + echo"$listElem[1]"; + if (constant("SHOWQRZ") && $listElem[2] !== "??????????" && !is_numeric($listElem[2])) { + echo"".str_replace("0","Ø",$listElem[2]).""; + } else { + echo"".$listElem[2].""; } + if (defined("ENABLEXTDLOOKUP")) { + echo "$listElem[3]"; + } + echo"$listElem[4]"; + echo"$listElem[5]"; + echo"$listElem[6]"; + if ($listElem[6] == null) { + echo'in TX'; + } else if ($listElem[7] == "SMS") { + echo'sending or receiving SMS'; + } else { + echo"$listElem[7]"; + echo"$listElem[8]"; + echo"$listElem[9]"; + } + echo"\n"; } +} ?> diff --git a/include/localtx_ajax.php b/include/localtx_ajax.php new file mode 100644 index 0000000..02cd1d5 --- /dev/null +++ b/include/localtx_ajax.php @@ -0,0 +1,33 @@ + +
+ +
Today's local transmissions
+ +
+ + + + + + + + + + + + + + + + + +
Time (UTC)ModeCallsignNameDSTAR-IDTargetSourceDur (s)LossBER
+
+
+ diff --git a/index.php b/index.php index 3c98509..6344e36 100644 --- a/index.php +++ b/index.php @@ -1,4 +1,5 @@ - - - @@ -74,8 +68,8 @@ include "include/sysinfo.php"; include "include/disk.php"; include "include/repeaterinfo.php"; include "include/modes.php"; -include "include/lh.php"; -include "include/localtx.php"; +include "include/lh_ajax.php"; +include "include/localtx_ajax.php"; if (defined("ENABLEYSFGATEWAY")) { include "include/ysfgatewayinfo.php"; } @@ -105,11 +99,51 @@ if (!isset($_GET['stoprefresh'])) { $(document).ready(function(){ var lastHeardT = $('#lastHeard').dataTable( { - "aaSorting": [[0,'desc']] + "aaSorting": [[0,'desc']], + "ajax": '/ajax.php?section=lastHeard', + "deferRender": true } ); + + +setInterval( function () { + lastHeardT.api().ajax.reload( ); +}, ); + + var localTxT = $('#localTx').dataTable( { - "aaSorting": [[0,'desc']] + "aaSorting": [[0,'desc']], + "ajax": '/ajax.php?section=localTx', + "deferRender": true } ); + + +setInterval( function () { + localTxT.api().ajax.reload( ); +}, ); + + var ysfGatewaysT = $('#ysfGateways').dataTable( { "aaSorting": [[0,'asc']] } ); diff --git a/txinfo.php b/txinfo.php index 86bd267..8ea0d7a 100644 --- a/txinfo.php +++ b/txinfo.php @@ -1,4 +1,5 @@ "; foreach ($lastHeard as $listElem) { echo ""; - if ($listElem[6] == null) { + if ($listElem[7] == null) { echo"$listElem[0]"; echo"$listElem[1]"; if (constant("SHOWQRZ") && $listElem[2] !== "??????????" && !is_numeric($listElem[2])) { @@ -20,21 +25,22 @@ foreach ($lastHeard as $listElem) { echo"
".$listElem[2].""; } if (defined("ENABLEXTDLOOKUP")) { - echo "".getName($listElem[2]).""; + //echo "".getName($listElem[2]).""; + echo "$listElem[3]"; } - echo"$listElem[3]"; echo"$listElem[4]"; + echo"$listElem[5]"; if ($listElem[5] == "RF"){ echo "RF"; }else{ - echo"$listElem[5]"; + echo"$listElem[6]"; } $UTC = new DateTimeZone("UTC"); $d1 = new DateTime($listElem[0], $UTC); $d2 = new DateTime('now', $UTC); $diff = $d2->getTimestamp() - $d1->getTimestamp(); echo"$diff s"; - } + } echo ""; } ?> diff --git a/version.php b/version.php index 284929d..32d38a0 100644 --- a/version.php +++ b/version.php @@ -1,3 +1,3 @@