Revision 64510 of Template:ifattribute

  • Revision slug: Template:ifattribute
  • Revision title: Template:ifattribute
  • Revision id: 64510
  • Created:
  • Creator: Sheppy
  • Is current revision? No
  • Comment 1 words added, 1 words removed
Tags: 

Revision Content

<% /* creates a link to an attribute in an interface */ /* parameters: interface_name, attribute_name */ /* get a page's language (Don't use page.language!) */ var u = Uri.Parts(Page.uri); var lang = string.toLower(u.path[0]); if(string.Contains(lang, "project")) { lang = string.Substr(lang, 8); } /* fall back to page.language on a user page */ else if (string.StartsWith(lang, "user:")) { lang = page.language; } var destNewType = lang + '/XPCOM Interface Reference/' + $0; var destOldType = lang + '/' + $0; var apiString = $0 + '.' + $1; if(wiki.pageExists(destNewType)) { /* the page exists from the dekiwiki age */ (web.link(wiki.uri(destNewType) + '#' + $1, apiString)); } else if (wiki.pageExists(destOldType)) { /* the page exists from the mediawiki age */ (web.link(wiki.uri(destOldType) + '#' + $1, apiString)); } else { /* the page doesn't exist */   var targeturi = "https://developer.mozilla.org/Article_not_found?uri=" + destNewType +         "&ident=" + $0; <a rel=('internal') href=(targeturi) class=('new')>(apiString)a>; }

Revision Source

<%

/* creates a link to an attribute in an interface */
/* parameters: interface_name, attribute_name */
/* get a page's language (Don't use page.language!) */
var u = Uri.Parts(Page.uri);
var lang = string.toLower(u.path[0]);
if(string.Contains(lang, "project")) {
 lang = string.Substr(lang, 8);
}
/* fall back to page.language on a user page */
else if (string.StartsWith(lang, "user:")) {
 lang = page.language;
}
var destNewType = lang + '/XPCOM Interface Reference/' + $0;
var destOldType = lang + '/' + $0;
var apiString = $0 + '.' + $1;
if(wiki.pageExists(destNewType)) { /* the page exists from the dekiwiki age */
    <code>(web.link(wiki.uri(destNewType) + '#' + $1, apiString))</code>;
} else if (wiki.pageExists(destOldType)) { /* the page exists from the mediawiki age */
    <code>(web.link(wiki.uri(destOldType) + '#' + $1, apiString))</code>;
} else { /* the page doesn't exist */
  var targeturi = "https://developer.mozilla.org/Article_not_found?uri=" + destNewType +
        "&ident=" + $0;
    <code><<span class="start-tag">a</span><span class="attribute-name"> rel</span>=(<span class="attribute-value">'internal') </span><span class="attribute-name">href</span><span>=</span>(targeturi<span>) </span><span class="attribute-name">class</span>=<span class="attribute-value">('new')></span>(apiString)</<span class="end-tag">a></span></code>;
}
</pre>