Template:CSSRef

  • Revision slug: Template:CSSRef
  • Revision title: Template:CSSRef
  • Revision id: 467629
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment

Revision Content

<% function containsTag(tagList, tag) { if (!tagList || tagList == undefined) return 0; tag = tag.toLowerCase(); for (var i = 0, len = tagList.length; i < len; i++) { if (tagList[i].toLowerCase() == tag) return 1; } return 0; } var s_css_href = '/en-US/docs/Web/CSS'; var s_css_title = 'CSS'; var s_css_ref_href = '/en-US/docs/Web/CSS/Reference'; var s_css_ref_title = 'CSS Reference'; var s_api_href = '/' + env.locale + '/docs/Web/API'; var s_guide_href = '/' + env.locale + '/docs/Web/Guide/CSS'; switch (env.locale) { case 'es': s_css_href = false; s_css_ref_href = '/es/docs/Guía_de_referencia_de_CSS'; s_css_ref_title = 'Referencia CSS'; break; case 'fr': s_css_href = '/fr/docs/CSS'; s_css_ref_href = '/fr/docs/CSS/Référence_CSS'; s_css_ref_title = 'Référence CSS'; break; case 'ja': s_css_href = '/ja/docs/Web/CSS'; s_css_ref_href = '/ja/docs/Web/CSS/Reference'; s_css_ref_title = 'CSS リファレンス'; break; case 'ko': s_css_href = false; s_css_ref_href = '/ko/docs/CSS_Reference'; s_css_ref_title = 'CSS Reference'; break; case 'pl': s_css_href = '/pl/docs/CSS'; s_css_ref_href = '/pl/docs/Dokumentacja_CSS'; s_css_ref_title = 'Dokumentacja CSS'; break; case 'pt-PT': s_css_href = false; s_css_ref_href = '/pt-PT/docs/Referência_CSS'; s_css_ref_title = 'Referência CSS'; break; case 'pt-BR': s_css_href = '/pt-BR/docs/CSS'; s_css_ref_href = '/pt-BR/docs/CSS/CSS_Reference'; s_css_ref_title = 'Referência CSS'; break; case 'zh-CN': s_css_href = false; s_css_ref_href = '/zh-CN/docs/CSS_Reference'; s_css_ref_title = 'CSS 参考'; break; case 'de': s_css_href = '/de/docs/CSS'; s_css_ref_href = 'de/docs/CSS_Referenz'; s_css_ref_title = 'CSS Referenz'; break; default: break; } // Find the section of CSS this page belongs to (that is the first tag of the form "CSS XYZ") var tags = env.tags; var found_tag = ''; for (i in tags) { if ((tags[i] != 'CSS Reference') && (tags[i] != 'CSS Référence') && (tags[i] != s_css_ref_title)) { // Only keep this one one the 'accent' bug is fixed if (tags[i].substr(0, 4) == 'CSS ') { found_tag = tags[i]; break; } } } // Find the CSS entities belonging to the same subject if (found_tag) { // Find the pages, sub-pages of CSS/ that are tagged with that specific tag var pageList = page.subpagesExpand(s_css_href); // Get subpages, including tags var resultCSS = []; for (aPage in pageList) { if (containsTag(pageList[aPage].tags, found_tag)) { resultCSS.push(pageList[aPage].title); } } } // Find the interfaces belonging to the same subject if (found_tag) { // Find the pages, sub-pages of CSS/ that are tagged with that specific tag var pageList = page.subpagesExpand(s_api_href); // Get subpages, including tags var resultAPI = []; for (aPage in pageList) { if (containsTag(pageList[aPage].tags, found_tag) && containsTag(pageList[aPage].tags, "Interface")) { // We only want interfaces, not properties or methods resultAPI.push(pageList[aPage].title); } } } // Find the guides, tutorials, ... belonging to the same subject if (found_tag) { // Find the pages, sub-pages of CSS/ that are tagged with that specific tag var pageList = page.subpagesExpand(s_guide_href); // Get subpages, including tags var resultGuide = []; for (aPage in pageList) { if (containsTag(pageList[aPage].tags, found_tag)) { resultGuide.push({title: pageList[aPage].title, url: pageList[aPage].href}); } } } %><% if (s_css_href) { %>« <%=s_css_title%> <% } %>« <%=s_css_ref_title%> <% if (s_css_href) { %>
    <% if (found_tag) { for( aPage in resultGuide) { // Tutorials and guides matching %>
  1. <%-aPage.title%>
  2. <% } for (aTitle in resultCSS) { // CSS entities matching %>
  3. <%- template("cssxref", [resultCSS[aTitle]]) %>
  4. <% } for (aTitle in resultAPI) { // CSSOM interfaces matching %>
  5. <%- template("domxref", [resultAPI[aTitle]]) %>
  6. <% } } %>
  7. <%=s_css_ref_title%> <%- template("CSS_Ref_Core") %>
<%}%>

Revision Source

<%
function containsTag(tagList, tag) {
    if (!tagList || tagList == undefined) return 0;
    tag = tag.toLowerCase();
    for (var i = 0, len = tagList.length; i < len; i++) {
        if (tagList[i].toLowerCase() == tag) return 1;
    }
    return 0;
}

