Difference between revisions 137481 and 138373 on testwiki/// PerfektesChaos/js/WikisyntaxTextMod/?M.js /// 2012-06-1127 [email protected] /// Fingerprint: #0#0# /// <nowiki> // WikiSyntaxTextMod: Main functions, not initially loaded /* jshint curly:true, latedef:true, laxbreak:true, trailing:true, undef:true, white:false */ /* global jQuery: true, mw: true, mediaWiki: false */ /*jslint browser: true, plusplus: true, regexp: true, sloppy: true, unparam: true, vars: true, white: true, maxerr: 50 */ /*globals jQuery: true, mw: true, mediaWiki: false */ if (typeof(mediaWiki) !== "object") { // disconnected mw = { config: false, libs: { WikiSyntaxTextMod: {debugging: false} }, log: function () {} }; } if (typeof(mw.libs.WikiSyntaxTextMod) !== "object") { // isolated mw.libs.WikiSyntaxTextMod = {debugging: false}; } if (typeof(mw.libs.WikiSyntaxTextMod.main) !== "object") { mw.libs.WikiSyntaxTextMod.main = { }; } mw.libs.WikiSyntaxTextMod.main.vsn = -4.578; if (typeof(mw.libs.WikiSyntaxTextMod.bb) !== "object") { mw.libs.WikiSyntaxTextMod.bb = { }; } /* (contracted; show full) // > .config.diffPage // > WikisyntaxTextMod_Diffpage // >< .mod.lazy // .api.textMod() // .str.trimR() // .str.trimL() // .str.trim() // 2012-0 4-076-18 [email protected] var got = this.textMod(arglist.wikitext); var r = false; var seed; var sum; if (! got && WSTM.errors.collection) { got = [ arglist.wikitext, false ]; } if (got) { seed = false; sum = ""; r = { wikitext: got[0], minor: (got[1]⏎ ⏎ && WSTM.mod.lazy⏎ && ! WSTM.errors.collection), summary: false, diffpage: true}; if (typeof(WSTM.main.less) === "boolean") { r.minor = r.minor && WSTM.main.less; } if (typeof(arglist.summary) === "string") { sum = WSTM.str.trimR(arglist.summary, true); (contracted; show full) // auto -- true: automatic attempt // add -- additional information as found, or false // plain wikitext; will be HTML-escaped // Uses: // > .debugging // >< .errors.collection // mw.log() // 2012-0 3-255-01 [email protected] var err = [ alert, auto, add ]; if (this.collection) { this.collection.push(err); } else { this.collection = [ err ]; } if (WSTM.debugging) { mw.log(WSTM.debugging, ".errors.found()", 1, err); } }; // .errors.found() (contracted; show full) //----------------------------------------------------------------------- mw.libs.WikiSyntaxTextMod.bb.hooksM = function (WSTM) { // Hook functionality for registration // Uses: // .util.fiatObjects() // 2012-06-27 [email protected] WSTM.util.fiatObjects(WSTM, "hooks"); WSTM.hooks.finalize = function (apply) { // Register function for endrun, or execute // Precondition: // apply -- function for registration, or false for final run // Uses: // >< .hooks.endrun[] // 2012-06-27 [email protected] var i; if (apply) { if (this.endrun) { this.endrun.push(apply); } else { this.endrun = [ apply ]; } } else if (WSTM.hooks.endrun) { for (i = 0; i < this.endrun.length; i++) { this.endrun[i](); } } // for i }; // .hooks.finalize() }; // .bb.hooksM() mw.libs.WikiSyntaxTextMod.bb.hooksM(mw.libs.WikiSyntaxTextMod); delete mw.libs.WikiSyntaxTextMod.bb.hooksM; //-----------------------------------------------------------------------⏎ ⏎ ⏎ ⏎ mw.libs.WikiSyntaxTextMod.bb.l10nM = function (WSTM) { // Invariant localization functions // Uses: // .util.fiatObjects() // 2012-05-18 [email protected] WSTM.util.fiatObjects(WSTM, "l10n", { lang: { }, proj: { }, (contracted; show full) } else if (k === 3) { if (s === "doi") { r = s; } else if (this.s.re.c3.indexOf(s) >= 0) { r = false; } } else if (s === "simple") { // } else if (slang === "minnan") {⏎ // } else if (slang === "tokipona") { } else if (k > 5) { k = s.indexOf("-"); if (k === 2 || k === 3) { /* |bat-smg|be-x-old|cbk-zam|fiu-vro|map-bms|nds-nl |roa-rup|roa-tara|ru-sib |zh-classical|zh-min-nan|zh-yue| */ if (/^[a-z][a-z][a-z]?-[a-z][a-z][-a-z]*/.test(got)) { (contracted; show full)mw.libs.WikiSyntaxTextMod.bb.mainM = function (WSTM) { // Top level functions (internal) // 2012-05-26 [email protected] WSTM.main.maxMsg = 5; WSTM.main.fault = function (alert, about) { // Submit error message caused by user input // Precondition: // alert -- error message // about -- user context, or false to suppress // Uses: // > window // >< .main.maxMsg // .l10n.text.fetch() // 2012-05-26 [email protected] var s; if (window) { s = (about ? " " + about : ""); if (typeof(window.console) === "object") { window.console.info("PerfektesChaos::WikiSyntaxTextMod" + s + "\n" + alert); }⏎ }⏎ if (WSTM.main.maxMsg) { s = window.confirm(WSTM.l10n.text.fetch("ERROR") + ":\r\n" + alert + "\r\n" + "PerfektesChaos/js/WikiSyntaxTextMod" + s); if (s) { WSTM.main.maxMsg--; } else { WSTM.main.maxMsg = 0; } } }⏎ }⏎ }; // .main.fault() WSTM.main.full = function () { // Execute syntax and user defined replacement connecrelated to HTML page // Precondition: // Wikiserver environment for editpage with "editform" // Postcondition: // wpTextbox1 value of "editform" is modified, if appropriate. // If modified, DiffView is to be displayed to the user // // Postcondition: // wpTextbox1 value of "editform" is modified, if appropriate. // If modified, DiffView is to be displayed to the user // (if not suppressed by WikisyntaxTextMod_DiffPage). // Remark: Used as event handler -- 'this' is not WSTM.main // Uses: // > .ia.$editform // > .errors.story // > .debugging.live // .main.textarea() // .api.edit() // .errors.fill() // "editform" // < .wpSummary // > .wpDiff // 2012-03-23 [email protected] var button; var perform; var s; var stuff; var task; var $field; stuff = WSTM.main.textarea(false, false); if (typeof(stuff) === "string") { task = { wikitext: stuff, summary: false }; $field = WSTM.ia.$editform.find("#wpSummary"); if ($field.length) { task.summary = $field.val(); } else { $field = false; } perform = WSTM.api.edit(task); if (perform) { s = perform.wikitext; WSTM.errors.fill(); if (WSTM.errors.story) { s = WSTM.errors.story + s; } if (perform.diffpage) { if (typeof(WSTM.debugging) === "object") { if (typeof(WSTM.debugging.live) === "boolean") { perform.diffpage = ! WSTM.debugging.live; if (WSTM.debugging.live) { mw.log(WSTM.debugging, ".main.full() diffpage", 1); } } } } WSTM.main.textarea(s, perform.diffpage); if (perform.summary && $field) { $field.val(perform.summary); } if (perform.diffpage) { /* var $button = WSTM.ia.$editform.find("#wpDiff"); if ($button.length) { window.onbeforeunload = null; // stop editwarner $button.click(); } */ // DOM, not hooked by editwarner: button = document.getElementById("wpDiff"); if (button !== null) { button.click(); } } // human stupidity vs. artificial intelligence } // any change } // Textarea }; // .main.full() }; // .bb.mainM() mw.libs.WikiSyntaxTextMod.bb.mainM(mw.libs.WikiSyntaxTextMod); delete mw.libs.WikiSyntaxTextMod.bb.mainM; //----------------------------------------------------------------------- mw.libs.WikiSyntaxTextMod.bb.mod = function (WSTM) { // User modification request // 2012-04-07 [email protected] if (typeof(WSTM.mod) !== "object") { WSTM.mod = { "*": { comment: false, // <!-- --> file: false, // [[file:]] or gallery or .ext hyper: false, // config.mod.link lazy: true, // no visible change lenient: false, // config.mod.tested lock: false, // text replacement expected luxury: false, // any no-comment replacement plain: false, // any text outside protected tag: false, // tag context text: false, // no <poem> nor tag nor quote template: false, // {{any or [[template:any]] url: false, // //x.y wiki: false // [[any]] }, visible: false // Deprecated }; } WSTM.mod.furnish = function () { // (Re-)initialize user modification request // Postcondition: // Uses: // > Modif_Comment // > Modif_Link // > Modif_Text // > .config.mod // > .config.mod.* // >< .mod.* // < .mod.luxury // < .mod.lock // .util.isArray() // .w.link.replace.factory() // .w.template.mod.factory() // 2012-06-11 [email protected] var base = this["*"]; var hyperlinks = false; var p; for (p in base) { if (base.hasOwnProperty(p)) { this[p] = base[p]; } } // p in WSTM.mod.* if (typeof(Modif_Comment) === "object") { // Benutzer:Chemiewikibm if (WSTM.util.isArray(Modif_Comment)) { this.comment = { name: "Modif_Comment", raw: Modif_Comment }; } } if (typeof(Modif_Text) === "object") { if (WSTM.util.isArray(Modif_Text)) { this.plain = { name: "Modif_Text", raw: Modif_Text }; } } if (typeof(Modif_Link) === "object") { if (WSTM.util.isArray(Modif_Link)) { hyperlinks = { name: "Modif_Link", raw: Modif_Link }; } } if (WSTM.config && typeof(WSTM.config) === "object") { if (WSTM.config.mod && typeof(WSTM.config.mod) === "object") { if (typeof(WSTM.config.mod.tested) === "boolean") { this.lenient = WSTM.config.mod.tested; } if (WSTM.util.isArray(WSTM.config.mod.plain)) { this.plain = { name: ".config.mod.plain", raw: WSTM.config.mod.plain }; } if (WSTM.util.isArray(WSTM.config.mod.link)) { hyperlinks = { name: ".config.mod.link", raw: WSTM.config.mod.link }; } if (WSTM.util.isArray(WSTM.config.mod.comment)) { this.comment = { name: ".config.mod.comment", raw: WSTM.config.mod.comment }; }⏎ // Uses: // > .ia.$editform // > .errors.story // > .debugging.live // .main.textarea() // .api.edit() // .errors.fill() // "editform" // < .wpSummary // > .wpDiff // 2012-03-23 [email protected] var button; var perform; var s; var stuff; var task; var $field; stuff = WSTM.main.textarea(false, false); if (typeof(stuff) === "string") { task = { wikitext: stuff, summary: false }; $field = WSTM.ia.$editform.find("#wpSummary"); if ($field.length) { task.summary = $field.val(); } else { $field = false; } perform = WSTM.api.edit(task); if (perform) { s = perform.wikitext; WSTM.errors.fill(); if (WSTM.errors.story) { s = WSTM.errors.story + s; } if (perform.diffpage) { if (typeof(WSTM.debugging) === "object") { if (typeof(WSTM.debugging.live) === "boolean") { perform.diffpage = ! WSTM.debugging.live; if (WSTM.debugging.live) { mw.log(WSTM.debugging, ".main.full() diffpage", 1); } } } } WSTM.main.textarea(s, perform.diffpage); if (perform.summary && $field) { $field.val(perform.summary); } if (perform.diffpage) { /* var $button = WSTM.ia.$editform.find("#wpDiff"); if ($button.length) { window.onbeforeunload = null; // stop editwarner $button.click(); } */ // DOM, not hooked by editwarner: button = document.getElementById("wpDiff"); if (button !== null) { button.click(); } } // human stupidity vs. artificial intelligence } // any change } // Textarea }; // .main.full() }; // .bb.mainM() mw.libs.WikiSyntaxTextMod.bb.mainM(mw.libs.WikiSyntaxTextMod); delete mw.libs.WikiSyntaxTextMod.bb.mainM; //----------------------------------------------------------------------- mw.libs.WikiSyntaxTextMod.bb.mod = function (WSTM) { // User modification request // 2012-04-07 [email protected] if (typeof(WSTM.mod) !== "object") { WSTM.mod = { "*": { comment: false, // <!-- --> file: false, // [[file:]] or gallery or .ext hyper: false, // config.mod.link lazy: true, // no visible change lenient: false, // config.mod.tested lock: false, // text replacement expected luxury: false, // any no-comment replacement plain: false, // any text outside protected tag: false, // tag context text: false, // no <poem> nor tag nor quote template: false, // {{any or [[template:any]] url: false, // //x.y wiki: false // [[any]] }, visible: false // Deprecated }; } WSTM.mod.furnish = function () { // (Re-)initialize user modification request // Postcondition: // Uses: // > Modif_Comment // > Modif_Link // > Modif_Text // > .config.mod // > .config.mod.* // >< .mod.* // < .mod.luxury // < .mod.lock // .util.isArray() // .w.link.replace.factory() // .w.template.mod.factory() // 2012-06-27 [email protected] var base = this["*"]; var hyperlinks = false; var p; var urls = false; var wikilinks = false; for (p in base) { if (base.hasOwnProperty(p)) { this[p] = base[p]; } } // p in WSTM.mod.* if (typeof(Modif_Comment) === "object") { // User:Chemiewikibm if (WSTM.util.isArray(Modif_Comment)) { this.comment = { name: "Modif_Comment", raw: Modif_Comment }; } } if (typeof(Modif_Text) === "object") { if (WSTM.util.isArray(Modif_Text)) { this.plain = { name: "Modif_Text", raw: Modif_Text }; } } if (typeof(Modif_Link) === "object") { if (WSTM.util.isArray(Modif_Link)) { hyperlinks = { name: "Modif_Link", raw: Modif_Link }; } } if (WSTM.config && typeof(WSTM.config) === "object") { if (WSTM.config.mod && typeof(WSTM.config.mod) === "object") { if (typeof(WSTM.config.mod.tested) === "boolean") { this.lenient = WSTM.config.mod.tested; } if (WSTM.util.isArray(WSTM.config.mod.plain)) { this.plain = { name: ".config.mod.plain", raw: WSTM.config.mod.plain }; } if (WSTM.util.isArray(WSTM.config.mod.link)) { hyperlinks = { name: ".config.mod.link", raw: WSTM.config.mod.link }; } if (WSTM.util.isArray(WSTM.config.mod.url)) { urls = { name: ".config.mod.url", raw: WSTM.config.mod.url }; } if (WSTM.util.isArray(WSTM.config.mod.wikilink)) { wikilinks = { name: ".config.mod.wikilink", raw: WSTM.config.mod.wikilink }; } if (WSTM.util.isArray(WSTM.config.mod.comment)) { this.comment = { name: ".config.mod.comment", raw: WSTM.config.mod.comment }; }⏎ if (WSTM.config.mod.template) { if (WSTM.w.template.mod) { // WSTM.4 this.template = WSTM.w.template.mod.factory(WSTM.config.mod.template); } }⏎ } } } if (hyperlinks) { this.hyper = WSTM.w.link.replace.factory(hyperlinks); } if (this.plain) { this.lock = true; } this.luxury = (this.plain || this.hyper || this.template); this.lock = this.luxury;⏎ if (hyperlinks) { this.hyper = WSTM.w.link.replace.factory(hyperlinks); } if (urls) { this.url = WSTM.w.link.replace.factory(urls); if (this.hyper) { this.url = this.url.concat(this.hyper); } } if (wikilinks) { this.wikilink = WSTM.w.link.replace.factory(wikilinks); if (this.hyper) { this.wikilink = this.wikilink.concat.concat(this.hyper); } } if (this.plain) { this.lock = true; } this.luxury = (this.plain || this.template); this.lock = this.luxury;⏎ }; // .mod.furnish() }; // .bb.mod() mw.libs.WikiSyntaxTextMod.bb.mod(mw.libs.WikiSyntaxTextMod); delete mw.libs.WikiSyntaxTextMod.bb.mod; // Start on import: callback to waiting ... if (typeof(mw.libs.WikiSyntaxTextMod.main.wait) === "function") { mw.libs.WikiSyntaxTextMod.main.wait("M", mw.libs.WikiSyntaxTextMod.main.vsn); } delete mw.libs.WikiSyntaxTextMod.main.vsn; // Emacs // Local Variables: // encoding: iso-8859-1-dos // fill-column: 80 // End: /// EOF </nowiki> WikiSyntaxTextMod/?M.js All content in the above text box is licensed under the Creative Commons Attribution-ShareAlike license Version 4 and was originally sourced from https://test.wikipedia.org/w/index.php?diff=prev&oldid=138373.
![]() ![]() This site is not affiliated with or endorsed in any way by the Wikimedia Foundation or any of its affiliates. In fact, we fucking despise them.
|