Difference between revisions of "User:Wottem/wikEd.js"

From Wazeopedia
(Created page with "// _________________________________________________________________________________________ // |...")
 
Line 1: Line 1:
// _________________________________________________________________________________________
+
// <syntaxhighlight lang="JavaScript">
// |                                                                                        |
+
 
// |                    === WARNING: GLOBAL GADGET FILE ===                                 |
+
// JSHint options
// |                  Changes to this page affect many users.                               |
+
/* jshint -W004, -W100, newcap: false, browser: true, jquery: true, sub: true, bitwise: true, curly: true, evil: true, forin: true, freeze: true, globalstrict: true, immed: true, latedef: true, loopfunc: true, quotmark: single, strict: true, undef: true */
// | Please discuss changes on the talk page or on [[Wikipedia_talk:Gadget]] before editing. |
+
/* global GM_getValue, GM_setValue, GM_xmlhttpRequest, console */
// |_________________________________________________________________________________________|
+
 
 +
// turn on ECMAScript 5 strict mode
 +
'use strict';
 +
 
 +
// define global object
 +
var wikEd; if (wikEd === undefined) { wikEd = {}; }
 +
 
 +
wikEd.Meta = function () {/*
 +
// ==UserScript==
 +
// @name        wikEd
 +
// @version    0.9.148
 +
// @date        March 20, 2017
 +
// @namespace  https://en.wikipedia.org/wiki/User:Cacycle/
 +
// @description A full-featured in-browser editor for Wikipedia and other MediaWikis
 +
// @include    *
 +
// @homepage    https://en.wikipedia.org/wiki/User:Cacycle/wikEd
 +
// @source      https://en.wikipedia.org/wiki/User:Cacycle/wikEd.js
 +
// @author      Cacycle (https://en.wikipedia.org/wiki/User:Cacycle)
 +
// @license    Released into the public domain
 +
// @grant      GM_getValue
 +
// @grant      GM_xmlhttpRequest
 +
// ==/UserScript==
 +
 
 +
wikEd is a full-featured edit page text editor for regular to advanced users on Wikipedia and other MediaWikis.
 +
wikEd features syntax highlighting, reference, template, and code folding,
 +
on-page Show preview and Show changes, and advanced search and replace functions.
 +
wikEd works under all web browsers except Internet Explorer.
 +
This code has to be saved as UTF-8 in your editor to preserve Unicode characters like ♥ (heart symbol).
 +
 
 +
*/};
 +
 
 +
// define global objects
 +
var wikEdConfig;
 +
var wikEdText;
 +
var WED;
 +
var WikEdDiff;
 +
 
 +
//
 +
// start of user configurable variables
 +
//
 +
 
 +
//
 +
// wikEd.InitGlobalsConfigs: initialize user configurable variables
 +
//
 +
 
 +
