User:Whiteknight/perpage.js

//Per-Book javascript. //adapted from http://en.wikinews.org/wiki/User:Matt/public/pagecss.js /* Imports stylesheets and script pages that are specific to a given book or namespace. Also, provides links in the form of tabs to the stylesheet and script pages that correspond to the particular page. Allows significant customization for individual pages and individual books. Currently does not support per-namespace stylesheets, or scripts for the main namespace.

var pagejs_base = "User:Whiteknight/Javascripts/"; var nsjs_base = "User:Whiteknight/Javascripts/ns/"; var pagecss_base = "User:Whiteknight/Stylesheets/"; function WKAddPerPageTabs { if(wgPageName.match(pagejs_base) ||    wgPageName.match(pagecss_base)) { var bookpath = "/wiki/" + wgPageName.split("/")[2]; add_toolbox_link(bookpath, 'book', 'ca-gobook'); } else { var scriptpath = "/wiki/" + pagejs_base + wgBookName; var stylepath = "/wiki/" + pagecss_base + wgBookName; add_toolbox_link(stylepath, 'style', 'ca-addstyle'); add_toolbox_link(scriptpath, 'script', 'ca-addscript'); } }

import_style(pagecss_base + wgBookName); import_script(pagejs_base + wgBookName); if(wgCanonicalNamespace != "") import_script(nsjs_base + wgCanonicalNamespace); $(WKAddPerPageTabs);