Template:domxref

  • Revision slug: Template:domxref
  • Revision title: Template:domxref
  • Revision id: 56098
  • Created:
  • Creator: Sheppy
  • Is current revision? No
  • Comment 2 words added, 1 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:parm1, then DOM/parm1 if that doesn't exist */

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

if (string.endswith($0, '()')) {
  var len = string.length($0) - 2;
  api = string.substr($0, 0, len);
}

var dest = lang + '/' + 'DOM:' + api;
if (wiki.pageExists(dest)) {
    (web.link(wiki.uri(dest), $0));
} else {
    (web.link(wiki.uri(lang + '/' + 'DOM/' + api), $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:parm1, then DOM/parm1 if that doesn't exist */

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

if (string.endswith($0, '()')) {
  var len = string.length($0) - 2;
  api = string.substr($0, 0, len);
}

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

%>
Revert to this revision