Template:domxref

  • Revision slug: Template:domxref
  • Revision title: Template:domxref
  • Revision id: 296079
  • Created:
  • Creator: Jeremie
  • Is current revision? No
  • Comment

Revision Content

<% /* Used for generating cross-references within the DOM documentation. */ /* This will first try to link to DOM/$0, then DOM:$0 if that doesn't exist */ /* if you specify the API name with parens (ie, "foo()"), the link is to */ /* lang/DOM/foo but the title is displayed as "foo()" to make it clear it's */ /* a function */ /* @param */ /* The path of the page to link to, relative to the DOM documentation path. */ /* @param [optional] */ /* The text to use for the link. If omitted, the value of the first */ /* parameter will be used */ /* @param [optional] */ /* An anchor to link to on the page. Link text will display as $0.$2 or $1.$2 */ /* get a page's language (Don't use page.language!) */ var lang = env.locale; var api = $0; var str = $1 || $0; if (api.substr(-2) === '()') { api = api.substr(0, api.length - 2); } var URL = "/" + lang + '/docs/DOM/' + api; var anch = ''; if ($2) {   str = str + '.' + $2; anch = '#' + $2; } %> <%= $str %>

Revision Source

<%
/* Used for generating cross-references within the DOM documentation. */
/* This will first try to link to DOM/$0, then DOM:$0 if that doesn't exist */
/* if you specify the API name with parens (ie, "foo()"), the link is to */
/* lang/DOM/foo but the title is displayed as "foo()" to make it clear it's */
/* a function */
/* @param */
/*   The path of the page to link to, relative to the DOM documentation path. */
/* @param [optional] */
/*   The text to use for the link.  If omitted, the value of the first */
/*   parameter will be used */
/* @param [optional] */
/*   An anchor to link to on the page. Link text will display as $0.$2 or $1.$2 */

/* get a page's language (Don't use page.language!) */
var lang = env.locale;

var api = $0;
var str = $1 || $0;

if (api.substr(-2) === '()') {
  api = api.substr(0, api.length - 2);
}

var URL = "/" + lang + '/docs/DOM/' + api;

var anch = '';

if ($2) {
  str = str + '.' + $2;
  anch = '#' + $2;
}
%>
<code><a href="<%- URL+anch %>" title="<%- URL+anch %>"><%= $str %></a></code>
Revert to this revision