Page 2 of 2

Re: Create Custom Link w/ Custom Content Plugin

Posted: Fri Dec 14, 2018 10:18 am
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.

Re: Create Custom Link w/ Custom Content Plugin

Posted: Thu Jun 13, 2019 8:02 pm
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.

Re: Create Custom Link w/ Custom Content Plugin

Posted: Thu Jun 13, 2019 8:11 pm
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.

Re: Create Custom Link w/ Custom Content Plugin

Posted: Thu Nov 05, 2020 6:49 pm
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?

Re: Create Custom Link w/ Custom Content Plugin

Posted: Thu Nov 05, 2020 7:43 pm
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!

Re: Create Custom Link w/ Custom Content Plugin

Posted: Thu Nov 05, 2020 7:43 pm
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!!

Re: Create Custom Link w/ Custom Content Plugin

Posted: Thu Nov 05, 2020 11:00 pm
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>

Re: Create Custom Link w/ Custom Content Plugin

Posted: Sun Nov 22, 2020 2:29 pm
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>

Re: Create Custom Link w/ Custom Content Plugin

Posted: Fri Jan 01, 2021 4:45 pm
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