Are you having problems with using or developing a plugin? Let me know here.
-
jfm
- Posts: 82
- Joined: Thu May 10, 2012 4:09 pm
Post
by jfm » Thu Mar 20, 2014 4:22 pm
Hi Andrew,
I'm trying to add a link to FlightAware on the Aircraft Detail panel. I'm not sure if this is possible with the Custom Content plugin. Can you tell me if I'm on the right track?
The logic I'm trying to use to create the link is:
- Check for a callsign
- If it exists and it is a number (e.g. 697) and I know the operator flag code (e.g. WJA), then append the two. Westjet only uses the flight number as the callsign, so this would make the callsign WJA697.
- If it exists and it is not a number, then use the callsign
- Otherwise use the registration
In enums.js in VRS.LinkSite, I believe I need to add the following before StandingDataMaintenance:
Code: Select all
FlightAwareDotCom: 'flightaware.com',
In linksRenderer.js, I believe I need to add a VRS.LinkRenderHandler as follows:
Code: Select all
new VRS.LinkRenderHandler({
linkSite: VRS.LinkSite.FlightAwareDotCom,
displayOrder: 400,
canLinkAircraft: function(/** VRS.Aircraft */ aircraft) { return aircraft && (aircraft.registration.val || aircraft.callsign.val); },
hasChanged: function(/** VRS.Aircraft */ aircraft) { return aircraft.registration.chg || aircraft.callsign.chg; },
title: 'www.flightaware.com',
buildUrl: function(/** VRS.Aircraft */ aircraft) { return 'http://flightaware.com/live/flight/' + ( aircraft.callsign.val ? (!isNaN(aircraft.callsign.val) && aircraft.operatorIcao.val ? VRS.stringUtility.htmlEscape(aircraft.formatOperatorIcao() + aircraft.formatCallsign()) : VRS.stringUtility.htmlEscape(aircraft.formatCallsign())) : VRS.stringUtility.htmlEscape(aircraft.formatRegistration(true)) )); },
target: 'flightaware'
}),
Thanks!!!
Last edited by
jfm on Sat Mar 22, 2014 7:13 pm, edited 3 times in total.
-
jfm
- Posts: 82
- Joined: Thu May 10, 2012 4:09 pm
Post
by jfm » Thu Mar 20, 2014 5:08 pm
Just doing a bit more reading of the documentation. I think I can replace those two files in their entirety with my own versions using the plugin. But could I instead inject those JS snippets into desktop.html? Maybe at the end of the header?
Thanks again.
-
jfm
- Posts: 82
- Joined: Thu May 10, 2012 4:09 pm
Post
by jfm » Thu Mar 20, 2014 10:47 pm
Wait long enough and I'll answer my own questions!
I'm injecting the following code at the end of HEAD and it is working!
Code: Select all
<script type="text/javascript">
VRS.LinkSite["FlightAwareDotCom"] = "flightaware.com";
VRS.linkRenderHandlers.push(
new VRS.LinkRenderHandler({
linkSite: VRS.LinkSite.FlightAwareDotCom,
displayOrder: 400,
canLinkAircraft: function(/** VRS.Aircraft */ aircraft) { return aircraft && (aircraft.registration.val || aircraft.callsign.val); },
hasChanged: function(/** VRS.Aircraft */ aircraft) { return aircraft.registration.chg || aircraft.callsign.chg; },
title: 'www.flightaware.com',
buildUrl: function(/** VRS.Aircraft */ aircraft) { return 'http://flightaware.com/live/flight/' + ( aircraft.callsign.val ? (!isNaN(aircraft.callsign.val) && aircraft.operatorIcao.val ? VRS.stringUtility.htmlEscape(aircraft.formatOperatorIcao() + aircraft.formatCallsign()) : VRS.stringUtility.htmlEscape(aircraft.formatCallsign())) : VRS.stringUtility.htmlEscape(aircraft.formatRegistration(true)) ); },
target: 'flightaware'
})
);
</script>
-
agw
- Posts: 2249
- Joined: Fri Feb 17, 2012 3:20 am
Post
by agw » Fri Mar 21, 2014 12:33 am
That is exactly the way to add custom links - the only thing I would suggest is adding some kind of prefix to the name of the VRS.LinkSite index so that there's no possibility of clashing with a future update. Perhaps "jfm_FlightAwareDotCom"?
-
jfm
- Posts: 82
- Joined: Thu May 10, 2012 4:09 pm
Post
by jfm » Fri Mar 21, 2014 2:45 pm
Thanks, I'll make that change.
Maybe you can change the topic title to something more descriptive, if anyone else is looking to do the same thing?
-
agw
- Posts: 2249
- Joined: Fri Feb 17, 2012 3:20 am
Post
by agw » Sat Mar 22, 2014 4:03 pm
I can change the topic title but it's probably better if you do it

