Setup main element structure for JS, created main event listener

This commit is contained in:
Dan
2019-11-26 09:43:47 +00:00
parent 79c82499f2
commit 64e24ca9d6
2 changed files with 63 additions and 2 deletions

View File

@@ -4,7 +4,7 @@
</head>
<body onselectstart="return false;" ondragstart="return false;">
<div class="unit_frame" style="visibility: hidden;">
<div id="radarFrame" class="unit_frame" style="visibility: hidden;">
<!-- <div class="unit_frame"> -->
<div class="frame_border"></div>

View File

@@ -2,5 +2,66 @@
Wraith ARS 2X - v1.0.0
Created by WolfKnight
This JS file takes inspiration from RandomSean's RS9000 JS file, so
thanks to him!
-------------------------------------------------------------------------*/
-------------------------------------------------------------------------*/
// Setup the main const element structure, this way we can easily access elements without having the mess
// that was in the JS file for WraithRS
const elements =
{
radar: $( "radarFrame" ),
patrolSpeed: $( "patrolSpeed" ),
antennas: {
front: {
targetSpeed: $( "frontSpeed" ),
dirs: {
forward: $( "frontDirAway" ),
backward: $( "frontDirTowards" )
},
modes: {
same: $( "frontSame" ),
opp: $( "frontOpp" ),
xmit: $( "frontXmit" )
},
fast: {
speed: $( "frontFastSpeed" ),
fastLabel: $( "frontFastLabel" ),
lockLabel: $( "frontFastLockLabel" )
}
},
rear: {
targetSpeed: $( "rearSpeed" ),
dirs: {
forward: $( "rearDirTowards" ),
backward: $( "rearDirAway" )
},
modes: {
same: $( "rearSame" ),
opp: $( "rearOpp" ),
xmit: $( "rearXmit" )
},
fast: {
speed: $( "rearFastSpeed" ),
fastLabel: $( "rearFastLabel" ),
lockLabel: $( "rearFastLockLabel" )
}
}
}
}
// The main event listener, this is what the NUI messages sent by the LUA side arrive at, they are
// then handled properly via a switch/case that runs the relevant code
window.addEventListener( "message", function( event ) {
var item = event.data;
} );