User:PerfektesChaos/js/menuSwitcher/r.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. |
This user script seems to have a documentation page at User:PerfektesChaos/js/menuSwitcher/r. |
/// PerfektesChaos/js/menuSwitcher/r.js
/// 2024-06-21 PerfektesChaos@de.wikipedia
/// Fingerprint:#0#24120EB9#
/// @license:CC-by-sa/4.0 GPLv3
///<nowiki>
(function(mw,$){
/// Gadget for configurable Edittools
"use strict";
var Version=1.95,Sign="menuSwitcher",Signature="ext.gadget."+Sign,Support="w:en:User:PerfektesChaos/js/"+Sign,CONFIG={maxItems:99},EDIT={},GUI={css:{"background-color":"#FFFFFF",
"clear":"both",
"color":"#000000",
"font-style":"normal",
"font-weight":"normal",
"line-height":"1.2rem"}},
REMIND={};
function fire(){
var rls;
if(mw.loader.getState(Signature)!=="ready"){
rls={};
rls[Signature]="ready";
mw.loader.state(rls);
CONFIG.first();
mw.hook(Signature+".config").add(CONFIG.fired);
mw.hook(Signature+".help").add(CONFIG.forward);
$(document).ready(GUI.fire);}}
CONFIG.facility=function(access,assign){
var cnf,config,def;
switch(access){
case "help":
def={"background-color":"#008000",
"show":"?",
"start":false,
"suite":"$helpers",
"support":"Help"};
break;
case "hide":
def={"background-color":"#FF0000",
"show":"X",
"start":"fade",
"suite":"$hiders",
"support":"Hide"};
break;}
if(def){
switch(typeof assign){
case "boolean":
cnf={mode:(assign?1:0)};
break;
case "object":
cnf=assign||{};
break;
case "string":
if(access==="help"){
cnf={mode:(assign?1:0),service:(assign?assign:false)};
}else{
cnf={};}
break;}
if(typeof CONFIG[access]!=="object"){
CONFIG[access]={service:false,start:def.start,suite:def.suite};}
config=CONFIG[access];
if(typeof cnf["class"]==="string"&&cnf["class"]){
config["class"]=cnf["class"];}
if(typeof cnf.css==="object"&&cnf.css){
config.css=cnf.css;
}else{
config.css={"background-color":def["background-color"],
"border-color":"#808080",
"border-radius":"4px",
"border-style":"solid",
"border-width":"1px",
"color":"#FFFFFF",
"display":"inline-block",
"font-size":"0.8rem",
"font-weight":"bold",
"margin":"0.5em",
"padding":"2px"};}
switch(access){
case "help":
if(typeof cnf.service==="string"){
config.service=cnf.service;
config.mode=1;}
break;
case "hide":
if(typeof cnf.less==="boolean"){
config.less=cnf.less;
}else if(typeof config.less!=="boolean"){
config.less=false;}
if(config.less&&typeof REMIND.fetch("less")!=="boolean"){
if(CONFIG.live&&GUI.live){
GUI.fade();
}else{
REMIND.feed("less",true);}}
break;}
if(typeof cnf.mode==="number"){
config.mode=cnf.mode;
}else{
config.mode=1;}
if(typeof cnf.show==="string"&&cnf.show){
config.show=cnf.show;
}else{
config.show=def.show;}
if(typeof cnf.support==="string"&&cnf.support){
config.support=cnf.support;
}else{
config.support=def.support;}
if(CONFIG.live&&GUI.live){
GUI.facility(access);}}
};
CONFIG.feed=function(apply){
var last,suitable;
if(typeof apply.create==="object"&&apply.create&&typeof apply.system==="string"){
suitable="feed_"+apply.system;
if(typeof CONFIG[suitable]==="function"&&CONFIG.fit(apply)){
if(typeof apply.last==="boolean"){
last=apply.last;}
CONFIG[suitable](apply.create,last);}
}else if(typeof apply.top==="object"&&apply.top&&typeof apply.top.length==="number"){
CONFIG.feed_existing(apply.top);}
};
CONFIG.feed_builtin=function(apply,after){
var e,i,s;
if(typeof apply.length==="number"){
for(i=0;i<apply.length;i++){
e=apply[i];
if(typeof e==="object"&&e){
if(typeof e.selector==="string"&&e.selector){
s=e.selector;
}else{
s=false;}
CONFIG.feeder(s,"builtin",e,after);}}
GUI.fresh(true);}
};
CONFIG.feed_charinsert=function(apply){
if(CONFIG.learn&&typeof apply.selector==="string"){
CONFIG.exist=apply;
GUI.flip();}
};
CONFIG.feed_existing=function(apply){
var i,live,s;
for(i=0;i<apply.length;i++){
s=apply[i];
if(typeof s==="string"&&s){
s=CONFIG.follower(s);
if(typeof CONFIG.groups.panels[s]==="object"){
CONFIG.follow(s,CONFIG.groups.panels[s],false);
live=true;}}}
if(live){
GUI.fresh(true);}
};
CONFIG.feed_stringArrayObject=function(apply,after){
var e,s;
for(s in apply){
e=apply[s];
if(typeof e==="object"&&e&&typeof e.length==="number"){
CONFIG.feeder(s,"stringArray",e,after);}}
GUI.fresh(true);
};
CONFIG.feed_stringArrays=function(apply,after){
var e,i,s;
if(typeof apply.length==="number"){
for(i=0;i<apply.length;i++){
e=apply[i];
if(typeof e==="object"&&e&&typeof e.length==="number"){
s=e[0];
e=e[1];
if(typeof s==="string"&&s&&typeof e==="object"&&e&&typeof e.length==="number"){
CONFIG.feeder(s,"stringArray",e,after);}}}
GUI.fresh(true);}
};
CONFIG.feeder=function(assign,arranged,apply,after){
var panel={contentmodel:true,system:arranged,$panel:false},s;
if(arranged==="builtin"){
for(s in apply){
panel[s]=apply[s];}
}else{
panel.def=apply;}
if(CONFIG.fit(panel)){
panel.selector=assign;
CONFIG.follow(assign,panel,after);}
};
CONFIG.fired=function(apply){
var live;
switch(typeof apply){
case "boolean":
CONFIG.live=apply;
GUI.fresh();
break;
case "object":
if(apply){
if(typeof apply.live==="boolean"){
CONFIG.live=apply.live;}
if(typeof apply.position==="object"&&apply.position&&typeof apply.position.length==="number"){
CONFIG.furnish(apply.position);}
if(typeof apply.client==="object"&&apply.client){
EDIT.client=apply.client;}
if(typeof apply.css==="object"&&apply.css){
GUI.furnish(apply.css);}
if(typeof apply.hide==="object"&&apply.hide||typeof apply.hide==="boolean"){
CONFIG.facility("hide",apply.hide);}
if(typeof apply.help==="object"&&apply.help||typeof apply.help==="string"||typeof apply.help==="boolean"){
CONFIG.facility("help",apply.help);}
if(typeof apply.defs==="object"&&apply.defs){
CONFIG.feed(apply.defs);}
if(typeof apply.top==="object"&&apply.top&&typeof apply.top.length==="number"){
CONFIG.feed_existing(apply.top);}
if(typeof apply.select==="string"&&apply.select){
live=true;
REMIND.feed("select",apply.select);}
if(live||typeof apply.live==="boolean"){
GUI.fresh(live);}}
break;}
};
CONFIG.first=function(){
var env=mw.config.get(["wgAction","wgUserName"]);
CONFIG.css=false;
CONFIG.defs=false;
CONFIG.exist=false;
CONFIG.groups=false;
CONFIG.pos=false;
CONFIG.items=0;
CONFIG.nsn=env.wgNamespaceNumber;
CONFIG.last=false;
CONFIG.learn=(env.wgAction!=="view"||CONFIG.nsn<0);
CONFIG.live=true;
GUI.live=false;
GUI.$wrappers=false;
};
CONFIG.fit=function(ask){
var i,r,source;
switch(typeof ask.contentmodel){
case "boolean":
case "string":
r=ask.contentmodel;
break;
case "object":
if(ask.contentmodel&&typeof ask.contentmode.length==="number"){
r=ask.contentmodel;}
default:
r=false;}
if(typeof r!=="boolean"){
if(typeof CONFIG.nsn!=="number"){
CONFIG.nsn=mw.config.get("wgNamespaceNumber");}
switch(CONFIG.nsn){
case-1:
source="wikitext";
break;
default:
if(typeof CONFIG.source!=="string"){
CONFIG.source=mw.config.get("wgPageContentModel");}
source=CONFIG.source;}
if(typeof r==="object"){
for(i=r.length-1;i>=0;i--){
if(r[i]===source){
r=true;
break;
}else if(!i){
r=false;}}
}else{
r=(r===source);}}
return r;
};
CONFIG.follow=function(assign,apply,after){
var s=CONFIG.follower(assign),panels=CONFIG.groups.panels,old,other;
apply.sel=s;
if(typeof panels[s]==="object"){
old=panels[s];
if(typeof after==="boolean"){
if(old.before){
other=panels[old.before];
other.behind=old.behind;
if(!old.behind){
CONFIG.groups.stop=other.sel;}}
if(old.behind){
other=panels[old.behind];
other.before=old.before;
if(!old.before){
CONFIG.groups.start=other.sel;}}
if(after){
if(CONFIG.groups.stop){
other=panels[CONFIG.groups.stop];
other.behind=s;}
apply.before=CONFIG.groups.stop;
apply.behind=null;
CONFIG.groups.stop=s;
}else{
if(CONFIG.groups.start){
other=panels[CONFIG.groups.start];
other.before=s;}
apply.behind=CONFIG.groups.start;
apply.before=null;
CONFIG.groups.start=s;}
}else{
apply.before=old.before;
apply.behind=old.behind;}
}else if(CONFIG.items<CONFIG.maxItems){
CONFIG.items++;
apply.item=CONFIG.items;
if(CONFIG.groups.start){
if(after){
old=panels[CONFIG.groups.stop];
old.behind=s;
CONFIG.groups.stop=s;
apply.before=old.sel;
apply.behind=null;
}else{
old=panels[CONFIG.groups.start];
old.before=s;
CONFIG.groups.start=s;
apply.before=null;
apply.behind=old.sel;}
}else{
CONFIG.groups.start=s;
CONFIG.groups.stop=s;
apply.before=null;
apply.behind=null;}}
panels[s]=apply;
return apply.item;
};
CONFIG.follower=function(assign){
var r;
if(!CONFIG.groups){
CONFIG.groups={panels:{},start:null,stop:null};}
if(typeof assign==="string"){
r=assign.replace(/(\S)\s*$/,"$1")
.replace(/^\s*(\S)/,"$1");}
if(!r){
r="UNKNOWN-"+(CONFIG.items+1);}
return r;
};
CONFIG.forward=function(auxilary){
CONFIG.facility("help",auxilary);
};
CONFIG.furnish=function(apply){
var e,i,v;
for(i=apply.length-1;i>=0;i--){
e=apply[i];
if(e){
v=false;
switch(typeof e){
case "object":
if(typeof e.selector==="string"&&e.selector){
v={$parents:false,sel:e.selector};
}else if(typeof e.jQuery==="object"&&e.jQuery&&typeof e.jQuery.jQuery==="string"){
v={$parents:e.jQuery};}
if(v){
if(typeof e.lead==="boolean"){
v.lead=e.lead;
}else{
v.lead=false;}}
break;
case "string":
v={lead:false,sel:e};
break;}
if(v){
CONFIG.pos=CONFIG.pos||[];
if(typeof e.last==="boolean"&&e.last){
CONFIG.pos.push(v);
}else{
CONFIG.pos.pop(v);}}}}
if(typeof CONFIG.pos==="object"){
GUI.furnish();}
};
EDIT.fasten=function(around,arglist){
var r=around,got/*,k,luxury*/;
if(r){
if(typeof this.reWSbeg!=="object"){
this.reWSbeg=new RegExp("^\\s+");
this.reWSend=new RegExp("\\S(\\s+)$");}
got=this.reWSbeg.exec(r);
if(got){
if(typeof arglist.pre==="string"){
arglist.pre=got[0]+arglist.pre;
}else{
arglist.pre=got[0];}
r=r.substr(got[0].length);}
got=this.reWSend.exec(r);
if(got){
if(typeof arglist.post==="string"){
arglist.post=arglist.post+got[1];
}else{
arglist.post=got[1];}
r=r.substr(0,r.length-got[1].length);}}
return r;
};
EDIT.fiat=function($area,action,arglist){
if(typeof EDIT.client==="object"&&typeof EDIT.client.lfDoubled==="boolean"&&EDIT.client.lfDoubled){
this.fossile($area,action,arglist);
}else{
$area.textSelection(action,arglist);}
};
EDIT.fossile=function($area,action,arglist){
var textarea=$area.get(0),iBeg=textarea.selectionStart||0,iEnd=textarea.selectionEnd||iBeg,story=$area.val(),r,sel,sub,suffix;
if(typeof this.reCRLF!=="object"){
this.reCRLF=new RegExp("\r?\n","g");}
if(action==="encapsulateSelection"){
story=story.replace(this.reCRLF,"\r\n");
sub=story.slice(0,iEnd).replace(this.reCRLF,"\n");
iBeg=story.slice(0,iBeg).replace(this.reCRLF,"\n").length;
suffix=story.slice(iEnd);
story=sub.slice(0,iBeg);
if(!arglist.replace){
sel=sub.slice(iBeg);
sel=this.fasten(sel,arglist);}
if(typeof arglist.pre==="string"){
story=story+arglist.pre;}
if(arglist.replace){
if(typeof arglist.peri==="string"){
story=story+arglist.peri;}
}else{
story=story+sel;}
if(typeof arglist.post==="string"){
story=story+arglist.post;}
iEnd=story.replace(this.reCRLF,"\r\n").length;
story=story+suffix;
$area.val(story);
textarea.selectionEnd=iEnd;
textarea.selectionStart=iBeg;
$area.focus();
textarea.selectionEnd=iEnd;
textarea.selectionStart=iEnd;}
return r;
};
GUI.facet=function($area,assign){
$area.addClass(Sign+"-panel "+Sign+"-panel-"+assign);
};
GUI.facility=function(access){
var config=CONFIG[access],i,live,$btn,$collection;
if(typeof config.$btn!=="object"&&config.mode>0){
config.$btn=$("<a>");
config.$btn.addClass(Sign+"-"+access+"-button").attr({"href":"#"+Sign+"-0",
"title":config.support}).css(config.css).css({"text-decoration":"none"})
.text(config.show);
if(config["class"]==="string"){
config.$btn.addClass(config["class"]);}
if(config.support==="string"){
config.$btn.attr({"title":config.support});}
if(config.service){
config.$btn.attr({"href":config.service,
"target":"_blank"});}}
if(GUI.$wrappers&&GUI.$wrappers.length){
$collection=GUI[config.suite];
$collection.empty();
live=(config.mode>0);
if(live&&access==="hide"){
live=(REMIND.feed("less")!==true);}
if(live){
$btn=config.$btn.clone();
if(config.start){
$btn.click(GUI[config.start]);}
$collection.eq(0).append($btn);
for(i=1;i<$collection.length;i++){
$btn=config.$btn.clone();
if(config.start){
$btn.click(GUI[config.start]);}
$collection.eq(i).append($btn);}}}
};
GUI.factory_builtin=function(assigned){
var $r=$("<div>"),def,e,i,label,link,low,s,space,src,$e,$img;
if(typeof assigned["class"]==="string"){
$r.addClass(assigned["class"]);}
if(typeof assigned.style==="string"){
$r.attr({"style":assigned.style});}
if(typeof assigned.ltr==="boolean"){
$r.attr({"dir":(assigned.ltr?"ltr":"rtl")});}
if(typeof assigned.lang==="string"){
$r.attr({"lang":assigned.lang});}
if(typeof assigned.support==="string"){
$r.attr({"title":assigned.support});}
if(typeof assigned.def==="object"&&assigned.def&&typeof assigned.def.length==="number"){
def=assigned.def;
for(i=0;i<def.length;i++){
e=def[i];
s=false;
if(typeof e==="object"&&e){
if(typeof e.fun==="function"){
e.id=i;
link=true;
}else{
if(typeof e.sample==="string"&&e.sample){
s=e.sample;}
if(typeof e.start==="string"&&e.start){
s=e.start;
if(typeof e.suffix==="string"&&e.suffix){
s=s+e.suffix;}
}else if(typeof e.suffix==="string"&&e.suffix){
s=e.suffix;}
link=(s?true:false);}
if(typeof e.show==="string"&&e.show){
s=e.show;
low=false;
}else{
low=true;}
if(typeof e.src==="string"&&e.src){
s=s||true;}
switch(typeof e.contentmodel){
case "boolean":
case "object":
case "string":
if(!CONFIG.fit(e)){
s=false;}
break;}}
if(s){
if(link){
if(!CONFIG.defs){
CONFIG.defs=[];}
$e=$("<a>");
$e.attr({"data-id":CONFIG.defs.length,
"href":"#"}).click(GUI.fiat);
CONFIG.defs.push(e);
}else{
$e=$("<span>");}
if(typeof e.src==="string"){
if(e.src.charCodeAt(0)===47&&e.src.charCodeAt(0)!==47){
src=e.src;
}else{
if(typeof CONFIG.reURL!=="object"){
CONFIG.reURL=new RegExp("^(?:https?:)?//[^/]*\\.(?:mediawiki|wik(?:i(?:books|data|media|news|pedia|quote|source|species|tech|versity|voyage)|tionary))\\.org/");}
if(CONFIG.reURL.test(e.src)){
src=e.src;
}else{
src=false;}}
if(src){
$img=$("<img>");
$img.attr({"src":src});
$e.prepend($img);
label=true;}}
if(typeof s==="string"){
if(low){
$e.text(s);
label=true;
}else{
$e.html(s);
label=$e.text();}}
if(label){
switch(typeof e.style){
case "string":
$e.attr({"style":e.style});
break;
case "object":
$e.css(e.style);
break;}
if(typeof e["class"]==="string"){
$e.addClass(e["class"]);}
if(typeof e.support==="string"){
$e.attr({"title":e.support});}
if(link){
$e.css({"text-decoration":"none",
"white-space":"nowrap"});}
if($r){
switch(typeof e.space){
case "string":
space=e.space;
break;
case "number":
String.fromCharCode(e.space);
break;
default:
space=" ";}
}else{
space=false;}
$r=($r||$("<div>"));
if(GUI.ltr){
if(space&&link){
$r.append(space);}
$r.append($e);
}else{
if(space&&link){
$r.prepend(space);}
$r.prepend($e);}}}}}
return $r;
};
GUI.factory_stringArray=function(assigned){
var elem,elt,i,j,lead,panel,unit,$r;
if(typeof assigned.def==="object"&&assigned.def&&typeof assigned.def.length==="number"){
panel={def:[]};
for(i=0;i<assigned.def.length;i++){
if(i&&!lead){
lead=false;
panel.def.push({show:"  •  ",style:{"font-weight":"bold"}});}
unit=assigned.def[i];
if(typeof unit==="object"&&unit){
if(typeof unit.length==="number"){
for(j=0;j<unit.length;j++){
elem=unit[j];
switch(typeof elem){
case "string":
panel.def.push({start:elem});
break;
case "object":
if(elem&&typeof elem.length==="number"){
elt={};
if(typeof elem[0]==="string"&&elem[0]){
elt.start=elem[0];}
if(typeof elem[1]==="string"&&elem[1]){
elt.suffix=elem[1];}
if(typeof elem[2]==="string"&&elem[2]){
elt.sample=elem[2];}
if(typeof elem[3]==="string"&&elem[3]){
elt.support=elem[3];}
if(typeof elem[4]==="string"&&elem[4]){
elt.show=elem[4];}
panel.def.push(elt);}
break;}}
}else if(!i){
lead=true;
if(typeof unit["class"]==="string"&&unit["class"]){
panel["class"]=unit["class"];}
if(typeof unit["font-size"]==="string"&&unit["font-size"]){
panel.style="font-size:"+unit["font-size"];}
if(typeof unit.lang==="string"&&unit.lang){
panel.lang=unit.lang;}
if(typeof unit.ltr==="boolean"){
panel.ltr=unit.ltr;}}}}
if(panel.def.length){
$r=GUI.factory_builtin(panel);}}
return $r;
};
GUI.faculty=function(){
var e,i,s,$o;
if(GUI.$poly){
GUI.$poly.empty();
}else if(CONFIG.groups){
GUI.$poly=$("<select>");
GUI.$poly.css({"display":"inline",
"float":(GUI.ltr?"left":
"right"),
"margin-bottom":"0.5em",
"vertical-align":"middle"});
if(GUI.ltr){
GUI.$poly.css({"float":"left",
"margin-right":"0.5em"});
}else{
GUI.$poly.css({"float":"right",
"margin-left":"0.5em"});}
GUI.$wrappers.eq(0).prepend(GUI.$poly);
for(i=1;i<GUI.$wrappers.length;i++){
GUI.$wrappers.eq(i).prepend(GUI.$poly.clone());}
GUI.$poly=GUI.$wrappers.children("select");
if(typeof CONFIG.help==="object"){
GUI.facility("help");}
if(typeof CONFIG.hide==="object"){
GUI.facility("hide");}
GUI.$poly.change(GUI.fold).click(GUI.fold);}
if(CONFIG.groups){
s=CONFIG.groups.start;
do{
e=CONFIG.groups.panels[s];
if(e&&(CONFIG.learn||typeof e.low!=="boolean"||e.low)){
$o=$("<option>");
$o.attr("data-item",e.item).text(e.sel);
GUI.$poly.eq(0).append($o);
for(i=1;i<GUI.$poly.length;i++){
GUI.$poly.eq(i).append($o.clone());}
s=e.behind;}
}while(e&&s);
if(CONFIG.learn){
s=REMIND.fetch("select");
if(s){
GUI.select=s;
GUI.$poly.prop("value",s);}}
if(!REMIND.fetch("less")){
GUI.$poly.trigger("click");}}
};
GUI.fade=function(action){
var $btn,$parent;
if(action){
$btn=$(action.target).parent();
$parent=$btn.parent();
if(CONFIG.hide.mode>1){
$parent.hide();
}else{
$parent.find("div").hide();}
}else if(GUI.$wrappers&&GUI.$wrappers.length){
GUI.$wrappers.find("."+Sign+"-panel ").hide();
if(GUI.$hiders){
GUI.$hiders.empty();}}
REMIND.feed("less",true);
};
GUI.fetch=function(){
if(GUI.$texts){
GUI.$texts.off("blur",GUI.fetch);
$(window.document).off("focus","textarea,input:text",GUI.focus);}
GUI.$texts=$("textarea,input:text").not("*:disabled").not('*[type="hidden"]')
.not("#wpAntispam");
if(GUI.$texts.length){
$(window.document).on("focus","textarea,input:text",GUI.focus);
GUI.$texts.on("blur",GUI.fetch);}
};
GUI.fiat=function(event){
var $item=$(event.target),item=parseInt($item.data("id"),10),def=CONFIG.defs[item],params,sel,suffix,veFrag,veSurface,veSModel,$elt;
if(def){
if(typeof window.ve==="object"&&window.ve&&typeof window.ve.init==="object"&&window.ve.init&&typeof window.ve.init.target==="object"&&window.ve.init.target&&window.ve.init.target.active){
veSurface=window.ve.init.target.getSurface();
veSModel=veSurface.getModel();
veFrag=veSModel.getFragment();
if(!veFrag.isNull()){
if(typeof def.low==="boolean"&&def.low){
}else if(typeof def.fun==="function"){
sel=def.fun(def,event,false,veSModel);
if(typeof sel!=="string"){
sel=false;}
}else{
if(typeof def.start==="string"){
sel=def.start;}
if(typeof def.suffix==="string"){
suffix=def.suffix;}}
if(event.ctrlKey){
veFrag.remove();}
if(typeof def.leave==="boolean"&&!def.leave&&typeof def.sample==="string"){
sel=def.sample;
veFrag.remove();
suffix=false;}
if(sel){
veFrag.insertContent(sel);}
if(suffix){
veFrag.collapseToEnd().insertContent(suffix);}}
}else{
if(GUI.received){
$elt=$(GUI.received);
}else{
$elt=GUI.$texts.eq(0);}
if($elt.length){
if(typeof def.fun==="function"){
params=def.fun(def,event,$elt);
switch(typeof params){
case "object":
break;
case "string":
params={peri:params,replace:true};
break;
default:
params=false;}
}else if(typeof def.leave==="boolean"&&!def.leave){
if(typeof def.sample==="string"){
params={peri:def.sample,replace:true};}
}else{
params={replace:(event.ctrlKey?true:false)};
if(typeof def.start==="string"){
params.pre=def.start;}
if(typeof def.suffix==="string"){
params.post=def.suffix;}
if(typeof def.sample==="string"){
sel=$elt.textSelection("getSelection");
}else{
sel=!params.replace;
def.sample="";}
if(sel){
if(typeof sel!=="string"){
sel=$elt.textSelection("getSelection");}
params.peri=EDIT.fasten(sel,params);
params.replace=true;
}else{
params.peri=def.sample;}
if(typeof def.lonely==="boolean"){
params.ownline=true;}}
if(params){
EDIT.fiat($elt,"encapsulateSelection",params);}}}}
if(typeof event.preventDefault==="function"){
event.preventDefault();}
if(typeof event.stopPropagation==="function"){
event.stopPropagation();}
};
GUI.finished=function(about){
mw.hook(Signature+".ready").fire({doc:"[["+Support+"]]",state:about,type:Signature,vsn:Version,fire:CONFIG.fired});
};
GUI.fire=function(){
if(CONFIG.live){
if(typeof GUI.live==="boolean"&&!GUI.live){
GUI.$texts=false;
GUI.fetch();
if(GUI.$texts.length){
GUI.live=true;
GUI.ltr=($("html").attr("dir")!=="rtl");
GUI.received=false;
GUI.select=false;
GUI.$poly=false;
GUI.$wrappers=false;
GUI.flip();
mw.loader.using(["user","user.options","mediawiki.user","jquery.textSelection"],GUI.fired);}}
}else if(typeof GUI.live!=="boolean"||!GUI.live){
GUI.fired();}
};
GUI.fired=function(){
var say;
if(typeof GUI.live!=="boolean"){
GUI.live=false;}
if(CONFIG.live){
say="built";
}else{
say="biocked";}
GUI.fresh(true);
GUI.finished(say);
};
GUI.flip=function(){
var i,k,s,$e,$groups,$previous;
if(GUI.live&&CONFIG.exist&&CONFIG.pos&&CONFIG.live){
$previous=$(CONFIG.exist.selector);
if($previous.length===1){
$previous.hide();
GUI.furnish();
if(GUI.$wrappers){
if(typeof CONFIG.exist.segments==="string"&&CONFIG.exist.segments){
s=$previous.attr("title");
if(s){
GUI.$wrappers.attr("title",s);}
$groups=$previous.find(CONFIG.exist.segments);
for(i=0;i<$groups.length;i++){
$e=$groups.eq(i);
$e.hide();
k=CONFIG.follow($e.attr("title")||$e.attr("id"),{$panels:[$e]},true);
GUI.facet($e,k);
GUI.$wrappers.append($e);}
$previous.empty();}
}else{
$previous.show();}}
GUI.fresh(true);
CONFIG.exist=false;}
};
GUI.focus=function(event){
GUI.received=event.target;
};
GUI.fold=function(event){
var $poly=$(event.target),sel=$poly.prop("value"),$item=$poly.find(":selected"),index=$item.data("item"),sign="."+Sign+"-panel",signX=sign+"-"+index,$parent=$poly.parent(),$panels=$parent.children(sign),$panel=$parent.find(signX),panel,shift;
if(CONFIG.learn&&GUI.select&&typeof CONFIG.groups.panels[GUI.select]==="object"){
GUI.select=sel;
REMIND.feed("select",sel);}
$panels.not(signX).hide();
if($panel.length){
$panel.show();
$parent.find("."+Sign+"-hide").show();
}else{
panel=CONFIG.groups.panels[sel];
if(typeof panel==="object"){
if(panel.$panel){
$panel=panel.$panel.clone().show();
}else{
shift="factory_"+panel.system;
if(typeof GUI[shift]==="function"){
$panel=GUI[shift](panel);
if($panel){
GUI.facet($panel,index);
panel.$panel=$panel;}}}
if($panel){
$parent.append($panel);}}}
if(typeof REMIND.fetch("less")==="boolean"){
REMIND.feed("less",false);}
};
GUI.fresh=function(apply){
GUI.fire();
GUI.furnish();
if(GUI.$wrappers){
if(CONFIG.live){
if(apply){
GUI.faculty();}
GUI.$wrappers.show();
}else{
GUI.$wrappers.hide();}}
};
GUI.furnish=function(appearance){
var e,i,j,k,m,seq,$wrap;
if(GUI.live&&CONFIG.live&&CONFIG.pos&&!GUI.$wrappers){
for(i=0;i<CONFIG.pos.length;i++){
e=CONFIG.pos[i];
if(!e.$parents){
e.$parents=$(e.sel);}
m=e.$parents.length;
if(m){
GUI.$wrappers=$("<div>");
GUI.$wrappers.addClass(Sign).css(GUI.css);
GUI.$helpers=$("<div>");
GUI.$helpers.addClass(Sign+"-help").attr({"id":Sign+"-0"})
.css({"float":(GUI.ltr?"right":
"left")});
GUI.$hiders=$("<div>");
GUI.$hiders.addClass(Sign+"-hide").attr({"id":Sign+"-1"})
.css({"float":(GUI.ltr?"right":
"left")});
seq=(e.lead?"before":"after");
e.$parents.eq(0)[seq](GUI.$wrappers);
for(k=1;k<m;k++){
$wrap=GUI.$wrappers.clone();
j=k+k;
$wrap.append(GUI.$helpers.clone()).attr({"id":Sign+"-"+j});
j++;
$wrap.append(GUI.$hiders.clone()).attr({"id":Sign+"-"+j});
e.$parents.eq(k)[seq]($wrap);}
GUI.$wrappers.append(GUI.$hiders);
GUI.$wrappers.append(GUI.$helpers);
if(m>1){
GUI.$wrappers=$("."+Sign);
GUI.$helpers=$("."+Sign+"-help");
GUI.$hiders=$("."+Sign+"-hide");}
mw.hook(Signature+".created").fire(GUI.$wrappers);
break;}}}
if(appearance){
CONFIG.css=appearance;}
if(CONFIG.css&&GUI.$wrappers){
GUI.$wrappers.css(CONFIG.css);}
};
REMIND.feed=function(sign,val){
var webSs;
if(typeof REMIND.o!=="object"){
REMIND.fetch("");}
REMIND.o[sign]=val;
if(typeof window.sessionStorage==="object"){
webSs=window.sessionStorage;
if(webSs&&typeof webSs.setItem==="function"){
try{
if(typeof REMIND.w!=="object"){
REMIND.w={};}
REMIND.w[REMIND.fragment()]=REMIND.o;
webSs.setItem(REMIND.full(),JSON.stringify(REMIND.w));
}catch(e){
}}}
};
REMIND.fetch=function(sign){
var got,r,webSs;
if(typeof REMIND.o!=="object"&&typeof window.sessionStorage==="object"){
webSs=window.sessionStorage;
if(webSs&&typeof webSs.getItem==="function"){
try{
got=JSON.parse(webSs.getItem(REMIND.full()));
if(typeof got==="object"&&got){
REMIND.w=got;
if(typeof got[REMIND.fragment()]==="object"){
REMIND.o=got[REMIND.sub];}}
}catch(e){
}}}
if(typeof REMIND.o!=="object"){
REMIND.o={};}
if(typeof REMIND.o[sign]!=="undefined"){
r=REMIND.o[sign];}
return r;
};
REMIND.fragment=function(){
if(typeof REMIND.sub!=="string"){
REMIND.sub=mw.config.get("wgRevisionId");
if(!REMIND.sub||REMIND.sub<=0){
REMIND.sub=mw.config.get("wgTitle");}}
return REMIND.sub;
};
REMIND.full=function(){
if(typeof REMIND.sign!=="string"){
REMIND.sign=Sign+"."+mw.config.get("wgDBname");}
return REMIND.sign;
};
fire();
}(mediaWiki,jQuery));
/// EOF</nowiki>menuSwitcher/r.js