Manufacturer as squadron logo source in Custom Content Plugin?

Are you having problems with using or developing a plugin? Let me know here.
OhhNeal
Posts: 17
Joined: Sat Aug 22, 2015 3:38 am

Manufacturer as squadron logo source in Custom Content Plugin?

Post by OhhNeal » Sat Aug 22, 2015 4:08 am

Hi ,

First of all thanks for a wonderfull program. I'm not sure if this should be in the Plugins sub-forum or the Feature Suggestions.

I've been using it for a long time now but since a short time I've been using Active Display. As AD populates the manufacturer field with squadron information, I would like to use that info to display the squadron logo's instead of the ie. the RCH logo. Just as it is possible with the aircraftAllowRegistrationFlagOverride to show reg-code named logos and which I've been using for quite some time now. Is that a posibility within the customcontent at the moment or a work around that does not involve changing all the manufacturing fields to the operator field?

Kind regards,
Neal

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

Re: Manufacturer as squadron logo source in Custom Content Plugin?

Post by agw » Sun Aug 23, 2015 7:26 pm

It depends on what exactly they're putting into the manufacturer field. You can use the custom content plugin to add your own render items to the site (i.e. the fields that you see in the aircraft list and aircraft detail panels) and if you wanted to you could add a render item that takes the content of the manufacturer field and uses that to form a URL for an image on the server.

However, I don't think the release version sends the manufacturer to the web site. I've added it for the next release, it's in the current previews if you want to give that a try and see the squadron coming out on the site, albeit described as the manufacturer. Once the next version is released remind me by posting to this thread, preferably with an example of what ADLite puts into the manufacturer field :), and I'll see what I can do about a script for it.

OhhNeal
Posts: 17
Joined: Sat Aug 22, 2015 3:38 am

Re: Manufacturer as squadron logo source in Custom Content Plugin?

Post by OhhNeal » Mon Aug 24, 2015 2:09 am

Hi agw,

Thanks for the reply. I already tried the preview but I returned to the releae version as it wouldn't save the polarplot for me. Might have been because I copied over the release version, don't know exactly :oops: . As I'm working offshore at the moment I get way more range than at home so Love the new sized airplane icons though :o

GAS uses the Manufacturing field in basesation.sqb for what the call "Sub-Operator" in ActiveDisplay. That might be a squadron or a long wet lease/contract airlines.

Examples are:
Hex Reg Type Icao Operator Icao op. Sub op.
AE2FAF 08-8203 Boeing C17A Globemaster III C17 United States Air Force RCH 60AMW
43C04E ZZ175 Boeing C17A Globemaster III C17 Royal Air Force RRR 99SQN
3C4DC1 D-ACNA Canadair CRJ900NG Regional Jet CRJ9 Eurowings EWG DLH

As for normal Icao codes for the suboperators it will use the "normal" logos and for the Squadron/wings, I've Mustang51's military logos with most of them following the same naming convention as the sub operators used by GAS. AD uses all of them in the basestation\OperatorFlags directory so once in a while when you find a new logo it might show a sillhouette. But so far it works well.

In AD you can setup the logos to be displayed in whatever order you want. I have mine setup as 1:Registration 2:Sub operator 3:Operator/type and 4:Operator With the last as an example, if I would have a logo for D-ACNA it would display that. If there is no bmp with that name it would look for a bmp named DLH (which I do have) if it couldn't find one it would look for a file called EWGCRJ9 and the last posibilty is that it would show EWG.bmp or a blank if none are available.

So I'll have to read up on scripting during the long worknights.

All I'm doing now is wait for the weekend to end, so I'll see some more military flights in the skies :shock:

Regards,
Neal

OhhNeal
Posts: 17
Joined: Sat Aug 22, 2015 3:38 am

Re: Manufacturer as squadron logo source in Custom Content Plugin?

Post by OhhNeal » Thu Sep 10, 2015 7:27 pm

Hi Andrew,

I see the new version is live, and thanks for that one. Like I said before those new icons based on class are perfect.

Hope you have time now to look into scripting to get the manufacturer in to display the squadron logo. If you need more explanation on how GAS uses the manufacturing field please let me know.

Regards,
Neal

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

Re: Manufacturer as squadron logo source in Custom Content Plugin?

Post by agw » Sun Sep 13, 2015 4:54 pm

So, to get this straight in my head - the manufacturer field in those examples would have been (in order):

60AMW
99SQN
DLH

and you want the site to use Manufacturer, and then if there isn't a BMP for that then use OperatorFlagCode? So for those examples it would try to use, in order:

60AMW.BMP, then RCH.BMP
99SQN.BMP then RRR.BMP
DLH.BMP then EWG.BMP

If so then that should be doable, I think.

If I've got hold of the wrong end of the stick then let me know :)

OhhNeal
Posts: 17
Joined: Sat Aug 22, 2015 3:38 am

Re: Manufacturer as squadron logo source in Custom Content Plugin?

Post by OhhNeal » Mon Sep 14, 2015 1:23 pm

Andrew,

You are holding the stick at the right end, with both hands :lol:

