Inhaltsverzeichnis
keine Gliederung
// 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:"span#description", upload:"div#anchor-files", comments:"div.comments", history:"div.modified", menu:"div.site", options:"div.options", pagetalk:"dd.pagetalk", pagealert:"div#deki-page-alerts", notification:"div.info", title:"div.title", header:"div#header", secure:"div.restricted" }; 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>;