wikEd.InitGlobalConfigs = function () {
 +
 
 +
// user readable texts, copy changes to https://en.wikipedia.org/wiki/User:Cacycle/wikEd_international_en.js, also defined in wikEdDiff.js
 +
if (wikEd.config.text === undefined) { wikEd.config.text = {}; }
 +
 
 +
// wikEd.InitText: define built-in user interface texts
 +
wikEd.InitText = function () {
 +
wikEd.InitObject(wikEd.config.text, {
 +
 
 +
// logo
 +
'wikEdLogo alt':              'wikEd',
 +
'wikEdLogo title':            'wikEd {wikEdProgramVersion} ({wikEdProgramDate}) Click to disable',
 +
'wikEdLogo error alt':        'wikEd error',
 +
'wikEdLogo error title':      'Loading error - wikEd {wikEdProgramVersion} ({wikEdProgramDate}) Click to disable',
 +
'wikEdLogo browser alt':      '(wikEd)',
 +
'wikEdLogo browser title':    'Browser not supported - wikEd {wikEdProgramVersion} ({wikEdProgramDate})',
 +
'wikEdLogo incompatible alt':  '(wikEd)',
 +
'wikEdLogo incompatible title': 'Incompatible script, gadget, or add-on: {wikEdParameter} - wikEd {wikEdProgramVersion} ({wikEdProgramDate})',
 +
'wikEdLogo disabled alt':      '(wikEd)',
 +
'wikEdLogo disabled title':    'Disabled - wikEd {wikEdProgramVersion} ({wikEdProgramDate}) Click to enable',
 +
'wikEdLogo testVersion alt':  'wikEd_dev',
 +
'wikEdLogo testVersion title': 'wikEd_dev (unstable test version) {wikEdProgramVersion} ({wikEdProgramDate}) Click to disable',
 +
 
 +
// top jumper
 +
'wikEdScrollToEdit4 alt':      'Scroll to edit',
 +
'wikEdScrollToEdit4 title':    'Scroll to edit field',
 +
 
 +
// button bar grip titles
 +
'wikEdGripFormat title':      'Formatting buttons (click to hide or show)',
 +
'wikEdGripTextify title':      'Textify and wikify buttons (click to hide or show)',
 +
'wikEdGripCustom1 title':      'Custom buttons (click to hide or show)',
 +
'wikEdGripFind title':        'Find buttons (click to hide or show)',
 +
'wikEdGripFix title':          'Fixing buttons (click to hide or show)',
 +
'wikEdGripCustom2 title':      'Custom buttons (click to hide or show)',
 +
'wikEdGripControl title':      'wikEd control buttons (click to hide or show)',
 +
 
 +
// button bar background titles
 +
'wikEdBarFormat title':        '',
 +
'wikEdBarTextify title':      '',
 +
'wikEdBarCustom1 title':      '',
 +
'wikEdBarFind title':          '',
 +
'wikEdBarFix title':          '',
 +
'wikEdBarCustom2 title':      '',
 +
'wikEdBarControl title':      'wikEd {wikEdProgramVersion} ({wikEdProgramDate})',
 +
'wikEdBarPreview title':      '',
 +
'wikEdBarPreview2 title':      '',
 +
'wikEdBarJump title':          '',
 +
'wikEdBarPasted title':        '',
 +
 
 +
// formatting buttons, top row
 +
'wikEdUndo alt':              'Undo',
 +
'wikEdUndo title':            'Undo',
 +
'wikEdRedo alt':              'Redo',
 +
'wikEdRedo title':            'Redo',
 +
'wikEdBold alt':              'Bold',
 +
'wikEdBold title':            'Bold text',
 +
'wikEdItalic alt':            'Italic',
 +
'wikEdItalic title':          'Italic text',
 +
'wikEdUnderline alt':          'Underline',
 +
'wikEdUnderline title':        'Underline text',
 +
'wikEdStrikethrough alt':      'Strikethrough',
 +
'wikEdStrikethrough title':    'Strikethrough text',
 +
'wikEdNowiki alt':            'Nowiki',
 +
'wikEdNowiki title':          'Nowiki markup text',
 +
'wikEdSuperscript alt':        'Superscript',
 +
'wikEdSuperscript title':      'Superscript text',
 +
'wikEdSubscript alt':          'Subscript',
 +
'wikEdSubscript title':        'Subscript text',
 +
'wikEdRef alt':                'Ref',
 +
'wikEdRef title':              'In-text reference (shift-click: named tag)',
 +
'wikEdCase alt':              'Case',
 +
'wikEdCase title':            'Toggle between lowercase, uppercase first, and uppercase',
 +
'wikEdSort alt':              'Sort',
 +
'wikEdSort title':            'Sort alphabetically',
 +
'wikEdRedirect alt':          'Redirect',
 +
'wikEdRedirect title':        'Create redirect, deletes whole text',
 +
'wikEdUndoAll alt':            'Undo all',
 +
'wikEdUndoAll title':          'Undo all changes',
 +
'wikEdRedoAll alt':            'Redo all',
 +
'wikEdRedoAll title':          'Redo all changes',
 +
 
 +
// formatting buttons, bottom row
 +
'wikEdWikiLink alt':          'Link',
 +
'wikEdWikiLink title':        'Wiki link',
 +
'wikEdWebLink alt':            'Weblink',
 +
'wikEdWebLink title':          'External weblink',
 +
'wikEdHeading alt':            'Heading',
 +
'wikEdHeading title':          'Increase heading levels (shift-click: decrease)',
 +
'wikEdBulletList alt':        'Bullet list',
 +
'wikEdBulletList title':      'Increase bulleted list level (shift-click: decrease)',
 +
'wikEdNumberList alt':        'Number list',
 +
'wikEdNumberList title':      'Increase numbered list level (shift-click: decrease)',
 +
'wikEdIndentList alt':        'Indent list',
 +
'wikEdIndentList title':      'Increase indention (shift-click: decrease)',
 +
'wikEdDefinitionList alt':    'Def list',
 +
'wikEdDefinitionList title':  'Definition list',
 +
'wikEdImage alt':              'Image',
 +
'wikEdImage title':            'Image',
 +
'wikEdTable alt':              'Table',
 +
'wikEdTable title':            'Table',
 +
'wikEdReferences alt':        'References',
 +
'wikEdReferences title':      'References location (shift-click: references section)',
 +
'wikEdSign alt':              'Signature',
 +
'wikEdSign title':            'Signature ~~~~ (shift-click: name only ~~~)',
 +
 
 +
// textify buttons
 +
'wikEdWikify alt':            'Wikify',
 +
'wikEdWikify title':          'Convert pasted content to wiki code, update highlighting',
 +
'wikEdTextify alt':            'Textify',
 +
'wikEdTextify title':          'Convert pasted content to plain text, update highlighting (shift-click: forced highlighting)',
 +
'wikEdPastedWikify alt':      'Wikify pasted',
 +
'wikEdPastedWikify title':    'Convert pasted content to wiki code',
 +
'wikEdPastedTextify alt':      'Textify pasted',
 +
'wikEdPastedTextify title':    'Convert pasted content to plain text',
 +
'wikEdPastedClose alt':        'x',
 +
'wikEdPastedClose title':      'Close',
 +
 
 +
// find and replace buttons, top row
 +
'wikEdFindAll alt':            'Find all',
 +
'wikEdFindAll title':          'Find all matches',
 +
'wikEdFindPrev alt':          'Find prev',
 +
'wikEdFindPrev title':        'Find previous match',
 +
'wikEdFindSelect title':      'Select a previous search or jump to a heading',
 +
'wikEdFindNext alt':          'Find next',
 +
'wikEdFindNext title':        'Find next match (shift-click: get selection)',
 +
'wikEdJumpPrev alt':          'Selected prev',
 +
'wikEdJumpPrev title':        'Find the selected text backwards',
 +
'wikEdJumpNext alt':          'Selected next',
 +
'wikEdJumpNext title':        'Find the selected text forwards',
 +
 
 +
// find and replace buttons, bottom row
 +
'wikEdReplaceAll alt':        'Replace all',
 +
'wikEdReplaceAll title':      'Replace all matches in whole text or selection',
 +
'wikEdReplacePrev alt':        'Replace prev',
 +
'wikEdReplacePrev title':      'Replace previous match',
 +
'wikEdReplaceSelect title':    'Select a previous replacement',
 +
'wikEdReplaceNext alt':        'Replace next (shift-click: get selection)',
 +
'wikEdReplaceNext title':      'Replace next match',
 +
'wikEdCaseSensitive alt':      'Case sensitive',
 +
'wikEdCaseSensitive title':    'Search is case sensitive',
 +
'wikEdRegExp alt':            'RegExp',
 +
'wikEdRegExp title':          'Search field is a regular expression',
 +
'wikEdFindAhead alt':          'Find ahead',
 +
'wikEdFindAhead title':        'Find ahead as you type (case-insensitive non-regexp search)',
 +
 
 +
// fix buttons, top row
 +
'wikEdFixBasic alt':          'Fix basic',
 +
'wikEdFixBasic title':        'Fix blanks and empty lines, also done by other fixing functions',
 +
'wikEdFixHtml alt':            'Fix html',
 +
'wikEdFixHtml title':          'Fix html to wikicode',
 +
'wikEdFixCaps alt':            'Fix caps',
 +
'wikEdFixCaps title':          'Fix caps in headers and lists',
 +
'wikEdFixUnicode alt':        'Fix Unicode',
 +
'wikEdFixUnicode title':      'Fix Unicode character representations',
 +
'wikEdFixAll alt':            'Fix all',
 +
'wikEdFixAll title':          'Fix basic, html, capitalization, and Unicode',
 +
'wikEdFixRedirect alt':        'Fix redirects',
 +
'wikEdFixRedirect title':      'Fix redirects',
 +
 
 +
// fix buttons, bottom row
 +
'wikEdFixDashes alt':          'Fix dashes',
 +
'wikEdFixDashes title':        'Fix dashes',
 +
'wikEdFixPunct alt':          'Fix punctuation',
 +
'wikEdFixPunct title':        'Fix spaces before punctuation',
 +
'wikEdFixMath alt':            'Fix math',
 +
'wikEdFixMath title':          'Fix math',
 +
'wikEdFixChem alt':            'Fix chem',
 +
'wikEdFixChem title':          'Fix chemical formulas',
 +
'wikEdFixUnits alt':          'Fix units',
 +
'wikEdFixUnits title':        'Fix units',
 +
'wikEdFixRegExTypo alt':      'Fix typos',
 +
'wikEdFixRegExTypo title':    'Fix typos using the AutoWikiBrowser RegExTypoFixer rules',
 +
 
 +
// wikEd control buttons, top row
 +
'wikEdRefHide alt':            '[REF, TEMPL]',
 +
'wikEdRefHide title':          'Simple view: hide refs, templates, and table code',
 +
'wikEdRefButtonTooltip':      'Click to display hidden reference',
 +
'wikEdTemplButtonTooltip':    'Click to display hidden template',
 +
'wikEdCharEntityButtonTooltip': 'Click to display hidden character entity',
 +
'wikEdTableButtonTooltip':    'Click to display hidden table code',
 +
'wikEdRefButtonShowTooltip':  'Click to hide reference',
 +
'wikEdTemplButtonShowTooltip': 'Click to hide template',
 +
'wikEdCharEntityButtonShowTooltip': 'Click to hide character entity',
 +
'wikEdTableButtonShowTooltip': 'Click to hide table code',
 +
'wikEdTextZoom alt':          'Text zoom',
 +
'wikEdTextZoom title':        'Text zoom cycling (shift-click: reverse)',
 +
'wikEdClearHistory alt':      'Clear history',
 +
'wikEdClearHistory title':    'Clear the find, replace, and summary history',
 +
'wikEdScrollToPreview alt':    'Scroll to preview',
 +
'wikEdScrollToPreview title':  'Scroll to preview field',
 +
'wikEdScrollToEdit alt':      'Scroll to edit',
 +
'wikEdScrollToEdit title':    'Scroll to edit field',
 +
 
 +
// wikEd control buttons, bottom row
 +
'wikEdUseWikEd alt':          'Use wikEd',
 +
'wikEdUseWikEd title':        'Use wikEd instead of classic text area',
 +
'wikEdHighlightSyntax alt':    'Syntax',
 +
'wikEdHighlightSyntax title':  'Syntax highlighting',
 +
'wikEdSource alt':            'Source',
 +
'wikEdCloseToolbar title':    'Close the standard non-wikEd toolbar',
 +
'wikEdCloseToolbar alt':      'Close toolbar',
 +
'wikEdSource title':          'Show the source code for testing',
 +
'wikEdUsing alt':              'Using',
 +
'wikEdUsing title':            'Automatically add \'\'…using wikEd\'\' to summaries',
 +
'wikEdFullScreen alt':        'Fullscreen',
 +
'wikEdFullScreen title':      'Fullscreen mode',
 +
'wikEdTableMode alt':          'Table as tables',
 +
'wikEdTableMode title':        'Edit tables as tables',
 +
 
 +
// summary buttons
 +
'wikEdClearSummary alt':      'Clear summary',
 +
'wikEdClearSummary title':    'Clear the summary field',
 +
'wikEdSummarySelect title':    'Select a previous summary',
 +
'wikEdPresetSummary': [
 +
'/*  */ ', 'copyedit', 'reply', 'article created', 'intro rewrite',
 +
'linkfix', 'fixing typos', 'removing linkspam', 'reverting test',
 +
'reverting vandalism', 'formatting source text', '{wikEdUsing}'
 +
],
 +
'wikEdSummaryUsing':          '…using [[en:User:Cacycle/wikEd|wikEd]]',
 +
 
 +
// toolbar
 +
'wikEdCodeEditorButtonDisabled': ' (disabled by wikEd)',
 +
 
 +
// button title acceskey
 +
'alt-shift':                  'alt-shift-',
 +
 
 +
// submit buttons
 +
'wikEdLocalPreviewImg alt':    'Preview below',
 +
'wikEdLocalPreview title':    'Show preview below',
 +
'wikEdLocalDiffImg alt':      'Changes below',
 +
'wikEdLocalDiff title':        'Show current changes below',
 +
'wikEdHelpPageLink':          ' | <a href="{wikEdHomeBaseUrl}wiki/User:Cacycle/wikEd_help" target="helpwindow">wikEd help</a>', // use full link without {wikEdHomeBaseUrl} if the page is not on the English Wikipedia
 +
 
 +
// preview and changes buttons, top
 +
'wikEdClose alt':              'Close',
 +
'wikEdClose title':            'Close preview box',
 +
'wikEdClose2 alt':            'Close',
 +
'wikEdClose2 title':          'Close preview box',
 +
'wikEdScrollToPreview2 alt':  'Scroll to preview',
 +
'wikEdScrollToPreview2 title': 'Scroll to preview field',
 +
'wikEdScrollToEdit2 alt':      'Scroll to edit',
 +
'wikEdScrollToEdit2 title':    'Scroll to edit field',
 +
 
 +
// preview and changes buttons, bottom
 +
'wikEdScrollToPreview3 alt':  'Scroll to preview',
 +
'wikEdScrollToPreview3 title': 'Scroll to preview field',
 +
'wikEdScrollToEdit3 alt':      'Scroll to edit',
 +
'wikEdScrollToEdit3 title':    'Scroll to edit field',
 +
 
 +
// preview field
 +
'wikEdPreviewLoading':        '...',
 +
'diffNotLoaded':              'Error: Local diff script not installed.',
 +
 
 +
// formatting functions
 +
'image filename':              'filename',
 +
'image width':                'width',
 +
'table caption':              'caption',
 +
'table heading':              'heading',
 +
'table cell':                  'cell',
 +
'redirect article link':      'article link',
 +
 
 +
// fixing functions
 +
'External links':              'External links',
 +
'See also':                    'See also',
 +
'References':                  'References',
 +
 
 +
// language specific wiki code
 +
'wikicode Image':              'Image',
 +
'wikicode File':              'File',
 +
'wikicode Media':              'Media',
 +
'wikicode Category':          'Category',
 +
'wikicode Template':          'Template',
 +
'wikEdReferencesSection':      '\n== References ==\n\n<references />\n',
 +
'talk page':                  'talk',
 +
'history page':                'history',
 +
'talk namespace':              'Talk',
 +
'talk namespace suffix':      '$1_talk', // '$1_talk', '_talk', or 'talk_'
 +
 
 +
// hiding buttons, type
 +
'hideRef':                    'REF',
 +
'hideTempl':                  'TEMPL',
 +
'hideTable':                  '',
 +
 
 +
// hiding buttons, details
 +
'hideTableStart':              'Table',
 +
'hideTableEnd':                'Table end',
 +
'hideTableCaption':            'Caption',
 +
'hideTableRow':                'Row',
 +
'hideTableHeader':            'Header',
 +
'hideTableCell':              'Cell',
 +
 
 +
// shortened button texts
 +
'shortenedPreview':            'Preview',
 +
'shortenedChanges':            'Changes',
 +
 
 +
// link popup
 +
'followLink':                  '(ctrl-click)',
 +
'followLinkMac':              '(cmd-click)',
 +
'redirect':                    ', redirect to:',
 +
'redlink':                    ' (page does not exist)',
 +
 
 +
// auto updating
 +
'wikEdGreasemonkeyAutoUpdate': 'wikEd Update:\n\nA new version of the Greasemonkey script "wikEd" is available.\n\n\nIt will be installed from:\n\n{updateURL}',
 +
'wikEdGreasemonkeyAutoUpdateBugfix': 'Important wikEd Bugfix:\n\nA bugfix for the Greasemonkey script "wikEd" is available.\n\n\nIt will be installed from:\n\n{updateURL}',
 +
 
 +
// highlighting popups
 +
'hyphenDash':                  'Standard hyphen',
 +
'figureDash':                  'Figure dash',
 +
'enDash':                      'En dash',
 +
'emDash':                      'Em dash',
 +
'barDash':                    'Horizontal bar',
 +
'minusDash':                  'Minus sign',
 +
'softHyphen':                  'Soft hyphen',
 +
'tab':                        'Tab',
 +
'enSpace':                    'En space',
 +
'emSpace':                    'Em space',
 +
'thinSpace':                  'Thin space',
 +
'ideographicSpace':            'Ideographic space',
 +
 
 +
// highlighting
 +
'wikEdSignature3':            'Sign with username only',
 +
'wikEdSignature4':            'Sign with user name and date',
 +
'wikEdSignature5':            'Sign with date only',
 +
 
 +
// highlighting errors
 +
'wikEdErrorHtmlUnknown':      'Unsupported HTML tag',
 +
'wikEdErrorBoldItalic':        'Invalid bold / italic',
 +
'wikEdErrorWrongClose':        'Close tag does not match',
 +
'wikEdErrorNoOpen':            'Close tag has no match',
 +
'wikEdErrorNoHandler':        'No handler',
 +
'wikEdErrorNoClose':          'Open tag has no match',
 +
'wikEdErrorNewline':          'Open tag closed by new line',
 +
'wikEdErrorTemplHeading':      'Headings in templates are ignored',
 +
'wikEdErrorTemplParam':        'Template/parameter tags do not match',
 +
'wikEdErrorTemplParamAmbig':  'Template/parameter tags are ambiguous',
 +
'wikEdErrorCodeInLinkName':    'Wikicode in link name',
 +
'wikEdErrorCodeInTemplName':  'Wikicode in template name',
 +
'wikEdErrorCodeInParamName':  'Wikicode in template parameter name',
 +
 
 +
// highlighting image preview
 +
'wikEdFilePreview':            'Image preview',
 +
 
 +
// location search string functions
 +
'iconPage':                    'All icons and images used by wikEd. Save page as <i>web page, complete</i> to download all files into one folder.<br><br>',
 +
 
 +
// duplicated message
 +
'clonedWarningsNote':          'Duplicated edit warnings (wikEd):'
 +
 
 +
}, wikEd.config.showMissingTranslations);
 +
};
 +
 
 +
// define built-in user interface texts
 +
wikEd.InitText();
 +
 
 +
// use local copies of images for testing (set to true in local copy of edit page), also defined in wikEdDiff.js
 +
if (wikEd.config.useLocalImages === undefined) { wikEd.config.useLocalImages = false; }
 +
 
 +
// path to local wikEd images for testing, also defined in wikEdDiff.js
 +
if (wikEd.config.imagePathLocal === undefined) { wikEd.config.imagePathLocal = 'file:///D:/wikEd/images/'; }
 +
 
 +
// path to wikEd images, also defined in wikEdDiff.js
 +
if (wikEd.config.imagePath === undefined) { wikEd.config.imagePath = '//upload.wikimedia.org/wikipedia/commons/'; }
 +
 
 +
// wikEd image filenames, also defined in wikEdDiff.js
 +
if (wikEd.config.image === undefined) { wikEd.config.image = {}; }
 +
 
 +
// wikEd.InitImages: define built-in image URLs
 +
wikEd.InitImages = function () {
 +
 
 +
wikEd.InitImage(wikEd.config.image, {
 +
'barDash':            '5/52/WikEd_bar_dash.png',
 +
'bold':                '5/59/WikEd_bold.png',
 +
'browser':            '0/07/WikEd_disabled.png',
 +
'bulletList':          '6/62/WikEd_bullet_list.png',
 +
'case':                'a/aa/WikEd_case.png',
 +
'caseSensitive':      '0/0d/WikEd_case_sensitive.png',
 +
'clearHistory':        'c/c8/WikEd_clear_history.png',
 +
'clearSummary':        '2/2c/WikEd_clear_summary.png',
 +
'close':              '9/97/WikEd_close.png',
 +
'closePasted':        'b/bc/WikEd_close_pasted.png',
 +
'closeToolbar':        '1/1d/WikEd_close_toolbar.png',
 +
'ctrl':                '1/10/WikEd_ctrl.png',
 +
'definitionList':      'f/f5/WikEd_definition_list.png',
 +
'diff':                'd/db/WikEd_diff.png',
 +
'disabled':            '0/07/WikEd_disabled.png',
 +
'dummy':              'c/c5/WikEd_dummy.png',
 +
'emDash':              '5/58/WikEd_em_dash.png',
 +
'emSpace':            '3/3a/WikEd_em_space.png',
 +
'enDash':              'f/fc/WikEd_en_dash.png',
 +
'enSpace':            '0/04/WikEd_en_space.png',
 +
'error':              '3/3e/WikEd_error.png',
 +
'figureDash':          '2/25/WikEd_figure_dash.png',
 +
'findAhead':          '3/34/WikEd_find_ahead.png',
 +
'findAll':            '7/75/WikEd_find_all.png',
 +
'findNext':            'a/ad/WikEd_find_next.png',
 +
'findPrev':            'f/f5/WikEd_find_prev.png',
 +
'fixAll':              '8/86/WikEd_fix_all.png',
 +
'fixBasic':            '3/30/WikEd_fix_basic.png',
 +
'fixCaps':            '0/00/WikEd_fix_caps.png',
 +
'fixUnicode':          'd/d4/WikEd_fix_unicode.png',
 +
'fixRedirect':        'f/f8/WikEd_fix_redirect.png',
 +
'fixChem':            'e/e7/WikEd_fix_chem.png',
 +
'fixDash':            'e/e5/WikEd_fix_dash.png',
 +
'fixHtml':            '0/05/WikEd_fix_html.png',
 +
'fixMath':            '3/3f/WikEd_fix_math.png',
 +
'fixPunct':            'd/db/WikEd_fix_punct.png',
 +
'fixRegExTypo':        '9/94/WikEd_fix_reg-ex-typo.png',
 +
'fixUnits':            '6/69/WikEd_fix_units.png',
 +
'textZoom':            '7/71/WikEd_font_size.png',
 +
'fullScreen':          'd/d3/WikEd_fullscreen.png',
 +
'getFind':            '9/96/WikEd_get_selection.png',
 +
'grip':                'a/ad/WikEd_grip.png',
 +
'gripHidden':          'a/a8/WikEd_grip_hidden.png',
 +
'heading':            '0/07/WikEd_heading.png',
 +
'highlightSyntax':    '6/67/WikEd_syntax.png',
 +
'ideographicSpace':    'c/c6/WikEd_ideographic_space.png',
 +
'image':              '3/37/WikEd_image.png',
 +
'incompatible':        '3/3e/WikEd_error.png',
 +
'indentList':          '7/7a/WikEd_indent_list.png',
 +
'italic':              'd/d4/WikEd_italic.png',
 +
'jumpNext':            '5/54/WikEd_jump_next.png',
 +
'logo':                '6/67/WikEd_logo.png',
 +
'minusDash':          'b/ba/WikEd_minus_dash.png',
 +
'noFile':              '8/88/WikEd_no_file.png',
 +
'nowiki':              '5/5a/WikEd_nowiki.png',
 +
'numberList':          '3/3b/WikEd_number_list.png',
 +
'jumpPrev':            'c/c7/WikEd_jump_prev.png',
 +
'preview':            '3/31/WikEd_preview.png',
 +
'redirect':            'f/fa/WikEd_redirect.png',
 +
'redo':                'd/d7/WikEd_redo.png',
 +
'ref':                'b/ba/WikEd_ref.png',
 +
'refHide':            '0/0b/WikEd_ref_hide.png',
 +
'references':          '6/66/WikEd_references.png',
 +
'sign':                'd/d5/WikEd_sign.png',
 +
'redoAll':            '2/2d/WikEd_redo_all.png',
 +
'resizeGrip':          'e/e1/WikEd_resize_grip.png',
 +
'regExp':              '6/6a/WikEd_regexp.png',
 +
'replaceAll':          '2/2a/WikEd_replace_all.png',
 +
'replaceNext':        'b/b0/WikEd_replace_next.png',
 +
'replacePrev':        'a/a1/WikEd_replace_prev.png',
 +
'scrollToEdit':        '1/13/WikEd_align_top.png',
 +
'scrollToPreview':    '3/37/WikEd_align_preview.png',
 +
'scrollToEditDown':    'a/a8/WikEd_align_down.png',
 +
'scrollToPreviewDown': '5/58/WikEd_align_preview_down.png',
 +
'softHyphen':          'c/c7/WikEd_soft_hyphen.png',
 +
'sort':                '7/7c/WikEd_sort.png',
 +
'source':              '0/02/WikEd_source.png',
 +
'strikethrough':      '0/06/WikEd_strikethrough.png',
 +
'subscript':          '9/9e/WikEd_subscript.png',
 +
'superscript':        'b/bf/WikEd_superscript.png',
 +
'tab':                'e/e7/WikEd_tab.png',
 +
'table':              'b/bd/WikEd_table.png',
 +
'tableMode':          'e/ee/WikEd_table_edit.png',
 +
'testVersion':        '3/3e/WikEd_error.png',
 +
'textify':            'c/cd/WikEd_textify.png',
 +
'thinSpace':          '5/56/WikEd_thin_space.png',
 +
'underline':          '2/21/WikEd_underline.png',
 +
'undo':                'e/e6/WikEd_undo.png',
 +
'undoAll':            '0/08/WikEd_undo_all.png',
 +
'unknown':            '8/8a/WikEd_unknown.png',
 +
'useWikEd':            '6/67/WikEd_logo.png',
 +
'using':              'e/e0/WikEd_using.png',
 +
'webLink':            '1/16/WikEd_weblink.png',
 +
'wikify':              '9/9f/WikEd_wikify.png',
 +
'wikiLink':            '2/21/WikEd_wikilink.png'
 +
});
 +
};
 +
 
 +
// edit-frame css rules
 +
if (wikEd.config.frameCSS === undefined) { wikEd.config.frameCSS = {}; }
 +
 
 +
// wikEd.InitFrameCSS: define built-in edit frame css
 +
wikEd.InitFrameCSS = function () {
 +
wikEd.InitObject(wikEd.config.frameCSS, {
 +
 
 +
// frame
 +
'.wikEdFrameHtml':      'height: 100%; width: 100%; padding: 0; margin: 0; background: transparent; background-image: url({wikEdImage:resizeGrip}); background-attachment: fixed; background-position: right bottom; background-repeat: no-repeat; line-height: normal;',
 +
'.wikEdFrameBodyPlain': 'height: auto; min-height: 100%; width: auto; background: transparent; margin: 0; padding: 0; padding-left: 0.25em; overflow: auto; font-family: monospace;',
 +
'.wikEdFrameBodySyntax': 'height: auto; min-height: 100%; width: auto; background: transparent; margin: 0; padding: 0; padding-left: 0.25em; overflow: auto; font-family: monospace;',
 +
'.wikEdFrameBodyNewbie': 'height: auto; min-height: 100%; width: auto; background: transparent; margin: 0; padding: 0; padding-left: 0.25em; overflow: auto; font-family: monospace;',
 +
 
 +
// reselection / scroll to selection
 +
'.wikEdScrollLineHeight': 'position: absolute;',
 +
 
 +
// syntax highlighting
 +
'.wikEdError':          'background-image: url({wikEdImage:unknown}); color: black; font-weight: normal; font-style: normal; text-decoration: none;',
 +
'.wikEdHighlightError': 'color: black; background: #faa;',
 +
 
 +
'.wikEdHtml':          'background: #e8e8e8;',
 +
'.wikEdHtmlTag':        'color: #777;',
 +
'.wikEdHtmlTagButtons': 'color: #777;',
 +
'.wikEdHtmlUnknown':    'background-image: url({wikEdImage:unknown}); color: black; font-weight: normal; font-style: normal;',
 +
'.wikEdParsingNote':    'border: 1px outset #fcc; padding: 0 0.5em 0 0.5em; margin: 0 0.25em 0 0.25em;  color: black; background: #fcc; font-weight: normal; font-size: smaller; font-style: normal; text-decoration: none; font-family: sans-serif;',
 +
 
 +
'.wikEdSubscript':      'position: relative; top: 0.3em;',
 +
'.wikEdSuperscript':    'position: relative; top: -0.3em;',
 +
'.wikEdBold':          'font-weight: bold;',
 +
'.wikEdItalic':        'font-style: italic;',
 +
 
 +
'.wikEdComment':        'background: #fff0d0; color: black; font-weight: normal; font-style: normal; text-decoration: none;',
 +
'.wikEdKeep':          '',
 +
'.wikEdDel':            'text-decoration: line-through;',
 +
'.wikEdIns':            'text-decoration: underline;',
 +
 
 +
'.wikEdPre':            'background: #f8e8e0;',
 +
'.wikEdMath':          'background: #e8f0ff;',
 +
'.wikEdScore':          'background: #fff8e0;',
 +
'.wikEdNowiki':        'background: #f8e8e8;',
 +
 
 +
// horizontal rule
 +
'.wikEdHr':            'background: #666; color: #ffffff;',
 +
 
 +
// wiki code
 +
'.wikEdWiki':          'color: #777;',
 +
'.wikEdRedir':          'color: #c00; font-weight: bold;',
 +
'.wikEdSignature':      'color: #f00; font-weight: bold;',
 +
'.wikEdMagic':          'color: #666; font-weight: bold; background: #e8e8e8;',
 +
'.wikEdParserFunct':    'color: #f00;',
 +
 
 +
// headings
 +
'.wikEdFrameBodySyntax .wikEdHeading':  'color: #000; font-weight: bold;',
 +
'.wikEdFrameBodySyntax .wikEdHeadingWP': 'color: #000; font-weight: bold; background: #e8e8e8;',
 +
'.wikEdFrameBodyNewbie .wikEdHeading':  'color: #000; font-weight: bold; color: #000; background: #eee; padding: 0 0.25em; border: 1px solid #ddd; font-size: larger; line-height: 1.5;',
 +
'.wikEdFrameBodyNewbie .wikEdHeadingWP': 'color: #000; font-weight: bold; color: #000; background: #ddd; padding: 0 0.25em; border: 1px solid #ccc; font-size: larger; line-height: 1.5;',
 +
 
 +
// tables
 +
'.wikEdTableBlock':    '',
 +
 
 +
'.wikEdTableCode':      'color: #888; background: #ccc;',
 +
'.wikEdTableTag':      'background: #ccc;',
 +
'.wikEdTableCaption':  'color: #000; background: #fff;',
 +
'.wikEdTableRow':      'color: #000; background: #ccc;',
 +
'.wikEdTableHeader':    'color: #000; background: #e8e8e8;',
 +
'.wikEdTableCell':      'color: #000; background: #f0f0f0;',
 +
 
 +
'.wikEdFrameBodyNewbie .wikEdTableCode': 'color: #888; background: transparent;',
 +
'.wikEdFrameBodyNewbie .wikEdTableTag,    .wikEdFrameBodyNewbie .wikEdTableTagBR':    'background: #d8d8d8;',
 +
'.wikEdFrameBodyNewbie .wikEdTableCaption, .wikEdFrameBodyNewbie .wikEdTableCaptionBR': 'color: #000; background: #fff;',
 +
'.wikEdFrameBodyNewbie .wikEdTableRow,    .wikEdFrameBodyNewbie .wikEdTableRowBR':    'color: #000; background: #d8d8d8;',
 +
'.wikEdFrameBodyNewbie .wikEdTableHeader,  .wikEdFrameBodyNewbie .wikEdTableHeaderBR':  'color: #000; background: #f2f2f2;',
 +
'.wikEdFrameBodyNewbie .wikEdTableCell,    .wikEdFrameBodyNewbie .wikEdTableCellBR':    'color: #000; background: #fbfbfb;',
 +
 
 +
'br.wikEdTableBR':      'display: none;',
 +
'.wikEdTableTagAttrib .wikEdTableCode, .wikEdTableCaptionAttrib .wikEdTableCode, .wikEdTableRowAttrib .wikEdTableCode, .wikEdTableHeaderAttrib .wikEdTableCode, .wikEdTableCellAttrib .wikEdTableCode':
 +
'background: transparent;',
 +
'.wikEdTableTagAttrib, .wikEdTableRowAttrib': 'color: #666;',
 +
'.wikEdTableCaptionAttrib, .wikEdTableHeaderAttrib, .wikEdTableCellAttrib': 'color: #888;',
 +
 
 +
'table.wikEdTableMode': 'border: 1px solid #aaa; background: #d8d8d8; color: #000; border-collapse: separate; border-spacing: 0.25em 2px; margin: 0.5em 0;',
 +
'td.wikEdTableCaption, td.wikEdTableHeader, td.wikEdTableCell, td.wikEdTableCaptionBR, td.wikEdTableHeaderBR, td.wikEdTableCellBR': 'border: 1px solid #aaa;',
 +
'td.wikEdTableTag, td.wikEdTableRow, td.wikEdTableTagBR, td.wikEdTableRowBR': 'border: none; border-spacing: 0;',
 +
 
 +
// list
 +
'.wikEdList':          'color: #000; background: #e8e8e8;',
 +
'.wikEdListTag':        'font-weight: bold; font-family: monospace; vertical-align: text-bottom;',
 +
 
 +
// space-pre
 +
'.wikEdSpace':          'color: #000; background: #e8e8e8;',
 +
'.wikEdSpaceTag':      'background: #e8e8e8;',
 +
 
 +
// links
 +
'.wikEdLinkTag':        'color: #777;',
 +
 
 +
// wiki links
 +
'.wikEdLink':          'color: #00a;',
 +
'.wikEdLinkCrossNs':    'background: #ddd; color: #00a;',
 +
'.wikEdLinkInter':      'background: #ddd;',
 +
'.wikEdLinkNs':        'background: #ddd;',
 +
'.wikEdLinkName':      'font-weight: bold;',
 +
'.wikEdLinkTarget':    '',
 +
'.wikEdLinkText':      'font-weight: bold;',
 +
 
 +
'.wikEdPMID':          'color: #00e;',
 +
'.wikEdISBN':          'color: #00e;',
 +
'.wikEdLinkInter span': 'font-weight: normal;',
 +
'span.wikEdLinkText:hover': 'text-decoration: underline;',
 +
'span.wikEdLinkName:hover': 'text-decoration: underline;',
 +
'span.wikEdPMID:hover': 'text-decoration: underline;',
 +
'span.wikEdISBN:hover': 'text-decoration: underline;',
 +
 
 +
// external links
 +
'.wikEdURL':            '',
 +
'.wikEdURLName':        'color: #00e; font-weight: bold;',
 +
'.wikEdURLTarget':      'color: #00e;',
 +
'.wikEdURLText':        'color: #00e; font-weight: bold;',
 +
'span.wikEdURLName:hover': 'text-decoration: underline;',
 +
'span.wikEdURLText:hover': 'text-decoration: underline;',
 +
 
 +
// files
 +
'.wikEdFile':          'background: rgb(213, 255, 176); background: rgba(199, 255, 149, 0.75); color: #00e;',
 +
'.wikEdFrameBodyNewbie .wikEdFile':
 +
'background: rgb(213, 255, 176); padding: 0.25em; margin-right: 0.25em; display: inline-block; border: 1px solid #082; margin: 1px;',
 +
'.wikEdFileTag':        'color: #444;',
 +
'.wikEdFileName':      '',
 +
'.wikEdFileParam':      'color: #666;',
 +
'.wikEdFileCaption':    'color: #000;',
 +
'.wikEdFilePreview':    'border: 1px solid #c0ffa0; background: rgb(192, 192, 192) no-repeat 50% 50%; background: rgba(192, 192, 192, 0.75); position: absolute; right: 0; margin: 0.1em 0.25em; z-index: -1; border: none; padding: 1px; display: block;',
 +
'.wikEdFrameBodyNewbie .wikEdFilePreview':
 +
'position: static; float: right; clear: both; background: transparent; padding: 0; ',
 +
 
 +
// categories
 +
'.wikEdCat':            'background: #ccc; color: #00e;',
 +
'.wikEdCatName':        '',
 +
'.wikEdCat .wikEdLinkInter': 'color: #000; background: #aaa;',
 +
'.wikEdCat .wikEdLinkNs': 'color: #000; background: #ccc;',
 +
'.wikEdCat .wikEdLinkText': 'color: #000; font-weight: normal;',
 +
'.wikEdCat span.wikEdLinkText:hover': 'text-decoration: none;',
 +
 
 +
// refs
 +
'.wikEdFrameBodySyntax .wikEdRefContainer': 'display: block; position: fixed; left: -10000em;',
 +
 
 +
'.wikEdRefContainer':  'position: relative;',
 +
'.wikEdRefContainer button': 'padding: 0.1em; position: relative;',
 +
 
 +
'.wikEdRefButton':      'border: 1px solid; border-color: #e8e8e8 #444 #444 #e8e8e8; background: #d8d4d0;',
 +
'.wikEdRefButtonShow':  'border: 1px solid; border-color: #000 #e8e8e8 #e8e8e8 #000; background: #c8c4c0;',
 +
'.wikEdRef, .wikEdRefShow': 'background: #e8e8e8; color: #666;',
 +
 
 +
'.wikEdReferences':    'background: #eee;',
 +
'.wikEdReferencesTag':  'color: #444;',
 +
'.wikEdFrameBodyNewbie .wikEdReferences':
 +
'background: #eee; padding: 0.25em; display: inline-block; border: 1px solid black; vertical-align: middle;',
 +
'.wikEdRefList':        'background: #eee;',
 +
'.wikEdFrameBodyNewbie .wikEdRefList':
 +
'background: #e8e8e8; padding: 0.25em; display: inline-block; border: 1px solid black; vertical-align: middle;',
 +
'.wikEdRefName':        'color: #000;',
 +
 
 +
// templates
 +
'.wikEdFrameBodySyntax .wikEdTemplContainer':  'display: block; position: fixed; left: -10000em;',
 +
'.wikEdTemplContainer':  'position: relative;',
 +
'.wikEdTemplContainer button': 'padding: 0.1em; position: relative;',
 +
'.wikEdTemplButton':    'border: 1px solid; border-color: #e8e8e8 #444 #444 #e8e8e8; background: #d8d4d0;',
 +
'.wikEdTemplButtonShow': 'border: 1px solid; border-color: #000 #e8e8e8 #e8e8e8 #000; background: #c8c4c0;',
 +
 
 +
'.wikEdTempl, .wikEdTemplShow': 'background: #e8e8e8; color: #509;',
 +
'.wikEdTemplNs, .wikEdTemplNsShow': 'background: #ccc;',
 +
 
 +
'.wikEdTemplTag':      'color: #777;',
 +
'.wikEdTemplName':      '',
 +
'.wikEdTemplParam':    'color: #666;',
 +
'.wikEdTemplMod':      'color: #f00; font-weight: bold;',
 +
 
 +
'.wikEdParam':          'background: #e8e8e8;',
 +
'.wikEdParamName':      'color: #900;',
 +
'.wikEdParamDefault':  'color: #000;',
 +
 
 +
// missing article for links, cats, refs, and templates
 +
'.wikEdRedlink':        'color: #c00;',
 +
 
 +
// character entities
 +
'.wikEdFrameBodySyntax .wikEdCharEntityContainer':  'display: block; position: fixed; left: -10000em;',
 +
'.wikEdCharEntityContainer': 'position: relative; right: -0.25em;',
 +
'.wikEdCharEntityContainer button':
 +
'padding: 0; color: #000; font-weight: normal; font-family: monospace; position: relative; right: 0.25em; line-height: 0.75em;',
 +
'.wikEdCharEntityButton':
 +
'border: 1px solid; border-color: #e8e8e8 #444 #444 #e8e8e8; background: #d8d4d0; border-color: rgba(255, 255, 255, 0.75) rgba(64, 64, 64, 0.5) rgba(64, 64, 64, 0.5) rgba(255, 255, 255, 0.75); background: rgba(192, 192, 192, 0.3);',
 +
'.wikEdCharEntityButtonShow':
 +
'border: 1px solid; border-color: #000 #e8e8e8 #e8e8e8 #000; background: #c8c4c0; border-color: rgba(64, 64, 64, 0.5) rgba(255, 255, 255, 0.75) rgba(255, 255, 255, 0.75) rgba(64, 64, 64, 0.5); background: rgba(192, 192, 192, 0.3);',
 +
'.wikEdCharEntity, .wikEdCharEntityShow':
 +
'color: #000; background: #e8e8e8;',
 +
 
 +
// tables
 +
'.wikEdFrameBodySyntax .wikEdTableContainer':  'display: block; position: fixed; left: -10000em;',
 +
'.wikEdTableContainer': 'position: relative;',
 +
'.wikEdTableContainer button':
 +
'padding: 0.1em; position: relative; vertical-align: top;',
 +
'.wikEdTableButton':    'border: 1px solid; border-color: #e8e8e8 #444 #444 #e8e8e8; background: #d8d4d0;',
 +
'.wikEdTableButtonShow':
 +
'border: 1px solid; border-color: #000 #e8e8e8 #e8e8e8 #000; background: #c8c4c0;',
 +
'.wikEdTable, .wikEdTableShow': '',
 +
'.wikEdTableButton:before, .wikEdTableButtonShow:before':
 +
'line-height: 0.75em; font-size: 65%; color: #000; font-family: sans-serif;',
 +
 
 +
// links in references and templates
 +
'.wikEdFrameBodySyntax .wikEdRef .wikEdURLName,  .wikEdFrameBodySyntax .wikEdTempl .wikEdURLName,  .wikEdFrameBodySyntax .wikEdRef .wikEdURLTarget,  .wikEdFrameBodySyntax .wikEdTempl .wikEdURLTarget,  .wikEdFrameBodySyntax .wikEdRef .wikEdURLText,  .wikEdFrameBodySyntax .wikEdTempl .wikEdURLText':  'color: #66f; font-weight: normal;',
 +
'.wikEdFrameBodySyntax .wikEdRef .wikEdLinkName, .wikEdFrameBodySyntax .wikEdTempl .wikEdLinkName, .wikEdFrameBodySyntax .wikEdRef .wikEdLinkTarget, .wikEdFrameBodySyntax .wikEdTempl .wikEdLinkTarget, .wikEdFrameBodySyntax .wikEdRef .wikEdLinkText, .wikEdFrameBodySyntax .wikEdTempl .wikEdLinkText': 'color: #66f; font-weight: normal;',
 +
 
 +
// wikEdFrameBodyNewbie ref and template hiding
 +
'.wikEdFrameBodyNewbie .wikEdRefContainer + .wikEdRef, .wikEdFrameBodyNewbie .wikEdTemplContainer + .wikEdTempl, .wikEdFrameBodyNewbie .wikEdTemplContainer + .wikEdTemplNs':
 +
'position: fixed; left: -10000em;',
 +
'.wikEdFrameBodyNewbie .wikEdRefContainer + .wikEdRefShow, .wikEdFrameBodyNewbie .wikEdTemplContainer + .wikEdTemplShow, .wikEdFrameBodyNewbie .wikEdTemplContainer + .wikEdTemplNsShow':
 +
'display: block; position: relative; color: #000; background: #f8f8f8; font-weight: normal; border: 1px solid; border-color: #444 #ccc #ccc #444; padding: 0.5em 0.25em;',
 +
'.wikEdFrameBodyNewbie .wikEdRefButton:before, .wikEdFrameBodyNewbie .wikEdTemplButton:before, .wikEdFrameBodyNewbie .wikEdTableButton:before, .wikEdFrameBodyNewbie .wikEdRefButtonShow:before, .wikEdFrameBodyNewbie .wikEdTemplButtonShow:before, .wikEdFrameBodyNewbie .wikEdTableButtonShow:before':
 +
'line-height: 0.75em; font-size: 65%; color: #000; font-family: sans-serif;',
 +
'.wikEdRefButton:before, .wikEdTemplButton:before, .wikEdRefButtonShow:before, .wikEdTemplButtonShow:before':
 +
'line-height: 0.75em; font-size: 65%; color: #000; font-family: sans-serif;',
 +
'.wikEdFrameBodyNewbie .wikEdRefButton:before, .wikEdFrameBodyNewbie .wikEdRefButtonShow:before':
 +
'content: "{wikEdText:hideRef}"',
 +
'.wikEdFrameBodyNewbie .wikEdTemplButton:before, .wikEdFrameBodyNewbie .wikEdTemplButtonShow:before':
 +
'content: "{wikEdText:hideTempl}";',
 +
 
 +
// wikEdFrameBodyNewbie char entity hiding
 +
'.wikEdFrameBodyNewbie .wikEdCharEntity':
 +
'position: fixed; left: -10000em;',
 +
'.wikEdFrameBodyNewbie .wikEdCharEntityShow':
 +
'display: inline; position: relative; color: #000; background: #f8f8f8; border: 1px solid; font-weight: normal; background: rgba(192, 192, 192, 0.3); border: 1px inset;',
 +
'.wikEdCharEntityButton:before, .wikEdCharEntityButtonShow:before':
 +
'',
 +
 
 +
// wikEdFrameBodyNewbie table hiding
 +
'.wikEdFrameBodyNewbie .wikEdTableContainer + .wikEdTable':
 +
'position: fixed; left: -10000em;',
 +
'.wikEdFrameBodyNewbie .wikEdTableContainer + .wikEdTableShow':
 +
'display: inline-block; position: relative; color: #000; font-weight: normal; background: rgba(255, 255, 255, 0.2); border: 1px inset;',
 +
'.wikEdFrameBodyNewbie .wikEdTableButton:before, .wikEdFrameBodyNewbie .wikEdTableButtonShow:before':
 +
'content: "{wikEdText:hideTable}";',
 +
 
 +
// insert wikicode here
 +
'.wikEdInsertHere':    'background: orange; font-style: italic;',
 +
 
 +
// colors
 +
'.wikEdColorsLight':    'color: black;',
 +
'.wikEdColorsDark':    'color: white;',
 +
 
 +
// dashes
 +
'.wikEdFigureDash':    'background-image: url({wikEdImage:figureDash}); background-position: top right; background-repeat: no-repeat;',
 +
'.wikEdEmDash':        'background-image: url({wikEdImage:emDash}); background-position: top left; background-repeat: no-repeat;',
 +
'.wikEdEnDash':        'background-image: url({wikEdImage:enDash}); background-position: top left; background-repeat: no-repeat;',
 +
'.wikEdBarDash':        'background-image: url({wikEdImage:barDash}); background-position: top left; background-repeat: no-repeat;',
 +
'.wikEdMinusDash':      'background-image: url({wikEdImage:minusDash}); background-position: top left; background-repeat: no-repeat;',
 +
'.wikEdSoftHyphen':    'background-image: url({wikEdImage:softHyphen}); background-position: top left; background-repeat: no-repeat;',
 +
'.wikEdSoftHyphen:before': 'content: \'\xa0\'',
 +
'.wikEdHyphenDash':    '',
 +
 
 +
// dashes, invisibles, control chars, and strange spaces
 +
'.wikEdTab':            'white-space: pre; background-image: url({wikEdImage:tab}); background-position: bottom right; background-repeat: no-repeat;',
 +
'.wikEdTabPlain':      'white-space: pre;',
 +
'.wikEdCtrl':          'white-space: pre; background-image: url({wikEdImage:ctrl}); background-position: center center; background-repeat: no-repeat; margin: 0 1px;',
 +
'.wikEdCtrl:before':    'content: \'\xa0\'',
 +
 
 +
'.wikEdEmSpace':        'background-image: url({wikEdImage:emSpace}); background-position: bottom left; background-repeat: no-repeat; margin: 0 1px; padding: 0 3px;',
 +
'.wikEdEnSpace':        'background-image: url({wikEdImage:enSpace}); background-position: bottom left; background-repeat: no-repeat; margin: 0 1px; padding: 0 3px;',
 +
'.wikEdThinSpace':      'background-image: url({wikEdImage:thinSpace}); background-position: bottom left; background-repeat: no-repeat; margin: 0 1px; padding: 0 3px;',
 +
'.wikEdIdeographicSpace': 'background-image: url({wikEdImage:ideographicSpace}); background-position: bottom left; background-repeat: no-repeat; margin: 0 1px; padding: 0 3px;'
 +
});
 +
};
 +
 
 +
// main window css rules
 +
if (wikEd.config.mainCSS === undefined) { wikEd.config.mainCSS = {}; }
 +
 
 +
// wikEd.InitMainCSS: define built-in main window css
 +
wikEd.InitMainCSS = function () {
 +
wikEd.InitObject(wikEd.config.mainCSS, {
 +
 
 +
// logo
 +
'.wikEdLogoList':              'list-style-type: none;',
 +
'.wikEdLogo':                  'margin-left: 0.5em;',
 +
'.wikEdLogoFallBack':          'margin: 0.25em 0 0.25em 0.5em; float: right;'
 +
});
 +
};
 +
 
 +
// main window css rules for edit pages only
 +
if (wikEd.config.mainEditCSS === undefined) { wikEd.config.mainEditCSS = {}; }
 +
 
 +
// wikEd.InitMainEditCSS: define built-in main window css for edit pages only
 +
wikEd.InitMainEditCSS = function () {
 +
wikEd.InitObject(wikEd.config.mainEditCSS, {
 +
 
 +
// combo input box
 +
'.wikEdCombo':                '',
 +
 
 +
// wikEd button areas
 +
 
 +
// button bar margins
 +
'.wikEdButtonBarFormat':      'margin: 0 8px 3px 1px; float: left;',
 +
'.wikEdButtonBarTextify':      'margin: 0 8px 3px 1px; float: left;',
 +
'.wikEdButtonBarCustom1':      'margin: 0 8px 3px 1px; float: left;',
 +
'.wikEdButtonBarFind':        'margin: 0 8px 3px 1px; float: left;',
 +
'.wikEdButtonBarFix':          'margin: 0 8px 3px 1px; float: left;',
 +
'.wikEdButtonBarCustom2':      'margin: 0 8px 3px 1px; float: left;',
 +
'.wikEdButtonBarControl':      'margin: 0 1px 3px 0; float: right;',
 +
'.wikEdButtonBarPreview':      'margin: 0.4em 0.75em 0 0; float: right;',
 +
'.wikEdButtonBarPreviewFull':  'margin: -0.2em 0 0 0.6em; float: right;',
 +
'.wikEdButtonBarPreview2':    'margin: 0.2em 0 0.4em 0; float: right;',
 +
'.wikEdButtonBarJump':        'margin: 0 0 0 0.6em; float: right;',
 +
'.wikEdButtonBarPasted':      'position: absolute;',
 +
 
 +
// button bar inner wrapper: border
 +
'.wikEdButtonBarInnerWrapperVisible': '',
 +
'.wikEdButtonBarInnerWrapperHidden': '',
 +
 
 +
// button bar grip wrapper
 +
'.wikEdButtonBarGripWrapperVisible': 'float: left; border: 1px solid; border-color: #e4e0dc #c4c0bc #c4c0bc #e4e0dc;',
 +
'.wikEdButtonBarGripWrapperHidden': 'float: left; border: 1px solid; border-color: #e4e0dc #c4c0bc #c4c0bc #e4e0dc;',
 +
 
 +
// button bar buttons wrapper
 +
'.wikEdButtonBarButtonsWrapperVisible, .wikEdButtonBarButtonsWrapperHidden': 'float: left; background: #d4d0cc; border: 1px solid; border-color: #e4e0dc #c4c0bc #c4c0bc #e4e0dc; background: #d4d0cc; z-index: 4;',
 +
 
 +
// button bar grip
 +
'.wikEdButtonBarGrip':        'background: #d4d0cc; cursor: pointer; background-repeat: no-repeat; background-position: center;',
 +
'.wikEdButtonBarGripWrapperVisible .wikEdButtonBarGrip': 'background-image: url({wikEdImage:grip});',
 +
'.wikEdButtonBarGripWrapperHidden  .wikEdButtonBarGrip': 'background-image: url({wikEdImage:gripHidden});',
 +
 
 +
// button bar buttons
 +
'.wikEdButtonsFormat':        'padding: 2px 2px 0 0px;',
 +
'.wikEdButtonsTextify':        'padding: 2px 2px 0 0px;',
 +
'.wikEdButtonsCustom1':        'padding: 2px 2px 0 0px;',
 +
'.wikEdButtonsFind':          'padding: 2px 2px 0 0px;',
 +
'.wikEdButtonsFix':            'padding: 2px 2px 0 0px;',
 +
'.wikEdButtonsCustom2':        'padding: 2px 2px 0 0px;',
 +
'.wikEdButtonsControl':        'padding: 2px 2px 0 1px;',
 +
'.wikEdButtonsPasted':        'padding: 2px; border: 1px solid; border-color: #e0e0e0 #808080 #808080 #e0e0e0; background: rgba(212, 208, 204, 0.6);',
 +
'.wikEdButtonsPasted:hover':  'background-color: #e4e0dc;',
 +
'.wikEdButtonsPasted img':    'border-color: rgba(0, 0, 0, 0) !important; background-color: rgba(0, 0, 0, 0);',
 +
'.wikEdButtonsPasted img:hover': 'background-color: #e4e0dc;',
 +
'.wikEdButtonsPreview':        'padding: 2px; border: 1px solid; border-color: #e0e0e0 #808080 #808080 #e0e0e0; background: #d4d0cc;',
 +
'.wikEdButtonsPreviewFull':    'padding: 2px; border: 1px solid; border-color: #e0e0e0 #808080 #808080 #e0e0e0; background: #d4d0cc;',
 +
'.wikEdButtonsPreview2':      'padding: 2px; border: 1px solid; border-color: #e0e0e0 #808080 #808080 #e0e0e0; background: #d4d0cc;',
 +
'.wikEdButtonsJump':          'border: 1px solid; border-color: #e0e0e0 #808080 #808080 #e0e0e0; background: #d4d0cc;',
 +
 
 +
// wikEd buttons (!important for devmo skin)
 +
'.wikEdButton':                'vertical-align: text-top; font-size: small; text-decoration: underline; margin: 1px 2px; padding: 0; background: #d4d0cc; border: 1px #d4d0cc solid !important; cursor: pointer;',
 +
'.wikEdButton:hover':          'background: #e4e0dc; border: 1px outset !important; cursor: pointer;',
 +
'.wikEdButton:active':        'background: #e4e0dc; border: 1px inset !important;  cursor: pointer;',
 +
'.wikEdButtonSolo':            'display: block; font-size: small; text-decoration: underline; padding: 0.2em; background: #d4d0cc; border: 1px #d4d0cc solid !important; cursor: pointer;',
 +
'.wikEdButtonSolo:hover':      'background: #e4e0dc; border: 1px outset !important; cursor: pointer;',
 +
'.wikEdButtonChecked':        'vertical-align: text-top; font-size: small; text-decoration: none; margin: 1px 2px; padding: 0; background: #ccc8c3; border: 1px solid !important; border-color: black white white black !important; cursor: pointer;',
 +
'.wikEdButtonUnchecked':      'vertical-align: text-top; font-size: small; text-decoration: none; margin: 1px 2px; padding: 0; background: #ddd8d3; border: 1px solid !important; border-color: white black black white !important; cursor: pointer;',
 +
'.wikEdButtonPressed':        'vertical-align: text-top; font-size: small; text-decoration: none; margin: 1px 2px; padding: 0; background: #ccc8c3; border: 1px solid !important; border-color: black white white black !important; cursor: wait;',
 +
'.wikEdButtonInactive':        'vertical-align: text-top; font-size: small; text-decoration: underline; margin: 1px 2px; padding: 0; background: rgba(160, 160, 160, 0.5) !important; border: 1px #b0b0b0 solid !important; cursor: not-allowed',
 +
'.wikEdLocalPreview':          'vertical-align: top; margin: 0 0.33em 0 0.15em; padding: 0;',
 +
'.wikEdLocalDiff':            'vertical-align: top; margin: 0 0.33em 0 0.15em; padding: 0;',
 +
'input#wpDiff, input#wpPreview': 'margin-right: 0;', // monobook fix
 +
'.wikEdButtonDummy':          'vertical-align: text-top; margin: 1px 2px; padding: 1px; background: #d4d0cc;',
 +
 
 +
// preview box
 +
'.wikEdPreviewArticle':        'margin: 0.75em 0 0.2em; padding: 0.5em; border: 1px solid #c0c0c0; background: #faf8f6;',
 +
'.wikEdPreviewDiff':          'margin: 0.75em 0 0.5em;',
 +
'.wikEdPreviewRefs':          'margin-top: 1.5em; padding-top: 1em; border-top: 1px solid #a0a0a0;',
 +
'.wikEdPreviewDiffError':      'padding: 0.5em; font-weight: bold; color: red; text-align: center;',
 +
 
 +
// find and replace fields
 +
'.wikEdFindComboInput, .wikEdReplaceComboInput': 'position: relative; margin: 0 5px; top: -1px; white-space: nowrap; vertical-align: bottom; padding: 0; line-height: 20px; font-size: 13px;',
 +
'#wikEdFindText, #wikEdReplaceText': 'padding: 0; font-family: monospace; margin: 0; position: absolute; left: 0; top: 0; z-index: 2; vertical-align: bottom; width: 170px; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; height: 18px;',
 +
'#wikEdFindSelect, #wikEdReplaceSelect': 'font-family: monospace; margin: 0; position: relative; left: 0; top: 0; z-index: 1; vertical-align: bottom; width: 190px; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; height: 18px;',
 +
 
 +
// summary field
 +
'.wikEdSummaryComboInput':    'position: relative; margin: 0 0 0 2px; top: 0; white-space: nowrap; padding: 0; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; font-size: 13px;',
 +
'.wikEdSummaryText':          'padding: 0 2px !important; margin: 0; position: absolute; left: 0; top: 0; z-index: 2; vertical-align: bottom; width: auto; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; height: 21px;',
 +
'.wikEdSummarySelect':        'padding: 0; margin: 0; position: relative; left: 0; top: 0; z-index: 1; vertical-align: text-top; width: auto; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; height: 21px;',
 +
 
 +
// space around submit buttons
 +
'.editButtons':                '',
 +
 
 +
// frame (frame container border will be removed if textarea has none; frame must not have a border)
 +
'.wikEdFrameOuter':            'float: left; width: auto; border: 1px solid; border-color: #808080 #d0d0d0 #d0d0d0 #808080; position: relative;',
 +
'.wikEdFrameInner':            'float: left; width: auto; background: white; border: 1px solid; border-color: #404040 #ffffff #ffffff #404040; line-height: 0; position: relative;',
 +
'.wikEdFrame':                'float: left; width: 100%; border: 0;',
 +
 
 +
// summary
 +
'.wikEdSummaryWrapper':        'margin: 0.4em 0.75em 0; line-height: 26px; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;',
 +
'.wikEdConsoleTopWrapper':    'clear: both; background: #f0f0f0; border: 1px solid #c0c0c0; position: relative; padding: 0 0 0.6em; margin: 0 0 0.5em;',
 +
'#wpSummaryLabel':            'margin: 0;',
 +
'.editOptions':                'padding: 0; border: none; margin: 0 0.75em; float: left',
 +
'.wikEdClearSummaryForm':      'display: inline;',
 +
'.wikEdClearSummary':          'vertical-align: middle; margin: 0 0 0 0.5em; padding: 1px; height: 19px; width: 18px; ',
 +
'#wikEdClearSummaryImg':      'vertical-align: 10%; ',
 +
 
 +
// input wrapper
 +
'.wikEdInputWrapper':          'position: relative; z-index: 100; margin-top: 0.5em; clear: both;',
 +
'.wikEdFullscreen .wikEdInputWrapper ': 'position: fixed; margin-top: 0; top: 0; left: 0; right: 0; background: #f0f0f0;',
 +
'body.wikEdFullscreen':        'overflow: hidden;',
 +
'.wikEdFullscreen .portlet ':  'z-index: 0 !important;', // for monobook
 +
 
 +
// other wrappers
 +
'.wikEdEditorWrapper':        '',
 +
'.wikEdToolbarWrapper':        '',
 +
'.wikEdButtonBarWrapper':      'line-height: 14px; float: left; width: 100%; padding: 0.2em 0;',
 +
'.wikEdCaptchaWrapper':        '',
 +
'.wikEdDebugWrapper':          'position: relative; margin: 0 0 0.5em;',
 +
'.wikEdDebugTextarea':        'width: 100%; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;',
 +
'.wikEdEditWrapper':          'clear: both;',
 +
'.wikEdEditWrapperFull':      'float: left; clear: both; width: 100%;',
 +
'.wikEdTextareaWrapper':      '',
 +
'.wikEdFrameWrapper':          '',
 +
'.wikEdConsoleWrapper':        'clear: both; background: #f0f0f0; border: 1px solid #c0c0c0; border-top: none; padding: 0 0 0.4em; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; float: left; width: 100%;',
 +
'.wikEdButtonsWrapper':        '',
 +
'.wikEdButtonsWrapperFull':    'float: left; clear: both; width: 100%;',
 +
'.wikEdSummaryInputWrapper':  'display: inline; white-space: nowrap;',
 +
'.wikEdSubmitWrapper':        '',
 +
'.wikEdSubmitButtonsWrapper':  'float: left; margin: 0.4em 0.75em 0;',
 +
'.wikEdEditOptionsWrapper':    'float: left; margin: 0.4em 0.75em 0;',
 +
'.wikEdEditHelp':              'white-space: nowrap;',
 +
'.wikEdInsertWrapper':        'float: left; clear: both; margin-top: 0.25em;',
 +
'.wikEdFullscreen .wikEdInsertWrapper p': 'display: inline; margin: 0;',
 +
'.wikEdLocalPrevWrapper':      'float: left; width: 100%;',
 +
 
 +
// various
 +
'.editCheckboxes':            'margin-bottom: 0;',
 +
'.wikEdEditOptions':          'display: inline-block; white-space: nowrap; vertical-align: text-top;',
 +
'.wikEdEditOptions label':    'vertical-align: text-bottom;',
 +
'#editpage-copywarn':          '',
 +
'#editpage-specialchars':      '',
 +
'#wikEdClonedWarnings':        '',
 +
'#wikEdClonedWarningsNote':    'background: #fff; color: #888; font-size: 75%; display: inline;',
 +
'.editButtons input:first-child': 'margin-left: 0; margin-right: 0.33em;',
 +
'fieldset#templatesandbox-editform': 'margin: 0 0 0.5em 0; float: left;',
 +
'#templatesandbox-editform legend': 'padding-top: 0;',
 +
});
 +
};
 +
 
 +
// buttons
 +
if (wikEd.config.button === undefined) { wikEd.config.button = {}; }
 +
 
 +
// wikEd.InitButton: define built-in buttons
 +
wikEd.InitButton = function () {
 +
wikEd.InitObject(wikEd.config.button, {
 +
 
 +
// button number: [id, class, tooltip, image url, width, height, alt text, onclick handler code were obj is the button element]
 +
 
 +
// format top
 +
1:  ['wikEdUndo',            'wikEdButtonInactive',  wikEd.config.text['wikEdUndo title'],            wikEd.config.image['undo'],                '16', '16', wikEd.config.text['wikEdUndo alt'],            'wikEd.EditButton(obj, obj.id);' ],
 +
2:  ['wikEdRedo',            'wikEdButtonInactive',  wikEd.config.text['wikEdRedo title'],            wikEd.config.image['redo'],                '16', '16', wikEd.config.text['wikEdRedo alt'],            'wikEd.EditButton(obj, obj.id);' ],
 +
3:  ['wikEdBold',            'wikEdButton',          wikEd.config.text['wikEdBold title'],            wikEd.config.image['bold'],                '16', '16', wikEd.config.text['wikEdBold alt'],            'wikEd.EditButton(obj, obj.id);' ],
 +
4:  ['wikEdItalic',          'wikEdButton',          wikEd.config.text['wikEdItalic title'],          wikEd.config.image['italic'],              '16', '16', wikEd.config.text['wikEdItalic alt'],          'wikEd.EditButton(obj, obj.id);' ],
 +
5:  ['wikEdUnderline',        'wikEdButton',          wikEd.config.text['wikEdUnderline title'],        wikEd.config.image['underline'],          '16', '16', wikEd.config.text['wikEdUnderline alt'],        'wikEd.EditButton(obj, obj.id);' ],
 +
6:  ['wikEdStrikethrough',    'wikEdButton',          wikEd.config.text['wikEdStrikethrough title'],    wikEd.config.image['strikethrough'],      '16', '16', wikEd.config.text['wikEdStrikethrough alt'],    'wikEd.EditButton(obj, obj.id);' ],
 +
7:  ['wikEdNowiki',          'wikEdButton',          wikEd.config.text['wikEdNowiki title'],          wikEd.config.image['nowiki'],              '16', '16', wikEd.config.text['wikEdNowiki alt'],          'wikEd.EditButton(obj, obj.id);' ],
 +
8:  ['wikEdSuperscript',      'wikEdButton',          wikEd.config.text['wikEdSuperscript title'],      wikEd.config.image['superscript'],        '16', '16', wikEd.config.text['wikEdSuperscript alt'],      'wikEd.EditButton(obj, obj.id);' ],
 +
9:  ['wikEdSubscript',        'wikEdButton',          wikEd.config.text['wikEdSubscript title'],        wikEd.config.image['subscript'],          '16', '16', wikEd.config.text['wikEdSubscript alt'],        'wikEd.EditButton(obj, obj.id);' ],
 +
10: ['wikEdRef',              'wikEdButton',          wikEd.config.text['wikEdRef title'],              wikEd.config.image['ref'],                '16', '16', wikEd.config.text['wikEdRef alt'],              'if (!event.shiftKey) { wikEd.EditButton(obj, \'wikEdRef\'); } else { wikEd.EditButton(obj, \'wikEdRefNamed\'); }' ],
 +
12: ['wikEdCase',            'wikEdButton',          wikEd.config.text['wikEdCase title'],            wikEd.config.image['case'],                '16', '16', wikEd.config.text['wikEdCase alt'],            'wikEd.EditButton(obj, obj.id);' ],
 +
80: ['wikEdSort',            'wikEdButton',          wikEd.config.text['wikEdSort title'],            wikEd.config.image['sort'],                '16', '16', wikEd.config.text['wikEdSort alt'],            'wikEd.EditButton(obj, obj.id);' ],
 +
25: ['wikEdRedirect',        'wikEdButton',          wikEd.config.text['wikEdRedirect title'],        wikEd.config.image['redirect'],            '16', '16', wikEd.config.text['wikEdRedirect alt'],        'wikEd.EditButton(obj, obj.id);' ],
 +
13: ['wikEdUndoAll',          'wikEdButton',          wikEd.config.text['wikEdUndoAll title'],          wikEd.config.image['undoAll'],            '16', '16', wikEd.config.text['wikEdUndoAll alt'],          'wikEd.EditButton(obj, obj.id);' ],
 +
14: ['wikEdRedoAll',          'wikEdButtonInactive',  wikEd.config.text['wikEdRedoAll title'],          wikEd.config.image['redoAll'],            '16', '16', wikEd.config.text['wikEdRedoAll alt'],          'wikEd.EditButton(obj, obj.id);' ],
 +
 
 +
// format bottom
 +
15: ['wikEdWikiLink',        'wikEdButton',          wikEd.config.text['wikEdWikiLink title'],        wikEd.config.image['wikiLink'],            '16', '16', wikEd.config.text['wikEdWikiLink alt'],        'wikEd.EditButton(obj, obj.id);' ],
 +
16: ['wikEdWebLink',          'wikEdButton',          wikEd.config.text['wikEdWebLink title'],          wikEd.config.image['webLink'],            '16', '16', wikEd.config.text['wikEdWebLink alt'],          'wikEd.EditButton(obj, obj.id);' ],
 +
17: ['wikEdHeading',          'wikEdButton',          wikEd.config.text['wikEdHeading title'],          wikEd.config.image['heading'],            '16', '16', wikEd.config.text['wikEdHeading alt'],          'if (!event.shiftKey) { wikEd.EditButton(obj, \'wikEdIncreaseHeading\'); } else { wikEd.EditButton(obj, \'wikEdDecreaseHeading\'); }' ],
 +
19: ['wikEdBulletList',      'wikEdButton',          wikEd.config.text['wikEdBulletList title'],      wikEd.config.image['bulletList'],          '16', '16', wikEd.config.text['wikEdBulletList alt'],      'if (!event.shiftKey) { wikEd.EditButton(obj, \'wikEdIncreaseBulletList\'); } else { wikEd.EditButton(obj, \'wikEdDecreaseBulletList\'); }' ],
 +
20: ['wikEdNumberList',      'wikEdButton',          wikEd.config.text['wikEdNumberList title'],      wikEd.config.image['numberList'],          '16', '16', wikEd.config.text['wikEdNumberList alt'],      'if (!event.shiftKey) { wikEd.EditButton(obj, \'wikEdIncreaseNumberList\'); } else { wikEd.EditButton(obj, \'wikEdDecreaseNumberList\'); }' ],
 +
21: ['wikEdIndentList',      'wikEdButton',          wikEd.config.text['wikEdIndentList title'],      wikEd.config.image['indentList'],          '16', '16', wikEd.config.text['wikEdIndentList alt'],      'if (!event.shiftKey) { wikEd.EditButton(obj, \'wikEdIncreaseIndentList\'); } else { wikEd.EditButton(obj, \'wikEdDecreaseIndentList\'); }' ],
 +
22: ['wikEdDefinitionList',  'wikEdButton',          wikEd.config.text['wikEdDefinitionList title'],  wikEd.config.image['definitionList'],      '16', '16', wikEd.config.text['wikEdDefinitionList alt'],  'wikEd.EditButton(obj, obj.id);' ],
 +
23: ['wikEdImage',            'wikEdButton',          wikEd.config.text['wikEdImage title'],            wikEd.config.image['image'],              '16', '16', wikEd.config.text['wikEdImage alt'],            'wikEd.EditButton(obj, obj.id);' ],
 +
24: ['wikEdTable',            'wikEdButton',          wikEd.config.text['wikEdTable title'],            wikEd.config.image['table'],              '16', '16', wikEd.config.text['wikEdTable alt'],            'wikEd.EditButton(obj, obj.id);' ],
 +
11: ['wikEdReferences',      'wikEdButton',          wikEd.config.text['wikEdReferences title'],      wikEd.config.image['references'],          '16', '16', wikEd.config.text['wikEdReferences alt'],      'if (!event.shiftKey) { wikEd.EditButton(obj, obj.id); } else { wikEd.EditButton(obj, \'wikEdReferencesSection\'); }' ],
 +
84: ['wikEdSign',            'wikEdButton',          wikEd.config.text['wikEdSign title'],            wikEd.config.image['sign'],                '16', '16', wikEd.config.text['wikEdSign alt'],            'if (!event.shiftKey) { wikEd.EditButton(obj, obj.id); } else { wikEd.EditButton(obj, \'wikEdSignName\'); }' ],
 +
 
 +
// wikify, textify
 +
26: ['wikEdWikify',          'wikEdButton',          wikEd.config.text['wikEdWikify title'],          wikEd.config.image['wikify'],              '16', '16', wikEd.config.text['wikEdWikify alt'],          'wikEd.EditButton(obj, obj.id);' ],
 +
27: ['wikEdTextify',          'wikEdButton',          wikEd.config.text['wikEdTextify title'],          wikEd.config.image['textify'],            '16', '16', wikEd.config.text['wikEdTextify alt'],          'if (event.shiftKey) { wikEd.EditButton(obj, obj.id, \'shift\'); } else { wikEd.EditButton(obj, obj.id); }' ],
 +
 
 +
// control top
 +
77: ['wikEdRefHide',          'wikEdButtonUnchecked', wikEd.config.text['wikEdRefHide title'],          wikEd.config.image['refHide'],            '16', '16', wikEd.config.text['wikEdRefHide alt'],          'wikEd.Button(obj, obj.id, true);' ],
 +
29: ['wikEdTextZoom',        'wikEdButton',          wikEd.config.text['wikEdTextZoom title'],        wikEd.config.image['textZoom'],            '16', '16', wikEd.config.text['wikEdTextZoom alt'],        'if (!event.shiftKey) { wikEd.Button(obj, \'wikEdTextZoomDown\'); } else { wikEd.Button(obj, \'wikEdTextZoomUp\'); }' ],
 +
30: ['wikEdClearHistory',    'wikEdButton',          wikEd.config.text['wikEdClearHistory title'],    wikEd.config.image['clearHistory'],        '16', '16', wikEd.config.text['wikEdClearHistory alt'],    'wikEd.Button(obj, obj.id);' ],
 +
31: ['wikEdScrollToPreview',  'wikEdButton',          wikEd.config.text['wikEdScrollToPreview title'],  wikEd.config.image['scrollToPreviewDown'], '16', '16', wikEd.config.text['wikEdScrollToPreview alt'],  'wikEd.Button(obj, obj.id);' ],
 +
32: ['wikEdScrollToEdit',    'wikEdButton',          wikEd.config.text['wikEdScrollToEdit title'],    wikEd.config.image['scrollToEditDown'],    '16', '16', wikEd.config.text['wikEdScrollToEdit alt'],    'wikEd.Button(obj, obj.id);' ],
 +
 
 +
// control bottom
 +
33: ['wikEdUseWikEd',        'wikEdButtonChecked',  wikEd.config.text['wikEdUseWikEd title'],        wikEd.config.image['useWikEd'],            '16', '16', wikEd.config.text['wikEdUseWikEd alt'],        'if (!event.ctrlKey) { wikEd.Button(obj, obj.id, true); } else { wikEd.DebugInfo(event); }' ],
 +
34: ['wikEdHighlightSyntax',  'wikEdButtonUnchecked', wikEd.config.text['wikEdHighlightSyntax title'],  wikEd.config.image['highlightSyntax'],    '16', '16', wikEd.config.text['wikEdHighlightSyntax alt'],  'wikEd.Button(obj, obj.id, true);' ],
 +
35: ['wikEdSource',          'wikEdButton',          wikEd.config.text['wikEdSource title'],          wikEd.config.image['source'],              '16', '16', wikEd.config.text['wikEdSource alt'],          'wikEd.EditButton(obj, obj.id);' ],
 +
75: ['wikEdCloseToolbar',    'wikEdButtonUnchecked', wikEd.config.text['wikEdCloseToolbar title'],    wikEd.config.image['closeToolbar'],        '16', '16', wikEd.config.text['wikEdCloseToolbar alt'],    'wikEd.Button(obj, obj.id, true);' ],
 +
36: ['wikEdUsing',            'wikEdButtonUnchecked', wikEd.config.text['wikEdUsing title'],            wikEd.config.image['using'],              '16', '16', wikEd.config.text['wikEdUsing alt'],            'wikEd.Button(obj, obj.id, true);' ],
 +
37: ['wikEdFullScreen',      'wikEdButtonUnchecked', wikEd.config.text['wikEdFullScreen title'],      wikEd.config.image['fullScreen'],          '16', '16', wikEd.config.text['wikEdFullScreen alt'],      'wikEd.Button(obj, obj.id, true);' ],
 +
79: ['wikEdTableMode',        'wikEdButtonUnchecked', wikEd.config.text['wikEdTableMode title'],        wikEd.config.image['tableMode'],          '16', '16', wikEd.config.text['wikEdTableMode alt'],        'wikEd.Button(obj, obj.id, true);' ],
 +
 
 +
// find top
 +
39: ['wikEdFindAll',          'wikEdButton',          wikEd.config.text['wikEdFindAll title'],          wikEd.config.image['findAll'],            '16', '16', wikEd.config.text['wikEdFindAll alt'],          'wikEd.EditButton(obj, obj.id);' ],
 +
40: ['wikEdFindPrev',        'wikEdButton',          wikEd.config.text['wikEdFindPrev title'],        wikEd.config.image['findPrev'],            '16', '16', wikEd.config.text['wikEdFindPrev alt'],        'wikEd.EditButton(obj, obj.id);' ],
 +
41: ['wikEdFindNext',        'wikEdButton',          wikEd.config.text['wikEdFindNext title'],        wikEd.config.image['findNext'],            '16', '16', wikEd.config.text['wikEdFindNext alt'],        'if (event.shiftKey) { wikEd.EditButton(obj, obj.id, \'shift\'); } else { wikEd.EditButton(obj, obj.id); }' ],
 +
43: ['wikEdJumpPrev',        'wikEdButton',          wikEd.config.text['wikEdJumpPrev title'],        wikEd.config.image['jumpPrev'],            '16', '16', wikEd.config.text['wikEdJumpPrev alt'],        'wikEd.EditButton(obj, obj.id);' ],
 +
44: ['wikEdJumpNext',        'wikEdButton',          wikEd.config.text['wikEdJumpNext title'],        wikEd.config.image['jumpNext'],            '16', '16', wikEd.config.text['wikEdJumpNext alt'],        'wikEd.EditButton(obj, obj.id);' ],
 +
 
 +
// find bottom
 +
46: ['wikEdReplaceAll',      'wikEdButton',          wikEd.config.text['wikEdReplaceAll title'],      wikEd.config.image['replaceAll'],          '16', '16', wikEd.config.text['wikEdReplaceAll alt'],      'wikEd.EditButton(obj, obj.id);' ],
 +
47: ['wikEdReplacePrev',      'wikEdButton',          wikEd.config.text['wikEdReplacePrev title'],      wikEd.config.image['replacePrev'],        '16', '16', wikEd.config.text['wikEdReplacePrev alt'],      'wikEd.EditButton(obj, obj.id);' ],
 +
48: ['wikEdReplaceNext',      'wikEdButton',          wikEd.config.text['wikEdReplaceNext title'],      wikEd.config.image['replaceNext'],        '16', '16', wikEd.config.text['wikEdReplaceNext alt'],      'if (event.shiftKey) { wikEd.EditButton(obj, obj.id, \'shift\'); } else { wikEd.EditButton(obj, obj.id); }' ],
 +
49: ['wikEdCaseSensitive',    'wikEdButtonUnchecked', wikEd.config.text['wikEdCaseSensitive title'],    wikEd.config.image['caseSensitive'],      '16', '16', wikEd.config.text['wikEdCaseSensitive alt'],    'wikEd.Button(obj, obj.id, true);' ],
 +
50: ['wikEdRegExp',          'wikEdButtonUnchecked', wikEd.config.text['wikEdRegExp title'],          wikEd.config.image['regExp'],              '16', '16', wikEd.config.text['wikEdRegExp alt'],          'wikEd.Button(obj, obj.id, true);' ],
 +
51: ['wikEdFindAhead',        'wikEdButtonUnchecked', wikEd.config.text['wikEdFindAhead title'],        wikEd.config.image['findAhead'],          '16', '16', wikEd.config.text['wikEdFindAhead alt'],        'wikEd.Button(obj, obj.id, true);' ],
 +
 
 +
// fix top
 +
52: ['wikEdFixBasic',        'wikEdButton',          wikEd.config.text['wikEdFixBasic title'],        wikEd.config.image['fixBasic'],            '16', '16', wikEd.config.text['wikEdFixBasic alt'],        'wikEd.EditButton(obj, obj.id);' ],
 +
53: ['wikEdFixHtml',          'wikEdButton',          wikEd.config.text['wikEdFixHtml title'],          wikEd.config.image['fixHtml'],            '16', '16', wikEd.config.text['wikEdFixHtml alt'],          'wikEd.EditButton(obj, obj.id);' ],
 +
54: ['wikEdFixCaps',          'wikEdButton',          wikEd.config.text['wikEdFixCaps title'],          wikEd.config.image['fixCaps'],            '16', '16', wikEd.config.text['wikEdFixCaps alt'],          'wikEd.EditButton(obj, obj.id);' ],
 +
55: ['wikEdFixUnicode',      'wikEdButton',          wikEd.config.text['wikEdFixUnicode title'],      wikEd.config.image['fixUnicode'],          '16', '16', wikEd.config.text['wikEdFixUnicode alt'],      'wikEd.EditButton(obj, obj.id);' ],
 +
81: ['wikEdFixRedirect',      'wikEdButton',          wikEd.config.text['wikEdFixRedirect title'],      wikEd.config.image['fixRedirect'],        '16', '16', wikEd.config.text['wikEdFixRedirect alt'],      'wikEd.EditButton(obj, obj.id);' ],
 +
56: ['wikEdFixAll',          'wikEdButton',          wikEd.config.text['wikEdFixAll title'],          wikEd.config.image['fixAll'],              '16', '16', wikEd.config.text['wikEdFixAll alt'],          'wikEd.EditButton(obj, obj.id);' ],
 +
57: ['wikEdFixRegExTypo',    'wikEdButton',          wikEd.config.text['wikEdFixRegExTypo title'],    wikEd.config.image['fixRegExTypo'],        '16', '16', wikEd.config.text['wikEdFixRegExTypo alt'],    'wikEd.EditButton(obj, obj.id);' ],
 +
 
 +
// fix bottom
 +
58: ['wikEdFixDashes',        'wikEdButton',          wikEd.config.text['wikEdFixDashes title'],        wikEd.config.image['fixDash'],            '16', '16', wikEd.config.text['wikEdFixDashes alt'],        'wikEd.EditButton(obj, obj.id);' ],
 +
59: ['wikEdFixPunct',        'wikEdButton',          wikEd.config.text['wikEdFixPunct title'],        wikEd.config.image['fixPunct'],            '16', '16', wikEd.config.text['wikEdFixPunct alt'],        'wikEd.EditButton(obj, obj.id);' ],
 +
60: ['wikEdFixMath',          'wikEdButton',          wikEd.config.text['wikEdFixMath title'],          wikEd.config.image['fixMath'],            '16', '16', wikEd.config.text['wikEdFixMath alt'],          'wikEd.EditButton(obj, obj.id);' ],
 +
61: ['wikEdFixChem',          'wikEdButton',          wikEd.config.text['wikEdFixChem title'],          wikEd.config.image['fixChem'],            '16', '16', wikEd.config.text['wikEdFixChem alt'],          'wikEd.EditButton(obj, obj.id);' ],
 +
62: ['wikEdFixUnits',        'wikEdButton',          wikEd.config.text['wikEdFixUnits title'],        wikEd.config.image['fixUnits'],            '16', '16', wikEd.config.text['wikEdFixUnits alt'],        'wikEd.EditButton(obj, obj.id);' ],
 +
 
 +
// preview top
 +
65: ['wikEdClose',            'wikEdButton',          wikEd.config.text['wikEdClose title'],            wikEd.config.image['close'],              '16', '16', wikEd.config.text['wikEdClose alt'],            'wikEd.Button(obj, obj.id);' ],
 +
66: ['wikEdScrollToPreview2', 'wikEdButton',          wikEd.config.text['wikEdScrollToPreview2 title'], wikEd.config.image['scrollToPreviewDown'], '16', '16', wikEd.config.text['wikEdScrollToPreview2 alt'], 'wikEd.Button(obj, obj.id);' ],
 +
67: ['wikEdScrollToEdit2',    'wikEdButton',          wikEd.config.text['wikEdScrollToEdit2 title'],    wikEd.config.image['scrollToEdit'],        '16', '16', wikEd.config.text['wikEdScrollToEdit2 alt'],    'wikEd.Button(obj, obj.id);' ],
 +
 
 +
// preview bottom
 +
70: ['wikEdClose2',          'wikEdButton',          wikEd.config.text['wikEdClose2 title'],          wikEd.config.image['close'],              '16', '16', wikEd.config.text['wikEdClose2 alt'],          'wikEd.Button(obj, obj.id);' ],
 +
71: ['wikEdScrollToPreview3', 'wikEdButton',          wikEd.config.text['wikEdScrollToPreview3 title'], wikEd.config.image['scrollToPreview'],    '16', '16', wikEd.config.text['wikEdScrollToPreview3 alt'], 'wikEd.Button(obj, obj.id);' ],
 +
72: ['wikEdScrollToEdit3',    'wikEdButton',          wikEd.config.text['wikEdScrollToEdit3 title'],    wikEd.config.image['scrollToEdit'],        '16', '16', wikEd.config.text['wikEdScrollToEdit3 alt'],    'wikEd.Button(obj, obj.id);' ],
 +
 
 +
// jump
 +
74: ['wikEdScrollToEdit4',    'wikEdButtonSolo',      wikEd.config.text['wikEdScrollToEdit4 title'],    wikEd.config.image['scrollToEditDown'],    '16', '16', wikEd.config.text['wikEdScrollToEdit4 alt'],    'wikEd.Button(obj, obj.id);' ],
 +
 
 +
// dummy (empty placeholder)
 +
76: ['wikEdDummy',            'wikEdButtonDummy',    '',                                              wikEd.config.image['dummy'],              '16', '16', '',                                            '' ],
 +
 
 +
// wikEd.InitButton: define built-in buttons (id, class, popup title, image src, width, height, alt text, click handler code were obj is the button element)
 +
82: ['wikEdLocalPreview',    'wikEdLocalPreview',    wikEd.config.text['wikEdLocalPreview title'],    wikEd.config.image['preview'],            '16', '16', wikEd.config.text['wikEdLocalPreviewImg alt'],  'wikEd.Button(obj, obj.id);' ],
 +
83: ['wikEdLocalDiff',        'wikEdLocalDiff',      wikEd.config.text['wikEdLocalDiff title'],        wikEd.config.image['diff'],                '16', '16', wikEd.config.text['wikEdLocalDiffImg alt'],    'wikEd.Button(obj, obj.id);' ],
 +
 
 +
// pasted
 +
85: ['wikEdPastedTextify',    'wikEdButtonInactive',  wikEd.config.text['wikEdPastedTextify title'],    wikEd.config.image['textify'],            '16', '16', wikEd.config.text['wikEdPastedTextify alt'],    'wikEd.EditButton(obj, obj.id);' ],
 +
86: ['wikEdPastedWikify',    'wikEdButtonInactive',  wikEd.config.text['wikEdPastedWikify title'],    wikEd.config.image['wikify'],              '16', '16', wikEd.config.text['wikEdPastedWikify alt'],    'wikEd.EditButton(obj, obj.id);' ],
 +
87: ['wikEdPastedClose',      'wikEdButton',          wikEd.config.text['wikEdPastedClose title'],      wikEd.config.image['closePasted'],        '16', '16', wikEd.config.text['wikEdPastedClose alt'],      'wikEd.PastedClose();' ]
 +
});
 +
};
 +
 
 +
// button access keys
 +
if (wikEd.config.buttonKey === undefined) { wikEd.config.buttonKey = {}; }
 +
 
 +
// wikEd.InitButtonKey: define accesskeys for edit buttons
 +
wikEd.InitButtonKey = function () {
 +
wikEd.InitObject(wikEd.config.buttonKey, {
 +
 
 +
// wikEd button number: [key string, JS key code]
 +
26: ['b', 66], // wikify
 +
27: ['o', 79], // textify
 +
67: ['g', 71], // scrolltoedit2
 +
72: ['g', 71], // scrolltoedit3
 +
74: ['g', 71], // scrolltoedit4
 +
32: ['g', 71]  // scrolltoedit, overwrites previous wikEd buttons for same key
 +
});
 +
};
 +
 
 +
// button bars (id, class, button numbers)
 +
if (wikEd.config.buttonBar === undefined) { wikEd.config.buttonBar = {}; }
 +
 
 +
// wikEd.InitButtonBar: define built-in button bars
 +
wikEd.InitButtonBar = function () {
 +
wikEd.InitObject(wikEd.config.buttonBar, {
 +
 
 +
// button name: [id outer, class outer, id inner, class inner, height, grip title, button numbers, bar title
 +
'format':  ['wikEdButtonBarFormat',  'wikEdButtonBarFormat',  'wikEdButtonsFormat',  'wikEdButtonsFormat',  44, wikEd.config.text['wikEdGripFormat title'],  [1,2,3,4,5,6,7,8,9,10,12,13,14,'br',15,16,17,19,20,21,22,23,24,11,80,25,84], wikEd.config.text['wikEdBarFormat title'] ],
 +
'textify':  ['wikEdButtonBarTextify',  'wikEdButtonBarTextify',  'wikEdButtonsTextify',  'wikEdButtonsTextify',  44, wikEd.config.text['wikEdGripTextify title'], [26,'br',27], wikEd.config.text['wikEdBarTextify title'] ],
 +
'custom1':  ['wikEdButtonBarCustom1',  'wikEdButtonBarCustom1',  'wikEdButtonsCustom1',  'wikEdButtonsCustom1',  44, wikEd.config.text['wikEdGripCustom1 title'], [ ], wikEd.config.text['wikEdBarCustom1 title'] ],
 +
'find':    ['wikEdButtonBarFind',    'wikEdButtonBarFind',    'wikEdButtonsFind',    'wikEdButtonsFind',    44, wikEd.config.text['wikEdGripFind title'],    [39,40,'find',41,76,43,44,'br',46,47,'replace',48,49,50,51], wikEd.config.text['wikEdBarFind title'] ],
 +
'fix':      ['wikEdButtonBarFix',      'wikEdButtonBarFix',      'wikEdButtonsFix',      'wikEdButtonsFix',      44, wikEd.config.text['wikEdGripFix title'],    [52,53,54,55,56,81,'br',58,59,60,61,62,57], wikEd.config.text['wikEdBarFix title'] ],
 +
'custom2':  ['wikEdButtonBarCustom2',  'wikEdButtonBarCustom2',  'wikEdButtonsCustom2',  'wikEdButtonsCustom2',  44, wikEd.config.text['wikEdGripCustom2 title'], [ ], wikEd.config.text['wikEdBarCustom2 title'] ],
 +
'control':  ['wikEdButtonBarControl',  'wikEdButtonBarControl',  'wikEdButtonsControl',  'wikEdButtonsControl',  44, wikEd.config.text['wikEdGripControl title'], [77,29,30,35,31,32,'br',33,34,79,75,36,37], wikEd.config.text['wikEdBarControl title'] ],
 +
'preview':  ['wikEdButtonBarPreview',  'wikEdButtonBarPreview',  'wikEdButtonsPreview',  'wikEdButtonsPreview',  0, null, [66,67,65], wikEd.config.text['wikEdBarPreview title'] ],
 +
'preview2': ['wikEdButtonBarPreview2', 'wikEdButtonBarPreview2', 'wikEdButtonsPreview2', 'wikEdButtonsPreview2',  0, null, [71,72,70], wikEd.config.text['wikEdBarPreview2 title'] ],
 +
'jump':    ['wikEdButtonBarJump',    'wikEdButtonBarJump',    'wikEdButtonsJump',    'wikEdButtonsJump',      0, null, [74],      wikEd.config.text['wikEdBarJump title'] ],
 +
'pasted':  ['wikEdButtonBarPasted',  'wikEdButtonBarPasted',  'wikEdButtonsPasted',  'wikEdButtonsPasted',    0, null, [85,86,87], wikEd.config.text['wikEdBarPasted title'] ]
 +
});
 +
};
 +
 
 +
// history length for find, replace, and summary fields
 +
if (wikEd.config.historyLength === undefined) { wikEd.config.historyLength = {}; }
 +
wikEd.InitHistoryLength = function () {
 +
wikEd.InitObject(wikEd.config.historyLength, {
 +
'find': 10,
 +
'replace': 10,
 +
'summary': 10
 +
});
 +
};
 +
 
 +
// presets for combo input fields dropdown options, {wikEdUsing} appends a link to this script
 +
if (wikEd.config.comboPresetOptions === undefined) { wikEd.config.comboPresetOptions = {}; }
 +
if (wikEd.config.comboPresetOptions.summary === undefined) { wikEd.config.comboPresetOptions.summary = wikEd.config.text.wikEdPresetSummary; }
 +
 
 +
// text for summary link to this script
 +
if (wikEd.config.summaryUsing === undefined) { wikEd.config.summaryUsing = wikEd.config.text.wikEdSummaryUsing; }
 +
 
 +
// expiration time span for permanent cookies in seconds, also defined in wikEdDiff.js
 +
if (wikEd.config.cookieExpireSec === undefined) { wikEd.config.cookieExpireSec = 1 * 30 * 24 * 60 * 60; }
 +
 
 +
// disable wikEd preset
 +
if (wikEd.config.disabledPreset === undefined) { wikEd.config.disabledPreset = false; }
 +
 
 +
// find ahead as you type checkbox preset
 +
if (wikEd.config.findAheadSelected === undefined) { wikEd.config.findAheadSelected = true; }
 +
 
 +
// highlight syntax preset
 +
if (wikEd.config.highlightSyntaxPreset === undefined) { wikEd.config.highlightSyntaxPreset = true; }
 +
 
 +
// enable wikEd preset
 +
if (wikEd.config.useWikEdPreset === undefined) { wikEd.config.useWikEdPreset = true; }
 +
 
 +
// add '...using wikEd' to summary preset
 +
if (wikEd.config.usingPreset === undefined) { wikEd.config.usingPreset = false; }
 +
 
 +
// scroll to edit field on non-preview pages
 +
if (wikEd.config.scrollToEdit === undefined) { wikEd.config.scrollToEdit = true; }
 +
 
 +
// focus the edit field on non-preview pages
 +
if (wikEd.config.focusEdit === undefined) { wikEd.config.focusEdit = true; }
 +
 
 +
// fullscreen mode preset
 +
if (wikEd.config.fullScreenModePreset === undefined) { wikEd.config.fullScreenModePreset = false; }
 +
 
 +
// show MediaWiki toolbar preset
 +
if (wikEd.config.closeToolbarPreset === undefined) { wikEd.config.closeToolbarPreset = false; }
 +
 
 +
// hide ref tags preset
 +
if (wikEd.config.refHidePreset === undefined) { wikEd.config.refHidePreset = false; }
 +
 
 +
// text size adjustment for edit window (percentage)
 +
if (wikEd.config.textSizeAdjust === undefined) { wikEd.config.textSizeAdjust = 100; }
 +
 
 +
// remove invisible syntax highlighting comments after closing tag
 +
if (wikEd.config.removeHighlightComments === undefined) { wikEd.config.removeHighlightComments = true; }
 +
 
 +
// show the text-to-source button for testing purposes
 +
if (wikEd.config.showSourceButton === undefined) { wikEd.config.showSourceButton = false; }
 +
 
 +
// show the using-wikEd button
 +
if (wikEd.config.showUsingButton === undefined) { wikEd.config.showUsingButton = false; }
 +
 
 +
// the wikEd help page link to be displayed after the editing help link, an empty string disables the link
 +
if (wikEd.config.helpPageLink === undefined) { wikEd.config.helpPageLink = wikEd.config.text.wikEdHelpPageLink; }
 +
 
 +
// enable external diff script
 +
if (wikEd.config.loadDiffScript === undefined) { wikEd.config.loadDiffScript = true; }
 +
 
 +
// enable external wikEdDiff script
 +
if (wikEd.config.loadDiff === undefined) { wikEd.config.loadDiff = true; }
 +
 
 +
// RegExTypoFix rules page, the address must have the exact same domain name as the used wiki
 +
if (wikEd.config.regExTypoFixURL === undefined) { wikEd.config.regExTypoFixURL = wikEd.config.homeBaseUrl + 'w/index.php?title=Wikipedia:AutoWikiBrowser/Typos&action=raw'; }
 +
 
 +
// enable RegExTypoFix button (https://en.wikipedia.org/wiki/User:Mboverload/RegExTypoFix)
 +
if (wikEd.config.regExTypoFix === undefined) { wikEd.config.regExTypoFix = false; }
 +
 
 +
// enable highlighting as links
 +
if (wikEd.config.followHighlightedLinks === undefined) { wikEd.config.followHighlightedLinks = false; }
 +
 
 +
// skip the browser detection to run wikEd under IE and Opera
 +
if (wikEd.config.skipBrowserTest === undefined) { wikEd.config.skipBrowserTest = false; }
 +
 
 +
// skip the script test that disables wikEd if certain scripts are present
 +
if (wikEd.config.skipScriptTest === undefined) { wikEd.config.skipScriptTest = false; }
 +
 
 +
// skip the add-on test that disables wikEd if certain add-ons are present
 +
if (wikEd.config.skipAddonTest === undefined) { wikEd.config.skipAddonTest = false; }
 +
 
 +
// skip the read-only detection
 +
if (wikEd.config.skipReadOnlyTest === undefined) { wikEd.config.skipReadOnlyTest = false; }
 +
 
 +
// disable wikEd if incompatible scripts are active
 +
if (wikEd.config.incompatibleScripts === undefined) { wikEd.config.incompatibleScripts = {}; }
 +
 
 +
// wikEd.InitIncompatibleScripts: disable wikEd if incompatible scripts are active
 +
// 'name in error message': 'regexp', case insensitive for script file name from URL w/o .js, use '\\' for '\'
 +
wikEd.InitIncompatibleScripts = function () {
 +
wikEd.InitObject(wikEd.config.incompatibleScripts, {
 +
'CKEditor': '\\bckeditor',
 +
'FCKEditor': 'fckeditor',
 +
'less edit clutter': 'less.?edit.?clutter', // [[User:Magnus_Manske/less_edit_clutter.js]]
 +
'MagnusEditBox': 'MagnusEditBox' // less_edit_clutter gadget on fr
 +
});
 +
};
 +
 
 +
// disable beta toolbar CodeEditor button
 +
if (wikEd.config.disableCodeEditorButton === undefined) { wikEd.config.disableCodeEditorButton = true; }
 +
 
 +
// set the button bar grip width in px
 +
if (wikEd.config.buttonBarGripWidth === undefined) { wikEd.config.buttonBarGripWidth = 7; }
 +
 
 +
// enable server preview (Ajax)
 +
if (wikEd.config.useAjaxPreview === undefined) { wikEd.config.useAjaxPreview = true; }
 +
 
 +
// enable auto update (Ajax)
 +
if (wikEd.config.autoUpdate === undefined) { wikEd.config.autoUpdate = true; }
 +
 
 +
// hours between update check (monobook.js)
 +
if (wikEd.config.autoUpdateHours === undefined) { wikEd.config.autoUpdateHours = 20; }
 +
 
 +
// hours between update check (Greasemonkey)
 +
if (wikEd.config.autoUpdateHoursGM === undefined) { wikEd.config.autoUpdateHoursGM = 40; }
 +
 
 +
// auto update: version url (Ajax)
 +
if (wikEd.config.autoUpdateUrl === undefined) { wikEd.config.autoUpdateUrl = wikEd.config.homeBaseUrl + 'w/index.php?title=User:Cacycle/wikEd_current_version&action=raw&maxage=0'; }
 +
 
 +
// auto update: script url for Greasemonkey update
 +
if (wikEd.config.autoUpdateScriptUrl === undefined) { wikEd.config.autoUpdateScriptUrl = wikEd.config.homeBaseUrl + 'w/index.php?action=raw&ctype=text/javascript&title=User:Cacycle/wikEd.user.js'; }
 +
 
 +
// auto update: script url for Greasemonkey bugfix (fix script duplication after @namespace change in version 0.9.127)
 +
if (wikEd.config.autoUpdateScriptUrlBugfix === undefined) { wikEd.config.autoUpdateScriptUrlBugfix = wikEd.config.homeBaseUrl + 'w/index.php?action=raw&ctype=text/javascript&title=User:Cacycle/bugfix_wikEd.user.js'; }
 +
 
 +
// make links ctrl-clickable
 +
if (wikEd.config.linkify === undefined) { wikEd.config.linkify = true; }
 +
 
 +
// absolute instead of relative linkify links, URL with "$1" as article name placeholder
 +
if (wikEd.config.linkifyArticlePath === undefined) { wikEd.config.linkifyArticlePath = null; }
 +
 
 +
// hide refs and templates in newbie mode
 +
if (wikEd.config.hideContent === undefined) { wikEd.config.hideContent = true; }
 +
 
 +
// unhide refs and templates in newbie mode by hover-shift instead of mouseover
 +
if (wikEd.config.unhideShift === undefined) { wikEd.config.unhideShift = false; }
 +
 
 +
// wikify table parameters, replaces original table parameters with this string
 +
if (wikEd.config.wikifyTableParameters === undefined) { wikEd.config.wikifyTableParameters = ''; }
 +
 
 +
// do not rearrange page elements
 +
if (wikEd.config.noRearrange === undefined) { wikEd.config.noRearrange = false; }
 +
 
 +
// use French rules for fix punctuation
 +
if (wikEd.config.fixPunctFrench === undefined) { wikEd.config.fixPunctFrench = false; }
 +
 
 +
// wikEd.config.setupHook, executed after wikEd has been set up, usage: wikEd.config.setupHook.push(YourFunction);
 +
if (wikEd.config.setupHook === undefined) { wikEd.config.setupHook = []; }
 +
 
 +
// wikEd.config.onHook, executed after wikEd has been re-enabled by logo click, usage: wikEd.config.onHook.push(YourFunction);
 +
if (wikEd.config.onHook === undefined) { wikEd.config.onHook = []; }
 +
 
 +
// wikEd.config.offHook, executed after wikEd has been disabled by logo click, usage: wikEd.config.offHook.push(YourFunction);
 +
if (wikEd.config.offHook === undefined) { wikEd.config.offHook = []; }
 +
 
 +
// wikEd.config.textareaHook, executed after classic textarea has been enabled by user, usage: wikEd.config.textareaHook.push(YourFunction);
 +
if (wikEd.config.textareaHook === undefined) { wikEd.config.textareaHook = []; }
 +
 
 +
// wikEd.config.frameHook, executed after wikEd edit frame has been enabled by user, usage: wikEd.config.frameHook.push(YourFunction);
 +
if (wikEd.config.frameHook === undefined) { wikEd.config.frameHook = []; }
 +
 
 +
// wikEd.config.previewHook, executed after the local preview has been added to the page, usage: wikEd.config.previewHook.push(YourFunction);
 +
if (wikEd.config.previewHook === undefined) { wikEd.config.previewHook = []; }
 +
 
 +
// wikEd.config.diffHook, executed after the local changes diff has been added to the page, usage: wikEd.config.diffHook.push(YourFunction);
 +
if (wikEd.config.dHook === undefined) { wikEd.config.diffHook = []; }
 +
 
 +
// custom edit form id instead of 'editform'
 +
if (wikEd.config.customEditFormId === undefined) { wikEd.config.customEditFormId = ''; }
 +
 
 +
// custom textarea id instead of 'wpTextbox1'
 +
if (wikEd.config.customTextAreaId === undefined) { wikEd.config.customTextAreaId = ''; }
 +
 
 +
// custom save button id instead of 'wpSave'
 +
if (wikEd.config.customSaveButtonId === undefined) { wikEd.config.customSaveButtonId = ''; }
 +
 
 +
// display tables as editable html tables (table mode)
 +
if (wikEd.config.tableMode === undefined) { wikEd.config.tableMode = true; }
 +
 
 +
// show table mode toggle button
 +
if (wikEd.config.showTableModeButton === undefined) { wikEd.config.showTableModeButton = false; }
 +
 
 +
// maximal time for syntax highlighting in ms
 +
if (wikEd.config.maxHighlightTime === undefined) { wikEd.config.maxHighlightTime = 3000; }
 +
 
 +
// first char of article names is case sensitive (e.g. Wiktionary)
 +
if (wikEd.config.articlesCaseSensitive === undefined) { wikEd.config.articlesCaseSensitive = false; }
 +
 
 +
// force immediate update if this version string is newer
 +
if (wikEd.config.forcedUpdate === undefined) { wikEd.config.forcedUpdate = ''; }
 +
 
 +
// display highlighting error messages in text
 +
if (wikEd.config.highlightError === undefined) { wikEd.config.highlightError = false; }
 +
 
 +
// display preview of files in text
 +
if (wikEd.config.filePreview === undefined) { wikEd.config.filePreview = true; }
 +
 
 +
// file preview image size in pixels
 +
if (wikEd.config.filePreviewSize === undefined) { wikEd.config.filePreviewSize = 75; }
 +
 
 +
// move cursor/caret outside syntax highlighted element
 +
if (wikEd.config.antiHighlightBleeding === undefined) { wikEd.config.antiHighlightBleeding = false; }
 +
 
 +
// debug window maximal length in chars
 +
if (wikEd.config.debugMaxLength === undefined) { wikEd.config.debugMaxLength = 500000; }
 +
 
 +
// debug display of DOM nodes: maximal length of innerHTML in chars
 +
if (wikEd.config.debugInnerHtmlLength === undefined) { wikEd.config.debugInnerHtmlLength = 150; }
 +
 
 +
// WikiMedia Commons (or other external file repository) script url for redlink detection
 +
if (wikEd.config.externalApiUrl === undefined) { wikEd.config.externalApiUrl = '//commons.wikimedia.org/w/api.php'; }
 +
 
 +
// origin domains allowed to call externalScriptURL API for redlink detection via Ajax cross-origin request (CORS) (comma separated list)
 +
if (wikEd.config.externalApiDomains === undefined) { wikEd.config.externalApiDomains = 'wikipedia.org,wiktionary.org,wikibooks.org,wikinews.org,wikiquote.org,wikisource.org,wikiversity.org,wikivoyage.org,wikidata.org,mediawiki.org,wikimedia.org,wikimediafoundation.org'; }
 +
 
 +
// wikibase data repository url default
 +
if (wikEd.config.wbRepoUrl === undefined) { wikEd.config.wbRepoUrl = '//www.wikidata.org'; }
 +
 
 +
// wikibase data repository article path default
 +
if (wikEd.config.wbRepoArticlePath === undefined) { wikEd.config.wbRepoArticlePath = '/wiki/$1'; }
 +
 
 +
// interlanguage name of default wiki on wikibase data repository default
 +
if (wikEd.config.wbGlobalSiteId === undefined) { wikEd.config.wbGlobalSiteId = 'enwiki'; }
 +
 
 +
// copy textarea background color to wikEd edit frame
 +
if (wikEd.config.frameBackgroundColor === undefined) { wikEd.config.frameBackgroundColor = false; }
 +
 
 +
// convert all &nbsp; character entities to actual characters for textarea editing and saving (not recommended)
 +
if (wikEd.config.nbspToChar === undefined) { wikEd.config.nbspToChar = false; }
 +
 
 +
return;
 +
};
 +
 
 +
