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

Content deleted Content added
-3.5
-4.3
 
(6 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
/// 2018-0709-1403 PerfektesChaos@de.wikipedia
// ResourceLoader: compatible;
// dependencies: --
Line 17:
( function ( mw, $ ) {
"use strict";
var Version = -34.53,
MW_LIB Signature = "citoidWikitext",
Sub = "core",
APICSites = { } = "|dewiki|",
BOOKAPIC = { },
DESCBOOK = { },
GUIPDESC = { btn: = { },
EDIT = { caretcodeMirror: { }false,
gadget wikEd: { false },
GUIP = { inputbtn: { },
push: { } caret: { },
I18N = gadget: { },
input: { },
push: { } },
HELP = { site: "w:en",
support: "user:PerfektesChaos/js/" + Signature },
I18N = { },
PREGO = { maxage: 604812,
signature: "preferencesGadgetOptions",
Line 37 ⟶ 42:
site: "w:en",
store: "User:PerfektesChaos/js/" },
PROJ = false,
TASK = { },
UTIL = { },
XPORT = { core: { sites: Sites } },
CITWT;
 
 
if ( typeof mw.libs[ MW_LIB ] !== "object" ||
! mw.libs[ MW_LIB ] ) {
mw.libs[ MW_LIB ] = { };
}
CITWT = mw.libs[ MW_LIB ];
if ( typeof CITWT.vsn === "string" ) {
CITWT.vsn = CITWT.vsn + " ";
} else {
CITWT.vsn = "";
}
CITWT.vsn = CITWT.vsn + "c:" + Version;
CITWT.type = MW_LIB;
UTIL.support = "user:PerfektesChaos/js/" + CITWT.type;
CITWT.support = "[[w:en:" + UTIL.support + "]]";
if ( typeof CITWT[ Sub ] !== "object" || ! CITWT[ Sub ] ) {
CITWT[ Sub ] = { };
}
CITWT.core.sites = "|dewiki|";
 
 
Line 67 ⟶ 53:
// Mark sub-module as ready
// Uses:
// > Signature
// > Sub
// > .typeVersion
// > XPORT
// < CITWT
// < .signature
// < .vsn
// < .type
// mw.loader.getState()
// mw.loader.state()
// mw.hook()
// 20162018-0108-0224 PerfektesChaos@de.wikipedia
var subsign = "/ext.gadget." + SubSignature,
signature;sub = "/" + Sub,
CITWT. signature = "ext.gadget."sign + CITWT.type;sub,
s = mw.loader.getState( signature ),
signature = CITWT.signature + sub;
e, o, rls;
if ( mw.loader.getState( signature ) !== "ready" ) {
if ( s mw.loader.state(!== signature,"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();
}
Line 1,058 ⟶ 1,082:
// > .vsn
// > GUIP.$panel
// > GUIP.$textarea
// < GUIP.live
// GUIP.input.free()
Line 1,192 ⟶ 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,264 ⟶ 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,305 ⟶ 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,408 ⟶ 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,428 ⟶ 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,437 ⟶ 1,468:
 
GUIP.caret.find = function () {
// Get selection in regular textarea, but perhaps CodeMirror
// Precondition:
// jquery.textSelection has been loaded
Line 1,443 ⟶ 1,474:
// selection assigned
// Uses:
// > CodeMirror
// > GUIP.$textarea
// > GUIP.caret.further
// >< EDIT.codeMirror
// < GUIP.caret.story
// < GUIP.caret.min
Line 1,451 ⟶ 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,474 ⟶ 1,522:
// Uses:
// this
// > GUIPEDIT.wikEd
// > wikEd
// > GUIP.$textarea
// < GUIP.caret.start
Line 1,485 ⟶ 1,532:
// < GUIP.caret.starter
// (GUIP.caret.wikEdEnclose)
// 20172018-0201-0621 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,504 ⟶ 1,555:
this.selection = this.story.substr( this.min );
this.starter = this.story.substr( 0, this.min );
windowEDIT.wikEd.UpdateFrame();
r = true;
}
Line 1,519 ⟶ 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,613 ⟶ 1,665:
// event -- jQuery event object
// Uses:
// > UTILHELP.support
// UTIL.fullstop()
// I18N.fair()
// mw.util.getUrl()
// Remark: Used as event handler -- 'this' is not GUIP.gadget
// 20172018-0607-1020 PerfektesChaos@de.wikipedia
var support = "https://" + I18N.fair( "helpSite", true )
+ ".wikipedia.org"
+ mw.util.getUrl( UTILHELP.support );
UTIL.fullstop( event );
window.open( support, "citWThelp" );
Line 2,086 ⟶ 2,138:
// mw.loader.state()
// REPOS.fire()
// 2018-0709-0603 PerfektesChaos@de.wikipedia
var ssign = "ext.gadget." + PREGO.signature;,
rls;
if ( ! mw.loader.getState( ssign ) ) {
mw.loader.state(rls s,= "loading"{ )};
rls[ sign ] = "loading";
mw.loader.state( rls );
REPOS.fire( PREGO.site,
PREGO.store + PREGO.signature + PREGO.sub,
Line 2,486 ⟶ 2,541:
// address -- URL to be used, else created from access
// Uses:
// > Version.suite
// >< REPOS.suitemaxage
// mw.loader.getState()
// mw.loader.state()
// mw.loader.load()
// REPOS.fire()
// 2018-0709-1403 PerfektesChaos@de.wikipedia
var p, rls;
if ( ! mw.loader.getState( assigned ) ) {
mw.loader.state(rls assigned,= "loading"{ )};
rls[ assigned ] = "loading";
mw.loader.state( rls );
if ( address ) {
mw.loader.load( address );
} else {
p = { bcache: 1 };
if ( typeof CITWT.suite !== "string" ) {
CITWT.suite = ( Version > 1 ? "r" : "d" );
}
p.maxage = ( CITWT.suite === "r" ? REPOS.maxage : 100 );
REPOS.fire( REPOS.site,
REPOS.store + assignedaccess + ".js",
false,
p );
Line 2,521 ⟶ 2,575:
// > .signature
// > .type
// > Version.suite
// >< .suite
// UTIL.feed()
// 2018-07-1428 PerfektesChaos@de.wikipedia
var sub = "/" + access;
if ( typeof CITWT.suite !== "string" ) {
CITWT.suite = "r";
}
UTIL.feed( CITWT.signature + sub,
CITWT.type + sub + "/" + CITWT.suite );
Line 2,604 ⟶ 2,654:
 
 
CITWTXPORT.core.fold = function ( analyse ) {
// Derive simple template parameters; not nested
// Precondition:
Line 2,650 ⟶ 2,700:
} // for i
return r;
}; // CITWTXPORT.core.fold()
 
 
Line 2,658 ⟶ 2,708:
 
 
CITWTXPORT.fire = function ( event ) {
// Tool button has been clicked
// Precondition:
Line 2,668 ⟶ 2,718:
// GUIP.factory()
// TASK.fiat()
// Remark: Used as event handler -- 'this' is not CITWTXPORT
// 2015-05-23 PerfektesChaos@de.wikipedia
UTIL.fullstop( event );
Line 2,677 ⟶ 2,727:
}
TASK.fiat();
}; // CITWTXPORT.fire()
 
 
Line 2,688 ⟶ 2,738:
// Start regular workflow in edit mode, if appropriate
// Uses:
// > CITWT
// > HELP.site
// > HELP.support
// > Version
// > .signature
// >< .core.loaded
// >< .bibRecord
// < .support
// < .core.site
// facilitated()
Line 2,701 ⟶ 2,754:
// mw.loader.using()
// (TASK.fire)
// 2018-07-1428 PerfektesChaos@de.wikipedia
var suitableenv, = "|edit|submit|"sub, suitable;
env, sub;
facilitated();
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 &&
Line 2,742 ⟶ 2,795:
fire();
}( window.mediaWiki, window.jQuery ) );
 
/// EOF </nowiki> citoidWikitext/core/d.js