Template:domxref

  • Revision slug: Template:domxref
  • Revision title: Template:domxref
  • Revision id: 56082
  • Created:
  • Creator: Sheppy
  • Is current revision? No
  • Comment 8 words added, 7 words removed

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, 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 ttl = $0;

/* build displayed title */

var useparens = $1 || 0;
if (useparens) {
  ttl = ttl + '()';
}

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

%>

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, 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 ttl = $0;

/* build displayed title */

var useparens = $1 || 0;
if (useparens) {
  ttl = ttl + '()';
}

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

%>
Revert to this revision