// user configurable variables needed during start up
 +
 
 +
// init config
 +
if (wikEd.config === undefined) { wikEd.config = {}; }
 +
 
 +
// wikEd code home base URL, also defined in wikEdDiff.js
 +
if (wikEd.config.homeBaseUrl === undefined) { wikEd.config.homeBaseUrl = '//en.wikipedia.org/'; }
 +
 
 +
// diff library URL, also defined in wikEdDiff.js
 +
if (wikEd.config.diffScriptSrc === undefined) { wikEd.config.diffScriptSrc = wikEd.config.homeBaseUrl + 'w/index.php?title=User:Cacycle/diff.js&action=raw&ctype=text/javascript'; }
 +
 
 +
// wikEdDiff script URL, also defined in wikEdDiff.js
 +
if (wikEd.config.diffSrc === undefined) { wikEd.config.diffSrc = wikEd.config.homeBaseUrl + 'w/index.php?title=User:Cacycle/wikEdDiff.js&action=raw&ctype=text/javascript'; }
 +
 
 +
// wikEd-as-gadget detection, set to true if gadget script name is not MediaWiki:Gadget-wikEd.js
 +
if (wikEd.config.gadget === undefined) { wikEd.config.gadget = null; }
 +
 
 +
// duplicate edit warnings from the top of the page to above the edit window
 +
