Jump to content

User:PerfektesChaos/js/filesMetaData/lib/r.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
/// User:PerfektesChaos/js/filesMetaData/lib/r.js
/// 2018-08-24 PerfektesChaos@de.wikipedia
/// Fingerprint:#0#18A09579#
/// @license GPL [//www.mediawiki.org/w/COPYING](+GFDL,LGPL,CC-BY-SA)
///<nowiki>
(function(mw,$){
"use strict";
var Version=1.3,Signature="filesMetaData",Sub="lib",G,MEDIA,PREGO,TEXTS;
G={api:{Api:false,errors:false,cl:{},cm:{query:false},dc:{query:false},fi:{},incr:10,max:50,more:200,qp:{},reNS:false,rv:{},th:{query:false},trsl:["go","sort-ascending","sort-descending"]
},body:{legal:true
},cat:{legal:true
},direct:{
},extensions:{groups:{audio:"flac kar midi opus spx wav mp3 mpga mpa mp2 oga ogg ogm ogv ogx",paged:"djvu pdf tiff",pixel:"bmp gif jpeg png tiff xcf",vector:"stl svg",video:"mp3 webm webp ogg ogm ogv ogx"},unique:{apng:"png",jpg:"jpeg",mid:"midi",tif:"tiff"},valid:false
},genuine:{Category:{clm:"SBMTUIECD",list:false,live:true},Direct:{clm:"UTSBMIECD",list:false,live:true},Listfiles:{clm:"UTSBIMECD",list:true,live:false},Mostimages:{clm:"PSBTUMIECD",list:true,live:true},Newimages:{clm:"UTSBMIECD",list:true,live:false},Uncategorizedimages:{clm:"SBTUMIECD",list:true,live:true},Unusedimages:{clm:"UTSBMIECD",list:true,live:true}
},head:{columns:"^MSBUTIPECD",$error:false,$wrap:false},origin:["Category","Listfiles","Mostimages","Newimages","Uncategorizedimages","Unusedimages","Direct"],query:{columns:{"#":{type:"n"},"^":{type:"b"},
"@":{type:"s"},B:{api:"Fsize",type:"n"},C:{api:"Dtimestamp",type:"d"},D:{},E:{api:"Duser",type:"s"},I:{},L:{},M:{type:"s"},P:{api:false,type:"n"},S:{api:"Fsize"
},T:{api:"Ftimestamp",type:"d"},U:{api:"Fuser",type:"s"}
},descr:{value:500,step:100,min:100,max:10000},part:{value:50,step:10,min:10,max:500},rows:{value:200,step:20,min:20,max:1000},thumb:{value:100,step:10,min:20,max:500}
},table:{retrieve:false,thumb:{css:false,src:"5/5d/Checker-16x16.png"},$wrap:false},use:{columns:false,conditions:false,descr:false,directs:false,part:false,permit:false,rows:false,source:false,sub:false,target:"_blank",thumb:false
},wikitext:{}
};
TEXTS={
"About":{"en":"Show sortable metadata of media files.","de":"Zeige sortierbare Metadaten zu Mediendateien."},
"Domain":{"en":"en.wikipedia.org","de":"de.wikipedia.org"},
"cache":{"en":"Clear gadget cache","de":"Gadget-Cache leeren"},
"clm.#":{"en":"#"},"clm.^":{"en":"Mark files",
"de":"Markieren von Dateien"},"clm.@":{"en":"File"},
"clm.B":{"en":"Size (bytes)","de":"Größe (Bytes)"},
"clm.C":{"en":"Changed (description)","de":"Geändert (Beschreibung)"},
"clm.D":{"en":"Description","de":"Beschreibung"},
"clm.E":{"en":"Editor (description)","de":"Bearbeitet (Beschreibung)"},
"clm.I":{"en":"Thumbnail","de":"Miniatur"},
"clm.M":{"en":"Extension","de":"Endung"},
"clm.P":{"en":"Pages using","de":"Nutzende Seiten"},
"clm.S":{"en":"Size (pixel)","de":"Größe (Pixel)"},
"clm.T":{"en":"Timestamp (upload)","de":"Zeitpunkt (Hochladen)"},
"clm.U":{"en":"User (upload)","de":"Benutzer (Hochladen)"},
"columns":{"en":"Columns","de":"Spalten"},
"descr":{"en":"Initial description text length","de":"Erste Zeichen des Beschreibungstexts"},
"direct":{"en":"Plain list of media identifiers","de":"Freie Auflistung von Medienbezeichnern"},
"exports":{"en":"Export","de":"Export"},
"exportW":{"en":"Export wikitable","de":"Exportiere wikitable"},
"exportX":{"en":"Export file list","de":"Exportiere Dateiliste"},
"filter":{"en":"Filter","de":"Filter"},
"filterB":{"en":"Identifier","de":"Bezeichner"},
"filterBt":{"en":"Substring or RegExp","de":"Teilzeichenkette oder RegExp"},
"filterE":{"en":"Types","de":"Dateitypen"},
"invert":{"en":"invert","de":"Umkehren"},
"mark":{"en":"√"},"markAll":{"en":"Mark all",
"de":"Alle markieren"},"markNone":{"en":"Mark none",
"de":"Nichts markieren"},"noCat":{"en":"Apparently no category description.",
"de":"Anscheinend keine Kategoriebeschreibung."},"noFiles":{"en":"No matching files.",
"de":"Keine zutreffenden Dateien."},"origin":{"en":"Origin",
"de":"Datenherkunft"},"part":{"en":"API query chunk size",
"de":"Größe des Abfrageblocks zur API"},"plain":{"en":"Individual list",
"de":"Individuelle Liste"},"rows":{"en":"Number of table rows per block",
"de":"Anzahl der Zeilen je Tabellenblock"},"thumb":{"en":"Thumbnail width",
"de":"Miniaturbildbreite"},"typesEx":"png SVG audio/* pdf"
};
function first(){
var rls,s;
G.signature=Signature+"."+Sub;
s="ext.gadget."+G.signature;
if(mw.loader.getState(s)!=="ready"){
rls={};
rls[s]="ready";
mw.loader.state(rls);
G.vsn=Version;
mw.hook(G.signature+".ready").fire(G);}}
G.fair=function(ask){
var set=ask;
if(set.indexOf("_")>=0){
if(typeof G.reUnder!=="object"){
G.reUnder=new RegExp("[_ ]+","g");}
set=set.replace(G.reUnder," ");}
return set.replace(G.reSpc," ");
};
G.features=function(about){
var r;
if(typeof about.width==="number"&&typeof about.height==="number"){
r=about.width+"×"+about.height;}
if(typeof about.pagecount==="number"){
r=(r?r+" ":"")+"("+about.pagecount+")";}
return r;
};
G.fine=function(ask){
return(ask.indexOf("<")<0&&ask.indexOf("|")<0&&ask.indexOf(">")<0&&ask.indexOf("[")<0&&ask.indexOf("]")<0&&ask.indexOf("{{")<0&&ask.indexOf("}}")<0);
};
G.first=function(app){
PREGO=app;
G.head.first();
MEDIA={};
G.api.foreign();
};
G.flat=function(apply){
return "_"+apply.replace(G.reDot,"_").replace(G.reSpc,"_");
};
G.foreign=function(){
var rooms=mw.config.get("wgFormattedNamespaces"),i,s;
TEXTS["clm.@"]={"en":rooms["6"]};
TEXTS.Special=rooms["-1"];
TEXTS.Category=rooms["14"];
TEXTS.Direct=PREGO.translation(TEXTS.direct);
for(i=0;i<G.api.trsl.length;i++){
s=G.api.trsl[i];
if(mw.messages.exists(s)){
TEXTS[s]=mw.message(s).text();
}else{
TEXTS[s]=s;}}
G.head.form();
};
G.from=function(at){
return at.substr(0,10)+" "+at.substr(11,5);
};
G.front=function(ask,area){
var s=ask,k,space;
if(s){
k=s.indexOf(":");
if(k>0){
space=s.substr(0,k).trim().toLowerCase().replace(G.reSpc,"_");
if(typeof G.wgNamespaceIds!=="object"){
G.wgNamespaceIds=mw.config.get("wgNamespaceIds");}
if(typeof G.wgNamespaceIds[space]==="number"&&G.wgNamespaceIds[space]===area){
s=s.substr(k+1).trim();}}}
return s;
};
G.api.fault=function(jqXHR,textStatus,errorThrown){
var scream;
if(textStatus){
switch(typeof textStatus){
case "object":
if(typeof textStatus.textStatus==="string"){
scream=textStatus.textStatus;
}else{
scream="";}
if(typeof textStatus.exception==="string"&&textStatus.exception){
scream=scream+" ("+textStatus.exception+")";}
break;
case "string":
scream=textStatus;
break;}}
if(errorThrown){
if(scream){
scream=scream+"  -- Error: ";}
scream=scream+errorThrown;}
if(!scream){
scream="???";}
if(typeof window.console==="object"&&typeof window.console.log==="function"){
window.console.log(Signature+" * "+scream);
if(typeof textStatus==="object"&&textStatus&&typeof window.console.dir==="function"){
window.console.dir(textStatus);}}
G.head.fault(scream);
};
G.api.flop=function(){
G.api.cm.query=false;
G.api.fi.titles=[];
G.api.qp.query=false;
G.api.rv.titles=[];
};
G.api.foreign=function(){
var i;
for(i=1;i<G.origin.length-1;i++){
G.api.trsl.push(G.origin[i]);}
if(!G.api.Api){
G.api.Api=new mw.Api();}
G.api.Api.loadMessagesIfMissing(G.api.trsl).done(G.foreign).fail(G.api.fault);
};
G.api.cl.feed=function(at,after){
if(!G.api.cl.query){
G.api.cl.query={"action":"query","prop":"categories"};
G.api.cl.follow=after;
if(!G.api.reNS){
G.api.reNS=new RegExp("^[^:]+:");}}
G.api.cl.query.titles="Category:"+at;
G.api.Api.get(G.api.cl.query).done(G.api.cl.fine).fail(G.api.fault);
};
G.api.cl.fine=function(arrived){
var e,got,i,k,s;
if(typeof arrived==="object"&&arrived&&typeof arrived.query==="object"&&arrived.query&&typeof arrived.query.pages==="object"&&arrived.query.pages){
for(k in arrived.query.pages){
e=arrived.query.pages[k];
if(typeof e==="object"&&e&&typeof e.categories==="object"&&e.categories&&typeof e.categories.length==="number"&&e.categories.length){
got=[];
e=e.categories;
for(i=0;i<e.length;i++){
if(typeof e[i].title==="string"&&e[i].title){
s=e[i].title.replace(G.api.reNS,"");
got.push(s);}}
if(typeof arrived["continue"]==="object"&&arrived["continue"]){
got.push(false);}}
break;}}
G.api.cl.follow(got);
};
G.api.cm.feed=function(alike,after,at){
if(after){
if(!G.api.cm.query){
G.api.cm.query={"action":"query","list":"categorymembers"};}
G.api.cm.follow=after;
G.api.cm.like=alike;
if(at){
G.api.cm.query.cmtitle="Category:"+at;
G.api.cm.cmcontinue=true;
if(!G.api.reNS){
G.api.reNS=new RegExp("^[^:]+:");}}}
if(G.api.cm.query){
G.api.cm.query.cmtype=(alike?"subcat":
"file");
G.api.cm.query.cmlimit=G.api.incr;
if(alike){
if(G.api.incr<100){
G.api.cm.query.cmlimit=100;}
if(typeof G.api.cm.query.cmcontinue==="string"){
delete G.api.cm.query.cmcontinue;}
}else if(typeof G.api.cm.cmcontinue==="string"){
G.api.cm.query.cmcontinue=G.api.cm.cmcontinue;}
if(alike||G.api.cm.cmcontinue){
G.api.Api.get(G.api.cm.query).done(G.api.cm.fine).fail(G.api.fault);
}else{
G.api.cm.follow(false);}
}else{
G.api.cm.follow();}
};
G.api.cm.fine=function(arrived){
var cm,e,g,got,i,longer;
if(typeof arrived==="object"&&arrived){
if(typeof arrived["continue"]==="object"&&arrived["continue"]&&typeof arrived["continue"].cmcontinue==="string"&&arrived["continue"].cmcontinue){
longer=true;
if(!G.api.cm.like){
G.api.cm.cmcontinue=arrived["continue"].cmcontinue;
G.api.cm.query.cmcontinue=G.api.cm.cmcontinue;}
}else{
delete G.api.cm.cmcontinue;}
if(typeof arrived.query==="object"&&arrived.query&&typeof arrived.query.categorymembers==="object"&&arrived.query.categorymembers){
cm=arrived.query.categorymembers;
if(typeof cm==="object"&&cm&&typeof cm.length==="number"&&cm.length){
got=[];
for(i=0;i<cm.length;i++){
G.api.cm.items++;
e=cm[i];
if(typeof e.title==="string"&&e.title){
g=[];
g[0]=e.title.replace(G.api.reNS,"");
got.push(g);}}
if(G.api.cm.like&&longer){
got.push(false);}}}}
G.api.cm.follow(got);
};
G.api.dc.feed=function(at,after){
if(!G.api.dc.query){
G.api.dc.query={"action":"query","prop":"revisions",
"rvlimit":1,"rvprop":"content"};
G.api.dc.follow=after;}
G.api.dc.query.titles="File:"+at;
G.api.Api.get(G.api.dc.query).done(G.api.dc.fine).fail(G.api.fault);
};
G.api.dc.fine=function(arrived){
var e,k,show,sign;
if(typeof arrived==="object"&&arrived&&typeof arrived.query==="object"&&arrived.query&&typeof arrived.query.pages==="object"&&arrived.query.pages){
for(k in arrived.query.pages){
e=arrived.query.pages[k];
if(typeof e==="object"&&e&&typeof e.title==="string"){
if(typeof e.revisions==="object"&&e.revisions&&typeof e.revisions.length==="number"&&e.revisions.length){
show=e.revisions[0]["*"];
}else{
show=true;}
sign=e.title.replace(G.api.reNS,"");
G.api.dc.follow(sign,show);}
break;}}
};
G.api.fi.feed=function(ahead){
var n=G.api.fi.titles.length,i,m,s;
if(n){
if(ahead){
G.api.fi.query={"action":"query","continue":"",
"prop":"imageinfo","iiprop":G.api.fi.props};
G.api.fi.got={};
if(!G.api.reNS){
G.api.reNS=new RegExp("^[^:]+:");}}
m=(n>G.api.max?n-G.api.max:0);
s="";
for(i=m;i<n;i++){
s=s+"|File:"+G.api.fi.titles[i];}
G.api.fi.query.titles=s.substr(1);
G.api.fi.titles.splice(m,n-m);
G.api.Api.get(G.api.fi.query).done(G.api.fi.fine).fail(G.api.fault);
}else{
G.table.filling(G.api.fi.got,G.api.fi.follow);}
};
G.api.fi.fine=function(arrived){
var e,got,k,s;
if(typeof arrived==="object"&&arrived&&typeof arrived.query==="object"&&arrived.query&&typeof arrived.query.pages==="object"&&arrived.query.pages){
for(k in arrived.query.pages){
e=arrived.query.pages[k];
if(typeof e==="object"&&e&&typeof e.imageinfo==="object"&&e.imageinfo&&typeof e.imageinfo.length==="number"&&e.imageinfo.length&&typeof e.title==="string"){
got=false;
if(typeof e.imagerepository==="string"){
switch(e.imagerepository){
case "local":
got={L:true};
break;
case "shared":
got={L:false};
break;}}
s=e.title.replace(G.api.reNS,"");
e=e.imageinfo[0];
if(typeof e.size==="number"){
got=got||{};
got.B=e.size;
got.S=G.features(e);}
if(typeof e.timestamp==="string"){
got=got||{};
got.T=G.from(e.timestamp);}
if(typeof e.user==="string"){
got=got||{};
got.U=e.user;}
if(got){
G.api.fi.got[s]=got;}}}}
G.api.fi.feed();
};
G.api.qp.feed=function(action,after){
if(action){
G.api.qp.items=0;
G.api.qp.max=99999999;
if(!G.api.reNS){
G.api.reNS=new RegExp("^[^:]+:");}
G.api.qp.source=action;
G.api.qp.follow=after;
G.api.qp.query={"action":"query","continue":"",
"list":"querypage","qppage":action};}
if(G.api.qp.query&&G.api.qp.items<G.api.qp.max){
G.api.qp.query.qplimit=G.api.incr;
G.api.Api.get(G.api.qp.query).done(G.api.qp.fine).fail(G.api.fault);
}else if(G.api.qp.follow){
G.api.qp.follow(G.api.qp.query);}
};
G.api.qp.fine=function(arrived){
var e,g,got,i,qp;
if(typeof arrived==="object"&&arrived){
if(typeof arrived["continue"]==="object"&&arrived["continue"]&&typeof arrived["continue"].qpoffset==="number"){
G.api.qp.query.qpoffset=arrived["continue"].qpoffset;
}else{
G.api.qp.query=false;}
if(typeof arrived.query==="object"&&arrived.query&&typeof arrived.query.querypage==="object"&&arrived.query.querypage){
qp=arrived.query.querypage;
if(typeof qp.maxresults==="number"){
G.api.qp.max=qp.maxresults;}
if(typeof qp.results==="object"&&qp.results&&typeof qp.results.length==="number"&&qp.results.length){
got=[];
for(i=0;i<qp.results.length;i++){
G.api.qp.items++;
e=qp.results[i];
if(typeof e.title==="string"&&e.title){
g=[];
g[0]=e.title.replace(G.api.reNS,"");
switch(G.api.qp.source){
case "Mostimages":
if(typeof e.value==="string"){
g[1]={P:parseInt(e.value,10)};}
break;
case "Uncategorizedimages":
break;
case "Unusedimages":
if(typeof e.timestamp==="string"){
g[1]={T:G.from(e.timestamp)};}
break;}
got.push(g);}}}}}
G.api.qp.follow(got);
};
G.api.rv.feed=function(ahead){
var n=G.api.rv.titles.length,i,m,s;
if(n){
if(ahead){
G.api.rv.query={"action":"query","continue":"",
"prop":"revisions","rvprop":G.api.rv.props};
G.api.rv.got={};}
m=(n>G.api.max?n-G.api.max:0);
s="";
for(i=m;i<n;i++){
s=s+"|File:"+G.api.rv.titles[i];}
G.api.rv.query.titles=s.substr(1);
G.api.rv.titles.splice(m,n-m);
G.api.Api.post(G.api.rv.query).done(G.api.rv.fine).fail(G.api.fault);
}else{
G.table.filling(G.api.rv.got,G.api.rv.follow);}
};
G.api.rv.fine=function(arrived){
var e,got,k,s;
if(typeof arrived==="object"&&arrived&&typeof arrived.query==="object"&&arrived.query&&typeof arrived.query.pages==="object"&&arrived.query.pages){
for(k in arrived.query.pages){
e=arrived.query.pages[k];
if(typeof e==="object"&&e&&typeof e.revisions==="object"&&e.revisions&&typeof e.revisions.length==="number"&&e.revisions.length&&typeof e.title==="string"){
got={L:true};
s=e.title.replace(G.api.reNS,"");
e=e.revisions[0];
if(typeof e.timestamp==="string"){
got.C=G.from(e.timestamp);}
if(typeof e.user==="string"){
got=got||{};
got.E=e.user;}
}else{
got={L:false};}
G.api.rv.got[s]=got;}}
G.api.rv.feed();
};
G.api.th.feed=function(at){
if(!G.api.th.query){
G.api.th.query={"action":"query","prop":"imageinfo",
"iiprop":"url"};}
G.api.th.query.titles="File:"+at;
G.api.th.query.iiurlwidth=G.use.thumb;
G.api.Api.get(G.api.th.query).done(G.api.th.fine).fail(G.api.fault);
};
G.api.th.fine=function(arrived){
var e,got,k,s;
if(typeof arrived==="object"&&arrived&&typeof arrived.query==="object"&&arrived.query&&typeof arrived.query.pages==="object"&&arrived.query.pages){
for(k in arrived.query.pages){
e=arrived.query.pages[k];
if(typeof e==="object"&&e&&typeof e.title==="string"){
s=e.title.replace(G.api.reNS,"");
if(typeof e.imageinfo==="object"&&e.imageinfo&&typeof e.imageinfo.length==="number"&&e.imageinfo.length){
e=e.imageinfo[0];
got={u:e.thumburl,h:e.thumbheight,w:e.thumbwidth};
G.table.filed(s,got);}}
break;}
if(s&&!got){
G.table.filed(s,false);}}
};
G.body.fairly=function(){
return G.body.legal;
};
G.body.filter=function(allow){
var body,r;
if(G.use.conditions&&typeof G.use.conditions.body==="object"&&typeof G.use.conditions.body.less==="boolean"&&(typeof G.use.conditions.body.re==="object"||typeof G.use.conditions.body.sub==="string")){
body=G.use.conditions.body;
if(typeof body.re==="object"){
r=body.re.test(allow);
}else{
r=(allow.indexOf(body.sub)>=0);}
r=(body.less?!r:r);
}else{
r=true;}
return r;
};
G.body.fired=function(){
var set=G.wish.body.text.getValue(),got,re;
G.body.legal=true;
if(set){
set=G.fair(set);
if(set.indexOf("/")>0){
if(typeof G.body.reRegExp!=="object"){
G.body.reRegExp=new RegExp("^/([^/]+)/(i?)$");}
set=set.trim();
got=G.body.reRegExp.exec(set);
if(got){
try{
re=new RegExp(got[1],got[2]);
G.wish.body.text.setValue(set);
}catch(e){
set=false;}}}
if(!re&&(!G.fine(set)||set.indexOf("/")>0)){
set=false;}
if(set){
if(typeof G.use.conditions!=="object"){
G.use.conditions={};}
if(typeof G.use.conditions.body!=="object"){
G.use.conditions.body={less:false};}
if(re){
G.use.conditions.body.re=re;
G.use.conditions.body.sub=false;
}else{
G.use.conditions.body.re=false;
G.use.conditions.body.sub=set;}
G.wish.body.check.setDisabled(false);
}else{
G.body.legal=false;
if(typeof G.use.conditions==="object"&&typeof G.use.conditions.body==="object"){
if(G.use.conditions.body.less){
G.use.conditions.body.re=false;
G.use.conditions.body.sub=false;
}else{
G.use.conditions.body=false;}}}
}else{
G.wish.body.check.setSelected(false);
G.wish.body.check.setDisabled(true);
if(typeof G.use.conditions==="object"&&typeof G.use.conditions.body==="object"){
G.use.conditions.body=false;}}
};
G.body.flip=function(){
G.use.conditions.body.less=G.wish.body.check.isSelected();
};
G.cat.fairly=function(){
return G.cat.legal;
};
G.cat.finish=function(){
var s=G.wish.category.getValue().trim();
G.use.sub=false;
if(s){
s=G.front(s,14);
s=s.substr(0,1).toUpperCase()+s.substr(1);
if(G.fine(s)){
G.use.sub=s;}
G.wish.category.setValue(s);}
G.wish.run.setDisabled((G.use.sub?false:true));
};
G.cat.fired=function(){
var s=G.wish.category.getValue(),k;
if(s){
k=s.indexOf("#");
if(k>=0){
s=s.substr(0,k);}
s=G.fair(s);
if(s.substr(0,1)===" "){
s=s.substr(1);}
if(s.indexOf(":")>=0){
if(typeof G.reColonLead!=="object"){
G.reColonLead=new RegExp("^[: ]+","g");}
s=s.replace(G.reColonLead,"");}
G.wish.category.setValue(s);}
G.cat.legal=(s&&G.fine(s));
};
G.cat.foreign=function(assign){
var s;
if(typeof assign==="string"){
s=assign.trim();
if(s){
G.wish.category.setValue(s);
G.cat.fired();
G.head.form();}}
};
G.direct.files=function(apply){
var s=apply,g,i,q,s2;
if(typeof G.direct.reBrackOpen!=="object"){
G.direct.reBrackOpen=new RegExp("\\[\\[","g");
G.direct.reBrackTerm=new RegExp("\\]\\]","g");
G.direct.reBrackPipe=new RegExp("^\\[\\[:?([^|]+:[^|]+)(:?\\|.*)?\\]\\]$");}
s=s.replace(G.direct.reBrackTerm,"]]\n").replace(G.direct.reBrackOpen,"\n[[");
q=s.split("\n");
for(i=q.length-1;i>=0;i--){
s=q[i].trim();
if(s.indexOf(".")>0){
if(s.indexOf("]]")>0){
g=G.direct.reBrackPipe.exec(s);
if(g){
s2=g[1].trim();
s=G.front(s2,6);
if(s===s2||!G.fine(s)){
s=false;}
}else{
s=false;}}
}else{
s=false;}
if(s){
q[i]=s;
}else{
q.splice(i,1);}}
return q.join("\n");
};
G.direct.finish=function(){
var s=G.wish.direct.getValue().trim(),g,i,k,q,sub;
G.use.directs=false;
if(s){
if(s.indexOf(">")>0){
if(typeof G.direct.reTag!=="object"){
G.direct.reTag=new RegExp("<[a-z/A-Z][^<>]*>","g");}
s=s.replace(G.direct.reTag,"\n");}
if(s.indexOf("]]")>0){
s=G.direct.files(s);}
if(s.indexOf("|")>=0){
if(typeof G.direct.rePipe!=="object"){
G.direct.rePipe=new RegExp("\\|","g");}
s=s.replace(G.direct.rePipe,"\n");}
G.extensions.factory();
q=s.split("\n");
for(i=q.length-1;i>=0;i--){
s=G.fair(q[i].trim());
k=s.lastIndexOf(".");
if(k>0&&s.indexOf("/")<=0&&s.indexOf("#")<=0&&G.fine(s)){
sub=s.substr(k+1).toLowerCase();
sub=G.extensions.flat(sub);
if(typeof G.extensions.valid[sub]==="boolean"){
if(s.indexOf(":")>=0){
if(typeof G.reColonLead!=="object"){
G.reColonLead=new RegExp("^[: ]+","g");}
s=s.replace(G.reColonLead,"");
s=G.front(s,6);}
s=s.substr(0,1).toUpperCase()+s.substr(1);
}else{
s=false;}
}else{
s=false;}
if(s){
q[i]=s;
}else{
q.splice(i,1);}}
g={};
for(i=q.length-1;i>=0;i--){
s=q[i];
if(typeof g[s]==="boolean"){
q.splice(i,1);
}else{
g[s]=true;}}
if(q.length){
G.use.directs=q;
s=q.join("\n");
}else{
s="";}}
G.wish.direct.setValue(s);
G.wish.run.setDisabled((G.use.directs?false:true));
};
G.direct.foreign=function(assign){
var s;
if(typeof assign==="string"){
s=assign.trim();
if(s){
G.direct.$textarea.show();
G.wish.direct.setValue(s);
G.direct.finish();
G.head.form();}}
};
G.extensions.factory=function(){
var ext=G.extensions,g,i,s;
if(!ext.valid){
ext.valid={};
for(s in ext.groups){
g=ext.groups[s].split(" ");
for(i=0;i<g.length;i++){
ext.valid[g[i]]=true;}}
ext.groups.image=ext.groups.pixel+" "+ext.groups.vector;}
};
G.extensions.filter=function(allow){
var ext,r;
if(G.use.conditions&&typeof G.use.conditions.ext==="object"&&typeof G.use.conditions.ext.less==="boolean"&&typeof G.use.conditions.ext.permit==="object"){
ext=G.use.conditions.ext;
r=(typeof ext.permit[allow]==="boolean");
r=(ext.less?!r:r);
}else{
r=true;}
return r;
};
G.extensions.finder=function(){
var permit=G.use.conditions.ext.suffix.split(" "),g,i,k,s;
G.use.conditions.ext.permit={};
for(i=0;i<permit.length;i++){
s=permit[i];
k=s.indexOf("/*");
if(k<0){
G.use.conditions.ext.permit[s]=true;
}else{
g=G.extensions.groups[s.substr(0,k)].split(" ");
for(k=0;k<g.length;k++){
G.use.conditions.ext.permit[g[k]]=true;}}}
};
G.extensions.fired=function(){
var ext=G.extensions,set=G.wish.extensions.text.getValue().trim(),g,got,i,k,s;
if(set){
G.extensions.factory();
set=set.replace(G.reSpc," ").toLowerCase();
g=set.split(" ");
set="";
got={};
for(i=0;i<g.length;i++){
s=ext.flat(g[i]);
if(typeof ext.valid[s]!=="boolean"){
k=s.length-2;
if(k<4||s.substr(k)!=="/*"||
typeof ext.groups[s.substr(0,k)]!=="string"){
s=false;}}
if(s){
if(typeof got[s]!=="boolean"){
set=set+(set?" ":"")+s;
got[s]=true;}}}}
G.wish.extensions.text.setValue(set);
if(set){
if(typeof G.use.conditions!=="object"){
G.use.conditions={};}
if(typeof G.use.conditions.ext!=="object"){
G.use.conditions.ext={less:false};}
G.use.conditions.ext.suffix=set;
G.wish.extensions.check.setDisabled(false);
}else{
G.wish.extensions.check.setSelected(false);
G.wish.extensions.check.setDisabled(true);
if(typeof G.use.conditions==="object"&&typeof G.use.conditions.ext==="object"){
G.use.conditions.ext=false;}}
};
G.extensions.flat=function(after){
var r;
if(typeof G.extensions.unique[after]==="string"){
r=G.extensions.unique[after];
}else{
r=after;}
return r;
};
G.extensions.flip=function(){
G.use.conditions.ext.less=G.wish.extensions.check.isSelected();
};
G.head.fault=function(alert){
if(G.head.$error){
G.head.$error.empty();
if(alert){
G.head.$error.text(alert).show();
}else{
G.head.$error.hide();}}
};
G.head.feeder=function(assigned){
var lock;
if(assigned){
lock=(assigned.data!=="Category");
G.use.source=assigned.data;
G.wish.category.setDisabled(lock);
if(assigned.data==="Direct"){
G.direct.$textarea.show();
}else{
G.direct.$textarea.hide();}}
G.wish.run.setDisabled(!(lock||G.use.sub));
};
G.head.figure=function(assign,assigned){
var n,o,w,$e,$i,$t;
if(typeof assigned==="string"){
n=parseInt(assigned,10);
if(!n||isNaN(n)){
n=G.use[assign];
}else{
o=G.query[assign];
if(n<o.min){
n=o.min;
}else if(n>o.max){
n=o.max;}}
w=G.wish[assign];
w.setValue(n+"");
}else{
o=G.query[assign];
n=o.value;
w=new OO.ui.NumberInputWidget({allowInteger:true,maxLength:5,title:"≤"+o.max,input:{value:n},min:o.min,max:o.max,step:o.step});
G.use[assign]=o.value;
w.on("change",G.head.figure,[assign]);
G.wish[assign]=w;
$e=w.$element;
$e.css({"float":(G.ltr?"left":"right"),"margin-bottom":"1em",
"width":"11em"});
$t=$("<div>");
$t.css({"float":(G.ltr?"left":"right"),"margin":"0 1em"})
.text(PREGO.translation(TEXTS[assign]));
$i=$("<div>");
$i.css({"clear":"both"}).append($e,$t);
G.head.$options.append($i);}
G.use[assign]=n;
switch(assign){
case "descr":
break;
case "part":
G.api.incr=n;
break;
case "rows":
G.api.more=n;
G.table.fiat();
break;
case "thumb":
break;}
};
G.head.filter=function(assign,about,abbr){
var $d=$("<div>"),$i=$("<div>"),$w=$("<div>"),start=(G.ltr?"left":"right"),w=new OO.ui.TextInputWidget({type:"text"}),sign=assign.substr(0,1).toUpperCase(),$c,$e;
$d.css({"float":start,"margin":"1em"})
.text(PREGO.translation(TEXTS["filter"+sign]));
if(typeof about==="string"){
w.setTitle(about);}
$e=w.$element;
$e.css({"float":start,"margin":"0.5em 1em 0.5em 1em",
"width":(abbr?"15em":"25em")});
if(sign==="B"){
w.on("change",G.body.fired);
w.setValidation(G.body.fairly);
}else if(sign==="E"){
$e.find("input").blur(G[assign].fired);}
G.wish[assign].text=w;
w=new OO.ui.CheckboxInputWidget({disabled:true});
w.on("change",G[assign].flip);
$c=w.$element;
$c.css({"float":start,"margin":"1em 0.5em 0em 0.5em"});
$i.css({"float":start,"margin-top":"1em"})
.text(PREGO.translation(TEXTS.invert));
G.wish[assign].check=w;
$w.css({"clear":"both","margin-top":"0.5em"})
.append($d,$e,$c,$i);
G.head.$request.append($w);
};
G.head.fire=function(){
var checkbox,checked,columns,i,s,suitable,suite;
G.head.flip();
checked=G.wish.columns.findSelectedItems();
if(checked&&typeof checked==="object"&&typeof checked.length==="number"&&checked.length){
columns={};
suite="";
for(i=0;i<checked.length;i++){
checkbox=checked[i];
columns[checkbox.data]=true;}
suitable="^"+G.genuine[G.use.source].clm;
for(i=0;i<suitable.length;i++){
s=suitable.substr(i,1);
if(typeof columns[s]==="boolean"){
suite=suite+s;}}}
G.wish.cache.setDisabled(false);
G.table.first(G.use.source,suite);
};
G.head.first=function(){
var $e;
G.head.$doc.attr({href:"https://"+PREGO.translation(TEXTS.Domain)+"/wiki/User:PerfektesChaos/js/"+Signature,target:Signature});
$e=$("<div>");
$e.css({"font-size":"111%"}).html(PREGO.translation(TEXTS.About));
G.$page.append($e);
$e=$("<hr>");
$e.css({"margin":"1em 0","padding-top":"0.5em"});
G.$page.append($e);
};
G.head.flat=function(){
G.wish.cache.setDisabled(true);
MEDIA={};
};
G.head.flip=function(){
G.head.$error.hide();
G.head.$show.show();
G.head.$request.hide();
G.head.$run.hide();
};
G.head.focus=function(){
G.wish.origin.selectItemByData("Category");
G.wish.category.setDisabled(false);
G.wish.category.setValue(G.use.sub);
G.head.feeder();
G.head.form();
G.wish.origin.focus();
};
G.head.form=function(){
var gen,i,s,see,w,$e;
if(G.head.$wrap){
G.head.$error.hide();
G.head.$show.hide();
G.head.$hide.show();
G.head.$request.show();
G.head.$run.show();
G.head.$cache.show();
}else{
G.head.$wrap=$("<div>");
G.wish={body:{},clms:[],extensions:{},origins:[]};
G.head.$request=$("<div>");
w=new OO.ui.ButtonWidget({icon:"expand",iconTitle:"expand"});
w.on("click",G.head.form);
G.head.$show=w.$element;
G.head.$show.css({"margin-bottom":"1em"}).hide();
w=new OO.ui.ButtonWidget({icon:"collapse",iconTitle:"collapse"});
w.on("click",G.head.flip);
G.head.$hide=w.$element;
G.head.$hide.css({"margin-bottom":"1em"}).hide();
$e=$("<div>");
$e.css({"clear":"both"});
G.head.$request.append(G.head.$show,G.head.$hide,$e);
w=new OO.ui.TextInputWidget({disabled:true,required:true,type:"text"
});
w.on("change",G.cat.fired);
w.setValidation(G.cat.fairly);
G.wish.category=w;
for(i=0;i<G.origin.length;i++){
s=G.origin[i];
see=TEXTS[s];
gen=G.genuine[s];
if(gen.list){
see=TEXTS.Special+": "+see;}
w=new OO.ui.RadioOptionWidget({data:s,disabled:!gen.live,label:see});
G.wish.origins.push(w);}
s=PREGO.translation(TEXTS.origin);
w=new OO.ui.RadioSelectWidget({items:G.wish.origins,text:s});
w.on("choose",G.head.feeder);
G.wish.origin=w;
w.$element.css({"max-width":"35%"});
G.head.$request.append(w.$element);
$e=G.wish.category.$element;
$e.css({"display":"inline-block","margin-top":"2em",
"float":(G.ltr?"right":"left"),"width":"60%"});
$e.find("input").blur(G.cat.finish);
G.wish.origin.$element.before($e);
w=new OO.ui.MultilineTextInputWidget({required:true,rows:10,type:"text"
});
G.direct.$textarea=w.$element;
G.direct.$textarea.hide();
G.direct.$textarea.find("textarea").blur(G.direct.finish);
G.wish.direct=w;
G.wish.origin.$element.after(G.direct.$textarea);
for(i=0;i<G.head.columns.length;i++){
s=G.head.columns.substr(i,1);
see=PREGO.translation(TEXTS["clm."+s]);
w=new OO.ui.CheckboxMultioptionWidget({data:s,label:see});
G.wish.clms.push(w);}
s=PREGO.translation(TEXTS.columns);
w=new OO.ui.CheckboxMultiselectWidget({items:G.wish.clms,text:s});
G.wish.columns=w;
$e=w.$element;
$e.css({"margin-top":"1em"});
G.head.$request.append($e);
$e=$("<div>");
$e.css({"margin-top":"2em"}).text(PREGO.translation(TEXTS.filter));
G.head.$request.append($e);
G.head.filter("body",PREGO.translation(TEXTS.filterBt));
G.head.filter("extensions",TEXTS.typesEx,true);
G.head.$options=$("<div>");
G.head.$options.css({"clear":"both","padding-top":"2em"});
G.head.figure("rows");
G.head.figure("part");
G.head.figure("thumb");
G.head.figure("descr");
w=new OO.ui.ButtonWidget({disabled:true,flags:["primary","progressive"],label:TEXTS.go});
w.on("click",G.head.fire);
G.wish.run=w;
G.head.$run=$("<div>");
G.head.$run.css({"clear":"both"}).append(w.$element);
s=PREGO.translation(TEXTS.cache);
w=new OO.ui.ButtonWidget({flags:["primary","destructive"],label:s});
w.on("click",G.head.flat);
G.wish.cache=w;
G.head.$cache=$("<div>");
G.head.$cache.css({"float":(G.ltr?"right":"left")}).hide().append(w.$element);
G.head.$run.append(G.head.$cache);
G.head.$error=$("<div>");
G.head.$error.addClass("error").css({"background-color":"#FFFF00",
"border":"#FF0000 2px solid","clear":"both",
"color":"#FF0000","margin":"2em 0",
"padding":"0.5em"
}).hide();
G.head.$wrap.append(G.head.$show,G.head.$request,G.head.$options,G.head.$run,G.head.$error);
G.$page.append(G.head.$wrap);
mw.hook(Signature+".category").add(G.cat.foreign);
mw.hook(Signature+".files").add(G.direct.foreign);}
};
G.table.feature=function(active){
var sign,$btn;
if(typeof active.target==="object"){
$btn=$(active.target);
sign=$btn.data("file");
if(typeof MEDIA[sign]==="object"&&typeof MEDIA[sign].D==="string"&&MEDIA[sign].D){
G.table.featured(sign,MEDIA[sign].D);
}else{
G.api.dc.feed(sign,G.table.featured);}}
};
G.table.featured=function(at,about){
var j,$btn,$span,$td,$tr;
if(about){
MEDIA[at].D=about;
j=G.table.suite.indexOf("D");
$tr=G.table.$table.find("#"+G.flat(at));
if($tr.length&&j>1){
$td=$tr.children().eq(j);
$td.empty();
if(about===true){
$td.text("—");
}else{
$td.css({"text-align":(G.ltr?"left":"right"),"vertical-align":"top"});
j=about.length-G.use.descr;
if(j<20){
$td.text(about);
}else{
$span=$("<span>");
$span.text(about.substr(0,G.use.descr)+" … ");
$btn=$("<button>");
$btn.attr({"data-file":at}).click(G.table.features).text("+"+j);
$td.append($span,$btn);}}}}
};
G.table.features=function(active){
var sign,$btn,$td;
if(typeof active.target==="object"){
$btn=$(active.target);
sign=$btn.data("file");
$td=$btn.parent();
$td.empty().text(MEDIA[sign].D);}
};
G.table.fed=function(arrived){
var c,d,e,g,i,k,s,src,st,stem,suffix,$a,$cb,$td,$tr;
G.table.max--;
if(G.table.max&&arrived){
for(i=0;i<arrived.length;i++){
e=arrived[i];
if(!e){
arrived=false;
if(G.table.$retrieve){
G.table.$retrieve.hide();}
break;}
src=e[0];
if(typeof MEDIA[src]==="object"){
d=MEDIA[src];
}else{
d={};}
g=G.table.reBodyExt.exec(src);
if(g){
stem=g[1];
suffix=G.extensions.flat(g[2].toLowerCase());
}else{
stem="???";
suffix="???";}
if(G.body.filter(stem)&&G.extensions.filter(suffix)){
if(typeof d.M!=="string"){
d.M=suffix;}
G.table.items++;
$tr=$("<tr>");
$tr.attr({id:G.flat(src)});
if(e.length>1){
g=e[1];
for(s in g){
d[s]=g[s];}}
g={"#":G.table.items,"^":"",
"@":src,"$tr":$tr};
for(k=0;k<G.table.suite.length;k++){
s=G.table.suite.substr(k,1);
if(typeof d[s]==="string"){
g[s]=d[s];}}
for(k=0;k<G.table.suite.length;k++){
s=G.table.suite.substr(k,1);
$td=$("<td>");
c=G.query.columns[s];
if(typeof c.type==="string"&&c.type==="n"){
$td.css({"text-align":
(G.ltr?"right":"left")});}
st=typeof g[s];
if(st==="string"||st==="number"){
switch(s){
case "^":
$cb=$("<input>");
$cb.addClass("markfile").attr({"type":"checkbox"})
.change(G.table.flip);
$td.append($cb).attr({"data-sort-value":"-"});
break;
case "@":
s=g[s];
$a=$("<a>");
$a.attr({href:mw.util.getUrl("File:"+s),target:G.use.target}).text(s);
$td.append($a);
break;
default:
$td.text(g[s]);}
}else{
g[s]=null;}
$tr.append($td);}
G.table.query.push(g);
G.table.$tbody.append($tr);}
MEDIA[src]=d;}
}else if(arrived===false&&G.table.$retrieve){
G.table.$retrieve.hide();}
if(G.table.max&&arrived&&G.table.query.length<G.table.rows){
i=5+45*G.table.query.length / G.table.rows;
G.table.progress.setProgress(i);
if(G.table.list){
G.api.qp.feed();
}else if(G.use.source==="Category"){
G.api.cm.feed();
}else{
G.table.further();}
}else{
G.table.progress.setProgress(50);
G.table.further();
if(!G.table.list){
if(G.use.source==="Category"){
G.api.cm.feed(true,G.table.friends);}}}
};
G.table.fiat=function(){
if(G.table.retrieve){
G.table.retrieve.setLabel("+"+G.api.more);}
};
G.table.file=function(active){
var sign,$btn;
if(typeof active.target==="object"){
$btn=$(active.target);
sign=$btn.data("file");
if(typeof MEDIA[sign]==="object"&&typeof MEDIA[sign].I==="object"&&MEDIA[sign].I){
G.table.filed(sign,MEDIA[sign].I);
}else{
G.api.th.feed(sign);}}
};
G.table.filed=function(at,about){
var j=G.table.suite.indexOf("I"),$tr=G.table.$table.find("#"+G.flat(at)),$img,$td;
MEDIA[at].I=about;
if($tr.length&&j>1){
$td=$tr.children().eq(j);
$td.empty();
if(about){
if(!G.table.thumb.css){
G.table.thumb.css={"background":"transparent repeat scroll 0% 0% url('//upload.wikimedia.org/wikipedia/commons/"+G.table.thumb.src+"')"};}
$img=$("<img>");
$img.attr({src:about.u,height:about.h,width:about.w});
$td=$tr.children().eq(j);
$td.css(G.table.thumb.css).append($img);}}
};
G.table.fill=function(){
var i,j,g,q,s,sign,$td,$tr;
G.table.progress.setProgress(70);
for(i=0;i<G.table.query.length;i++){
q=G.table.query[i];
if(q){
sign=q["@"];
if(typeof MEDIA[sign]==="object"){
g=MEDIA[sign];
for(s in q){
if(q[s]===null&&typeof g[s]!=="undefined"){
j=G.table.suite.indexOf(s);
$tr=q.$tr;
$td=$tr.children().eq(j);
$td.text(g[s]);}}
j=70+20*i / G.table.query.length;
G.table.progress.setProgress(j);}}}
G.table.furnish("D");
G.table.furnish("I");
delete G.table.query;
G.table.progress.setProgress(90);
G.table.finish();
};
G.table.filling=function(apply,after){
var e,g,s,sub;
G.table.progress.setProgress(60);
for(s in apply){
g=apply[s];
if(typeof MEDIA[s]==="object"){
e=MEDIA[s];
for(sub in g){
e[sub]=g[sub];}
}else{
MEDIA[s]=g;}}
after(true);
};
G.table.finish=function(){
if(G.table.items){
G.table.$abort.hide();
if(G.table.items>1&&typeof G.table.$table.tablesorter==="function"){
G.table.$table.find("thead").remove();
G.table.$table.prepend(G.table.$thead.clone());
G.table.$table.addClass("sortable").tablesorter();}
G.table.$progress.hide();
if(G.table.retrieve){
G.table.retrieve.setDisabled(false);}
G.wikitext.first();
}else{
G.table.$files.remove();
G.table.$files=$("<div>");
G.table.$files.css({"font-size":"1.2em"}).text(PREGO.translation(TEXTS.noFiles));
G.table.$wrap.append(G.table.$files);}
};
G.table.fire=function(){
G.table.max=G.api.incr;
G.table.rows=G.use.rows;
if(G.table.retrieve){
G.table.retrieve.setDisabled(true);}
G.table.progress.setProgress(5);
G.table.progress.setDisabled(false);
G.table.$progress.show();
G.table.$abort.show();
G.table.query=[];
if(G.table.list){
G.api.qp.feed();
}else{
G.api.cm.feed(false,G.table.fed);}
};
G.table.first=function(assign,apply){
var i,show,src,w,$a,$e;
if(G.table.$wrap){
G.table.$wrap.empty();
}else{
G.table.$wrap=$("<div>");
G.$page.append(G.table.$wrap);}
G.table.rows=G.use.rows;
G.table.list=G.genuine[assign].list;
if(G.table.list){
show=TEXTS[assign];
src="Special:"+assign;
}else if(assign==="Category"){
show=TEXTS.Category+":"+G.use.sub;
src="Category:"+G.use.sub;
}else if(assign==="Direct"){
show=PREGO.translation(TEXTS.plain);
}else{
show="????????";}
if(src){
$a=$("<a>");
$a.attr({href:mw.util.getUrl(src),target:G.use.target});
}else{
$a=$("<span>");}
$a.text(show);
$e=$("<h2>");
$e.css({"clear":"both","margin-top":"4em"})
.append($a);
G.table.$wrap.append($e);
G.table.$files=$("<div>");
G.table.progress=new OO.ui.ProgressBarWidget({progress:5});
G.table.$progress=G.table.progress.$element;
G.table.$progress.css({"margin-bottom":"1em"});
G.table.$files.append(G.table.$progress);
w=new OO.ui.ButtonWidget({flags:["primary","destructive"],icon:"clear",iconTitle:"abort"});
w.on("click",G.table.flop);
G.table.$abort=$("<div>");
G.table.$abort.css({"clear":"both","float":(G.ltr?"right":"left")})
.hide().append(w.$element);
G.table.$files.append(G.table.$abort);
if(G.table.list||src){
w=new OO.ui.ButtonWidget({disabled:true,flags:["primary","progressive"],label:"+"+G.api.more});
w.on("click",G.table.fire);
G.table.retrieve=w;
G.table.$retrieve=w.$element;
G.table.$files.append(G.table.$retrieve);
}else{
G.table.retrieve=false;
G.table.$retrieve=false;}
G.table.frame(assign,apply);
G.table.$wrap.append(G.table.$files);
G.table.items=0;
G.table.query=[];
if(!G.table.reBodyExt){
G.table.reBodyExt=new RegExp("^(.+)\\.([a-zA-Z0-9]+)$");
G.reDot=new RegExp("\\.","g");
G.reSpc=new RegExp("\\s+","g");}
if(G.use.conditions&&typeof G.use.conditions.ext==="object"){
G.extensions.finder();}
G.table.max=G.api.incr;
if(G.table.list){
G.api.qp.feed(assign,G.table.fed);
}else if(src){
G.table.$cats=false;
G.api.cm.feed(false,G.table.fed,G.use.sub);
}else{
w=[];
for(i=0;i<G.use.directs.length;i++){
w.push([G.use.directs[i]]);}
G.table.rows=G.use.directs.length;
G.table.fed(w);}
};
G.table.flip=function(){
var $cb=$(this),$td=$cb.parent();
$td.attr({"data-sort-value":($cb.prop("checked")?"+":"-")});
};
G.table.flop=function(){
G.table.progress.setDisabled(true);
G.table.$abort.hide();
G.api.flop();
};
G.table.frame=function(assign,apply){
var c,i,s,show,sort,$th,$tr;
G.table.source=assign;
G.table.learn=false;
if(apply){
if(apply.substr(0,1)==="^"){
G.table.learn=true;
G.table.suite="#^@"+apply.substr(1);
}else{
G.table.suite="#@"+apply;}
}else{
G.table.suite="#@";}
G.table.$table=$("<table>");
G.table.$table.addClass("wikitable").css({"margin-top":"2em"});
G.table.$thead=$("<thead>");
$tr=$("<tr>");
for(i=0;i<G.table.suite.length;i++){
s=G.table.suite.substr(i,1);
$th=$("<th>");
if(s==="^"){
show="mark";
}else{
show="clm."+s;}
$th.text(PREGO.translation(TEXTS[show]));
c=G.query.columns[s];
if(typeof c.type==="string"){
switch(c.type){
case "n":
sort="number";
break;
default:
sort="text";}
$th.attr({"data-sort-type":sort});
}else{
$th.addClass("unsortable");}
$tr.append($th);}
G.table.$thead.append($tr);
G.table.$tbody=$("<tbody>");
G.table.$table.append(G.table.$thead.clone(),G.table.$tbody);
G.table.$files.append(G.table.$table);
};
G.table.friendly=function(adult,arrived){
var i,s,$btn,$div,$e;
if(arrived&&arrived.length){
$div=$("<div>");
$div.css({"margin-top":"3em"});
G.table.$cats.append($div);
$btn=$("<button>");
$btn.text(String.fromCharCode((adult?8593:8595)));
for(i=0;i<arrived.length;i++){
s=arrived[i];
$div=$("<div>");
if(s){
$e=$("<span>");
$e.css({"margin":"0 1em"}).text(s);
$div.css({"margin-top":"0.5em"}).append($btn.clone().attr({"data-cat":s})
.click(G.table.friendship),$e);
}else{
$div.text("… …");}
G.table.$cats.append($div);}}
if(adult&&!G.table.$cats.children().length){
G.table.$cats.text(PREGO.translation(TEXTS.noCat));}
};
G.table.friends=function(arrived){
if(G.table.$cats){
G.table.friendly(true,arrived);
}else{
G.table.$cats=$("<div>");
G.table.friendly(false,arrived);
G.table.$wrap.append(G.table.$cats);
G.api.cl.feed(G.use.sub,G.table.friends);}
};
G.table.friendship=function(active){
var $btn;
if(typeof active.target==="object"){
$btn=$(active.target);
G.use.sub=$btn.data("cat");
G.head.focus();}
};
G.table.furnish=function(ask){
var j=G.table.suite.indexOf(ask),i,q,s,$btn,$td,$tr;
if(j>1){
for(i=0;i<G.table.query.length;i++){
q=G.table.query[i];
s=q["@"];
if(ask!=="D"||typeof MEDIA[s].L!=="boolean"||MEDIA[s].L){
if(typeof q[ask]!=="string"){
q[ask]=false;}
$tr=q.$tr;
$td=$tr.children().eq(j);
$btn=$("<button>");
$btn.attr({"data-file":s}).click((ask==="I"?G.table.file:G.table.feature))
.text("+");
$td.css({"text-align":"center","vertical-align":"middle"})
.append($btn);}}}
};
G.table.further=function(){
var props={},follow,get,i,q,s,suck;
G.api.fi.titles=[];
G.api.rv.titles=[];
for(i=G.table.query.length-1;i>=0;i--){
q=G.table.query[i];
get={F:false,D:false};
for(s in q){
if(q[s]===null){
suck=G.query.columns[s].api;
if(suck){
props[suck]=true;
get[suck.substr(0,1)]=true;}}}
if(get.F||get.D){
if(get.F){
G.api.fi.titles.push(q["@"]);}
if(get.D){
G.api.rv.titles.push(q["@"]);}}}
G.table.progress.setProgress(55);
if(G.api.rv.titles.length){
follow=G.api.rv.feed;
suck="";
for(s in props){
if(s.substr(0,1)==="D"){
suck=suck+"|"+s.substr(1);}}
G.api.rv.props=suck.substr(1);
G.api.rv.follow=G.table.fill;
}else{
follow=G.table.fill;}
if(G.api.fi.titles.length){
suck="";
for(s in props){
if(s.substr(0,1)==="F"){
suck=suck+"|"+s.substr(1);}}
G.api.fi.props=suck.substr(1);
G.api.fi.follow=follow;
G.api.fi.feed(G.table.filling);
}else{
follow(true);}
G.table.progress.setProgress(60);
};
G.wikitext.fetch=function(ask){
var k=G.table.suite.indexOf("@"),$rows=G.table.$tbody.children(),i,j,s,stuff,story,suite,o,w,$tr;
if(ask){
story="{| class=\"wikitable\"\n"+"|-\n"+"! ";
suite=G.table.suite.substr(k);
if(typeof G.wikitext.reI!=="object"){
G.wikitext.reI=new RegExp("I");
G.wikitext.rePipe=new RegExp("|","g");
G.wikitext.reLT=new RegExp("<","g");}
suite=suite.replace(G.wikitext.reI,"");
for(j=0;j<suite.length;j++){
s=suite.substr(j,1);
if(j){
story=story+" !! ";}
story=story+PREGO.translation(TEXTS["clm."+s]);}
story=story+"\n";
}else{
story="";}
for(i=0;i<$rows.length;i++){
$tr=$rows.eq(i);
if(G.table.learn&&!$tr.find(".markfile").prop("checked")){
$tr=false;}
if($tr){
s=$tr.children().eq(k).text();
if(ask){
story=story+"|-\n| [["+TEXTS["clm.@"].en+":"+s+"|"+s+"]]\n";
if(typeof MEDIA[s]==="object"){
o=MEDIA[s];
for(j=1;j<suite.length;j++){
s=suite.substr(j,1);
story=story+"| ";
stuff=o[s]||"";
if(s==="D"){
story=story+stuff.replace(G.wikitext.rePipe,"{{!}}").replace(G.wikitext.reLT,"&lt;");
}else{
story=story+stuff;}
story=story+"\n";}}
}else{
story=story+s+"\n";}}}
if(ask){
story=story+"|}";}
if(typeof G.wikitext.$textarea==="object"){
if(!story){
G.wikitext.$textarea.hide();}
}else if(story){
w=new OO.ui.MultilineTextInputWidget({rows:10,type:"text"
});
G.wikitext.textarea=w;
G.wikitext.$textarea=w.$element;
G.wikitext.$textarea.css({"clear":"both","padding-top":"1em"});
G.table.$wrap.append(G.wikitext.$textarea);}
if(story){
G.wikitext.textarea.setValue(story);
G.wikitext.$textarea.show();}
};
G.wikitext.files=function(){
G.wikitext.fetch(false);
};
G.wikitext.fill=function(apply){
var $c=G.table.$table.find(".markfile");
$c.prop("checked",apply);
};
G.wikitext.first=function(){
var side=(G.ltr?"left":"right"),$block=$("<div>"),$h3=$("<h3>"),s,w,$div;
$h3.text(PREGO.translation(TEXTS.exports));
G.table.$wrap.append($h3);
if(G.table.learn){
s=PREGO.translation(TEXTS.markAll);
w=new OO.ui.ButtonWidget({flags:["progressive"],label:s});
w.on("click",G.wikitext.flag);
$div=$("<div>");
$div.append(w.$element).css({"float":side});
$block.append($div);
s=PREGO.translation(TEXTS.markNone);
w=new OO.ui.ButtonWidget({flags:["progressive"],label:s});
w.on("click",G.wikitext.flat);
$div=$("<div>");
$div.append(w.$element).css("margin-"+side,"3em").css({"float":side});
$block.append($div).css({"padding-top":"1em","padding-bottom":"2em"});
G.table.$wrap.append($block);
$block=$("<div>");}
$block.css({"padding-top":"1em"});
s=PREGO.translation(TEXTS.exportW);
w=new OO.ui.ButtonWidget({flags:["primary","progressive"],label:s});
w.on("click",G.wikitext.full);
$div=$("<div>");
$div.append(w.$element).css({"float":side});
$block.append($div);
s=PREGO.translation(TEXTS.exportX);
w=new OO.ui.ButtonWidget({flags:["primary","progressive"],label:s});
w.on("click",G.wikitext.files);
$div=$("<div>");
$div.append(w.$element).css("margin-"+side,"3em").css({"float":side});
$block.append($div).css({"clear":"both"});
G.table.$wrap.append($block);
};
G.wikitext.flag=function(){
G.wikitext.fill(true);
};
G.wikitext.flat=function(){
G.wikitext.fill(false);
};
G.wikitext.full=function(){
G.wikitext.fetch(true);
};
first();
}(window.mediaWiki,window.jQuery));
/// EOF</nowiki>filesMetaData/lib/r.js