mozilla

Revision 235771 of Template:ifattribute

  • Revision slug: Template:ifattribute
  • Revision title: Template:ifattribute
  • Revision id: 235771
  • Created:
  • Creator: groovecoder
  • Is current revision? No
  • Comment
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 + '/docs/XPCOM Interface Reference/' + $0; var destOldType = lang + '/docs/' + $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; %> class="new"><%=(apiString)%> <% } %>

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 + '/docs/XPCOM Interface Reference/' + $0;
var destOldType = lang + '/docs/' + $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>
<%
}
%>