if (wikEd.config.doCloneWarnings === undefined) { wikEd.config.doCloneWarnings = true; }
 +
 
 +
// startup debugging
 +
if (wikEd.config.debugStartUp === undefined) { wikEd.config.debugStartUp = ''; }
 +
 
 +
// show missing translations
 +
if (wikEd.config.showMissingTranslations === undefined) { wikEd.config.showMissingTranslations = false; }
 +
 
 +
// content language default, also used for wikEd UI localization
 +
if (wikEd.config.languageDefault === undefined) { wikEd.config.languageDefault = ''; }
 +
 
 +
// load external translation
 +
if (wikEd.config.loadTranslation === undefined) { wikEd.config.loadTranslation = true; }
 +
 
 +
// translation javascript URLs
 +
if (wikEd.config.translations === undefined) { wikEd.config.translations = {}; }
 +
 
 +
// wikEd.InitTranslations: define translation javascript URLs ('': internal default)
 +
wikEd.InitTranslations = function () {
 +
wikEd.InitObject(wikEd.config.translations, {
 +
'en':  '',
 +
'af':  wikEd.config.homeBaseUrl + 'w/index.php?action=raw&ctype=text/javascript&title=User:Arnobarnard/wikEd_international_af.js',
 +
'ar':  wikEd.config.homeBaseUrl + 'w/index.php?action=raw&ctype=text/javascript&title=User:ترجمان05/wikEd_international_ar.js',
 +
'bn':  wikEd.config.homeBaseUrl + 'w/index.php?action=raw&ctype=text/javascript&title=User:Aftabuzzaman/wikEd_international_bn.js',
 +
'zh-hans': wikEd.config.homeBaseUrl + 'w/index.php?action=raw&ctype=text/javascript&title=User:CAS222222221/wikEd_international_zh.js',
 +
'zh-hant': wikEd.config.homeBaseUrl + 'w/index.php?action=raw&ctype=text/javascript&title=User:Liflon/wikEd_international_zh-hant.js',
 +
'cs':  wikEd.config.homeBaseUrl + 'w/index.php?action=raw&ctype=text/javascript&title=User:Sevela.p/wikEd_international_cs.js',
 +
'nl':  wikEd.config.homeBaseUrl + 'w/index.php?action=raw&ctype=text/javascript&title=User:Jeronevw/wikEd_international_nl.js',
 +
'eo':  wikEd.config.homeBaseUrl + 'w/index.php?action=raw&ctype=text/javascript&title=Tlustulimu/wikEd_international_eo.js',
 +
'fi':  wikEd.config.homeBaseUrl + 'w/index.php?action=raw&ctype=text/javascript&title=User:Ejs-80/wikEd_international_fi.js',
 +
'fr':  wikEd.config.homeBaseUrl + 'w/index.php?action=raw&ctype=text/javascript&title=User:Leag/wikEd-fr.js',
 +
'gl':  wikEd.config.homeBaseUrl + 'w/index.php?action=raw&ctype=text/javascript&title=User:Toliño/wikEd_international_gl.js',
 +
'de':  wikEd.config.homeBaseUrl + 'w/index.php?action=raw&ctype=text/javascript&title=User:PerfektesChaos/wikEd_international_de.js',
 +
'he':  wikEd.config.homeBaseUrl + 'w/index.php?action=raw&ctype=text/javascript&title=User:שמוליק/wikEd_international_he.js',
 +
'hr':  wikEd.config.homeBaseUrl + 'w/index.php?action=raw&ctype=text/javascript&title=User:SpeedyGonsales/wikEd_international_hr.js',
 +
'hu':  wikEd.config.homeBaseUrl + 'w/index.php?action=raw&ctype=text/javascript&title=User:Tsch81/wikEd-hu.js',
 +
'it':  wikEd.config.homeBaseUrl + 'w/index.php?action=raw&ctype=text/javascript&title=User:Jalo/wikEd_international_it.js',
 +
'ja':  wikEd.config.homeBaseUrl + 'w/index.php?action=raw&ctype=text/javascript&title=User:Hatukanezumi/wikEd_international_ja.js',
 +
'kk':  wikEd.config.homeBaseUrl + 'w/index.php?action=raw&ctype=text/javascript&title=User:Arystanbek/wikEd_international_kk.js',
 +
'ko':  wikEd.config.homeBaseUrl + 'w/index.php?action=raw&ctype=text/javascript&title=User:Ilovesabbath/wikEd_international_ko.js',
 +
'dsb': wikEd.config.homeBaseUrl + 'w/index.php?action=raw&ctype=text/javascript&title=User:Michalwiki/wikEd_international_dsb.js',
 +
'ms':  wikEd.config.homeBaseUrl + 'w/index.php?action=raw&ctype=text/javascript&title=User:Aviator/wikEd_international_ms.js',
 +
'no':  wikEd.config.homeBaseUrl + 'w/index.php?action=raw&ctype=text/javascript&title=User:Dvyjones/wikEd_international_no.js',
 +
'nn':  wikEd.config.homeBaseUrl + 'w/index.php?action=raw&ctype=text/javascript&title=User:Frokor/wikEd_international_nn.js',
 +
'fa':  wikEd.config.homeBaseUrl + 'w/index.php?action=raw&ctype=text/javascript&title=User:Reza1615/wikEd_international_fa.js',
 +
'pl':  wikEd.config.homeBaseUrl + 'w/index.php?action=raw&ctype=text/javascript&title=User:Konradek/wikEd_international_pl.js',
 +
'pt':  wikEd.config.homeBaseUrl + 'w/index.php?action=raw&ctype=text/javascript&title=User:He7d3r/Tools/wikEd_international_pt.js',
 +
'ro':  wikEd.config.homeBaseUrl + 'w/index.php?action=raw&ctype=text/javascript&title=User:Roamataa/wikEd_international_ro.js',
 +
'ru':  wikEd.config.homeBaseUrl + 'w/index.php?action=raw&ctype=text/javascript&title=User:IGW/wikEd_international_ru.js',
 +
'scn': wikEd.config.homeBaseUrl + 'w/index.php?action=raw&ctype=text/javascript&title=User:Meloscn/wikEd_international_scn.js',
 +
'sk':  wikEd.config.homeBaseUrl + 'w/index.php?action=raw&ctype=text/javascript&title=User:Helix84/wikEd_international_sk.js',
 +
'sl':  wikEd.config.homeBaseUrl + 'w/index.php?action=raw&ctype=text/javascript&title=User:Eleassar/wikEd_international_sl.js',
 +
'es':  wikEd.config.homeBaseUrl + 'w/index.php?action=raw&ctype=text/javascript&title=User:Doblecaña/wikEd_international_es.js',
 +
'sv':  wikEd.config.homeBaseUrl + 'w/index.php?action=raw&ctype=text/javascript&title=User:Where_next_Columbus?/wikEd_international_sv.js',
 +
'tr':  wikEd.config.homeBaseUrl + 'w/index.php?action=raw&ctype=text/javascript&title=User:Vito_Genovese/wikEd_international_tr.js',
 +
'hsb': wikEd.config.homeBaseUrl + 'w/index.php?action=raw&ctype=text/javascript&title=User:Michalwiki/wikEd_international_hsb.js',
 +
'vi':  wikEd.config.homeBaseUrl + 'w/index.php?action=raw&ctype=text/javascript&title=User:Vinhtantran/wikEd_international_vi.js'
 +
});
 +
};
 +
 
 +
// Mediawiki page and skin detection, logo placement
 +
if (wikEd.config.mediaWikiSkinIds === undefined) { wikEd.config.mediaWikiSkinIds = {}; }
 +
 
 +
// wikEd.InitMediaWikiSkinIds: define Mediawiki page and skin detection, logo placement
 +
//  format: skin name: [ dom element to add logo to ('': top right), logo to this list or list contained in this parent element, rearrange page elements, [skin detection element id list], enable local preview / diff ],
 +
wikEd.InitMediaWikiSkinIds = function () {
 +
wikEd.InitObject(wikEd.config.mediaWikiSkinIds, {
 +
 
 +
// monobook, also detects simple and myskin
 +
monobook:    [ 'p-personal', true, true, ['column-content', 'content', 'bodyContent', 'siteSub', 'contentSub', 'column-one', 'p-cactions'] ],
 +
 
 +
// vector (see https://bugzilla.wikimedia.org/show_bug.cgi?id=19527)
 +
vector_old:  [ 'personal', true, true, ['content', 'bodyContent', 'contentSub', 'left-navigation', 'namespaces'] ],
 +
vector_new:  [ 'p-personal', true, true, ['content', 'bodyContent', 'contentSub', 'left-navigation', 'p-namespaces', 'p-cactions'] ],
 +
 
 +
// citizendium.org
 +
pinkwich5:  [ 'p-personal', true, true, ['column-content', 'content', 'bodycontent', 'sitesub', 'contentSub', 'column-one', 'p-cactions'] ],
 +
 
 +
// other MediaWiki skins
 +
standard:    [ 'quickbar', false, true, ['content', 'topbar', 'article', 'footer', 'pagestats'] ],
 +
nostalgia:  [ 'topbar', false, true, ['content', 'specialpages', 'article', 'footer'] ],
 +
cologneblue: [ 'quickbar', false, true, ['content', 'topbar', 'sitetitle', 'sitesub', 'article', 'footer'] ],
 +
modern:      [ 'p-personal', true, true, ['mw_header', 'mw_main', 'mw_contentwrapper'] ],
 +
 
 +
// wikia.com
 +
monaco:      [ 'userData', false, false, ['background_strip', 'siteSub', 'contentSub', 'monaco_footer'] ],
 +
quartz:      [ 'welcome', false, true, ['articleWrapper', 'bodyContent', 'siteSub', 'contentSub', 'sidebar'] ],
 +
searchwikia: [ 'header-li-buttons', false, true, ['header', 'header-container', 'header-go-button', 'article-container', 'article', 'article-text'] ],
 +
oasis:      [ 'AccountNavigation', false, false, ['WikiaHeader', 'WikiaPage'], false ],
 +
 
 +
// custom skins developed on wiki.mozilla.org and developer.mozilla.org
 +
cavendish:  [ '', false, true, ['internal', 'container', 'header', 'contentTop', 'mBody', 'side', 'nav', 'siteSub', 'contentSub'] ],
 +
devmo:      [ 'personal', false, true, ['developer-mozilla-org', 'container', 'header', 'navigation', 'bar', 'page', 'sidebar', 'sidebarslideup', 'contentTop', 'siteSub', 'contentSub'] ],
 +
 
 +
// custom skins
 +
gumaxdd:    [ 'gumax-p-login', true, true, ['gumax-header', 'gumax-content-body'] ],
 +
pixeled:    [ 'topright', true, true, ['contentwrapper', 'catnav', 'morefoot'] ],
 +
 
 +
// custom MediaWiki identifier
 +
mediawiki:  [ '', false, false, ['mediawiki'] ]
 +
});
 +
};
 +
 
 +
//
 +
// end of user configurable variables
 +
//
 +
 
 +
 
 +
//
 +
// wikEd.InitGlobals: initialize non-configurable variables
 +
//
 +
 
 +
wikEd.InitGlobals = function () {
 +
 
 +
// global variables
 +
wikEd.turnedOn = false;
 +
wikEd.disabled = true;
 +
wikEd.debugOpen = false;
 +
wikEd.pageNamespace = null;
 +
wikEd.frameLoaded = false;
 +
 
 +
// edit page types
 +
wikEd.editArticle = false;
 +
wikEd.editUpload = false;
 +
wikEd.editReadOnly = false;
 +
wikEd.editSemanticForm = false;
 +
wikEd.viewDeleted = false;
 +
wikEd.editWatchlist = false;
 +
wikEd.cssPage = false;
 +
wikEd.jsPage = false;
 +
wikEd.editSection = null;
 +
 
 +
// beta toolbar, CodeEditor
 +
wikEd.useBetaToolbar = false;
 +
wikEd.useCodeEditor = false;
 +
wikEd.codeEditorButtonPollCount = 0;
 +
 
 +
// history
 +
wikEd.fieldHist = [];
 +
wikEd.savedName = [];
 +
wikEd.inputElement = [];
 +
wikEd.selectElement = [];
 +
 
 +
wikEd.checkMarker = [];
 +
wikEd.checkMarker[true] = '♦';
 +
wikEd.checkMarker[false] = '◊';
 +
 
 +
// undo all, redo all
 +
wikEd.origVersion = '';
 +
wikEd.lastVersion = null;
 +
 
 +
// global dom elements
 +
wikEd.logo = null;
 +
wikEd.logoList = null;
 +
wikEd.debug = null;
 +
wikEd.wikiEditor = null;
 +
wikEd.wikiEditorFrame = null;
 +
wikEd.wikiEditorTop = null;
 +
wikEd.wikiEditorLeft = null;
 +
wikEd.wikiEditorBar = null;
 +
wikEd.wikiEditorBottom = null;
 +
wikEd.wikiEditorText = null;
 +
wikEd.textareaContainer = null;
 +
wikEd.toolbar = null;
 +
wikEd.frameInner = null;
 +
wikEd.frameOuter = null;
 +
wikEd.frame = null;
 +
wikEd.frameDocument = null;
 +
wikEd.frameBody = null;
 +
wikEd.frameHtml = null;
 +
wikEd.frameWindow = null;
 +
 
 +
wikEd.inputWrapper = null;
 +
wikEd.editorWrapper = null;
 +
wikEd.toolbarWrapper = null;
 +
wikEd.buttonBarWrapper = null;
 +
wikEd.captchaWrapper = null;
 +
wikEd.debugWrapper = null;
 +
wikEd.editWrapper = null;
 +
wikEd.textareaWrapper = null;
 +
wikEd.frameWrapper = null;
 +
wikEd.consoleWrapper = null;
 +
wikEd.buttonsWrapper = null;
 +
wikEd.summaryWrapper = null;
 +
wikEd.consoleTopWrapper = null;
 +
wikEd.summaryInputWrapper = null;
 +
wikEd.editOptionsWrapper = null;
 +
wikEd.submitWrapper = null;
 +
wikEd.submitButtonsWrapper = null;
 +
wikEd.localPrevWrapper = null;
 +
wikEd.wikiPreview = null;
 +
wikEd.catLinks = null;
 +
wikEd.insertWrapper = null;
 +
wikEd.textBoxTable = null;
 +
 
 +
// edit form fields
 +
wikEd.editForm = null;
 +
wikEd.starttime = null;
 +
wikEd.edittime = null;
 +
wikEd.editToken = null;
 +
wikEd.autoSummary = null;
 +
wikEd.textarea = null;
 +
 
 +
wikEd.buttonsWrapperWidth = {};
 +
wikEd.buttonBarFormat = null;
 +
wikEd.buttonBarTextify = null;
 +
wikEd.buttonBarCustom1 = null;
 +
wikEd.buttonBarFind = null;
 +
wikEd.buttonBarFix = null;
 +
wikEd.buttonBarCustom2 = null;
 +
wikEd.buttonBarControl = null;
 +
wikEd.buttonBarPreview = null;
 +
wikEd.buttonBarPreview2 = null;
 +
wikEd.buttonBarJump = null;
 +
wikEd.buttonBarPasted = null;
 +
wikEd.previewArticle = null;
 +
wikEd.previewDiff = null;
 +
wikEd.clearSummary = null;
 +
wikEd.clearSummaryImg = null;
 +
 
 +
wikEd.caseSensitive = null;
 +
wikEd.regExp = null;
 +
wikEd.findAhead = null;
 +
wikEd.fixRegExTypo = null;
 +
 
 +
wikEd.findText = null;
 +
wikEd.replaceText = null;
 +
wikEd.summaryText = null;
 +
wikEd.summarySelect = null;
 +
wikEd.summaryTextWidth = null;
 +
 
 +
wikEd.editHelp = null;
 +
wikEd.saveButton = null;
 +
wikEd.previewButton = null;
 +
wikEd.lDiffButton = null;
 +
wikEd.diffPreviewButton = null;
 +
wikEd.summaryLabel = null;
 +
 
 +
wikEd.highlightNamedHideButtonsStylesheet = null;
 +
 
 +
// frame resizing
 +
wikEd.resizeGripWidth = 16;
 +
wikEd.resizeGripHeight = 16;
 +
wikEd.resizeFramePageYStart = 0;
 +
wikEd.resizeFramePageXStart = 0;
 +
wikEd.resizeFrameOffsetHeight = 0;
 +
wikEd.resizeFrameOffsetWidth = 0;
 +
wikEd.resizeFrameMouseOverGrip = false;
 +
wikEd.resizeFrameActive = false;
 +
wikEd.frameHeight = '';
 +
wikEd.frameWidth = '';
 +
wikEd.textareaHeight = '';
 +
wikEd.textareaWidth = '';
 +
 
 +
// various
 +
wikEd.insertCounter = 0;
 +
wikEd.editButtonHandler = {};
 +
wikEd.textareaBorderHeight = 0;
 +
wikEd.frameBorderHeight = 0;
 +
wikEd.frameBorderWidth = 0;
 +
wikEd.textareaOffsetHeightInitial = 0;
 +
wikEd.clearSummaryWidth = null;
 +
 
 +
// fullscreen button state and actual fullscreen state
 +
wikEd.fullScreenMode = false;
 +
wikEd.fullscreen = false;
 +
 
 +
wikEd.addNewSection = null;
 +
wikEd.browserNotSupported = false;
 +
wikEd.frameScrollTop = null;
 +
wikEd.textareaUpdated = true;
 +
wikEd.previewIsAjax = null;
 +
wikEd.buttonKeyCode = [];
 +
wikEd.direction = null;
 +
wikEd.textSize = 0;
 +
wikEd.textSizeInit = 0;
 +
wikEd.previewPage = false;
 +
wikEd.clonedWarnings = false;
 +
wikEd.syntaxHighlightTagCSS = [];
 +
wikEd.loader = false;
 +
wikEd.wikibase = {};
 +
wikEd.keepSelRange = null;
 +
 
 +
// override site javascript functions
 +
wikEd.InsertTagsOriginal = null;
 +
wikEd.insertAtCursorOriginal = null;
 +
 
 +
// wikEd settings
 +
wikEd.refHide = false;
 +
wikEd.using = false;
 +
wikEd.closeToolbar = false;
 +
wikEd.highlightSyntax = false;
 +
wikEd.noSpellcheck = false;
 +
wikEd.diff = false;
 +
wikEd.tableMode = false;
 +
wikEd.cleanNodes = false;
 +
wikEd.readOnly = false;
 +
 
 +
// unicode fixing and char highlighting
 +
wikEd.supportedChars = null;
 +
wikEd.reservedChars = null;
 +
wikEd.specialChars = null;
 +
wikEd.problemChars = null;
 +
 
 +
wikEd.charEntitiesByName = {};
 +
 
 +
wikEd.controlCharHighlighting = null;
 +
wikEd.controlCharHighlightingStr = '';
 +
wikEd.charHighlighting = null;
 +
wikEd.charHighlightingStr = '';
 +
 
 +
wikEd.letters = '';
 +
 
 +
// linkification and hiding
 +
wikEd.wikiLinks = {};
 +
wikEd.referenceArray = [];
 +
wikEd.templateArray = [];
 +
wikEd.charEntityArray = [];
 +
wikEd.tableArray = [];
 +
wikEd.scheduledUnhide = null;
 +
 
 +
// RegExtypoFix rules
 +
wikEd.typoRulesFind = [];
 +
wikEd.typoRulesReplace = [];
 +
 
 +
// store link infos (normalizations, redirects, redlinks)
 +
wikEd.linkInfo = {};
 +
wikEd.externalLinkInfo = {};
 +
 
 +
// article preview: named reference definitions
 +
wikEd.namedRefs = {};
 +
 
 +
// file preview
 +
wikEd.filePreviewCache = {};
 +
wikEd.filePreviewRequest = '';
 +
wikEd.filePreviewNo = 0;
 +
wikEd.filePreviewIds = [];
 +
 
 +
// debugging time measurement, usage: wikEd.debugTimer.push([1234, new Date]); wikEd.DebugTimer();
 +
wikEd.debugTimer = [];
 +
 
 +
// syntax highlighting
 +
wikEd.parseObj = {};
 +
 
 +
// MediaWiki file paths for use in regexps
 +
wikEd.server = '';
 +
wikEd.articlePath = '';
 +
wikEd.script = '';
 +
wikEd.scriptPath = '';
 +
wikEd.scriptName = '';
 +
wikEd.scriptURL = '';
 +
wikEd.useExternalApi = false;
 +
 
 +
// pasting object
 +
wikEd.paste = null;
 +
 
 +
// magic words and parser functions, see https://www.mediawiki.org/wiki/Help:Magic_words
 +
// __MAGICWORDS__
 +
wikEd.magicWords = 'NOTOC|FORCETOC|TOC|NOEDITSECTION|NEWSECTIONLINK|NOGALLERY|HIDDENCAT|NOCONTENTCONVERT|NOCC|NOTITLECONVERT|NOTC|END|START|NOINDEX|INDEX|STATICREDIRECT';
 +
 
 +
// template, parser function, and parser variable modifiers {{modifier:...}}
 +
// see https://meta.wikimedia.org/wiki/Help:Magic_words#Template_modifiers
 +
wikEd.templModifier = 'int|msg|msgnw|raw|subst';
 +
 
 +
// parser variables {{variable}}
 +
wikEd.parserVariables = 'CURRENTYEAR|CURRENTMONTH|CURRENTMONTHNAME|CURRENTMONTHNAMEGEN|CURRENTMONTHABBREV|CURRENTDAY|CURRENTDAY2|CURRENTDOW|CURRENTDAYNAME|CURRENTTIME|CURRENTHOUR|CURRENTWEEK|CURRENTTIMESTAMP|LOCALYEAR|LOCALMONTH|LOCALMONTHNAME|LOCALMONTHNAMEGEN|LOCALMONTHABBREV|LOCALDAY|LOCALDAY2|LOCALDOW|LOCALDAYNAME|LOCALTIME|LOCALHOUR|LOCALWEEK|LOCALTIMESTAMP|SITENAME|CURRENTVERSION|CONTENTLANGUAGE|REVISIONID|REVISIONDAY|REVISIONDAY2|REVISIONMONTH|REVISIONYEAR|REVISIONTIMESTAMP|SERVER|SERVERNAME|SCRIPTPATH|FULLPAGENAME|PAGENAME|BASEPAGENAME|SUBPAGENAME|SUBJECTPAGENAME|TALKPAGENAME|FULLPAGENAMEE|PAGENAMEE|BASEPAGENAMEE|SUBPAGENAMEE|SUBJECTPAGENAMEE|TALKPAGENAMEE|NAMESPACE|SUBJECTSPACE|ARTICLESPACE|TALKSPACE|NAMESPACEE|SUBJECTSPACEE|TALKSPACEE|DIRMARK|DIRECTIONMARK|PAGENAME|PAGENAMEE|ARTICLEPATH|NOEXTERNALLANGLINKS';
 +
 
 +
// parser variables {{variable:R}}
 +
wikEd.parserVariablesR = 'NUMBEROFPAGES|NUMBEROFARTICLES|NUMBEROFFILES|NUMBEROFEDITS|NUMBEROFUSERS|NUMBEROFADMINS|NUMBEROFVIEWS|NUMBEROFACTIVEUSERS|PROTECTIONLEVEL';
 +
 
 +
// parser functions {{FUNCTION:parameter|R}}
 +
wikEd.parserFunctionsR = 'NUMBERINGROUP|PAGESINNS|PAGESINNAMESPACE|PAGESINCATEGORY|PAGESINCAT|PAGESIZE|DEFAULTSORT|DISPLAYTITLE';
 +
 
 +
// parser functions {{function:param|param}}
 +
wikEd.parserFunctions = 'localurl|localurle|fullurl|filepath|fullurle|urlencode|urldecode|anchorencode|ns|lc|lcfirst|uc|ucfirst|formatnum|padleft|padright|padright|plural|grammar|gender|int|noexternallanglinks';
 +
 
 +
// parser functions {{#function:param|param}}
 +
wikEd.parserFunctionsHash = 'language|special|tag|tag|expr|if|ifeq|ifexist|ifexpr|switch|time|timel|rel2abs|titleparts|iferror|iferror|special|tag|categorytree|formatdate|property|invoke';
 +
 
 +
// define leaf elements for wikEd.GetInnerHTML
 +
wikEd.leafElements = {
 +
'IMG':  true,
 +
'HR':    true,
 +
'BR':    true,
 +
'INPUT': true
 +
};
 +
 
 +
return;
 +
};
 +
 
 +
// variables needed during startup, might be called multiple times
 +
 
 +
// hash of loaded scripts, also defined in wikEdDiff.js
 +
if (wikEd.externalScripts === undefined) { wikEd.externalScripts = null; }
 +
if (wikEd.externalScriptsString === undefined) { wikEd.externalScriptsString = ''; }
 +
if (wikEd.pageLoaded === undefined) { wikEd.pageLoaded = false; }
 +
if (wikEd.programVersion === undefined) { wikEd.programVersion = ''; }
 +
if (wikEd.programDate === undefined) { wikEd.programDate = ''; }
 +
 
 +
// browser and os identificationr
 +
if (wikEd.browserName === undefined) { wikEd.browserName = ''; }
 +
if (wikEd.browserFlavor === undefined) { wikEd.browserFlavor = ''; }
 +
if (wikEd.browserVersion === undefined) { wikEd.browserVersion = 0; }
 +
if (wikEd.browserVersionStr === undefined) { wikEd.browserVersionStr = ''; }
 +
if (wikEd.msie === undefined) { wikEd.msie = false; }
 +
if (wikEd.mozilla === undefined) { wikEd.mozilla = false; }
 +
if (wikEd.opera === undefined) { wikEd.opera = false; }
 +
if (wikEd.safari === undefined) { wikEd.safari = false; }
 +
if (wikEd.webkit === undefined) { wikEd.webkit = false; }
 +
if (wikEd.chrome === undefined) { wikEd.chrome = false; }
 +
if (wikEd.greasemonkey === undefined) { wikEd.greasemonkey = false; }
 +
if (wikEd.testVersion === undefined) { wikEd.testVersion = false; }
 +
if (wikEd.platform === undefined) { wikEd.platform = null; }
 +
if (wikEd.installationType === undefined) { wikEd.installationType = ''; }
 +
 
 +
// global variables for Greasemonkey
 +
if (wikEd.wikiGlobals === undefined) { wikEd.wikiGlobals = {}; }
 +
if (wikEd.text === undefined) { wikEd.text = {}; }
 +
 
 +
// skins
 +
if (wikEd.logoContainerId === undefined) { wikEd.logoContainerId = ''; }
 +
if (wikEd.rearrange === undefined) { wikEd.rearrange = false; }
 +
if (wikEd.logoToList === undefined) { wikEd.logoToList = false; }
 +
if (wikEd.enableLocalPreview === undefined) { wikEd.enableLocalPreview = false; }
 +
if (wikEd.skin === undefined) { wikEd.skin = ''; }
 +
 
 +
// various
 +
if (wikEd.gotGlobalsHook === undefined) { wikEd.gotGlobalsHook = []; }
 +
if (wikEd.getGlobalsCounter === undefined) { wikEd.getGlobalsCounter = 0; }
 +
if (wikEd.loadingTranslation === undefined) { wikEd.loadingTranslation = false; }
 +
if (wikEd.webStorage === undefined) { wikEd.webStorage = null; }
 +
 
 +
// customization
 +
if (wikEd.useWikEd === undefined) { wikEd.useWikEd = false; }
 +
if (wikEd.wikEdTextAdded === undefined) { wikEd.wikEdTextAdded = false; }
 +
if (wikEd.wikEdConfigAdded === undefined) { wikEd.wikEdConfigAdded = false; }
 +
 
 +
// global dom elements, also defined in wikEdDiff.js
 +
if (wikEd.pageOrigin === undefined) { wikEd.pageOrigin = ''; }
 +
if (wikEd.head === undefined) { wikEd.head = null; }
 +
 
 +
// also defined in wikEdDiff.js
 +
if (wikEd.pageName === undefined) { wikEd.pageName = null; }
 +
 
 +
 
 +
//
 +
// wikEd.InitObject: initialize object, keep pre-defined values (code copied to wikEdDiff.js)
 +
//
 +
 
 +
wikEd.InitObject = function (target, source, showMissing) {
 +
 
 +
if (typeof target == 'object') {
 +
for (var key in source) {
 +
if (typeof target[key] == 'undefined') {
 +
target[key] = source[key];
 +
 
 +
// show missing array entries
 +
if (showMissing === true)  {
 +
if (typeof target[key] == 'string') {
 +
wikEd.config.debugStartUp += '\t\t\t\'' + key + '\': \'' + target[key].replace(/\n/g, '\\n') + '\',\n';
 +
}
 +
}
 +
}
 +
}
 +
}
 +
return;
 +
};
 +
 
 +
 
 +
//
 +
// wikEd.AddToObject: add or replace properties, replace existing values (code copied to wikEdDiff.js)
 +
//
 +
 
 +
wikEd.AddToObject = function (target, source, priority) {
 +
 
 +
if (priority === undefined) {
 +
priority = {};
 +
}
 +
if (typeof target == 'object') {
 +
for (var key in source) {
 +
if (priority[key] !== undefined) {
 +
target[key] = priority[key];
 +
}
 +
else {
 +
target[key] = source[key];
 +
}
 +
}
 +
}
 +
return;
 +
};
 +
 
 +
 
 +
//
 +
// wikEd.InitImage: initialize images, keep pre-defined values (code copied to wikEdDiff.js)
 +
//
 +
 
 +