var s_css_href = '/en-US/docs/Web/CSS';
var s_css_title = 'CSS';
var s_css_ref_href = '/en-US/docs/Web/CSS/Reference';
var s_css_ref_title = 'CSS Reference';
var s_api_href = '/' + env.locale + '/docs/Web/API';
var s_guide_href = '/' + env.locale + '/docs/Web/Guide/CSS';

switch (env.locale) {
    case 'es':
        s_css_href = false;
        s_css_ref_href = '/es/docs/Guía_de_referencia_de_CSS';
        s_css_ref_title = 'Referencia CSS';
        break;
    case 'fr':
        s_css_href = '/fr/docs/CSS';
        s_css_ref_href = '/fr/docs/CSS/Référence_CSS';
        s_css_ref_title = 'Référence CSS';
        break;
    case 'ja':
        s_css_href = '/ja/docs/Web/CSS';
        s_css_ref_href = '/ja/docs/Web/CSS/Reference';
        s_css_ref_title = 'CSS リファレンス';
        break;
    case 'ko':
        s_css_href = false;
        s_css_ref_href = '/ko/docs/CSS_Reference';
        s_css_ref_title = 'CSS Reference';
        break;
    case 'pl':
        s_css_href = '/pl/docs/CSS';
        s_css_ref_href = '/pl/docs/Dokumentacja_CSS';
        s_css_ref_title = 'Dokumentacja CSS';
        break;
    case 'pt-PT':
        s_css_href = false;
        s_css_ref_href = '/pt-PT/docs/Referência_CSS';
        s_css_ref_title = 'Referência CSS';
        break;
    case 'pt-BR':
        s_css_href = '/pt-BR/docs/CSS';
        s_css_ref_href = '/pt-BR/docs/CSS/CSS_Reference';
        s_css_ref_title = 'Referência CSS';
        break;
    case 'zh-CN':
        s_css_href = false;
        s_css_ref_href = '/zh-CN/docs/CSS_Reference';
        s_css_ref_title = 'CSS 参考';
        break;
    case 'de':
        s_css_href = '/de/docs/CSS';
        s_css_ref_href = 'de/docs/CSS_Referenz';
        s_css_ref_title = 'CSS Referenz';
        break;
    default: break;
}

// Find the section of CSS this page belongs to (that is the first tag of the form "CSS XYZ")
var tags = env.tags;
var found_tag = '';
for (i in tags) {
    if ((tags[i] != 'CSS Reference') &&
        (tags[i] != 'CSS Référence') &&
        (tags[i] != s_css_ref_title)) { // Only keep this one one the 'accent' bug is fixed
        if (tags[i].substr(0, 4) == 'CSS ') {
            found_tag = tags[i];
            break;
        }
    }
}

// Find the CSS entities belonging to the same subject
if (found_tag) {
    // Find the pages, sub-pages of CSS/ that are tagged with that specific tag
    var pageList = page.subpagesExpand(s_css_href);   // Get subpages, including tags
    var resultCSS = [];

    for (aPage in pageList) {
        if (containsTag(pageList[aPage].tags, found_tag)) {
            resultCSS.push(pageList[aPage].title);
        }
    }
}


// Find the interfaces belonging to the same subject
if (found_tag) {
    // Find the pages, sub-pages of CSS/ that are tagged with that specific tag
    var pageList = page.subpagesExpand(s_api_href);   // Get subpages, including tags
    var resultAPI = [];

    for (aPage in pageList) {
        if (containsTag(pageList[aPage].tags, found_tag) &&
            containsTag(pageList[aPage].tags, "Interface")) { // We only want interfaces, not properties or methods
            resultAPI.push(pageList[aPage].title);
        }
    }
}

// Find the guides, tutorials, ... belonging to the same subject
if (found_tag) {
    // Find the pages, sub-pages of CSS/ that are tagged with that specific tag
    var pageList = page.subpagesExpand(s_guide_href);   // Get subpages, including tags
    var resultGuide = [];

    for (aPage in pageList) {
        if (containsTag(pageList[aPage].tags, found_tag)) {
            resultGuide.push({title: pageList[aPage].title, url: pageList[aPage].href});
        }
    }
}
%><span class="breadcrumbs cssRef_breadcrumbs themeUpdated"><% if (s_css_href) { %>&laquo; <a href="<%=s_css_href%>"><%=s_css_title%></a> <% } %>&laquo; <a href="<%=s_css_ref_href%>"><%=s_css_ref_title%></a></span>

  <% if (s_css_href) {  %>
  <h2 class="Quick_links" id="Quick_Links">Quick Links</h2>
  <ol>
  <% if (found_tag) { 
        for( aPage in resultGuide) { // Tutorials and guides matching
  %>
            <li><a href="<%-aPage.url%>"><%-aPage.title%></a></li>
  <%    }
        for (aTitle in resultCSS) { // CSS entities matching 
  %>
            <li><%- template("cssxref", [resultCSS[aTitle]]) %></li>
  <%    } 
        for (aTitle in resultAPI) { // CSSOM interfaces matching 
  %>
            <li><%- template("domxref", [resultAPI[aTitle]]) %></li>
  <%    } 
    } %>
    <li><a href="<%=s_css_ref_href%>"><%=s_css_ref_title%></a>
<%- template("CSS_Ref_Core") %></li>  
  </ol>
  <%}%>
Revert to this revision