Help - Java - CustomContent

Are you having problems with using or developing a plugin? Let me know here.
Post Reply
batrakiu
Posts: 11
Joined: Sat Oct 15, 2016 10:14 pm

Help - Java - CustomContent

Post by batrakiu » Tue Nov 29, 2016 2:51 am

Hi guys!

My java skills are none. :!:

I want to add to this code a return option of:
If Mlat is 'Yes' -> show 'Yes'
If Mlat is 'No' or 'null' -> show "receiverId"

Code: Select all

    VRS.renderPropertyHandlers[VRS.RenderProperty.Mlat] = new VRS.RenderPropertyHandler({
        property: VRS.RenderProperty.Mlat,
        surfaces: VRS.RenderSurface.List + VRS.RenderSurface.DetailBody + VRS.RenderSurface.InfoWindow,
        headingKey: 'ListMlat',
        labelKey: 'Mlat',
        sortableField: VRS.AircraftListSortableField.Mlat,
        hasChangedCallback: function (aircraft) { return aircraft.isMlat.chg; },
        contentCallback: function (aircraft) { return aircraft.formatIsMlat(); }
    });
If helps, the information of the Receiver Render:
property: VRS.RenderProperty.Receiver
hasChangedCallback: function (aircraft) { return aircraft.receiverId.chg; },
contentCallback: function (aircraft) { return aircraft.formatReceiver(); }

agw
Posts: 2249
Joined: Fri Feb 17, 2012 3:20 am

Re: Help - Java - CustomContent

Post by agw » Wed Dec 07, 2016 12:49 am

JavaScript ;) Despite the similar names Java and JavaScript are different languages.

If you copy and paste this to a file called "ChangeMlat.html":

Code: Select all

<script type="text/javascript">
    if(VRS && VRS.globalDispatch && VRS.serverConfig) {
        VRS.globalDispatch.hook(VRS.globalEvent.bootstrapCreated, function(bootStrap) {
            if(VRS.renderPropertyHandlers) {
                // Overwrite the standard MLAT renderer with a custom one.
                // THIS MIGHT NEED TO BE MODIFIED WHEN NEW VERSIONS OF VRS ARE RELEASED
                VRS.renderPropertyHandlers[VRS.RenderProperty.Mlat] = new VRS.RenderPropertyHandler({
                    property: VRS.RenderProperty.Mlat,
                    surfaces: VRS.RenderSurface.List + VRS.RenderSurface.DetailBody + VRS.RenderSurface.InfoWindow,
                    headingKey: 'ListMlat',
                    labelKey: 'Mlat',
                    sortableField: VRS.AircraftListSortableField.Receiver,
                    hasChangedCallback: function (aircraft) { return aircraft.isMlat.chg || aircraft.receiverId.chg; },
                    contentCallback: function (aircraft) { return aircraft.isMlat.val ? aircraft.formatIsMlat() : aircraft.formatReceiver(); }
                });
            }
        });
    }
</script>
Then download and install the custom content plugin and tell VRS to inject the file you've saved to the END of HEAD for address * (as in the address is just an asterisk - documentation on configuring the plugin can be found here: http://www.virtualradarserver.co.uk/Doc ... fault.aspx).

If you want to see the MLAT / Receiver status on the aircraft markers as well then change this line:

Code: Select all

surfaces: VRS.RenderSurface.List + VRS.RenderSurface.DetailBody + VRS.RenderSurface.InfoWindow,
to this:

Code: Select all

surfaces: VRS.RenderSurface.List + VRS.RenderSurface.DetailBody + VRS.RenderSurface.InfoWindow + VRS.RenderSurface.Marker,

batrakiu
Posts: 11
Joined: Sat Oct 15, 2016 10:14 pm

Re: Help - Java - CustomContent

Post by batrakiu » Wed Dec 07, 2016 11:38 pm

Thank you agw!
Sorry about the wrong spelling, you can guess my skill level. :D

I want this to the Mobile List, to compress all the information that I 'like' or think is 'useful on the go' in a narrow space as possible.

Image

"Created" also the 'Type&Callsign' and the 'Speed&Alt' (with sortableField:(...)CivOrMil).

I'm trying to understand it by reverse engineering, and you gave some more understanding/options now. Thanks!

Post Reply