wikEd.InitImage = function (target, source) {
 +
 
 +
var server = window.location.href.replace(/^(\w+:\/\/.*?)\/.*/, '$1');
 +
var protocol = server.replace(/^(\w+:)\/\/.*/, '$1');
 +
 
 +
for (var key in source) {
 +
if (typeof target[key] == 'undefined') {
 +
 
 +
// remove MediaWiki path prefixes and add local path
 +
if (wikEd.config.useLocalImages === true) {
 +
target[key] = wikEd.config.imagePathLocal + source[key].replace(/^[0-9a-f]+\/[0-9a-f]+\/()/, '');
 +
}
 +
 
 +
// add path
 +
else {
 +
target[key] = wikEd.config.imagePath + source[key];
 +
}
 +
 
 +
// Chrome 33.0.1750.146 m bug, not displaying frame html background image without complete URL
 +
if (/^\/\//.test(target[key]) === true) {
 +
target[key] = protocol + target[key];
 +
}
 +
else if (/^\//.test(target[key]) === true) {
 +
target[key] = server + target[key];
 +
}
 +
}
 +
}
 +
return;
 +
};
 +
 
 +
 
 +
//
 +
// wikEd.Startup: wikEd startup code, called during page load
 +
//
 +
 
 +
wikEd.Startup = function () {
 +
 
 +
// redirect WED shortcut to wikEd.Debug(objectName, object, popup)
 +
window.WED = wikEd.Debug;
 +
 
 +
// extract version info from wikEd.Meta()
 +
var meta = wikEd.Meta.toString();
 +
var regExpMatchVersion = /@version\s+(.*?)[ \t]*\n/.exec(meta);
 +
if ( (regExpMatchVersion !== null) && (regExpMatchVersion[1] !== null) ) {
 +
wikEd.programVersion = regExpMatchVersion[1];
 +
}
 +
var regExpMatchDate = /@date\s+(.*?)[ \t]*\n/.exec(meta);
 +
if ( (regExpMatchDate !== null) && (regExpMatchDate[1] !== null) ) {
 +
wikEd.programDate = regExpMatchDate[1];
 +
}
 +
 
 +
// MediaWiki pages always have their title set, filter out Greasemonkey running on created iframes
 +
if (document.title === '') {
 +
return;
 +
}
 +
 
 +
// check if wikEd has already started up
 +
if (document.getElementsByName('wikEdStartupFlag')[0] !== undefined) {
 +
return;
 +
}
 +
 
 +
// define current window head
 +
wikEd.head = document.getElementsByTagName('head')[0] || null;
 +
 
 +
// set startup flag
 +
var flag = document.createElement('meta');
 +
flag.setAttribute('name', 'wikEdStartupFlag');
 +
wikEd.head.appendChild(flag);
 +
 
 +
// get site of origin (window.location.href is about:blank if Firefox during page load)
 +
var origin = wikEd.head.baseURI;
 +
if (origin === undefined) {
 +
origin = window.location.toString();
 +
}
 +
wikEd.pageOrigin = origin.replace(/^((https?|file):\/\/[^\/?#]*)?.*$/, '$1');
 +
 
 +
// check browser and version
 +
var regExpMatchAgent = window.navigator.userAgent.match(/\b(Firefox|Netscape|SeaMonkey|IceWeasel|IceCat|Fennec|Minefield|BonEcho|GranParadiso|Shiretoko|Namoroka)\W+(\d+\.\d+)/i);
 +
if (regExpMatchAgent !== null) {
 +
wikEd.browserName = 'Mozilla';
 +
wikEd.browserFlavor = regExpMatchAgent[1];
 +
wikEd.browserVersion = parseFloat(regExpMatchAgent[2]);
 +
wikEd.mozilla = true;
 +
}
 +
 
 +
// check for MSIE
 +
else {
 +
regExpMatchAgent = window.navigator.userAgent.match(/(MSIE)\W+(\d+\.\d+)/i);
 +
if (regExpMatchAgent !== null) {
 +
wikEd.browserName = 'MSIE';
 +
wikEd.browserVersion = parseFloat(regExpMatchAgent[2]);
 +
wikEd.msie = true;
 +
}
 +
 
 +
// check for Opera <= version 12 (Opera/9.80 (Windows NT 6.0) Presto/2.12.388 Version/12.14)
 +
else {
 +
regExpMatchAgent = window.navigator.userAgent.match(/\b(Opera)\W+(\d+\.\d+)/i);
 +
if (regExpMatchAgent !== null) {
 +
wikEd.browserName = 'Opera';
 +
wikEd.browserVersion = parseFloat(regExpMatchAgent[2]);
 +
if (wikEd.browserVersion == 9.80) {
 +
var versionMatch = window.navigator.userAgent.match(/(Version)\W+(\d+\.\d+)/i);
 +
if (versionMatch !== null) {
 +
wikEd.browserVersion = parseFloat(regExpMatchAgent[2]);
 +
}
 +
}
 +
wikEd.opera = true;
 +
}
 +
 
 +
// check for Opera >= version 15 (Mozilla/5.0 (Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.52 Safari/537.36 OPR/15.0.1147.100)
 +
else {
 +
regExpMatchAgent = window.navigator.userAgent.match(/\b(OPR)\W+(\d+\.\d+)/i);
 +
if (regExpMatchAgent !== null) {
 +
wikEd.browserName = 'Opera';
 +
wikEd.browserVersion = parseFloat(regExpMatchAgent[2]);
 +
wikEd.opera = true;
 +
}
 +
 
 +
// check for Google Chrome (AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.2.149.30 Safari/525.13)
 +
else {
 +
regExpMatchAgent = window.navigator.userAgent.match(/\b(Chrome)\W+(\d+\.\d+)(\S+)/i);
 +
if (regExpMatchAgent !== null) {
 +
wikEd.browserName = 'Chrome';
 +
wikEd.browserVersion = parseFloat(regExpMatchAgent[2]);
 +
wikEd.browserVersionStr = regExpMatchAgent[ 2 ] + regExpMatchAgent[ 3 ];
 +
wikEd.chrome = true;
 +
}
 +
 
 +
// check for Safari
 +
else {
 +
regExpMatchAgent = window.navigator.userAgent.match(/\b(Safari)\W+(\d+\.\d+)/i);
 +
if (regExpMatchAgent !== null) {
 +
wikEd.browserName = 'Safari';
 +
wikEd.browserVersion = parseFloat(regExpMatchAgent[2]);
 +
wikEd.safari = true;
 +
}
 +
 
 +
// check for other WebKit
 +
else {
 +
regExpMatchAgent = window.navigator.userAgent.match(/\b(WebKit)(GTK\+)?\W+(\d+\.\d+)/i);
 +
if (regExpMatchAgent !== null) {
 +
wikEd.browserName = 'WebKit';
 +
wikEd.browserVersion = parseFloat(regExpMatchAgent[3]);
 +
wikEd.webkit = true;
 +
}
 +
}
 +
}
 +
}
 +
}
 +
}
 +
}
 +
 
 +
// check OS
 +
var regExpMatchOS = window.navigator.platform.match(/^(win|mac|unix|linux)/i);
 +
if (regExpMatchOS !== null) {
 +
wikEd.platform = regExpMatchOS[1].toLowerCase();
 +
}
 +
 
 +
// import customization (try now again after page load for user/skin.js)
 +
if ( (wikEdConfig !== undefined) && (wikEd.wikEdConfigAdded === false) ) {
 +
wikEd.AddToObject(wikEd.config, wikEdConfig);
 +
wikEd.wikEdConfigAdded = true;
 +
}
 +
if ( (wikEdText !== undefined) && (wikEd.wikEdTextAdded === false) ) {
 +
wikEd.AddToObject(wikEd.text, wikEdText, wikEd.config.text);
 +
wikEd.wikEdTextAdded = true;
 +
}
 +
 
 +
// compatibility fixes for older customizations and wikEd-compatibilizations in other scripts
 +
window.wikEdUseWikEd = wikEd.useWikEd;
 +
window.WikEdUpdateTextarea = wikEd.UpdateTextarea;
 +
window.WikEdUpdateFrame = wikEd.UpdateFrame;
 +
window.WikEdGetText = wikEd.GetText;
 +
window.WikEdEditButton = wikEd.EditButton;
 +
 
 +
// check if this runs under Greasemonkey
 +
if (typeof GM_info == 'object') {
 +
wikEd.greasemonkey = true;
 +
}
 +
 
 +
// parse global-context (MediaWiki) variables into hash (for Greasemonkey)
 +
var globalNames = ['skin', 'wgServer', 'wgTitle', 'wgCanonicalNamespace', 'wgArticlePath', 'wgScript', 'wgScriptPath', 'wgUserName', 'wgCurRevisionId', 'wgContentLanguage', 'wgUserLanguage', 'wgEnableAPI', 'wgPageName', 'wgNamespaceIds', 'wgFormattedNamespaces', 'wgUseAutomaticEditSummaries', 'wgVersion', 'wgPageContentModel'];
 +
if (wikEd.greasemonkey === true) {
 +
globalNames.push('wikEdConfig', 'wikEdText');
 +
}
 +
 
 +
// copy custom config settings and text after values have arrived
 +
var gotGlobalsHook = [
 +
function() {
 +
if ( (typeof wikEd.wikiGlobals.wikEdConfig == 'object') && (wikEd.wikEdConfigAdded === false) ) {
 +
wikEd.AddToObject(wikEd.config, wikEd.wikiGlobals.wikEdConfig);
 +
wikEd.wikEdConfigAdded = true;
 +
}
 +
if ( (typeof wikEd.wikiGlobals.wikEdText == 'object') && (wikEd.wikEdTextAdded === false) ) {
 +
wikEd.AddToObject(wikEd.text, wikEd.wikiGlobals.wikEdText, wikEd.config.text);
 +
wikEd.wikEdTextAdded = true;
 +
}
 +
return;
 +
}
 +
];
 +
 
 +
// and load translations when done
 +
if ( (wikEd.config.loadTranslation === true) && (wikEd.loadingTranslation === false) ) {
 +
gotGlobalsHook.push(wikEd.LoadTranslations);
 +
}
 +
 
 +
// set listener for GetGlobals messaging
 +
window.addEventListener('message', wikEd.GetGlobalsReceiver, false);
 +
 
 +
// parse globals (asynchronous)
 +
wikEd.GetGlobals(globalNames, gotGlobalsHook);
 +
 
 +
// schedule the setup routine; readyState interactive gives GM security error
 +
if (document.readyState == 'complete') {
 +
wikEd.Setup();
 +
}
 +
 
 +
// with DOMContentLoaded event wikEd does not load for first (uncached) section edit
 +
else {
 +
window.addEventListener('load', wikEd.Setup, false);
 +
}
 +
 
 +
return;
 +
};
 +
 
 +
 
 +
//
 +
// wikEd.LoadTranslations: load external wikEd translation and language settings
 +
//
 +
 
 +
wikEd.LoadTranslations = function () {
 +
 
 +
if ( (wikEd.config.loadTranslation === true) && (wikEd.loadingTranslation === false) ) {
 +
var contentLang = wikEd.wikiGlobals.wgContentLanguage || '';
 +
var userLang = wikEd.wikiGlobals.wgUserLanguage || '';
 +
if ( (wikEd.config.languageDefault !== '') || (userLang !== '') || (contentLang !== '') ) {
 +
 
 +
// simplified Chinese
 +
if (contentLang == 'zh') {
 +
contentLang = 'zh-hans';
 +
}
 +
if ( (userLang == 'zh') || (userLang == 'zh-cn') || (userLang == 'zh-sg') ) {
 +
userLang = 'zh-hans';
 +
}
 +
 
 +
// traditional Chinese
 +
else if ( (userLang == 'zh-hk') || (userLang == 'zh-tw') ) {
 +
userLang = 'zh-hant';
 +
}
 +
 
 +
wikEd.InitTranslations();
 +
var scriptUrl = wikEd.config.translations[wikEd.config.languageDefault] || '';
 +
if (scriptUrl === '') {
 +
scriptUrl = wikEd.config.translations[userLang] || '';
 +
if (scriptUrl === '') {
 +
scriptUrl = wikEd.config.translations[contentLang] || '';
 +
}
 +
}
 +
if (scriptUrl !== '') {
 +
wikEd.AppendScript(scriptUrl, function () {
 +
 
 +
// copy custom text after values have arrived
 +
var gotGlobalsHook = function () {
 +
wikEd.AddToObject(wikEd.text, wikEd.wikiGlobals.wikEdText, wikEd.config.text);
 +
return;
 +
};
 +
 
 +
// parse globals (asynchronous)
 +
wikEd.GetGlobals(['wikEdText'], [gotGlobalsHook]);
 +
wikEd.loadingTranslation = true;
 +
});
 +
}
 +
}
 +
}
 +
return;
 +
};
 +
 
 +
 
 +
//
 +
// wikEd.Setup: basic setup routine, scheduled after DOM or page load
 +
//
 +
 
 +
wikEd.Setup = function () {
 +
 
 +
document.removeEventListener('DOMContentLoaded', wikEd.Setup, false);
 +
 
 +
window.removeEventListener('load', wikEd.Setup, false);
 +
 
 +
// check if wikEd has already set up
 +
if (document.getElementsByName('wikEdSetupFlag')[0] !== undefined) {
 +
return;
 +
}
 +
 
 +
// set setup flag
 +
var flag = document.createElement('meta');
 +
flag.setAttribute('name', 'wikEdSetupFlag');
 +
wikEd.head.appendChild(flag);
 +
 
 +
// import customization (try later again after page load for user/skin.js)
 +
if ( (typeof wikEdConfig == 'object') && (wikEd.wikEdConfigAdded === false) ) {
 +
wikEd.AddToObject(wikEd.config, wikEdConfig);
 +
wikEd.wikEdConfigAdded = true;
 +
}
 +
if ( (typeof wikEdText == 'object') && (wikEd.wikEdTextAdded === false) ) {
 +
wikEd.AddToObject(wikEd.text, wikEdText, wikEd.config.text);
 +
wikEd.wikEdTextAdded = true;
 +
}
 +
 
 +
// detect already loaded external scripts
 +
if (wikEd.externalScripts === null) {
 +
wikEd.externalScripts = [];
 +
var pageScripts = document.getElementsByTagName('script');
 +
for (var i = 0; i < pageScripts.length; i ++) {
 +
var scriptSrc = pageScripts[i].src;
 +
var regExpMatchName = scriptSrc.match(/\btitle=([^&]*)/);
 +
if (regExpMatchName === null) {
 +
regExpMatchName = scriptSrc.match(/\/([^\/]*?)($|\?)/);
 +
}
 +
if (regExpMatchName !== null) {
 +
var scriptName = regExpMatchName[1] || '';
 +
if (scriptName !== '') {
 +
 
 +
// ignore other diff.js scripts
 +
if ( (scriptName == 'diff.js') && (scriptSrc != wikEd.config.diffScriptSrc) ) {
 +
continue;
 +
}
 +
 
 +
// ignore resource loader
 +
if (scriptName == 'load.php') {
 +
continue;
 +
}
 +
 
 +
wikEd.externalScripts[scriptName] = pageScripts[i];
 +
wikEd.externalScriptsString += scriptName + '\n';
 +
}
 +
}
 +
}
 +
}
 +
 
 +
// detect developer version
 +
if (wikEd.externalScripts['wikEd_dev.js'] !== undefined) {
 +
wikEd.testVersion = true;
 +
}
 +
 
 +
// exit if executed as Greasemonkey script if wiki user script is available
 +
if (typeof GM_getValue == 'function') {
 +
if (wikEd.externalScripts['wikEd.js'] !== undefined) {
 +
wikEd.greasemonkey = false;
 +
return;
 +
}
 +
else {
 +
wikEd.greasemonkey = true;
 +
}
 +
}
 +
 
 +
// detect wikEd running as a gadget
 +
if (wikEd.config.gadget === null) {
 +
if (wikEd.externalScripts['MediaWiki:Gadget-wikEd.js'] !== undefined) {
 +
wikEd.config.gadget = true;
 +
}
 +
}
 +
 
 +
// set installation type
 +
if (wikEd.config.gadget === true) {
 +
wikEd.installationType += ' G';
 +
}
 +
else if (wikEd.greasemonkey === true) {
 +
wikEd.installationType += ' GM';
 +
}
 +
 
 +
// detect MediaWiki page and its skin
 +
wikEd.InitMediaWikiSkinIds();
 +
for (var skin in wikEd.config.mediaWikiSkinIds) {
 +
if (Object.prototype.hasOwnProperty.call(wikEd.config.mediaWikiSkinIds, skin) === true) {
 +
var logoContainerId = wikEd.config.mediaWikiSkinIds[skin][0];
 +
var logoToList = wikEd.config.mediaWikiSkinIds[skin][1];
 +
var rearrange = wikEd.config.mediaWikiSkinIds[skin][2];
 +
var skinIds = wikEd.config.mediaWikiSkinIds[skin][3];
 +
var enableLocalPreview = wikEd.config.mediaWikiSkinIds[skin][4];
 +
for (var i = 0; i < skinIds.length; i ++) {
 +
if (document.getElementById(skinIds[i]) === null) {
 +
break;
 +
}
 +
}
 +
if (i == skinIds.length) {
 +
wikEd.logoContainerId = logoContainerId;
 +
wikEd.skin = skin;
 +
wikEd.rearrange = rearrange;
 +
wikEd.logoToList = logoToList;
 +
wikEd.enableLocalPreview = enableLocalPreview;
 +
break;
 +
}
 +
}
 +
}
 +
 
 +
// not a MediaWiki page
 +
if (wikEd.skin === '') {
 +
return;
 +
}
 +
 
 +
// initialize user configurable variables
 +
wikEd.InitGlobalConfigs();
 +
 
 +
// import custom text and translations
 +
wikEd.AddToObject(wikEd.config.text, wikEd.text);
 +
 
 +
// do not rearrange page elements
 +
if (wikEd.config.noRearrange !== false) {
 +
wikEd.rearrange = false;
 +
}
 +
 
 +
// initialize non-configurable variables
 +
wikEd.InitGlobals();
 +
 
 +
// check for updates
 +
wikEd.AutoUpdate();
 +
 
 +
// initialize images (needed here for logo)
 +
wikEd.InitImages();
 +
 
 +
// load css for edit and non-edit pages
 +
wikEd.InitMainCSS();
 +
 
 +
// add stylesheet definitions
 +
wikEd.ApplyCSS(document, wikEd.config.mainCSS);
 +
 
 +
// add image path to image filename
 +
if (wikEd.logo === null) {
 +
 
 +
// create logo
 +
wikEd.logo = document.createElement('img');
 +
wikEd.logo.id = 'wikEdLogoImg';
 +
 
 +
// insert logo into page
 +
var logoContainer;
 +
if (wikEd.logoContainerId !== '') {
 +
logoContainer = document.getElementById(wikEd.logoContainerId);
 +
}
 +
if (logoContainer !== null) {
 +
 
 +
// logo as last element of specified list (e.g. monobook, simple, myskin, gumax)
 +
if (wikEd.logoToList === true) {
 +
wikEd.logoList = document.createElement('li');
 +
wikEd.logoList.id = 'wikEdLogoList';
 +
wikEd.logoList.className = 'wikEdLogoList';
 +
wikEd.logoList.appendChild(wikEd.logo);
 +
var list;
 +
if (logoContainer.tagName == 'UL') {
 +
list = logoContainer;
 +
}
 +
else {
 +
list = logoContainer.getElementsByTagName('ul')[0];
 +
}
 +
if (list !== undefined) {
 +
list.appendChild(wikEd.logoList);
 +
wikEd.logo.className = 'wikEdLogo';
 +
}
 +
}
 +
 
 +
// logo as last child of specified element
 +
else {
 +
logoContainer.appendChild(wikEd.logo);
 +
wikEd.logo.className = 'wikEdLogo';
 +
}
 +
}
 +
 
 +
// logo as first page element, fallback for undetected skin
 +
if (wikEd.logo.className === '') {
 +
document.body.insertBefore(wikEd.logo, document.body.firstChild);
 +
wikEd.logo.className = 'wikEdLogoFallBack';
 +
}
 +
 
 +
// add event listeners to logo
 +
wikEd.logo.addEventListener('click', wikEd.MainSwitch, true);
 +
wikEd.logo.addEventListener('click', wikEd.DebugInfo, true);
 +
}
 +
 
 +
// page loaded flag for dynamically loaded scripts
 +
wikEd.pageLoaded = true;
 +
 
 +
// load the external wikEd diff library script if not already done
 +
if ( (wikEd.config.loadDiffScript === true) && (wikEd.externalScripts['diff.js'] === undefined) ) {
 +
if (WikEdDiff === undefined) {
 +
var sep = '&';
 +
if (wikEd.config.diffScriptSrc.indexOf('?') == -1) {
 +
sep = '?';
 +
}
 +
wikEd.externalScripts['diff.js'] = wikEd.AppendScript(wikEd.config.diffScriptSrc + sep + wikEd.programVersion);
 +
}
 +
}
 +
 
 +
// load the external wikEdDiff script if not already done
 +
if ( (wikEd.config.loadDiff === true) && (wikEd.externalScripts['wikEdDiff.js'] === undefined) ) {
 +
if (wikEd.Diff === undefined) {
 +
var sep = '&';
 +
if (wikEd.config.diffSrc.indexOf('?') == -1) {
 +
sep = '?';
 +
}
 +
wikEd.externalScripts['wikEdDiff.js'] = wikEd.AppendScript(wikEd.config.diffSrc + sep + wikEd.programVersion);
 +
}
 +
}
 +
 
 +
// init syntax highlighting regExp object
 +
wikEd.HighlightSyntaxInit();
 +
 
 +
// check if disabled
 +
wikEd.disabled = wikEd.GetSavedSetting('wikEdDisabled', wikEd.config.disabledPreset);
 +
if (wikEd.disabled === true) {
 +
wikEd.useWikEd = false;
 +
window.wikEdUseWikEd = wikEd.useWikEd;
 +
wikEd.SetLogo();
 +
return;
 +
}
 +
 
 +
// location search string function: put all used images and icons on an empty page
 +
if (/(\?|&)wikEd=iconPage\b/i.test(window.location.search) === true) {
 +
var str = wikEd.config.text.iconPage;
 +
for (var imageKey in wikEd.config.image) {
 +
if (Object.prototype.hasOwnProperty.call(wikEd.config.image, imageKey) === true) {
 +
var imageAddress = wikEd.config.image[imageKey];
 +
if (typeof imageAddress == 'string') {
 +
str += '<img src="' + imageAddress + '"> ';
 +
}
 +
}
 +
}
 +
document.body.innerHTML = str;
 +
return;
 +
}
 +
 
 +
// continue setup
 +
wikEd.TurnOn(true);
 +
 
 +
return;
 +
};
 +
 
 +
 
 +
//
 +
// wikEd.TurnOn: continue setup, can be called repeatedly
 +
//
 +
 
 +
wikEd.TurnOn = function (scrollToEditFocus) {
 +
 
 +
// check if setup was already run
 +
if (wikEd.turnedOn === true) {
 +
return;
 +
}
 +
 
 +
// set error logo
 +
wikEd.SetLogo('error');
 +
 
 +
// check for active code editor and .js or .css page
 +
wikEd.CodeEditorCheck();
 +
 
 +
// no id, no wikEd
 +
if (window.navigator.appName === null) {
 +
wikEd.browserNotSupported = true;
 +
}
 +
 
 +
// check browser versions
 +
switch (wikEd.browserName) {
 +
 
 +
// check Mozilla version
 +
case 'Mozilla':
 +
if (
 +
(wikEd.browserFlavor == 'Firefox') && (wikEd.browserVersion < 1.5) ||
 +
(wikEd.browserFlavor == 'Netscape') && (wikEd.browserVersion < 8.0) ||
 +
(wikEd.browserFlavor == 'SeaMonkey') && (wikEd.browserVersion < 1.0)
 +
) {
 +
wikEd.browserNotSupported = true;
 +
}
 +
break;
 +
 
 +
// check MSIE version
 +
case 'MSIE':
 +
wikEd.browserNotSupported = true;
 +
break;
 +
 
 +
// check Opera version
 +
case 'Opera':
 +
if (wikEd.browserVersion < 15) {
 +
 
 +
// too buggy (inserthtml, parentNode...)
 +
wikEd.browserNotSupported = true;
 +
}
 +
break;
 +
 
 +
// check Google Chrome version
 +
case 'Chrome':
 +
if (wikEd.browserVersion < 0.2) {
 +
wikEd.browserNotSupported = true;
 +
}
 +
 
 +
// Chrome bug https://code.google.com/p/chromium/issues/detail?id=528382, version 45.0.2454.85 - 45.0.2454.93
 +
else if (wikEd.browserVersion == 45) {
 +
var regExpMatch = /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/.exec( wikEd.browserVersionStr );
 +
if ( ( regExpMatch !== null ) && ( regExpMatch[ 3 ] == 2454 ) && ( regExpMatch[ 4 ] >= 85 ) && ( regExpMatch[ 4 ] < 93 ) ) {
 +
wikEd.browserNotSupported = true;
 +
}
 +
}
 +
break;
 +
 
 +
// check Safari version
 +
case 'Safari':
 +
if (wikEd.browserVersion < 500) {
 +
wikEd.browserNotSupported = true;
 +
}
 +
break;
 +
}
 +
 
 +
// browser or version not supported, set error message and exit
 +
if ( (wikEd.browserNotSupported === true) && (wikEd.config.skipBrowserTest === false) ) {
 +
wikEd.disabled = true;
 +
wikEd.SetLogo('browser');
 +
return;
 +
}
 +
 
 +
// get form elements
 +
var array;
 +
array = document.getElementsByName('wpEdittime');
 +
if (array[0] !== undefined) {
 +
wikEd.edittime = array[0].value;
 +
}
 +
array = document.getElementsByName('wpStarttime');
 +
if (array[0] !== undefined) {
 +
wikEd.starttime = array[0].value;
 +
}
 +
array = document.getElementsByName('wpAutoSummary');
 +
if (array[0] !== undefined) {
 +
wikEd.autoSummary = array[0].value;
 +
}
 +
array = document.getElementsByName('wpEditToken');
 +
if (array[0] !== undefined) {
 +
wikEd.editToken = array[0].value;
 +
}
 +
 
 +
// page type detection
 +
 
 +
// detect custom edit page
 +
if (wikEd.config.customEditFormId !== '') {
 +
wikEd.editForm = document.getElementById(wikEd.config.customEditFormId);
 +
}
 +
if (wikEd.config.customTextAreaId !== '') {
 +
wikEd.textarea = document.getElementById(wikEd.config.customTextAreaId);
 +
}
 +
if (wikEd.config.customSaveButtonId !== '') {
 +
wikEd.saveButton = document.getElementById(wikEd.customwikEdSaveButtonId);
 +
}
 +
 
 +
// detect standard edit page
 +
if (wikEd.textarea === null) {
 +
 
 +
// HotCat injects this textarea into non-edit pages
 +
var textarea = document.getElementsByName('wpTextbox1')[0];
 +
if ( (textarea !== undefined) && (textarea.type != 'hidden') ) {
 +
wikEd.textarea = textarea;
 +
}
 +
}
 +
if (wikEd.editForm === null) {
 +
wikEd.editForm = document.getElementById('editform');
 +
}
 +
if (wikEd.saveButton === null) {
 +
wikEd.saveButton = document.getElementById('wpSave');
 +
}
 +
wikEd.diffPreviewButton = document.getElementById('wpDiff');
 +
wikEd.previewButton = document.getElementById('wpPreview');
 +
wikEd.editArticle = true;
 +
 
 +
// detect read-only edit page
 +
if ( (wikEd.textarea !== null) && (wikEd.editForm === null) && (wikEd.saveButton === null) ) {
 +
wikEd.editReadOnly = true;
 +
wikEd.editArticle = false;
 +
wikEd.readOnly = true;
 +
}
 +
 
 +
// detect semantic forms extension
 +
else if (wikEd.textarea === null) {
 +
wikEd.editForm = document.getElementById('sfForm');
 +
wikEd.textarea = document.getElementById('sf_free_text');
 +
if ( (wikEd.editForm !== null) && (wikEd.textarea !== null) ) {
 +
wikEd.editArticle = false;
 +
wikEd.editSemanticForm = true;
 +
}
 +
 
 +
// detect edit raw watchlist page
 +
else {
 +
wikEd.textarea = document.getElementById('mw-input-wpTitles');
 +
 
 +
// old version
 +
if (wikEd.textarea === null) {
 +
wikEd.textarea = document.getElementById('titles');
 +
}
 +
if (wikEd.textarea !== null) {
 +
wikEd.editArticle = false;
 +
wikEd.editWatchlist = true;
 +
 
 +
// get watchlist edit form
 +
var node = wikEd.textarea;
 +
while (node !== null) {
 +
node = node.parentNode;
 +
if (node.tagName == 'FORM') {
 +
break;
 +
}
 +
}
 +
wikEd.editForm = node;
 +
 
 +
// get watchlist submit button
 +
var saveButton = document.getElementsByClassName('mw-htmlform-submit')[0];
 +
if ( (saveButton === undefined) && (wikEd.editForm !== null) ) {
 +
wikEd.saveButton = saveButton;
 +
var submits = wikEd.editForm.getElementsByTagName('input');
 +
for (var i = 0; i < submits.length; i ++) {
 +
if (submits[i].type == 'submit') {
 +
wikEd.saveButton = submits[i];
 +
break;
 +
}
 +
}
 +
}
 +
}
 +
}
 +
 
 +
// detect upload page
 +
if ( (wikEd.textarea === null) || (wikEd.editForm === null) || (wikEd.saveButton === null) ) {
 +
var textarea = document.getElementsByName('wpUploadDescription')[0];
 +
var editForm = document.getElementById('mw-upload-form');
 +
var saveButton = document.getElementsByName('wpUpload')[0];
 +
if ( (textarea !== undefined) && (editForm !== null) && (saveButton !== undefined) ) {
 +
wikEd.textarea = textarea;
 +
wikEd.editForm = editForm;
 +
wikEd.saveButton = saveButton;
 +
wikEd.editArticle = false;
 +
wikEd.editUpload = true;
 +
wikEd.rearrange = false;
 +
}
 +
}
 +
 
 +
// detect view and restore deleted pages (no id on textarea)
 +
if ( (wikEd.textarea === null) || (wikEd.editForm === null) || (wikEd.saveButton === null) ) {
 +
var forms = document.getElementsByTagName('form');
 +
var i = 0;
 +
var form;
 +
while ( (form = forms[i ++]) !== undefined) {
 +
if (/\btitle=Special:Undelete\b/i.test(form.action) === true) {
 +
var textareas = document.getElementsByTagName('textarea');
 +
var j = 0;
 +
var textarea;
 +
while ( (textarea = textareas[j ++]) !== undefined) {
 +
if (textarea.readOnly === true) {
 +
wikEd.textarea = textarea;
 +
wikEd.previewButton = document.getElementsByName('preview')[0] || null;
 +
wikEd.editArticle = false;
 +
wikEd.viewDeleted = true;
 +
wikEd.rearrange = true;
 +
break;
 +
}
 +
}
 +
}
 +
break;
 +
}
 +
}
 +
}
 +
 
 +
// set page detection error indicator
 +
if (wikEd.textarea === null) {
 +
wikEd.SetLogo();
 +
return;
 +
}
 +
 
 +
// do not turn on when code editor is active
 +
if (wikEd.useCodeEditor === true) {
 +
wikEd.disabled = true;
 +
wikEd.SetLogo('incompatible', 'Code Editor');
 +
return;
 +
}
 +
 
 +
// check if the textarea is read-only
 +
if (wikEd.config.skipReadOnlyTest === false) {
 +
if ( (wikEd.textarea.getAttribute('readonly') !== null) || (wikEd.saveButton === null) ) {
 +
wikEd.readOnly = true;
 +
}
 +
}
 +
 
 +
// check for section edits
 +
var section = document.getElementsByName('wpSection');
 +
if (
 +
section !== null &&
 +
section.length > 0 &&
 +
/^\d+$/.test(section[0].value) === true
 +
) {
 +
wikEd.editSection = section[0].value;
 +
}
 +
 
 +
// get missing wg variables from footer link (code copied to wikEdDiff.js)
 +
if (wikEd.wikiGlobals.wgArticlePath === undefined) {
 +
var printfooter = document.body.getElementsByClassName('printfooter')[0];
 +
if (printfooter !== undefined) {
 +
var articleLink = printfooter.getElementsByTagName('a')[0];
 +
if (articleLink !== undefined) {
 +
var regExpMatch = /^(https?:\/\/[^\/]*)(\/([^\/]*\/)*)([^\/]*)$/.exec(articleLink.href);
 +
if (regExpMatch !== null) {
 +
wikEd.wikiGlobals.wgServer = regExpMatch[1];
 +
wikEd.wikiGlobals.wgArticlePath = regExpMatch[1] + regExpMatch[2] + '$1';
 +
wikEd.wikiGlobals.wgPageName = regExpMatch[4] || '';
 +
wikEd.wikiGlobals.wgTitle = decodeURIComponent( regExpMatch[4].replace(/_/g, ' ') );
 +
}
 +
}
 +
}
 +
}
 +
 
 +
// get missing wg variables from form action url
 +
if (wikEd.wikiGlobals.wgScript === undefined) {
 +
var form = wikEd.editForm;
 +
if ( form !== null && form.action.indexOf( '/Special:EditWatchlist' ) !== -1 ) {
 +
form = document.getElementById( 'searchform' );
 +
}
 +
if ( form !== null && form.action.indexOf( '/index.php' ) !== -1 ) {
 +
wikEd.wikiGlobals.wgScript = form.action.replace(/^https?:\/\/[^\/]*|\?.*$/g, '');
 +
wikEd.wikiGlobals.wgScriptPath = wikEd.wikiGlobals.wgScript.replace(/\/index\.php/, '');
 +
}
 +
}
 +
 
 +
// get current page name
 +
wikEd.pageName = wikEd.wikiGlobals.wgPageName;
 +
 
 +
// get current namespace
 +
if (wikEd.pageName !== null) {
 +
var colonPos = wikEd.pageName.indexOf(':');
 +
if (colonPos == -1) {
 +
wikEd.pageNamespace = '';
 +
}
 +
else {
 +
wikEd.pageNamespace = wikEd.pageName.substr(0, colonPos);
 +
}
 +
}
 +
 
 +
// get MediaWiki file paths
 +
wikEd.GetPaths();
 +
 
 +
// check if we can call external API for redlink detection
 +
var regExpDomains = new RegExp('//(.*?\\.)?(' + wikEd.config.externalApiDomains.replace(/\s*,\s*/g, '|').replace(/\./g, '\\.') + '$)', 'g');
 +
wikEd.useExternalApi = regExpDomains.test(window.location.origin);
 +
 
 +
// get page elements
 +
wikEd.catLinks = document.getElementById('catlinks');
 +
 
 +
// check if mw.loader is available
 +
if ( (window.mw !== undefined) && (window.mw.loader !== undefined) && (window.mw.config !== undefined) ) {
 +
wikEd.loader = true;
 +
}
 +
 
 +
// get wikibase defaults for linkification
 +
wikEd.wikibase.currentSite = {};
 +
wikEd.wikibase.currentSite.globalSiteId = wikEd.config.wbGlobalSiteId;
 +
wikEd.wikibase.repoUrl = wikEd.config.wbRepoUrl;
 +
wikEd.wikibase.repoArticlePath = wikEd.config.wbRepoArticlePath;
 +
 
 +
// get wikibase infos
 +
if (wikEd.loader === true) {
 +
 
 +
// prevent error if module is not installed
 +
try {
 +
window.mw.loader.using('wikibase.client.currentSite', function () {
 +
wikEd.wikibase.currentSite = window.mw.config.get('wbCurrentSite');
 +
});
 +
}
 +
catch (exception) {
 +
}
 +
 
 +
try {
 +
window.mw.loader.using('wikibase.repoAccess', function () {
 +
wikEd.wikibase.repoUrl = window.mw.config.get('wbRepoUrl');
 +
wikEd.wikibase.repoArticlePath = window.mw.config.get('wbRepoArticlePath');
 +
});
 +
}
 +
catch (exception) {
 +
}
 +
}
 +
 
 +
// initialize frame css, main css, buttons, and button bars
 +
wikEd.InitFrameCSS();
 +
wikEd.InitMainEditCSS();
 +
wikEd.InitButton();
 +
wikEd.InitButtonKey();
 +
wikEd.InitButtonBar();
 +
wikEd.InitHistoryLength();
 +
wikEd.InitIncompatibleScripts();
 +
 
 +
// check for incompatible scripts
 +
var incompatible = '';
 +
if (wikEd.config.skipScriptTest === false) {
 +
for (var key in wikEd.config.incompatibleScripts) {
 +
if (Object.prototype.hasOwnProperty.call(wikEd.config.incompatibleScripts, key) === true) {
 +
var regExp = new RegExp(wikEd.config.incompatibleScripts[key].replace(/\.js$/g, ''), 'gim');
 +
if (regExp.test(wikEd.externalScriptsString) === true) {
 +
if (incompatible !== '') {
 +
incompatible += ', ';
 +
}
 +
incompatible += key;
 +
}
 +
}
 +
}
 +
}
 +
 
 +
// detect incompatible add-ons
 +
if (wikEd.config.skipAddonTest === false) {
 +
 
 +
// Ginger add-on breaks undo history, corrupts text (<tag><!-- -->)
 +
if (document.body.getAttribute('ginger_software_stylesheet') !== null) {
 +
if (incompatible !== '') {
 +
incompatible += ', ';
 +
}
 +
incompatible += 'Ginger';
 +
}
 +
}
 +
 
 +
// incompatible script or add-on error
 +
if (incompatible !== '') {
 +
wikEd.disabled = true;
 +
wikEd.SetLogo('incompatible', incompatible);
 +
return;
 +
}
 +
 
 +
// define Unicode characters for fixing function
 +
wikEd.InitUnicode();
 +
 
 +
// detect if we add a new section (+ tab)
 +
if (/(\?|&)section=new\b/.test(window.location.search) === true) {
 +
wikEd.addNewSection = true;
 +
}
 +
else {
 +
var section = document.getElementsByName('wpSection');
 +
if ( (section[0] !== undefined) && (section[0].value == 'new') ) {
 +
wikEd.addNewSection = true;
 +
}
 +
}
 +
 
 +
// get initial textarea dimensions
 +
wikEd.textareaBorderHeight = parseInt(wikEd.GetStyle(wikEd.textarea, 'borderTopWidth'), 10) + parseInt(wikEd.GetStyle(wikEd.textarea, 'borderBottomWidth'), 10);
 +
if (wikEd.GetStyle(wikEd.textarea, 'display') != 'none') {
 +
wikEd.textareaOffsetHeightInitial = wikEd.textarea.offsetHeight;
 +
}
 +
else {
 +
wikEd.textareaOffsetHeightInitial = wikEd.textarea.parentNode.clientHeight;
 +
}
 +
wikEd.textareaOffsetHeightInitial = wikEd.textarea.offsetHeight;
 +
wikEd.textareaHeight = (wikEd.textarea.offsetHeight - wikEd.textareaBorderHeight) + 'px';
 +
wikEd.textareaWidth = '100%';
 +
 
 +
// setup the undo buffers and save the original text for local changes view
 +
wikEd.origVersion = wikEd.textarea.value;
 +
 
 +
// add stylesheet definitions
 +
wikEd.ApplyCSS(document, wikEd.config.mainEditCSS);
 +
 
 +
// get button settings from saved settings
 +
wikEd.using = wikEd.GetSavedSetting('wikEdSummaryUsing', wikEd.config.usingPreset);
 +
wikEd.useWikEd = ! wikEd.GetSavedSetting('wikEdUseClassic', ! wikEd.config.useWikEdPreset);
 +
wikEd.highlightSyntax = ! wikEd.GetSavedSetting('wikEdSyntaxOff', ! wikEd.config.highlightSyntaxPreset);
 +
wikEd.fullScreenMode = wikEd.GetSavedSetting('wikEdFullscreen', wikEd.config.fullScreenModePreset);
 +
wikEd.closeToolbar = wikEd.GetSavedSetting('wikEdCloseToolbar', wikEd.config.closeToolbarPreset);
 +
wikEd.refHide = wikEd.GetSavedSetting('wikEdRefHide', wikEd.config.refHidePreset);
 +
window.wikEdUseWikEd = wikEd.useWikEd;
 +
if (wikEd.config.tableMode === true) {
 +
wikEd.tableMode = wikEd.refHide;
 +
}
 +
else {
 +
wikEd.tableMode = false;
 +
}
 +
 
 +
// detect preview page
 +
if (/(\?|&)action=submit\b/.test(window.location.search) === true) {
 +
wikEd.previewPage = true;
 +
}
 +
 
 +
// disable wikEd for Lupin's autoedit scripts
 +
if (/(\?|&)autoedit=/.test(window.location.search) === true) {
 +
wikEd.useWikEd = false;
 +
window.wikEdUseWikEd = wikEd.useWikEd;
 +
}
 +
 
 +
// disable wikEd for .js and .css pages
 +
if ( (wikEd.jsPage === true) || (wikEd.cssPage === true) ) {
 +
wikEd.noSpellcheck = true;
 +
if (wikEd.origVersion.length > 20000) {
 +
wikEd.useWikEd = false;
 +
window.wikEdUseWikEd = wikEd.useWikEd;
 +
}
 +
else {
 +
wikEd.highlightSyntax = false;
 +
}
 +
}
 +
 
 +
// disable highlighting for module namespace (Scribunto/Lua templates)
 +
if (wikEd.wikiGlobals.wgCanonicalNamespace == 'Module') {
 +
wikEd.noSpellcheck = true;
 +
wikEd.highlightSyntax = false;
 +
}
 +
 
 +
// no spellcheck for watchlist editing
 +
if (wikEd.editWatchlist === true) {
 +
wikEd.noSpellcheck = true;
 +
}
 +
 
 +
// disable spellchecker for textarea
 +
if (wikEd.noSpellcheck === true) {
 +
wikEd.textarea.setAttribute('spellcheck', false);
 +
}
 +
 
 +
// preset frame related styles to avoid browser crashes
 +
var styleFrameWrapperPosition;
 +
var styleFrameWrapperVisibility;
 +
var styleTextareaWrapperPosition;
 +
var styleTextareaWrapperVisibility;
 +
if (wikEd.useWikEd === true) {
 +
styleFrameWrapperPosition = 'static';
 +
styleFrameWrapperVisibility = 'visible';
 +
styleTextareaWrapperPosition = 'absolute';
 +
styleTextareaWrapperVisibility = 'hidden';
 +
}
 +
else {
 +
styleFrameWrapperPosition = 'absolute';
 +
styleFrameWrapperVisibility = 'hidden';
 +
styleTextareaWrapperPosition = 'static';
 +
styleTextareaWrapperVisibility = 'visible';
 +
}
 +
 
 +
// find proper insertion point of input wrapper
 +
 
 +
// inside the wikiEditor interface
 +
var wikiEditor = document.body.getElementsByClassName('wikiEditor-ui')[0];
 +
if (wikiEditor !== undefined) {
 +
wikEd.wikiEditor = wikiEditor;
 +
wikEd.wikiEditorFrame = wikEd.wikiEditor.getElementsByTagName('IFRAME')[0] || null;
 +
wikEd.wikiEditorTop = document.body.getElementsByClassName('wikiEditor-ui-top')[0] || null;
 +
wikEd.wikiEditorLeft = document.body.getElementsByClassName('wikiEditor-ui-left')[0] || null;
 +
wikEd.wikiEditorBar = document.body.getElementsByClassName('wikiEditor-ui-toolbar')[0] || null;
 +
wikEd.wikiEditorBottom = document.body.getElementsByClassName('wikiEditor-ui-bottom')[0] || null;
 +
wikEd.wikiEditorText = document.body.getElementsByClassName('wikiEditor-ui-text')[0] || null;
 +
wikEd.textareaContainer = wikEd.wikiEditor;
 +
if (wikEd.wikiEditorBar === null) {
 +
wikEd.SetLogo('incompatible', 'WikiEditor (delayed)');
 +
return;
 +
}
 +
}
 +
 
 +
// before original textarea container (multiple nested containers for semantic forms)
 +
else {
 +
var node = wikEd.textarea;
 +
var parent = node.parentNode;
 +
while (wikEd.GetFirstChildNode(parent) == wikEd.GetLastChildNode(parent) ) {
 +
if (/^(SPAN|DIV|P)$/.test(parent.nodeName) === false) {
 +
break;
 +
}
 +
node = parent;
 +
parent = node.parentNode;
 +
}
 +
wikEd.textareaContainer = node;
 +
}
 +
 
 +
// create input wrapper, contains the whole wikEd and wikiEditor user interface, is the fullscreen container
 +
wikEd.inputWrapper = document.createElement('div');
 +
wikEd.inputWrapper.id = 'wikEdInputWrapper';
 +
wikEd.inputWrapper.className = 'wikEdInputWrapper';
 +
if (wikEd.wikiEditor !== null) {
 +
wikEd.inputWrapper = wikEd.wikiEditor.parentNode.insertBefore(wikEd.inputWrapper, wikEd.wikiEditor);
 +
wikEd.inputWrapper.appendChild(wikEd.wikiEditor);
 +
}
 +
else {
 +
wikEd.textareaContainer.parentNode.insertBefore(wikEd.inputWrapper, wikEd.textareaContainer);
 +
}
 +
 
 +
// create editor wrapper, contains captcha, toolbar, debug, buttons bar, textarea, toc, but not the summary
 +
wikEd.editorWrapper = document.createElement('div');
 +
wikEd.editorWrapper.id = 'wikEdEditorWrapper';
 +
wikEd.editorWrapper.className = 'wikEdEditorWrapper';
 +
if (wikEd.wikiEditor !== null) {
 +
wikEd.wikiEditor.parentNode.insertBefore(wikEd.editorWrapper, wikEd.wikiEditor);
 +
wikEd.editorWrapper.appendChild(wikEd.wikiEditor);
 +
}
 +
else {
 +
wikEd.inputWrapper.appendChild(wikEd.editorWrapper);
 +
}
 +
 
 +
// create buttons wrapper for toolbar, wikiEditor, and wikEd button bars
 +
wikEd.buttonsWrapper = document.createElement('div');
 +
wikEd.buttonsWrapper.id = 'wikEdButtonsWrapper';
 +
wikEd.buttonsWrapper.className = 'wikEdButtonsWrapper';
 +
if (wikEd.wikiEditor !== null) {
 +
wikEd.wikiEditorBar.parentNode.insertBefore(wikEd.buttonsWrapper, wikEd.wikiEditorBar);
 +
wikEd.buttonsWrapper.appendChild(wikEd.wikiEditorBar);
 +
}
 +
else {
 +
wikEd.editorWrapper.appendChild(wikEd.buttonsWrapper);
 +
}
 +
 
 +
// create toolbar wrapper
 +
wikEd.toolbarWrapper = document.createElement('div');
 +
wikEd.toolbarWrapper.id = 'wikEdToolbarWrapper';
 +
wikEd.toolbarWrapper.className = 'wikEdToolbarWrapper';
 +
wikEd.buttonsWrapper.appendChild(wikEd.toolbarWrapper);
 +
 
 +
// fill toolbar wrapper
 +
wikEd.toolbar = document.getElementById('toolbar');
 +
if (wikEd.toolbar !== null) {
 +
wikEd.toolbarWrapper.appendChild(wikEd.toolbar);
 +
}
 +
if (wikEd.wikiEditorBar !== null) {
 +
wikEd.toolbarWrapper.appendChild(wikEd.wikiEditorBar);
 +
}
 +
wikEd.buttonsWrapper.appendChild(wikEd.toolbarWrapper);
 +
 
 +
// create debug textarea wrapper
 +
wikEd.debugWrapper = document.createElement('div');
 +
wikEd.debugWrapper.id = 'wikEdDebugWrapper';
 +
wikEd.debugWrapper.className = 'wikEdDebugWrapper';
 +
wikEd.debugWrapper.style.display = 'none';
 +
wikEd.editorWrapper.insertBefore(wikEd.debugWrapper, wikEd.editorWrapper.firstChild);
 +
 
 +
// create captcha wrapper
 +
if ( (wikEd.rearrange === true) && (wikEd.readOnly === false) ) {
 +
wikEd.captchaWrapper = document.createElement('div');
 +
wikEd.captchaWrapper.id = 'wikEdCaptchaWrapper';
 +
wikEd.captchaWrapper.className = 'wikEdCaptchaWrapper';
 +
wikEd.editorWrapper.insertBefore(wikEd.captchaWrapper, wikEd.editorWrapper.firstChild);
 +
}
 +
 
 +
// create editor wrapper, contains toolbar, textarea, toc, but not the summary
 +
wikEd.editWrapper = document.createElement('div');
 +
wikEd.editWrapper.id = 'wikEdEditWrapper';
 +
wikEd.editWrapper.className = 'wikEdEditWrapper';
 +
if (wikEd.wikiEditor !== null) {
 +
wikEd.textarea.parentNode.appendChild(wikEd.editWrapper);
 +
}
 +
else {
 +
wikEd.inputWrapper.appendChild(wikEd.editWrapper);
 +
}
 +
 
 +
// create textarea wrapper
 +
wikEd.textareaWrapper = document.createElement('div');
 +
wikEd.textareaWrapper.id = 'wikEdTextareaWrapper';
 +
wikEd.textareaWrapper.className = 'wikEdTextareaWrapper';
 +
wikEd.textareaWrapper.style.position = styleTextareaWrapperPosition;
 +
wikEd.textareaWrapper.style.visibility = styleTextareaWrapperVisibility;
 +
wikEd.editWrapper.appendChild(wikEd.textareaWrapper);
 +
 
 +
// create frame wrapper
 +
wikEd.frameWrapper = document.createElement('div');
 +
wikEd.frameWrapper.id = 'wikEdFrameWrapper';
 +
wikEd.frameWrapper.className = 'wikEdFrameWrapper';
 +
wikEd.frameWrapper.style.position = styleFrameWrapperPosition;
 +
wikEd.frameWrapper.style.visibility = styleFrameWrapperVisibility;
 +
wikEd.textareaWrapper.parentNode.appendChild(wikEd.frameWrapper);
 +
 
 +
// create console wrapper for buttons, summary, and submit
 +
if (wikEd.rearrange === true) {
 +
wikEd.consoleWrapper = document.createElement('div');
 +
wikEd.consoleWrapper.id = 'wikEdConsoleWrapper';
 +
wikEd.consoleWrapper.className = 'wikEdConsoleWrapper';
 +
wikEd.inputWrapper.appendChild(wikEd.consoleWrapper);
 +
}
 +
 
 +
// create button bar wrapper
 +
wikEd.buttonBarWrapper = document.createElement('div');
 +
wikEd.buttonBarWrapper.id = 'wikEdButtonBarWrapper';
 +
wikEd.buttonBarWrapper.className = 'wikEdButtonBarWrapper';
 +
wikEd.buttonsWrapper.appendChild(wikEd.buttonBarWrapper);
 +
 
 +
// create summary wrapper for summary, minor edit, and watch this page
 +
if (wikEd.rearrange === true) {
 +
wikEd.summaryWrapper = document.createElement('div');
 +
wikEd.summaryWrapper.id = 'wikEdSummaryWrapper';
 +
wikEd.summaryWrapper.className = 'wikEdSummaryWrapper';
 +
 
 +
// add summary above the edit field if we add a new section (+ tab)
 +
if (wikEd.addNewSection === true) {
 +
wikEd.consoleTopWrapper = document.createElement('div');
 +
wikEd.consoleTopWrapper.id = 'wikEdConsoleTopWrapper';
 +
wikEd.consoleTopWrapper.className = 'wikEdConsoleTopWrapper';
 +
wikEd.consoleTopWrapper.appendChild(wikEd.summaryWrapper);
 +
wikEd.inputWrapper.insertBefore(wikEd.consoleTopWrapper, wikEd.inputWrapper.firstChild);
 +
}
 +
else {
 +
wikEd.consoleWrapper.appendChild(wikEd.summaryWrapper);
 +
}
 +
 
 +
// create summary input wrapper
 +
wikEd.summaryInputWrapper = document.createElement('div');
 +
wikEd.summaryInputWrapper.id = 'wikEdSummaryInputWrapper';
 +
wikEd.summaryInputWrapper.className = 'wikEdSummaryInputWrapper';
 +
wikEd.summaryWrapper.appendChild(wikEd.summaryInputWrapper);
 +
 
 +
// create minor edit and watch page wrapper
 +
wikEd.editOptionsWrapper = document.createElement('div');
 +
wikEd.editOptionsWrapper.id = 'wikEdEditOptionsWrapper';
 +
wikEd.editOptionsWrapper.className = 'wikEdEditOptionsWrapper';
 +
 
 +
// create submit wrapper for submit elements
 +
wikEd.submitWrapper = document.createElement('div');
 +
wikEd.submitWrapper.id = 'wikEdSubmitWrapper';
 +
wikEd.submitWrapper.className = 'wikEdSubmitWrapper';
 +
wikEd.consoleWrapper.appendChild(wikEd.submitWrapper);
 +
 
 +
// create submit buttons wrapper for submit buttons and help links
 +
wikEd.submitButtonsWrapper = document.createElement('div');
 +
wikEd.submitButtonsWrapper.id = 'wikEdSubmitButtonsWrapper';
 +
wikEd.submitButtonsWrapper.className = 'wikEdSubmitButtonsWrapper';
 +
}
 +
 
 +
// create preview wrapper for preview and diff box
 +
if (wikEd.enableLocalPreview !== false) {
 +
wikEd.localPrevWrapper = document.createElement('div');
 +
wikEd.localPrevWrapper.id = 'wikEdLocalPrevWrapper';
 +
wikEd.localPrevWrapper.className = 'wikEdLocalPrevWrapper';
 +
wikEd.localPrevWrapper.style.display = 'none';
 +
if (wikEd.rearrange === true) {
 +
wikEd.inputWrapper.appendChild(wikEd.localPrevWrapper);
 +
}
 +
else if (wikEd.saveButton !== null) {
 +
wikEd.saveButton.parentNode.appendChild(wikEd.localPrevWrapper);
 +
}
 +
else if (wikEd.previewButton !== null) {
 +
wikEd.previewButton.parentNode.appendChild(wikEd.localPrevWrapper);
 +
}
 +
else if (wikEd.diffPreviewButton !== null) {
 +
wikEd.diffPreviewButton.parentNode.appendChild(wikEd.localPrevWrapper);
 +
}
 +
}
 +
 
 +
// create insert wrapper for insert special chars links
 +
if (wikEd.rearrange === true) {
 +
wikEd.insertWrapper = document.createElement('div');
 +
wikEd.insertWrapper.id = 'wikEdInsertWrapper';
 +
wikEd.insertWrapper.className = 'wikEdInsertWrapper';
 +
wikEd.inputWrapper.appendChild(wikEd.insertWrapper);
 +
}
 +
 
 +
// fill the wrappers
 +
 
 +
// create debug textarea and add to debug wrapper
 +
wikEd.debug = document.createElement('textarea');
 +
wikEd.debug.id = 'wikEdDebugTextarea';
 +
wikEd.debug.className = 'wikEdDebugTextarea';
 +
wikEd.debug.rows = 20;
 +
wikEd.debug.setAttribute('spellcheck', false);
 +
wikEd.debugWrapper.appendChild(wikEd.debug);
 +
 
 +
// display startup error messages
 +
if (wikEd.config.debugStartUp !== '') {
 +
wikEd.Debug(wikEd.config.debugStartUp);
 +
}
 +
 
 +
// wikEdDiff enhanced ajax diff
 +
if (typeof wikEd.diffTable == 'object') {
 +
if ( (wikEd.diffTable !== null) && (wikEd.diff === true) ) {
 +
if (wikEd.Diff !== undefined) {
 +
wikEd.Diff();
 +
}
 +
}
 +
}
 +
 
 +
// hide toolbar wrapper
 +
if (wikEd.closeToolbar === true) {
 +
wikEd.toolbarWrapper.style.display = 'none';
 +
}
 +
else {
 +
wikEd.toolbarWrapper.style.display = 'block';
 +
}
 +
 
 +
// call wikibits:mwSetupToolbar() now because it would terminate with an error after setting textarea to display: none
 +
if (wikEd.toolbar !== null) {
 +
if (wikEd.toolbar.getElementsByTagName('IMG').length === 0) {
 +
if (window.mwSetupToolbar !== undefined) {
 +
window.mwSetupToolbar();
 +
window.removeEventListener('load', window.mwSetupToolbar, false);
 +
}
 +
}
 +
}
 +
 
 +
// dropdowns from toolbar should go over wikEd toolbar
 +
if (wikEd.wikiEditorBar !== null) {
 +
wikEd.wikiEditorBar.style.zIndex = '5';
 +
}
 +
 
 +
// move editpage-copywarn out of summary wrapper
 +
// needs to be done before appending editOptions to summary wrapper otherwise a linebreak stays (Mozilla bug)
 +
if (wikEd.rearrange === true) {
 +
var copywarn = document.getElementById('editpage-copywarn');
 +
if (copywarn !== null) {
 +
wikEd.inputWrapper.parentNode.insertBefore(copywarn, wikEd.inputWrapper.nextSibling);
 +
copywarn.style.clear = 'both';
 +
}
 +
}
 +
 
 +
// add a link to the wikEd help page
 +
var editHelp = document.getElementsByClassName('editHelp')[0];
 +
if (editHelp !== undefined) {
 +
if (typeof wikEd.config.helpPageLink == 'string') {
 +
wikEd.editHelp = document.createElement('span');
 +
wikEd.editHelp.id = 'wikEdEditHelp';
 +
wikEd.editHelp.className = 'wikEdEditHelp';
 +
wikEd.editHelp.innerHTML = wikEd.config.helpPageLink.replace(/\{wikEdHomeBaseUrl\}/g, wikEd.config.homeBaseUrl);
 +
editHelp.parentNode.insertBefore(wikEd.editHelp, editHelp.nextSibling);
 +
}
 +
}
 +
 
 +
// add submit buttons to submit wrapper, leaving only checkboxes in editOptions
 +
if (wikEd.rearrange === true) {
 +
var editButtons = document.getElementsByClassName('editButtons')[0];
 +
if (editButtons === undefined) {
 +
if (wikEd.saveButton !== null) {
 +
 
 +
// edit watchlist, semantic forms
 +
if (wikEd.editWatchlist === true) {
 +
editButtons = wikEd.saveButton;
 +
}
 +
 
 +
// semantic forms
 +
else {
 +
editButtons = wikEd.saveButton.parentNode;
 +
}
 +
}
 +
else if (wikEd.previewButton !== null) {
 +
 
 +
// edit watchlist
 +
if (wikEd.editWatchlist === true) {
 +
editButtons = wikEd.previewButton;
 +
}
 +
else {
 +
editButtons = wikEd.previewButton.parentNode;
 +
}
 +
}
 +
else if (wikEd.diffPreviewButton !== null) {
 +
editButtons = wikEd.diffPreviewButton.parentNode;
 +
}
 +
}
 +
if ( (editButtons !== undefined) && (editButtons !== null) ) {
 +
wikEd.submitButtonsWrapper.appendChild(editButtons);
 +
}
 +
}
 +
 
 +
// get edit checkboxes
 +
var editCheckboxes;
 +
if (wikEd.editForm !== null) {
 +
editCheckboxes = wikEd.editForm.getElementsByClassName('editCheckboxes')[0];
 +
}
 +
 
 +
// non-standard page (old, semantic forms...)
 +
if (editCheckboxes === undefined) {
 +
var checkbox = document.getElementById('wpMinoredit');
 +
if (checkbox === null) {
 +
checkbox = document.getElementById('wpWatchthis');
 +
}
 +
var summary = document.getElementsByName('wpSummary')[0];
 +
if ( (summary !== undefined) && (checkbox !== null) ) {
 +
 
 +
// get checkbox container, e.g. semantic forms <p>
 +
if ( (summary.nextSibling == checkbox.parentNode) || (summary.parentNode.nextSibling == checkbox.parentNode) ) {
 +
editCheckboxes = checkbox.parentNode;
 +
editCheckboxes.className = 'wikEdEditCheckboxes';
 +
}
 +
 
 +
// old MediaWiki versions: create edit options container
 +
else {
 +
editCheckboxes = document.createElement('div');
 +
editCheckboxes.id = 'wikEdEditCheckboxes';
 +
editCheckboxes.className = 'wikEdEditCheckboxes';
 +
if (summary.nextSibling == checkbox) {
 +
var node = checkbox;
 +
while (node !== null) {
 +
var nextNode = node.nextSibling;
 +
editCheckboxes.appendChild(node);
 +
node = nextNode;
 +
}
 +
}
 +
}
 +
}
 +
}
 +
 
 +
// add summary elements to summary input wrapper
 +
if (wikEd.rearrange === true) {
 +
wikEd.summaryLabel = document.getElementById('wpSummaryLabel');
 +
if (wikEd.summaryLabel !== null) {
 +
wikEd.summaryInputWrapper.appendChild(wikEd.summaryLabel);
 +
}
 +
wikEd.summaryText = document.getElementsByName('wpSummary')[0] || null;
 +
if (wikEd.summaryText !== null) {
 +
wikEd.summaryInputWrapper.appendChild(wikEd.summaryText);
 +
}
 +
}
 +
 
 +
// add submit buttons, edit options, and edit help to submit wrapper
 +
if (wikEd.submitWrapper !== null) {
 +
if (wikEd.submitButtonsWrapper !== null) {
 +
wikEd.submitWrapper.appendChild(wikEd.submitButtonsWrapper);
 +
}
 +
if (wikEd.editOptionsWrapper !== null) {
 +
wikEd.submitWrapper.appendChild(wikEd.editOptionsWrapper);
 +
if (editCheckboxes !== undefined) {
 +
wikEd.editOptionsWrapper.appendChild(editCheckboxes);
 +
 
 +
// remove linebreak before minor edit checkbox
 +
var node = editCheckboxes.firstChild;
 +
while (node !== null) {
 +
if (node.tagName !== null) {
 +
if (node.tagName == 'BR') {
 +
node.parentNode.removeChild(node);
 +
break;
 +
}
 +
}
 +
node = node.nextSibling;
 +
}
 +
}
 +
}
 +
}
 +
 
 +
// add empty editOptions to wikEdConsoleWrapper
 +
if (wikEd.consoleWrapper !== null) {
 +
var editOptions = document.getElementsByClassName('editOptions')[0];
 +
if (editOptions !== undefined) {
 +
wikEd.consoleWrapper.appendChild(editOptions);
 +
}
 +
}
 +
 
 +
// add textBoxTable or textarea to textarea wrapper
 +
wikEd.textBoxTable = document.getElementById('textBoxTable');
 +
if (wikEd.textBoxTable !== null) {
 +
wikEd.textareaWrapper.appendChild(wikEd.textBoxTable);
 +
}
 +
else {
 +
wikEd.textareaWrapper.appendChild(wikEd.textarea);
 +
}
 +
 
 +
// fill captcha wrapper with elements between form and textarea (table)
 +
if (wikEd.captchaWrapper !== null) {
 +
if ( (wikEd.editUpload === false) && (wikEd.editWatchlist === false) ) {
 +
var node = wikEd.editForm.firstChild;
 +
while (node !== null) {
 +
if ( (node == wikEd.inputWrapper) || (node == wikEd.wikiEditor) || (node == wikEd.captchaWrapper)  ) {
 +
break;
 +
}
 +
var nextNode = node.nextSibling;
 +
if (node.tagName != 'INPUT') {
 +
wikEd.captchaWrapper.appendChild(node);
 +
}
 +
node = nextNode;
 +
}
 +
}
 +
}
 +
 
 +
// create editing frame wrapper
 +
wikEd.frameOuter = document.createElement('div');
 +
wikEd.frameOuter.id = 'wikEdFrameOuter';
 +
wikEd.frameOuter.className = 'wikEdFrameOuter';
 +
wikEd.frameWrapper.appendChild(wikEd.frameOuter);
 +
 
 +
wikEd.frameInner = document.createElement('div');
 +
wikEd.frameInner.id = 'wikEdFrameInner';
 +
wikEd.frameInner.className = 'wikEdFrameInner';
 +
wikEd.frameOuter.appendChild(wikEd.frameInner);
 +
 
 +
// remove frame border if textarea has none
 +
if (wikEd.textareaBorderHeight === 0) {
 +
wikEd.frameInner.style.borderWidth = '0';
 +
wikEd.frameOuter.style.borderWidth = '0';
 +
}
 +
 
 +
// create editing frame and initialize after iframe loading
 +
wikEd.frame = document.createElement('iframe');
 +
wikEd.frame.addEventListener('load', wikEd.FrameLoadHandler, false);
 +
wikEd.frame.id = 'wikEdFrame';
 +
wikEd.frame.className = 'wikEdFrame';
 +
wikEd.frameInner.appendChild(wikEd.frame);
 +
 
 +
// set frame height and width, border divs shrink around
 +
wikEd.frameBorderHeight = parseInt(wikEd.GetStyle(wikEd.frameOuter, 'borderTopWidth'), 10) + parseInt(wikEd.GetStyle(wikEd.frameOuter, 'borderBottomWidth'), 10) + parseInt(wikEd.GetStyle(wikEd.frameInner, 'borderTopWidth'), 10) + parseInt(wikEd.GetStyle(wikEd.frameInner, 'borderBottomWidth'), 10);
 +
wikEd.frameHeight = (wikEd.textareaOffsetHeightInitial - wikEd.frameBorderHeight) + 'px';
 +
wikEd.frame.style.height = wikEd.frameHeight;
 +
 
 +
wikEd.frameBorderWidth = parseInt(wikEd.GetStyle(wikEd.frameOuter, 'borderLeftWidth'), 10) + parseInt(wikEd.GetStyle(wikEd.frameOuter, 'borderRightWidth'), 10) + parseInt(wikEd.GetStyle(wikEd.frameInner, 'borderLeftWidth'), 10) + parseInt(wikEd.GetStyle(wikEd.frameInner, 'borderRightWidth'), 10);
 +
wikEd.frameWidth = (wikEd.editorWrapper.clientWidth - wikEd.frameBorderWidth) + 'px';
 +
wikEd.frame.style.width = wikEd.frameWidth;
 +
 
 +
// generate button bars and add them to the buttons wrapper
 +
// form wrapper added against summary input submit defaulting to this button
 +
if (wikEd.readOnly === false) {
 +
wikEd.buttonBarFormat = wikEd.MakeButtonBar(wikEd.config.buttonBar.format);
 +
wikEd.buttonBarWrapper.appendChild(wikEd.buttonBarFormat);
 +
 
 +
wikEd.buttonBarTextify = wikEd.MakeButtonBar(wikEd.config.buttonBar.textify);
 +
wikEd.buttonBarWrapper.appendChild(wikEd.buttonBarTextify);
 +
}
 +
 
 +
wikEd.buttonBarControl = wikEd.MakeButtonBar(wikEd.config.buttonBar.control);
 +
wikEd.buttonBarWrapper.appendChild(wikEd.buttonBarControl);
 +
 
 +
if (wikEd.config.buttonBar.custom1[6].length > 0) {
 +
wikEd.buttonBarCustom1 = wikEd.MakeButtonBar(wikEd.config.buttonBar.custom1);
 +
wikEd.buttonBarWrapper.appendChild(wikEd.buttonBarCustom1);
 +
}
 +
 
 +
wikEd.buttonBarFind = wikEd.MakeButtonBar(wikEd.config.buttonBar.find);
 +
wikEd.buttonBarWrapper.appendChild(wikEd.buttonBarFind);
 +
 
 +
// inactivate replace buttons for read-only pages
 +
if (wikEd.readOnly === true) {
 +
document.getElementById('wikEdReplaceAll').className = 'wikEdButtonInactive';
 +
document.getElementById('wikEdReplacePrev').className = 'wikEdButtonInactive';
 +
document.getElementById('wikEdReplaceNext').className = 'wikEdButtonInactive';
 +
}
 +
 
 +
if (wikEd.readOnly === false) {
 +
wikEd.buttonBarFix = wikEd.MakeButtonBar(wikEd.config.buttonBar.fix);
 +
wikEd.buttonBarWrapper.appendChild(wikEd.buttonBarFix);
 +
}
 +
 
 +
if (wikEd.config.buttonBar.custom2[6].length > 0) {
 +
wikEd.buttonBarCustom2 = wikEd.MakeButtonBar(wikEd.config.buttonBar.custom2);
 +
wikEd.buttonBarWrapper.appendChild(wikEd.buttonBarCustom2);
 +
}
 +
 
 +
var br = document.createElement('br');
 +
br.style.clear = 'both';
 +
wikEd.buttonsWrapper.appendChild(br);
 +
wikEd.caseSensitive = document.getElementById('wikEdCaseSensitive');
 +
wikEd.regExp = document.getElementById('wikEdRegExp');
 +
wikEd.findAhead = document.getElementById('wikEdFindAhead');
 +
wikEd.findText = document.getElementById('wikEdFindText');
 +
wikEd.replaceText = document.getElementById('wikEdReplaceText');
 +
 
 +
// add preview box top bar to submit wrapper
 +
wikEd.buttonBarPreview = wikEd.MakeButtonBar(wikEd.config.buttonBar.preview);
 +
if ( (wikEd.rearrange === true) && (wikEd.submitWrapper !== null) ) {
 +
if ( (wikEd.fullScreenMode === true) && (wikEd.editArticle === true) && (wikEd.useWikEd === true) ) {
 +
wikEd.buttonBarPreview.style.display = 'none';
 +
}
 +
wikEd.submitWrapper.appendChild(wikEd.buttonBarPreview);
 +
}
 +
 
 +
// add pasted button bar to frame wrapper
 +
wikEd.buttonBarPasted = wikEd.MakeButtonBar(wikEd.config.buttonBar.pasted);
 +
wikEd.buttonBarPasted.style.visibility = 'hidden';
 +
wikEd.frameInner.insertBefore(wikEd.buttonBarPasted, wikEd.frameInner.firstChild);
 +
 
 +
// add article and diff preview containers and their bottom bar to preview wrapper
 +
if (wikEd.localPrevWrapper !== null) {
 +
 
 +
// article preview
 +
wikEd.previewArticle = document.createElement('div');
 +
wikEd.previewArticle.id = 'wikEdPreviewArticle';
 +
wikEd.previewArticle.className = 'wikEdPreviewArticle';
 +
wikEd.previewArticle.display = 'none';
 +
wikEd.localPrevWrapper.appendChild(wikEd.previewArticle);
 +
 
 +
// diff preview
 +
wikEd.previewDiff = document.createElement('div');
 +
wikEd.previewDiff.id = 'wikEdPreviewDiff';
 +
wikEd.previewDiff.className = 'wikEdPreviewDiff';
 +
wikEd.previewDiff.display = 'none';
 +
wikEd.localPrevWrapper.appendChild(wikEd.previewDiff);
 +
 
 +
// add preview container bottom bar to preview wrapper
 +
wikEd.buttonBarPreview2 = wikEd.MakeButtonBar(wikEd.config.buttonBar.preview2);
 +
wikEd.localPrevWrapper.appendChild(wikEd.buttonBarPreview2);
 +
}
 +
 
 +
// add jump box to standard preview
 +
wikEd.wikiPreview = document.getElementById('wikiPreview');
 +
if (wikEd.wikiPreview !== null) {
 +
if (wikEd.wikiPreview.firstChild !== null) {
 +
wikEd.buttonBarJump = wikEd.MakeButtonBar(wikEd.config.buttonBar.jump);
 +
wikEd.wikiPreview.insertBefore(wikEd.buttonBarJump, wikEd.wikiPreview.firstChild);
 +
}
 +
}
 +
 
 +
// add insert special chars to insert wrapper
 +
if (wikEd.insertWrapper !== null) {
 +
var insert = document.getElementById('mw-edittools-charinsert');
 +
if (insert === null) {
 +
insert = document.getElementById('editpage-specialchars');
 +
}
 +
if (insert !== null) {
 +
wikEd.insertWrapper.appendChild(insert);
 +
}
 +
}
 +
 
 +
// wrappers filled
 +
 
 +
// add local preview button next to submit button
 +
if (wikEd.enableLocalPreview !== false) {
 +
var previewSpan = document.createElement('span');
 +
previewSpan.innerHTML = wikEd.MakeButtonCode(82, 'button');
 +
if (wikEd.previewButton !== null) {
 +
wikEd.previewButton.parentNode.insertBefore(previewSpan, wikEd.previewButton.nextSibling);
 +
}
 +
else if (wikEd.saveButton !== null) {
 +
wikEd.saveButton.parentNode.insertBefore(previewSpan, wikEd.saveButton.nextSibling);
 +
}
 +
else {
 +
wikEd.submitWrapper.insertBefore(previewSpan, wikEd.submitWrapper.firstChild);
 +
}
 +
 
 +
// add local diff button next to submit button
 +
if ( ( (wikEd.diffPreviewButton !== null) || (wikEd.editWatchlist === true) ) && (wikEd.readOnly === false) ) {
 +
var diffSpan = document.createElement('span');
 +
diffSpan.innerHTML = wikEd.MakeButtonCode(83, 'button');
 +
if (wikEd.diffPreviewButton !== null) {
 +
wikEd.diffPreviewButton.parentNode.insertBefore(diffSpan, wikEd.diffPreviewButton.nextSibling);
 +
}
 +
else if (previewSpan !== null) {
 +
previewSpan.parentNode.insertBefore(diffSpan, previewSpan.nextSibling);
 +
}
 +
else if (wikEd.previewButton !== null) {
 +
wikEd.previewButton.parentNode.insertBefore(diffSpan, wikEd.previewButton.nextSibling);
 +
}
 +
}
 +
}
 +
 
 +
// correct tab order between check boxes and submits
 +
wikEd.frame.tabIndex = wikEd.textarea.tabIndex;
 +
 
 +
// initialize image buttons
 +
wikEd.Button(document.getElementById('wikEdRefHide'),        'wikEdRefHide', null, wikEd.refHide);
 +
wikEd.Button(document.getElementById('wikEdHighlightSyntax'), 'wikEdHighlightSyntax', null, wikEd.highlightSyntax);
 +
wikEd.Button(document.getElementById('wikEdUseWikEd'),        'wikEdUseWikEd', null, wikEd.useWikEd);
 +
wikEd.Button(document.getElementById('wikEdCloseToolbar'),    'wikEdCloseToolbar', null, wikEd.closeToolbar);
 +
wikEd.Button(document.getElementById('wikEdFullScreen'),      'wikEdFullScreen', null, wikEd.fullScreenMode);
 +
wikEd.Button(document.getElementById('wikEdUsing'),          'wikEdUsing', null, wikEd.using);
 +
wikEd.Button(document.getElementById('wikEdCaseSensitive'),  'wikEdCaseSensitive', null, false);
 +
wikEd.Button(document.getElementById('wikEdRegExp'),          'wikEdRegExp', null, false);
 +
wikEd.Button(document.getElementById('wikEdFindAhead'),      'wikEdFindAhead', null, wikEd.config.findAheadSelected);
 +
wikEd.Button(document.getElementById('wikEdClose'),          'wikEdClose', null, false, 'wikEdButton');
 +
wikEd.Button(document.getElementById('wikEdClose2'),          'wikEdClose2', null, false, 'wikEdButton');
 +
wikEd.Button(document.getElementById('wikEdTableMode'),      'wikEdTableMode', null, wikEd.tableMode);
 +
 
 +
// grey out fullscreen button
 +
if ( (wikEd.editArticle === false) || (wikEd.useWikEd === false) ) {
 +
document.getElementById('wikEdFullScreen').className = 'wikEdButtonInactive';
 +
}
 +
 
 +
// grey out close toolbar button
 +
if (wikEd.rearrange === false) {
 +
document.getElementById('wikEdCloseToolbar').className = 'wikEdButtonInactive';
 +
}
 +
 
 +
// hide typo fix button until typo fix rules are loaded and parsed
 +
wikEd.fixRegExTypo = document.getElementById('wikEdFixRegExTypo');
 +
if (wikEd.fixRegExTypo !== null) {
 +
wikEd.fixRegExTypo.style.display = 'none';
 +
}
 +
 
 +
// hide buttons if API is not available
 +
if ( (wikEd.wikiGlobals.wgEnableAPI !== true) && (wikEd.wikiGlobals.wgEnableAPI != 'true') ) {
 +
var fixRedirect = document.getElementById('wikEdFixRedirect');
 +
if (fixRedirect !== null) {
 +
fixRedirect.style.display = 'none';
 +
}
 +
}
 +
 
 +
// add a clear summary button left to the summary input field
 +
if (wikEd.summaryText !== null) {
 +
var clearSummaryForm = document.createElement('form');
 +
clearSummaryForm.id = 'wikEdClearSummaryForm';
 +
clearSummaryForm.className = 'wikEdClearSummaryForm';
 +
wikEd.summaryText.parentNode.insertBefore(clearSummaryForm, wikEd.summaryText);
 +
 
 +
wikEd.clearSummary = document.createElement('button');
 +
wikEd.clearSummary.id = 'wikEdClearSummary';
 +
wikEd.clearSummary.className = 'wikEdClearSummary';
 +
wikEd.clearSummary.alt = wikEd.config.text['wikEdClearSummary alt'];
 +
wikEd.clearSummary.title = wikEd.config.text['wikEdClearSummary title'];
 +
clearSummaryForm.appendChild(wikEd.clearSummary);
 +
 
 +
wikEd.clearSummaryImg = document.createElement('img');
 +
wikEd.clearSummaryImg.id = 'wikEdClearSummaryImg';
 +
wikEd.clearSummaryImg.src = wikEd.config.image['clearSummary'];
 +
wikEd.clearSummaryImg.alt = 'Clear summary';
 +
wikEd.clearSummary.appendChild(wikEd.clearSummaryImg);
 +
 
 +
// remember button width, might be without image
 +
wikEd.clearSummaryWidth = wikEd.clearSummary.offsetWidth;
 +
 
 +
// make the summary a combo box
 +
var summaryComboInput = document.createElement('span');
 +
summaryComboInput.id = 'wikEdSummaryComboInput';
 +
summaryComboInput.className = 'wikEdSummaryComboInput';
 +
summaryComboInput = wikEd.summaryText.parentNode.insertBefore(summaryComboInput, wikEd.summaryText);
 +
 
 +
wikEd.summaryText = wikEd.summaryText.parentNode.removeChild(wikEd.summaryText);
 +
wikEd.summaryText.className = 'wikEdSummaryText';
 +
wikEd.summaryTextWidth = wikEd.summaryWrapper.offsetWidth - wikEd.summaryInputWrapper.offsetWidth;
 +
if (wikEd.summaryTextWidth < 150) {
 +
wikEd.summaryTextWidth = 150;
 +
}
 +
wikEd.summaryText.style.width = wikEd.summaryTextWidth + 'px';
 +
 
 +
wikEd.summarySelect = document.createElement('select');
 +
wikEd.summarySelect.id = 'wikEdSummarySelect';
 +
wikEd.summarySelect.className = 'wikEdSummarySelect';
 +
 
 +
summaryComboInput.appendChild(wikEd.summaryText);
 +
summaryComboInput.appendChild(wikEd.summarySelect);
 +
 
 +
// repair summary combo css (e.g. Wikisource MediaWiki:Common.css/Tweaks.css)
 +
wikEd.summaryText.style.setProperty('position', 'absolute', 'important');
 +
}
 +
 
 +
// shorten submit button texts
 +
if (wikEd.previewButton !== null) {
 +
wikEd.previewButton.value = wikEd.config.text.shortenedPreview;
 +
}
 +
if (wikEd.diffPreviewButton !== null) {
 +
wikEd.diffPreviewButton.value = wikEd.config.text.shortenedChanges;
 +
}
 +
 
 +
// set up combo input boxes with history
 +
wikEd.fieldHist ['find'] = [];
 +
wikEd.savedName.find = 'wikEdFindHistory';
 +
wikEd.inputElement.find = new Object(wikEd.findText);
 +
wikEd.selectElement.find = new Object(document.getElementById('wikEdFindSelect'));
 +
wikEd.selectElement.find.title = wikEd.config.text['wikEdFindSelect title'];
 +
 
 +
wikEd.fieldHist ['replace'] = [];
 +
wikEd.savedName.replace = 'wikEdReplaceHistory';
 +
wikEd.inputElement.replace = new Object(wikEd.replaceText);
 +
wikEd.selectElement.replace = new Object(document.getElementById('wikEdReplaceSelect'));
 +
wikEd.selectElement.replace.title = wikEd.config.text['wikEdReplaceSelect title'];
 +
 
 +
if (wikEd.summaryInputWrapper !== null) {
 +
wikEd.fieldHist ['summary'] = [];
 +
wikEd.savedName.summary = 'wikEdSummaryHistory';
 +
wikEd.inputElement.summary = new Object(wikEd.summaryText);
 +
wikEd.selectElement.summary = new Object(document.getElementById('wikEdSummarySelect'));
 +
wikEd.selectElement.summary.title = wikEd.config.text['wikEdSummarySelect title'];
 +
}
 +
 
 +
// adjust the select field widths to that of the text input fields
 +
wikEd.ResizeComboInput('find');
 +
wikEd.ResizeComboInput('replace');
 +
if (wikEd.summaryText !== null) {
 +
wikEd.ResizeComboInput('summary');
 +
}
 +
 
 +
// hide the button bars per saved setting
 +
if (wikEd.buttonBarFormat !== null) {
 +
wikEd.ButtonBarInit(wikEd.buttonBarFormat);
 +
}
 +
if (wikEd.buttonBarTextify !== null) {
 +
wikEd.ButtonBarInit(wikEd.buttonBarTextify);
 +
}
 +
if (wikEd.buttonBarControl !== null) {
 +
wikEd.ButtonBarInit(wikEd.buttonBarControl);
 +
}
 +
if (wikEd.buttonBarCustom1 !== null) {
 +
wikEd.ButtonBarInit(wikEd.buttonBarCustom1);
 +
}
 +
if (wikEd.buttonBarFind !== null) {
 +
wikEd.ButtonBarInit(wikEd.buttonBarFind);
 +
}
 +
if (wikEd.buttonBarFix !== null) {
 +
wikEd.ButtonBarInit(wikEd.buttonBarFix);
 +
}
 +
if (wikEd.buttonBarCustom2 !== null) {
 +
wikEd.ButtonBarInit(wikEd.buttonBarCustom2);
 +
}
 +
 
 +
// copy page warnings above edit window
 +
if ( (wikEd.config.doCloneWarnings === true) && (wikEd.editForm !== null) ) {
 +
if ( (wikEd.clonedWarnings === false) && (wikEd.previewPage === false) && (/(.*\n){2}/.test(wikEd.origVersion) ) === true) {
 +
var divs = document.getElementsByTagName('div');
 +
var divWarnings = [];
 +
var editnoticeArea = false;
 +
for (var i = 0; i < divs.length; i ++) {
 +
var div = divs[i];
 +
if (/editnotice/.test(div.id) === true) {
 +
if (editnoticeArea === false) {
 +
divWarnings.push(div);
 +
editnoticeArea = true;
 +
}
 +
}
 +
else if (/mw-.*?warning/.test(div.className) === true) {
 +
divWarnings.push(div);
 +
}
 +
}
 +
 
 +
// create clone wrapper
 +
if (divWarnings.length > 0) {
 +
var cloneWrapper = document.createElement('div');
 +
cloneWrapper.id = 'wikEdClonedWarnings';
 +
var cloneNote = document.createElement('div');
 +
cloneNote.id = 'wikEdClonedWarningsNote';
 +
cloneNote.innerHTML = wikEd.config.text['clonedWarningsNote'];
 +
cloneWrapper.appendChild(cloneNote);
 +
for (var i = 0; i < divWarnings.length; i ++) {
 +
var clone = divWarnings[i].cloneNode(true);
 +
 
 +
// ignore redlink-only edit warnings
 +
var html = clone.innerHTML;
 +
html = html.replace(/<a\b[^>].*?\bclass="new"[^>]*>(.|\n)*?<\/a>/g, '');
 +
html = html.replace(/<(.|\n)*?>/g, '');
 +
html = html.replace(/\s*/g, '');
 +
if (html === '') {
 +
continue;
 +
}
 +
 
 +
cloneWrapper.appendChild(clone);
 +
wikEd.clonedWarnings = true;
 +
}
 +
if (wikEd.clonedWarnings === true) {
 +
wikEd.inputWrapper.parentNode.insertBefore(cloneWrapper, wikEd.inputWrapper);
 +
}
 +
}
 +
}
 +
}
 +
 
 +
// init and resize frame after buttons and summary are in place, wait until iframe has been loaded
 +
if (wikEd.frameLoaded === false) {
 +
wikEd.frame.addEventListener('load', wikEd.InitializeFrame, false);
 +
}
 +
else {
 +
wikEd.InitializeFrame();
 +
}
 +
 
 +
// scroll to edit window and focus if not preview page or Semantic Form
 +
if ( (scrollToEditFocus === true) && (wikEd.previewPage === false) && (wikEd.editSemanticForm === false) ) {
 +
 
 +
// focus the input field
 +
if ( (wikEd.config.focusEdit === true) && (wikEd.useWikEd === false) ) {
 +
wikEd.textarea.setSelectionRange(0, 0);
 +
wikEd.textarea.focus();
 +
}
 +
 
 +
// scroll
 +
if ( (wikEd.fullScreenMode === false) && (wikEd.config.scrollToEdit === true) ) {
 +
window.scroll(0, wikEd.GetOffsetTop(wikEd.inputWrapper) - 2);
 +
}
 +
}
 +
 
 +
// register edit button click events
 +
for (var buttonId in wikEd.editButtonHandler) {
 +
if (Object.prototype.hasOwnProperty.call(wikEd.editButtonHandler, buttonId) === true) {
 +
var buttonObj = document.getElementById(buttonId);
 +
if (buttonObj !== null) {
 +
buttonObj.addEventListener('click', wikEd.EditButtonHandler, true);
 +
}
 +
}
 +
}
 +
 
 +
// register summary shrinking event after loading the 'Clear summary' image handler
 +
if (wikEd.clearSummaryImg !== null) {
 +
wikEd.clearSummaryImg.addEventListener('load', wikEd.ShrinkSummaryHandler, true);
 +
}
 +
 
 +
// register summary resize event for window resizing
 +
window.addEventListener('resize', wikEd.ResizeWindowHandler, true);
 +
 
 +
// register document events
 +
document.addEventListener('keydown', wikEd.KeyHandler, true);
 +
 
 +
// dblclick on wrapper events
 +
wikEd.debugWrapper.addEventListener('dblclick', wikEd.DebugHandler, true);
 +
wikEd.localPrevWrapper.addEventListener('dblclick', wikEd.PrevWrapperHandler, true);
 +
 
 +
// register find ahead events
 +
wikEd.findText.addEventListener('keyup', wikEd.FindAhead, true);
 +
 
 +
// register submit button events
 +
if (wikEd.saveButton !== null) {
 +
wikEd.saveButton.addEventListener('click', wikEd.SaveButtonHandler, true);
 +
}
 +
if (wikEd.previewButton !== null) {
 +
wikEd.previewButton.addEventListener('click', wikEd.PreviewButtonHandler, true);
 +
}
 +
if (wikEd.diffPreviewButton !== null) {
 +
wikEd.diffPreviewButton.addEventListener('click', wikEd.DiffPreviewButtonHandler, true);
 +
}
 +
 
 +
// set button bar grip area events
 +
if (wikEd.buttonBarFormat !== null) {
 +
wikEd.buttonBarFormat.firstChild.firstChild.addEventListener('click', wikEd.ButtonBarGripHandler, false);
 +
}
 +
if (wikEd.buttonBarTextify !== null) {
 +
wikEd.buttonBarTextify.firstChild.firstChild.addEventListener('click', wikEd.ButtonBarGripHandler, false);
 +
}
 +
if (wikEd.buttonBarControl !== null) {
 +
wikEd.buttonBarControl.firstChild.firstChild.addEventListener('click', wikEd.ButtonBarGripHandler, false);
 +
}
 +
if (wikEd.buttonBarCustom1 !== null) {
 +
if (wikEd.buttonBarCustom1.firstChild.firstChild !== null) {
 +
wikEd.buttonBarCustom1.firstChild.firstChild.addEventListener('click', wikEd.ButtonBarGripHandler, false);
 +
}
 +
}
 +
if (wikEd.buttonBarFind !== null) {
 +
wikEd.buttonBarFind.firstChild.firstChild.addEventListener('click', wikEd.ButtonBarGripHandler, false);
 +
}
 +
if (wikEd.buttonBarFix !== null) {
 +
wikEd.buttonBarFix.firstChild.firstChild.addEventListener('click', wikEd.ButtonBarGripHandler, false);
 +
}
 +
if (wikEd.buttonBarCustom2 !== null) {
 +
if (wikEd.buttonBarCustom2.firstChild.firstChild !== null) {
 +
wikEd.buttonBarCustom2.firstChild.firstChild.addEventListener('click', wikEd.ButtonBarGripHandler, false);
 +
}
 +
}
 +
 
 +
// register combo box events
 +
if (wikEd.summarySelect !== null) {
 +
wikEd.summarySelect.addEventListener('change', function () { wikEd.ChangeComboInput('summary'); }, false);
 +
wikEd.summarySelect.addEventListener('focus', function () { wikEd.SetComboOptions('summary'); }, false);
 +
}
 +
if (wikEd.selectElement.find !== null) {
 +
wikEd.selectElement.find.addEventListener('change', function () { wikEd.ChangeComboInput('find'); }, false);
 +
wikEd.selectElement.find.addEventListener('focus', function () { wikEd.SetComboOptions('find'); }, false);
 +
}
 +
if (wikEd.selectElement.replace !== null) {
 +
wikEd.selectElement.replace.addEventListener('change', function () { wikEd.ChangeComboInput('replace'); }, false);
 +
wikEd.selectElement.replace.addEventListener('focus', function () { wikEd.SetComboOptions('replace'); }, false);
 +
}
 +
 
 +
// register the clear summary click handler
 +
if (wikEd.clearSummary !== null) {
 +
wikEd.clearSummary.addEventListener('click', wikEd.ClearSummaryHandler, false);
 +
}
 +
 
 +
// register double click handler on wiki preview area
 +
if (wikEd.wikiPreview !== null) {
 +
wikEd.wikiPreview.addEventListener('dblclick', wikEd.WikiPreviewHandler, false);
 +
}
 +
 
 +
// register special char insert select handler for fullscreen resizing
 +
if (wikEd.insertWrapper !== null) {
 +
var select = wikEd.insertWrapper.getElementsByTagName('select')[0];
 +
if (select !== undefined) {
 +
select.addEventListener('change', wikEd.InsertChangeHandler, true);
 +
}
 +
}
 +
 
 +
// select the text on focus for find and replace fields, tab/shift-tab between find and replace fields
 +
if (wikEd.findText !== null) {
 +
wikEd.findText.addEventListener('focus', wikEd.FindReplaceHandler, true);
 +
wikEd.findText.addEventListener('keydown', wikEd.FindReplaceHandler, true);
 +
}
 +
if (wikEd.replaceText !== null) {
 +
wikEd.replaceText.addEventListener('focus', wikEd.FindReplaceHandler, true);
 +
wikEd.replaceText.addEventListener('keydown', wikEd.FindReplaceHandler, true);
 +
}
 +
 
 +
// check if dynamically inserted addon tags have to be removed: Web of Trust (WOT)
 +
if (document.getElementById('wot-logo') !== null) {
 +
wikEd.cleanNodes = true;
 +
}
 +
 
 +
// override insertTags function used by standard button toolbar and editpage special chars with wikEd replacement
 +
 
 +
// window.mw.toolbar.insertTags
 +
if ( (window.mw !== undefined) && (window.mw.toolbar !== undefined) && (typeof window.mw.toolbar.insertTags === 'function') ) {
 +
if (wikEd.InsertTagsOriginal === null) {
 +
wikEd.InsertTagsOriginal = window.mw.toolbar.insertTags;
 +
}
 +
window.mw.toolbar.insertTags = wikEd.InsertTags;
 +
}
 +
 
 +
// deprecated insertTags function in wikibits.js
 +
else if (typeof window.insertTags == 'function') {
 +
if (wikEd.InsertTagsOriginal === null) {
 +
wikEd.InsertTagsOriginal = window.insertTags;
 +
}
 +
window.insertTags = wikEd.InsertTags;
 +
}
 +
 
 +
if (typeof jQuery == 'function') {
 +
// hook wikEd into the enhanced new edit toolbar, not Greasemonkey compatible
 +
jQuery('#wpTextbox1').bind('encapsulateSelection', function (e, before, inside, after) {
 +
if (wikEd.useWikEd === true) {
 +
wikEd.InsertTags(before, after, inside);
 +
}
 +
});
 +
 
 +
// allow other code to cause us to update the textarea via textSelection( 'getContents' )
 +
$( '#wpTextbox1' ).textSelection(
 +
'register',
 +
{
 +
getContents: function () {
 +
if ( wikEd && wikEd.useWikEd ) {
 +
wikEd.UpdateTextarea();
 +
}
 +
return $( this ).val();
 +
}
 +
}
 +
);
 +
}
 +
 
 +
// update textarea before using UI LivePreview function, not Greasemonkey compatible
 +
if ( (typeof jQuery == 'function') && (typeof window.mw == 'object') ) {
 +
jQuery(window.mw).bind('LivePreviewPrepare', function (event) {
 +
if (wikEd.useWikEd === true) {
 +
wikEd.UpdateTextarea();
 +
}
 +
});
 +
}
 +
 
 +
// override insertAtCursor function in wikia.com MediaWiki:Functions.js, not Greasemonkey compatible
 +
if (typeof window.insertAtCursor == 'function') {
 +
if (wikEd.InsertAtCursorOriginal === null) {
 +
wikEd.InsertAtCursorOriginal = window.insertAtCursor;
 +
}
 +
window.insertAtCursor = wikEd.InsertAtCursor;
 +
}
 +
 
 +
// reset error indicator
 +
wikEd.SetLogo();
 +
wikEd.turnedOn = true;
 +
 
 +
// get frame resize grip image dimensions
 +
var resizeGripImage = document.createElement('img');
 +
resizeGripImage.id = 'wikEdResizeGrip';
 +
resizeGripImage.addEventListener('load', wikEd.ResizeGripLoadHandler, true);
 +
resizeGripImage.src = wikEd.config.image['resizeGrip'];
 +
 
 +
// remove accesskeys that are defined in wikEd from page elements
 +
wikEd.DeleteAccesskeys();
 +
 
 +
// disable CodeEditor button when wikEd is active
 +
wikEd.DisableCodeEditorButton();
 +
 
 +
// run scheduled custom functions
 +
wikEd.ExecuteHook(wikEd.config.setupHook);
 +
 
 +
// load and parse RegExTypoFix rules if the button is enabled
 +
wikEd.LoadTypoFixRules();
 +
 
 +
// done with setup and turn-on
 +
return;
 +
};
 +
 
 +
 
 +
//
 +
// wikEd.GetPaths: get MediaWiki file paths from wikiGlobals if possible
 +
//
 +
 
 +
wikEd.GetPaths = function () {
 +
 
 +
// init MediaWiki file paths for use in regexps
 +
if (wikEd.wikiGlobals.wgServer !== undefined) {
 +
wikEd.server = wikEd.wikiGlobals.wgServer;
 +
}
 +
if (wikEd.wikiGlobals.wgArticlePath !== undefined) {
 +
wikEd.articlePath = wikEd.wikiGlobals.wgArticlePath;
 +
}
 +
if (wikEd.wikiGlobals.wgScriptPath !== undefined) {
 +
wikEd.scriptPath = wikEd.wikiGlobals.wgScriptPath;
 +
}
 +
if (wikEd.wikiGlobals.wgScript !== undefined) {
 +
wikEd.script = wikEd.wikiGlobals.wgScript;
 +
}
 +
 
 +
wikEd.articlePath = wikEd.articlePath.replace(wikEd.server, '');
 +
wikEd.scriptPath = wikEd.scriptPath.replace(wikEd.server, '');
 +
wikEd.articlePath = wikEd.articlePath.replace(/\$1$/, '');
 +
wikEd.scriptPath = wikEd.scriptPath.replace(/\/?$/, '/');
 +
wikEd.scriptName = wikEd.script.replace(wikEd.scriptPath, '');
 +
wikEd.scriptURL = wikEd.server + wikEd.scriptPath;
 +
 
 +
// prepare for use in regexps
 +
wikEd.server = wikEd.server.replace(/(\W)/g, '\\$1');
 +
wikEd.articlePath = wikEd.articlePath.replace(/(\W)/g, '\\$1');
 +
wikEd.script = wikEd.script.replace(/(\W)/g, '\\$1');
 +
wikEd.scriptPath = wikEd.scriptPath.replace(/(\W)/g, '\\$1');
 +
wikEd.scriptName = wikEd.scriptName.replace(/(\W)/g, '\\$1');
 +
 
 +
return;
 +
};
 +
 
 +
 
 +
//
 +
// wikEd.FrameLoadHandler: load handler for iframe
 +
//  Chrome fires iframe load event immediately after element creation, Firefox fires much later and then deletes already added content
 +
 
 +
wikEd.FrameLoadHandler = function (event) {
 +
 
 +
// remove event listener
 +
wikEd.frame.removeEventListener('load', wikEd.FrameLoadHandler, false);
 +
 
 +
// set frame loaded flag
 +
wikEd.frameLoaded = true;
 +
 
 +
return;
 +
};
 +
 
 +
 
 +
//
 +
// wikEd.InitializeFrame: initialize editing iframe after loading
 +
//
 +
 
 +
wikEd.InitializeFrame = function () {
 +
 
 +
// remove event listener
 +
wikEd.frame.removeEventListener('load', wikEd.InitializeFrame, false);
 +
 
 +
// get object shortcuts
 +
wikEd.frameWindow = wikEd.frame.contentWindow;
 +
wikEd.frameDocument = wikEd.frameWindow.document;
 +
wikEd.frameHtml = wikEd.frameDocument.documentElement;
 +
wikEd.frameBody = wikEd.frameDocument.body;
 +
 
 +
// set frame body properties
 +
if (wikEd.highlightSyntax === true) {
 +
if (wikEd.refHide === true) {
 +
wikEd.frameBody.className = 'wikEdFrameBodyNewbie';
 +
}
 +
else {
 +
wikEd.frameBody.className = 'wikEdFrameBodySyntax';
 +
}
 +
}
 +
else {
 +
wikEd.frameBody.className = 'wikEdFrameBodyPlain';
 +
}
 +
wikEd.frameBody.contentEditable = 'true';
 +
if (wikEd.noSpellcheck === true) {
 +
wikEd.frameBody.spellcheck = 'false';
 +
}
 +
 
 +
// disable table resizing controls in Firefox
 +
try {
 +
wikEd.frameDocument.execCommand('enableObjectResizing', false, 'false');
 +
wikEd.frameDocument.execCommand('enableInlineTableEditing', false, 'false');
 +
}
 +
catch (exception) {
 +
}
 +
 
 +
// display iframe, hide textarea, set fullscreen
 +
wikEd.SetEditArea(wikEd.useWikEd, true);
 +
 
 +
// add frame stylesheets
 +
wikEd.frameHtml.className = 'wikEdFrameHtml';
 +
wikEd.direction = wikEd.GetStyle(document.body, 'direction');
 +
wikEd.frameBody.style.direction = wikEd.direction;
 +
wikEd.ApplyCSS(wikEd.frameDocument, wikEd.config.frameCSS);
 +
wikEd.HighlightNamedHideButtonsStylesheet = new wikEd.StyleSheet(wikEd.frameDocument);
 +
 
 +
// copy textarea background style
 +
wikEd.textareaBackgroundColor = wikEd.GetStyle(wikEd.textarea, 'backgroundColor');
 +
if (wikEd.config.frameBackgroundColor === true) {
 +
wikEd.frameInner.style.setProperty('background-color', wikEd.textareaBackgroundColor);
 +
}
 +
 
 +
// adjust font size (px)
 +
wikEd.textSizeInit = parseFloat(wikEd.GetStyle(wikEd.textarea, 'fontSize')) * wikEd.config.textSizeAdjust / 100;
 +
wikEd.textSize = wikEd.textSizeInit;
 +
wikEd.frameBody.style.fontSize = wikEd.textSize + 'px';
 +
 
 +
// copy textarea content into iframe and focus
 +
if (wikEd.useWikEd === true) {
 +
wikEd.ScanPreviewRedlinks();
 +
wikEd.UpdateFrame();
 +
if ( (wikEd.config.focusEdit === true) && (wikEd.previewPage === false) && (wikEd.editSemanticForm === false) ) {
 +
wikEd.frameBody.focus();
 +
}
 +
}
 +
 
 +
// make read only
 +
if (wikEd.readOnly === true) {
 +
wikEd.frameBody.contentEditable = 'false';
 +
}
 +
 
 +
// register frame events
 +
wikEd.frameDocument.addEventListener('keydown', wikEd.KeyFrameHandler, true);
 +
wikEd.frameDocument.addEventListener('keyup', wikEd.KeyFrameHandler, true);
 +
wikEd.frameDocument.addEventListener('keypress', wikEd.KeyFrameHandler, true);
 +
wikEd.frameDocument.addEventListener('click', wikEd.KeyFrameHandler, true);
 +
 
 +
wikEd.frameDocument.addEventListener('keydown', wikEd.KeyHandler, true);
 +
wikEd.frameDocument.addEventListener('mousemove', wikEd.ResizeGripHandler, true);
 +
wikEd.frameDocument.addEventListener('dblclick', wikEd.ResizeFrameResetHandler, true);
 +
 
 +
// register paste events
 +
wikEd.frameDocument.addEventListener('paste', wikEd.PasteFrameHandler, true);
 +
wikEd.frameDocument.addEventListener('drop', wikEd.PasteFrameHandler, true);
 +
wikEd.frameDocument.addEventListener('paste', wikEd.KeyFrameHandler, true);
 +
 
 +
// fullscreen mode
 +
if (wikEd.fullScreenMode === true) {
 +
wikEd.FullScreen(true, true);
 +
}
 +
 
 +
// needed for upload and edit raw watchlist
 +
else {
 +
wikEd.ResizeWindowHandler();
 +
}
 +
 
 +
// unload (leaving page) events
 +
window.addEventListener('pagehide', wikEd.UnloadHandler, false);
 +
 
 +
return;
 +
};
 +
 
 +
 
 +
//
 +
// wikEd.CodeEditorCheck: check for active code editor and .js or .css page
 +
//
 +
 
 +
wikEd.CodeEditorCheck = function () {
 +
 
 +
wikEd.jsPage = false;
 +
wikEd.cssPage = false;
 +
wikEd.useCodeEditor = false;
 +
 
 +
// check if .js or .css page
 +
if ( (wikEd.wikiGlobals.wgCanonicalNamespace == 'MediaWiki') || ( (wikEd.wikiGlobals.wgCanonicalNamespace == 'User') && (wikEd.wikiGlobals.wgTitle.indexOf('/') >= 0) ) ) {
 +
if (/\.js$/.test(wikEd.wikiGlobals.wgTitle) === true) {
 +
wikEd.jsPage = true;
 +
 
 +
}
 +
else if (/\.css$/.test(wikEd.wikiGlobals.wgTitle) === true) {
 +
wikEd.cssPage = true;
 +
}
 +
}
 +
 
 +
// check for code editor
 +
if ( (wikEd.jsPage === true) || (wikEd.cssPage === true) ) {
 +
if (wikEd.wikiGlobals.wgPageContentModel === undefined) {
 +
if (wikEd.GetCookie('wikiEditor-0-codeEditor-enabled') == 1) {
 +
wikEd.useCodeEditor = true;
 +
}
 +
}
 +
else if (wikEd.wikiGlobals.wgPageContentModel != 'wikitext') {
 +
if (wikEd.GetCookie('wikiEditor-0-codeEditor-enabled') == 1) {
 +
wikEd.useCodeEditor = true;
 +
}
 +
}
 +
 
 +
// wait for landing patch: https://gerrit.wikimedia.org/r/#/c/130068/
 +
if ( (window.mw !== undefined) && (window.mw.user !== undefined) && (window.mw.user.options !== undefined) ) {
 +
if (window.mw.user.options.get('usebetatoolbar') == 1) {
 +
wikEd.useBetaToolbar = true;
 +
if (window.mw.user.options.get('usecodeeditor') == 1) {
 +
wikEd.useCodeEditor = true;
 +
}
 +
}
 +
}
 +
}
 +
return;
 +
};
 +
 
 +
 
 +
//
 +
// wikEd.DisableCodeEditorButton: disable CodeEditor button when wikEd is active
 +
//
 +
 
 +
wikEd.DisableCodeEditorButton = function () {
 +
 
 +
if ( (wikEd.config.disableCodeEditorButton === true) && ( (wikEd.useBetaToolbar === true) || (wikEd.wikiEditorBar !== null) ) ) {
 +
var buttons = document.body.getElementsByClassName('tool-button');
 +
var disabled = false;
 +
for (var i = 0; i < buttons.length; i ++) {
 +
var rel = buttons[i].getAttribute('rel');
 +
var title = buttons[i].getAttribute('title');
 +
if (rel == 'codeEditor') {
 +
var buttonClone = buttons[i].cloneNode(true);
 +
buttonClone.setAttribute('rel', rel + '_disabled_by_wikEd');
 +
buttonClone.setAttribute('title', title + wikEd.config.text['wikEdCodeEditorButtonDisabled']);
 +
buttons[i].style.display = 'none';
 +
buttons[i].parentNode.insertBefore(buttonClone, buttons[i]);
 +
disabled = true;
 +
break;
 +
}
 +
}
 +
 
 +
// poll between 0.1 and 12 s
 +
if ( (disabled === false) && (wikEd.codeEditorButtonPollCount < 15) ) {
 +
var delay = 100 + wikEd.codeEditorButtonPollCount * 100;
 +
wikEd.codeEditorButtonPollCount ++;
 +
window.setTimeout(wikEd.DisableCodeEditorButton, delay);
 +
}
 +
}
 +
return;
 +
};
 +
 
 +
 
 +
//
 +
// wikEd.DeleteAccesskeys: remove accesskeys that are defined in wikEd from page elements
 +
//
 +
 
 +
wikEd.DeleteAccesskeys = function () {
 +
 
 +
var accesskeyTags = ['textarea', 'input', 'a'];
 +
for (var i = 0; i < accesskeyTags.length; i ++) {
 +
var accesskeyElements = document.getElementsByTagName(accesskeyTags[i]);
 +
for (var j = 0; j < accesskeyElements.length; j ++) {
 +
var attribute = accesskeyElements[j].getAttribute('accesskey');
 +
if (attribute !== null) {
 +
if (wikEd.buttonKeyCode[ attribute.toUpperCase().charCodeAt(0) ] !== undefined) {
 +
accesskeyElements[j].setAttribute('accesskey', null);
 +
}
 +
}
 +
}
 +
}
 +
return;
 +
};
 +
 
 +
 
 +
//
 +
// wikEd.AutoUpdate: check for the latest version and force-reload to update
 +
//
 +
 
 +
wikEd.AutoUpdate = function () {
 +
 
 +
// check only on non-interaction pages
 +
if (/(\?|&)action=/.test(window.location.search) === true) {
 +
return;
 +
}
 +
 
 +
// check if autoupdate is enabled
 +
if (wikEd.config.autoUpdate !== true) {
 +
return;
 +
}
 +
 
 +
// install bugfix (fix script duplication after @namespace change in version 0.9.127)
 +
if (wikEd.greasemonkey === true) {
 +
var currentVersion = wikEd.VersionToNumber(wikEd.programVersion);
 +
if (currentVersion < 9127000) {
 +
var updatePopup = wikEd.config.text.wikEdGreasemonkeyAutoUpdateBugfix;
 +
var updateURL = wikEd.config.autoUpdateScriptUrlBugfix;
 +
var protocol = document.location.href.replace(/\/\/.*/, '');
 +
updateURL = updateURL.replace(/^(?=\/\/)/, protocol);
 +
updatePopup = updatePopup.replace(/\{updateURL\}/g, updateURL);
 +
window.alert(updatePopup);
 +
window.location.href = updateURL;
 +
}
 +
}
 +
 
 +
// check for forced update check
 +
var forcedUpdate = false;
 +
if (wikEd.config.forcedUpdate !== '') {
 +
 
 +
// get version numbers from strings
 +
var currentVersion = wikEd.VersionToNumber(wikEd.programVersion);
 +
var forcedVersion = wikEd.VersionToNumber(wikEd.config.forcedUpdate);
 +
 
 +
// schedule forced update check
 +
if ( (currentVersion !== '') && (forcedVersion !== '') ) {
 +
if (forcedVersion > currentVersion) {
 +
forcedUpdate = true;
 +
}
 +
}
 +
}
 +
 
 +
// check for regular update
 +
var regularUpdate = false;
 +
var currentDate = new Date();
 +
if (forcedUpdate === false) {
 +
 
 +
// get date of last update check
 +
var lastCheckStr = wikEd.GetPersistent('wikEdAutoUpdate');
 +
var lastCheckDate = new Date(lastCheckStr);
 +
 
 +
// fix missing or corrupt saved setting
 +
if (isNaN(lastCheckDate.valueOf()) === true) {
 +
wikEd.SetPersistent('wikEdAutoUpdate', 'January 1, 1970', 0, '/');
 +
return;
 +
}
 +
 
 +
// get the hours since last update check
 +
var diffHours = (currentDate - lastCheckDate) / 1000 / 60 / 60;
 +
if (wikEd.greasemonkey === true) {
 +
if (diffHours > wikEd.config.autoUpdateHoursGM) {
 +
regularUpdate = true;
 +
}
 +
}
 +
else if (diffHours > wikEd.config.autoUpdateHours) {
 +
regularUpdate = true;
 +
}
 +
}
 +
 
 +
// perform AJAX request to get latest version number
 +
if ( (forcedUpdate === true) || (regularUpdate === true) ) {
 +
 
 +
// save current update check date
 +
wikEd.SetPersistent('wikEdAutoUpdate', currentDate.toUTCString(), 0, '/');
 +
 
 +
// make the ajax request
 +
wikEd.AjaxRequest('GET', wikEd.config.autoUpdateUrl, null, 'text/plain', function (ajax) {
 +
 
 +
// get response
 +
var html = ajax.responseText;
 +
 
 +
// get version numbers from strings
 +
var currentVersion = wikEd.VersionToNumber(wikEd.programVersion);
 +
var newVersion = wikEd.VersionToNumber(html);
 +
 
 +
// check if downloaded version is newer and perform update
 +
if ( (currentVersion !== '') && (newVersion !== '') ) {
 +
if (newVersion > currentVersion) {
 +
wikEd.DoUpdate();
 +
}
 +
}
 +
});
 +
}
 +
return;
 +
};
 +
 
 +
 
 +
//
 +
// wikEd.VersionToNumber: parse version string (1.22.333a) into number 122333097
 +
//
 +
 
 +
wikEd.VersionToNumber = function (versionStr) {
 +
 
 +
var regExpMatchVer = versionStr.match(/(\d+)\.(\d+)\.(\d+)(\w?)/);
 +
if (regExpMatchVer === null) {
 +
return '';
 +
}
 +
var versionNumber = Number(regExpMatchVer[1]) * 100000000 + Number(regExpMatchVer[2]) * 1000000 + Number(regExpMatchVer[3]) * 1000 + (regExpMatchVer[4] + '0').charCodeAt(0);
 +
return versionNumber;
 +
};
 +
 
 +
 
 +
//
 +
// wikEd.DoUpdate: actually perform update
 +
//
 +
 
 +
wikEd.DoUpdate = function () {
 +
 
 +
// update Greasemonkey script by navigating to the script code page
 +
if (wikEd.greasemonkey === true) {
 +
var updatePopup = wikEd.config.text.wikEdGreasemonkeyAutoUpdate;
 +
updatePopup = updatePopup.replace(/\{updateURL\}/g, wikEd.config.autoUpdateUrl);
 +
window.alert(updatePopup);
 +
window.location.href = wikEd.config.autoUpdateScriptUrl;
 +
}
 +
 
 +
// update wikEd by reloading the page with cache bypassing (equivalent to Shift-Reload or Shift-F5)
 +
else {
 +
window.location.reload(true);
 +
}
 +
return;
 +
};
 +
 
 +
 
 +
//
 +
// wikEd.LoadTypoFixRules: load and parse RegExTypoFix rules if the button is enabled
 +
//
 +
 
 +
wikEd.LoadTypoFixRules = function () {
 +
 
 +
// load RegExTypoFix rules per Ajax if enabled
 +
if ( (wikEd.config.regExTypoFix === false) || (wikEd.readOnly === true) || (wikEd.typoRulesFind.length > 0) ) {
 +
return;
 +
}
 +
 
 +
// make the ajax request
 +
var sep = '&';
 +
if (wikEd.config.regExTypoFixURL.indexOf('?') == -1) {
 +
sep = '?';
 +
}
 +
 
 +
wikEd.AjaxRequest('GET', wikEd.config.regExTypoFixURL + sep + wikEd.programVersion, null, 'text/plain', function (ajax) {
 +
 
 +
// get response
 +
var rulesTxt = ajax.responseText;
 +
 
 +
// parse regexp rules
 +
var regExp = /<(?:Typo)?\s+(?:word="(.*?)"\s+)?find="(.*?)"\s+replace="(.*?)"\s*\/?>/g;
 +
var regExpMatch;
 +
while ( (regExpMatch = regExp.exec(rulesTxt)) !== null) {
 +
 
 +
// check if this is a valid regexp
 +
var regExpFind;
 +
try {
 +
regExpFind = new RegExp(regExpMatch[2], 'gm');
 +
}
 +
catch (exception) {
 +
var msg = 'Invalid RegExTypoFix rule:\nfind=' + regExpMatch[2] + '\nreplace=' + regExpMatch[3];
 +
wikEd.ConsoleLog(msg);
 +
continue;
 +
}
 +
 
 +
// save regexp and replace
 +
wikEd.typoRulesFind.push(regExpFind);
 +
wikEd.typoRulesReplace.push(regExpMatch[3]);
 +
}
 +
 
 +
// display typo fix button
 +
if (wikEd.typoRulesFind.length > 0) {
 +
if (wikEd.fixRegExTypo !== null) {
 +
wikEd.fixRegExTypo.style.display = 'inline';
 +
}
 +
}
 +
return;
 +
});
 +
return;
 +
};
 +
 
 +
 
 +
//
 +
// wikEd.EditButtonHandler: handler for clicks on edit buttons
 +
//
 +
 
 +
wikEd.EditButtonHandler = function (event) {
 +
 
 +
// execute the button click handler code, obj required in eval context
 +
var obj = event.currentTarget;
 +
eval(wikEd.editButtonHandler[obj.id]);
 +
return;
 +
};
 +
 
 +
 
 +
//
 +
// wikEd.ShrinkSummaryHandler: shrink the summary after loading the 'Clear summary' image
 +
//
 +
 
 +
wikEd.ShrinkSummaryHandler = function (event) {
 +
 
 +
var diffWidth = wikEd.clearSummary.offsetWidth - wikEd.clearSummaryWidth;
 +
wikEd.inputElement.summary.style.width = (wikEd.inputElement.summary.offsetWidth - diffWidth) + 'px';
 +
wikEd.selectElement.summary.style.width = (wikEd.selectElement.summary.offsetWidth - diffWidth) + 'px';
 +
wikEd.clearSummaryWidth = wikEd.clearSummary.offsetWidth;
 +
return;
 +
};
 +
 
 +
 
 +
//
 +
// wikEd.InsertChangeHandler: resize fullscreen after changing insert special char selection
 +
//
 +
 
 +
wikEd.InsertChangeHandler = function (event) {
 +
if (wikEd.fullscreen === true) {
 +
wikEd.ResizeWindowHandler();
 +
}
 +
};
 +
 
 +
 
 +
//
 +
// wikEd.ResizeWindowHandler: adjust fullscreen frame and summary width after resizing the window
 +
//  browser's dynamic table resizing interferes if wikEd is inserted in table (Special:Upload)
 +
 
 +
wikEd.ResizeWindowHandler = function (event) {
 +
 
 +
// fullscreen resizing
 +
if (wikEd.fullscreen === true) {
 +
var captchaHeight = wikEd.captchaWrapper.offsetHeight;
 +
var debugHeight = wikEd.debugWrapper.offsetHeight;
 +
var buttonsHeight = wikEd.buttonsWrapper.offsetHeight;
 +
 
 +
var consoleTopHeight = 0;
 +
if (wikEd.consoleTopWrapper !== null) {
 +
consoleTopHeight = wikEd.consoleTopWrapper.offsetHeight;
 +
}
 +
 
 +
var consoleHeight = wikEd.consoleWrapper.offsetHeight;
 +
 
 +
var insertHeight = 0;
 +
if (wikEd.insertWrapper !== null) {
 +
insertHeight = wikEd.insertWrapper.offsetHeight;
 +
}
 +
 
 +
var windowHeight = window.innerHeight;
 +
var frameHeight = windowHeight - captchaHeight - debugHeight - buttonsHeight - consoleTopHeight - consoleHeight - insertHeight - wikEd.frameBorderHeight;
 +
if (frameHeight < 100) {
 +
frameHeight = 100;
 +
}
 +
wikEd.frame.style.height = frameHeight + 'px';
 +
wikEd.frame.style.width = (wikEd.frameWrapper.clientWidth - wikEd.frameBorderWidth) + 'px';
 +
}
 +
 
 +
// adjust frame size
 +
else {
 +
wikEd.frameWidth = (wikEd.frameWrapper.clientWidth - wikEd.frameBorderWidth) + 'px';
 +
wikEd.frame.style.height = wikEd.frameHeight;
 +
wikEd.frame.style.width = wikEd.frameWidth;
 +
}
 +
wikEd.ResizeSummary();
 +
return;
 +
};
 +
 
 +
 
 +
//
 +
// wikEd.WikiPreviewHandler: event handler for wiki preview: scroll to edit field on double click
 +
//
 +
 
 +
wikEd.WikiPreviewHandler = function (event) {
 +
 
 +
// filter out selecting double clicks on text
 +
var sel = window.getSelection();
 +
 
 +
// explicitOriginalTarget (Firefox)
 +
var textTarget = event.explicitOriginalTarget;
 +
if (textTarget !== undefined) {
 +
if (textTarget.nodeName == '#text') {
 +
return;
 +
}
 +
}
 +
 
 +
// ignore for non-blank selection
 +
else if ( (sel !== null) && (/^\s*$/.test(sel.toString()) === false) ) {
 +
return;
 +
}
 +
sel.collapseToEnd();
 +
 
 +
window.scroll(0, wikEd.GetOffsetTop(wikEd.inputWrapper));
 +
return;
 +
};
 +
 
 +
 
 +
//
 +
// wikEd.UnloadHandler: save editing frame to cached textarea
 +
//
 +
 
 +
wikEd.UnloadHandler = function (event) {
 +
 
 +
// update textarea if not already done in submit handlers
 +
if (wikEd.useWikEd === true) {
 +
if (wikEd.textareaUpdated === false) {
 +
wikEd.UpdateTextarea();
 +
}
 +
}
 +
return;
 +
};
 +
 
 +
 
 +
//
 +
// wikEd.SaveButtonHandler: 'Save page' onsubmit click handler for submit button
 +
//
 +
 
 +
wikEd.SaveButtonHandler = function (event) {
 +
 
 +
wikEd.saveButton.removeEventListener('click', wikEd.SaveButtonHandler, true);
 +
 
 +
// update textarea
 +
if (wikEd.useWikEd === true) {
 +
wikEd.UpdateTextarea();
 +
wikEd.textareaUpdated = true;
 +
}
 +
 
 +
// check for interfering scripts or gadgets: mwEmbed for file uploads
 +
if ( (wikEd.editUpload === true) && (window.MW_EMBED_VERSION !== undefined) ) {
 +
wikEd.saveButton.addEventListener('click', wikEd.SaveButtonHandler, true);
 +
return;
 +
}
 +
 
 +
// add "using wikEd" to summary, not for adding a new section (+ tab)
 +
if (wikEd.summaryText !== null) {
 +
var text = wikEd.summaryText.value;
 +
text = text.replace(/^[, ]+/, '');
 +
text = text.replace(/[, ]+$/, '');
 +
wikEd.AddToHistory('summary');
 +
 
 +
if ( (wikEd.using === true) && (text !== '') ) {
 +
if (text.lastIndexOf(wikEd.config.summaryUsing) < 0) {
 +
if (wikEd.addNewSection !== true) {
 +
text += ' ' + wikEd.config.summaryUsing;
 +
}
 +
}
 +
}
 +
wikEd.summaryText.value = text;
 +
}
 +
 
 +
// submit
 +
wikEd.saveButton.click();
 +
 
 +
// reinstate handler in case the browser back button will be used
 +
wikEd.saveButton.addEventListener('click', wikEd.SaveButtonHandler, true);
 +
 
 +
return;
 +
};
 +
 
 +
 
 +
//
 +
// wikEd.PreviewButtonHandler: 'Show preview' click handler
 +
//
 +
 
 +
wikEd.PreviewButtonHandler = function (event) {
 +
 
 +
if (wikEd.useWikEd === true) {
 +
wikEd.UpdateTextarea();
 +
wikEd.textareaUpdated = true;
 +
}
 +
return;
 +
};
 +
 
 +
 
 +
//
 +
// wikEd.DiffPreviewButtonHandler: 'Show changes' click handler
 +
//
 +
 
 +
wikEd.DiffPreviewButtonHandler = function (event) {
 +
 
 +
// interrupt fullscreen mode
 +
if (wikEd.fullscreen === true) {
 +
wikEd.FullScreen(false);
 +
}
 +
 
 +
if (wikEd.useWikEd === true) {
 +
wikEd.UpdateTextarea();
 +
wikEd.textareaUpdated = true;
 +
}
 +
return;
 +
};
 +
 
 +
 
 +
//
 +
// wikEd.LinkifyHandler: open innermost highlighted link in new window/tab on ctrl/meta-click
 +
//
 +
 
 +
wikEd.LinkifyHandler = function (event) {
 +
 
 +
if ( (event.shiftKey === false) && ( (event.ctrlKey === true) || (event.metaKey === true) ) && (event.altKey === false) ) {
 +
var node = event.target;
 +
while (node !== null) {
 +
var id = node.id;
 +
if ( (id !== null) && (id.indexOf('wikEdWikiLink') === 0) ) {
 +
if (Object.prototype.hasOwnProperty.call(wikEd.wikiLinks, id) === true) {
 +
var linkUrl = wikEd.wikiLinks[id].url;
 +
event.stopPropagation();
 +
window.open(linkUrl);
 +
window.focus();
 +
break;
 +
}
 +
}
 +
node = node.parentNode;
 +
}
 +
}
 +
return;
 +
};
 +
 
 +
 
 +
//
 +
// wikEd.ButtonBarGripHandler: click, mouseover handler, see also wikEd.ButtonBarInit()
 +
//
 +
 
 +
wikEd.ButtonBarGripHandler = function (event) {
 +
 
 +
event.stopPropagation();
 +
 
 +
var grip = event.target;
 +
var gripWrapper = grip.parentNode;
 +
var buttonsWrapper = gripWrapper.nextSibling;
 +
var barInnerWrapper = gripWrapper.parentNode;
 +
var bar = barInnerWrapper.parentNode;
 +
if (event.type == 'click') {
 +
buttonsWrapper.style.position = 'static';
 +
 
 +
// hide the buttons bar
 +
if (buttonsWrapper.className != 'wikEdButtonBarButtonsWrapperHidden') {
 +
buttonsWrapper.className = 'wikEdButtonBarButtonsWrapperHidden';
 +
barInnerWrapper.className = 'wikEdButtonBarInnerWrapperHidden';
 +
gripWrapper.className = 'wikEdButtonBarGripWrapperHidden';
 +
wikEd.buttonsWrapperWidth[bar.id] = buttonsWrapper.offsetWidth;
 +
buttonsWrapper.style.display = 'none';
 +
grip.addEventListener('mouseover', wikEd.ButtonBarGripHandler, false);
 +
wikEd.SetPersistent(bar.id + 'Hidden', '1', 0, '/');
 +
}
 +
 
 +
// unhide the buttons bar
 +
else {
 +
buttonsWrapper.className = 'wikEdButtonBarButtonsWrapperVisible';
 +
barInnerWrapper.className = 'wikEdButtonBarInnerWrapperVisible';
 +
gripWrapper.className = 'wikEdButtonBarGripWrapperVisible';
 +
buttonsWrapper.style.display = 'block';
 +
grip.removeEventListener('mouseover', wikEd.ButtonBarGripHandler, false);
 +
wikEd.SetPersistent(bar.id + 'Hidden', '0', 0, '/');
 +
}
 +
}
 +
 
 +
// show the buttons bar on mouseover
 +
else if (event.type == 'mouseover') {
 +
if (buttonsWrapper.className == 'wikEdButtonBarButtonsWrapperHidden') {
 +
bar.addEventListener('mouseout', wikEd.ButtonBarHandler, false);
 +
 
 +
// browsers sometimes give offsetTop/offsetLeft - 1, + 0.5 seems to help
 +
 
 +
// show buttons to the right
 +
if (bar.offsetParent.clientWidth > grip.offsetLeft + grip.offsetWidth + wikEd.buttonsWrapperWidth[bar.id] + 0.5) {
 +
buttonsWrapper.style.left = (grip.offsetLeft + grip.offsetWidth + 0.5) + 'px';
 +
}
 +
 
 +
// show buttons to the left
 +
else {
 +
buttonsWrapper.style.left = (gripWrapper.offsetLeft - wikEd.buttonsWrapperWidth[bar.id] + 0.5) + 'px';
 +
}
 +
 
 +
buttonsWrapper.style.top = (gripWrapper.offsetTop + 0.5) + 'px';
 +
buttonsWrapper.style.position = 'absolute';
 +
buttonsWrapper.style.display = 'block';
 +
}
 +
}
 +
return;
 +
};
 +
 
 +
 
 +
//
 +
// wikEd.ButtonBarHandler: mouseout handler
 +
//
 +
 
 +
wikEd.ButtonBarHandler = function (event) {
 +
 
 +
event.stopPropagation();
 +
var bar = event.currentTarget;
 +
var barInnerWrapper = bar.firstChild;
 +
var gripWrapper = barInnerWrapper.firstChild;
 +
var grip = gripWrapper.firstChild;
 +
var buttonsWrapper = gripWrapper.nextSibling;
 +
var buttons = buttonsWrapper.firstChild;
 +
 
 +
// hide the buttons
 +
if (event.type == 'mouseout') {
 +
if (buttonsWrapper.className == 'wikEdButtonBarButtonsWrapperHidden') {
 +
 
 +
// filter the events for mouseouts actually leaving the bar
 +
if (
 +
(
 +
( (event.target == grip) || (event.target == gripWrapper) ) &&
 +
(event.relatedTarget != gripWrapper) && (event.relatedTarget != buttonsWrapper) && (event.relatedTarget != buttons) && (event.relatedTarget.parentNode != buttons)
 +
) ||
 +
(
 +
( (event.target.parentNode.parentNode == buttons) || (event.target.parentNode == buttons) || (event.target == buttons) || (event.target == buttonsWrapper) ) &&
 +
(event.relatedTarget.parentNode.parentNode != buttons) && (event.relatedTarget.parentNode != buttons) && (event.relatedTarget != buttons) && (event.relatedTarget != buttonsWrapper) && (event.relatedTarget != gripWrapper) && (event.relatedTarget != grip)
 +
)
 +
) {
 +
bar.removeEventListener('mouseout', wikEd.ButtonBarHandler, false);
 +
buttonsWrapper.style.display = 'none';
 +
buttonsWrapper.style.position = 'static';
 +
}
 +
}
 +
}
 +
return;
 +
};
 +
 
 +
 
 +
//
 +
// clear the summary click handler
 +
//
 +
 
 +
wikEd.ClearSummaryHandler = function (event) {
 +
 
 +
event.preventDefault();
 +
 
 +
// clear the summary if it is only a paragraph name
 +
if ( /^\/\* .*? \*\/ *$/.test(wikEd.summaryText.value) === true) {
 +
wikEd.summaryText.value = '';
 +
}
 +
 
 +
// clear the summary but leave paragraph names
 +
else {
 +
wikEd.summaryText.value = wikEd.summaryText.value.replace(/^((\/\* .*? \*\/ *)?).*()/,
 +
function(p, p1, p2, p3) {
 +
if (p1.length > 0) {
 +
p1 = p1 + ' ';
 +
}
 +
return p1;
 +
}
 +
);
 +
}
 +
wikEd.summaryText.focus();
 +
return;
 +
};
 +
 
 +
 
 +
//
 +
// wikEd.FindReplaceHandler: find and replace: tab and shift-tab between fields, select on focus
 +
//
 +
 
 +
wikEd.FindReplaceHandler = function (event) {
 +
 
 +
// tab / shift-tab between fields
 +
if (event.type == 'keydown') {
 +
if (event.keyCode == 9) {
 +
if (event.target == wikEd.findText) {
 +
event.preventDefault();
 +
wikEd.replaceText.removeEventListener('focus', wikEd.FindReplaceHandler, true);
 +
wikEd.replaceText.focus();
 +
wikEd.replaceText.addEventListener('focus', wikEd.FindReplaceHandler, true);
 +
}
 +
else if (event.target == wikEd.replaceText) {
 +
event.preventDefault();
 +
wikEd.findText.removeEventListener('focus', wikEd.FindReplaceHandler, true);
 +
wikEd.findText.focus();
 +
wikEd.findText.addEventListener('focus', wikEd.FindReplaceHandler, true);
 +
}
 +
}
 +
}
 +
 
 +
// select on focus
 +
else if (event.type == 'focus') {
 +
event.target.setSelectionRange(0, this.textLength);
 +
}
 +
return;
 +
};
 +
 
 +
 
 +
//
 +
// wikEd.KeyFrameHandler: event handler for key and mouse events in the frame
 +
//
 +
 
 +
wikEd.KeyFrameHandler = function (event) {
 +
 
 +
if (wikEd.useWikEd === true) {
 +
 
 +
// textarea no longer up to date
 +
if ( event.type == 'paste' ) {
 +
wikEd.textareaUpdated = false;
 +
}
 +
 
 +
// invalidate wikify/textify of recently pasted text and textarea status for printable char key presses
 +
else if ( (event.type == 'keydown') || (event.type == 'keypress') ) {
 +
switch (event.keyCode) {
 +
 
 +
// keys that do not change text
 +
case 16: // shift
 +
case 17: // ctrl
 +
case 18: // alt
 +
case 19: // pause/break
 +
case 20: // caps lock
 +
case 33: // page up
 +
case 34: // page down
 +
case 35: // end
 +
case 36: // home
 +
case 37: // left
 +
case 38: // up
 +
case 39: // right
 +
case 40: // down
 +
case 45: // insert
 +
case 91: // windows left
 +
case 91: // windows right
 +
case 93: // select
 +
case 112: // F1
 +
case 113: // F2
 +
case 114: // F3
 +
case 115: // F4
 +
case 116: // F5
 +
case 117: // F6
 +
case 118: // F7
 +
case 119: // F8
 +
case 120: // F9
 +
case 121: // F10
 +
case 122: // F11
 +
case 123: // F12
 +
case 144: // num lock
 +
case 145: // scroll lock
 +
case 182: // my computer
 +
case 183: // my calculator
 +
case 224: // apple
 +
break;
 +
 
 +
// escape ends wikify/textify, all others change text
 +
default:
 +
 
 +
// textarea no longer up to date
 +
if (event.keyCode !== 27) { // escape
 +
wikEd.textareaUpdated = false;
 +
}
 +
 
 +
// invalidate wikify/textify
 +
wikEd.PastedOff();
 +
}
 +
}
 +
 
 +
switch (event.type) {
 +
 
 +
// keydown event
 +
case 'keydown':
 +
switch (event.keyCode) {
 +
 
 +
// tab key, switch between form elements instead of adding multiple spaces
 +
case 9:
 +
if ( (event.shiftKey === false) && (event.ctrlKey === false) && (event.altKey === false) && (event.metaKey === false) ) {
 +
event.preventDefault();
 +
 
 +
// focus the next form element
 +
if (wikEd.addNewSection === true) {
 +
document.getElementById('wpMinoredit').focus();
 +
}
 +
else {
 +
wikEd.summaryText.focus();
 +
}
 +
 
 +
// scroll to text input top
 +
if (wikEd.fullscreen === false) {
 +
window.scroll(0, wikEd.GetOffsetTop(wikEd.inputWrapper));
 +
}
 +
}
 +
break;
 +
}
 +
break;
 +
 
 +
// after cursor movements set cursor position into closest highest text node so that highlighting does not bleed out
 +
case 'keyup':
 +
switch (event.keyCode) {
 +
case 17: // ctrl-v
 +
case 46: // del
 +
wikEd.AntiHighlightBleeding({});
 +
break;
 +
case 37: // left
 +
case 38: // up
 +
case 33: // page up
 +
case  8: // backspace
 +
wikEd.AntiHighlightBleeding({}, null, 'left');
 +
break;
 +
case 39: // right
 +
case 40: // down
 +
case 34: // page down
 +
wikEd.AntiHighlightBleeding({}, null, 'right');
 +
break;
 +
}
 +
break;
 +
case 'click':
 +
wikEd.AntiHighlightBleeding({});
 +
 
 +
// invalidate wikify/textify of recently pasted text after selecting text
 +
if ( (wikEd.paste !== null) && (wikEd.paste.polling === false) ) {
 +
var sel = wikEd.GetSelection();
 +
if (sel.isCollapsed === false) {
 +
 
 +
// check if clicking into selected pasted text
 +
var range = sel.getRangeAt(0);
 +
if (range != wikEd.keepSelRange) {
 +
wikEd.PastedOff();
 +
}
 +
}
 +
}
 +
// run through, no break
 +
 
 +
case 'keypress':
 +
case 'paste':
 +
 
 +
// grey out inactive buttons
 +
wikEd.InactiveButtons();
 +
}
 +
}
 +
return;
 +
};
 +
 
 +
 
 +
//
 +
// wikEd.PasteFrameHandler: event handler for paste and drop events in the edit frame
 +
//
 +
 
 +
wikEd.PasteFrameHandler = function (event) {
 +
 
 +
if (wikEd.useWikEd !== true) {
 +
event.stopPropagation();
 +
wikEd.paste = null;
 +
return;
 +
}
 +
 
 +
var sel = wikEd.GetSelection();
 +
var range = sel.getRangeAt(0);
 +
 
 +
// ignore if still processing previous event
 +
if ( (wikEd.paste !== null) && (wikEd.paste.polling === false) ) {
 +
return;
 +
}
 +
wikEd.paste = {
 +
eventType:        event.type,
 +
atStart:          false,
 +
polling:          true,
 +
blockStart:      false,
 +
blockEnd:        false,
 +
pasteAtEndOfLine: false,
 +
offset:          null,
 +
prevNode:        null,
 +
prevUp:          null,
 +
parent:          null,
 +
prevNodeIndex:    null,
 +
rangeStartNode:  null,
 +
rangeStartOffset: null,
 +
rangeStartAfter:  null,
 +
last:            '',
 +
dropHtml:        null,
 +
sel:              sel,
 +
range:            range
 +
};
 +
 
 +
// get position info before event is performed
 +
var startNode = range.startContainer;
 +
var startOffset = range.startOffset;
 +
var endNode = range.endContainer;
 +
var endOffset = range.endOffset;
 +
switch (event.type) {
 +
 
 +
// drop
 +
case 'drop':
 +
if (event.dataTransfer === undefined) {
 +
return;
 +
}
 +
wikEd.paste.dropHtml = event.dataTransfer.getData('text/html');
 +
break;
 +
 
 +
// paste
 +
case 'paste':
 +
 
 +
// find first previous node up as anchor to recover start node after insertion
 +
wikEd.PasteFindPreviousNode();
 +
break;
 +
}
 +
 
 +
// needed to check if pasted content has been added to frame
 +
wikEd.paste.startNode = startNode;
 +
wikEd.paste.startOffset = startOffset;
 +
wikEd.paste.endNode = endNode;
 +
wikEd.paste.endOffset = endOffset;
 +
 
 +
wikEd.paste.startNodePreviousSibling = startNode.previousSibling;
 +
wikEd.paste.startNodeNextSibling = startNode.nextSibling;
 +
wikEd.paste.endNodePreviousSibling = endNode.previousSibling;
 +
wikEd.paste.endNodeNextSibling = endNode.nextSibling;
 +
 
 +
// detect and process pasted content in edit frame by polling
 +
wikEd.paste.pollCount = 1;
 +
window.setTimeout(wikEd.PastePoll, 1);
 +
 
 +
return;
 +
};
 +
 
 +
 
 +
//
 +
// wikEd.PasteFindPreviousNode: find first previous node up relative to selection as an anchor to recover start node after insertion
 +
//
 +
 
 +
wikEd.PasteFindPreviousNode = function () {
 +
 
 +
var sel = wikEd.paste.sel;
 +
var range = sel.getRangeAt(0);
 +
var node = range.startContainer;
 +
var offset = range.startOffset;
 +
var prevNode = node.previousSibling;
 +
 
 +
// correct startNode into leaf node
 +
if ( (node.nodeName != '#text') && (offset > 0) ) {
 +
var childs = node.childNodes;
 +
if ( (childs.length > 0) && (offset < childs.length) ) {
 +
node = childs.item(offset);
 +
offset = 0;
 +
prevNode = node.previousSibling;
 +
}
 +
}
 +
 
 +
// test for paste at end of line after br
 +
if ( (node.nodeName == '#text') && (offset == node.textContent.length) ) {
 +
if ( (node.nextSibling !== null) && (node.nextSibling.nodeName == 'BR') ) {
 +
wikEd.paste.pasteAtEndOfLine = true;
 +
}
 +
}
 +
else if (node.nodeName == 'BR') {
 +
 
 +
// not in empty line
 +
if ( (node.previousSibling === null) || (node.previousSibling.nodeName != 'BR') ) {
 +
wikEd.paste.pasteAtEndOfLine = true;
 +
}
 +
}
 +
 
 +
// correct <br> into previous text node
 +
if ( (node.nodeName == 'BR') && (prevNode !== null) && (prevNode.nodeName == '#text') ) {
 +
node = prevNode;
 +
offset = node.textContent.length;
 +
prevNode = node.previousSibling;
 +
}
 +
 
 +
// ascend to first node with a previous sibling
 +
var prevUp = 0;
 +
while ( (node != wikEd.frameBody) && (prevNode === null) ) {
 +
node = node.parentNode;
 +
prevUp ++;
 +
prevNode = node.previousSibling;
 +
}
 +
 
 +
// save paste location reference to drop object
 +
if ( (node == wikEd.frameBody) && (offset === 0) ) {
 +
wikEd.paste.atStart = true;
 +
}
 +
else {
 +
wikEd.paste.offset = offset;
 +
wikEd.paste.prevNode = prevNode;
 +
wikEd.paste.prevUp = prevUp;
 +
 
 +
// find prevNode index
 +
wikEd.paste.parent = prevNode.parentNode;
 +
wikEd.paste.prevNodeIndex = null;
 +
var parentNodes = wikEd.paste.parent.childNodes;
 +
for (var i = 0; i < parentNodes.length; i ++) {
 +
if (prevNode === parentNodes.item(i)) {
 +
wikEd.paste.prevNodeIndex = i;
 +
break;
 +
}
 +
}
 +
}
 +
return;
 +
};
 +
 
 +
 
 +
//
 +
// wikEd.PastePoll: detect and process pasted content in edit frame by polling
 +
//
 +
 
 +
wikEd.PastePoll = function () {
 +
 
 +
if (wikEd.paste === null) {
 +
return;
 +
}
 +
 
 +
if (wikEd.paste.pollCount > 100) {
 +
wikEd.paste = null;
 +
return;
 +
}
 +
 
 +
var sel = wikEd.paste.sel;
 +
var range = sel.getRangeAt(0);
 +
var startNode = range.startContainer;
 +
var startOffset = range.startOffset;
 +
var endNode = range.endContainer;
 +
var endOffset = range.endOffset;
 +
 
 +
// check if pasted content has already been added to frame
 +
if (
 +
(startNode === wikEd.paste.startNode) &&
 +
(startOffset === wikEd.paste.startOffset) &&
 +
(endNode === wikEd.paste.endNode) &&
 +
(endOffset === wikEd.paste.endOffset) &&
 +
 
 +
(startNode.previousSibling === wikEd.paste.startNodePreviousSibling) &&
 +
(startNode.nextSibling === wikEd.paste.startNodeNextSibling) &&
 +
(endNode.previousSibling === wikEd.paste.endNodePreviousSibling) &&
 +
(endNode.nextSibling === wikEd.paste.endNodeNextSibling)
 +
) {
 +
 
 +
// schedule next poll, typically requires only one or two polls
 +
wikEd.paste.pollCount ++;<