mozilla
Your Search Results

    Template:APIListAlpha

    <%
    // Creates a list of API Interfaces sorted alphabetically
    
    function isInterface(pageSlug) {
        return (pageSlug.indexOf('_') == -1) && (pageSlug != 'Reference');
    }
    
    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 pages = page.subpagesExpand('/en-US/docs/Web/API'); // get subpages, including tags
    var slug = env.slug;
    var locale = env.locale;
    var letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    var html = "";
    
    var numLetters = letters.length;
    var numPages = pages.length;
    var p = 0;
    
    
    for (var i = 0; i < numLetters; i++) {
        var curLetter = letters[i];
        var insertedHeading = false; // Haven't done this letter's heading yet
        
        if (p < numPages) {
            do {
                var tags = pages[p].tags;
                var url = pages[p].url;
                var summary = pages[p].summary;
                var title = pages[p].title;
                
                // skip landing pages
                if (!isInterface(pages[p].slug)) {
                    p++;
                    continue;
                }
    
                var badge = "";
                
                // add badges if needed
                
                if (containsTag(tags, "Non-standard") || containsTag(tags, "Non standard")) {
                    badge = " " + template("NonStandardBadge", ["1"]);
                }
                
                if (containsTag(tags, "Obsolete")) {
                    badge += " " + template("ObsoleteBadge", [1]);
                } else if (containsTag(tags, "Deprecated")) {
                    badge += " " + template("DeprecatedBadge", [1]);
                }
                
                if (containsTag(tags, "Experimental")) {
                    badge += " " + template("ExperimentalBadge", ["1"]);
                }
                
                // Wrap the badges in another span
                
                if (badge.length) badge = '<span class="indexListBadges">' + badge + "</span>";
                        
                if (title[0].toUpperCase() == curLetter) {
                    if (!containsTag(tags, "junk")) {
                        if (!insertedHeading) {
                            html += "<span>" + curLetter + "</span><ul>";
                            insertedHeading = true;
                        }
                        html += '\n<li><span class="indexListRow"><span class="indexListTerm"><code><a href="' + url.replace("en-US", locale) + '" title="' + wiki.escapeQuotes(summary) + '">' + title + '</a></code></span>' + badge + '</span></li>';
                    }
                    p++;
                } else {
                    break;
                }
            } while (p < pages.length);
        }
        html += "\n</ul>\n";
    }
    
    
    %><div class="index">
    <%-html%>
    </div>
    Search for pages that use Template:APIListAlpha to see example use cases and how many pages use this macro.

    Document Tags and Contributors

    Contributors to this page: Sheppy, lmorchard, ethertank, fscholz, teoli
    Last updated by: fscholz,