Template:HideElements

20:42, 6 Dez 2013 geändert von admin | Historie
    Inhaltsverzeichnis
    keine Gliederung

    Version seit 17:14, 21 Nov 2024

    zu dieser Version.

    Zurück zu Versionshistorie.

    Zeige aktuelle Version

    // HideElements
    // by neilw, 2009
    //
    // 1.00    8/3/2009    neilw
    //
    // Usage:  HideElements(elements, byuser)
    //    elements:    list of strings OR "all".  If list of strings, each element may be one of the following
    //        page elements to hide:  "tags", "files", "images", "comments".  If "all", hide all.
    //    byuser:      hide the above elements only for users without write permission on the page
    //
    
    var allowed_elements = { 
    
    tags:"div.pageinfo",
    tagedit:"div#deki-page-tags-edit", 
    newtag:"div.toggleTagsView",
    files:"div#pageFiles", 
    images:"div#anchor-gallery", 
    imagedesc:"div#information", 
    upload:"div#anchor-files",
    comments:"div.comments", 
    history:"div.modified",
    menu:"div.site",
    options:"div.options",
    notification:"div.info",
    title:"div.title",
    header:"div#header", 
    secure:"div.restricted",
    coverview:"div.pagemetalinks",
    usertran:"span.deki-deuce-loggedin"
    };
    
    var elements = $0 ?? $elements;
    var byuser = $1 ?? $byuser ?? false;
    
    var selectors = [];
    
    if (elements != nil) {
        if (elements == "all")
            let selectors = map.values(allowed_elements);
        else if (elements is not list)
            <p> "ERROR: HidePageElements: first argument (ELEMENTS) must be a list of strings" </p>;
        else {
            var errors = [];
            foreach (var e in elements) {
                let e = string.tolower(e);
                if (e is not str || !list.contains(map.keys(allowed_elements), e))
                    let errors ..= [ e ];
                else
                    let selectors ..= [ allowed_elements[e] ];
            }
            if (#errors)
                <div>
                    "ERROR: HidePageElements: bad elements: " .. string.serialize(errors) .. "; allowed elements are:";
                    <ul> foreach (var ae in map.keys(allowed_elements)) <li> ae </li>; </ul>;
                </div>;
        }
    }
    if (#selectors && (!byuser || !wiki.pagepermissions().update))
        <style type="text/css"> string.join(selectors, ",").."{ display:none; }" </style>;
    
    Deki Appliance - Powered by TurnKey Linux