@@ -820,187 +820,187 @@ function deviceListenButtonClicked(form)
820820
821821
822822
823- //var displayUpdateInterval = 5000; // five seconds
824- var displayUpdateInterval = 0 ; // fast updates
825- var currentInterval = 0 ;
826- var pollingInterval = 250 ; // four times per second
823+ //var displayUpdateInterval = 5000; // five seconds
824+ var displayUpdateInterval = 0 ; // fast updates
825+ var currentInterval = 0 ;
826+ var pollingInterval = 250 ; // four times per second
827827
828- function periodicUpdate ( )
828+ function periodicUpdate ( )
829+ {
830+ //console.log("periodicUpdate");
831+
832+ if ( currentInterval >= displayUpdateInterval )
829833 {
830- //console.log("periodicUpdate");
831-
832- if ( currentInterval >= displayUpdateInterval )
833- {
834- // request to HTTP server to get radio status
835- var getUrl = window . location ;
836- var baseUrl = getUrl . protocol + "//" + getUrl . host + "/" ;
837- var nowPlayingStatusUrl = baseUrl + "nowplayingstatus.html" ;
834+ // request to HTTP server to get radio status
835+ var getUrl = window . location ;
836+ var baseUrl = getUrl . protocol + "//" + getUrl . host + "/" ;
837+ var nowPlayingStatusUrl = baseUrl + "nowplayingstatus.html" ;
838838
839- var xhttp = new XMLHttpRequest ( ) ;
840- xhttp . onreadystatechange = function ( ) {
841- if ( this . readyState == 4 && this . status == 200 ) {
842- // response received ok
843- updateStatusDisplay ( xhttp . response ) ;
844- }
845- } ;
846- xhttp . open ( "POST" , nowPlayingStatusUrl , true ) ;
847- xhttp . send ( ) ;
848- }
849-
850- currentInterval = currentInterval + pollingInterval ;
851-
852- if ( currentInterval >= displayUpdateInterval )
853- {
854- currentInterval = 0 ;
839+ var xhttp = new XMLHttpRequest ( ) ;
840+ xhttp . onreadystatechange = function ( ) {
841+ if ( this . readyState == 4 && this . status == 200 ) {
842+ // response received ok
843+ updateStatusDisplay ( xhttp . response ) ;
855844 }
845+ } ;
846+ xhttp . open ( "POST" , nowPlayingStatusUrl , true ) ;
847+ xhttp . send ( ) ;
856848 }
857-
858- // Printing description of statusData:
859- // {"modulation":"fm","oversampling":4,"signal_level":19,"options":"","frequency_scan_interval":0,"tuner_gain":49.7,"station_name":"KUAR-NPR Little Rock 89.1","atan_math":"std","stream_source":"icecast","sampling_mode":0,"sample_rate":85000,"frequency_mode":0,"squelch_level":0,"id":4,"tuner_agc":1,"frequency_scan_end":0,"fir_size":9,"audio_output_filter":"vol 1","audio_output":"icecast","frequency":89100000}
860- function updateStatusDisplay ( statusData )
849+
850+ currentInterval = currentInterval + pollingInterval ;
851+
852+ if ( currentInterval >= displayUpdateInterval )
861853 {
862- var statusObj = JSON . parse ( statusData ) ;
863-
864- var rtlsdr_task_mode = statusObj . rtlsdr_task_mode ;
865-
866- var audio_output = statusObj . audio_output ;
867- var audio_output_filter = statusObj . audio_output_filter ;
868- var atan_math = statusObj . atan_math ;
869- var fir_size = statusObj . fir_size ;
870- var frequency = statusObj . frequency ;
871- var frequency_mode = statusObj . frequency_mode ;
872- var frequency_scan_end = statusObj . frequency_scan_end ;
873- var frequency_scan_interval = statusObj . frequency_scan_interval ;
874- var modulation = statusObj . modulation ;
875- var options = statusObj . options ;
876- var oversampling = statusObj . oversampling ;
877- var sample_rate = statusObj . sample_rate ;
878- var sampling_mode = statusObj . sampling_mode ;
879- var short_frequency = statusObj . short_frequency ;
880- var signal_level = statusObj . signal_level ;
881- var squelch_level = statusObj . squelch_level ;
882- var station_name = statusObj . station_name ;
883- var stream_source = statusObj . stream_source ;
884- var tuner_agc = statusObj . tuner_agc ;
885- var tuner_gain = statusObj . tuner_gain ;
886-
887- if ( rtlsdr_task_mode == "frequency" )
888- {
889- var nowPlayingName = document . getElementById ( "now-playing-name" ) ;
890- if ( nowPlayingName != null )
891- {
892- nowPlayingName . innerHTML = station_name ;
893- }
894- }
854+ currentInterval = 0 ;
855+ }
856+ }
895857
896- if ( rtlsdr_task_mode == "scan" )
858+ // Printing description of statusData:
859+ // {"modulation":"fm","oversampling":4,"signal_level":19,"options":"","frequency_scan_interval":0,"tuner_gain":49.7,"station_name":"KUAR-NPR Little Rock 89.1","atan_math":"std","stream_source":"icecast","sampling_mode":0,"sample_rate":85000,"frequency_mode":0,"squelch_level":0,"id":4,"tuner_agc":1,"frequency_scan_end":0,"fir_size":9,"audio_output_filter":"vol 1","audio_output":"icecast","frequency":89100000}
860+ function updateStatusDisplay ( statusData )
861+ {
862+ var statusObj = JSON . parse ( statusData ) ;
863+
864+ var rtlsdr_task_mode = statusObj . rtlsdr_task_mode ;
865+
866+ var audio_output = statusObj . audio_output ;
867+ var audio_output_filter = statusObj . audio_output_filter ;
868+ var atan_math = statusObj . atan_math ;
869+ var fir_size = statusObj . fir_size ;
870+ var frequency = statusObj . frequency ;
871+ var frequency_mode = statusObj . frequency_mode ;
872+ var frequency_scan_end = statusObj . frequency_scan_end ;
873+ var frequency_scan_interval = statusObj . frequency_scan_interval ;
874+ var modulation = statusObj . modulation ;
875+ var options = statusObj . options ;
876+ var oversampling = statusObj . oversampling ;
877+ var sample_rate = statusObj . sample_rate ;
878+ var sampling_mode = statusObj . sampling_mode ;
879+ var short_frequency = statusObj . short_frequency ;
880+ var signal_level = statusObj . signal_level ;
881+ var squelch_level = statusObj . squelch_level ;
882+ var station_name = statusObj . station_name ;
883+ var stream_source = statusObj . stream_source ;
884+ var tuner_agc = statusObj . tuner_agc ;
885+ var tuner_gain = statusObj . tuner_gain ;
886+
887+ if ( rtlsdr_task_mode == "frequency" )
888+ {
889+ var nowPlayingName = document . getElementById ( "now-playing-name" ) ;
890+ if ( nowPlayingName != null )
897891 {
898- audio_output = statusObj . scan_audio_output ;
899- audio_output_filter = statusObj . scan_audio_output_filter ;
900- atan_math = statusObj . scan_atan_math ;
901- fir_size = statusObj . scan_fir_size ;
902- frequency_mode = statusObj . scan_frequency_mode ;
903- modulation = statusObj . scan_modulation ;
904- options = statusObj . scan_options ;
905- oversampling = statusObj . scan_oversampling ;
906- sample_rate = statusObj . scan_sample_rate ;
907- sampling_mode = statusObj . scan_sampling_mode ;
908- squelch_level = statusObj . scan_squelch_level ;
909- stream_source = statusObj . scan_stream_source ;
910- tuner_agc = statusObj . scan_tuner_agc ;
911- tuner_gain = statusObj . scan_tuner_gain ;
892+ nowPlayingName . innerHTML = station_name ;
912893 }
913-
914- var statusHtml = "<br><br>" ;
915-
916- if ( rtlsdr_task_mode == "scan" )
917- {
918- statusHtml += "<span id='now-playing-details' style='overflow-x: scroll; white-space: nowrap;'>" ;
894+ }
919895
920- statusHtml += "name: " ;
921- statusHtml += station_name ;
922- statusHtml += "<br>" ;
923-
924- statusHtml += "</span>"
925- }
926-
927- statusHtml += "frequency: " ;
928- statusHtml += short_frequency ;
929- statusHtml += "<br>" ;
930- statusHtml += "signal level: " ;
931- statusHtml += signal_level ;
932- statusHtml += "<br>" ;
933-
934- if ( rtlsdr_task_mode == "scan" )
935- {
936- statusHtml += "<br><br>CATEGORY SCANNER SETTINGS: <br>" ;
937- }
938-
939- statusHtml += "squelch level: " ;
940- statusHtml += squelch_level ;
941- statusHtml += "<br>" ;
942- statusHtml += "modulation: " ;
943- statusHtml += modulation ;
944- statusHtml += "<br>" ;
945- statusHtml += "sample rate: " ;
946- statusHtml += sample_rate ;
947- statusHtml += "<br>" ;
948- statusHtml += "sampling mode: " ;
949- statusHtml += sampling_mode ;
950- statusHtml += "<br>" ;
951- statusHtml += "oversampling: " ;
952- statusHtml += oversampling ;
953- statusHtml += "<br>" ;
954- statusHtml += "tuner gain: " ;
955- statusHtml += tuner_gain ;
956- statusHtml += "<br>" ;
957- statusHtml += "tuner agc: " ;
958- statusHtml += tuner_agc ;
959- statusHtml += "<br>" ;
960- statusHtml += "rtl-sdr options: pad " ;
961- statusHtml += options ;
962- statusHtml += "<br>" ;
963- statusHtml += "fir size: " ;
964- statusHtml += fir_size ;
965- statusHtml += "<br>" ;
966- statusHtml += "atan math: " ;
967- statusHtml += atan_math ;
968- statusHtml += "<br>" ;
969- statusHtml += "audio output filter: rate 48000 " ;
970- statusHtml += audio_output_filter ;
971- statusHtml += "<br>" ;
972- statusHtml += "audio output: " ;
973- statusHtml += audio_output ;
974- statusHtml += "<br>" ;
975- statusHtml += "stream source: " ;
976- statusHtml += stream_source ;
977- statusHtml += "<br>" ;
978-
979- var nowPlayingDetails = document . getElementById ( "now-playing-details" ) ;
980- if ( nowPlayingDetails != null )
981- {
982- nowPlayingDetails . innerHTML = statusHtml ;
983- }
984-
985- window . top . nowPlayingTitle = station_name ;
896+ if ( rtlsdr_task_mode == "scan" )
897+ {
898+ audio_output = statusObj . scan_audio_output ;
899+ audio_output_filter = statusObj . scan_audio_output_filter ;
900+ atan_math = statusObj . scan_atan_math ;
901+ fir_size = statusObj . scan_fir_size ;
902+ frequency_mode = statusObj . scan_frequency_mode ;
903+ modulation = statusObj . scan_modulation ;
904+ options = statusObj . scan_options ;
905+ oversampling = statusObj . scan_oversampling ;
906+ sample_rate = statusObj . scan_sample_rate ;
907+ sampling_mode = statusObj . scan_sampling_mode ;
908+ squelch_level = statusObj . scan_squelch_level ;
909+ stream_source = statusObj . scan_stream_source ;
910+ tuner_agc = statusObj . scan_tuner_agc ;
911+ tuner_gain = statusObj . scan_tuner_gain ;
912+ }
913+
914+ var statusHtml = "<br><br>" ;
915+
916+ if ( rtlsdr_task_mode == "scan" )
917+ {
918+ statusHtml += "<span id='now-playing-details' style='overflow-x: scroll; white-space: nowrap;'>" ;
986919
987- var nowPlayingNavBarLink = window . top . document . getElementById ( "nowPlayingNavBarLink" ) ;
988- nowPlayingNavBarLink . innerText = "NOW PLAYING: " + station_name ;
920+ statusHtml += "name: " ;
921+ statusHtml += station_name ;
922+ statusHtml += "<br>" ;
923+
924+ statusHtml += "</span>"
925+ }
926+
927+ statusHtml += "frequency: " ;
928+ statusHtml += short_frequency ;
929+ statusHtml += "<br>" ;
930+ statusHtml += "signal level: " ;
931+ statusHtml += signal_level ;
932+ statusHtml += "<br>" ;
933+
934+ if ( rtlsdr_task_mode == "scan" )
935+ {
936+ statusHtml += "<br><br>CATEGORY SCANNER SETTINGS: <br>" ;
937+ }
938+
939+ statusHtml += "squelch level: " ;
940+ statusHtml += squelch_level ;
941+ statusHtml += "<br>" ;
942+ statusHtml += "modulation: " ;
943+ statusHtml += modulation ;
944+ statusHtml += "<br>" ;
945+ statusHtml += "sample rate: " ;
946+ statusHtml += sample_rate ;
947+ statusHtml += "<br>" ;
948+ statusHtml += "sampling mode: " ;
949+ statusHtml += sampling_mode ;
950+ statusHtml += "<br>" ;
951+ statusHtml += "oversampling: " ;
952+ statusHtml += oversampling ;
953+ statusHtml += "<br>" ;
954+ statusHtml += "tuner gain: " ;
955+ statusHtml += tuner_gain ;
956+ statusHtml += "<br>" ;
957+ statusHtml += "tuner agc: " ;
958+ statusHtml += tuner_agc ;
959+ statusHtml += "<br>" ;
960+ statusHtml += "rtl-sdr options: pad " ;
961+ statusHtml += options ;
962+ statusHtml += "<br>" ;
963+ statusHtml += "fir size: " ;
964+ statusHtml += fir_size ;
965+ statusHtml += "<br>" ;
966+ statusHtml += "atan math: " ;
967+ statusHtml += atan_math ;
968+ statusHtml += "<br>" ;
969+ statusHtml += "audio output filter: rate 48000 " ;
970+ statusHtml += audio_output_filter ;
971+ statusHtml += "<br>" ;
972+ statusHtml += "audio output: " ;
973+ statusHtml += audio_output ;
974+ statusHtml += "<br>" ;
975+ statusHtml += "stream source: " ;
976+ statusHtml += stream_source ;
977+ statusHtml += "<br>" ;
978+
979+ var nowPlayingDetails = document . getElementById ( "now-playing-details" ) ;
980+ if ( nowPlayingDetails != null )
981+ {
982+ nowPlayingDetails . innerHTML = statusHtml ;
989983 }
984+
985+ window . top . nowPlayingTitle = station_name ;
990986
991- var intervalID = setInterval ( function ( ) { periodicUpdate ( ) ; } , 20000 ) ; // for Now Playing periodic updates using setInterval()
987+ var nowPlayingNavBarLink = window . top . document . getElementById ( "nowPlayingNavBarLink" ) ;
988+ nowPlayingNavBarLink . innerText = "NOW PLAYING: " + station_name ;
989+ }
992990
993- function startNowPlayingUpdates ( )
994- {
995- clearInterval ( intervalID ) ;
991+ var intervalID = setInterval ( function ( ) { periodicUpdate ( ) ; } , 20000 ) ; // for Now Playing periodic updates using setInterval()
996992
997- intervalID = setInterval ( function ( ) { periodicUpdate ( ) ; } , pollingInterval ) ; // fast updates
998- }
993+ function startNowPlayingUpdates ( )
994+ {
995+ clearInterval ( intervalID ) ;
999996
997+ intervalID = setInterval ( function ( ) { periodicUpdate ( ) ; } , pollingInterval ) ; // fast updates
998+ }
1000999
1001- function stopNowPlayingUpdates ( )
1002- {
1003- clearInterval ( intervalID ) ;
10041000
1005- intervalID = setInterval ( function ( ) { periodicUpdate ( ) ; } , 20000 ) ; // update every 20 seconds
1006- }
1001+ function stopNowPlayingUpdates ( )
1002+ {
1003+ clearInterval ( intervalID ) ;
1004+
1005+ intervalID = setInterval ( function ( ) { periodicUpdate ( ) ; } , 20000 ) ; // update every 20 seconds
1006+ }
0 commit comments