Template:JSGToC

  • Revision slug: Template:JSGToC
  • Revision title: Template:JSGToC
  • Revision id: 332439
  • Created:
  • Creator: ethertank
  • Is current revision? No
  • Comment

Revision Content

<% // Note: If you want to add chapters to this table of contents, // add their links to https://developer.mozilla.org/Template:JSGChapters var chapterList = string.deserialize(template("JSGChapters")); var cLen = chapterList.length; var expTOC = ""; var link1 = ""; var i; var s_TOC = mdn.localString({ "en-US": "Quick Table of Contents", "zh-CN": "目录", "ja": "目次" }); %>

<%- s_TOC %>

    <% switch (env.locale) { case "ja": for (i = 0; i < cLen; ++i) { chapterList[i] = chapterList[i].replace(/en-US/, "ja"); } break; case "de": for (i = 0; i < cLen; ++i) { chapterList[i] = chapterList[i].replace(/en-US/, "de"); } break; default: break; } for (i = 0; i < cLen; ++i) { var path = chapterList[i]; var link1 = web.link(path, wiki.getPage(path).title); %>
  1. <%- link1 %>
  2. <% // TODO: bug 769516, need support for wiki.toc() // expTOC += "

    " + link1 + "

    " + wiki.toc(path); } %>
<% if (expTOC) { %> <% /* TODO: bug 769516, need support for wiki.toc() */ %>

Expanded Table of Contents

<%- expTOC %> <% } %>

Revision Source

<%
// Note: If you want to add chapters to this table of contents,
// add their links to https://developer.mozilla.org/Template:JSGChapters

var chapterList = string.deserialize(template("JSGChapters"));
var cLen = chapterList.length;
var expTOC = "";
var link1 = "";
var i;
var s_TOC = mdn.localString({
    "en-US": "Quick Table of Contents",
    "zh-CN": "目录",
    "ja": "目次"
});

%><h2><%- s_TOC %></h2>
<ol>
<%

switch (env.locale) {
    case "ja":
        for (i = 0; i < cLen; ++i) { chapterList[i] = chapterList[i].replace(/en-US/, "ja"); }
        break;
    case "de":
        for (i = 0; i < cLen; ++i) { chapterList[i] = chapterList[i].replace(/en-US/, "de"); }
        break;
    default: break;
}

for (i = 0; i < cLen; ++i) {
    var path = chapterList[i];
    var link1 = web.link(path, wiki.getPage(path).title);

    %><li><%- link1 %></li><%
    // TODO: bug 769516, need support for wiki.toc()
    // expTOC += "<h3>" + link1 + "</h3>" + wiki.toc(path);
}
%>
</ol>
<% if (expTOC) { %>
<% /* TODO: bug 769516, need support for wiki.toc() */ %>
<h2>Expanded Table of Contents</h2>
<%- expTOC %>
<% } %>
Revert to this revision