Just click on the Edit button on your first post, you should be able to change the topic title from there.
-
Lector
- Posts: 39
- Joined: Sat Jan 18, 2014 1:02 pm
Post
by Lector » Sat Apr 19, 2014 1:34 pm
I did replicate this behaviour for the planespotters.net, since it provides (on one page) another links to different kinds of information (plane photos, airframe infos, aircompany fleet info etc).
Thanks to jfm for posting this thread, so I could walk the same way

Here below the script itself:
Code: Select all
<script type="text/javascript">
VRS.LinkSite["Lector_PlaneSpottersDotNet"] = "planespotters.net";
VRS.linkRenderHandlers.push(
new VRS.LinkRenderHandler({
linkSite: VRS.LinkSite.Lector_PlaneSpottersDotNet,
displayOrder: 400,
canLinkAircraft: function(/** VRS.Aircraft */ aircraft) { return aircraft && aircraft.registration.val; },
hasChanged: function(/** VRS.Aircraft */ aircraft) { return aircraft.registration.chg; },
title: 'www.planespotters.net',
buildUrl: function(/** VRS.Aircraft */ aircraft) { return 'http://www.planespotters.net/Aviation_Photos/search.php?tag=' + VRS.stringUtility.htmlEscape(aircraft.formatRegistration()); },
target: 'planespotters'
})
);
</script>
-
jfm
- Posts: 82
- Joined: Thu May 10, 2012 4:09 pm
Post
by jfm » Sun Apr 20, 2014 8:39 pm
You can also remove the default links. For example, I remove Airframes.Org with:
VRS.linkRenderHandlers.splice(0,1);
The 0 tells it to start at the first item in the array of links (0 is the first) and the 1 tells it to remove 1 item.
http://www.w3schools.com/jsref/jsref_splice.asp
-
TammaraBa30
- Posts: 2
- Joined: Tue Oct 14, 2014 5:50 am
Post
by TammaraBa30 » Wed Oct 15, 2014 2:20 am
I agree. Adding custom links is a bit tricky. You may add some sort of prefix to VRS.LinkSite index so that there's little possibility of clashing when you do the updates. Thanks.
Tammara
I cured my nightmares with this dream site at dream dictionary now. I understand my dreams so much better now. Here is the home link to that dream site.
-
louisd13
- Posts: 2
- Joined: Wed Nov 22, 2017 4:53 am
Post
by louisd13 » Wed Nov 22, 2017 4:59 am
Would anyone be able to help me in creating a custom link to flightradar24 as well? I have successfully created a custom link to flightaware.com using jfm's instruction above with the custom content plugin, but I am not able to create a link to Flightradar24. This is the script I am running with the custom content plugin:
Code: Select all
<script type="text/javascript">
VRS.LinkSite["FlightRadar24DotCom"] = "flightradar24.com";
VRS.linkRenderHandlers.push(
new VRS.LinkRenderHandler({
linkSite: VRS.LinkSite.FlightRadar24DotCom,
displayOrder: 400,
canLinkAircraft: function(/** VRS.Aircraft */ aircraft) { return aircraft && (aircraft.registration.val || aircraft.callsign.val); },
hasChanged: function(/** VRS.Aircraft */ aircraft) { return aircraft.registration.chg || aircraft.callsign.chg; },
title: 'www.flightradar24.com',
buildUrl: function(/** VRS.Aircraft */ aircraft) { return 'http://fr24.com/'+selected.flight' + ( aircraft.callsign.val ? (!isNaN(aircraft.callsign.val) && aircraft.operatorIcao.val ? VRS.stringUtility.htmlEscape(aircraft.formatOperatorIcao() + aircraft.formatCallsign()) : VRS.stringUtility.htmlEscape(aircraft.formatCallsign())) : VRS.stringUtility.htmlEscape(aircraft.formatRegistration(true)) ); },
target: 'flightradar24'
})
);
</script>
any assistance would be greatly appreciated. thanks!