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
///
// ResourceLoader: compatible;
// dependencies: --
Line 17:
( function ( mw, $ ) {
"use strict";
var Version = -3.
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.
} else {
APIC.jq.data = APIC.data;
Line 256 ⟶ 264:
// APIC.finish()
// Remark: Used as event handler -- 'this' is not APIC
//
var got;
switch ( typeof arrived ) {
Line 270 ⟶ 278:
if ( arrived && typeof arrived.length === "number" ) {
got = arrived[ 0 ];
if ( got && typeof got
APIC.
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
// Load and run script
// Precondition:
// assigned -- signature
// access -- script
// address -- URL to be used, else created from access
// Uses:
// > Version
// >< .suite
// mw.loader.getState()
// mw.loader.state()
// mw.loader.load()
//
// 2018-07-14 PerfektesChaos@de.wikipedia
var p;
if ( ! mw.loader.getState( assigned ) ) {
mw.loader.state( assigned, "loading" );
if ( address ) {
} else {
if ( typeof CITWT.suite !==
CITWT.suite = ( Version > 1 ?
p.maxage = ( CITWT.suite === "r" ?
REPOS.fire(
REPOS.store + assigned + "
p );
}
}
}; // UTIL.feed()
Line 2,380 ⟶ 2,514:
UTIL.fetch = function ( access
// Run subscripts
// Precondition:
// access -- subscript
// Uses:
// > .signature
// > .type
// > Version
// >< .suite
// UTIL.feed()
//
var sub = "/" + access;
if ( typeof CITWT.suite !== "string" ) {
Line 2,396 ⟶ 2,530:
}
UTIL.feed( CITWT.signature + sub,
CITWT.type + sub + "/" + CITWT.suite
}; // UTIL.fetch()
Line 2,414 ⟶ 2,547:
// UTIL.fetch()
// console.log()
//
var signature = CITWT.signature + "/" + CITWT.core.site,
r, s;
Line 2,422 ⟶ 2,555:
r = CITWT[ CITWT.core.site ];
if ( r ) {
UTIL.feed( signature
}
break;
Line 2,562 ⟶ 2,695:
// facilitated()
// mw.config.get()
//
// UTIL.fetch()
// UTIL.feed()
// UTIL.friend()
// mw.loader.using()
// (TASK.fire)
//
var suitable = "|edit|submit|",
env
facilitated();
if ( typeof CITWT.core.loaded !== "boolean" ) {
Line 2,582 ⟶ 2,716:
env.wgPageContentModel === "wikitext" &&
UTIL.friend() ) {
UTIL.fetch( "opus" );
sub = ( Version > 1 ? "r" : "d" );
UTIL.feed( "user:PerfektesChaos/WikiSyntaxTextMod/S",
"WikiSyntaxTextMod/" + sub + "S"
UTIL.feed( "user:PerfektesChaos/WikiSyntaxTextMod/U",
"WikiSyntaxTextMod/" + sub + "U"
UTIL.feed( "ext.gadget.isbnLib",
"isbnLib/" + sub
if ( typeof CITWT.bibRecord !== "object" ) {
CITWT.bibRecord = false;
|