If this could be done, I'll be a happy very happy :D camper.

Thanks in advance,
Neal

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

Re: Manufacturer as squadron logo source in Custom Content Plugin?

Post by agw » Tue Sep 15, 2015 12:57 am

OK, I think this should do it - I've stepped through it with Chrome's debugger so it's broadly working, I just don't have anything meaningful in manufacturer so I can't tell for sure :)

You can follow the instructions at the start of this page to see how to set up the custom content plugin to serve the JavaScript:

http://www.virtualradarserver.co.uk/Doc ... tings.aspx

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 operator flag renderer with a custom one.
                // THIS MIGHT NEED TO BE MODIFIED WHEN NEW VERSIONS OF VRS ARE RELEASED
                VRS.renderPropertyHandlers[VRS.RenderProperty.OperatorFlag] = new VRS.RenderPropertyHandler({
                    property:               VRS.RenderProperty.OperatorFlag,
                    surfaces:               VRS.RenderSurface.List + VRS.RenderSurface.DetailHead + VRS.RenderSurface.InfoWindow,
                    headingKey:             'ListOperatorFlag',
                    labelKey:               'OperatorFlag',
                    sortableField:          VRS.AircraftListSortableField.OperatorIcao,
                    headingAlignment:       VRS.Alignment.Centre,
                    suppressLabelCallback:  function() { return true; },
                    fixedWidth:             function() { return VRS.globalOptions.aircraftOperatorFlagSize.width.toString() + 'px'; },
                    // Changed the following line to redraw the flag if the manufacturer changes...
                    hasChangedCallback:     function(aircraft) { return aircraft.operatorIcao.chg || aircraft.icao.chg || aircraft.registration.chg || aircraft.manufacturer.chg; },
                    // And changed this line to call our custom function to build the <img> tag instead of the standard one...
                    renderCallback:         function(aircraft) { return customFormatOperatorIcaoImageHtml(aircraft); },
                    tooltipChangedCallback: function(aircraft) { return aircraft.operatorIcao.chg || aircraft.operator.chg; },
                    tooltipCallback:        function(aircraft) { return aircraft.formatOperatorIcaoAndName(); }
                });
                
            }
        });
    }
    
    function customFormatOperatorIcaoImageHtml(aircraft)
    {
        var codeToUse = '';
        codeToUse = customPipeSeparatedCode(codeToUse, aircraft.manufacturer.val);
        codeToUse = customPipeSeparatedCode(codeToUse, aircraft.operatorIcao.val);
        codeToUse = customPipeSeparatedCode(codeToUse, aircraft.registration.val);
        codeToUse = customPipeSeparatedCode(codeToUse, aircraft.icao.val);
        
        // The rest of this was copied from format.js operatorIcaoImageHtml()
        var size = VRS.globalOptions.aircraftOperatorFlagSize;
        var result = '<img src="images/File-' + encodeURIComponent(codeToUse);
        if(VRS.browserHelper.isHighDpi()) result += '/HiDpi';
        result += '/OpFlag.png"' +
            ' width="' + size.width.toString() + 'px"' +
            ' height="' + size.height.toString() + 'px"' +
            ' />';

        return result;
    }
    
    function customPipeSeparatedCode(text, code)
    {
        var result = text;
        
        if(code && code.length) {
            if(result.length) result += '|';
            result += code;
        }

        return result;
    }
</script>

OhhNeal
Posts: 17
Joined: Sat Aug 22, 2015 3:38 am

Re: Manufacturer as squadron logo source in Custom Content Plugin?

Post by OhhNeal » Tue Sep 15, 2015 7:42 am

Hi Andrew,

I'm happy, it sure works fine. All my Hop! planes have changed to Air France planes, both on the list and the aircraft detail page. No military to test with at the moment. Had a look in the reports, but it is not working there. I thought the customcontent plugin worked on all pages?

Before
Image
And after
Image

An that all without changing the operator field so I can still search for Hop! planes in my basestation.sqb.

And that combined with seeing all the Mlat planes really made it even better.

Now all I need is more military planes coming through!!!

OhhNeal
Posts: 17
Joined: Sat Aug 22, 2015 3:38 am

Re: Manufacturer as squadron logo source in Custom Content Plugin?

Post by OhhNeal » Wed Sep 16, 2015 8:53 am

Hi Andrew,

Some further testing gave me the following results on the mobile site.
On the list there was still the original logos, like no changes were made. While on the detail page the logos showed as intended. I cleared my cache just to make sure, but that didn't help.

I hope you are willing to spend some more time to this.

Regards,
Neal

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

Re: Manufacturer as squadron logo source in Custom Content Plugin?

Post by agw » Fri Sep 18, 2015 1:44 am

The reports use a different renderer, which is why they're not changing. However the mobile page does not - it's exactly the same JavaScript that's building the aircraft list for both the desktop and the mobile page, just like the aircraft detail panel is built by the same JavaScript for both.

However, I think the list uses a renderer that draws the logo and silhouette on top of each other, that would need to be changed.

It's late here and I need to go to bed, so I'll leave the script for that and the report renderer for the weekend :)

Post Reply