Benutzer:PerfektesChaos/js/deleteShortpages/core.js
Hinweis: Leere nach dem Veröffentlichen den Browser-Cache, um die Änderungen sehen zu können.
- Firefox/Safari: Umschalttaste drücken und gleichzeitig Aktualisieren anklicken oder entweder Strg+F5 oder Strg+R (⌘+R auf dem Mac) drücken
- Google Chrome: Umschalttaste+Strg+R (⌘+Umschalttaste+R auf dem Mac) drücken
- Edge: Strg+F5 drücken oder Strg drücken und gleichzeitig Aktualisieren anklicken
/// Gadget-deleteShortpages/core.js
// Semi-automatic deletion of short pages
/// 2018-08-24 PerfektesChaos@de.wikipedia
// ResourceLoader: compatible;
// dependencies: NONE
/// Fingerprint: #0#0#
// Documentation: [[w:en:User:PerfektesChaos/js/deleteShortpages]]
/// <nowiki>
/* global window:false */
/* jshint forin:false,
bitwise:true, curly:true, eqeqeq:true, latedef:true,
laxbreak:true,
nocomma:true, strict:true, undef:true, unused:true */
( function ( mw, $ ) {
"use strict";
var VERSION = "0.3",
Sign = "deleteShortpages",
API = false,
CODE = { },
DELSP;
if ( typeof mw.libs.deleteShortpages !== "object" ||
! mw.libs.deleteShortpages ) {
mw.libs.deleteShortpages = { };
}
DELSP = mw.libs.deleteShortpages;
DELSP.vsn = VERSION;
//-----------------------------------------------------------------------
if ( mw.config.get( "wgServer" ) ===
"//de.wikipedia.beta.wmflabs.org" ) {
DELSP.id = 1772; // BETA:Benutzer:PerfektesChaos/short pages
DELSP.max = 50;
DELSP.ns = 1;
}
if ( DELSP.ns % 2 !== 1 ) {
DELSP.ns = -999;
}
if ( typeof DELSP.max === "number" && DELSP.max > 150 ) {
DELSP.max = 0;
}
//-----------------------------------------------------------------------
CODE.cnf = { };
CODE.cnf.smiley = "//upload.wikimedia.org/wikipedia/commons"
+ "/8/85/Smiley.svg";
// 2014-11-01 PerfektesChaos@de.wikipedia
CODE.cnf.spooling = "//upload.wikimedia.org/wikipedia/commons"
+ "/d/de/Ajax-loader.gif";
// throbber URL
// 2012-12-15 PerfektesChaos@de.wikipedia
CODE.cnf.texts = {
// 2014-11-01 PerfektesChaos@de.wikipedia
"Abort": {"en": "Abort",
"de": "Abbruch"},
"AjaxWait": {"en": "Contacting server",
"de": "Kommuniziere mit dem GROSSEN GURU"},
"DeleteBot": {"en": "Delete bot edits",
"de": "Lösche Bot-Edits"},
"DeleteVandal": {"en": "Delete inappropriate",
"de": "Hier falsch! Löschen."},
"Deleted": {"en": "Page has been deleted.",
"de": "Seite wurde gelöscht."},
"DeletionFail": {"en": "Deletion failed:",
"de": "Löschversuch fehlgeschlagen:"},
"Error": {"en": "ERROR!",
"de": "FEHLER!"},
"Finish": {"en": "Finish",
"de": "Beenden"},
"Irresistible": {"en": "Really start (loose edits)?",
"de": "Wirklich starten"
+ " (Bearbeitungen gehen verloren)?"},
"Next": {"en": "Next please",
"de": "Weiter"},
"NoMore": {"en": "No more entries.",
"de": "Keine Einträge mehr."},
"HistoryInfo": {"en": "History info",
"de": "Versionsgeschichte"},
"PageInfo": {"en": "Page info",
"de": "Seiteninfo"},
"Start": {"en": "Start",
"de": "Start"},
"SummaryB": {"en": "Bot created maintenance list only",
"de": "Nur Bot-generierte Wartungsliste"},
"SummaryV": {"en": "Inappropriate edits only",
"de": "Keine regelgerechte Nutzung"},
"Whitespace": {"en": "Whitespace only.",
"de": "Keine sichtbaren Zeichen."}
}; // CODE.cnf.texts
CODE.cnf.feature = function ( apply ) {
// Wrap message text access
// Precondition:
// apply -- text keyword
// Postcondition:
// Return text in project language
// Uses:
// this
// > CODE.cnf.texts
// >< CODE.cnf.slang
// mw.config.get()
// CODE.cnf.format()
// 2014-11-01 PerfektesChaos@de.wikipedia
var e = this.texts[ apply ],
r;
if ( e ) {
if ( typeof this.slang !== "string" ) {
this.slang = mw.config.get( "wgContentLanguage" );
}
r = e[ this.slang ];
if ( ! r ) {
r = e.en;
if ( ! r ) {
r = "???" + apply + "???";
}
}
r = CODE.cnf.format( r );
} else {
r = "***" + apply + "***";
}
return r;
}; // CODE.cnf.feature()
CODE.cnf.format = function ( apply ) {
// Replace numeric entities by character codes
// Precondition:
// apply -- text
// Postcondition:
// Return text without entities
// 2014-11-01 PerfektesChaos@de.wikipedia
return apply.replace( /&#([0-9]+);/g,
function ( $0, $1 ) {
return String.fromCharCode(
parseInt( $1, 10 ) );
} )
.replace( /&#x([0-9a-f]+);/gi,
function ( $0, $1 ) {
return String.fromCharCode(
parseInt( $1, 16 ) );
} );
}; // CODE.cnf.format()
//-----------------------------------------------------------------------
CODE.box = { listen: true,
longing: true,
n: 0 };
CODE.box.finish = function () {
// All requests done
// Uses:
// this
// > CODE.page.$msg
// > CODE.page.$box
// > CODE.box.n
// > CODE.cnf.smiley
// CODE.cnf.feature()
// 2014-11-01 PerfektesChaos@de.wikipedia
var $img;
CODE.page.$msg.empty();
CODE.page.$msg.css( { "border": "solid 2px #808080",
"color": "#000000",
"margin": "3px",
"padding": "1em" } );
CODE.page.$msg.text( CODE.cnf.feature( "NoMore" ) );
CODE.page.$msg.show();
if ( this.n ) {
CODE.page.$box.empty();
CODE.page.$box.css( { "background-color": "#7CFC00" } );
$img = $( "<img />" );
$img.attr( { "src": CODE.cnf.smiley,
"height": 100 } );
$img.css( { "margin-left": "20em",
"margin-bottom": "5em",
"margin-top": "5em" } );
CODE.page.$box.append( $img );
} else {
CODE.page.$box.remove();
}
}; // CODE.box.finish()
CODE.box.find = function () {
// Get next element, and display
// Uses:
// this
// > CODE.titles.pageids
// > CODE.titles.bag
// > CODE.titles.mult
// > CODE.titles.last
// >< CODE.titles.next
// < CODE.box.longing
// CODE.box.found()
// CODE.titles.fiat()
// CODE.box.finish()
// 2014-11-01 PerfektesChaos@de.wikipedia
var collection = CODE.titles.pageids,
next = 0,
el, i, id;
for ( i = CODE.titles.next; i < collection.length; i++ ) {
if ( collection[ i ] ) {
break; // for i
} else {
CODE.titles.next = i + 1;
}
} // for i
for ( i = CODE.titles.next; i < collection.length; i++ ) {
id = collection[ i ];
if ( id && id > 0 ) {
el = CODE.titles.bag[ id ];
if ( el && el.$info ) {
this.found( id, i );
next = i;
break; // for i
}
}
} // for i
if ( next ) {
if ( next > collection.length - CODE.titles.mult ) {
CODE.titles.fiat( CODE.titles.mult );
}
} else if ( CODE.titles.next === collection.length ) {
this.longing = true;
if ( CODE.titles.last ) {
this.finish();
} else {
CODE.titles.fiat( false );
}
} else {
CODE.titles.fiat( false );
}
}; // CODE.box.find()
CODE.box.fire = function () {
// An element became available
// Uses:
// this
// > CODE.box.longing
// CODE.box.find()
// 2014-11-01 PerfektesChaos@de.wikipedia
if ( this.longing ) {
this.find();
}
}; // CODE.box.fire()
CODE.box.found = function ( apply, at ) {
// An element shall be displayed
// Precondition:
// apply -- pageid
// at -- position in CODE.titles.pageids
// Uses:
// this
// > CODE.box.$msg
// > CODE.box.$info
// > CODE.titles.bag
// > CODE.box.$n
// > CODE.box.$buttonB
// > CODE.box.$buttonV
// > CODE.page.$msg
// >< CODE.titles.bag
// >< CODE.box.listen
// >< CODE.titles.pageids
// >< CODE.box.n
// < CODE.box.longing
// < CODE.box.id
// < CODE.box.subject
// CODE.box.furnish()
// 2014-11-01 PerfektesChaos@de.wikipedia
var el = CODE.titles.bag[ apply ];
this.longing = false;
if ( this.listen ) {
this.listen = false;
this.furnish();
}
this.$msg.hide();
this.$msg.empty();
this.$info.children().remove();
this.$info.append( el.$info );
this.n++;
this.$n.text( this.n );
CODE.titles.pageids[ at ] = false;
delete el.$info;
delete el.story;
CODE.titles.bag[ apply ] = true;
this.$buttonB.attr( "disabled", null );
this.$buttonV.attr( "disabled", null );
CODE.page.$msg.hide();
CODE.page.$msg.empty();
this.id = apply;
this.subject = el.subject;
}; // CODE.box.found()
CODE.box.furnish = function () {
// Initialize box
// Uses:
// this
// > CODE.page.$box
// < CODE.box.$info
// < CODE.box.$msg
// < CODE.box.$buttonB
// < CODE.box.$buttonV
// < CODE.box.$n
// CODE.box.$face()
// CODE.page.$face()
// CODE.cnf.feature()
// (CODE.deletion.fiatB)
// (CODE.deletion.fiatV)
// (CODE.box.further)
// 2014-11-01 PerfektesChaos@de.wikipedia
var $button, $buttons, $div;
CODE.page.$box.css( { "border": "solid 2px #808080",
"margin-bottom": "1em",
"margin-top": "1em",
"padding": "1em" } );
this.$info = $( "<div>" );
CODE.page.$box.append( this.$info );
this.$msg = $( "<div>" );
CODE.page.$box.append( this.$msg );
$buttons = $( "<div>" );
$buttons.css( { "margin-top": "2em" } );
this.$buttonB = this.$face( "DeleteBot", CODE.deletion.fiatB );
this.$buttonB.css( { "background-color": "#ADD8E6",
"margin-right": "3em" } );
$buttons.append( this.$buttonB );
this.$buttonV = this.$face( "DeleteVandal", CODE.deletion.fiatV );
this.$buttonV.css( { "background-color": "#F0E68C",
"margin-right": "2em" } );
$buttons.append( this.$buttonV );
$div = $( "<div>" );
$div.css( { "float": "right",
"white-space": "nowrap" } );
this.$n = $( "<small>" );
$div.append( this.$n );
$button = CODE.page.$face( "Next", this.further );
$button.css( { "margin-left": "2em",
"padding": "5px" } );
$div.append( $button );
$buttons.append( $div );
CODE.page.$box.append( $buttons );
}; // CODE.box.furnish()
CODE.box.further = function () {
// Request next element
// Uses:
// < CODE.box.longing
// CODE.box.find()
// Remark: May be used as event handler -- 'this' is not accessed
// 2014-11-01 PerfektesChaos@de.wikipedia
CODE.box.longing = true;
CODE.box.find();
}; // CODE.box.further()
CODE.box.$face = function ( about, assign ) {
// Create deletion button
// Precondition:
// about -- keyword of label
// assign -- function
// Postcondition:
// Return $button
// Uses:
// CODE.page.$face()
// 2014-11-01 PerfektesChaos@de.wikipedia
var $r = CODE.page.$face( about, assign );
$r.css( { "border-left-color": "#FF2020",
"border-top-color": "#FF2020",
"border-right-color": "#FF0000",
"border-bottom-color": "#FF0000",
"border-width": "4px",
"padding": "5px" } );
return $r;
}; // CODE.box.$face()
//-----------------------------------------------------------------------
CODE.deletion = { summaryB: CODE.cnf.feature( "SummaryB" ),
summaryV: CODE.cnf.feature( "SummaryV" ) };
CODE.deletion.fault = function ( about, arrived ) {
// Deletion failed
// Precondition:
// about -- string with keyword
// arrived -- object with details
// Uses:
// > CODE.box.$msg
// CODE.page.fault()
// mw.log()
// Remark: May be used as event handler -- 'this' is not accessed
// 2014-11-01 PerfektesChaos@de.wikipedia
var $span;
CODE.page.fault( "DeletionFail", CODE.box.$msg );
if ( typeof arrived === "object" &&
typeof arrived.error === "object" &&
typeof arrived.error.info === "string" ) {
$span = $( "<span>" );
$span.css( { "font-style": "italic" } );
$span.text( arrived.error.info );
CODE.box.$msg.append( $span );
}
CODE.box.$msg.show();
mw.log( {loud:true}, ".deletion.fault()", 2, arrived );
}; // CODE.deletion.fault()
CODE.deletion.fiat = function ( about ) {
// Delete page
// Precondition:
// about -- key for reason
// Postcondition:
// API request launched
// Uses:
// this
// > CODE.deletion.summaryB
// > CODE.deletion.summaryV
// > CODE.box.$buttonB
// > CODE.box.$buttonV
// > CODE.box.$msg
// > CODE.box.id
// > API
// mw.user.tokens.get()
// mw.API().post()
// CODE.page.fired()
// (CODE.deletion.fine)
// (CODE.deletion.fault)
// 2016-04-30 PerfektesChaos@de.wikipedia
var pars = { action: "delete",
pageid: CODE.box.id,
reason: this[ "summary" + about ],
token: mw.user.tokens.get( "csrfToken" )
};
CODE.box.$buttonB.attr( "disabled", true );
CODE.box.$buttonV.attr( "disabled", true );
CODE.page.fired( CODE.box.$msg );
API.post( pars ).done( this.fine )
.fail( this.fault );
}; // CODE.deletion.fiatB()
CODE.deletion.fiatB = function () {
// Delete bot triggered edits
// Uses:
// CODE.deletion.fiat()
// Remark: May be used as event handler -- 'this' is not accessed
// 2014-11-01 PerfektesChaos@de.wikipedia
CODE.deletion.fiat( "B" );
}; // CODE.deletion.fiatB()
CODE.deletion.fiatV = function () {
// Delete inappropriate edits
// Uses:
// CODE.deletion.fiat()
// Remark: May be used as event handler -- 'this' is not accessed
// 2014-11-01 PerfektesChaos@de.wikipedia
CODE.deletion.fiat( "V" );
}; // CODE.deletion.fiatV()
CODE.deletion.fine = function ( arrived ) {
// Deletion succeeded
// Precondition:
// arrived -- JSON result of ajax query
// Uses:
// > CODE.box.subject
// > CODE.box.$msg
// CODE.cnf.feature()
// Remark: May be used as event handler -- 'this' is not accessed
// 2014-11-01 PerfektesChaos@de.wikipedia
var q;
if ( typeof arrived[ "delete" ] === "object" ) {
q = arrived[ "delete" ];
if ( typeof q.title === "string"
&& q.title === CODE.box.subject ) {
CODE.box.$msg.empty();
CODE.box.$msg.css( { "border": "solid 1px #00A000",
"color": "#00A000",
"margin": "3px",
"padding": "1em" } );
CODE.box.$msg.text( CODE.cnf.feature( "Deleted" ) );
}
}
}; // CODE.deletion.fault()
//-----------------------------------------------------------------------
CODE.history = { many: 20 };
CODE.history.factory = function ( adjust, apply ) {
// Create revision table
// Precondition:
// adjust -- pageid
// apply -- page information
// .ns -- namespace number
// .title -- page name
// .revisions -- Array with revision list
// Uses:
// this
// > .last
// >< CODE.titles.bag
// mw.config.get()
// mw.util.getUrl()
// CODE.history.finalize()
// 2014-11-01 PerfektesChaos@de.wikipedia
var el = CODE.titles.bag[ adjust ],
$table = $( "<table>" ),
$diffA = false,
i, memo, rv, s, $a, $caption, $code, $diffTD, $span, $td, $tr;
$table.attr( { "class": "wikitable" } );
$table.css( { "width": "100%" } );
$caption = $( "<caption>" );
$caption.css( { "text-align": "left" } );
el.subject = apply.title;
$span = $( "<span>" );
$span.css( { "font-size": "120%",
"margin-right": "2em" } );
$span.text( el.subject );
$caption.append( $span );
$code = $( "<code>" );
$code.text( adjust );
$caption.append( $code );
$table.append( $caption );
for ( i = 0; i < apply.revisions.length; i++ ) {
$tr = $( "<tr>" );
rv = apply.revisions[ i ];
$td = $( "<td>" );
$a = $( "<a>" );
s = "Special:Redirect/revision/" + rv.revid;
$a.attr( { "href": mw.util.getUrl( s ),
"target": "delShortPg" } );
$a.text( rv.timestamp );
$td.append( $a );
$tr.append( $td );
$td = $( "<td>" );
if ( typeof rv.anon === "string" ) {
$td.text( rv.user );
} else {
$a = $( "<a>" );
$a.attr( { "href": mw.util.getUrl( "User:" + rv.user ),
"target": "delShortPg" } );
$a.text( rv.user );
$td.append( $a );
}
$tr.append( $td );
$td = $( "<td>" );
$td.css( { "text-align": "right" } );
$code = $( "<code>" );
$code.text( rv.size );
$td.append( $code );
$tr.append( $td );
if ( $diffA ) {
memo = memo - rv.size;
if ( memo < 0 ) {
memo = - memo;
$diffA.text( String.fromCharCode( 8722 ) + memo );
$diffTD.css( { "border-color": "#FF0000",
"border-width": "2px" } );
} else if ( memo > 0 ) {
$diffA.text( "+" + memo );
$diffTD.css( { "border-color": "#008000",
"border-width": "2px" } );
} else {
$diffA.text( "0" );
}
$diffTD.css( { "text-align": "right" } );
$diffTD.append( $diffA );
}
memo = rv.size;
$diffTD = $( "<td>" );
$diffA = $( "<a>" );
s = "Special:Diff/" + rv.revid;
$diffA.attr( { "href": mw.util.getUrl( s ),
"target": "delShortPg" } );
$tr.append( $diffTD );
$td = $( "<td>" );
$td.text( rv.comment );
$tr.append( $td );
if ( DELSP.last ) {
$table.prepend( $tr );
} else {
$table.append( $tr );
}
} // for i
el.$table = $table;
if ( el.story ) {
CODE.history.finalize( el );
}
}; // CODE.history.factory()
CODE.history.fault = function ( about, arrived ) {
// Query failed
// Precondition:
// about -- string with keyword
// arrived -- JSON result of ajax query
// Uses:
// CODE.page.fault()
// mw.log()
// Remark: May be used as event handler -- 'this' is not accessed
// 2014-11-01 PerfektesChaos@de.wikipedia
CODE.page.fault( "HistoryInfo" );
mw.log( {loud:true}, ".history.fault()", 2, arrived );
}; // CODE.history.fault()
CODE.history.feed = function ( arrived ) {
// Process revision list
// Precondition:
// arrived -- JSON result of ajax query
// Uses:
// CODE.history.factory()
// Remark: May be used as event handler -- 'this' is not accessed
// 2014-11-01 PerfektesChaos@de.wikipedia
var i, id, pageids, pages, q;
if ( typeof arrived.query === "object" ) {
q = arrived.query;
if ( typeof q.pageids === "object" ) {
pageids = q.pageids;
if ( pageids.length && typeof q.pages === "object" ) {
pages = q.pages;
for ( i = 0; i < pageids.length; i++ ) {
id = pageids[ i ];
if ( id > 0 ) {
q = pages[ id ];
if ( typeof q === "object" &&
typeof q.revisions === "object" ) {
CODE.history.factory( id, q );
}
}
} // for i
}
}
}
}; // CODE.history.feed()
CODE.history.fetch = function ( arrived ) {
// Process last revision content
// Precondition:
// arrived -- JSON result of ajax query
// Uses:
// CODE.history.fold()
// Remark: May be used as event handler -- 'this' is not accessed
// 2014-11-01 PerfektesChaos@de.wikipedia
var i, id, pageids, pages, q;
if ( typeof arrived.query === "object" ) {
q = arrived.query;
if ( typeof q.pageids === "object" ) {
pageids = q.pageids;
if ( pageids.length && typeof q.pages === "object" ) {
pages = q.pages;
for ( i = 0; i < pageids.length; i++ ) {
id = pageids[ i ];
if ( id > 0 ) {
q = pages[ id ];
if ( typeof q === "object" &&
typeof q.revisions === "object" ) {
q = q.revisions;
if ( typeof q[ 0 ] === "object" &&
typeof q[ 0 ][ "*" ] === "string" ) {
CODE.history.fold( id, q[ 0 ][ "*" ] );
}
}
}
} // for i
}
}
}
}; // CODE.history.fetch()
CODE.history.fiat = function ( access ) {
// Request details based upon pageids
// access -- array of requested pageids
// Precondition:
// Uses:
// this
// > CODE.history.many
// > API
// (CODE.history.feed)
// (CODE.history.fault)
// (CODE.history.fetch)
// 2014-11-01 PerfektesChaos@de.wikipedia
var i, id, p;
for ( i = 0; i < access.length; i++ ) {
id = access[ i ];
p = { action: "query",
"continue": "",
indexpageids: true,
prop: "revisions",
pageids: id,
rvlimit: this.many,
rvprop: "ids|flags|timestamp|user|comment|size" };
API.get( p ).done( this.feed )
.fail( this.fault );
if ( ! CODE.titles.bag[ id ].story ) {
p = { action: "query",
"continue": "",
indexpageids: true,
prop: "revisions",
pageids: id,
rvlimit: 1,
rvprop: "content" };
API.get( p ).done( this.fetch )
.fail( this.fault );
}
} // for i
}; // CODE.history.fiat()
CODE.history.finalize = function ( account ) {
// Combine
// Precondition:
// account -- page object
// Uses:
// > CODE.page.$msg
// CODE.cnf.feature()
// CODE.box.fire()
// 2014-11-01 PerfektesChaos@de.wikipedia
var $div;
CODE.page.$msg.hide();
CODE.page.$msg.empty();
if ( account.story && typeof account.$table === "object" ) {
account.$info = $( "<div>" );
account.$info.append( account.$table );
delete account.$table;
if ( typeof account.story === "string" ) {
$div = $( "<pre>" );
$div.css( { "background-color": "#FFD700",
"border": "#4B0082 2px solid",
"margin-top": "1em",
"padding": "1em" } );
$div.text( account.story );
account.$info.append( $div );
delete account.story;
} else if ( account.length ) {
$div = $( "<div>" );
$div.css( { "font-style": "italic",
"margin-bottom": "2em",
"margin-top": "2em" } );
$div.text( CODE.cnf.feature( "Whitespace" ) );
account.$info.append( $div );
}
CODE.box.fire();
}
}; // CODE.history.finalize()
CODE.history.fold = function ( adjust, apply ) {
// Store last revision content
// Precondition:
// adjust -- pageid
// apply -- string
// Uses:
// >< CODE.titles.bag
// CODE.history.finalize()
// 2014-11-01 PerfektesChaos@de.wikipedia
var el = CODE.titles.bag[ adjust ],
s = apply.replace( /^\s+/, "" )
.replace( /\s+$/, "" ),
c, i, re;
for ( i = s.length; i; ) {
i--;
c = s.charCodeAt( i );
switch ( c ) {
case 9 : // hor tab
case 13 : // CR
case 8194 : // enSpace \u2002
case 8195 : // emSpace \u2003
case 8198 : // SIX-PER-EM SPACE
case 8200 : // PUNCTUATION SPACE \u2008
case 8201 : // thinsp
case 8239 : // NARROW NO-BREAK SPACE
re = new RegExp( String.fromCharCode( c ), "g" );
s = s.replace( re, " " );
break;
case 11 : // vertical tab
case 12 : // form feed
case 160 : // nbsp
case 8203 : // ZERO WIDTH SPACE used in .lang.chr.zwsp
case 8204 : // ZERO WIDTH NON-JOINER in .lang.chr.zwnj
case 8205 : // ZERO WIDTH JOINER in .lang.chr.zwj
case 8202 : // hair space (english typography)
case 8206 : // LEFT-TO-RIGHT MARK \u200E
case 8207 : // RIGHT-TO-LEFT MARK \u200F
case 8232 : // LINE SEPARATOR
case 8233 : // PARAGRAPH SEPARATOR
case 8234 : // LEFT-TO-RIGHT EMBEDDING
case 8235 : // RIGHT-TO-LEFT EMBEDDING
case 8236 : // POP DIRECTIONAL FORMATTING
case 8237 : // LEFT-TO-RIGHT OVERRIDE
case 8238 : // RIGHT-TO-LEFT OVERRIDE
case 8288 : // WORD JOINER
re = new RegExp( String.fromCharCode( c ), "g" );
s = s.replace( re, "" );
break;
} // switch c
} // for i --
s = s.replace( /^\s+/, "" )
.replace( /\s+$/, "" );
if ( s === "" ) {
s = true;
}
el.story = s;
if ( typeof el.$table === "object" ) {
CODE.history.finalize( el );
}
}; // CODE.history.fold()
//-----------------------------------------------------------------------
CODE.page = { story: false };
CODE.page.fallback = function () {
// Bail out
// Postcondition:
// buttons available
// Uses:
// > CODE.page.$div
// >< CODE.page.$button
// < CODE.page.$buttonX
// CODE.page.$face()
// (CODE.page.furnish)
// (CODE.page.flop)
// Remark: May be used as event handler -- 'this' is not accessed
// 2014-11-01 PerfektesChaos@de.wikipedia
CODE.page.$button.remove();
CODE.page.$button = CODE.page.$face( "Irresistible",
CODE.page.furnish );
CODE.page.$button.css( { "margin-bottom": "2em",
"margin-right": "4em",
"margin-top": "1em" } );
CODE.page.$div.append( CODE.page.$button );
CODE.page.$buttonX = CODE.page.$face( "Abort", CODE.page.flop );
CODE.page.$div.append( CODE.page.$buttonX );
}; // CODE.page.fallback()
CODE.page.fault = function ( apply, $assign ) {
// Equip page with error message box
// Precondition:
// apply -- HTML error message text, jQuery, or false
// $assign -- jQuery container to be reset
// CODE.page.$msg
// Uses:
// this
// > CODE.page.$msg
// jQuery().empty()
// jQuery().css()
// CODE.cnf.feature()
// jQuery().append()
// 2014-11-01 PerfektesChaos@de.wikipedia
var $container = $assign,
$msg, $span;
if ( ! $container ) {
$container = this.$msg;
}
$container.empty();
$container.css( { "border": "solid 2px #FF0000",
"color": "#FF0000",
"margin": "3px",
"padding": "1em" } );
switch ( typeof apply ) {
case "function":
case "object":
$msg = apply;
break;
case "string":
$msg = $( "<span>" );
$span = $( "<strong>" );
$span.text( CODE.cnf.feature( "Error" ) );
$msg.append( $span );
$msg.text( CODE.cnf.feature( apply ) );
$span = $( "<span>" );
$span.css( { "margin-left": "3em" } );
$msg.append( $span );
break;
default:
$msg = $( "<strong>" );
$msg.text( CODE.cnf.feature( "Error" ) );
} // switch typeof apply
$container.append( $msg );
$container.show();
}; // CODE.page.fault()
CODE.page.finish = function () {
// Terminate procedures, rebuild page
// Uses:
// > window
// > CODE.page.$msg
// > CODE.page.$box
// > CODE.page.$button
// mw.config.get()
// mw.util.getUrl()
// Remark: May be used as event handler -- 'this' is not accessed
// 2014-11-01 PerfektesChaos@de.wikipedia
CODE.page.$msg.remove();
CODE.page.$box.remove();
CODE.page.$button.remove();
window.document.location =
window.document.location.protocol
+ mw.util.getUrl( mw.config.get( "wgPageName" ),
{ action: "purge" } );
}; // CODE.page.finish()
CODE.page.fired = function ( $assign, alter ) {
// Equip page with waiting loop and throbber
// $assign -- jQuery container to be reset
// CODE.page.$msg
// alter -- number of pixels other than standard, or false
// Uses:
// this
// > CODE.page.$msg
// jQuery().empty()
// jQuery().css()
// CODE.cnf.feature()
// jQuery().append()
// 2014-11-01 PerfektesChaos@de.wikipedia
var $container = $assign,
$span = $( "<span>" );
if ( ! $container ) {
$container = this.$msg;
}
$container.empty();
$container.css( { "border": "solid 1px #0000FF",
"color": "#0000FF",
"margin": "3px",
"padding": "1em" } );
$container.append( this.$flow( alter ) );
$span.css( { "margin-left": "3em" } );
$span.text( CODE.cnf.feature( "AjaxWait" ) );
$container.append( $span );
$container.show();
}; // CODE.page.fired()
CODE.page.first = function () {
// Insert button and headline in page top
// Precondition:
// document ready
// Postcondition:
// button available
// Uses:
// > .vsn
// < CODE.page.$button
// < CODE.page.$div
// < CODE.page.$content
// CODE.page.$face()
// (CODE.page.fallback)
// Remark: May be used as event handler -- 'this' is not accessed
// 2014-11-01 PerfektesChaos@de.wikipedia
var $h3;
CODE.page.$div = $( "#deleteShortpages" );
if ( ! CODE.page.$div.length ) {
CODE.page.$div = $( "<div>" );
CODE.page.$div.attr( { id: "deleteShortpages" } );
$h3 = $( "<h3>" );
$h3.text( "deleteShortpages (" + DELSP.vsn + ")" );
CODE.page.$div.append( $h3 );
CODE.page.$button = CODE.page.$face( "Start",
CODE.page.fallback );
CODE.page.$button.css( { "margin-bottom": "2em",
"margin-top": "1em" } );
CODE.page.$div.append( CODE.page.$button );
CODE.page.$content = $( "#mw-content-text" );
CODE.page.$content.before( CODE.page.$div );
}
}; // CODE.page.first()
CODE.page.flop = function () {
// Aborted
// Postcondition:
// cleared
// Uses:
// > CODE.page.$div
// Remark: May be used as event handler -- 'this' is not accessed
// 2014-11-01 PerfektesChaos@de.wikipedia
CODE.page.$div.remove();
}; // CODE.page.flop()
CODE.page.furnish = function () {
// Clear page and establish work mode
// Postcondition:
// edit form text saved
// standard page cleared
// equipped with containers
// Uses:
// > CODE.page.$buttonX
// > CODE.page.$content
// > .many
// > .max
// > .summaryB
// > .summaryV
// >< CODE.page.$button
// < CODE.page.$msg
// < CODE.page.story
// < CODE.page.$box
// < CODE.history.many
// < CODE.history.max
// < CODE.deletion.summaryB
// < CODE.deletion.summaryV
// CODE.page.$face()
// CODE.page.fired()
// CODE.titles.fiat()
// Remark: May be used as event handler -- 'this' is not accessed
// 2014-11-01 PerfektesChaos@de.wikipedia
var $textarea;
CODE.page.$button.remove();
CODE.page.$buttonX.remove();
CODE.page.$button = CODE.page.$face( "Finish", CODE.page.finish );
CODE.page.$button.css( { "margin-bottom": "2em",
"margin-top": "1em" } );
CODE.page.$div.append( CODE.page.$button );
CODE.page.$msg = $( "<div>" );
CODE.page.$button.before( CODE.page.$msg );
$textarea = CODE.page.$content.find( "#wpTextbox1" );
if ( $textarea.length ) {
CODE.page.story = $textarea.val();
CODE.page.$content.remove();
CODE.page.$box = $( "<div>" );
CODE.page.$button.before( CODE.page.$box );
if ( typeof DELSP.many === "number"
&& DELSP.many >= 5
&& DELSP.many <= 50 ) {
CODE.history.many = Math.ceil( DELSP.many );
}
if ( typeof DELSP.max === "number" ) {
if ( DELSP.max < 0 ) {
CODE.history.max = 0;
} else {
CODE.history.max = Math.ceil( DELSP.max );
}
} else {
CODE.history.max = 0;
}
if ( typeof DELSP.summaryB === "string" ) {
CODE.deletion.summaryB = DELSP.summaryB;
}
if ( typeof DELSP.summaryV === "string" ) {
CODE.deletion.summaryV = DELSP.summaryV;
}
CODE.page.fired();
CODE.titles.fiat( 0 );
}
}; // CODE.page.furnish()
CODE.page.$face = function ( about, assign ) {
// Create button
// Precondition:
// about -- keyword of label
// assign -- function
// Postcondition:
// Return $button
// Uses:
// CODE.cnf.feature()
// jQuery()
// jQuery().attr()
// jQuery().click()
// jQuery().text()
// 2014-11-01 PerfektesChaos@de.wikipedia
var $r = $( "<button />" );
$r.attr( { "type": "button" } );
$r.click( assign );
$r.text( CODE.cnf.feature( about ) );
return $r;
}; // CODE.page.$face()
CODE.page.$flow = function ( alter ) {
// Create throbber
// Precondition:
// alter -- number of pixels other than standard, or false
// Postcondition:
// Return jQuery with throbber IMG
// Uses:
// > CODE.cnf.spooling
// jQuery()
// jQuery().attr()
// 2014-11-01 PerfektesChaos@de.wikipedia
var $r = $( "<img />" );
$r.attr( { "src": CODE.cnf.spooling,
"height": ( alter ? alter : "24" )
} );
return $r;
}; // CODE.page.$flow()
//-----------------------------------------------------------------------
CODE.titles = { bag: { },
index: 0,
last: false,
max: 100,
mult: 8,
next: 0,
pageids: [ ] };
CODE.titles.fault = function ( about, arrived ) {
// Query failed
// Precondition:
// about -- string with keyword
// arrived -- JSON result of ajax query
// Uses:
// CODE.page.fault()
// mw.log()
// Remark: May be used as event handler -- 'this' is not accessed
// 2014-11-01 PerfektesChaos@de.wikipedia
CODE.page.fault( "PageInfo" );
mw.log( {loud:true}, ".history.fault()", 2, arrived );
}; // CODE.titles.fault()
CODE.titles.feed = function ( arrived ) {
// Basic page information
// Precondition:
// arrived -- JSON result of ajax query
// Uses:
// > CODE.history.max
// >< CODE.titles.bag
// >< CODE.titles.pageids
// CODE.history.fiat()
// Remark: May be used as event handler -- 'this' is not accessed
// 2014-11-01 PerfektesChaos@de.wikipedia
var got = [ ],
i, id, pageids, pages, q;
if ( typeof arrived.query === "object" ) {
q = arrived.query;
if ( typeof q.pageids === "object" ) {
pageids = q.pageids;
if ( pageids.length && typeof q.pages === "object" ) {
pages = q.pages;
for ( i = 0; i < pageids.length; i++ ) {
id = pageids[ i ];
if ( id > 0 &&
typeof CODE.titles.bag[ id ] === "undefined" ) {
q = pages[ id ];
if ( typeof q === "object" &&
typeof q.redirect === "undefined" ) {
if ( q.length <= CODE.history.max ) {
CODE.titles.bag[ id ] =
{ length: q.length,
ns: q.ns,
story: ( ! q.length ),
title: q.title,
$info: false };
CODE.titles.pageids.push( id );
got.push( id );
}
}
}
} // for i
}
}
}
if ( got.length ) {
CODE.history.fiat( got );
}
}; // CODE.titles.feed()
CODE.titles.fiat = function ( amount ) {
// Require action based upon titles
// amount -- number of requested titles, or false
// Precondition:
// Uses:
// this
// > CODE.page
// > .ns
// > CODE.page.story
// > mw.Title
// > CODE.titles.max
// > mw.Api
// >< CODE.titles.last
// >< CODE.titles.index
// >< CODE.titles.mult
// >< API
// CODE.box.fire()
// (CODE.titles.feed)
// (CODE.titles.fault)
// 2014-11-01 PerfektesChaos@de.wikipedia
var got, k, n, p, s, title;
if ( this.last ) {
CODE.page.$msg.hide();
CODE.page.$msg.empty();
} else {
got = [ ];
if ( amount ) {
n = amount;
} else {
n = this.mult;
this.mult += this.mult;
if ( this.mult > this.max ) {
this.mult = this.max;
}
}
do {
this.index = CODE.page.story.indexOf( "[[", this.index );
if ( this.index < 0 ) {
this.last = true;
} else {
this.index += 2;
k = CODE.page.story.indexOf( "]]", this.index );
if ( k < 0 ) {
this.index = -2;
this.last = true;
} else {
s = CODE.page.story.substring( this.index, k );
title = new mw.Title( s );
if ( typeof DELSP.ns === "number" ) {
if ( title.getNamespaceId() !== DELSP.ns ) {
title = false;
}
}
this.index = k + 2;
if ( title ) {
got.push( title.getPrefixedDb() );
}
}
}
} while ( this.index > 0 && got.length < n );
if ( got.length ) {
if ( ! API ) {
API = new mw.Api();
}
p = { action: "query",
"continue": "",
indexpageids: true,
prop: "info",
titles: got.join( "|" ) };
API.get( p ).done( this.feed )
.fail( this.fault );
} else {
this.last = true;
CODE.box.fire( false );
}
}
}; // CODE.titles.fiat()
//-----------------------------------------------------------------------
function fire() {
// Autorun on load
// Uses:
// > .ids
// > .id
// mw.config.get()
// jQuery.inArray()
// mw.loader.using()
// jQuery().ready()
// (CODE.page.first)
// 2014-11-01 PerfektesChaos@de.wikipedia
var env = mw.config.get( [ "wgAction",
"wgArticleId" ] ),
launch = ( env.wgAction === "edit" );
if ( launch ) {
if ( typeof DELSP.ids === "object" ) {
launch = ( $.inArray( env.wgArticleId, DELSP.ids ) >= 0 );
} else if ( typeof DELSP.id === "number" ) {
launch = ( env.wgArticleId === DELSP.id );
}
if ( launch ) {
mw.loader.using( [ "mediawiki.api",
"mediawiki.Title",
"mediawiki.user",
"mediawiki.util" ],
$( function () {
CODE.page.first();
} ) );
}
}
} // fire()
function first() {
// Autorun on load (once)
// Uses:
// > Sign
// mw.loader.getState()
// mw.loader.state()
// mw.loader.using()
// (fire)
// 2018-08-24 PerfektesChaos@de.wikipedia
var signature = "ext.gadget." + Sign + ".core",
rls;
if ( mw.loader.getState( signature ) !== "ready" ) {
rls = { };
rls[ signature ] = "ready";
mw.loader.state( rls );
mw.loader.using( [ "user" ],
fire );
}
} // first()
first();
}( window.mediaWiki, window.jQuery ) );
/// EOF </nowiki> deleteShortpages/core/d.js