Template:CSSOMRef

<% /*
    
    Parameter : none

    Caution:
        LTR ("de" ...etc) : "&laquo"
        RTL ("he" ...etc) : "&raquo"

*/

var str = mdn.localString({
    'en-US' : '&laquo; <a href="/en-US/docs/Gecko_DOM_Reference">DOM Reference</a> &laquo; CSSOM',
       'de' : '&laquo; <a href="/de/docs/Gecko-DOM-Referenz">DOM Referenz</a> &laquo; CSSOM',
       'es' : '&laquo; <a href="/es/docs/Referencia_DOM_de_Gecko">Referencia DOM</a> &laquo; CSSOM',
       'fr' : '&laquo; <a href="/fr/docs/Référence_du_DOM_Gecko">Référence du DOM</a> &laquo; CSSOM',
       'he' : 'CSSOM &raquo; <a href="/he/docs/Gecko_DOM_Reference">GDOM</a> &raquo;',
       'it' : '&laquo; <a href="/it/docs/Reference_del_DOM_di_Gecko">Reference del DOM</a> &laquo; CSSOM',
       'ja' : '&laquo; <a href="/ja/docs/DOM/DOM_Reference">DOM リファレンス</a> &laquo; CSSOM',
       'ko' : '&laquo; <a href="/ko/docs/Gecko_DOM_Reference">DOM Reference</a> &laquo; CSSOM',
       'pl' : '<a href="/pl/docs/Dokumentacja_Gecko_DOM">&laquo; Dokumentacja DOM</a> &laquo; CSSOM',
    'pt-PT' : '&laquo; <a href="/pt-PT/docs/Referência_do_DOM_Gecko">Referência do DOM</a> &laquo; CSSOM',
    'pt-BR' : '&laquo; <a href="/pt-BR/docs/Referência_do_DOM_Gecko">Referência do DOM</a> &laquo; CSSOM',
    'zh-CN' : '&laquo; <a href="/zh-CN/docs/Gecko_DOM_参考">DOM 参考</a> &laquo; CSSOM'
});

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;
}

function containsAPI(APIList, name) {
    name = name.toLowerCase();
    name = name.split('.')[0];
    for (var i = 0, len = APIList.length; i < len; i++) {
        if (APIList[i].toLowerCase() === name) {
            return 1;
        }
    }
    return 0;
}

var s_api_tag  = 'CSSOM';
var s_api_href = '/' + env.locale + '/docs/Web/API';

var s_api_title_methods = mdn.localString({
  "en-US": "Methods",
  "fr"   : "Méthodes",
  "de"   : "Methoden"
});

var s_api_title_properties = mdn.localString({
  "en-US": "Properties",
  "fr"   : "Propriétés",
  "de"   : "Eigenschaften"
});

var s_api_title_seealso = mdn.localString({
  "en-US": "Related APIs",
  "fr"   : "API connexes",
  "de"   : "Verwandte APIs"
});

var aquo = mdn.localString({
  "en-US": "&laquo;", // "»"
 
  // For RTL locales (ar, he, ...)
  "ar"   : "&raquo;", // "«"
  "he"   : "&raquo;", // "«"
});

/* Find the API Name from the URL: the part after the last / and before the first . */
var pageURL = env.path;
    
var pageFolders = pageURL.split('/');
if (pageFolders) {
    var pageName = pageFolders[pageFolders.length-1]; // We are only interested in the last part
    var mainIF = pageName.split('.')[0];
    var APIList = [];
    APIList.push(mainIF);

    var pageList = page.subpagesExpand(s_api_href);   // Get subpages, including tags
    
    /* List properties of this API */
    var resultProps = [];
    
    /* List methods of this API */
    var resultMethods = [];

    /* List related APIs */
    var resultSeealso = [];

    for (aPage in pageList) {
        if (containsAPI(APIList, pageList[aPage].title)) {
            if (containsTag(pageList[aPage].tags, "Property")) { // We only want properties
                pageList[aPage].domxref = template("domxref", [pageList[aPage].title]);
                resultProps.push(pageList[aPage]);
            }
            
            if (containsTag(pageList[aPage].tags, "Method") &&
                        !containsTag(pageList[aPage].tags, "Constructor")) { // We only want methods
                pageList[aPage].domxref = template("domxref", [pageList[aPage].title]);
                resultMethods.push(pageList[aPage]);
            }
        }
        
        if (containsTag(pageList[aPage].tags, s_api_tag) &&
                    pageList[aPage].title.indexOf('.') === -1 &&
                    pageList[aPage].title !== mainIF) {
            pageList[aPage].domxref = template("domxref", [pageList[aPage].title]);
            resultSeealso.push(pageList[aPage]);
        }
    }
}

var badges = {
    ExperimentalBadge : '<span class="sidebar-icon">' + template("ExperimentalBadge", [1]) + '</span>',
    NonStandardBadge  : '<span class="sidebar-icon">' + template("NonStandardBadge", [1]) + '</span>',
    DeprecatedBadge   : '<span class="sidebar-icon">' + template("DeprecatedBadge", [1]) + '</span>',
    ObsoleteBadge     : '<span class="sidebar-icon">' + template("ObsoleteBadge", [1]) + '</span>',
}

function buildSublist(pages, title) {
    var result = '<li data-default-state="open"><a href="#"><strong>' + title + '</strong></a><ol>';
    
    for (aPage in pages) {
        result += '<li>';
        
        if (containsTag(pages[aPage].tags, 'Experimental')) {
            result += badges.ExperimentalBadge;
        }
        
        if (containsTag(pages[aPage].tags, 'Non-standard') ||
                    containsTag(pages[aPage].tags, 'Non Standard')) {
            result += badges.NonStandardBadge;
        }
        
        if (containsTag(pages[aPage].tags, 'Deprecated')) {
            result += badges.DeprecatedBadge;
        }
        
        if (containsTag(pages[aPage].tags, 'Obsolete')) {
            result += badges.ObsoleteBadge;
        }
        
        result += '<em>' + pages[aPage].domxref + '</em></li>';
    }
    
    result += '</ol></li>';
    
    return result;
}

%><span class="breadcrumbs themeUpdated"><%- str %></span>
<section class="Quick_links" id="Quick_Links">
  <ol>
    <%
    /* Display ancestor chain */
    // TBD: the chain, we only displays the lowest one!
    %>
    <li><strong><%- template("domxref", [mainIF]) %></a></strong></li>
    <% 
    
    /* Display properties */ 
    if (resultProps.length > 0) { 
        %><%-buildSublist(resultProps, s_api_title_properties)%><%
    }
    
    /* Display methods */ 
    if (resultMethods.length > 0) {
        %><%-buildSublist(resultMethods, s_api_title_methods)%><%
    }
    
    /* Display related APIs */
    if (resultSeealso.length > 0) {
        %><%-buildSublist(resultSeealso, s_api_title_seealso)%><%
    }
    %>
  </ol>
</section>
Search for pages that use Template:CSSOMRef to see example use cases and how many pages use this macro.

Document Tags and Contributors

Contributors to this page: ethertank, teoli
Last updated by: teoli,