User:PerfektesChaos/js/citoidWikitext/core/d.js: Difference between revisions

Content deleted Content added
-3.32
-3.4
Line 1:
/// User:PerfektesChaos/js/citoidWikitext/core.js
// Execute core functionality for citoid on wikitext source editing
/// 20172018-0607-1114 PerfektesChaos@de.wikipedia
// ResourceLoader: compatible;
// dependencies: --
Line 17:
( function ( mw, $ ) {
"use strict";
var Version = -3.324,
MW_LIB = "citoidWikitext",
Sub = "core",
Line 29:
push: { } },
I18N = { },
PREGO = { maxage: 604812,
signature: "preferencesGadgetOptions",
site: "w:en",
store: "User:PerfektesChaos/js/",
sub: "/r.js" },
REPOS = { maxage: 86400,
site: "w:en",
store: "User:PerfektesChaos/js/" },
PROJ = false,
TASK = { },
Line 201 ⟶ 209:
} else if ( APIC.stateless ) {
APIC.site = window.___location.protocol + "//" +
window.___location. hostname + APIC.stateless;
} else {
APIC.jq.data = APIC.data;
Line 256 ⟶ 264:
// APIC.finish()
// Remark: Used as event handler -- 'this' is not APIC
// 20172018-0607-0414 PerfektesChaos@de.wikipedia
var got;
switch ( typeof arrived ) {
Line 270 ⟶ 278:
if ( arrived && typeof arrived.length === "number" ) {
got = arrived[ 0 ];
if ( got && typeof got.url === "stringobject" ) {
APIC.results.pushif ( typeof got.url === "string" && got.url ); {
APIC.missing--results.push( got );
APIC.missing--;
} else if ( typeof got.Error === "string" ) {
// Never reached
// HTTP-OPTIONS call APIC.fault() only
// Plan:
// * Record on console
// shared with APIC.fault()
// * Enrich flat("unanswered") by details
GUIP.flat( "unanswered" );
// GUIP.flat( "unanswered", $span );
}
}
}
Line 2,058 ⟶ 2,068:
}
}; // I18N.fire()
 
 
 
//-----------------------------------------------------------------------
 
 
 
PREGO.feed = function () {
// Provide PREGO
// Uses:
// > PREGO.signature
// > PREGO.site
// > PREGO.store
// > PREGO.sub
// > PREGO.maxage
// mw.loader.getState()
// mw.loader.state()
// REPOS.fire()
// 2018-07-06 PerfektesChaos@de.wikipedia
var s = "ext.gadget." + PREGO.signature;
if ( ! mw.loader.getState( s ) ) {
mw.loader.state( s, "loading" );
REPOS.fire( PREGO.site,
PREGO.store + PREGO.signature + PREGO.sub,
false,
{ action: "raw",
ctype: "text/javascript",
bcache: 1,
maxage: PREGO.maxage } );
}
}; // PREGO.feed()
 
 
 
//-----------------------------------------------------------------------
 
 
 
REPOS.fire = function ( at, access, append, alter ) {
// Load from external URL
// Precondition:
// at -- Wikimedia Foundation site code, or not
// access -- string with basic page name
// append -- string with subpage, or not
// alter -- parameter object, or MIME string, or not
// Uses:
// >< REPOS.requests
// REPOS.foundation()
// mw.loader.load()
// 2018-03-21 PerfektesChaos@de.wikipedia
var source, syntax;
if ( typeof REPOS.requests !== "object" ) {
REPOS.requests = { };
}
if ( typeof REPOS.requests[ access ] !== "boolean" ) {
REPOS.requests[ access ] = true;
if ( append ) {
source = access + append;
} else {
source = access;
}
if ( at ) {
source = REPOS.foundation( at, source, alter );
if ( typeof alter === "object"
&& alter &&
typeof alter.ctype === "string" ) {
syntax = alter.ctype;
}
} else {
syntax = alter;
}
mw.loader.load( source, syntax );
}
}; // REPOS.fire()
 
 
 
