User:TransporterMan/vector.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
![]() | The accompanying .css page for this skin can be added at User:TransporterMan/vector.css. |
//importScript("User:Gerbrant/hidePane.js");
//importScript('User:TheDJ/Gadget-HotCat.js');
// Storage:
// importScript('User:Twp/tineye.js');
// importScript("User:Blue-Haired Lawyer/footnote popups.js");
// importScript('User:Lupin/recent2.js');
//importScript('User:TheJosh/Scripts/NewPagePatrol.js');
importScript('User:Ais523/watchlistnotifier.js');
importScript('User:Steven Zhang/DRW.js');
//prevent wikiED from jumping down and turn off duplicate warnings
var wikEdConfig = { 'scrollToEdit': false, 'scrollToPreview': false, 'doCloneWarnings': false };
//Modification by SDG of ("User:PleaseStand/subsearch.js") to search current page and subpages, not just subpages
// line below was: textbox.value += " prefix:" + nsPrefix + wgTitle + "/";
// Script will not work, author says, in Vector
/*global window, addOnloadHook, addHandler, SubsearchJsConfig,
wgNamespaceNumber, wgFormattedNamespaces, wgTitle*/
// Global variables
var SubsearchJsCheckbox;
// Event handler called when a search is performed
function SubsearchJsSubmitHandler() {
// Local variables
var textbox; var nsPrefix = "";
if(SubsearchJsCheckbox.checked) {
// Note that the main namespace (0) has no prefix.
if(mw.config.get('wgNamespaceNumber')) {
nsPrefix = mw.config.get('wgFormattedNamespaces')[mw.config.get('wgNamespaceNumber')] + ":";
}
textbox = window.document.getElementById("searchInput");
textbox.value += " prefix:" + nsPrefix + mw.config.get('wgTitle');
SubsearchJsCheckbox.checked = false;
}
return true;
}
$(function () {
// Local variables
var label; var labelText; var searchform;
try {
if(typeof SubsearchJsConfig != "object") {
// Default configuration
SubsearchJsConfig = {
text: "\u00a0Subpages only",
tooltip: "Search only the subpages of the current page",
accesskey: "",
style: "display: block; font-size: 80%; margin-top: 0.4em;",
namespaces: // Update the following line from http://en.wikipedia.org/w/api.php?action=query&meta=siteinfo&siprop=namespaces&format=json
{"query":{"namespaces":{"-2":{"id":-2,"*":"Media","canonical":"Media"},"-1":{"id":-1,"*":"Special","canonical":"Special"},"0":{"id":0,"*":"","content":""},"1":{"id":1,"*":"Talk","subpages":"","canonical":"Talk"},"2":{"id":2,"*":"User","subpages":"","canonical":"User"},"3":{"id":3,"*":"User talk","subpages":"","canonical":"User talk"},"4":{"id":4,"*":"Wikipedia","subpages":"","canonical":"Project"},"5":{"id":5,"*":"Wikipedia talk","subpages":"","canonical":"Project talk"},"6":{"id":6,"*":"File","canonical":"File"},"7":{"id":7,"*":"File talk","subpages":"","canonical":"File talk"},"8":{"id":8,"*":"MediaWiki","canonical":"MediaWiki"},"9":{"id":9,"*":"MediaWiki talk","subpages":"","canonical":"MediaWiki talk"},"10":{"id":10,"*":"Template","subpages":"","canonical":"Template"},"11":{"id":11,"*":"Template talk","subpages":"","canonical":"Template talk"},"12":{"id":12,"*":"Help","subpages":"","canonical":"Help"},"13":{"id":13,"*":"Help talk","subpages":"","canonical":"Help talk"},"14":{"id":14,"*":"Category","canonical":"Category"},"15":{"id":15,"*":"Category talk","subpages":"","canonical":"Category talk"},"100":{"id":100,"*":"Portal","subpages":"","canonical":"Portal"},"101":{"id":101,"*":"Portal talk","subpages":"","canonical":"Portal talk"},"108":{"id":108,"*":"Book","subpages":"","canonical":"Book"},"109":{"id":109,"*":"Book talk","subpages":"","canonical":"Book talk"}}}}
};
}
// Make sure the current page's namespace has subpages turned on.
if(!SubsearchJsConfig.namespaces.query.namespaces[mw.config.get('wgNamespaceNumber')].
hasOwnProperty("subpages")) {
return false;
}
// Add the checkbox if so.
label = window.document.createElement("label");
label.setAttribute("title", SubsearchJsConfig.tooltip);
label.setAttribute("style", SubsearchJsConfig.style);
SubsearchJsCheckbox = window.document.createElement("input");
SubsearchJsCheckbox.setAttribute("type", "checkbox");
SubsearchJsCheckbox.setAttribute("accesskey", SubsearchJsConfig.accesskey);
label.appendChild(SubsearchJsCheckbox);
labelText = window.document.createTextNode(SubsearchJsConfig.text);
label.appendChild(labelText);
searchform = window.document.getElementById("searchform");
searchform.appendChild(label);
// Add the submit handler to the search form.
addHandler(searchform, "submit", SubsearchJsSubmitHandler);
} catch(e) {}
return false;
});
//Modification by SDG of ("User:PleaseStand/subsearch.js") ends