MDN may have intermittent access issues April 18 13:00 - April 19 01:00 UTC. See whistlepig.mozilla.org for all notifications.

mozilla

Revision 56079 of Template:domxref

  • Revision slug: Template:domxref
  • Revision title: Template:domxref
  • Revision id: 56079
  • Created:
  • Creator: Sheppy
  • Is current revision? No
  • Comment 82 words added

Revision Content

/* accepts as input one required parameter: DOM API to create a xref to */
/* this will first try to link to DOM:$0, then DOM/$0 if that doesn't exist */
/* if $1 is specified and non-zero, the item is displayed as a method name with parens */

/* get a page's language (Don't use page.language!) */
var u = Uri.Parts(Page.uri);
var lang = u.path[0];
var title = $0;

/* build displayed title */

if ($1) {
  title = title + "()";
}

/* check $0 exists */
var dest = lang + '/' + 'DOM:' + $0;
if(wiki.pageExists(dest)) {
    (web.link(wiki.uri(dest), $0));
} else {
    (web.link(wiki.uri(lang + '/' + 'DOM/' + $0), $0));
}

Revision Source

<pre class="script">
/* accepts as input one required parameter: DOM API to create a xref to */
/* this will first try to link to DOM:$0, then DOM/$0 if that doesn't exist */
/* if $1 is specified and non-zero, the item is displayed as a method name with parens */

/* get a page's language (Don't use page.language!) */
var u = Uri.Parts(Page.uri);
var lang = u.path[0];
var title = $0;

/* build displayed title */

if ($1) {
  title = title + "()";
}

/* check $0 exists */
var dest = lang + '/' + 'DOM:' + $0;
if(wiki.pageExists(dest)) {
    <code>(web.link(wiki.uri(dest), $0))</code>;
} else {
    <code>(web.link(wiki.uri(lang + '/' + 'DOM/' + $0), $0))</code>;
}
</pre>
Revert to this revision