REPOS.foundation = function ( at, access, alter ) {
// Create URL within Wikimedia Foundation
// Precondition:
// at -- site code, or not
// access -- string with page name
// alter -- parameter object, or not
// Postcondition:
// Returns full URL
// 2018-03-21 PerfektesChaos@de.wikipedia
var s = access,
r = encodeURI( s );
if ( typeof alter === "object"
&& alter ) {
r = "/w/index.php?title=" + r;
if ( access.substr( -3 ) === ".js" ) {
alter.ctype = "text/javascript";
} else if ( access.substr( -4 ) === ".css" ) {
alter.ctype = "text/css";
}
alter.action = "raw";
for ( s in alter ) {
r = r + "&" + s + "=" + encodeURI( alter[ s ] );
} // for s in alter
} else {
r = "/wiki/" + r;
}
if ( typeof at === "string"
&& at ) {
switch ( at ) {
case "meta":
r = "meta.wikimedia.org" + r;
break;
case "mw":
r = "www.mediawiki.org" + r;
break;
case "w:en":
r = "en.wikipedia.org" + r;
break;
default:
r = window.___location.host + r;
} // switch at
r = "https://" + r;
}
return r;
}; // REPOS.foundation()
 
 
Line 2,347 ⟶ 2,479:
 
 
UTIL.feed = function ( assigned, access, age, address ) {
// Load and run script
// Precondition:
// assigned -- signature
// access -- script
// age -- maxage
// address -- URL to be used, else created from access
// Uses:
// > Version
// >< .suite
// mw.loader.getState()
// mw.loader.state()
// mw.loader.load()
// 2016-02-21 PerfektesChaos@de REPOS.wikipediafire()
// 2018-07-14 PerfektesChaos@de.wikipedia
var source;
var p;
if ( ! mw.loader.getState( assigned ) ) {
mw.loader.state( assigned, "loading" );
if ( address ) {
source =mw.loader.load( address );
} else {
sourcep = "https{ bcache://en.wikipedia.org" 1 };
if ( typeof CITWT.suite !== + "/w/index.php?title=string" ) {
CITWT.suite = ( Version > 1 ? + "Userr" :PerfektesChaos/js/ "d" );
+ access}
p.maxage = ( CITWT.suite === "r" ? + "REPOS.js"maxage : 100 );
REPOS.fire( + "&bcache=1&maxage=" + ageREPOS.site,
REPOS.store + assigned + "&action=raw.js",
+ "&ctype=text/javascript"; false,
p );
}
mw.loader.load( source, "text/javascript" );
}
}; // UTIL.feed()
Line 2,380 ⟶ 2,514:
 
 
UTIL.fetch = function ( access, age ) {
// Run subscripts
// Precondition:
// access -- subscript
// age -- maxage
// Uses:
// > .signature
// > .type
// > Version
// >< .suite
// UTIL.feed()
// 20152018-0607-1014 PerfektesChaos@de.wikipedia
var sub = "/" + access;
if ( typeof CITWT.suite !== "string" ) {
Line 2,396 ⟶ 2,530:
}
UTIL.feed( CITWT.signature + sub,
CITWT.type + sub + "/" + CITWT.suite, );
( age ? age : 3600 ) );
}; // UTIL.fetch()
 
Line 2,414 ⟶ 2,547:
// UTIL.fetch()
// console.log()
// 20152018-0507-1714 PerfektesChaos@de.wikipedia
var signature = CITWT.signature + "/" + CITWT.core.site,
r, s;
Line 2,422 ⟶ 2,555:
r = CITWT[ CITWT.core.site ];
if ( r ) {
UTIL.feed( signature, false, false, r );
}
break;
Line 2,562 ⟶ 2,695:
// facilitated()
// mw.config.get()
// UTILPREGO.feed()
// UTIL.fetch()
// UTIL.feed()
// UTIL.friend()
// mw.loader.using()
// (TASK.fire)
// 20162018-0307-2114 PerfektesChaos@de.wikipedia
var suitable = "|edit|submit|",
env, maxage, sub;
facilitated();
if ( typeof CITWT.core.loaded !== "boolean" ) {
Line 2,582 ⟶ 2,716:
env.wgPageContentModel === "wikitext" &&
UTIL.friend() ) {
if PREGO.feed( Version > 0 ) {;
maxage = 604855;
sub = "r";
} else {
maxage = 1000;
sub = "d";
}
UTIL.feed( "ext.gadget.preferencesGadgetOptions",
"preferencesGadgetOptions/" + sub,
604811 );
UTIL.fetch( "opus" );
sub = ( Version > 1 ? "r" : "d" );
UTIL.feed( "user:PerfektesChaos/WikiSyntaxTextMod/S",
"WikiSyntaxTextMod/" + sub + "S", );
maxage );
UTIL.feed( "user:PerfektesChaos/WikiSyntaxTextMod/U",
"WikiSyntaxTextMod/" + sub + "U", );
maxage );
UTIL.feed( "ext.gadget.isbnLib",
"isbnLib/" + sub, );
maxage );
if ( typeof CITWT.bibRecord !== "object" ) {
CITWT.bibRecord = false;