Content deleted Content added
-3.6 |
-4.3 |
||
(5 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-
// ResourceLoader: compatible;
// dependencies: --
Line 17:
( function ( mw, $ ) {
"use strict";
var Version = -
Sub = "core",
GUIP = { btn:
I18N = {
PREGO = {
REPOS = {
TASK = { },
UTIL = { },
XPORT = { core: { sites: Sites } },
CITWT;
Line 69 ⟶ 53:
// Mark sub-module as ready
// Uses:
// > Signature
// > Sub
// >
// > XPORT
// < CITWT
// < .signature
// < .vsn
// < .type
// mw.loader.getState()
// mw.loader.state()
// mw.hook()
//
var
s = mw.loader.getState( signature ),
e, o, rls;
if ( s
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,193 ⟶ 1,215:
// GUIP.btn.portlet()
// (GUIP.btn.wikiEditor)
//
if ( ! this.wikEd() ) {
if ( GUIP.opts.usebetatoolbar ) {
GUIP.submit = "wikiEditor ... (loading)";
mw.loader.using( [ "ext.wikiEditor
this.wikiEditor );
} else if ( GUIP.opts.showtoolbar ) {
Line 1,265 ⟶ 1,287:
// > GUIP.btn.show
// < GUIP.submit
// <
// mw.user.options.get()
// GUIP.file()
//
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: { } };
}
if ( typeof
EDIT.wikEd.config = { button: { },
buttonBar: { } };
}
cnf =
if ( typeof cnf.button !== "object" ) {
cnf.button = { };
Line 1,306 ⟶ 1,330:
}
cnf.buttonBar.custom1[ 6 ].push( id );
if ( typeof
typeof EDIT.wikEd.turnedOn === "boolean" &&
typeof EDIT.wikEd.useWikEd === "boolean"
&& EDIT.wikEd.useWikEd ) {
GUIP.submit = "wikEd";
}
}
return GUIP.submit;
Line 1,409 ⟶ 1,435:
// > GUIP.caret.max
// > GUIP.$textarea
// > EDIT.codeMirror
// > EDIT.wikEd
// Remark: Used as event handler -- 'this' is not GUIP.caret
//
var shift, start, story;
if ( GUIP.caret.max >= 0 ) {
Line 1,429 ⟶ 1,457:
story = start + shift + story;
GUIP.$textarea.val( story );
if (
} else if ( alien === "wikEd" ) {
EDIT.wikEd.UpdateFrame();
}
}
Line 1,438 ⟶ 1,468:
GUIP.caret.find = function () {
// Get selection in regular textarea, but perhaps CodeMirror
// Precondition:
// jquery.textSelection has been loaded
Line 1,444 ⟶ 1,474:
// selection assigned
// Uses:
// > CodeMirror
// > GUIP.$textarea
// > GUIP.caret.further
// >< EDIT.codeMirror
// < GUIP.caret.story
// < GUIP.caret.min
Line 1,452 ⟶ 1,484:
// < GUIP.caret.starter
// Remark: Used as event handler -- 'this' is not GUIP.caret
//
var rg, uo;
if ( ! EDIT.codeMirror &&
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,475 ⟶ 1,522:
// Uses:
// this
// >
// > GUIP.$textarea
// < GUIP.caret.start
Line 1,486 ⟶ 1,532:
// < GUIP.caret.starter
// (GUIP.caret.wikEdEnclose)
//
var r;
if (
! 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#";
r = GUIP.$textarea.val();
this.min = r.search( this.start );
Line 1,505 ⟶ 1,555:
this.selection = this.story.substr( this.min );
this.starter = this.story.substr( 0, this.min );
r = true;
}
Line 1,520 ⟶ 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
//
if ( assign.selection.plain === "" ) {
assign.sel =
if ( assign.sel.anchorNode.previousSibling ) {
assign.changed = assign.cursor;
} else {
assign.changed = assign.whole;
}
Line 2,087 ⟶ 2,138:
// mw.loader.state()
// REPOS.fire()
// 2018-
var
rls;
if ( ! mw.loader.getState( rls[ sign ] = "loading";
mw.loader.state( rls );
REPOS.fire( PREGO.site,
PREGO.store + PREGO.signature + PREGO.sub,
Line 2,487 ⟶ 2,541:
// address -- URL to be used, else created from access
// Uses:
// >
// >
// mw.loader.getState()
// mw.loader.state()
// mw.loader.load()
// REPOS.fire()
// 2018-
var p, rls;
if ( ! mw.loader.getState( assigned ) ) {
rls[ assigned ] = "loading";
mw.loader.state( rls );
if ( address ) {
mw.loader.load( address );
} else {
p = { bcache: 1 };
p.maxage = ( CITWT.suite === "r" ? REPOS.maxage : 100 );
REPOS.fire( REPOS.site,
Line 2,522 ⟶ 2,575:
// > .signature
// > .type
// >
// UTIL.feed()
// 2018-07-
var sub = "/" + access;
UTIL.feed( CITWT.signature + sub,
CITWT.type + sub + "/" + CITWT.suite );
Line 2,605 ⟶ 2,654:
// Derive simple template parameters; not nested
// Precondition:
Line 2,651 ⟶ 2,700:
} // for i
return r;
}; //
Line 2,659 ⟶ 2,708:
// Tool button has been clicked
// Precondition:
Line 2,669 ⟶ 2,718:
// GUIP.factory()
// TASK.fiat()
// Remark: Used as event handler -- 'this' is not
// 2015-05-23 PerfektesChaos@de.wikipedia
UTIL.fullstop( event );
Line 2,678 ⟶ 2,727:
}
TASK.fiat();
}; //
Line 2,689 ⟶ 2,738:
// Start regular workflow in edit mode, if appropriate
// Uses:
// > CITWT
// > HELP.site
// > HELP.support
// > Version
// > .signature
// >< .bibRecord
// < .support
// < .core.site
// facilitated()
Line 2,702 ⟶ 2,754:
// mw.loader.using()
// (TASK.fire)
// 2018-07-
var
facilitated();
if (
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,743 ⟶ 2,795:
fire();
}( window.mediaWiki, window.jQuery ) );
/// EOF </nowiki> citoidWikitext/core/d.js
|