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.