Create Custom Link w/ Custom Content Plugin

Are you having problems with using or developing a plugin? Let me know here.
milano
Posts: 2
Joined: Wed Nov 14, 2018 8:19 am

Re: Create Custom Link w/ Custom Content Plugin

Post by milano »

jfm wrote: 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
with this I can remove the default links, but how to remove the "first" link and pics for airport-data.com.
I want to bring at this position a custom pic and link.
RickBoatright
Posts: 16
Joined: Tue Dec 20, 2016 3:36 am

Re: Create Custom Link w/ Custom Content Plugin

Post by RickBoatright »

jfm

The problem with your code is that you didn't remove selected.aircraft from the prototype url you used, and VRS doesn't have that...

which would have shown up if you had looked at the javascript console.

This function works:

Code: Select all

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 'https://www.flightradar24.com/' + 
                              ( 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'
   })
);
Although, honestly, I've never SEEN an aircraft in VRS that has an all-number callsign. But if that's what you want, the above code works.
RickBoatright
Posts: 16
Joined: Tue Dec 20, 2016 3:36 am

Re: Create Custom Link w/ Custom Content Plugin

Post by RickBoatright »

That doesn't quite answer how to put NEW links in the front, and there's a conceptualy easier way.

Code: Select all

// reverse the order of the array
VRS.linkRenderHandlers.reverse(); 
// remove the last element (which was the first) 
VRS.linkRenderHandlers.pop(); 
// add your new link handlers to the end... 
VRS.linkRenderHandlers.push( 
   (code-for-hander-will-be-second) );
VRS.linkRenderHandlers.push( 
   (code-for-hander-will-be-first) );
// now The-First-Shall-Be-Last... 
VRS.linkRenderHandlers.reverse() 
// and the ones you pushed onto the end are now at the front of the list
milano wrote: Fri Dec 14, 2018 10:18 am
jfm wrote: 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
with this I can remove the default links, but how to remove the "first" link and pics for airport-data.com.
I want to bring at this position a custom pic and link.
gonzalu
Posts: 14
Joined: Wed Oct 31, 2018 8:41 pm

Re: Create Custom Link w/ Custom Content Plugin

Post by gonzalu »

Sorry for the dumb question, but, do I need to create a file with the code to inject and place it somewhere in the path for VRS to find it and inject it?
gonzalu
Posts: 14
Joined: Wed Oct 31, 2018 8:41 pm

Re: Create Custom Link w/ Custom Content Plugin

Post by gonzalu »

Lector wrote: 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:

I changed your URL to

Code: Select all

https://www.planespotters.net/search?q=
sinc eyours was not working... THANK YOU so much for the code tho... works great!
Last edited by gonzalu on Thu Nov 05, 2020 8:10 pm, edited 1 time in total.
gonzalu
Posts: 14
Joined: Wed Oct 31, 2018 8:41 pm

Re: Create Custom Link w/ Custom Content Plugin

Post by gonzalu »

gonzalu wrote: Thu Nov 05, 2020 6:49 pm Sorry for the dumb question, but, do I need to create a file with the code to inject and place it somewhere in the path for VRS to find it and inject it?
As someone earlier said, keep waiting and I answer my own questions :)

ALL working now, thank you all ... this is great!!
gonzalu
Posts: 14
Joined: Wed Oct 31, 2018 8:41 pm

Re: Create Custom Link w/ Custom Content Plugin

Post by gonzalu »

I'll make my own contribution with a link to JetPhotos.com

Code: Select all

<script type="text/javascript">
VRS.LinkSite["mg_JetPhotosDotCom"] = "jetphotos.com";

VRS.linkRenderHandlers.push(
   new VRS.LinkRenderHandler({
      linkSite:           VRS.LinkSite.mg_JetPhotosDotCom,
      displayOrder:       400,
            canLinkAircraft:    function(/** VRS.Aircraft */ aircraft) { return aircraft && aircraft.registration.val; },
            hasChanged:         function(/** VRS.Aircraft */ aircraft) { return aircraft.registration.chg; },
            title:              'www.jetphotos.com',
            buildUrl:           function(/** VRS.Aircraft */ aircraft) { return 'https://www.jetphotos.com/registration/' + VRS.stringUtility.htmlEscape(aircraft.formatRegistration()); },
            target:             'jetphotos'
   })
);
</script>
gonzalu
Posts: 14
Joined: Wed Oct 31, 2018 8:41 pm

Re: Create Custom Link w/ Custom Content Plugin

Post by gonzalu »

Added a new link to search the FAA.gov US Database

Code: Select all

<script type="text/javascript">
VRS.LinkSite["mg_FAAdotOrg"] = "faa.gov";

VRS.linkRenderHandlers.push(
   new VRS.LinkRenderHandler({
      linkSite:           VRS.LinkSite.mg_FAAdotOrg,
      displayOrder:       400,
            canLinkAircraft:    function(/** VRS.Aircraft */ aircraft) { return aircraft && aircraft.registration.val; },
            hasChanged:         function(/** VRS.Aircraft */ aircraft) { return aircraft.registration.chg; },
            title:              'faa.gov',
            buildUrl:           function(/** VRS.Aircraft */ aircraft) { return 'https://registry.faa.gov/AircraftInquiry/Search/NNumberResult?nNumberTxt=' + VRS.stringUtility.htmlEscape(aircraft.formatRegistration()); },
            target:             'faa'
   })
);
</script>
pakon
Posts: 20
Joined: Tue Sep 08, 2020 11:32 am
Location: Berlin, Germany
Contact:

Re: Create Custom Link w/ Custom Content Plugin

Post by pakon »

RickBoatright wrote: Thu Jun 13, 2019 8:02 pm jfm

Although, honestly, I've never SEEN an aircraft in VRS that has an all-number callsign. But if that's what you want, the above code works.
I also did, ist was an C3 Globemaster under the NATO Flag with the Callsign 03. Maybe it was misconfigured.

Cheers,
Pakon
Post Reply