mozilla
Your Search Results

    Template:domxref

    <%
    /* Used for generating cross-references within the Web API documentation.
     * if you specify the API name with parens (ie, "bar()"), the link is to
     * lang/Web/API/Foo/bar but the title is displayed as "bar()" to make it clear it's
     * a function.
     * @param
     *   The path of the page to link to, relative to the Web/API/ documentation path.
     * @param [optional] 
     *   The text to use for the link.  If omitted, the value of the first
     *   parameter will be used
     * @param [optional] 
     *   An anchor to link to on the page. Link text will display as $0.$2 or $1.$2 
     * @param [optional] 
     *   If set, do not put the domxref text in code 
     */
    
    /* get a page's language (Don't use page.language!) */
    var lang = env.locale;
    var api = $0;
    var str = $1 || $0;
    var rtlLocales = ['ar', 'he', 'fa'];
    
    api = api.replace(' ', '_').replace('()', '').replace(/\./g, '/');
    
    // RTL locales
    if (rtlLocales.indexOf(lang) != -1) {
        str = '<bdi>' + str +'</bdi>';
    }
    // Ensure Interfaces are always uppercased in links 
    // (important for red links to create correct new pages)
    api = api.charAt(0).toUpperCase() + api.slice(1);
    
    var URL = "/" + lang + '/docs/Web/API/' + api;
    
    var anch = '';
    
    if ($2) {
      str = str + '.' + $2;
      anch = '#' + $2;
    }
    
    // Now that we have the URL, let's gather the page summary for our tooltip
    
    var page = wiki.getPage(URL);
    var summary = "";
    
    if (!$2) {
        if (page && page.summary) {
            var summary = mdn.escapeQuotes(page.summary);
        } else {
            summary = "The documentation about this has not yet been written; please consider contributing!";
            switch(lang){
                case "zh-CN":
                    summary = "此页面仍未被本地化, 期待您的翻译!";
                    break;
            }
        }
    }
    
    var code = '';
    var endcode = '';
    if (!$3) { code = '<code>'; endcode = '</code>' }
    
    %><a href="<%- URL+anch %>" title="<%-summary%>"><%- code %><%- str %><%- endcode %></a>
    Search for pages that use Template:domxref to see example use cases and how many pages use this macro.

    Document Tags and Contributors

    Last updated by: fscholz,