User:PerfektesChaos/js/listPageOptions/r.js

/// User:PerfektesChaos/js/listPageOptions/r.js /// 2019-02-04 PerfektesChaos@de.wikipedia /// Documentation:w:en:User:PerfektesChaos/js/listPageOptions /// Fingerprint:#0#9CEA6DF5# /// @license GPL [//www.mediawiki.org/w/COPYING](+GFDL,LGPL,CC-BY-SA) /// (function(mw,$){ "use strict"; var Version=6.2,POpt="listPageOptions"; if(typeof mw.libs[POpt]!=="object"||!mw.libs[POpt]){ mw.libs[POpt]={};} mw.libs[POpt].type=POpt; POpt=mw.libs[POpt]; if(typeof POpt.loaded!=="boolean"){ POpt.loaded=true; POpt.config={"wikidata.bgc":"AFEEEE"}; POpt.disguise={}; POpt.edit={}; POpt.group={"sign":POpt.type+"_groupPg", "show":"groupie", "soft":"enhanced"}; POpt.increm={more:30}; POpt.multi={"sign":POpt.type+"_multiPg", "show":"multiple", "soft":"extended"}; POpt.notice={}; POpt.picked={"sign":POpt.type+"_visitedPg", "show":"visited", "soft":"visited"}; POpt.reduce={}; POpt.storage={}; POpt.unwatch={}; POpt.values={}; POpt.config.texts={ "edit":{"en":"edit", "de":"Bearbeiten"}, "groupie":{"en":"Group by pages", "de":"Seitenbezogene\xA0Gruppierung"}, "hide":{"en":"Hide", "de":"ausblenden"}, "multiple":{"en":"Multiple entries", "de":"Mehrere\xA0Einträge"}, "notice":{"en":"+\xA0Visited", "de":"+\xA0Gesehen"}, "notice?":{"en":"Add link for [visited] to every entry", "de":"Link zu 'Gesehen' bei jedem Eintrag"}, "notice!":{"en":"Mark as visited", "de":"Markiere als 'Gesehen'"}, "options":{"en":"Options and notices", "de":"Anzeigeoptionen"}, "show":{"en":"Show", "de":"einblenden"}, "toggleOff":{"en":"off", "de":"aus"}, "toggleOn":{"en":"on", "de":"ein"}, "update":{"en":"meanwhile", "de":"Zwischenzeitlich"}, "unwatch":{"en":"+\xA0[Unwatch]", "de":"+\xA0Nicht-Beobachten"}, "unwatch?":{"en":"Add link for [unwatch] to every entry", "de":"Link zu 'Nicht beobachten' bei jedem Eintrag"}, "visited":{"en":"Visited\xA0Pages", "de":"Besuchte\xA0Seiten:"}, "watchPgRE":{"en":"^\\s*([1-9][0-9,]*[^.\n]+[.\n])(.|\n)*$", "de":"^\\s*([1-9][0-9.]*[^.\n]+[.\n])(.|\n)*$"}, "wlnoteRE":{"en":"as of(.+,.+)\\.", "de":"Stand:(.+,.+)Uhr\\."}, "^show":{"en":"List-Page-Options", "de":"List-Page-Options"}, "^suffix":{"en":"&#8211; equip watchlist and recent changes with Options", "de":"&#8211; Beobachtungsliste und Letzte Änderungen mit Optionen ausstatten"}, "^support":{"en":"/wiki/User:PerfektesChaos/js/listPageOptions", "de":"/wiki/User:PerfektesChaos/js/listPageOptions"},"^^lean-show": {"en":"Compress option block", "de":"Komprimierter Optionsblock"}, "^^learnt-show": {"en":"Enable hiding of visited changes on watchlist", "de":"Möglichkeit zum Verbergen besuchter Änderungen auf der Beobachtungsliste"}, "^^learnt-null": {"en":"not enabled", "de":"keine Möglichkeit"}, "^^learnt-false": {"en":"additional button; preset: show all", "de":"Zusatz-Button; Vorgabe: alle anzeigen"}, "^^learnt-true": {"en":"additional button; preset: hide visited", "de":"Zusatz-Button; Vorgabe: besuchte ausblenden"}, "^^leyo-show": {"en":"Enable hiding of last-edit-your-own on watchlist", "de":"Möglichkeit zum Verbergen eigener letzter Beiträge auf der Beobachtungsliste"}, "^^link-show": {"en":"Button to access this option page", "de":"Schaltknopf, um auf diese Optionsseite zu kommen"}, "^^looked-show": {"en":"Enable entries to be marked as 'visited' on watchlist", "de":"Möglichkeit zum Markieren einzelner Änderungen als 'Gesehen' auf der Beobachtungsliste"}, "^^looked-null": {"en":"not enabled", "de":"keine Möglichkeit"}, "^^looked-false": {"en":"on demand", "de":"auf Anforderung"}, "^^looked-true": {"en":"always", "de":"immer"}, "^^lower-show": {"en":"Additional buttons: hide and show option block", "de":"Zusätzliche Knöpfe: Ein- und Ausblenden des Optionsblocks"}, "^^lower-null": {"en":"no additional button", "de":"kein zusätzlicher Knopf"}, "^^lower-false": {"en":"button for hiding", "de":"Knopf zum Ausblenden"}, "^^lower-true": {"en":"hide: button for showing", "de":"Ausblenden; Knopf zum Einblenden"}, "^^luxury-show": {"en":"Additional checkboxes for hide and show", "de":"Zusätzliche Checkboxen zum Ein- und Ausblenden"}, "^^more-show": {"en":"Overlap seconds for incremental watchlist", "de":"Zeitüberschneidung für inkrementelle Beobachtungsliste in Sekunden"}, "^^self":{"en":"Mark own edit", "de":"Eigene Bearbeitung markieren"} }; POpt.spooling="https://upload.wikimedia.org/wikipedia/commons/d/de/Ajax-loader.gif";} function fullstop(activity){ if(typeof activity==="object"&&activity){ if(typeof activity.preventDefault==="function"){ activity.preventDefault;} if(typeof activity.stopPropagation==="function"){ activity.stopPropagation;}}} POpt.config.feature=function(apply){ var e,r; if(typeof this.language!=="boolean"){ if(typeof POpt.prego!=="object"){ if(typeof mw.libs[this.supply]==="object"){ POpt.prego=mw.libs[this.supply];}} if(typeof POpt.prego==="object"){ if(typeof POpt.prego.translation==="function"){ this.language=(typeof POpt.prego.translation==="function");} }else{ this.language=false;}} e=this.texts[apply]; if(e){ if(this.language){ r=POpt.prego.translation(e); }else{ r=e.en;} }else{ r="***"+apply+"***";} return r; }; POpt.config.fetch=function{ var scope=" lean learnt leyo link looked lower luxury more self ",vals=POpt.prego.fetch(POpt.type),s; for(s in vals){ if(scope.indexOf(" "+s+" ")>0){ POpt[s]=vals[s];}} }; POpt.config.fire=function{ var rls,signature; this.supply="preferencesGadgetOptions"; signature="ext.gadget."+this.supply; if(!mw.loader.getState(signature)){ rls={}; rls[signature]="loading"; mw.loader.state(rls); mw.loader.load("https://en.wikipedia.org/w/index.php?title=User:PerfektesChaos/js/"+this.supply+"/r.js&action=raw&bcache=1&maxage=604802&ctype=text/javascript","text/javascript");} }; POpt.config.$flow=function{ var $r=$(" "); $r.attr({src:POpt.spooling,height:"16",alt:"Ajax"}); return $r; }; POpt.config.form=function{ var txt=this.texts,dialog={script:POpt.type,show:txt["^show"],support:txt["^support"],suffix:txt["^suffix"],opts:[{signature:"lean",type:"checkbox",show:txt["^^lean-show"],val:false },{signature:"learnt",type:"radio",show:txt["^^learnt-show"],poly:[{val:null,show:txt["^^learnt-null"]},{val:false,show:txt["^^learnt-false"]},{val:true,show:txt["^^learnt-true"]} ]},{signature:"looked",type:"radio",show:txt["^^looked-show"],poly:[{val:null,show:txt["^^looked-null"]},{val:false,show:txt["^^looked-false"]},{val:true,show:txt["^^looked-true"]} ]},{signature:"leyo",type:"checkbox",show:txt["^^leyo-show"],val:false },{signature:"lower",type:"radio",show:txt["^^lower-show"],val:null,poly:[{val:null,show:txt["^^lower-null"]},{val:false,show:txt["^^lower-false"]},{val:true,show:txt["^^lower-true"]} ]},{signature:"luxury",type:"checkbox",show:txt["^^luxury-show"],val:false },{signature:"self",type:"text",show:txt["^^self"],val:false },{signature:"more",type:"text",show:txt["^^more-show"],minimum:4,maxlength:4,val:POpt.increm.more },{signature:"link",type:"checkbox",show:txt["^^link-show"],val:false } ]}; POpt.prego.form(dialog); }; POpt.disguise.fetch=function{ var leap=false,learn=false,$list=mw.util.$content.find("table.mw-enhanced-rc"),n=$list.length,seen="mw-changeslist-line-not-watched",e,i,low,staff,story,stuff,$e,$li,$trs,$user; POpt.picked.leap=false; this.got=[]; this.list=(n===0); if(this.list){ $e=mw.util.$content.find("#resultListSort"); if($e.length){ $e=$e.find("ol"); }else{ $e=mw.util.$content.find("UL.special");} if($e.length){ $list=$e.children("li"); n=$list.length; for(i=0;i0); if(POpt.letal){ story=false;} this.got.push([$li,stuff,staff,low,learn,story]);} if(POpt.mode===1&&POpt.self){ story=".mw-changeslist-separator"; $e=$(" "); $e.css({"font-weight":"bold"}); $e.text(POpt.self); for(i=0;i<n;i++){ e=this.got[i]; staff=e[2]; if(staff){ if(this.reLeyo.test(staff)){ e[0].find(story).after($e.clone);}}}}} }else{ staff=false; for(i=0;i<n;i++){ $li=$list.eq(i); if(POpt.picked.learn){ learn=$li.hasClass(seen); if(learn){ POpt.picked.leap=true; }else{ leap=true;}} $trs=$li.children("tbody").children("tr"); stuff=$trs.find("SPAN.mw-title").children("a").attr("href"); $e=$trs.find("A.mw-userlink"); staff=false; switch($e.length){ case 0: break; case 1: staff=$e.attr("href"); break; default: $e=$trs.find(".changedby").children("A.mw-userlink"); if($e.length===1){ staff=$e.attr("href"); }else if(this.reLeyo){ $e=$trs.eq(1).find("A.mw-userlink"); staff=$e.attr("href");}} if(this.reLeyo&&staff){ if(this.reLeyo.test(staff)){ $li.hide;}} if($li){ low=($trs.children(".minoredit").length>0); this.got.push([$li,stuff,staff,low,learn,story]);}}} POpt.picked.leap=(POpt.picked.leap&&leap); }; POpt.disguise.fiat=function(array,abolish){ var i,k,m,n,q,q3,q4; if($.isArray(array)){ n=array.length; for(i=0;i1){ k=q[2]; if(m<4){ q4=false; if(m<3){ q3=false; }else{ q3=q[3];} }else{ q3=q[3]; q4=q[4];} if(!k||k===POpt.mode){ if(this.filter(q[0],q[1],q3,q4,abolish)){ break;}}}}}} }; POpt.disguise.filter=function(alter,abandon,account,ant,abolish){ var r=false,i,l,n,q,rep,reu,s; if(alter||abandon||account||(POpt.picked.learn&&POpt.picked.leap)){ n=this.got.length; if(n){ if(alter||!this.list){ rep="/wiki/"; if(alter){ if(!this.special){ q=mw.config.get("wgFormattedNamespaces"); if(q){ rep=q[-1];} this.special=rep+":";} rep=this.special;} }else{ rep="/w(iki/|/index\\.php\\?title=)";} if(abandon){ s=POpt.format(abandon); }else{ s="";} rep=new RegExp(rep+s); reu=this.format(account); r=true; for(i=0;i<n;i++){ q=this.got[i]; if(q){ l=false; if(rep.test(q[1])){ l=alter; if(reu){ l=reu.test(q[2]);} if(l&&ant){ l=q[3];}} if(l){ if(abolish){ q[0].hide; }else{ q[0].show;} this.got[i]=false; }else{ r=false;}}}}} return r; }; POpt.disguise.fire=function{ if(POpt.leyo||POpt.self){ this.fresh; }else if(POpt.picked.learn||this.hide||this.show){ this.fetch;} if(this.hide){ this.fiat(POpt.hide,true);} if(this.show){ this.fiat(POpt.show,false);} }; POpt.disguise.format=function(account){ var r; if(account){ r=new RegExp("/w(iki/|/index.php?title=)[^:]+:"+POpt.format(account)); }else{ r=false;} return r; }; POpt.disguise.fresh=function{ this.reLeyo=this.format(mw.config.get("wgUserName")); this.fetch; }; POpt.edit.fire=function{ var $entries=$(".mw-htmlform-flatlist-item,.oo-ui-fieldLayout-header"); $entries.each(POpt.edit.furnish); }; POpt.edit.furnish=function(address,achieve){ var $entry=$(achieve),$links=$entry.find("a"),$a=$links.eq(2),swift=$a.attr("href"),$end,$span; $links.attr({target:"_blank"}); if(swift){ $end=$links.last; swift=swift.replace(/&action=history/,"&action=edit"); $a=$(""); $a.attr({href:swift,target:"_blank"}); $a.text(POpt.config.feature("edit")); $end.after($a); $span=$(" "); $span.text(" | "); $end.after($span);} }; POpt.group.find=function(assigned){ var less=false,$grab; if(assigned){ less=(assigned==="1"); }else{ $grab=mw.util.$content.find(".mw-enhanced-rc"); if($grab.length){ less=true; }else if(!this.leaves){ if(mw.user.options.get("usenewrc")){ less=true;}}} POpt.values.ctl2url[this.sign].val=(less?"1":"0"); }; POpt.increm.fire=function{ var date=new Date,incr=(date-POpt.increm.retrieved)/ 1000,more=POpt.increm.more,site=mw.config.get("wgServer"); if(typeof POpt.more==="string"&&POpt.more){ POpt.more=parseInt(POpt.more,10);} if(typeof POpt.more==="number"&&POpt.more>more){ more=POpt.more;} incr+=more; POpt.values.ctl2url.days=false; if(site.indexOf("://")<0){ site=window.location.protocol+site;} window.location=site+POpt.values.script+"?title=Special:"+POpt.special+POpt.values.factory+"&days="+(incr / 86400); }; POpt.increm.furnish=function($around){ var $r=false,$box,$e; if($around){ $box=$around; }else{ $box=mw.util.$content.find("#mw-watchlist-options");} if($box.length){ POpt.increm.retrieved=new Date; $e=$box.find("br").eq(0); if($e.length){ $r=$(" "); $r.attr({id:POpt.type+"_incrNormal",type:"button"}).click(this.fire).css({"margin-left":"1em", "margin-right":"1em"}).text(POpt.config.feature("update")); $e.before($r);}} return $r; }; POpt.multi.find=function(assigned){ var less=false; if(assigned){ less=(assigned==="1"); }else{ if(mw.user.options.get("extendwatchlist")){ less=true;}} POpt.values.ctl2url[this.sign].val=(less?"1":"0"); }; POpt.notice.factory=function{ var $e=$(this),s; if(POpt.unwatch.less){ $e=$e.parent; }else{ s=$e.attr("class"); if(s){ if(s.indexOf("mw-changeslist-line-")<0){ $e=false;} }else{ $e=false;}} if($e){ $e.find("a").each(POpt.notice.feed);} return true; }; POpt.notice.feed=function{ var loop=true,$e=$(this),s=$e.attr("href"),g,id,$btn,$span; if(s&&s.indexOf("&action=history")>0){ g=/[?&]title=([^&]+)(&.+)*&curid=([0-9]+)(&.+)?$/.exec(s); if(g){ s=g[1]; id=g[3]; $btn=$(" "); $btn.attr({type:"button",title:POpt.config.feature("notice!")}).click(POpt.notice.fire).css({"color":"#006000", "font-size":"85%", "font-weight":"bold", "padding-left":"0", "padding-right":"0"}).data({curid:id,title:s}).text("+"); $span=$(" "); $span.attr({"class":"curid"+id}).text(" | ") .append($btn); $e.after($span); loop=false;}} return loop; }; POpt.notice.fiat=function{ this.$portlet=$(mw.util.addPortletLink("p-tb","#",POpt.config.feature("notice"),"t-mark-visited",POpt.config.feature("notice?"),"v",null)); this.$portlet.click(this.furnish); }; POpt.notice.fine=function(arrived,$apply){ if(typeof arrived==="object"&&typeof arrived.invalid==="undefined"){ $apply.children("img").remove; $apply.each(POpt.notice.fix); }else{ POpt.fault("notice",arrived,$apply);} }; POpt.notice.fire=function{ var $g=$(this),id=$g.data("curid"),$e=mw.util.$content.find(".curid"+id),defaults,promise,s; if($e.length){ $e.children("button").hide; $e.append(POpt.config.$flow); if(typeof POpt.notice.api!=="object"){ defaults={parameters: {action:"setnotificationtimestamp"} }; POpt.notice.api=new mw.Api(defaults);} s=unescape(decodeURI($g.data("title"))); promise=POpt.notice.api.postWithToken("edit",{titles:s}); promise.done(function(arrived){ POpt.notice.fine(arrived,$e); }).fail(function(arrived){ POpt.fault("notice",arrived,$e); });} }; POpt.notice.first=function{ if(typeof POpt.looked==="boolean"){ this.$unvisiteds=$(".mw-changeslist-line-watched"); if(this.$unvisiteds.length){ if(POpt.looked){ this.$portlet=false; this.furnish; }else{ this.fiat;}}} }; POpt.notice.fix=function{ var $g=$(this).parent,state=$g.attr("class").replace(/\bmw-changeslist-line-watched\b/,"mw-changeslist-line-not-watched"); $g.attr("class",state); }; POpt.notice.furnish=function(activity){ fullstop(activity); POpt.notice.$unvisiteds.each(POpt.notice.factory); if(POpt.notice.$portlet){ POpt.notice.$portlet.remove;} }; POpt.picked.$factory=function{ var s; if(this.leap){ if(typeof this.$toggle!=="object"){ this.$toggle=$(" "); this.$toggle.attr({id:POpt.type+"_visited",type:"button"}); this.$toggle.click(this.fire); this.$toggle.css({"margin-left":"0.5em", "margin-right":"0.5em"}); POpt.values.$POpt.append(this.$toggle);} s=(this.learning?"hide":"show"); this.$toggle.text(POpt.config.feature(s));} }; POpt.picked.fire=function{ var less=(POpt.picked.learning&&POpt.picked.leap),n,i,q; n=POpt.disguise.got.length; for(i=0;i<n;i++){ q=POpt.disguise.got[i]; if(q[4]){ if(less){ q[0].hide; }else{ q[0].show;}}} POpt.storage.flush("learnt",POpt.picked.learning); POpt.picked.learning=!POpt.picked.learning; POpt.picked.$factory; }; POpt.picked.furnish=function{ var s,$span; if(POpt.values.$form){ s=POpt.storage.find("learnt"); if(s){ this.learning=(s==="true"); }else{ this.learning=POpt.learnt; POpt.storage.flush("learnt",this.learning);} $span=$(" "); $span.text("\xA0| "); POpt.values.$POpt.append($span); $span=$(" "); $span.text(POpt.config.feature(this.show)); POpt.values.$POpt.append($span); if(!this.leap){ $span=$(" "); $span.css({"color":"#B0B0B0"}); $span.text(" ./."); POpt.values.$POpt.append($span); if(POpt.mode===2){ this.learning=false;}} if(POpt.mode===2&&!POpt.lean){ POpt.values.$POpt.append($(" "));} this.fire;} }; POpt.reduce.facility=function{ POpt.reduce.$box.show; POpt.reduce.$resuscitate.hide; POpt.reduce.lower=false; POpt.storage.flush("lower",POpt.reduce.lower); }; POpt.reduce.fade=function{ POpt.reduce.$resuscitate.css({"margin-top":"10px"}); POpt.reduce.$resuscitate.show; POpt.reduce.$box.hide; POpt.reduce.lower=true; POpt.storage.flush("lower",POpt.reduce.lower); }; POpt.reduce.furnish=function{ var s=POpt.storage.find("lower"),btnR,got,re,$btn,$div,$span; if(s){ this.lower=(s==="true"); }else{ this.lower=POpt.lower; POpt.storage.flush("lower",this.lower);} s=(POpt.mode===1?"#mw-watchlist-options":".rcoptions"); this.$box=mw.util.$content.find(s); if(this.$box.length){ btnR={"float":(POpt.ltr?"right":"left ")}; btnR[(POpt.ltr?"margin-left":"margin-right")]="8px"; btnR[(POpt.ltr?"margin-right":"margin-left")]="0"; this.$resuscitate=$(" "); this.$resuscitate.attr({id:POpt.type+"_resuscitate"}); this.$resuscitate.css({"margin-top":"10px"}); if(POpt.mode===1){ s=this.$box.text; if(s){ re=new RegExp(POpt.config.feature("wlnoteRE")); got=re.exec(s); if(got){ $span=$(" "); $span.text(got[1]); this.$resuscitate.append($span); $btn=POpt.increm.furnish(this.$box); if($btn){ $btn=$btn.clone; $btn.attr({id:POpt.type+"_incrShrinked"}); $btn.click(POpt.increm.fire); this.$resuscitate.append($btn);}}}} if(!POpt.$options){ POpt.$options=this.$box.find("legend");} if(POpt.link&&POpt.prego){ $btn=POpt.prego.$button(POpt.type); $btn.attr({id:POpt.type+"_optPage"}); $btn.css(btnR); $btn.css({"margin-top":"20px"}); POpt.$options.after($btn); $div=$(" "); $div.css({"clear":"right"}); POpt.$options.after($div);} $btn=$(" "); $btn.attr({id:POpt.type+"_optShow",type:"button"}); $btn.click(POpt.reduce.facility); $btn.css((POpt.ltr?"margin-left":"margin-right"),"10px"); $btn.text(POpt.config.feature("options")); this.$resuscitate.append($btn); this.$box.before(this.$resuscitate); $btn=$(" "); $btn.attr({id:POpt.type+"_optHide",type:"button"}); $btn.click(POpt.reduce.fade); $btn.css(btnR); $span=$(" "); $span.css({"color":"#FF0000", "font-weight":"bold"}); $span.text("X"); $btn.append($span); POpt.$options.after($btn); if(this.lower){ this.fade; }else{ this.facility;}} }; POpt.storage.find=function(access){ var r=false,s="~"+access+"_",i,j; if(!this.stored){ if(window.sessionStorage){ this.stored=window.sessionStorage.getItem(POpt.type);} if(!this.stored){ this.stored="~";}} i=this.stored.indexOf(s); if(i>=0){ j=this.stored.indexOf("~",i+2); if(j>0){ r=this.stored.substring(i+s.length,j);}} return r; }; POpt.storage.flush=function(access,assign){ var s="~"+access+"_",i,j; if(!this.stored){ this.stored="~";} i=this.stored.indexOf(s); s=s+assign; if(i<0){ this.stored=s+this.stored; }else{ j=this.stored.indexOf("~",i+2); if(j<0){ this.stored=s+"~"; }else{ this.stored=this.stored.substr(0,i)+s+this.stored.substr(j);}} if(window.sessionStorage){ window.sessionStorage.setItem(POpt.type,this.stored);} }; POpt.unwatch.factory=function{ var $e=$(this),s; if(POpt.unwatch.less){ $e=$e.parent; }else{ s=$e.attr("class"); if(s){ if(s.indexOf("mw-changeslist-line-")<0){ $e=false;} }else{ $e=false;}} if($e){ $e.find("a").each(POpt.unwatch.feed);} return true; }; POpt.unwatch.feed=function{ var loop=true,$e=$(this),s=$e.attr("href"),g,id,$btn,$span; if(s&&s.indexOf("&action=history")>0){ g=/[?&]title=([^&]+)(&.+)*&curid=([0-9]+)(&.+)?$/.exec(s); if(g){ s=g[1]; id=g[3]; $btn=$(" "); $btn.attr({type:"button"}).click(POpt.unwatch.fire).css({"padding-left":"0", "padding-right":"0"}).data({curid:id, leave:true,title:s}).text(POpt.unwatch.flag(false)); $span=$(" "); $span.attr({"class":"curid"+id}).text(" | ") .append($btn); $e.after($span); loop=false;}} return loop; }; POpt.unwatch.fiat=function{ this.$portlet=$(mw.util.addPortletLink("p-tb","#",POpt.config.feature("unwatch"),"t-unwatch",POpt.config.feature("unwatch?"),"w",null)); this.$portlet.click(POpt.unwatch.furnish); }; POpt.unwatch.fine=function(arrived,$apply){ if(typeof arrived==="object"&&typeof arrived.invalid==="undefined"){ $apply.children("img").remove; $apply.each(POpt.unwatch.fix); }else{ POpt.fault("unwatch",arrived,$apply);} }; POpt.unwatch.fire=function{ var $g=$(this),id=$g.data("curid"),$e=mw.util.$content.find(".curid"+id),promise,subject,submit; if($e.length){ $e.children("button").hide; $e.append(POpt.config.$flow); subject=unescape(decodeURI($g.data("title"))); submit=($g.data("leave")?"unwatch":"watch"); if(typeof this.api!=="object"){ this.api=new mw.Api;} promise=this.api[submit](subject); promise.done(function(arrived){ POpt.unwatch.fine(arrived,$e); }).fail(function(arrived){ POpt.fault("unwatch",arrived,$e); });} }; POpt.unwatch.fix=function{ var $e=$(this),$btn=$e.children("button"),leave; if($btn.length){ leave=$btn.data("leave"); $btn.css({"background-color":(leave?"#FFB0B0":"#B0B0FF"), "padding-left":"5px", "padding-right":"5px"}); $btn.data({leave:!leave}); $btn.text(POpt.unwatch.flag(leave)); $btn.show;} }; POpt.unwatch.flag=function(again){ return(again?"/////":"—"); }; POpt.unwatch.furnish=function{ var $list=mw.util.$content.find("#mw-content-text"),ctl,seek; if($list.length){ ctl=POpt.values.ctl2url[POpt.group.sign]; POpt.unwatch.less=ctl.val; if(POpt.unwatch.less==="0"){ POpt.unwatch.less=false;} seek=(POpt.unwatch.less?".mw-title":"li"); $list.find(seek).each(POpt.unwatch.factory);} POpt.unwatch.$portlet.remove; }; POpt.values.factory=function{ var r="",s; for(s in this.ctl2url){ r=r+this.fiat(s);} return r; }; POpt.values.fiat=function(access){ var par=this.ctl2url[access],r="",s=access; if(par){ if(par.val!==undefined){ if(par.url){ s=par.url;} if(par.type==="checkbox"){ if(typeof par.val!=="string"){ par.val=(par.val?"1":"0");}} r="&"+s+"="+par.val;}} return r; }; POpt.values.find=function(around,adapt){ var $input,$sep; this.first; this.$wrap=mw.util.$content.find(around); if(this.$wrap.length){ this.$form=mw.util.$content.find(adapt); if(this.$form.length){ $input=this.$form.find("input"); $input.each(this.found);} if(POpt.lean){ $sep=$(" "); $sep.text("\xA0| "); this.$wrap.append($sep); this.$POpt=$(" "); }else{ this.$POpt=$(" ");} this.$POpt.attr({id:POpt.type+"_extra"}); this.$wrap.append(this.$POpt); }else{ this.$form=false; this.$wrap=false; this.$POpt=false;} }; POpt.values.first=function{ if(!this.ctl2url){ this.ctl2url={"associated":{type:"checkbox"}, "days":{name:"days", type:false}, "hideAnons":{type:"checkbox"}, "hideBots":{type:"checkbox"}, "hideLiu":{type:"checkbox"}, "hideMinor":{type:"checkbox"}, "hideOwn":{type:"checkbox"}, "hideReviewed":{type:"checkbox"}, "hideWikibase":{type:"checkbox"}, "nsinvert":{type:"checkbox",url:"invert"}, "namespace":{type:"select"} }; this.ctl2url[POpt.group.sign]={type:"checkbox",url:POpt.group.soft}; this.ctl2url[POpt.multi.sign]={type:"checkbox",url:POpt.multi.soft}; if(POpt.mode===2){ this.ctl2url.from={type:false}; this.ctl2url.limit={type:false}; this.ctl2url.tagfilter={type:"text"};}} }; POpt.values.fix=function(access){ if(!this.$hrefs){ if(this.$wrap){ this.$hrefs=this.$wrap.find("a"); }else{ this.$hrefs=true;}} if(typeof this.$hrefs!=="boolean"){ this.current=this.ctl2url[access]; if(!this.current.url){ this.current.url=access;} this.$hrefs.each(this.fixing);} }; POpt.values.fixing=function(at,access){ var got,par,swap,$e; if(at<0){ $e=access; }else{ $e=$(access);} swap=$e.attr("href"); if(swap){ if(!POpt.values.script){ POpt.values.script=mw.config.get("wgScript");} if(swap.indexOf(POpt.values.script)<0){ swap=false;} if(swap){ par=POpt.values.current; if(par.val!==undefined){ if(!par.reURL){ par.reURL="([?&]"+par.url+"=)(?:[^&]*)(&?.+)?$"; par.reURL=new RegExp(par.reURL);} if(par.type==="checkbox"){ if(typeof par.val!=="string"){ par.val=(par.val?"1":"0");}} got=par.reURL.exec(swap); if(got){ swap=swap.replace(par.reURL,"$1"+par.val+"$2"); }else{ swap=swap+"&"+par.url+"="+par.val;} $e.attr({href:swap});}}} return true; }; POpt.values.flat=function{ var $e=this.$wrap.find("br, hr"),$sep=$(" "); $sep.text(" | "); $e.before($sep.clone); $e.remove; this.$wrap.find("p, form, ul").show; }; POpt.values.flip=function(access){ var par=this.ctl2url[access],s,$e; if(par){ if(!par.$ctl){ par.$ctl=this.$form.find("#"+access);} if(par.$ctl&&par.$ctl.length){ if(par.type==="checkbox"){ s=par.$ctl.attr("value"); if(s){ s=(s==="0"?"1":"0"); }else{ s=(par.$ctl.prop("checked")?"1":"0");} par.$ctl.val(s); if(s==="0"){ par.$ctl.prop("checked", false);} if(POpt.mode===1){ switch(access){ case POpt.group.sign: POpt.flip(s,"1",POpt.multi); break; case POpt.multi.sign: POpt.flip(s,"0",POpt.group); break;}} }else{ s=par.$ctl.val;} par.val=s; $e=this.$form.find("#hidden_"+access); if($e.length){ $e.val(s);} this.fix(access);}} }; POpt.values.found=function{ var $input=$(this),par,sign; if($input.attr("type")==="hidden"){ sign=$input.attr("name"); par=POpt.values.ctl2url[sign]; if(par){ par.val=$input.val;}} return true; }; POpt.values.furnish=function(access){ var par=this.ctl2url[access],s; if(par){ if(!par.$ctl){ if(this.$form){ par.$ctl=this.$form.find("#"+access);}} if(par.$ctl){ if(par.type==="checkbox"){ s=(par.$ctl.prop("checked")?"1":"0"); }else{ s=par.$ctl.val;} par.val=s; s=POpt.slip+".values.flip('"+access+"');"; par.$ctl.attr({onchange:s});}} }; POpt.facilitate=function{ var bools=["hideMinor","hideBots","hideAnons","hideLiu","hideOwn","hideReviewed" ],j=(this.mode===1?8:9),n=j+bools.length,k=0,$set=POpt.values.$wrap.find("a"),i,par,sign,$e; for(i=j;i<n;i++){ sign=bools[k]; par=POpt.values.ctl2url[sign]; par.$ctl=$(" "); par.$ctl.attr({id:sign,onchange:POpt.slip+".values.flip(\""+sign,type:"checkbox"}); if(par.val){ par.$ctl.attr({checked:"true"});} par.$ctl.val((par.val?"1":"0")); $e=$set.eq(i); $e.attr({id:"link_"+sign}); $e.before(par.$ctl); $e=$(" "); $e.attr({id:"hidden_"+sign,name:sign,type:"hidden",value:(par.val?"1'":"0'")}); $e.val((par.val?"1":"0")); POpt.values.$form.append($e); k++;} }; POpt.factory=function(assign,ahead){ var less,shift,sub,$a,$input,$label,$sep,$span; if(this.values.$form){ if(!this.values.script){ this.values.script=mw.config.get("wgScript");} less=this.values.ctl2url[assign.sign].val; if(less==="0"){ less=false;} shift=this.values.script+"?title=Special:"+this.special+this.values.factory; sub="&"+assign.soft+"="; shift=shift.replace(new RegExp(sub+"?[01]"),sub+(less?"0":"1")); if(this.mode===1){ if(shift.indexOf("&extended=0")>0){ shift=shift.replace(/&enhanced=1/,"&enhanced=0");} if(shift.indexOf("&enhanced=1")>0){ if(shift.indexOf("&extended=")>0){ shift=shift.replace(/&extended=0/,"&extended=1"); }else{ shift=shift+"&extended=1";}}} $label=$(" "); $span=$(" "); $span.text(this.config.feature(assign.show)+" ("); $label.append($span); $a=$(""); $a.attr({href:shift}); $a.text(this.config.feature((less?"toggleOff":"toggleOn"))); $label.append($a); $span=$(" "); $span.text(")"); $label.append($span); this.values.$POpt.prepend($label); $input=$(" "); $input.attr({id:assign.sign,name:assign.soft,onchange:this.slip+".values.flip('"+assign.sign+"')",type:"checkbox",value:(less?"1":"0")}); if(less){ $input.attr({checked:true});} this.values.$POpt.prepend($input); if(this.mode===1){ if(!this.lean&&ahead){ $sep=$(" "); }else if(!ahead){ $sep=$(" "); $sep.text("\xA0| ");} this.values.$POpt.prepend($sep);}} }; POpt.fault=function(action,arrived,$apply){ var $e=$(" "); $e.css({"border":"#FF0000 2px solid", "color":"#FF0000", "margin":"5px"}); $e.text("ERROR"); $apply.empty; $apply.append($e); mw.log({loud:true},"."+POpt.type+"."+action+".fault",2,arrived); }; POpt.fiat=function{ var sep,store,story,style,suite,$grab,$wd; mw.util.$content.find(".mw-changeslist-legend").hide; POpt.ltr=($(window.document).find("html").attr("dir")!=="rtl"); switch(POpt.mode){ case 1: sep=".mw-changeslist-separator"; $grab=mw.util.$content.find(sep); POpt.group.leaves=($grab.length>0); if(POpt.group.leaves){ POpt.unwatch.fiat;} story="#mw-watchlist-options"; suite="#mw-watchlist-form"; POpt.flat; store=".wikibase-edit"; $wd=mw.util.$content.find(store); if($wd.length){ switch(typeof POpt.store){ case "boolean": style=POpt.store; break; case "string": if(/[0-9A-F]{6}/.test(POpt.store)){ style=POpt.store; break;} default: style=true;} if(style===true){ style=POpt.config["wikidata.bgc"];} if(style){ style="{background-color:#"+style+"}"; mw.util.addCSS(store+style);}} break; case 2: POpt.group.leaves=true; story=".rcoptions"; suite="form"; break;} POpt.values.find(story,suite); if(POpt.luxury){ POpt.facilitate;} POpt.values.furnish("associated"); POpt.values.furnish("nsinvert"); POpt.values.furnish("namespace"); POpt.disguise.hide=(typeof POpt.hide==="object"&&POpt.hide); POpt.disguise.show=(typeof POpt.show==="object"&&POpt.show); POpt.picked.learn=(typeof POpt.learnt==="boolean"); if(POpt.disguise.hide||POpt.disguise.show||POpt.picked.learn||POpt.letal||POpt.leyo||POpt.self){ POpt.disguise.fire;} if(POpt.picked.learn&&POpt.mode===1){ POpt.picked.furnish;} if(typeof POpt.lower==="boolean"){ POpt.reduce.furnish; }else if(POpt.mode===1){ POpt.increm.furnish;} if(POpt.lean){ POpt.values.flat;} POpt.furnish(POpt.group,false); if(POpt.mode===1){ POpt.furnish(POpt.multi,true); if(POpt.values.$wrap&&POpt.values.$score){ if(!POpt.$options){ POpt.$options=POpt.values.$wrap.find("legend");} POpt.$options.after(POpt.values.$score);} POpt.notice.first;} }; POpt.fire=function{ var env,pages,require,rls; POpt.signature="ext.gadget."+POpt.type; POpt.vsn=Version; if(!mw.loader.getState(POpt.signature)){ env=mw.config.get(["wgCanonicalSpecialPageName","wgNamespaceNumber"]); pages={"Blankpage":-1, "Gadgets":-1, "Watchlist":1, "Recentchanges":2, "EditWatchlist":3}; rls={}; POpt.doc="w:en:User:PerfektesChaos/js/"+POpt.type+""; if(env.wgNamespaceNumber===-1){ this.special=env.wgCanonicalSpecialPageName; this.mode=pages[this.special]; if(this.mode){ rls[this.signature]="loading"; mw.loader.state(rls); rls[this.signature]="ready"; this.rLoading=rls; rls=false; this.config.fire; require=["user","user.options","mediawiki.user","mediawiki.util"]; if(this.mode===1){ require=require.concat(["mediawiki.api"]);} mw.loader.using(require,this.firing);}} if(rls){ rls[this.signature]="ready"; mw.loader.state(rls);}} }; POpt.firing=function{ mw.hook(POpt.config.supply+".ready").add(POpt.first); }; POpt.first=function(attributes){ POpt.prego=attributes; POpt.slip="mw.libs."+POpt.type; if(POpt.mode>0){ if(POpt.prego){ POpt.config.fetch;} if(POpt.mode<3){ $(POpt.fiat); }else{ $(POpt.edit.fire);} }else if(POpt.prego){ POpt.config.form;} mw.loader.state(POpt.rLoading); mw.hook(POpt.type+".ready").fire(POpt); }; POpt.flat=function{ var $e=mw.util.$content.find("#mw-content-text"),re,s; if($e.length){ $e=$e.children("p"); if($e.length){ re=new RegExp(POpt.config.feature("watchPgRE",false)); s=$e.text.replace(re,"$1"); if(s){ $e.remove; POpt.values.$score=$(" "); POpt.values.$score.text(s+"\xA0| ");}}} }; POpt.flip=function(alter,allow,assign){ var co,s; if(alter===allow){ s=assign.sign; co=this.values.ctl2url[s]; if(co){ if(co.val!==allow){ if(!co.$ctl){ if(this.values.$form){ co.$ctl=this.values.$form.find("#"+s);}} if(co.$ctl){ co.$ctl.click;}}}} }; POpt.format=function(access){ var r=access,i,k,n,s; if(r){ if(access.indexOf("%")<0){ n=access.length; r=""; for(i=n-1;i>=0;i--){ k=access.charCodeAt(i); s=String.fromCharCode(k); if(k>127){ s=encodeURI(s);} r=s+r;} s=mw.util.wikiUrlencode(r); }else{ if(!this.sp2_){ this.sp2_=new RegExp(" ","g");} r=r.replace(this.sp2_,"_");}} return r; }; POpt.furnish=function(assign,ahead){ var set=mw.util.getParamValue(assign.soft); assign.find(set); POpt.values.fix(assign.sign); this.factory(assign,ahead); }; POpt.fire; }(window.mediaWiki,window.jQuery)); /// EOF listPageOptions/r.js