User:PerfektesChaos/js/autoBackup/r.js: Difference between revisions

Content deleted Content added
1.3
2.2
 
(6 intermediate revisions by the same user not shown)
Line 1:
/// User:PerfektesChaos/js/autoBackup/r.js
/// 20132019-0807-2301 PerfektesChaos@de.wikipedia
/// Fingerprint:#0#7A0845C62860E0F5#
/// @license GPL [//www.mediawiki.org/w/COPYING](+GFDL,LGPL,:CC-BYby-SA)sa/4.0
///<nowiki>
(function(mw,$){
"use strict";
var BAK,vsnVERSION=12.3,BAK="autoBackup";
if(typeof mw.libs.autoBackup[BAK]!=="object"||!mw.libs.autoBackup[BAK]){
mw.libs.autoBackup[BAK]={};}
BAK=mw.libs[BAK].autoBackuptype=BAK;
BAK=mw.libs[BAK];
BAK.doc="[[w:en:User:PerfektesChaos/js/autoBackup"+BAK+"]]";
BAK.typevsn="autoBackup"VERSION;
BAK.vsn=vsn;
BAK.cnf={maxAge:72,maxHist:5,maxPages:10,maxRev:3,mid:5,msec:300000};
BAK.disk={self:"AutoBackupPerfectChaos",stick:"newest|subject"};
Line 19:
if(!typeof BAK.opt||typeof BAK.opt!=="object"){
BAK.opt={};}
if(typeof BAK.debugging!=="object"){
BAK.debugging={loud:true,say:"autoBAK"};}
BAK.cnf.text={
"BAKself":{"en":"AutoBackup",
"BAKself":{"en":"AutoBackup","de":"AutoBackup"},"IntparseJSON":{"en":"Internal ERROR -- parseJSON","de":"Interner FEHLER -- parseJSON"},"NoLSavail":{"en":"No localStorage available","de":"Kein localStorage zugreifbar"},"otherPages":{"en":"Other Pages","de":"Andere Seiten"},"pending":{"en":"Recover from pending abort?","de":"Wiederherstellung nach Abbruch?"},"setItemExcept":{"en":"ERROR setting localStorage","de":"FEHLER beim Setzen im localStorage"},"thisPage":{"en":"this page","de":"diese Seite"},"VanishedLS":{"en":"ERROR: localStorage vanished","de":"FEHLER: localStorage verschwunden"},"WriteCrash":{"en":"Crash on localStorage write attempt","de":"Schreibversuch auf localStorage versagt"}
"de":"AutoBackup"},
"IntJSONparse":{"en":"Internal ERROR -- JSON.parse",
"de":"Interner FEHLER -- JSON.parse"},
"NoLSavail":{"en":"No localStorage available",
"de":"Kein localStorage zugreifbar"},
"otherPages":{"en":"Other Pages",
"de":"Andere Seiten"},
"pending":{"en":"Recover from pending abort?",
"de":"Wiederherstellung nach Abbruch?"},
"setItemExcept":{"en":"ERROR setting localStorage",
"de":"FEHLER beim Setzen im localStorage"},
"thisPage":{"en":"this page",
"de":"diese Seite"},
"VanishedLS":{"en":"ERROR: localStorage vanished",
"de":"FEHLER: localStorage verschwunden"},
"WriteCrash":{"en":"Crash on localStorage write attempt",
"de":"Schreibversuch auf localStorage versagt"}
};
BAK.cnf.translang={
"de":"de",
"de":"de","de-at":"de","de-ch":"de","de-formal":"de","als":"de","bar":"de","dsb":"de","frr":"de","gsw":"de","hsb":"de","ksh":"de","lb":"de","nds":"de","pdc":"de","pdt":"de","pfl":"de","sli":"de","stq":"de","vmf":"de"
"de-at":"de",
"de-ch":"de",
"de-formal":"de",
"als":"de",
"bar":"de",
"dsb":"de",
"frr":"de",
"gsw":"de",
"hsb":"de",
"ksh":"de",
"lb":"de",
"nds":"de",
"pdc":"de",
"pdt":"de",
"pfl":"de",
"sli":"de",
"stq":"de",
"vmf":"de"
};
BAK.cnf.favorite=function(){
Line 89 ⟶ 122:
if(s){
try{
BAK.pages=$JSON.parseJSONparse(s);
}catch(e){
BAK.gui.flag("IntparseJSONIntJSONparse",false);
window.localStorage.setItem(this.storage,"");}}
}else{
Line 98 ⟶ 131:
};
BAK.disk.flush=function(){
var s,store=false,s;
if(typeof BAK.pages==="object"){
for(s in BAK.pages){
Line 107 ⟶ 140:
if(typeof window.localStorage==="object"){
if(BAK.pages){
store=$JSON.toJSONstringify(BAK.pages);
if(store==="{}"){
store="";}
Line 139 ⟶ 172:
this.$top=$("#content");
if(!this.$top.length){
this.$top=mw.utilBAK.$contentpage;}}}
this.$top.before(this.$div);}}}
if(apply){
Line 156 ⟶ 189:
};
BAK.gui.facility=function(){
var portlet,$portlet;
var script="javascript",shoot=script+":window.mw.libs.autoBackup.fresh();void(0);";
if(!BAK.cnf.self){
BAK.cnf.self=BAK.cnf.feature("BAKself");}
portlet=mw.util.addPortletLink("p-cactions",shoot"#",BAK.cnf.self,"ca-AutoBackup",null,null,null+BAK.type);
$portlet=$(portlet);
$portlet.click(BAK.fresh);
$portlet.attr({title:BAK.type+" "+BAK.vsn});
};
BAK.gui.feed=function(){
var r=false,$form,$ta;
var $form;
var $ta;
if(this.leading){
this.leading=false;
this.$editform=false;
this.$textarea=false;
$form=mw.utilBAK.$contentpage.find("#editform");
if($form){
$ta=mw.utilBAK.$contentpage.find("#wpTextbox2");
if($ta.length){
r=$ta.val();}
Line 201 ⟶ 235:
r="";}
if(r){
r="\n &nbsp; \n<button type='button' id='autoBackup"+action+(add?add:"")+"'>"+r+"</button>";}
return r;
};
BAK.gui.fill=function(){
var page=BAK.pages[BAK.pageID],revs=false,i,n,s;
var revs=false;
var i,n,s;
BAK.gui.$msg.find("#autoBackupALL").remove();
if(BAK.gui.$box){
Line 241 ⟶ 273:
BAK.cnf.self=BAK.cnf.feature("BAKself");}
s=BAK.cnf.feature(apply);
s="<div id='autoBackup' style='border: solid "+(action?2:5)+"px #FF0000; padding: 0.5em;"+(action?"":" color: #FF0000;")+"'>\n"+"<span style='font-size: larger; font-weight: bold;'>"+BAK.cnf.self+"</span> &nbsp;\n"+(action?"":"<span class='error'>")+s+(action?"\n":"</span>\n")+this.fiat(action)+"</div>\n";
this.face(s);
if(action){
Line 247 ⟶ 279:
};
BAK.gui.folder=function(access,album){
var e=access.split(" "),k=e[1],s="autoBackupR"+k,i,w,$div,$textarea;
var i;
var k=e[1];
var s="autoBackupR"+k;
var w;
var $div;
var $textarea;
this.$box.append("<div id='"+s+"' />");
$div=this.$box.find("#"+s);
Line 277 ⟶ 303:
};
BAK.gui.form=function(action,add){
var fun=false,sign,$btn;
var sign;
var $btn;
switch(action){
case "ALL":
Line 359 ⟶ 383:
};
BAK.util.focus=function(appoint){
var r=appoint+" UTC",s=typeof BAK.cnf.justify,g;
var g;
if(s!=="boolean"&&s!=="number"){
var r=appoint+" UTC";
var s;
if(BAK.cnf.justify!==false){
if(typeof BAK.cnf.justify!=="number"){
BAK.cnf.justify=false;
if(typeof mw.user==="object"){
Line 378 ⟶ 399:
if(g){
r=Date.UTC(parseInt(g[1],10),parseInt(g[2],10)-1,parseInt(g[3],10),parseInt(g[4],10),parseInt(g[5],10)+BAK.cnf.justify,parseInt(g[6],10));
r=this.format(new Date(r));}}}
return r;
};
BAK.util.format=function(appoint){
var r=appoint.getUTCFullYear()+"-",i=appoint.getUTCMonth()+1;
var i=appoint.getUTCMonth()+1;
if(i<10){
i="0"+i;}
Line 405 ⟶ 425:
};
BAK.family=function(){
var env;
if(!this.pageID){
this.pageIDenv=mw.config.get(["wgArticleId","wgPageName"]);
this.pageID=env.wgArticleId;
this.pageName=mw.config.get("wgPageName");
this.pageName=env.wgPageName;
if(this.pageID===0){
this.pageID="0_"+this.pageName.replace(/~/,"%7E");}}
};
BAK.fast=function(){
var q,r=true,s=window.sessionStorage.getItem(this.disk.storage),q;
if(s){
r=(s.length>1);
Line 430 ⟶ 452:
};
BAK.filter=function(){
var lazy=true,store="~",hist,page,pid,revs,rid,sift,stamp;
var lazy=true;
var store="~";
this.cnf.fetch();
if(this.cnf.maxAge){
Line 475 ⟶ 495:
};
BAK.finalize=function(already,add){
var k=add.length,r=add,i;
var k=add.length;
var r=add;
for(i=k;i>0;i--){
if(add.charCodeAt(i-1)>32){
Line 493 ⟶ 511:
};
BAK.find=function(){
var q=new mw.Api();,w={action:"query",
"continue":"",
var w={action:"query",pageids:this.pageID,prop:"revisions",rvlimit:3,rvuser:mw.util.wikiUrlencode(mw.config.get("wgUserName"))
pageids:this.pageID,prop:"revisions",rvlimit:3,rvuser:mw.util.wikiUrlencode(mw.config.get("wgUserName"))
};
if(this.later){
Line 510 ⟶ 529:
this.find();}}
if(typeof mw.user==="object"){
if(mw.user.options&&mw.user.options.get("uselivepreview")){
if(mw.user.options.get("uselivepreview")){
this.livePreview=true;
$(mw).bind("LivePreviewDone",this.fresh);}}}
this.gui.leading=true;
mw.hook("wikipage.content").add(this.fresh();
};
BAK.fixed=function(apply){
Line 568 ⟶ 586:
};
BAK.found=function(arrived){
var query=(typeof arrived==="object"),learnt=false,i;
var learnt=false;
var i;
if(query){
query=arrived.query;
Line 589 ⟶ 605:
};
BAK.founder=function(arrived){
var query=(typeof arrived==="object"),learnt=false;
var learnt=false;
if(query){
query=arrived.query;
Line 605 ⟶ 620:
};
BAK.fresh=function(){
var shot=BAK.gui.feed(),page,revs,stamp;
var revs;
var shot=BAK.gui.feed();
var stamp;
if(shot){
BAK.family();
Line 660 ⟶ 672:
};
BAK.fire=function(){
var env=mw.config.get(["wgAction","wgIsArticle","wgUserName"]);
var s;
BAK.disk.storage=BAK.disk.self+" "+mwenv.config.get("wgUserName");
if(mwenv.config.get("wgIsArticle")){
if(mwenv.config.get("wgAction")==="view"&&BAK.fast()){
if(BAK.fastfollow()){;}
BAK.follow();}}
}else{
sBAK.start=mw.util.getParamValue("action");
if(sBAK.start){
BAK.learn=true;
if(s==="|edit|submit|".indexOf(BAK.start)>0){
mw.hook("wikipage.content").add(BAK.firing);}}}
};
BAK.firing=function($all){
BAK.$page=$all;
switch(BAK.start){
case "submit":
BAK.gui.leading=true;
BAK.fresh();
BAK.further();
break;
}else if(s==="edit"){
case "edit":
BAK.first();
BAK.further();}}}
};
function first(){
if(!BAK.loaded){
var signature="ext.gadget."+BAK.type,rls;
BAK.loaded=true;
if(mw.loader.getState(signature)!=="ready"){
rls={};
rls[signature]="ready";
mw.loader.state(rls);
if(mw.config.get("wgNamespaceNumber")>=0){
mw.loader.using(["user","mediawiki.api","mediawiki.user","mediawiki.util"],BAK.fire);}}}
$(window.document).ready(function(){
first();
mw.loader.using(["user","mediawiki.api","mediawiki.user","mediawiki.util","jquery.json"],BAK.fire);
});}
mw.loader.state("ext.gadget.autoBackup","ready");}
}(window.mediaWiki,window.jQuery));
/// EOF</nowiki>autoBackup/r.js