Radar menu now opens and works properly

Settings configured in the menu also have an effect on the radar's operation, e.g. the antenna sensitivities effect the range.
This commit is contained in:
Dan
2019-12-01 16:56:20 +00:00
parent 227c25f340
commit 6877d61267
3 changed files with 195 additions and 54 deletions

View File

@@ -279,6 +279,26 @@ function radarPower( state )
state ? poweringUp() : clearEverything();
}
function menu( optionText, option )
{
clearEverything();
elements.antennas.front.targetSpeed.html( optionText[0] );
elements.antennas.front.fastSpeed.html( optionText[1] );
elements.patrolSpeed.html( option );
}
function settingUpdate( ants, fast )
{
for ( let ant in ants )
{
setAntennaXmit( ant, ants[ant].xmit );
setAntennaMode( ant, ants[ant].mode );
setAntennaFastMode( ant, fast );
}
}
// This function is used to send data back through to the LUA side
function sendData( name, data ) {
$.post( "http://" + resourceName + "/" + name, JSON.stringify( data ), function( datab ) {
@@ -290,10 +310,10 @@ function sendData( name, data ) {
// This runs when the JS file is loaded, loops through all of the remote buttons and assigns them an onclick function
elements.remote.find( "button" ).each( function( i, obj ) {
if ( $( this ).attr( "data-nuitype" ) && $( this ).attr( "data-value" ) ) {
if ( $( this ).attr( "data-nuitype" ) ) {
$( this ).click( function() {
let type = $( this ).data( "nuitype" );
let value = $( this ).data( "value" );
let value = $( this ).attr( "data-value" ) ? $( this ).data( "value" ) : null;
let mode = $( this ).attr( "data-mode" ) ? $( this ).data( "mode" ) : null;
sendData( type, { value, mode } );
@@ -339,6 +359,12 @@ window.addEventListener( "message", function( event ) {
case "antennaMode":
setAntennaMode( item.ant, item.mode );
break;
case "menu":
menu( item.text, item.option );
break;
case "settingUpdate":
settingUpdate( item.antennaData, item.fast );
break;
default:
break;
}