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

Content deleted Content added
-1.22
-4.3
 
(28 intermediate revisions by the same user not shown)
Line 1:
/// User:PerfektesChaos/js/citoidWikitext/core.js
// Execute core functionality for citoid on wikitext source editing
/// 20152018-0609-0503 PerfektesChaos@de.wikipedia
// ResourceLoader: compatible;
// dependencies: --
Line 17:
( function ( mw, $ ) {
"use strict";
var VERSIONVersion = -14.223,
MW_LIB Signature = "citoidWikitext",
APICSub = { } = "core",
BOOKSites = { } = "|dewiki|",
DESCAPIC = { },
GUIPBOOK = { btn: = { },
DESC caret: = { },
EDIT = { gadgetcodeMirror: { }false,
input wikEd: { false },
GUIP = { pushbtn: { }{ },
I18N = caret: { },
PROJ = false gadget: { },
TASK = input: { },
UTIL = push: { } },
HELP = { site: "w:en",
support: "user:PerfektesChaos/js/" + Signature },
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 = { },
UTIL = { },
XPORT = { core: { sites: Sites } },
CITWT;
 
 
 
if ( typeof mw.libs[ MW_LIB ] !== "object" ||
function facilitated() {
! mw.libs[ MW_LIB ] ) {
mw.libs[// MW_LIBMark ]sub-module =as { };ready
} // Uses:
// > Signature
CITWT = mw.libs[ MW_LIB ];
if ( typeof CITWT.vsn// === "string"> ) {Sub
CITWT.vsn// = CITWT.vsn + "> "; Version
// > XPORT
} else {
CITWT.vsn// = ""; < CITWT
// < .signature
}
CITWT.vsn // = CITWT< .vsn + "c:" + VERSION;
CITWT.type // = MW_LIB; < .type
// mw.loader.getState()
CITWT.signature = "ext.gadget." + CITWT.type;
// mw.loader.state()
CITWT.support = "user:PerfektesChaos/js/" + CITWT.type;
// mw.hook()
if ( typeof CITWT.core !== "object" || ! CITWT.core ) {
// 2018-08-24 PerfektesChaos@de.wikipedia
CITWT.core = { };
var sign = "ext.gadget." + Signature,
}
CITWT.core.sites sub = "|dewiki|/"; + Sub,
signature = sign + sub,
s = mw.loader.getState( signature ),
e, o, rls;
if ( s !== "loaded" && s !== "ready" ) {
rls = { };
rls[ signature ] = "loaded";
mw.loader.state( rls );
if ( typeof mw.libs[ Signature ] !== "object" ||
! mw.libs[ Signature ] ) {
mw.libs[ Signature ] = { };
}
CITWT = mw.libs[ Signature ];
CITWT.signature = sign;
if ( typeof CITWT.vsn === "string" ) {
CITWT.vsn = CITWT.vsn + " ";
} else {
CITWT.vsn = "";
}
CITWT.vsn = CITWT.vsn + Sub.substr( 0, 1 ) + ":" + Version;
CITWT.type = Signature;
CITWT.suite = ( Version > 1 ? "r" : "d" );
if ( typeof CITWT[ Sub ] !== "object" ||
! CITWT[ Sub ] ) {
CITWT[ Sub ] = { };
}
e = XPORT[ Sub ];
o = CITWT[ Sub ];
for ( s in e ) {
o[ s ] = e[ s ];
} // for s in e
for ( s in XPORT ) {
if ( typeof XPORT[ s ] === "function" ) {
CITWT[ s ] = XPORT[ s ];
}
} // for s in XPORT
rls[ signature ] = "ready";
mw.loader.state( rls );
mw.hook( CITWT.type + sub + ".ready" ).fire();
}
} // facilitated()
 
 
Line 59 ⟶ 114:
 
 
APIC.site = "https://citoid.wikimedia.org/urlapi";
APIC.stateless = "/api/rest_v1/data/citation/mediawiki/";
 
 
Line 72 ⟶ 128:
// GUIP.flat()
// console.log()
// console.dir()
// Remark: Used as event handler -- 'this' is not APIC
// 2015-05-01 PerfektesChaos@de.wikipedia
Line 86 ⟶ 143:
}
}; // APIC.fault()
 
 
 
APIC.finish = function () {
// All queries have been answered
// Uses:
// > APIC.results
// >< APIC.queries
// TASK.follow()
// 2017-06-10 PerfektesChaos@de.wikipedia
var n = APIC.queries.length,
i, j, q, r, ufo;
for ( i = 0; i < APIC.results.length; i++ ) {
r = APIC.results[ i ];
if ( r ) {
for ( j = 0; j < n; j++ ) {
q = APIC.queries[ j ];
if ( q === r.url ) {
r.lucky = true;
APIC.queries[ j ] = r;
r = false;
break; // for j
}
} // for j
if ( r ) {
if ( ! ufo ) {
ufo = [ ];
}
r.idResult = i;
ufo.push( r );
}
}
} // for i
if ( ufo ) {
i = 0;
if ( ufo.length === 1 ) {
ufo[ 0 ].idResult = false;
}
for ( j = 0; j < n; j++ ) {
q = APIC.queries[ j ];
if ( typeof q === "string" ) {
ufo[ i ].queryURL = q;
APIC.queries[ j ] = ufo[ i ];
i++;
}
} // for j
}
TASK.follow();
}; // APIC.finish()
 
 
Line 96 ⟶ 202:
// > .server
// > APIC.site
// > APIC.stateless
// > APIC.queries
// >< APIC.data
// >< APIC.jq
// >< APIC.legacy
// < APIC.results
// < APIC.missing
// (APIC.found)
// (APIC.fault)
// Remark: Used as event handler -- 'this' is not APIC
// 20152017-06-0111 PerfektesChaos@de.wikipedia
var f, i, query, service;
if ( typeof APIC.jq !== "object" ) {
f = function ( jqXHR ) {
Line 113 ⟶ 224:
service = APIC.site;
}
APIC.jqdata = { beforeSendformat: f,"mediawiki" }; // mediawiki zotero
APIC.jq = { beforeSend: f,
dataType: "json", // No "Intelligent Guess"
type url: "POST", service };
APIC.legacy = ( service.indexOf( "/url:" ) > 0 service });
if ( APIC.legacy ) {
APIC.jq.type = "POST";
} else if ( APIC.stateless ) {
APIC.site = window.___location.protocol + "//" +
window.___location.hostname + APIC.stateless;
} else {
APIC.jq.data = APIC.data;
}
}
APIC.results = [ ];
for ( i = 0; i < APIC.queries.length; i++ ) {
APIC.missing = APIC.queries.length;
for ( i = 0; i < APIC.missing; i++ ) {
/* citoid.wmflabs appears to handle an Array of URL
and will return an Array of result objects,
Line 124 ⟶ 246:
nor a stable implementation in spring 2015.
*/
APIC.jq.dataquery = JSON.stringify( { url: APIC.queries[ i ],;
switch ( typeof query ) {
format: "zotero" } );
$.ajax( APIC.jq ).done( APIC.foundcase )"string":
if .fail( APIC.faultlegacy ); {
APIC.data.url = query;
APIC.jq.data = JSON.stringify( APIC.data );
} else if ( APIC.stateless ) {
APIC.jq.url = APIC.site + encodeURIComponent( query );
} else {
APIC.jq.data.search = query;
}
$.ajax( APIC.jq ).done( APIC.found )
.fail( APIC.fault );
break;
case "object":
if ( typeof query.beforeSend === "string"
&& query.beforeSend === "json" ) {
query.jq.beforeSend = f;
}
query.jq.beforeSend = f;
$.ajax( query.jq ).done( query.found )
.fail( query.fault );
break;
} // switch typeof query
} // for i
}; // APIC.fire()
Line 134 ⟶ 276:
 
APIC.found = function ( arrived ) {
// QueryAnswer has been answeredarrived
// Precondition:
// arrived -- object, full result
// string, favorite result
// boolean, no favorite result
// Uses:
// > < APIC.queriesmissing
// >< APIC.results
// GUIP.flat()
// TASK.follow()
// APIC.finish()
// Remark: Used as event handler -- 'this' is not APIC
// 20152018-0607-0514 PerfektesChaos@de.wikipedia
var got, i, leap, lone, n, q;
ifswitch ( arrivedtypeof arrived ) &&{
typeof arrived === case "objectboolean" &&:
typeof arrivedAPIC.length === "number" ) {missing--;
got = arrived[ 0 ]break;
if ( typeof got.url === case "string" ) {:
n APIC.missing = APIC.queries.length-1;
lone = GUIP.flat( n === 1 );
if TASK.follow( lone ) {;
lone = APIC.queries[ 0 ]break;
case if ( lone === got.url ) {"object":
if ( arrived && typeof arrived.length lone === "number" ) false;{
}got else= {arrived[ 0 ];
if ( got APIC.queries[ 0 ]&& = typeof got.url; === "object" ) {
if ( typeof got.url === "string" && got.url ) {
APIC.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 );
}
}
}
for ( i = 0break; i < n; i++ ) {
} // switch typeof q = APIC.queries[ i ];arrived
if ( q ===! gotAPIC.urlmissing ) {
APIC.queries[ i ] = gotfinish();
} else if ( typeof q === "string" ) {
leap = true;
}
} // for i
if ( ! leap ) {
if ( lone ) {
APIC.queries[ 0 ].urlQuery = lone;
}
TASK.follow();
}
}
}
}; // APIC.found()
Line 182 ⟶ 331:
 
 
BOOK.countries978fire = [function () {
[// "bg",Initialize 954ISBN ],support
[// "cs", 80 ],Uses:
[// "da", 87 ], mw.hook()
[// "de", 3 ], (BOOK.first)
// 2016-03-21 PerfektesChaos@de.wikipedia
[ "el", 960, 9963 ],
[mw.hook( "enisbnLib.ready", 0,).add( 1BOOK.first ],);
}; // BOOK.fire()
[ "es", 84, 950, 956, 958, 959, 968, 970, 980, 987,
9942, 9945, 9962, 9968, 9972, 9974, 9977, 9978,
99905, 99922, 99923, 99924, 99925, 99926,
99934, 99939, 99953, 99954 ],
[ "et", 9949, 9985 ],
[ "fi", 951, 952 ],
[ "fr", 2 ],
[ "he", 965 ],
[ "hu", 963 ],
[ "it", 88 ],
[ "ja", 4 ],
[ "ko", 89, 9946 ],
[ "nl", 90 ],
[ "nn", 82 ],
[ "no", 82 ],
[ "pl", 83 ],
[ "pt", 85, 972, 989 ],
[ "ru", 5 ],
[ "sk", 80 ],
[ "sl", 961 ],
[ "sv", 91 ],
[ "th", 974 ],
[ "tr", 975, 9944 ],
[ "uk", 966 ],
[ "zh", 7 ]
]; // BOOK.countries978 2015-05-01
 
 
 
BOOK.finderfirst = function ( assignapplication ) {
// Retrieve set of library catalog URLs for a particular language
// Precondition:
// assign -- language code (not "qqq"), or false
// Postcondition:
// Returns Array, might be empty
// "qqq" will always precede the list
// Uses:
// this
// > BOOK.catalogs
// BOOK.furnish()
// 2015-05-01 PerfektesChaos@de.wikipedia
var r = [ ],
g, i;
if ( typeof BOOK.catalogs !== "object" ) {
BOOK.furnish();
}
for ( i = 0; i < BOOK.catalogs.qqq.length; i++ ) {
r.push( BOOK.catalogs.qqq[ i ] );
} // for i
if ( assign &&
typeof BOOK.catalogs[ assign ] === "object" ) {
g = BOOK.catalogs[ assign ];
for ( i = 0; i < g.length; i++ ) {
r.push( g[ i ] );
} // for i
}
return r;
}; // BOOK.finder()
 
 
 
BOOK.focus = function ( analyse, advanced ) {
// Guess language code from ISBN string
// Precondition:
// analyseapplication -- ISBN string (length 10 or 13)isbnLib
// advanced -- ISBN-13 from 979
// Postcondition:
// Returns language code, or false
// Uses:
// this < .isbnLib
// > BOOK.countries978isbnLib.furnish()
// 2015-05-01 PerfektesChaos@de GUIP.wikipediafire()
// 2016-03-25 PerfektesChaos@de.wikipedia
var r = false,
CITWT.isbnLib = g, i, k, napplication;
if ( advanced ) {
switch ( analyse.substr( 3, 2 ) ) {
case "10": r = "fr"; break;
case "11": r = "ko"; break;
case "12": r = "it"; break;
} // switch substr( 3, 2 )
} else {
switch ( analyse.substr( 0, 1 ) ) {
case "0":
case "1": r = "en"; break;
case "2": r = "fr"; break;
case "3": r = "de"; break;
case "4": r = "ja"; break;
case "5": r = "ru"; break;
case "6":
n = analyse.substr( 0, 3 );
break;
case "7": r = "zh"; break;
case "8":
n = analyse.substr( 0, 2 );
break;
case "9":
switch ( analyse.substr( 0, 2 ) ) {
case "90":
case "94": r = "nl"; break;
case "91": r = "sv"; break;
case "92": r = "mul"; break;
default:
if ( analyse.substr( 1, 1 ) === "9" ) {
if ( analyse.substr( 2, 1 ) === "9" ) {
n = 5;
} else {
n = 4;
}
} else {
n = 3;
}
n = analyse.substr( 0, n );
} // switch substr( 0, 2 )
break;
} // switch substr( 0, 1 )
if ( n ) {
n = parseInt( n, 10 );
for ( i = 0; i < this.countries978.length; i++ ) {
g = this.countries978[ i ];
for ( k = 1; k < g.length; k++ ) {
if ( g[ k ] === n ) {
r = g[ 0 ];
break; // for k
}
} // for k
if ( r ) {
break; // for i
}
} // for i
}
}
return r;
}; // BOOK.focus()
 
 
 
BOOK.furnish = function () {
// Build set of library catalogs, including user defined
// Uses:
// this
// > CITWT.isbn (user defined)
// < BOOK.catalogs
// 2015-05-01 PerfektesChaos@de.wikipedia
var g, i, s, slang, user;
BOOK.catalogs = {
de: [ "http://swb.bsz-bw.de/"
+ "DB=2.1/CMD?ACT=SRCHA&IKT=1007&TRM=#",
// "http://gso.gbv.de/DB=2.1/"
// + "CMD?ACT=SRCHA&IKT=1007&TRM=#",
"https://portal.dnb.de/"
+ "opac.htm?method=simpleSearch&query=#" ],
en: [ "http://catalog.loc.gov/"
+ "cgi-bin/Pwebrecon.cgi?DB=local&CNT=10&CMD=#" ],
// British Library requires Login
// "http://explore.bl.uk/"
// + "primo_library/libweb/action/search.do"
// + "?fn=search&vl(freeText0)=#"
fr: [ "http://catalogue.bnf.fr/servlet/AccueilConnecte?"
+ "recherche=equation&Equation=ibn+=+#" ],
nl: [ "http://opc4.kb.nl/"
+ "LNG=NE/CMD?ACT=SRCH&IKT=1007&TRM=#" ],
pl: [ "http://koha.biblos.pk.edu.pl/cgi-bin/koha/"
+ "opac-search.pl?idx=nb&q=#" ],
qqq: [ "http://www.worldcat.org/search?q=isbn:#" ]
};
switch ( typeof CITWT.isbn ) {
case "string":
user = { qqq: [ CITWT.isbn ] };
break;
case "object":
if CITWT.isbnLib.furnish( CITWT.isbn ) {;
if ( CITWT.isbn.length === "number" ) {
user = { qqq: CITWT.isbn };
} else {
user = CITWT.isbn;
}
}
break;
} // switch typeof CITWT.isbn
if GUIP.fire( user ) {;
}; // for BOOK.first( slang in user ) {
g = user[ slang ];
if ( typeof g === "object" && g
&& typeof g.length === "number" ) {
if ( typeof BOOK.catalogs[ slang ] !== "object" ) {
BOOK.catalogs[ slang ] = [ ];
}
for ( i = 0; i < g.length; i++ ) {
s = g[ i ];
if ( typeof s === "string" &&
s.indexOf( "#" ) > 10 ) {
BOOK.catalogs[ slang ].push( s );
}
} // for i
}
} // for slang in user
} // user defined
}; // BOOK.furnish()
 
 
 
//-----------------------------------------------------------------------
 
 
 
DESC.re = { };
 
 
Line 401 ⟶ 377:
// Returns object, or false
// Uses:
// > .bibRecord
// > GUIP.caret.story
// DESC.fold()
// DESC.*()
// 2015-0507-3101 PerfektesChaos@de.wikipedia
var got, i, mode, r, s, start;
if ( attempt ) {
s = attempt.replace( /^\s+/, "" );
i = s.indexOf( "</ref>" );
if ( i >= 0 ) {
s = s.substr( 0, i );
}
if ( s ) {
switch ( s.substr( 0, 1 ) ) {
Line 455 ⟶ 434:
break;
} // switch s.substr( 0, 1 )
//console.log("DESC.fire()", s)
if ( ! s && CITWT.bibRecord && ! GUIP.caret.story ) {
s = CITWT.bibRecord.id;
}
if ( s ) {
if ( mode ) {
Line 492 ⟶ 467:
// > PROJ
// mw.config.get()
// 20152017-05-1217 PerfektesChaos@de.wikipedia
var r = false,
env, got, i, ns, sign, space, suffix;
Line 530 ⟶ 505:
case "DNB":
case "DOI":
case "ISBN":
case "LCCN":
case "OCLC":
case "PMC":
case "PMID":
case "RFC":
got = /^\|\s*([^|}]+)\s*[|}]/.exec( suffix );
if ( got ) {
Line 599 ⟶ 577:
// Postcondition:
// Returns object, or not
// 2015-0506-0130 PerfektesChaos@de.wikipedia
var got, i, r, s;
switch ( achieved ) {
case 0:
Line 615 ⟶ 593:
s = got[ 1 ].replace( /^\s+/, "" )
.replace( /\s+$/, "" );
i = s.indexOf( "}}" );
if ( i > 0 && s.indexOf( "{", i ) < 0 ) {
s = s.substr( 0, i );
}
r = { scheme: "doi",
doi: s,
Line 650 ⟶ 632:
// Uses:
// > GUIP.caret.starter
// 2015-05-19 PerfektesChaos@de >< DESC.re.wikipediaurl
// 2015-09-07 PerfektesChaos@de.wikipedia
var got = /(\S+)\s?/.exec( attempt ),
i, r, re, s, site, suffix;
if ( got ) {
if ( typeof DESC.re.url !== "object" ) {
s = "^((?:f|ht)tps?://"
+ "(?:[^./]+\\.)+\\w+"
+ "(?::[0-9]+)?)"
+ "(/.*)$";
DESC.re.url = new RegExp( s, "i" );
}
s = got[ 1 ];
r = { scheme: "url" };
re got = /^((?:f|ht)tps?:\/\/(?:[^DESC.\/]+\re.)+\w+)url.exec(\/.* s )$/i;
got = re.exec( s );
if ( got ) {
site = got[ 1 ].toLowerCase();
Line 673 ⟶ 662:
}
}
re = /^([^#<]+)([#<])(.*)$/;
got = re.exec( suffix );
if ( got ) {
suffix = got[ 1 ];
if ( got[ 2 ] === "#" ) {
r.subtle = got[ 3 ];
}
}
r.url = site + suffix;
// TODO ///////// redirect URL
r.source = r.url;
got = /[.\/]?([^.\/]+\.\w+)(:[0-9]+)?$/.exec( site );
if ( got ) {
r.say = got[ 1 ];
Line 714 ⟶ 707:
// Returns object, or not
// Uses:
// BOOK.isbnLib.focus()
// BOOK.isbnLib.finder()
// 20152016-0503-0129 PerfektesChaos@de.wikipedia
var got, i, isbnLib, r;
switch ( achieved ) {
case 0:
Line 730 ⟶ 723:
got = /^([-0-9]+x?)(?:[^-0-9x].*)?$/i.exec( r.isbn );
if ( got ) {
isbnLib = CITWT.isbnLib;
r.isbn = got[ 1 ].replace( /-/g, "" );
switch ( r.isbn.length ) {
Line 735 ⟶ 729:
r.isbn = r.isbn.toUpperCase();
if ( /^[0-9]+X?$/.test( r.isbn ) ) {
r.lang = BOOKisbnLib.focus( r.isbn );
r.url = true;
}
break;
Line 743 ⟶ 737:
if ( got ) {
if ( got[ 1 ] === "8" ) {
r.lang = BOOKisbnLib.focus( r.isbn.substr( 3 ) );
} else {
r.lang = BOOKisbnLib.focus( r.isbn, true );
}
r.url = true;
Line 752 ⟶ 746:
} // switch n
if ( r.url ) {
r.url = BOOKisbnLib.finder( r.lang );
r.say = r.isbn;
r.url.push( "/wiki/Special:Booksources/#" );
Line 882 ⟶ 876:
// > .vsn
// > GUIP.$textarea
// < GUIP.live
// < GUIP.oneof
// < GUIP.$panel
Line 890 ⟶ 885:
// GUIP.fiat()
// (TASK.fiat)
// 2015-0506-3016 PerfektesChaos@de.wikipedia
var collection = [ "empty",
"invalid",
Line 898 ⟶ 893:
"yippie" ],
i, $editarea;
GUIP.live = false;
GUIP.oneof = { };
GUIP.$panel = $( "<div>" );
Line 1,038 ⟶ 1,034:
// Uses:
// > GUIP.$panel
// > CITWT.bibRecord
// > .leading (user defined)
// < GUIP.$textarea
// < GUIP.submit
Line 1,046 ⟶ 1,043:
// GUIP.btn.fire()
// mw.loader.using()
// GUIP.flat()
// mw.loader.load()
// (.fire);
// Remark: Used as event handler -- 'this' is not GUIP
// 20152017-0502-3120 PerfektesChaos@de.wikipedia
var require;
GUIP.$textarea = $( "#wpTextbox1" );
Line 1,059 ⟶ 1,057:
require = [ "jquery.textSelection",
"mediawiki.api" ];
if ( CITWT.bibRecord && CITWT.bibRecord.launch ) {
mw.loader.using( require, CITWT.fire );
} else {
if ( typeof CITWT.leading === "boolean"
&& CITWT.leading ) {
GUIP.flat( false );
}
mw.loader.load( require );
}
Line 1,080 ⟶ 1,082:
// > .vsn
// > GUIP.$panel
// > < GUIP.$textarealive
// GUIP.input.free()
// GUIP.input.fire()
// 2015-0506-2716 PerfektesChaos@de.wikipedia
var leave, s, $child, $elem;
if ( access ) {
Line 1,112 ⟶ 1,114:
} // for $elem in .oneof
GUIP.push.flip( 0 );
/*
// re-assign panel for wikiEditor
GUIP.$panel.detach();
GUIP.$textarea = $( "#wpTextbox1" ); // Test wikiEditor
GUIP.$textarea.before( GUIP.$panel );
*/
GUIP.$panel.show();
GUIP.live = true;
if ( $elem ) {
$elem.show();
Line 1,218 ⟶ 1,215:
// GUIP.btn.portlet()
// (GUIP.btn.wikiEditor)
// 20152018-0508-1424 PerfektesChaos@de.wikipedia
if ( ! this.wikEd() ) {
if ( GUIP.opts.usebetatoolbar ) {
GUIP.submit = "wikiEditor ... (loading)";
mw.loader.using( [ "ext.wikiEditor.toolbar" ],
this.wikiEditor );
} else if ( GUIP.opts.showtoolbar ) {
Line 1,290 ⟶ 1,287:
// > GUIP.btn.show
// < GUIP.submit
// < GUIPEDIT.wikEd
// mw.user.options.get()
// GUIP.file()
// 20152018-0507-1221 PerfektesChaos@de.wikipedia
var id = 746,
cnf;
if ( mw.user.options.get( "gadget-wikEd" )
|| ( typeof window.wikEd === "object" ) {
&& window.wikEd ) ) {
if ( typeof window.wikEd !== "object" ) {
window.wikEd = { config: { } };
}
ifEDIT.wikEd ( typeof= window.wikEd.config !== "object" ) {;
if ( typeof windowEDIT.wikEd.config !== { button: "object" ) { },
EDIT.wikEd.config = { button: { },
buttonBar: { } };
}
cnf = windowEDIT.wikEd.config;
if ( typeof cnf.button !== "object" ) {
cnf.button = { };
Line 1,331 ⟶ 1,330:
}
cnf.buttonBar.custom1[ 6 ].push( id );
if ( typeof windowEDIT.wikEd.useWikEddisabled === "boolean" &&
&&typeof windowEDIT.wikEd.useWikEdhighlightSyntax ) {=== "boolean" &&
typeof EDIT.wikEd.turnedOn === "boolean" &&
typeof EDIT.wikEd.useWikEd === "boolean"
&& EDIT.wikEd.useWikEd ) {
GUIP.submit = "wikEd";
}
GUIP.wikEd = true;
}
return GUIP.submit;
Line 1,434 ⟶ 1,435:
// > GUIP.caret.max
// > GUIP.$textarea
// > EDIT.codeMirror
// > EDIT.wikEd
// Remark: Used as event handler -- 'this' is not GUIP.caret
// 20152018-0507-0121 PerfektesChaos@de.wikipedia
var shift, start, story;
if ( GUIP.caret.max >= 0 ) {
Line 1,454 ⟶ 1,457:
story = start + shift + story;
GUIP.$textarea.val( story );
if ( alienEDIT.codeMirror ===&& "wikEd"EDIT.codeMirror.liveCITWT ) {
windowEDIT.wikEdcodeMirror.UpdateFramedoc.setValue( story );
} else if ( alien === "wikEd" ) {
EDIT.wikEd.UpdateFrame();
}
}
Line 1,463 ⟶ 1,468:
 
GUIP.caret.find = function () {
// Get selection in regular textarea, but perhaps CodeMirror
// Precondition:
// jquery.textSelection has been loaded
Line 1,469 ⟶ 1,474:
// selection assigned
// Uses:
// > CodeMirror
// > GUIP.$textarea
// > GUIP.caret.further
// >< EDIT.codeMirror
// < GUIP.caret.story
// < GUIP.caret.min
Line 1,477 ⟶ 1,484:
// < GUIP.caret.starter
// Remark: Used as event handler -- 'this' is not GUIP.caret
// 20152018-0507-1921 PerfektesChaos@de.wikipedia
var rg, uo;
var rg = GUIP.$textarea.textSelection( "getCaretPosition",
if ( ! EDIT.codeMirror &&
{ "startAndEnd": true } );
typeof window.CodeMirror === "function" &&
typeof window.CodeMirror.doc === "object"
&& window.CodeMirror.doc ) {
EDIT.codeMirror = window.CodeMirror;
}
if ( EDIT.codeMirror ) {
uo = mw.user.options.get( "usecodemirror" );
EDIT.codeMirror.liveCITWT = ( typeof uo === "number"
&& uo > 0 );
if ( EDIT.codeMirror.liveCITWT ) {
GUIP.$textarea.val( EDIT.codeMirror.doc.getValue() );
}
}
rg = GUIP.$textarea.textSelection( "getCaretPosition",
{ "startAndEnd": true } );
GUIP.caret.story = GUIP.$textarea.val();
if ( rg[0] <= rg[1] ) {
Line 1,500 ⟶ 1,522:
// Uses:
// this
// > GUIPEDIT.wikEd
// > wikEd
// > GUIP.$textarea
// < GUIP.caret.start
Line 1,511 ⟶ 1,532:
// < GUIP.caret.starter
// (GUIP.caret.wikEdEnclose)
// 20152018-0501-1921 PerfektesChaos@de.wikipedia
var r;
if ( GUIPEDIT.wikEd && window.wikEd.useWikEd ) {
! EDIT.wikEd.disabled &&
EDIT.wikEd.useWikEd &&
EDIT.wikEd.turnedOn &&
EDIT.wikEd.highlightSyntax ) {
this.start = "##\f#citoid_marker_begin##\f#";
this.stop = "##\f#citoid_marker_end##\f#";
windowEDIT.wikEd.EditButton( null,
null,
null,
this.wikEdEnclose );
windowEDIT.wikEd.UpdateTextarea();
r = GUIP.$textarea.val();
this.min = r.search( this.start );
Line 1,526 ⟶ 1,551:
this.max = r.search( this.stop ) - 1;
r = r.replace( this.stop, "" );
GUIP.g$textarea.val( r );
this.story = r;
this.selection = this.story.substr( this.min );
this.starter = this.story.substr( 0, this.min );
windowEDIT.wikEd.UpdateFrame();
r = true;
}
Line 1,545 ⟶ 1,570:
// assign got further properties
// Uses:
// > EDIT.wikEd
// > GUIP.caret.start
// > GUIP.caret.stop
// Remark: Used as event handler -- 'this' is not GUIP.caret
// 20152018-0507-0121 PerfektesChaos@de.wikipedia
windowEDIT.wikEd.GetText( assign, "selection, cursor" );
if ( assign.selection.plain === "" ) {
assign.sel = windowEDIT.wikEd.GetSelection();
if ( assign.sel.anchorNode.previousSibling ) {
assign.changed = assign.cursor;
} else {
windowEDIT.wikEd.GetText( assign, "whole" );
assign.changed = assign.whole;
}
Line 1,625 ⟶ 1,651:
// UTIL.fullstop()
// GUIP.input.fire()
// Remark: Used as event handler -- 'this' is not GUIP.inputgadget
// 2015-05-12 PerfektesChaos@de.wikipedia
UTIL.fullstop( event );
Line 1,639 ⟶ 1,665:
// event -- jQuery event object
// Uses:
// > HELP.support
// UTIL.fullstop()
// I18N.fair()
// mw.util.getUrl()
// Remark: Used as event handler -- 'this' is not GUIP.inputgadget
// 20152018-0507-1220 PerfektesChaos@de.wikipedia
var support = "https://" + I18N.fair( "helpSite", true )
+ ".wikipedia.org"
+ mw.util.getUrl( CITWTHELP.support );
UTIL.fullstop( event );
window.open( support, "citWThelp" );
Line 1,660 ⟶ 1,686:
// Uses:
// > GUIP.$panel
// < GUIP.live
// GUIP.gadget.home()
// Remark: Used as event handler -- 'this' is not GUIP.inputgadget
// 2015-0506-0116 PerfektesChaos@de.wikipedia
GUIP.gadget.home( event );
GUIP.$panel.hide();
GUIP.live = false;
}; // GUIP.gadget.hide()
 
Line 1,676 ⟶ 1,704:
// UTIL.fullstop()
// GUIP.flat()
// Remark: Used as event handler -- 'this' is not GUIP.inputgadget
// 2015-05-12 PerfektesChaos@de.wikipedia
UTIL.fullstop( event );
Line 1,693 ⟶ 1,721:
// Uses:
// this
// > GUIP.input.$text
// > GUIP.input.live
// GUIP.input.fire()
// 2015-05-01 PerfektesChaos@de.wikipedia
Line 1,726 ⟶ 1,754:
// event -- jQuery event object
// Uses:
// > GUIP.input.live
// > GUIP.input.$text
// CITWT.fire()
// Remark: Used as event handler -- 'this' is not GUIP.input
// 2015-0506-2416 PerfektesChaos@de.wikipedia
if ( ( event.which === 10 || event.which === 13 ) {
&& GUIP.input.live
&& GUIP.input.$text.is( ":focus" ) ) {
CITWT.fire( event );
}
Line 2,088 ⟶ 2,120:
}
}; // 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-09-03 PerfektesChaos@de.wikipedia
var sign = "ext.gadget." + PREGO.signature,
rls;
if ( ! mw.loader.getState( sign ) ) {
rls = { };
rls[ sign ] = "loading";
mw.loader.state( rls );
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,109 ⟶ 2,266:
// (TASK.found)
// Remark: Used as event handler -- 'this' is not TASK
// 2015-0506-1216 PerfektesChaos@de.wikipedia
var suggestlisten = GUIP.input.filler();true,
UTIL.fullstop( event ) suggest;
TASK.templateif =( false;event ) {
listen = GUIP.live && GUIP.$button.is( ":focus" );
if ( suggest ) {
TASK.foundif ( suggestlisten ); {
UTIL.fullstop( event );
} else {
GUIP.flat( true );}
}
GUIP.caret.fetch( TASK.found );
if ( listen ) {
suggest = GUIP.input.filler();
TASK.template = false;
if ( suggest ) {
TASK.found( suggest );
} else {
GUIP.flat( true );
GUIP.caret.fetch( TASK.found );
}
}
}; // TASK.fiat()
Line 2,134 ⟶ 2,300:
// .(project).fire()
// GUIP.caret.fill()
// GUIP.flat()
// GUIP.push.flip()
// Remark: Used as event handler -- 'this' is not TASK
// 20152017-06-0104 PerfektesChaos@de.wikipedia
var mode, result;
var result = CITWT.opus.fire( TASK.query, APIC.queries ),
if ( ! APIC.missing mode;) {
result = CITWT.opus.fire( TASK.query, APIC.queries );
//console.log("TASK.filter() " )
}
TASK.template = PROJ.fire( result );
//console.dir( result[ 0 ] )
switch ( typeof TASK.template ) {
case "object":
//console.dir( TASK.template )
mode = ( TASK.template[ 0 ][ 2 ] ? 4 : 3 );
break;
case "string":
if ( CITWT.bibRecord && CITWT.bibRecord.launch ) {
GUIP.caret.fill( TASK.template );
TASK.template = false;
GUIP.flat( "translated", TASK.query.$links );
} else {
mode = 3;
Line 2,177 ⟶ 2,344:
// mw.user.options.get()
// mw.loader.using()
// GUIPBOOK.fire()
// (GUIPBOOK.fire)
// 20152016-0503-1621 PerfektesChaos@de.wikipedia
if ( typeof CITWT[ CITWT.core.site ] === "object" ) {
PROJ = CITWT[ CITWT.core.site ];
Line 2,189 ⟶ 2,356:
// race condition
mw.loader.using( [ "ext.wikiEditor" ],
GUIPBOOK.fire );
} else {
GUIPBOOK.fire();
}
}
Line 2,207 ⟶ 2,374:
// mw.loader.using()
// (TASK.filter)
// 20152016-0502-1221 PerfektesChaos@de.wikipedia
GUIP.flat( "translated" );
mw.loader.using( [ CITWT.signature + "/opus",
"user:PerfektesChaos/js/WikiSyntaxTextMod/U" ],
TASK.filter );
GUIP.flat( "translated", TASK.query.$links );
Line 2,223 ⟶ 2,390:
// Uses:
// > GUIP.caret.selection
// > .bibRecord
// > APIC.stateless
// > APIC.found
// < TASK.query
// < APIC.queries
// DESC.fire()
// GUIP.flat()
// APIC.worldCat.fire()
// .(project).favorite()
// GUIP.$flip()
// GUIP.$flipper()
Line 2,232 ⟶ 2,405:
// GUIP.input.filler()
// (APIC.fire)
// 20152017-0506-1411 PerfektesChaos@de.wikipedia
var search = ( ask ? ask : GUIP.caret.selection ),
i,stateless k,= m"|isbn|", q, suggest, url; // |oclc
i, k, m, project, q, suggest, url;
if ( ! search && CITWT.bibRecord ) {
search = CITWT.bibRecord.sign + " " + CITWT.bibRecord.subject;
}
if ( search ) {
TASK.query = DESC.fire( search );
Line 2,275 ⟶ 2,452:
}
GUIP.flat( "throbber", q.$links );
if ( typeof APIC.stateless === "string" &&
typeof q.scheme === "string" &&
stateless.indexOf( "|" + q.scheme + "|" ) >= 0 ) {
stateless = q[ q.scheme ];
if ( typeof stateless === "string" ) {
stateless = q.scheme.toUpperCase()
+ " " + stateless;
APIC.queries.push( stateless );
}
}
if ( typeof PROJ.favorite === "function" ) {
project = PROJ.favorite( q, APIC.found );
if ( project ) {
project.local = true;
APIC.queries.push( project );
}
}
mw.loader.using( [ "mediawiki.api" ],
APIC.fire );
Line 2,340 ⟶ 2,534:
 
 
UTIL.feed = function ( assigned, access, age, address ) {
// Load and run script
// Precondition:"empty"
// assigned -- signature
// access -- script
// age -- maxage
// address -- URL to be used, else created from access
// Uses:
// > .suite
// > REPOS.maxage
// mw.loader.getState()
// mw.loader.implementstate()
// 2015-05-17 PerfektesChaos@de mw.loader.wikipediaload()
var// source = address; REPOS.fire()
// 2018-09-03 PerfektesChaos@de.wikipedia
var p, rls;
if ( ! mw.loader.getState( assigned ) ) {
ifrls (= !{ source ) {};
rls[ assigned source] = "//en.wikipedia.orgloading";
mw.loader.state( rls );
+ "/w/index.php?title="
if ( address ) + "User:PerfektesChaos/js/"{
mw.loader.load( address + access);
} else + ".js"{
p = { bcache: + "&bcache=1&maxage=" + age};
p.maxage = ( CITWT.suite === "r" ? +REPOS.maxage "&action=raw" : 100 );
REPOS.fire( + "&ctype=text/javascript";REPOS.site,
REPOS.store + access + ".js",
false,
p );
}
mw.loader.implement( assigned, [ source ] );
}
}; // UTIL.feed()
Line 2,369 ⟶ 2,568:
 
 
UTIL.fetch = function ( access, age ) {
// Run subscripts
// Precondition:
// access -- subscript
// age -- maxage
// Uses:
// > .signature
// > .type
// >< .suite
// UTIL.feed()
// 20152018-0507-2728 PerfektesChaos@de.wikipedia
var sub = "/" + access;
if ( typeof CITWT.suite !== "string" ) {
CITWT.suite = "r";
}
UTIL.feed( CITWT.signature + sub,
CITWT.type + sub + "/" + CITWT.suite, );
( age ? age : 900 ) );
}; // UTIL.fetch()
 
Line 2,394 ⟶ 2,588:
// Load current project plug-in, if appropriate
// Postcondition:
// Returns something, if plug-in shoukdshould becoebecome available
// Uses:
// > .signature
Line 2,403 ⟶ 2,597:
// UTIL.fetch()
// console.log()
// 20152018-0507-1714 PerfektesChaos@de.wikipedia
var signature = CITWT.signature + "/" + CITWT.core.site,
r, s;
Line 2,411 ⟶ 2,605:
r = CITWT[ CITWT.core.site ];
if ( r ) {
UTIL.feed( signature, false, false, r );
}
break;
Line 2,460 ⟶ 2,654:
 
 
CITWTXPORT.core.fold = function ( analyse ) {
// Derive simple template parameters; not nested
// Precondition:
Line 2,466 ⟶ 2,660:
// Postcondition:
// Returns object, with components identified by strings
// Uses:
// 2015-05-12 PerfektesChaos@de.wikipedia
var i = 0,
Line 2,507 ⟶ 2,700:
} // for i
return r;
}; // CITWTXPORT.core.fold()
 
 
Line 2,515 ⟶ 2,708:
 
 
CITWTXPORT.fire = function ( event ) {
// Tool button has been clicked
// Precondition:
Line 2,525 ⟶ 2,718:
// GUIP.factory()
// TASK.fiat()
// Remark: Used as event handler -- 'this' is not CITWTXPORT
// 2015-05-23 PerfektesChaos@de.wikipedia
//console.log("CITWT.fire()",event)
UTIL.fullstop( event );
if ( GUIP.$panel ) {
Line 2,535 ⟶ 2,727:
}
TASK.fiat();
}; // CITWTXPORT.fire()
 
 
Line 2,546 ⟶ 2,738:
// Start regular workflow in edit mode, if appropriate
// Uses:
// > CITWT
// > HELP.site
// > HELP.support
// > Version
// > .signature
// >< .core.loaded
// >< .bibRecord
// < .support
// < .core.site
// mw.loader.statefacilitated()
// mw.config.get()
// UTILPREGO.feed()
// UTIL.fetch()
// UTIL.feed()
// UTIL.friend()
// mw.loader.using()
// (TASK.fire)
// 20152018-0507-3128 PerfektesChaos@de.wikipedia
var suitableenv, = "|edit|submit|"sub, suitable;
envfacilitated();
mw.loader.stateif ( CITWT.signature +) "/core", "ready" );{
if ( typeof CITWT.core.loaded !== "boolean" ) {
CITWT.core.loaded = true;
env = mw.config.get( [ "wgAction",
"wgDBname",
"wgIsProbablyEditable",
"wgPageContentModel" ] );
CITWT.support = "[[" + HELP.site + ":" + HELP.support + "]]";
CITWT.core.site = env.wgDBname;
suitable = "|edit|submit|";
if ( suitable.indexOf( env.wgAction ) > 0 &&
env.wgIsProbablyEditable &&
env.wgPageContentModel === "wikitext" &&
UTIL.friend() ) {
UTILPREGO.feed( "ext.gadget.preferencesGadgetOptions",);
"preferencesGadgetOptions/r",
604811 );
UTIL.fetch( "opus" );
sub = ( Version > 1 ? "r" : "d" );
UTIL.feed( "user:PerfektesChaos/js/WikiSyntaxTextMod/U",
UTIL.feed( "user:PerfektesChaos/WikiSyntaxTextMod/rUS",
604800"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;
Line 2,596 ⟶ 2,795:
fire();
}( window.mediaWiki, window.jQuery ) );
 
/// EOF </nowiki> citoidWikitext/core/d.js