Content deleted Content added
0.9.96a (November 10, 2010) |
0.9.101 test |
||
Line 4:
// version info
wikEd.programVersion = '0.9.
wikEd.programDate = '
/*
Line 24:
// @description A full-featured in-browser editor for Wikipedia and other MediaWiki edit pages
// @include *
// @homepage http://en.wikipedia.org/wiki/User:Cacycle/wikEd
// @source http://en.wikipedia.org/wiki/User:Cacycle/wikEd.js
Line 49 ⟶ 48:
wikEd.InitGlobalConfigs = function() {
// user readable texts, copy changes to http://en.wikipedia.org/wiki/User:Cacycle/wikEd_international_en.js, also defined in wikEdDiff.js
if (typeof(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',
Line 70 ⟶ 69:
'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)',
Line 83 ⟶ 82:
'wikEdGripControl title': 'wikEd control buttons (click to hide or show)',
// formatting buttons, top row
'wikEdUndo alt': 'Undo',
'wikEdUndo title': 'Undo',
Line 107 ⟶ 106:
'wikEdCase title': 'Toggle between lowercase, uppercase first, and uppercase',
'wikEdSort alt': 'Sort',
'wikEdSort title': 'Sort
'wikEdRedirect alt': 'Redirect',
'wikEdRedirect title': 'Create redirect, deletes whole text',
Line 115 ⟶ 114:
'wikEdRedoAll title': 'Redo all changes',
// formatting buttons, bottom row
'wikEdWikiLink alt': 'Link',
'wikEdWikiLink title': 'Wiki link',
Line 137 ⟶ 136:
'wikEdReferences title': 'References ___location (shift-click: References section)',
// textify buttons
'wikEdWikify alt': 'Wikify',
'wikEdWikify title': 'Convert pasted content to wiki code, update highlighting',
Line 143 ⟶ 142:
'wikEdTextify title': 'Convert pasted content to plain text, update highlighting (shift-click: forced highlighting)',
// find and replace buttons, top row
'wikEdFindAll alt': 'Find all',
'wikEdFindAll title': 'Find all matches',
Line 156 ⟶ 155:
'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',
Line 171 ⟶ 170:
'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',
Line 185 ⟶ 184:
'wikEdFixRedirect title': 'Fix redirects',
// fix buttons, bottom row
'wikEdFixDashes alt': 'Fix dashes',
'wikEdFixDashes title': 'Fix dashes',
Line 199 ⟶ 198:
'wikEdFixRegExTypo title': 'Fix typos using the AutoWikiBrowser RegExTypoFixer rules',
// wikEd control buttons, top row
'wikEdRefHide alt': '[REF, TEMPL]',
'wikEdRefHide title': 'Toggle [REF] and [TEMPL] hiding',
Line 217 ⟶ 216:
'wikEdScrollToEdit title': 'Scroll to edit field',
// wikEd control buttons, bottom row
'wikEdUseWikEd alt': 'Use wikEd',
'wikEdUseWikEd title': 'Toggle between classic text area and wikEd',
Line 235 ⟶ 234:
'wikEdTableMode title': 'Toggle table edit mode',
// summary buttons
'wikEdClearSummary alt': 'Clear summary',
'wikEdClearSummary title': 'Clear the summary field',
Line 246 ⟶ 245:
'wikEdSummaryUsing': '…using [[en:User:Cacycle/wikEd|wikEd]]',
// button title acceskey
'alt-shift': 'alt-shift-',
// submit buttons
'wikEdLocalPreviewImg alt': 'Preview below',
'wikEdLocalPreview title': 'Show preview below',
Line 256 ⟶ 255:
'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',
Line 266 ⟶ 265:
'wikEdScrollToEdit2 title': 'Scroll to edit field',
// preview and changes buttons, bottom
'wikEdScrollToPreview3 alt': 'Scroll to preview',
'wikEdScrollToPreview3 title': 'Scroll to preview field',
Line 272 ⟶ 271:
'wikEdScrollToEdit3 title': 'Scroll to edit field',
// preview field
'wikEdPreviewLoading': '...',
'diffNotLoaded': 'Error: Local diff script not installed.',
// formatting functions
'image filename': 'filename',
'image width': 'width',
Line 284 ⟶ 283:
'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',
Line 300 ⟶ 299:
'talk namespace suffix': '_talk', //// in French it is a prefix (Discussion_Utilisateur)
// hiding buttons
'hideRef': 'REF',
'hideTempl': 'TEMPL',
// shortened button texts
'shortenedPreview': 'Preview',
'shortenedChanges': 'Changes',
// follow link popup
'followLink': '(ctrl-click)',
'followLinkMac': '(cmd-click)',
// error message popups
'wikEdTableModeError': 'The table wikicode contains errors',
// auto updating
'wikEdGreasemonkeyAutoUpdate': 'wikEd Update:\n\nA new version of the GreaseMonkey script "wikEd" is available.\n\n\nIt will be downloaded from:\n\n{updateURL}',
// highlighting popups
'hyphenDash': 'Standard hyphen',
'figureDash': 'Figure dash',
Line 332 ⟶ 331:
'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',
Line 352 ⟶ 351:
'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>'
Line 361 ⟶ 360:
};
// 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 (typeof(wikEd.config.useLocalImages) == 'undefined') { wikEd.config.useLocalImages = false; }
// path to local images for testing, also defined in wikEdDiff.js
if (typeof(wikEd.config.imagePathLocal) == 'undefined') { wikEd.config.imagePathLocal = 'file:///D:/wikEd/images/'; }
// path to images, also defined in wikEdDiff.js
if (typeof(wikEd.config.imagePath) == 'undefined') { wikEd.config.imagePath = '
// image filenames, also defined in wikEdDiff.js
if (typeof(wikEd.config.image) == 'undefined') { wikEd.config.image = {}; }
// wikEd.InitImages: define built-in image URLs
wikEd.InitImages = function() {
WED('wikEd.config.imagePath', wikEd.config.imagePath);
wikEd.InitImage(wikEd.config.image, {
'barDash': '5/52/WikEd_bar_dash.png',
Line 424 ⟶ 426:
'ideographicSpace': 'c/c6/WikEd_ideographic_space.png',
'image': '3/37/WikEd_image.png',
'incompatible': '
'indentList': '7/7a/WikEd_indent_list.png',
'italic': 'd/d4/WikEd_italic.png',
Line 476 ⟶ 478:
};
// edit-frame css rules
if (typeof(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;',
'.wikEdFrameBodyPlain': 'height: auto; min-height: 100%; width: auto; background: transparent; margin: 0; padding: 0; padding-left: 0.25em; overflow: auto; font-family: monospace;',
Line 491 ⟶ 493:
'.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; text-shadow: white -1px -1px 0, white -1px 0 0, white -1px 1px 0, white 0 -1px 0, white 0 1px 0, white 1px -1px 0, white 1px 0 0, white 1px 1px 0;',
'.wikEdHighlightError': 'color: black; background: #faa;',
Line 510 ⟶ 512:
'.wikEdComment': 'background: #fff0d0; text-shadow: none; color: black; font-weight: normal; font-style: normal; text-decoration: none;',
'.wikEdKeep': '',
'.wikEdDel': 'text-decoration: line-through;',
'.wikEdIns': 'text-decoration: underline;',
Line 517 ⟶ 520:
'.wikEdNowiki': 'background: #e8e8e8; text-shadow: none;',
// horizontal rule
'.wikEdHr': 'background: #666; text-shadow: none; color: #ffffff;',
// wiki code
'.wikEdWiki': 'color: #777;',
'.wikEdRedir': 'color: #c00; font-weight: bold;',
Line 527 ⟶ 530:
'.wikEdParserFunct': 'color: #f00;',
// headings
'.wikEdFrameBodySyntax .wikEdHeading': 'color: #000; font-weight: bold;',
'.wikEdFrameBodySyntax .wikEdHeadingWP': 'color: #000; font-weight: bold; background: #e8e8e8; text-shadow: none;',
Line 535 ⟶ 538:
'color: #000; font-weight: bold; color: #000; background: #ddd; padding: 0 0.25em; border: 1px solid #ccc; font-size: larger; line-height: 1.5; text-shadow: #eee -1px -1px 0; ',
// tables
'.wikEdTable': 'color: #000; background: #e8e8e8; text-shadow: none;',
'.wikEdTableTag': 'color: #777;',
// list
'.wikEdList': 'color: #000; background: #e8e8e8; text-shadow: none;',
'.wikEdListTag': 'font-weight: bold; font-family: monospace; vertical-align: text-bottom;',
// space-pre
'.wikEdSpace': 'color: #000; background: #e8e8e8; text-shadow: none;',
'.wikEdSpaceTag': 'background: #e8e8e8; text-shadow: none;',
// links
'.wikEdLinkTag': 'color: #777;',
// wiki links
'.wikEdLink': '',
'.wikEdLinkCrossNs': 'background: #ddd; text-shadow: none;',
Line 566 ⟶ 569:
'span.wikEdISBN:hover': 'text-decoration: underline;',
// external links
'.wikEdURL': '',
'.wikEdURLName': 'color: #00e; font-weight: bold;',
Line 574 ⟶ 577:
'span.wikEdURLText:hover': 'text-decoration: underline;',
// images
'.wikEdFile': 'background: rgb(213, 255, 176); background: rgba(199, 255, 149, 0.75); text-shadow: none;',
'.wikEdFrameBodyNewbie .wikEdFile':
Line 586 ⟶ 589:
'position: static; float: right; clear: both; background: transparent; padding: 0; ',
// categories
'.wikEdCat': 'background: #ccc; text-shadow: none;',
'.wikEdCatName': 'color: #00e;',
Line 594 ⟶ 597:
'.wikEdCat span.wikEdLinkText:hover': 'text-decoration: none;',
// refs
'.wikEdFrameBodySyntax .wikEdRefContainer': 'display: none;',
Line 613 ⟶ 616:
'.wikEdRefName': 'color: #000;',
// templates
'.wikEdFrameBodySyntax .wikEdTemplContainer': 'display: none;',
'.wikEdTemplContainer': 'position: relative; top: 1em;',
Line 632 ⟶ 635:
'.wikEdParamDefault': 'color: #000;',
// character entities
'.wikEdFrameBodySyntax .wikEdCharEntityContainer': 'display: none;',
Line 649 ⟶ 652:
'color: #000; background: #e8e8e8; text-shadow: none;',
// 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;',
// wikEd.frameBodyNewbie ref and template hiding
'.wikEdFrameBodyNewbie .wikEdRefContainer + .wikEdRef, .wikEdFrameBodyNewbie .wikEdTemplContainer + .wikEdTempl, .wikEdFrameBodyNewbie .wikEdTemplContainer .wikEdTemplNs, .wikEdFrameBodyNewbie wikEd.refContainer + .wikEdRefShow, .wikEdFrameBodyNewbie .wikEdTemplContainer + .wikEdTemplShow, .wikEdFrameBodyNewbie .wikEdTemplContainer + .wikEdTemplNsShow':
'display: none; color: #000; background: #f8f8f8; font-weight: normal; border: 1px solid; border-color: #444 #ccc #ccc #444; padding: 1em 0.25em 1em 0.25em; position: relative;',
Line 675 ⟶ 678:
'content: "{wikEdText:hideTempl}";',
// table edit
'.wikEdTableEdit': 'border: solid black; border-width: 1px 1px 0 0; background: red; text-shadow: none; background-image: url({wikEdImage:tableBG}); border-collapse: separate; border-spacing: 0;',
'.wikEdTableEdit td': 'border: solid black; border-width: 0 0 1px 1px; background: white; text-shadow: none;',
Line 682 ⟶ 685:
'.wikEdTableEdit caption': 'background: lightgrey; text-shadow: none; font-weight: normal;',////
// insert wikicode here
'.wikEdInsertHere': 'background: orange; text-shadow: none; font-style: italic;',
// colors
'.wikEdColorsLight': 'color: black; text-shadow: none;',
'.wikEdColorsDark': 'color: white; text-shadow: none;',
// 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;',
Line 699 ⟶ 702:
'.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;',
Line 712 ⟶ 715:
};
// main window css rules
if (typeof(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;',
Line 726 ⟶ 729:
};
// main window css rules for edit pages only
if (typeof(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': 'font-size: smaller; padding-left: 0.1em; padding-right: 0.1em; margin: 0 0.1em 0 0.1em; height: 1.6em; vertical-align: bottom;',
// wikEd button areas
// button bar margins
'.wikEdButtonBarFormat': 'margin: 0 8px 3px 1px; float: left;',
'.wikEdButtonBarTextify': 'margin: 0 8px 3px 1px; float: left;',
Line 751 ⟶ 754:
'.wikEdButtonBarJump': 'margin: 0 0 0 0.6em; float: right;',
// button bar inner wrapper: border (hidden: invisible)
'.wikEdButtonBarInnerWrapperVisible': 'border: 1px solid; border-color: #e0e0e0 #808080 #808080 #e0e0e0;',
'.wikEdButtonBarInnerWrapperHidden': '',
// button bar grip wrapper: invisible (hidden: border)
'.wikEdButtonBarGripWrapperVisible': 'float: left;',
'.wikEdButtonBarGripWrapperHidden': 'float: left; border: 1px solid; border-color: #e0e0e0 #808080 #808080 #e0e0e0;',
// button bar buttons wrapper: invisible (hidden: border)
'.wikEdButtonBarButtonsWrapperVisible': 'float: left; background: #d4d0cc; ',
'.wikEdButtonBarButtonsWrapperHidden': 'float: left; background: #d4d0cc; border: 1px solid; border-color: #e0e0e0 #808080 #808080 #e0e0e0; z-index: 4;',
// button bar grip
'.wikEdButtonBarGrip': 'background: #d4d0cc; padding: 0; background-image: url({wikEdImage:grip}); background-repeat: repeat-y; cursor: pointer;',
// button bar buttons
'.wikEdButtonsFormat': 'background: #d4d0cc; padding: 2px 2px 0 0px;',
'.wikEdButtonsTextify': 'background: #d4d0cc; padding: 2px 2px 0 0px;',
Line 780 ⟶ 783:
'.wikEdButtonsJump': 'background: #d4d0cc; padding: 2px; border: 1px solid; border-color: #e0e0e0 #808080 #808080 #e0e0e0;',
// 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: #e4e0dd; border: 1px outset !important; cursor: pointer;',
Line 794 ⟶ 797:
'input#wpDiff, input#wpPreview': 'margin-right: 0;', // monobook fix
'.wikEdButtonDummy': 'vertical-align: text-top; margin: 1px 2px; padding: 1px; background: #d4d0cc;',
// preview box
'.wikEdPreviewBoxOuter': 'clear: both; margin: 0; border-width: 1px; border-style: solid; border-color: #808080 #d0d0d0 #d0d0d0 #808080;',
'.wikEdPreviewBox': 'background: #faf8f6; padding: 5px; border-width: 1px; border-style: solid; border-color: #404040 #ffffff #ffffff #404040;',
Line 801 ⟶ 804:
'.wikEdPreviewDiffError': 'padding: 0.5em; font-weight: bold; color: red; text-align: center;',
// find field
'.wikEdFindComboInput': 'position: relative; padding: 0; margin: 0 0.2em; white-space: nowrap; top: 0; vertical-align: bottom;',
'#wikEdFindText': 'vertical-align: 0%; font-family: monospace; padding: 0; margin: 0; position: absolute; z-index: 2; -moz-box-sizing: content-box; left: 0; top: 1px; height: 14px; width: 170px;',
'#wikEdFindSelect': 'vertical-align: 0%; font-family: monospace; padding: 0; margin: 0; position: relative; z-index: 1; -moz-box-sizing: content-box; left: 0; top: 0px; height: 18px; border: none;',
// replace field
'.wikEdReplaceComboInput': 'position: relative; padding: 0; margin: 0 0.2em; white-space: nowrap; top: 0; vertical-align: bottom;',
'#wikEdReplaceText': 'vertical-align: 0%; font-family: monospace; padding: 0; margin: 0; position: absolute; z-index: 2; -moz-box-sizing: content-box; left: 0; top: 1px; height: 14px; width: 170px;',
'#wikEdReplaceSelect': 'vertical-align: 0%; font-family: monospace; padding: 0; margin: 0; position: relative; z-index: 1; -moz-box-sizing: content-box; left: 0; top: 0px; height: 18px; border: none; ',
// summary field
'.wikEdSummaryComboInput': 'position: relative; padding: 0; margin: 0 0 0 0.1em; white-space: nowrap; top: 0; vertical-align: text-bottom;',
'.wikEdSummaryText': 'vertical-align: 0%; padding: 0; margin: 0; position: absolute; z-index: 2; -moz-box-sizing: content-box; left: 0; top: 0px; height: 18px; width: auto;',
'.wikEdSummarySelect': 'vertical-align: 0%; padding: 0; margin: 0; position: relative; z-index: 1; -moz-box-sizing: content-box; left: 0; top: 1px; height: 21px; border: none;',
// 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;',
'.wikEdFrameInner': 'float: left; width: auto; background: white; border: 1px solid; border-color: #404040 #ffffff #ffffff #404040;',
'.wikEdFrame': 'border: 0;',
// summary
'.wikEdSummaryWrapper': 'margin: 0 0 0.4em 0; width: 100%',
'.wikEdSummaryWrapperTop': 'margin: 0.1em 0 0.4em 0; width: 100%',
Line 832 ⟶ 835:
'.wikEdClearSummary': 'vertical-align: middle; margin: 0 0.1em 0 0.5em; padding: 0 0 0.2em 0;',
// input wrapper
'.wikEdInputWrapper': 'z-index: 100; clear: both; margin-top: 0.5em;',
'.wikEdInputWrapperFull': 'position: fixed; top: 0; left: 0; right: 0; padding: 4px; background: white; z-index: 100;',
// other wrappers
'.wikEdEditorWrapper': '',
'.wikEdToolbarWrapper': 'margin: 0 0 0.25em 0;',
Line 855 ⟶ 858:
'.wikEdInsertWrapper': '',
// various
'.wikEdEditOptions': 'display: inline-block; white-space: nowrap; vertical-align: text-top;',
'.wikEdEditOptions LABEL': 'vertical-align: text-bottom;',
'#editpage-specialchars': 'clear: both;',
// wDiff
'.wDiffParagraph:before': 'content: "¶";'
});
};
// buttons (id, class, popup title, image src, width, height, alt text, click code)
if (typeof(wikEd.config.button) == 'undefined') { wikEd.config.button = {}; }
// 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)
wikEd.InitButton = function() {
wikEd.InitObject(wikEd.config.button, {
// workaround for mozilla 3.0 bug 441087: objId = obj.id; eventShiftKey = event.shiftKey;
// format top
1: ['wikEdUndo', 'wikEdButtonInactive', wikEd.config.text['wikEdUndo title'], wikEd.config.image['undo'], '16', '16', wikEd.config.text['wikEdUndo alt'], 'wikEd.EditButton(obj, objId);' ],
2: ['wikEdRedo', 'wikEdButtonInactive', wikEd.config.text['wikEdRedo title'], wikEd.config.image['redo'], '16', '16', wikEd.config.text['wikEdRedo alt'], 'wikEd.EditButton(obj, objId);' ],
Line 891 ⟶ 894:
14: ['wikEdRedoAll', 'wikEdButtonInactive', wikEd.config.text['wikEdRedoAll title'], wikEd.config.image['redoAll'], '16', '16', wikEd.config.text['wikEdRedoAll alt'], 'wikEd.EditButton(obj, objId);' ],
// format bottom
15: ['wikEdWikiLink', 'wikEdButton', wikEd.config.text['wikEdWikiLink title'], wikEd.config.image['wikiLink'], '16', '16', wikEd.config.text['wikEdWikiLink alt'], 'wikEd.EditButton(obj, objId);' ],
16: ['wikEdWebLink', 'wikEdButton', wikEd.config.text['wikEdWebLink title'], wikEd.config.image['webLink'], '16', '16', wikEd.config.text['wikEdWebLink alt'], 'wikEd.EditButton(obj, objId);' ],
Line 903 ⟶ 906:
11: ['wikEdReferences', 'wikEdButton', wikEd.config.text['wikEdReferences title'], wikEd.config.image['references'], '16', '16', wikEd.config.text['wikEdReferences alt'], 'if (!eventShiftKey) { wikEd.EditButton(obj, objId); } else { wikEd.EditButton(obj, \'wikEdReferencesSection\'); }' ],
// wikify, textify
26: ['wikEdWikify', 'wikEdButton', wikEd.config.text['wikEdWikify title'], wikEd.config.image['wikify'], '16', '16', wikEd.config.text['wikEdWikify alt'], 'wikEd.EditButton(obj, objId);' ],
27: ['wikEdTextify', 'wikEdButton', wikEd.config.text['wikEdTextify title'], wikEd.config.image['textify'], '16', '16', wikEd.config.text['wikEdTextify alt'], 'if (eventShiftKey) { wikEd.EditButton(obj, objId, \'shift\'); } else { wikEd.EditButton(obj, objId); }' ],
// control top
77: ['wikEdRefHide', 'wikEdButtonUnchecked', wikEd.config.text['wikEdRefHide title'], wikEd.config.image['refHide'], '16', '16', wikEd.config.text['wikEdRefHide alt'], 'wikEd.Button(obj, objId, true);' ],
29: ['wikEdTextZoom', 'wikEdButton', wikEd.config.text['wikEdTextZoom title'], wikEd.config.image['textZoom'], '16', '16', wikEd.config.text['wikEdTextZoom alt'], 'if (!eventShiftKey) { wikEd.Button(obj, \'wikEdTextZoomDown\'); } else { wikEd.Button(obj, \'wikEdTextZoomUp\'); }' ],
Line 914 ⟶ 917:
32: ['wikEdScrollToEdit', 'wikEdButton', wikEd.config.text['wikEdScrollToEdit title'], wikEd.config.image['scrollToEditDown'], '16', '16', wikEd.config.text['wikEdScrollToEdit alt'], 'wikEd.Button(obj, objId);' ],
// control bottom
33: ['wikEdUseWikEd', 'wikEdButtonChecked', wikEd.config.text['wikEdUseWikEd title'], wikEd.config.image['useWikEd'], '16', '16', wikEd.config.text['wikEdUseWikEd alt'], 'wikEd.Button(obj, objId, true);' ],
34: ['wikEdHighlightSyntax', 'wikEdButtonUnchecked', wikEd.config.text['wikEdHighlightSyntax title'], wikEd.config.image['highlightSyntax'], '16', '16', wikEd.config.text['wikEdHighlightSyntax alt'], 'wikEd.Button(obj, objId, true);' ],
Line 923 ⟶ 926:
79: ['wikEdTableMode', 'wikEdButtonUnchecked', wikEd.config.text['wikEdTableMode title'], wikEd.config.image['tableMode'], '16', '16', wikEd.config.text['wikEdTableMode alt'], 'wikEd.Button(obj, objId, 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, objId);' ],
40: ['wikEdFindPrev', 'wikEdButton', wikEd.config.text['wikEdFindPrev title'], wikEd.config.image['findPrev'], '16', '16', wikEd.config.text['wikEdFindPrev alt'], 'wikEd.EditButton(obj, objId);' ],
Line 930 ⟶ 933:
44: ['wikEdJumpNext', 'wikEdButton', wikEd.config.text['wikEdJumpNext title'], wikEd.config.image['jumpNext'], '16', '16', wikEd.config.text['wikEdJumpNext alt'], 'wikEd.EditButton(obj, objId);' ],
// find bottom
46: ['wikEdReplaceAll', 'wikEdButton', wikEd.config.text['wikEdReplaceAll title'], wikEd.config.image['replaceAll'], '16', '16', wikEd.config.text['wikEdReplaceAll alt'], 'wikEd.EditButton(obj, objId);' ],
47: ['wikEdReplacePrev', 'wikEdButton', wikEd.config.text['wikEdReplacePrev title'], wikEd.config.image['replacePrev'], '16', '16', wikEd.config.text['wikEdReplacePrev alt'], 'wikEd.EditButton(obj, objId);' ],
Line 938 ⟶ 941:
51: ['wikEdFindAhead', 'wikEdButtonUnchecked', wikEd.config.text['wikEdFindAhead title'], wikEd.config.image['findAhead'], '16', '16', wikEd.config.text['wikEdFindAhead alt'], 'wikEd.Button(obj, objId, 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, objId);' ],
53: ['wikEdFixHtml', 'wikEdButton', wikEd.config.text['wikEdFixHtml title'], wikEd.config.image['fixHtml'], '16', '16', wikEd.config.text['wikEdFixHtml alt'], 'wikEd.EditButton(obj, objId);' ],
Line 947 ⟶ 950:
57: ['wikEdFixRegExTypo', 'wikEdButton', wikEd.config.text['wikEdFixRegExTypo title'], wikEd.config.image['fixRegExTypo'], '16', '16', wikEd.config.text['wikEdFixRegExTypo alt'], 'wikEd.EditButton(obj, objId);' ],
// fix bottom
58: ['wikEdFixDashes', 'wikEdButton', wikEd.config.text['wikEdFixDashes title'], wikEd.config.image['fixDash'], '16', '16', wikEd.config.text['wikEdFixDashes alt'], 'wikEd.EditButton(obj, objId);' ],
59: ['wikEdFixPunct', 'wikEdButton', wikEd.config.text['wikEdFixPunct title'], wikEd.config.image['fixPunct'], '16', '16', wikEd.config.text['wikEdFixPunct alt'], 'wikEd.EditButton(obj, objId);' ],
Line 954 ⟶ 957:
62: ['wikEdFixUnits', 'wikEdButton', wikEd.config.text['wikEdFixUnits title'], wikEd.config.image['fixUnits'], '16', '16', wikEd.config.text['wikEdFixUnits alt'], 'wikEd.EditButton(obj, objId);' ],
// preview top
65: ['wikEdClose', 'wikEdButton', wikEd.config.text['wikEdClose title'], wikEd.config.image['close'], '16', '16', wikEd.config.text['wikEdClose alt'], 'wikEd.Button(obj, objId);' ],
66: ['wikEdScrollToPreview2', 'wikEdButton', wikEd.config.text['wikEdScrollToPreview2 title'], wikEd.config.image['scrollToPreviewDown'], '16', '16', wikEd.config.text['wikEdScrollToPreview2 alt'], 'wikEd.Button(obj, objId);' ],
67: ['wikEdScrollToEdit2', 'wikEdButton', wikEd.config.text['wikEdScrollToEdit2 title'], wikEd.config.image['scrollToEdit'], '16', '16', wikEd.config.text['wikEdScrollToEdit2 alt'], 'wikEd.Button(obj, objId);' ],
// preview bottom
70: ['wikEdClose2', 'wikEdButton', wikEd.config.text['wikEdClose2 title'], wikEd.config.image['close'], '16', '16', wikEd.config.text['wikEdClose2 alt'], 'wikEd.Button(obj, objId);' ],
71: ['wikEdScrollToPreview3', 'wikEdButton', wikEd.config.text['wikEdScrollToPreview3 title'], wikEd.config.image['scrollToPreview'], '16', '16', wikEd.config.text['wikEdScrollToPreview3 alt'], 'wikEd.Button(obj, objId);' ],
72: ['wikEdScrollToEdit3', 'wikEdButton', wikEd.config.text['wikEdScrollToEdit3 title'], wikEd.config.image['scrollToEdit'], '16', '16', wikEd.config.text['wikEdScrollToEdit3 alt'], 'wikEd.Button(obj, objId);' ],
// jump
78: ['wikEdDiff', 'wikEdButtonUnchecked', wikEd.config.text['wikEdDiff title'], wikEd.config.image['wikEdDiff'], '16', '16', wikEd.config.text['wikEdDiff alt'], 'wikEd.Button(obj, objId, true);' ],
74: ['wikEdScrollToEdit4', 'wikEdButtonSolo', wikEd.config.text['wikEdScrollToEdit4 title'], wikEd.config.image['scrollToEditDown'], '16', '16', wikEd.config.text['wikEdScrollToEdit4 alt'], 'wikEd.Button(obj, objId);' ],
// 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, objId);' ],
83: ['wikEdLocalDiff', 'wikEdLocalDiff', wikEd.config.text['wikEdLocalDiff title'], wikEd.config.image['diff'], '16', '16', wikEd.config.text['wikEdLocalDiffImg alt'], 'wikEd.Button(obj, objId);' ]
Line 977 ⟶ 980:
};
// button access keys
if (typeof(wikEd.config.buttonKey) == 'undefined') { wikEd.config.buttonKey = {}; }
// wikEd.InitButtonKey: define accesskeys for edit buttons (wikEd button number: [key string, JS key code])
wikEd.InitButtonKey = function() {
wikEd.InitObject(wikEd.config.buttonKey, {
Line 992 ⟶ 995:
};
// button bars (id, class, button numbers)
if (typeof(wikEd.config.buttonBar) == 'undefined') { wikEd.config.buttonBar = {}; }
// wikEd.InitButtonBar: define built-in button bars (id outer, class outer, id inner, class inner, height, grip title, button numbers)
wikEd.InitButtonBar = function() {
wikEd.InitObject(wikEd.config.buttonBar, {
Line 1,011 ⟶ 1,014:
};
// history length for find, replace, and summary fields
if (typeof(wikEd.config.historyLength) == 'undefined') { wikEd.config.historyLength = {}; }
wikEd.InitHistoryLength = function() {
Line 1,021 ⟶ 1,024:
};
// presets for combo input fields dropdown options, {wikEdUsing} appends a link to this script
if (typeof(wikEd.config.comboPresetOptions) == 'undefined') { wikEd.config.comboPresetOptions = {}; }
if (typeof(wikEd.config.comboPresetOptions.summary) == 'undefined') { wikEd.config.comboPresetOptions.summary = wikEd.config.text.wikEdPresetSummary; }
// text for summary link to this script
if (typeof(wikEd.config.summaryUsing) == 'undefined') { wikEd.config.summaryUsing = wikEd.config.text.wikEdSummaryUsing; }
// expiration time span for permanent cookies in seconds
if (typeof(wikEd.config.cookieExpireSec) == 'undefined') { wikEd.config.cookieExpireSec = 1 * 30 * 24 * 60 * 60; }
// disable wikEd preset
if (typeof(wikEd.config.disabledPreset) == 'undefined') { wikEd.config.disabledPreset = false; }
// find ahead as you type checkbox preset
if (typeof(wikEd.config.findAheadSelected) == 'undefined') { wikEd.config.findAheadSelected = true; }
// highlight syntax preset
if (typeof(wikEd.config.highlightSyntaxPreset) == 'undefined') { wikEd.config.highlightSyntaxPreset = true; }
// enable wikEd preset
if (typeof(wikEd.config.useWikEdPreset) == 'undefined') { wikEd.config.useWikEdPreset = true; }
// add '...using wikEd' to summary preset
if (typeof(wikEd.config.usingPreset) == 'undefined') { wikEd.config.usingPreset = false; }
// scroll to edit field on non-preview pages
if (typeof(wikEd.config.scrollToEdit) == 'undefined') { wikEd.config.scrollToEdit = true; }
// focus the edit field on non-preview pages
if (typeof(wikEd.config.focusEdit) == 'undefined') { wikEd.config.focusEdit = true; }
// wikEdDiff preset
if (typeof(wikEd.config.diffPreset) == 'undefined') { wikEd.config.diffPreset = false; }
// fullscreen mode preset
if (typeof(wikEd.config.fullScreenModePreset) == 'undefined') { wikEd.config.fullScreenModePreset = false; }
// show MediaWiki toolbar preset
if (typeof(wikEd.config.closeToolbarPreset) == 'undefined') { wikEd.config.closeToolbarPreset = false; }
// hide ref tags preset
if (typeof(wikEd.config.refHidePreset) == 'undefined') { wikEd.config.refHidePreset = false; }
// text size adjustment for edit window (percentage)
if (typeof(wikEd.config.textSizeAdjust) == 'undefined') { wikEd.config.textSizeAdjust = 100; }
// remove invisible syntax highlighting comments after closing tag
if (typeof(wikEd.config.removeHighlightComments) == 'undefined') { wikEd.config.removeHighlightComments = true; }
// show the text-to-source button for testing purposes
if (typeof(wikEd.config.showSourceButton) == 'undefined') { wikEd.config.showSourceButton = false; }
// show the using-wikEd button
if (typeof(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 (typeof(wikEd.config.helpPageLink) == 'undefined') { wikEd.config.helpPageLink = wikEd.config.text.wikEdHelpPageLink; }
// enable external diff script
if (typeof(wikEd.config.loadDiffScript) == 'undefined') { wikEd.config.loadDiffScript = true; }
// enable external wikEdDiff script
if (typeof(wikEd.config.loadDiff) == 'undefined') { wikEd.config.loadDiff = true; }
// enable external InstaView script
if (typeof(wikEd.config.loadInstaView) == 'undefined') { wikEd.config.loadInstaView = true; }
// enable external IERange script
if (typeof(wikEd.config.loadIERange) == 'undefined') { wikEd.config.loadIERange = true; }
// RegExTypoFix rules page, the address must have the exact same ___domain name as the used wiki
if (typeof(wikEd.config.regExTypoFixURL) == 'undefined') { wikEd.config.regExTypoFixURL = wikEd.config.homeBaseUrl + 'w/index.php?title=Wikipedia:AutoWikiBrowser/Typos&action=raw'; }
// enable RegExTypoFix button (http://en.wikipedia.org/wiki/User:Mboverload/RegExTypoFix)
if (typeof(wikEd.config.regExTypoFix) == 'undefined') { wikEd.config.regExTypoFix = false; }
// enable highlighting as links
if (typeof(wikEd.config.followHighlightedLinks) == 'undefined') { wikEd.config.followHighlightedLinks = false; }
// skip the browser detection to run wikEd under IE and Opera
if (typeof(wikEd.config.skipBrowserTest) == 'undefined') { wikEd.config.skipBrowserTest = false; }
// skip the script test that disables wikEd if certain scripts are present
if (typeof(wikEd.config.skipScriptTest) == 'undefined') { wikEd.config.skipScriptTest = false; }
// skip the read-only detection
if (typeof(wikEd.config.skipReadOnlyTest) == 'undefined') { wikEd.config.skipReadOnlyTest = false; }
// button access keys
if (typeof(wikEd.config.incompatibleScripts) == 'undefined') { wikEd.config.incompatibleScripts = {}; }
// wikEd.InitIncompatibleScripts: disable wikEd if incompatible scripts are active
// error message name: case insensitive regExp for script file name from URL w/o .js, use \\ for \
wikEd.InitIncompatibleScripts = function() {
wikEd.InitObject(wikEd.config.incompatibleScripts, {
'CKEditor': '
'FCKEditor': 'fckeditor
'less edit clutter': 'less.?edit.?clutter', // [[User:Magnus_Manske/less_edit_clutter.js]]
'MagnusEditBox': 'MagnusEditBox' // less_edit_clutter gadget on fr
});
};
// set the button bar grip width in px
if (typeof(wikEd.config.buttonBarGripWidth) == 'undefined') { wikEd.config.buttonBarGripWidth = 8; }
// enable local preview (Pilaf's InstaView)
if (typeof(wikEd.config.useLocalPreview) == 'undefined') { wikEd.config.useLocalPreview = true; }
// allow ajax requests from local copy for testing, also defined in wikEdDiff.js
if (typeof(wikEd.config.allowLocalAjax) == 'undefined') { wikEd.config.allowLocalAjax = false; }
// enable server preview (Ajax)
if (typeof(wikEd.config.useAjaxPreview) == 'undefined') { wikEd.config.useAjaxPreview = true; }
// enable appending '<references/> for Ajax section previews
if (typeof(wikEd.config.SectionPreviewRefs) == 'undefined') { wikEd.config.SectionPreviewRefs = true; }
// enable auto update (Ajax)
if (typeof(wikEd.config.autoUpdate) == 'undefined') { wikEd.config.autoUpdate = true; }
// hours between update check (monobook.js)
if (typeof(wikEd.config.autoUpdateHours) == 'undefined') { wikEd.config.autoUpdateHours = 20; }
// hours between update check (Greasemonkey)
if (typeof(wikEd.config.autoUpdateHoursGM) == 'undefined') { wikEd.config.autoUpdateHoursGM = 40; }
// auto update: version url (Ajax)
if (typeof(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 (typeof(wikEd.config.autoUpdateScriptUrl) == 'undefined') { wikEd.config.autoUpdateScriptUrl = wikEd.config.homeBaseUrl + 'w/index.php?action=raw&ctype=text/javascript&title=User:Cacycle/wikEd.user.js'; }
// show complete unshortened article text for local diff, also defined in wikEdDiff.js
if (typeof(wikEd.config.fullDiff) == 'undefined') { wikEd.config.fullDiff = false; }
// make links ctrl-clickable
if (typeof(wikEd.config.linkify) == 'undefined') { wikEd.config.linkify = true; }
// absolute instead of relative linkify links, URL with "$1" as article name placeholder
if (typeof(wikEd.config.linkifyArticlePath) == 'undefined') { wikEd.config.linkifyArticlePath = null; }
// hide refs and templates in newbie mode
if (typeof(wikEd.config.hideContent) == 'undefined') { wikEd.config.hideContent = true; }
// hide refs and templates in newbie mode
if (typeof(wikEd.config.unhideShift) == 'undefined') { wikEd.config.unhideShift = false; }
// wikify table parameters, replaces original table parameters with this string
if (typeof(wikEd.config.wikifyTableParameters) == 'undefined') { wikEd.config.wikifyTableParameters = ''; }
// do not rearrange page elements
if (typeof(wikEd.config.noRearrange) == 'undefined') { wikEd.config.noRearrange = false; }
// use French rules for fix punctuation
if (typeof(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 (typeof(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 (typeof(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 (typeof(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 (typeof(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 (typeof(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 (typeof(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 (typeof(wikEd.config.dHook) == 'undefined') { wikEd.config.diffHook = []; }
// custom edit form id instead of 'editform'
if (typeof(wikEd.config.customEditFormId) == 'undefined') { wikEd.config.customEditFormId = ''; }
// custom textarea id instead of 'wpTextbox1'
if (typeof(wikEd.config.customTextAreaId) == 'undefined') { wikEd.config.customTextAreaId = ''; }
// custom save button id instead of 'wpSave'
if (typeof(wikEd.config.customSaveButtonId) == 'undefined') { wikEd.config.customSaveButtonId = ''; }
// show table mode togle button
if (typeof(wikEd.config.showTableModeButton) == 'undefined') { wikEd.config.showTableModeButton = false; }
// maximal time for syntax highlighting in ms
if (typeof(wikEd.config.maxHighlightTime) == 'undefined') { wikEd.config.maxHighlightTime = 3000; }
// first char of article names is case sensitive (e.g. Wiktionary)
if (typeof(wikEd.config.articlesCaseSensitive) == 'undefined') { wikEd.config.articlesCaseSensitive = false; }
// force immediate update if this version string is newer
if (typeof(wikEd.config.forcedUpdate) == 'undefined') { wikEd.config.forcedUpdate = ''; }
// display highlighting error messages in text
if (typeof(wikEd.config.highlightError) == 'undefined') { wikEd.config.highlightError = false; }
// display preview of files in text
if (typeof(wikEd.config.filePreview) == 'undefined') { wikEd.config.filePreview = true; }
// file preview image size in pixels
if (typeof(wikEd.config.filePreviewSize) == 'undefined') { wikEd.config.filePreviewSize = 75; }
// file preview image size in pixels
if (typeof(wikEd.config.antiHighlightBleeding) == 'undefined') { wikEd.config.antiHighlightBleeding = true; }
// debug window maximal length in chars
if (typeof(wikEd.config.debugMaxLength) == 'undefined') { wikEd.config.debugMaxLength = 50000; }
// debug display of DOM nodes: maximal length of innerHTML in chars
if (typeof(wikEd.config.debugInnerHtmlLength) == 'undefined') { wikEd.config.debugInnerHtmlLength = 150; }
Line 1,233 ⟶ 1,248:
if (typeof(wikEd.config) == 'undefined') { wikEd.config = {}; }
// wikEd code home base URL
if (typeof(wikEd.config.
// diff script URL
Line 1,290 ⟶ 1,296:
'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:Matthias_M./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:Csörföly D/wikEd-hu.js',
'it': wikEd.config.homeBaseUrl + 'w/index.php?action=raw&ctype=text/javascript&title=User:Jalo/wikEd_international_it.js',
Line 1,323 ⟶ 1,331:
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', 'siteSub', 'contentSub', 'left-navigation', 'namespaces'] ],
vector_new: [ 'p-personal', true, true, ['content', 'bodyContent', 'siteSub', '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'] ],
Line 1,339 ⟶ 1,347:
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'] ],
// 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'] ],
// custom MediaWiki identifier
mediawiki: [ '', false, false, ['mediawiki'] ]
});
Line 1,368 ⟶ 1,375:
wikEd.InitGlobals = function() {
// global variables
wikEd.turnedOn = false;
wikEd.disabled = true;
Line 1,378 ⟶ 1,385:
wikEd.pageNamespace = null;
// history
wikEd.fieldHist = [];
wikEd.savedName = [];
Line 1,388 ⟶ 1,395:
wikEd.checkMarker[false] = '◊';
// undo all, redo all
wikEd.origVersion = '';
wikEd.lastVersion = null;
// global dom elements
wikEd.logo = null;
wikEd.logoList = null;
Line 1,431 ⟶ 1,438:
wikEd.insertWrapper = null;
// edit form fields
wikEd.editForm = null;
wikEd.starttime
Line 1,475 ⟶ 1,482:
wikEd.highlightNamedHideButtonsStylesheet = null;
// frame resizing
wikEd.resizeGripWidth = 16;
wikEd.resizeGripHeight = 16;
Line 1,489 ⟶ 1,496:
wikEd.textareaWidth = '';
// various
wikEd.insertCounter = 0;
wikEd.editButtonHandler = {};
Line 1,511 ⟶ 1,518:
wikEd.geSHiCSS = [];
// override site javascript functions
wikEd.insertTagsOriginal = null;
wikEd.insertAtCursorOriginal = null;
// wikEd settings
wikEd.refHide = false;
wikEd.using = false;
Line 1,527 ⟶ 1,534:
wikEd.readOnly = false;
// unicode fixing and char highlighting
wikEd.supportedChars = null;
wikEd.reservedChars = null;
Line 1,539 ⟶ 1,546:
wikEd.charHighlighting = null;
wikEd.charHighlightingStr = '';
wikEd.letters = '';
// linkification and hiding
wikEd.linkifyIdNo = 0;
wikEd.linkifyArray = [];
Line 1,548 ⟶ 1,555:
wikEd.templateArray = [];
wikEd.charEntityArray = [];
wikEd.scheduledUnhide = null;
// RegExtypoFix rules
wikEd.typoRulesFind = [];
wikEd.typoRulesReplace = [];
// redirect fixing
wikEd.redirectsCache = {};
// file preview
wikEd.filePreviewCache = {};
wikEd.filePreviewRequest = '';
Line 1,562 ⟶ 1,570:
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 = '';
Line 1,576 ⟶ 1,584:
wikEd.scriptURL = '';
// magic words and parser functions, see http://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 http://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';
// 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';
// 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';
// define leaf elements for wikEd.GetInnerHTML
wikEd.leafElements = {
'IMG': true,
Line 1,614 ⟶ 1,622:
// hash of loaded scripts, also defined in wikEdDiff.js
if (typeof(wikEd.externalScripts) == 'undefined') { wikEd.externalScripts = null; }
if (typeof(wikEd.externalScriptsString) == 'undefined') { wikEd.externalScriptsString = ''; }
if (typeof(wikEd.pageLoaded) == 'undefined') { wikEd.pageLoaded = false; }
Line 1,644 ⟶ 1,653:
if (typeof(wikEd.getGlobalsCounter) == 'undefined') { wikEd.getGlobalsCounter = 0; }
if (typeof(wikEd.loadingTranslation) == 'undefined') { wikEd.loadingTranslation = false; }
if (typeof(wikEd.webStorage) == 'undefined') { wikEd.webStorage =
// customization
if (typeof(wikEd.wikEdTextAdded) == 'undefined') { wikEd.wikEdTextAdded = false; }
if (typeof(wikEd.wikEdConfigAdded) == 'undefined') { wikEd.wikEdConfigAdded = false; }
// global dom elements, also defined in wikEdDiff.js
Line 1,675 ⟶ 1,678:
target[key] = source[key];
// show missing array entries
if (showMissing == true) {
if (typeof(target[key]) == 'string') {
Line 1,711 ⟶ 1,714:
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];
Line 1,732 ⟶ 1,735:
wikEd.Startup = function() {
// redirect WED shortcut to wikEd.Debug(objectName, object, popup)
window.WED = wikEd.Debug;
// 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] != null) {
return;
}
// define current window head
wikEd.head = document.getElementsByTagName('head')[0];
// 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 == null) {
Line 1,760 ⟶ 1,763:
wikEd.pageOrigin = origin.replace(/^((https?|file):\/\/[^\/?#]*)?.*$/, '$1');
// check browser and version
var agentMatch = navigator.userAgent.match(/(Firefox|Netscape|SeaMonkey|IceWeasel|IceCat|Fennec|Minefield|BonEcho|GranParadiso|Shiretoko)\W+(\d+\.\d+)/i);
if (agentMatch != null) {
Line 1,769 ⟶ 1,772:
}
// check for MSIE
else {
agentMatch = navigator.userAgent.match(/(MSIE)\W+(\d+\.\d+)/i);
Line 1,778 ⟶ 1,781:
}
// check for Opera
else {
agentMatch = navigator.userAgent.match(/(Opera)\W+(\d+\.\d+)/i);
Line 1,793 ⟶ 1,796:
}
// check for Google Chrome (AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.2.149.30 Safari/525.13)
else {
agentMatch = navigator.userAgent.match(/(Chrome)\W+(\d+\.\d+)/i);
Line 1,802 ⟶ 1,805:
}
// check for Safari
else {
agentMatch = navigator.userAgent.match(/(Safari)\W+(\d+\.\d+)/i);
Line 1,811 ⟶ 1,814:
}
// check for other WebKit
else {
agentMatch = navigator.userAgent.match(/(WebKit)(GTK\+)?\W+(\d+\.\d+)/i);
Line 1,825 ⟶ 1,828:
}
// check OS
var os = navigator.platform.match(/^(win|mac|unix|linux)/i);
if (os != null) {
Line 1,831 ⟶ 1,834:
}
// import customization (try now again after page load for user/skin.js)
if ( (typeof(wikEdConfig) == 'object') && (wikEd.wikEdConfigAdded == false) ) {
wikEd.AddToObject(wikEd.config, wikEdConfig);
Line 1,841 ⟶ 1,844:
}
// compatibility fixes for older customizations and wikEd-compatibilizations in other scripts
window.wikEdUseWikEd = wikEd.useWikEd;
window.WikEdUpdateTextarea = wikEd.UpdateTextarea;
Line 1,848 ⟶ 1,851:
window.WikEdEditButton = wikEd.EditButton;
// check if this runs under Greasemonkey
if (typeof(GM_getValue) == 'function') {
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
if (wikEd.greasemonkey == true) {
globalNames.push('wikEdConfig', 'wikEdText');
}
// copy custom config settings and text after values have arrived
var gotGlobalsHook = [
function() {
Line 1,874 ⟶ 1,877:
];
// and load translations when done
if ( (wikEd.config.loadTranslation == true) && (wikEd.loadingTranslation == false) ) {
gotGlobalsHook.push(wikEd.LoadTranslations);
}
// set listener for GetGlobals messaging
wikEd.AddEventListener(window, '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 {
wikEd.AddEventListener(window, 'load', wikEd.Setup, false);
}
return;
Line 1,903 ⟶ 1,913:
if ( (wikEd.config.languageDefault != '') || (userLang != '') || (contentLang != '') ) {
// simplified Chinese
if (contentLang == 'zh') {
contentLang = 'zh-hans';
Line 1,911 ⟶ 1,921:
}
// traditional Chinese
else if ( (userLang == 'zh-hk') || (userLang == 'zh-tw') ) {
userLang = 'zh-hant';
Line 1,927 ⟶ 1,937:
wikEd.AppendScript(scriptUrl, function() {
// copy custom text after values have arrived
var gotGlobalsHook = function() {
wikEd.AddToObject(wikEd.text, wikEd.wikiGlobals.wikEdText);
Line 1,933 ⟶ 1,943:
};
// parse globals (asynchronous)
wikEd.GetGlobals(['wikEdText'], [gotGlobalsHook]);
wikEd.loadingTranslation = true;
Line 1,945 ⟶ 1,955:
//
// wikEd.Setup: basic setup routine, scheduled after DOM or page load
//
wikEd.Setup = function() {
wikEd.RemoveEventListener(document, 'DOMContentLoaded', wikEd.Setup, false);
wikEd.RemoveEventListener(window, 'load', wikEd.Setup, false);
// check if wikEd has already set up
if (document.getElementsByName('wikEdSetupFlag')[0] != null) {
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);
Line 1,972 ⟶ 1,983:
}
// detect already loaded external scripts
if (wikEd.externalScripts == null) {
wikEd.externalScripts = [];
Line 1,986 ⟶ 1,997:
if (scriptName != '') {
// ignore other diff.js scripts
if ( (scriptName == 'diff.js') && (scriptSrc != wikEd.config.diffScriptSrc) ) {
continue;
}
wikEd.externalScripts[scriptName] = true;
wikEd.externalScriptsString += scriptName + '\n';
}
}
Line 1,996 ⟶ 2,008:
}
// detect developer version
if (wikEd.externalScripts['wikEd_dev.js'] == true) {
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'] == true) {
Line 2,012 ⟶ 2,024:
}
// redirect Greasemonkey debugging function to wikEd.Debug if run as a wiki user script
else {
window.GM_log = wikEd.Debug;
}
// detect wikEd running as a gadget
if (wikEd.config.gadget == null) {
if (wikEd.externalScripts['MediaWiki:Gadget-wikEd.js'] == true) {
Line 2,024 ⟶ 2,036:
}
// detect MediaWiki page and its skin
wikEd.InitMediaWikiSkinIds();
for (var skin in wikEd.config.MediaWikiSkinIds) {
Line 2,047 ⟶ 2,059:
}
// 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 != '') {
Line 2,092 ⟶ 2,104:
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');
Line 2,112 ⟶ 2,124:
}
// logo as last child of specified element
else {
logoContainer.appendChild(wikEd.logo);
Line 2,119 ⟶ 2,131:
}
// logo as first page element, fallback for undetected skin
if (wikEd.logo.className == '') {
document.body.insertBefore(wikEd.logo, document.body.firstChild);
Line 2,125 ⟶ 2,137:
}
// add event listener to logo
wikEd.AddEventListener(wikEd.logo, 'click', wikEd.MainSwitch, true);
}
// page loaded flag for dynamically loaded scripts
wikEd.pageLoaded = true;
// load the external diff script if not already done
if ( (wikEd.config.loadDiffScript == true) && (wikEd.externalScripts['diff.js'] == null) ) {
if (typeof(WDiffString) == 'undefined') {
Line 2,144 ⟶ 2,156:
}
// load the external wikEdDiff script if not already done
if ( (wikEd.config.loadDiff == true) && (wikEd.externalScripts['wikEdDiff.js'] == null) ) {
if (typeof(wikEd.Diff) == 'undefined') {
Line 2,156 ⟶ 2,168:
}
// load the MS IE selection/range compatibility library IERange
if (wikEd.msie == true) {
if ( (wikEd.config.loadIERange == true) && (wikEd.externalScripts['ierange.js'] == null) ) {
Line 2,170 ⟶ 2,182:
}
// init syntax highlighting regExp object
wikEd.HighlightSyntaxInit();
// check if disabled
wikEd.disabled = wikEd.GetSavedSetting('wikEdDisabled', wikEd.config.disabledPreset);
if (wikEd.disabled == true) {
Line 2,181 ⟶ 2,193:
}
// ___location search string function: put all used images and icons on an empty page
if (window.___location.search.match(/(\?|&)wikEd=iconPage\b/i) != null) {
var str = wikEd.config.text.iconPage;
Line 2,196 ⟶ 2,208:
}
// continue setup
wikEd.TurnOn(true);
Line 2,209 ⟶ 2,221:
wikEd.TurnOn = function(scrollToEditFocus) {
// check if setup was already run
if (wikEd.turnedOn == true) {
return;
}
// set error logo
wikEd.SetLogo('error');
// no id, no wikEd
if (navigator.appName == null) {
wikEd.browserNotSupported = true;
}
// check browser versions
switch (wikEd.browserName) {
// check Mozilla version
case 'Mozilla':
if (
Line 2,236 ⟶ 2,248:
break;
// check MSIE version
case 'MSIE':
wikEd.browserNotSupported = true;
break;
// check Opera version
case 'Opera':
if (wikEd.browserVersion < 10.51) {
Line 2,247 ⟶ 2,259:
}
// 10.50 beta, 10.51 are too buggy (inserthtml, parentNode...)
wikEd.browserNotSupported = true;
break;
// check Google Chrome version
case 'Chrome':
if (wikEd.browserVersion < 0.2) {
Line 2,259 ⟶ 2,271:
break;
// check Safari version
case 'Safari':
if (wikEd.browserVersion < 500) {
Line 2,267 ⟶ 2,279:
}
// browser or version not supported, set error message and exit
if ( (wikEd.browserNotSupported == true) && (wikEd.config.skipBrowserTest == false) ) {
wikEd.SetLogo('browser');
Line 2,273 ⟶ 2,285:
}
// get form elements
var array;
array = document.getElementsByName('wpEdittime');
Line 2,292 ⟶ 2,304:
}
// page type detection
// detect custom edit page
if (wikEd.config.customEditFormId != '') {
wikEd.editForm = document.getElementById(wikEd.config.customEditFormId);
Line 2,305 ⟶ 2,317:
}
// detect standard edit page
if (wikEd.textarea == null) {
wikEd.textarea = document.getElementsByName('wpTextbox1')[0];
Line 2,318 ⟶ 2,330:
wikEd.previewButton = document.getElementById('wpPreview');
// detect MediaWiki Semantic Forms extension
if (wikEd.textarea == null) {
wikEd.editForm = document.getElementsByName('createbox')[0];
Line 2,324 ⟶ 2,336:
}
// detect edit raw watchlist page
if ( (wikEd.editForm == null) || (wikEd.textarea == null) ) {
wikEd.textarea = document.getElementById('titles');
Line 2,330 ⟶ 2,342:
wikEd.watchlistEdit = true;
// get watchlist edit form
var node = wikEd.textarea;
while (node != null) {
Line 2,341 ⟶ 2,353:
}
// get watchlist submit button
if (wikEd.editForm != null) {
var submits = wikEd.editForm.getElementsByTagName('input');
Line 2,353 ⟶ 2,365:
}
// detect upload page
if ( (wikEd.textarea == null) || (wikEd.editForm == null) || (wikEd.saveButton == null) ) {
wikEd.textarea = document.getElementsByName('wpUploadDescription')[0];
Line 2,364 ⟶ 2,376:
}
// detect view and restore deleted pages
if ( (wikEd.textarea == null) || (wikEd.editForm == null) || (wikEd.saveButton == null) ) {
wikEd.textarea = document.getElementsByTagName('textarea')[0];
if (wikEd.textarea != null) {
// get form
var node = document.getElementsByName('preview')[0];
while (node != null) {
Line 2,386 ⟶ 2,398:
}
// set page detection error indicator
if ( (wikEd.textarea == null) || (wikEd.editForm == null) ) {
wikEd.SetLogo();
Line 2,392 ⟶ 2,404:
}
// check if the textarea is read-only
if (wikEd.config.skipReadOnlyTest == false) {
if ( (wikEd.GetAttribute(wikEd.textarea, 'readonly') != null) || (wikEd.saveButton == null) ) {
Line 2,399 ⟶ 2,411:
}
// get missing wg variables from footer link, fails on /subpages (code copied to wikEdDiff.js)
if (wikEd.wikiGlobals.wgArticlePath == null) {
var printfooter = wikEd.GetElementsByClassName('printfooter', 'div')[0];
Line 2,416 ⟶ 2,428:
}
// get missing wg variables from form action url
if (wikEd.wikiGlobals.wgScript == null) {
wikEd.wikiGlobals.wgScript = wikEd.editForm.action.replace(/^https?:\/\/[^\/]*|\?.*$/g, '');
Line 2,422 ⟶ 2,434:
}
// get current page name
wikEd.pageName = wikEd.wikiGlobals.wgPageName;
// get current namespace
if (wikEd.pageName != null) {
var colonPos = wikEd.pageName.indexOf(':');
Line 2,436 ⟶ 2,448:
}
// initialize frame css, main css, buttons, and button bars
wikEd.InitFrameCSS();
wikEd.InitMainEditCSS();
Line 2,445 ⟶ 2,457:
wikEd.InitIncompatibleScripts();
// check for incompatible scripts
if (wikEd.config.skipScriptTest == false) {
var scriptNames = '';
Line 2,451 ⟶ 2,463:
if (wikEd.config.incompatibleScripts.hasOwnProperty(key) == true) {
var generalName = key;
var
if (regExp.test(wikEd.
if (scriptNames != '') {
scriptNames += ', ';
Line 2,466 ⟶ 2,478:
}
// 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;
Line 2,484 ⟶ 2,496:
}
// load the external InstaView script
if ( (wikEd.greasemonkey == false) && (wikEd.config.loadInstaView == true) && (wikEd.externalScripts['instaview.js'] == null) ) {
if (typeof(InstaView) == 'undefined') {
Line 2,499 ⟶ 2,511:
}
// get initial textarea dimensions
wikEd.textareaBorderHeight = parseInt(wikEd.GetStyle(wikEd.textarea, 'borderTopWidth'), 10) + parseInt(wikEd.GetStyle(wikEd.textarea, 'borderBottomWidth'), 10);
Line 2,512 ⟶ 2,524:
wikEd.textareaWidth = '100%';
// remove frame border if textarea has none
var styleFrameContainer = '';
if (wikEd.textareaBorderHeight == 0) {
Line 2,518 ⟶ 2,530:
}
// setup the undo buffers and save the original text for local changes view
wikEd.origVersion = wikEd.textarea.value;
// Opera 0.9.51
wikEd.origVersion = wikEd.origVersion.replace(/\r\n|\n\r|\r/g, '\n');
// 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);
Line 2,537 ⟶ 2,549:
wikEd.tableMode = false;
// detect preview page
if (window.___location.search.match(/(\?|&)action=submit\b/) != null) {
wikEd.previewPage = true;
}
// no fullscreen for preview and upload pages
if ( (wikEd.uploadEdit == true) || (wikEd.previewPage == true) ) {
wikEd.fullScreenMode = false;
}
// disable wikEd for Lupin's autoedit scripts
if (window.___location.search.match(/(\?|&)autoedit=/) != null) {
wikEd.useWikEd = false;
}
// disable wikEd for js pages
if (/\.js$/.test(wikEd.wikiGlobals.wgTitle) == true) {
if ( (wikEd.wikiGlobals.wgCanonicalNamespace != 'User_talk') && (wikEd.wikiGlobals.wgCanonicalNamespace != 'Talk') ) {
Line 2,565 ⟶ 2,577:
}
// no spellcheck for watchlist editing
if (wikEd.watchlistEdit == 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 styleFrameBody;
var styleFrameWrapperPosition;
Line 2,603 ⟶ 2,615:
}
// check if we use the wikEd.editor user interface of the vector skin
// wikEd.wikiEditor = document.getElementById('wikiEditor-ui');
wikEd.wikiEditor = wikEd.GetElementsByClassName('wikiEditor-ui', 'div')[0];
Line 2,620 ⟶ 2,632:
}
// create input wrapper, contains the whole fullscreen content
wikEd.inputWrapper = document.createElement('div');
wikEd.inputWrapper.id = 'wikEdInputWrapper';
Line 2,626 ⟶ 2,638:
wikEd.textareaContainer.parentNode.insertBefore(wikEd.inputWrapper, wikEd.textareaContainer);
// create editor wrapper, contains toolbar, textarea, toc, but not the summary
if (wikEd.wikiEditor != null) {
wikEd.editorWrapper = wikEd.wikiEditor;
Line 2,637 ⟶ 2,649:
wikEd.inputWrapper.appendChild(wikEd.editorWrapper);
// create toolbar wrapper
wikEd.toolbarWrapper = document.createElement('div');
wikEd.toolbarWrapper.id = 'wikEdToolbarWrapper';
Line 2,644 ⟶ 2,656:
if (wikEd.toolbar != null) {
wikEd.editorWrapper.appendChild(wikEd.toolbarWrapper);
wikEd.toolbarWrapper.appendChild(wikEd.toolbar);
}
else if (wikEd.wikiEditorBar != null) {
Line 2,653 ⟶ 2,666:
}
// create captcha wrapper
wikEd.textBoxTable;
if (wikEd.rearrange == true) {
Line 2,661 ⟶ 2,674:
wikEd.editorWrapper.appendChild(wikEd.captchaWrapper);
// fill captcha wrapper with elements between form and textarea (table)
wikEd.textBoxTable = document.getElementById('textBoxTable');
if ( (wikEd.uploadEdit == false) && (wikEd.watchlistEdit == false) ) {
Line 2,676 ⟶ 2,689:
}
// create debug textarea wrapper
wikEd.debugWrapper = document.createElement('div');
wikEd.debugWrapper.id = 'wikEdDebugWrapper';
Line 2,683 ⟶ 2,696:
wikEd.editorWrapper.appendChild(wikEd.debugWrapper);
// create edit wrapper for textarea and frame wrapper
wikEd.editWrapper = document.createElement('div');
wikEd.editWrapper.id = 'wikEdEditWrapper';
Line 2,689 ⟶ 2,702:
wikEd.editorWrapper.appendChild(wikEd.editWrapper);
// create textarea wrapper
wikEd.textareaWrapper = document.createElement('div');
wikEd.textareaWrapper.id = 'wikEdTextareaWrapper';
Line 2,697 ⟶ 2,710:
wikEd.editWrapper.appendChild(wikEd.textareaWrapper);
// create frame wrapper
wikEd.frameWrapper = document.createElement('div');
wikEd.frameWrapper.id = 'wikEdFrameWrapper';
Line 2,705 ⟶ 2,718:
wikEd.editWrapper.appendChild(wikEd.frameWrapper);
// create console wrapper for buttons, summary, and submit
if (wikEd.rearrange == true) {
wikEd.consoleWrapper = document.createElement('div');
Line 2,713 ⟶ 2,726:
}
// create buttons wrapper for toolbar and wikEd button bars
if (wikEd.wikiEditor != null) {
wikEd.buttonsWrapper = wikEd.wikiEditorTop;
Line 2,724 ⟶ 2,737:
wikEd.editorWrapper.insertBefore(wikEd.buttonsWrapper, wikEd.editWrapper);
// create button bar wrapper
wikEd.buttonBarWrapper = document.createElement('div');
wikEd.buttonBarWrapper.id = 'wikEdButtonBarWrapper';
Line 2,730 ⟶ 2,743:
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';
// add summary above the edit field if we add a new section (+ tab)
if (wikEd.addNewSection == true) {
wikEd.summaryWrapper.className = 'wikEdSummaryWrapperTop';
Line 2,745 ⟶ 2,758:
}
// create summary input wrapper
wikEd.summaryInputWrapper = document.createElement('div');
wikEd.summaryInputWrapper.id = 'wikEdSummaryInputWrapper';
Line 2,751 ⟶ 2,764:
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';
Line 2,762 ⟶ 2,775:
wikEd.consoleWrapper.appendChild(wikEd.submitWrapper);
// create submit buttons wrapper for submit buttons and help links
wikEd.submitButtonsWrapper = document.createElement('div');
wikEd.submitButtonsWrapper.id = 'wikEdSubmitButtonsWrapper';
Line 2,768 ⟶ 2,781:
}
// create preview wrapper for preview and diff box
wikEd.localPrevWrapper = document.createElement('div');
wikEd.localPrevWrapper.id = 'wikEdLocalPrevWrapper';
Line 2,786 ⟶ 2,799:
}
// create insert wrapper for insert special chars links
if (wikEd.rearrange == true) {
wikEd.insertWrapper = document.createElement('div');
Line 2,794 ⟶ 2,807:
}
// append input wrapper to document
if ( (wikEd.rearrange == true) && (wikEd.watchlistEdit == false) ) {
wikEd.editForm.insertBefore(wikEd.inputWrapper, wikEd.editForm.firstChild);
}
// fill the wrappers
// create debug textarea and add to debug wrapper
wikEd.debug = document.createElement('textarea');
wikEd.debug.rows = 20;
Line 2,808 ⟶ 2,821:
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) ) {
Line 2,822 ⟶ 2,835:
}
// hide toolbar wrapper
if (wikEd.closeToolbar == true) {
wikEd.toolbarWrapper.style.display = 'none';
Line 2,830 ⟶ 2,843:
}
// 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) {
Line 2,840 ⟶ 2,853:
}
// dropdowns from toolbar should go over wikEd toolbar
if (wikEd.wikiEditorBar != null) {
wikEd.wikiEditorBar.style.zIndex = '5';
}
// get edit options
wikEd.editOptions = wikEd.GetElementsByClassName('editCheckboxes', 'div', wikEd.editForm)[0];
// old MediaWiki versions
if (wikEd.editOptions == null) {
var wpSummary = document.getElementsByName('wpSummary')[0];
Line 2,857 ⟶ 2,870:
}
// add summary elements to summary input wrapper
if (wikEd.rearrange == true) {
wikEd.summaryLabel = document.getElementById('wpSummaryLabel');
Line 2,869 ⟶ 2,882:
}
// 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');
Line 2,878 ⟶ 2,891:
}
// add submit buttons to submit wrapper
if (wikEd.rearrange == true) {
var wpEditButtons;
Line 2,895 ⟶ 2,908:
}
// add a link to the wikEd help page
if (wikEd.rearrange == true) {
if ( (wikEd.config.helpPageLink != '') && (wikEd.config.helpPageLink != null) ) {
Line 2,930 ⟶ 2,943:
}
// add submit buttons, edit options, and edit help to submit wrapper
if (wikEd.submitWrapper != null) {
if (wikEd.submitButtonsWrapper != null) {
Line 2,940 ⟶ 2,953:
wikEd.editOptionsWrapper.appendChild(wikEd.editOptions);
// remove linebreak before minor edit checkbox
var node = wikEd.editOptions.firstChild;
while (node != null) {
Line 2,958 ⟶ 2,971:
}
// add textBoxTable or textarea to edit wrapper
if (wikEd.textBoxTable != null) {
wikEd.textareaWrapper.appendChild(wikEd.textBoxTable);
Line 2,969 ⟶ 2,982:
}
// set frame font family
var classFrameBody;
if (wikEd.highlightSyntax == true) {
Line 2,983 ⟶ 2,996:
}
// add edit-frame to frame wrapper
// any DOM changes to a starting iframe in designmode may crash mozilla, including DOM move, display: none; and position: absolute;
// create the iframe
var html = '';
html += '<div id="wikEdFrameOuter" class="wikEdFrameOuter" style="' + styleFrameContainer + '">';
Line 2,995 ⟶ 3,008:
wikEd.frameWrapper.innerHTML = html;
// old Mozilla versions crash when designmode is turned on before the frame has loaded completely
// but onload workaround has problems starting with Firefox 3.6 (bug 542727)
var onloadWorkaround = false;
if ( (wikEd.mozilla == true) && (
Line 3,005 ⟶ 3,018:
}
// fill the frame with content
html = '';
html += '<html id="wikEdFrameHtml" class="wikEdFrameHtml"><head></head>';
html += '<body id="wikEdFrameBody" class="' + classFrameBody + '" style="' + styleFrameBody + '"';
// disable spellchecker in iframe
if (wikEd.noSpellcheck == true) {
html += ' spellcheck="false"';
Line 3,028 ⟶ 3,041:
wikEd.frameDocument = wikEd.frameWindow.document;
// set frame 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.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);
Line 3,037 ⟶ 3,050:
wikEd.frame.style.width = wikEd.frameWidth;
// do not remember sie if started in fullscreen mode
if (wikEd.fullScreenMode == true) {
wikEd.frameHeight = 0;
Line 3,043 ⟶ 3,056:
}
// turn on designmode before adding content
if ( (onloadWorkaround == false) && (wikEd.readOnly == false) ) {
wikEd.frameDocument.designMode = 'on';
Line 3,054 ⟶ 3,067:
}
// MS-IE needs styling for full width frame
if (wikEd.msie == true) {
//// wikEd.frame.style.width = wikEd.textareaWidth + 'px';// 100%
}
// fill iframe with content
wikEd.frameDocument.open();
wikEd.frameDocument.write(html);
Line 3,065 ⟶ 3,078:
wikEd.frameBody = wikEd.frameDocument.body;
// generate button bars and add them to the buttons wrapper
// form wrapper has been added against summary input submit defaulting to this button
if (wikEd.readOnly == false) {
wikEd.buttonBarFormat = wikEd.MakeButtonBar(wikEd.config.buttonBar.format);
Line 3,106 ⟶ 3,119:
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) ) {
Line 3,112 ⟶ 3,125:
}
// add preview box and its bottom bar to preview wrapper
if (wikEd.localPrevWrapper != null) {
var div = document.createElement('div');
Line 3,127 ⟶ 3,140:
}
// add jump box to standard preview
var wikiPreview = document.getElementById('wikiPreview');
if (wikiPreview != null) {
Line 3,136 ⟶ 3,149:
}
// add insert special chars to insert wrapper
if (wikEd.insertWrapper != null) {
var wpSpecialchars = document.getElementById('editpage-specialchars');
Line 3,144 ⟶ 3,157:
}
// wrappers filled
// add local preview button next to submit button
var previewSpan = document.createElement('span');
previewSpan.innerHTML = wikEd.MakeButtonCode(82, 'button');
Line 3,156 ⟶ 3,169:
}
// add local diff button next to submit button
if ( ( (wikEd.diffPreviewButton != null) || (wikEd.watchlistEdit == true) ) && (wikEd.readOnly == false) ) {
var diffSpan = document.createElement('span');
Line 3,171 ⟶ 3,184:
}
// correct tab order between check boxes and submits
wikEd.frame.tabIndex = wikEd.textarea.tabIndex;
// initialize image buttons
wikEd.Button(document.getElementById('wikEdDiff'), 'wikEdDiff', null, wikEd.diff);
wikEd.Button(document.getElementById('wikEdRefHide'), 'wikEdRefHide', null, wikEd.refHide);
Line 3,189 ⟶ 3,202:
wikEd.Button(document.getElementById('wikEdTableMode'), 'wikEdTableMode', null, wikEd.tableMode);
// hide typo fix button until typo fix rules are loaded and parsed
wikEd.fixRegExTypo = document.getElementById('wikEdFixRegExTypo');
if (wikEd.fixRegExTypo != null) {
Line 3,195 ⟶ 3,208:
}
// hide buttons if API is not available
if ( (wikEd.wikiGlobals.wgEnableAPI != true) && (wikEd.wikiGlobals.wgEnableAPI != 'true') ) {
var fixRedirect = document.getElementById('wikEdFixRedirect');
Line 3,203 ⟶ 3,216:
}
// add a clear summary button left to the summary input field
if (wikEd.summaryText != null) {
var clearSummaryForm = document.createElement('form');
Line 3,224 ⟶ 3,237:
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';
Line 3,249 ⟶ 3,262:
}
// shorten submit button texts
if (wikEd.previewButton != null) {
wikEd.previewButton.value = wikEd.config.text.shortenedPreview;
Line 3,257 ⟶ 3,270:
}
// set up combo input boxes with history
wikEd.fieldHist ['find'] = [];
wikEd.savedName.find = 'wikEdFindHistory';
Line 3,278 ⟶ 3,291:
}
// adjust the select field widths to that of the text input fields
wikEd.ResizeComboInput('find');
wikEd.ResizeComboInput('replace');
Line 3,285 ⟶ 3,298:
}
// hide the button bars per saved setting
if (wikEd.buttonBarFormat != null) {
wikEd.ButtonBarInit(wikEd.buttonBarFormat);
Line 3,308 ⟶ 3,321:
}
// display only the textarea or the iframe, dont change the frame
wikEd.SetEditArea(wikEd.useWikEd, true);
// copy page warnings above edit window
if (wikEd.config.doCloneWarnings == true) {
if ( (wikEd.clonedWarnings == false) && (wikEd.previewPage == false) && (/(.*\n){2}/.test(wikEd.origVersion) ) == true) {
Line 3,337 ⟶ 3,350:
}
// add frame stylesheet definition
wikEd.direction = wikEd.GetStyle(document.body, 'direction');
wikEd.frameBody.style.direction = wikEd.direction;
Line 3,343 ⟶ 3,356:
wikEd.HighlightNamedHideButtonsStylesheet = new wikEd.StyleSheet(wikEd.frameDocument);
// copy textarea background
if (wikEd.GetStyle(wikEd.textarea, 'display') != 'none') {
wikEd.frameInner.style.backgroundColor = wikEd.GetStyle(wikEd.textarea, 'backgroundColor');
}
// 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 the textarea content to the iframe
if (wikEd.useWikEd == true) {
wikEd.UpdateFrame();
}
// initialize IERange DOM range compatibility library
if (typeof(IERange) == 'function') {
IERange(wikEd.frameWindow, wikEd.frameDocument);
}
// scroll to edit window and focus if it is not a preview page
if ( (scrollToEditFocus == true) && (wikEd.previewPage == false) ) {
// focus the input field
if (wikEd.config.focusEdit == true) {
if (wikEd.useWikEd == true) {
Line 3,382 ⟶ 3,395:
}
// scroll
if ( (wikEd.fullScreenMode == false) && (wikEd.config.scrollToEdit == true) ) {
window.scroll(0, wikEd.GetOffsetTop(wikEd.editForm) - 2);
Line 3,388 ⟶ 3,401:
}
// register edit button click events
for (var buttonId in wikEd.editButtonHandler) {
if (wikEd.editButtonHandler.hasOwnProperty(buttonId) == true) {
Line 3,398 ⟶ 3,411:
}
// register summary shrinking event after loading the 'Clear summary' image handler
wikEd.AddEventListener(wikEd.clearSummaryImg, 'load', wikEd.ShrinkSummaryHandler, true);
// register summary resize event for window resizing (MS IE bug: fires once always)
wikEd.AddEventListener(window, 'resize', wikEd.ResizeWindowHandler, true);
// register frame events
wikEd.AddEventListener(wikEd.frameDocument, 'keydown', wikEd.KeyFrameHandler, true);
wikEd.AddEventListener(wikEd.frameDocument, 'keyup', wikEd.KeyFrameHandler, true);
Line 3,413 ⟶ 3,426:
wikEd.AddEventListener(wikEd.frameDocument, 'dblclick', wikEd.ResizeFrameResetHandler, true);
// register document events
wikEd.AddEventListener(document, 'keydown', wikEd.KeyHandler, true);
// dblclick on wrapper events
wikEd.AddEventListener(wikEd.debugWrapper, 'dblclick', wikEd.DebugHandler, true);
wikEd.AddEventListener(wikEd.localPrevWrapper, 'dblclick', wikEd.PrevWrapperHandler, true);
// register find ahead events
wikEd.AddEventListener(wikEd.findText, 'keyup', wikEd.FindAhead, true);
// register submit button events
wikEd.AddEventListener(wikEd.saveButton, 'click', wikEd.SaveButtonHandler, true);
wikEd.AddEventListener(wikEd.previewButton, 'click', wikEd.PreviewButtonHandler, true);
wikEd.AddEventListener(wikEd.diffPreviewButton, 'click', wikEd.DiffPreviewButtonHandler, true);
// unload (leaving page) events
wikEd.AddEventListener(window, 'pagehide', wikEd.UnloadHandler, false);
// set button bar grip area events
if (wikEd.buttonBarFormat != null) {
wikEd.AddEventListener(wikEd.buttonBarFormat.firstChild.firstChild, 'click', wikEd.ButtonBarGripHandler, false);
Line 3,458 ⟶ 3,471:
}
// register combo box events
wikEd.AddEventListener(wikEd.summarySelect, 'change', function() { wikEd.ChangeComboInput('summary'); }, false);
wikEd.AddEventListener(wikEd.summarySelect, 'focus', function() { wikEd.SetComboOptions('summary'); }, false);
Line 3,468 ⟶ 3,481:
wikEd.AddEventListener(wikEd.selectElement.replace, 'focus', function() { wikEd.SetComboOptions('replace'); }, false);
// register the clear summary click handler
wikEd.AddEventListener(wikEd.clearSummary, 'click', wikEd.ClearSummaryHandler, true);
// select the text on focus for find and replace fields
wikEd.AddEventListener(wikEd.findText, 'focus', wikEd.FindReplaceHandler, true);
wikEd.AddEventListener(wikEd.replaceText, 'focus', wikEd.FindReplaceHandler, true);
// tab / shift-tab between find and replace fields
wikEd.AddEventListener(wikEd.findText, 'keydown', wikEd.FindReplaceHandler, true);
wikEd.AddEventListener(wikEd.replaceText, 'keydown', wikEd.FindReplaceHandler, true);
// init MediaWiki file paths for use in regexps
if (wikEd.wikiGlobals.wgServer != null) {
wikEd.server = wikEd.wikiGlobals.wgServer;
Line 3,500 ⟶ 3,513:
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');
Line 3,507 ⟶ 3,520:
wikEd.scriptName = wikEd.scriptName.replace(/(\W)/g, '\\$1');
// check if dynamically inserted addon tags have to be removed: Web of Trust (WOT)
if (document.getElementById('wot-logo') != null) {
wikEd.cleanNodes = true;
}
// fullscreen mode
if (wikEd.fullScreenMode == true) {
wikEd.FullScreen(wikEd.fullScreenMode, true);
}
// override the insertTags function in wikibits.js used by the standard button toolbar and the editpage special chars
if (typeof(insertTags) == 'function') {
if (wikEd.InsertTagsOriginal == null) {
Line 3,528 ⟶ 3,541:
}
// hook wikEd into the enhanced new edit toolbar, not Greasemonkey compatible
if (typeof(jQuery) == 'function') {
jQuery('#wpTextbox1').bind('encapsulateSelection', function(e, before, inside, after) {
Line 3,537 ⟶ 3,550:
}
// update textarea before using UI LivePreview function, not Greasemonkey compatible
if ( (typeof(jQuery) == 'function') && (typeof(mw) == 'object') ) {
jQuery(mw).bind('LivePreviewPrepare', function(event) {
Line 3,546 ⟶ 3,559:
}
// override insertAtCursor function in wikia.com MediaWiki:Functions.js, not Greasemonkey compatible
if (typeof(insertAtCursor) == 'function') {
if (wikEd.InsertAtCursorOriginal == null) {
Line 3,554 ⟶ 3,567:
}
// reset error indicator
wikEd.SetLogo();
wikEd.turnedOn = true;
// get frame resize grip image dimensions
var resizeGripImage = document.createElement('img');
resizeGripImage.id = 'wikEdResizeGrip';
Line 3,564 ⟶ 3,577:
resizeGripImage.src = wikEd.config.image['resizeGrip'];
// remove accesskeys that are defined in wikEd from page elements
wikEd.deleteAccesskeys();
// 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;
};
Line 3,606 ⟶ 3,619:
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;
}
// 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 != null) && (forcedVersion != null) ) {
if (forcedVersion > currentVersion) {
Line 3,632 ⟶ 3,645:
}
// 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, '/');
Line 3,647 ⟶ 3,660:
}
// get the hours since last update check
var diffHours = (currentDate - lastCheckDate) / 1000 / 60 / 60;
if (wikEd.greasemonkey == true) {
Line 3,659 ⟶ 3,672:
}
// 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, obj) {
// 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 != null) && (newVersion != null) ) {
if (newVersion > currentVersion) {
Line 3,709 ⟶ 3,722:
wikEd.DoUpdate = function() {
// update Greasemonkey script by navigating to the script code page
if (wikEd.greasemonkey == true) {
var updatePopup = wikEd.config.text.wikEdGreasemonkeyAutoUpdate;
Line 3,717 ⟶ 3,730:
}
// update wikEd by reloading the page with cache bypassing (equivalent to Shift-Reload or Shift-F5)
else {
window.___location.reload(true);
Line 3,731 ⟶ 3,744:
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
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 = /
while ( (regExpMatch = regExp.exec(rulesTxt)) != null) {
// check if this is a valid regexp
var regExpFind;
try {
Line 3,756 ⟶ 3,770:
}
catch (err) {
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) {
Line 3,782 ⟶ 3,798:
wikEd.EditButtonHandler = function(event) {
// event compatibility fixes
event = wikEd.EventWrapper(event, this);
if (event == null) {
Line 3,788 ⟶ 3,804:
}
// execute the button click handler code
var obj;
if (event.currentTarget != null) {
Line 3,794 ⟶ 3,810:
}
// MS IE compatibility
else {
obj = event.srcElement;
}
// workaround for mozilla 3.0 bug 441087
objId = obj.id;
eventShiftKey = event.shiftKey;
Line 3,815 ⟶ 3,831:
var diffWidth = wikEd.clearSummary.offsetWidth - wikEd.clearSummaryWidth;
// Firefox < 3.0
if ( typeof(wikEd.inputElement.summary.clientLeft) == 'undefined' ) {
wikEd.inputElement.summary.style.width = (wikEd.inputElement.summary.clientWidth - diffWidth) + 'px';
Line 3,821 ⟶ 3,837:
}
// Firefox >= 3.0
else {
wikEd.inputElement.summary.style.width = (wikEd.inputElement.summary.clientWidth - diffWidth) + 'px';
Line 3,837 ⟶ 3,853:
wikEd.ResizeWindowHandler = function(event) {
// adjust frame size
wikEd.frameHeight = (wikEd.textareaOffsetHeightInitial - wikEd.frameBorderHeight) + 'px';
wikEd.frameWidth = (wikEd.editorWrapper.clientWidth - wikEd.frameBorderWidth) + 'px';
Line 3,854 ⟶ 3,870:
wikEd.UnloadHandler = function(event) {
// update textarea if not already done in submit handlers
if (wikEd.useWikEd == true) {
if (wikEd.textareaUpdated != true) {
Line 3,872 ⟶ 3,888:
wikEd.RemoveEventListener(wikEd.saveButton, 'click', wikEd.SaveButtonHandler, true);
// update textarea
if (wikEd.useWikEd == true) {
wikEd.UpdateTextarea();
Line 3,878 ⟶ 3,894:
}
// check for interfering scripts or gadgets: mwEmbed for file uploads
if ( (wikEd.uploadEdit == true) && (typeof(MW_EMBED_VERSION) != 'undefined') ) {
wikEd.AddEventListener(wikEd.saveButton, 'click', wikEd.SaveButtonHandler, true);
Line 3,884 ⟶ 3,900:
}
// add "using wikEd" to summary, not for adding a new section (+ tab)
if (wikEd.summaryText != null) {
var text = wikEd.summaryText.value;
Line 3,901 ⟶ 3,917:
}
// submit
wikEd.saveButton.click();
// reinstate handler in case the browser back button will be used
wikEd.AddEventListener(wikEd.saveButton, 'click', wikEd.SaveButtonHandler, true);
Line 3,949 ⟶ 3,965:
wikEd.LinkifyHandler = function(event) {
// event compatibility fixes
event = wikEd.EventWrapper(event, this);
if (event == null) {
Line 3,984 ⟶ 4,000:
wikEd.ButtonBarGripHandler = function(event) {
// event compatibility fixes
event = wikEd.EventWrapper(event, this);
if (event == null) {
Line 4,000 ⟶ 4,016:
buttonsWrapper.style.position = 'static';
// hide the buttons bar
if (buttonsWrapper.className != 'wikEdButtonBarButtonsWrapperHidden') {
buttonsWrapper.className = 'wikEdButtonBarButtonsWrapperHidden';
Line 4,011 ⟶ 4,027:
}
// unhide the buttons bar
else {
buttonsWrapper.className = 'wikEdButtonBarButtonsWrapperVisible';
Line 4,022 ⟶ 4,038:
}
// show the buttons bar on mouseover
else if (event.type == 'mouseover') {
if (buttonsWrapper.className == 'wikEdButtonBarButtonsWrapperHidden') {
wikEd.AddEventListener(bar, 'mouseout', wikEd.ButtonBarHandler, false);
// show buttons to the right
if (bar.offsetParent.clientWidth > grip.offsetLeft + grip.offsetWidth + wikEd.buttonsWrapperWidth[bar.id]) {
buttonsWrapper.style.left = (grip.offsetLeft + grip.offsetWidth) + 'px';
}
// show buttons to the left
else {
buttonsWrapper.style.left = (gripWrapper.offsetLeft - wikEd.buttonsWrapperWidth[bar.id]) + 'px';
}
// a mozilla bug sometimes gives offsetTop - 1 when the wikEd.toolbarWrapper is hidden
buttonsWrapper.style.top = gripWrapper.offsetTop + 'px';
buttonsWrapper.style.position = 'absolute';
Line 4,053 ⟶ 4,069:
wikEd.ButtonBarHandler = function(event) {
// event compatibility fixes
event = wikEd.EventWrapper(event, this);
if (event == null) {
Line 4,069 ⟶ 4,085:
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 (
(
Line 4,100 ⟶ 4,116:
wikEd.ClearSummaryHandler = function(event) {
// event compatibility fixes
event = wikEd.EventWrapper(event, this);
if (event == null) {
Line 4,108 ⟶ 4,124:
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(/^((\/\* .*? \*\/ *)?).*()/,
Line 4,135 ⟶ 4,151:
wikEd.FindReplaceHandler = function(event) {
// event compatibility fixes
event = wikEd.EventWrapper(event, this);
if (event == null) {
Line 4,141 ⟶ 4,157:
}
// tab / shift-tab between fields
if (event.type == 'keydown') {
if (event.keyCode == 9) {
Line 4,159 ⟶ 4,175:
}
// select on focus
else if (event.type == 'focus') {
if (wikEd.msie == true) {
Line 4,178 ⟶ 4,194:
wikEd.KeyFrameHandler = function(event) {
// event compatibility fixes
event = wikEd.EventWrapper(event, this);
if (event == null) {
Line 4,187 ⟶ 4,203:
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();
Line 4,204 ⟶ 4,220:
}
// scroll to text input top
if (wikEd.fullScreenMode == false) {
window.scroll(0, wikEd.GetOffsetTop(wikEd.inputWrapper));
Line 4,213 ⟶ 4,229:
break;
// after cursor movements set cursor position into closest highest text node so that highlighting does not bleed out
case 'keyup':
switch (event.keyCode) {
Line 4,229 ⟶ 4,245:
break;
// grey out inactive buttons
case 'mouseup':
wikEd.AntiHighlightBleeding(new Object());
Line 4,247 ⟶ 4,263:
wikEd.AntiHighlightBleeding = function(obj, editButtonInsert) {
// check if disabled
if (wikEd.config.antiHighlightBleeding != true) {
return;
}
// get selection object
if (obj.sel == null) {
obj.sel = wikEd.GetSelection();
}
// only if no text is selected
var range = obj.sel.getRangeAt(obj.sel.rangeCount - 1);
if ( (obj.sel.isCollapsed != true) || (range.collapsed != true) ) {
Line 4,263 ⟶ 4,279:
}
// correct focusNode to actual (deepest) node
var focusNode = obj.sel.focusNode;
var focusOffset = obj.sel.focusOffset;
Line 4,270 ⟶ 4,286:
}
// set focus into deepest node
if (focusNode.childNodes != null) {
if ( (focusNode.childNodes.length > 0) && (focusOffset < focusNode.childNodes.length) ) {
Line 4,282 ⟶ 4,298:
}
// do not further correct if focus is linebreak if key but not if edit button
if ( (focusNode.tagName == 'BR') && (editButtonInsert != true) ) {
return;
}
// get next text-like node to the left if we are not in the middle of a text node
var leftNode = focusNode;
var leftLevel = 0;
Line 4,301 ⟶ 4,317:
}
// get next text-like node to the right if we are not in the middle of a text node
var objRight = {
'backwards': false
Line 4,315 ⟶ 4,331:
}
// check if we need to correct the focus node to higher level text-like node
var correctTo = '';
if (leftNode != rightNode) {
Line 4,328 ⟶ 4,344:
}
// same level, set focus outside tag markups (class names contains 'Tag'): [ [[ | || <
else if (leftLevel == rightLevel) {
// get class names
var leftClass = '';
if (leftNode.nodeName == '#text') {
Line 4,357 ⟶ 4,373:
}
// set focus to the next left node
if (correctTo == 'left') {
var node;
// insert new text node after linebreak and focus
if (leftNode.tagName == 'BR') {
node = wikEd.frameDocument.createTextNode('');
Line 4,381 ⟶ 4,397:
}
// set focus to the next right node
else if (correctTo == 'right') {
var node;
// insert new text node before linebreak
if (rightNode.tagName == 'BR') {
var node = wikEd.frameDocument.createTextNode('');
Line 4,415 ⟶ 4,431:
wikEd.ResizeGripLoadHandler = function(event) {
// event compatibility fixes
event = wikEd.EventWrapper(event, this);
if (event == null) {
Line 4,433 ⟶ 4,449:
wikEd.ResizeGripHandler = function(event) {
// Firefox bug during startup ("WikEdEvent is not defined")
if (typeof(wikEd.EventWrapper) != 'function' ) {
return;
}
// event compatibility fixes
event = wikEd.EventWrapper(event, this);
if (event == null) {
Line 4,453 ⟶ 4,464:
if ( (event.shiftKey == false) && (event.ctrlKey == false) && (event.altKey == false) && (event.metaKey == false) ) {
// move into grip
if (wikEd.resizeFrameMouseOverGrip == false) {
if (event.clientY >= wikEd.frameBody.clientHeight - wikEd.resizeGripHeight) {
Line 4,471 ⟶ 4,482:
}
// move out of grip
else if (wikEd.resizeFrameActive == false) {
if (
Line 4,495 ⟶ 4,506:
wikEd.ResizeStartHandler = function(event) {
// event compatibility fixes
event = wikEd.EventWrapper(event, this);
if (event == null) {
Line 4,535 ⟶ 4,546:
wikEd.ResizeStopHandler = function(event) {
// event compatibility fixes
event = wikEd.EventWrapper(event, this);
if (event == null) {
Line 4,569 ⟶ 4,580:
wikEd.ResizeDragHandlerFrame = function(event) {
// event compatibility fixes
event = wikEd.EventWrapper(event, this);
if (event == null) {
Line 4,601 ⟶ 4,612:
wikEd.ResizeDragHandlerDocument = function(event) {
// event compatibility fixes
event = wikEd.EventWrapper(event, this);
if (event == null) {
Line 4,633 ⟶ 4,644:
wikEd.ResizeFrameResetHandler = function(event) {
// event compatibility fixes
event = wikEd.EventWrapper(event, this);
if (event == null) {
Line 4,646 ⟶ 4,657:
if ( (event.clientY < wikEd.frameBody.clientHeight) && (event.clientX < wikEd.frameBody.clientWidth) ) {
// end fullscreen mode
if (wikEd.fullScreenMode == true) {
wikEd.FullScreen(false);
}
// reset size to default
wikEd.frameHeight = (wikEd.textareaOffsetHeightInitial - wikEd.frameBorderHeight) + 'px';
wikEd.frameWidth = (wikEd.editorWrapper.clientWidth - wikEd.frameBorderWidth) + 'px';
Line 4,657 ⟶ 4,668:
wikEd.frame.style.width = wikEd.frameWidth;
// end resizing
wikEd.RemoveEventListener(wikEd.frameDocument, 'mouseup', wikEd.ResizeStopHandler, true);
wikEd.RemoveEventListener(document, 'mouseup', wikEd.ResizeStopHandler, true);
Line 4,764 ⟶ 4,775:
wikEd.MakeButtonBar = function(bar) {
// id outer, class outer, id inner, class inner, alt, button numbers
var barId = bar[0];
var barClass = bar[1];
Line 4,773 ⟶ 4,784:
var buttonNumbers = bar[6];
// collect the buttons
var buttons = '';
for (var i = 0; i < buttonNumbers.length; i ++) {
Line 4,810 ⟶ 4,821:
}
// add button html code
buttons += '<img ' + wikEd.MakeButtonCode(buttonNo) + '>';
}
}
// create the button bar div
var div = document.createElement('div');
div.id = barId;
Line 4,825 ⟶ 4,836:
}
// make a grip bar
var html = '';
if (gripTitle != null) {
Line 4,853 ⟶ 4,864:
}
// make a standard no-grip bar
else {
html += '<div id="' + buttonsId + '" class="' + buttonsClass + '"' + buttonsStyle + '">';
Line 4,873 ⟶ 4,884:
var currButton = wikEd.config.button[buttonNo];
// add accesskey information to button title and
var accessKey = '';
if (wikEd.config.buttonKey[buttonNo] != null) {
accessKey = ' [' + wikEd.config.text['alt-shift'] + wikEd.config.buttonKey[buttonNo][0] + ']';
// initialize wikEd.buttonKeyCode[keyCode] = id
wikEd.buttonKeyCode[ (wikEd.config.buttonKey[buttonNo][1]) ] = currButton[0];
}
// add button html code
var html;
if (type == 'button') {
Line 4,891 ⟶ 4,902:
}
// collect click event info
wikEd.editButtonHandler[ currButton[0] ] = currButton[7];
return(html);
};
//
// wikEd.ButtonBarInit: hide buttons bar, see also wikEd.ButtonBarGripHandler()
Line 4,929 ⟶ 4,940:
var scrollRatio;
// turn rich text frame on
if (useFrame == true) {
scrollRatio = wikEd.textarea.scrollTop / wikEd.textarea.scrollHeight;
// remember resized textarea dimensions
wikEd.textareaHeight = (wikEd.textarea.offsetHeight - wikEd.textareaBorderHeight) + 'px';
wikEd.textareaWidth = '100%';
Line 4,947 ⟶ 4,958:
}
// set visibility of native toolbar
if (wikEd.closeToolbar == true) {
wikEd.toolbarWrapper.style.display = 'none';
Line 4,979 ⟶ 4,990:
}
// turn classic textarea on
else {
scrollRatio = wikEd.frameBody.scrollTop / wikEd.frameBody.scrollHeight;
if (notFrame != true) {
// get resized frame dimensions for textarea
if (wikEd.useWikEd == true) {
wikEd.textareaHeight = wikEd.frameHeight;
Line 4,992 ⟶ 5,003:
wikEd.frameWrapper.style.visibility = 'hidden';
// Mozilla or wikEd bug: <br> insertion before text a while after setting display to 'none', test with setTimeout('alert(wikEd.frameBody.innerHTML)', 1000);
// wikEd.frameBody.style.display = 'none';
}
wikEd.textareaWrapper.style.position = 'static';
Line 5,001 ⟶ 5,012:
wikEd.textarea.style.display = 'block';
// force visibility of native toolbar
if (wikEd.toolbarWrapper != null) {
wikEd.toolbarWrapper.style.display = 'block';
Line 5,042 ⟶ 5,053:
if (buttonObj != null) {
// check if the button is disabled
if (buttonObj.className == 'wikEdButtonInactive') {
return;
}
// set button to pressed, set cursor to hourglass
buttonObj.style.cursor = 'wait';
// init the button
if (setButton != null) {
if (setButton == false) {
Line 5,069 ⟶ 5,080:
}
// toggle the button
if (toggleButton != null) {
if (toggleButton == true) {
Line 5,084 ⟶ 5,095:
}
// perform specific actions
var focusFrame = false;
if ( ( (setButton == null) && (classButton == null) ) || (doButton == true) ) {
// remove active content
wikEd.RemoveElements(['script', 'object', 'applet', 'embed']);
switch (buttonId) {
// switch between syntax highlighting and plain text
case 'wikEdHighlightSyntax':
if (wikEd.GetAttribute(buttonObj, 'checked') == 'true') {
Line 5,111 ⟶ 5,122:
}
// do not keep whole text selected
wikEd.EditButton( null, 'wikEdUpdateAll', {'keepSel': false} );
break;
// toggle table mode // {{TABLE}}
case 'wikEdTableMode':
if (wikEd.GetAttribute(buttonObj, 'checked') != 'true') {
Line 5,127 ⟶ 5,138:
break;
// align textbox with display top
case 'wikEdScrollToPreview':
case 'wikEdScrollToPreview2':
Line 5,135 ⟶ 5,146:
break;
// align edit buttons with display top
case 'wikEdScrollToEdit':
case 'wikEdScrollToEdit2':
Line 5,144 ⟶ 5,155:
break;
// cycle through different font sizes
case 'wikEdTextZoomDown':
wikEd.textSize = wikEd.textSize / 1.2;
Line 5,154 ⟶ 5,165:
break;
// cycle through different font sizes
case 'wikEdTextZoomUp':
wikEd.textSize = wikEd.textSize * 1.2;
Line 5,164 ⟶ 5,175:
break;
// display local preview box
case 'wikEdLocalPreview':
if (wikEd.fullScreenMode == true) {
Line 5,173 ⟶ 5,184:
}
// clear box to display loading indicator, keep wrapper height to prevent scrolling
var previewHeight = wikEd.previewBox.offsetHeight;
if ( (wikEd.previewBox.innerHTML != '') && (previewHeight > 0) ) {
Line 5,181 ⟶ 5,192:
wikEd.localPrevWrapper.style.display = 'inline';
// prepare ajax preview
wikEd.previewIsAjax = false;
var bodyData = wikEd.textarea.value;
// Opera 0.9.51
bodyData = bodyData.replace(/\r\n|\n\r|\r/g, '\n');
Line 5,191 ⟶ 5,202:
var livePreview = true;
// articles on watchlist preview page
if (wikEd.watchlistEdit == true) {
bodyData = bodyData.replace(/\n{1}/g, '\n\n');
Line 5,203 ⟶ 5,214:
if (/:/.test(article) == true) {
// postfix (User_talk) or prefix (Discussion_Utilisateur), test for xxx_ vs. _xxx (all ASCII non-letters as separator)
// Firefox 3.6.7 + Greasemonkey 0.8.20100408.06: invalid range with \{-‰ and \x8f-™
if (/[ -\/\:-\@\[-\`\{-\x88‰‹\x8d\x8f-\x98™›\x9d\xa0-»¿×÷]/.test(wikEd.config.text['talk namespace suffix']) == true) {
talk = article.replace(/([^:]*)/, wikEd.config.text['talk namespace suffix'] + '$1');
Line 5,225 ⟶ 5,236:
}
// normal article edit page
else {
// append references section for section edits
var section = document.getElementsByName('wpSection');
if (section != null) {
Line 5,242 ⟶ 5,253:
}
// GesHI syntax highlighting support, GeSHi css is only provided dynamically and not for &live
// so request a full preview and attach css to page, remember already loaded GeSHi languages
while ( (regExpMatch = regExp.exec(bodyData)) != null) { var lang = regExpMatch[3];
if (wikEd.geSHiCSS['wikEd' + lang] == null) {
Line 5,254 ⟶ 5,266:
}
// make the ajax request
wikEd.AjaxPreview(bodyData, wikEd.LocalPreviewAjaxHandler, livePreview);
}
// prepare a local preview (Pilaf's InstaView), will be overwritten by Ajax version
if ( (wikEd.config.useLocalPreview == true) && (typeof(InstaView) == 'object') ) {
InstaView.conf.user.name = wikEd.wikiGlobals.wgUserName;
var text = wikEd.textarea.value;
// Opera 0.9.51
text = text.replace(/\r\n|\n\r|\r/g, '\n');
Line 5,270 ⟶ 5,282:
wikEd.previewBox.innerHTML = instaView;
// init sortable tables (wikibits.js)
if (typeof(sortables_init) == 'function') {
sortables_init();
}
// init collapsible tables (common.js)
if (typeof(createCollapseButtons) == 'function') {
createCollapseButtons();
Line 5,284 ⟶ 5,296:
break;
// display local diff box
case 'wikEdLocalDiff':
if (typeof(WDiffString) != 'function') {
Line 5,299 ⟶ 5,311:
}
// add trailing newline
var currentVersion = wikEd.textarea.value;
// Opera 0.9.51
currentVersion = currentVersion.replace(/\r\n|\n\r|\r/g, '\n');
// call external diff program
wikEd.previewBox.innerHTML = wikEd.DiffResponse(wikEd.origVersion, currentVersion);
// display diff, keep wrapper height to prevent scrolling
var previewHeight = wikEd.previewBox.offsetHeight;
if ( (wikEd.previewBox.innerHTML != '') && (previewHeight > 0) ) {
Line 5,315 ⟶ 5,327:
wikEd.localPrevWrapper.style.display = 'block';
// scroll to button, textarea, or preview field
wikEd.ScrollToPreview();
// run scheduled custom functions
wikEd.ExecuteHook(wikEd.config.diffHook);
break;
// toggle wikEdDiff
case 'wikEdDiff':
// turn wikEdDiff off
if (wikEd.GetAttribute(buttonObj, 'checked') != 'true') {
wikEd.diff = false;
Line 5,335 ⟶ 5,349:
}
// turn wikEdDiff on
else {
wikEd.diff = true;
Line 5,350 ⟶ 5,364:
break;
// close the preview / diff box
case 'wikEdClose':
case 'wikEdClose2':
Line 5,359 ⟶ 5,373:
break;
// switch between textarea and frame display
// switching an iframe in design mode immediately after initialization between absolute/static may crash mozilla
case 'wikEdUseWikEd':
// enble wikEd
if (wikEd.GetAttribute(buttonObj, 'checked') == 'true') {
wikEd.UpdateFrame();
// turn rich text frame on
wikEd.SetEditArea(true);
wikEd.useWikEd = true;
wikEd.SetPersistent('wikEdUseClassic', '0', 0, '/');
// run scheduled custom functions
wikEd.ExecuteHook(wikEd.config.frameHook);
}
// turn classic textarea on, disable wikEd
else {
wikEd.UpdateTextarea();
Line 5,383 ⟶ 5,397:
wikEd.SetPersistent('wikEdUseClassic', '1', 0, '/');
// run scheduled custom functions
wikEd.ExecuteHook(wikEd.config.textareaHook);
}
break;
// add "using wikEd" to summaries
case 'wikEdUsing':
if (wikEd.GetAttribute(buttonObj, 'checked') == 'true') {
Line 5,400 ⟶ 5,414:
break;
// hide ref tags
case 'wikEdRefHide':
if (wikEd.GetAttribute(buttonObj, 'checked') == 'true') {
Line 5,421 ⟶ 5,435:
break;
// close the toolbar
case 'wikEdCloseToolbar':
if (wikEd.GetAttribute(buttonObj, 'checked') == 'true') {
Line 5,438 ⟶ 5,452:
break;
// just toggle the case sensitive search button
case 'wikEdCaseSensitive':
break;
// just toggle the regexp search button
case 'wikEdRegExp':
break;
// just toggle the find-ahead-as-you-type search button
case 'wikEdFindAhead':
break;
// switch to fullscreen edit area
case 'wikEdFullScreen':
if (wikEd.rearrange == true) {
Line 5,464 ⟶ 5,478:
break;
// clear the saved settings for find, replace, and summary history
case 'wikEdClearHistory':
wikEd.ClearHistory('find');
Line 5,472 ⟶ 5,486:
break;
// for testing
case 'wikEdPlaceholder':
break;
Line 5,478 ⟶ 5,492:
}
// reset cursor to normal
if (buttonObj != null) {
buttonObj.style.cursor = 'pointer';
}
// focus the frame
if ( (wikEd.useWikEd == true) && (focusFrame == true) ) {
wikEd.frameWindow.focus();
Line 5,499 ⟶ 5,513:
wikEd.EditButton = function(buttonObj, buttonId, parameters, CustomHandler) {
// check if button is disabled
if (buttonObj != null) {
if (buttonObj.className == 'wikEdButtonInactive') {
Line 5,506 ⟶ 5,520:
}
// remove active and non-text content
wikEd.RemoveElements(['script', 'object', 'applet', 'embed', 'textarea']);
// select the appropriate text change targets (whole, selection, cursor, focusWord, focusLine, selectionWord, or selectionLine)
var obj = {};
obj.changed = {};
var highlightNoTimeOut = false;
// set cursor position into closest highest text node so that highlighting does not bleed out
wikEd.AntiHighlightBleeding(obj, true);
// switch the button
switch (buttonId) {
// undo, redo: whole
case 'wikEdUndo':
case 'wikEdRedo':
Line 5,529 ⟶ 5,543:
break;
// basic wiki character formatting: selection / focusWord / cursor
case 'wikEdBold':
case 'wikEdItalic':
Line 5,554 ⟶ 5,568:
break;
// reference: selection / cursor
case 'wikEdRef':
case 'wikEdRefNamed':
Line 5,566 ⟶ 5,580:
break;
// references and small references: selection / cursor
case 'wikEdReferences':
case 'wikEdReferencesSection':
Line 5,578 ⟶ 5,592:
break;
// character formatting: selection / focusWord / cursor
case 'wikEdCase':
wikEd.GetText(obj, 'selection, cursor');
Line 5,595 ⟶ 5,609:
break;
// multiple line changes: selectionLine / focusLine / cursor
case 'wikEdDecreaseHeading':
case 'wikEdIncreaseHeading':
Line 5,621 ⟶ 5,635:
break;
// sort: selectionLine / focusLine
case 'wikEdSort':
wikEd.GetText(obj, 'selection, cursor, selectionLine');
if (obj.selection.plain
obj.changed = obj.selectionLine;
}
else if (/\n./.test(obj.selection.plain) == false) {
obj.changed = obj.selection;
}
else {
obj.changed = obj.selectionLine;
}
break;
// image: selectionWord (if text is selected) / cursor
case 'wikEdImage':
wikEd.GetText(obj, 'selection, cursor');
Line 5,648 ⟶ 5,661:
break;
// table: selectionLine / cursor
case 'wikEdTable':
wikEd.GetText(obj, 'selection, cursor');
Line 5,661 ⟶ 5,674:
break;
// wikify: selection / whole
case 'wikEdWikify':
if (parameters == 'whole') {
Line 5,679 ⟶ 5,692:
break;
// textify: selection / whole, without wikifying
case 'wikEdTextify':
wikEd.GetText(obj, 'selection', false);
Line 5,691 ⟶ 5,704:
break;
// redirect: whole
case 'wikEdRedirect':
wikEd.GetText(obj, 'whole, selection, cursor');
Line 5,700 ⟶ 5,713:
break;
// find and replace: selection / focusWord / cursor
case 'wikEdFindPrev':
case 'wikEdFindNext':
Line 5,723 ⟶ 5,736:
break;
// replace all: selection / whole
case 'wikEdReplaceAll':
wikEd.GetText(obj, 'selection');
Line 5,735 ⟶ 5,748:
break;
// fixing buttons: selection / whole
case 'wikEdFixBasic':
case 'wikEdFixUnicode':
Line 5,753 ⟶ 5,766:
break;
// fixing buttons: selection / focusPara / cursor
case 'wikEdFixPunct':
case 'wikEdFixMath':
Line 5,775 ⟶ 5,788:
break;
// fixing buttons: selection / focusLine / cursor
case 'wikEdFixChem':
wikEd.GetText(obj, 'selection, cursor');
Line 5,792 ⟶ 5,805:
break;
// source: selection / whole
case 'wikEdSource':
wikEd.GetText(obj, 'selection');
Line 5,804 ⟶ 5,817:
break;
// insert tags: selection / focusWord / cursor
case 'wikEdInsertTags':
wikEd.GetText(obj, 'selection, cursor');
Line 5,821 ⟶ 5,834:
break;
// convert wiki tables to html
case 'wikEdTablify':
wikEd.GetText(obj, 'whole');
Line 5,827 ⟶ 5,840:
break;
// update text view using current control button settings
case 'wikEdUpdateAll':
wikEd.GetText(obj, 'whole');
Line 5,833 ⟶ 5,846:
break;
// custom edit functions have to call wikEd.GetText() themselves
default:
wikEd.GetText(obj, 'cursor');
Line 5,840 ⟶ 5,853:
}
// exit
if (obj.changed == null) {
wikEd.frameWindow.focus();
// reset button to active, reset cursor
if (buttonObj != null) {
if (buttonObj.className != 'wikEdButtonInactive') {
Line 5,853 ⟶ 5,866:
}
// set local syntax highlighting flag
var highlightSyntax = wikEd.highlightSyntax;
// manipulate the text
var selectChanged = true;
var selectChangedText = '';
switch (buttonId) {
// undo
case 'wikEdUndo':
if (wikEd.lastVersion == null) {
Line 5,875 ⟶ 5,888:
break;
// redo
case 'wikEdRedo':
wikEd.FrameExecCommand('redo');
Line 5,886 ⟶ 5,899:
break;
// bold
case 'wikEdBold':
if ( /'''([^'](.|\n)*?)'''/.test(obj.changed.plain) ) {
Line 5,899 ⟶ 5,912:
break;
// italic
case 'wikEdItalic':
if ( /('{3,})''([^'](.|\n)*?)''('{3,})/.test(obj.changed.plain) ) {
Line 5,915 ⟶ 5,928:
break;
// underline
case 'wikEdUnderline':
if ( /<u>((.|\n)*?)<\/u>/i.test(obj.changed.plain) ) {
Line 5,927 ⟶ 5,940:
break;
// strikethrough
case 'wikEdStrikethrough':
if ( /<s>((.|\n)*?)<\/s>/i.test(obj.changed.plain) ) {
Line 5,939 ⟶ 5,952:
break;
// nowiki
case 'wikEdNowiki':
if ( /<nowiki>((.|\n)*?)<\/nowiki>/i.test(obj.changed.plain) ) {
Line 5,951 ⟶ 5,964:
break;
// superscript
case 'wikEdSuperscript':
obj.changed.plain = obj.changed.plain.replace(/^(\s*)<sub>((.|\n)*?)<\/sub>(\s*)$/, '$1$2$4');
Line 5,964 ⟶ 5,977:
break;
// subscript
case 'wikEdSubscript':
obj.changed.plain = obj.changed.plain.replace(/^(\s*)<sup>((.|\n)*?)<\/sup>(\s*)$/, '$1$2$4');
Line 5,977 ⟶ 5,990:
break;
// in-text reference
case 'wikEdRef':
case 'wikEdRefNamed':
Line 6,006 ⟶ 6,019:
break;
// references ___location
case 'wikEdReferences':
case 'wikEdReferencesSection':
Line 6,018 ⟶ 6,031:
var regExp = new RegExp(refEscaped, 'gi');
// plain references tag
if (buttonId == 'wikEdReferences') {
if (obj.changed.plain == '') {
Line 6,035 ⟶ 6,048:
}
// complete references code
else {
if (obj.changed.plain == '') {
Line 6,054 ⟶ 6,067:
break;
// toggle lowercase / uppercase
case 'wikEdCase':
if (obj.changed.plain == '') {
Line 6,060 ⟶ 6,073:
}
// lowercase all uppercased text
else {
// html character entities to chars
var plain = obj.changed.plain;
plain = plain.replace(/>/g, '>');
Line 6,073 ⟶ 6,086:
}
// first-letter-uppercase all lowercased text
else if (plain.toLowerCase() == plain) {
var regExp = new RegExp('(^|[^' + wikEd.letters + '_])([' + wikEd.letters + '_])([' + wikEd.letters + '_\']*)', 'g')
Line 6,083 ⟶ 6,096:
}
// uppercase mixed upper and lowercased text
else {
plain = plain.toUpperCase();
}
// chars back to html character entities
plain = plain.replace(/&/g, '&');
plain = plain.replace(/</g, '<');
Line 6,097 ⟶ 6,110:
break;
// sort alphabetically by visible words, case insensitive, and numerically
case 'wikEdSort':
// fix unicode and character entities
wikEd.FixUnicode(obj.changed);
// sort a single line
if (/\n./.test(obj.changed.plain) == false) {
// Normalize(): normalize strings for sorting
var Normalize = function(text) {
// [ [ |( ) ] ]
text = text.replace(/\[\[[^\[\]\|]*\|([^\[\]]*)\]\]/g, '$1');
// [ [( ) ] ]
text = text.replace(/\[\[([^\[\]\|]*)\]\]/g, '$1');
// start with first letter
var regExp = new RegExp('^[^' + wikEd.letters + '_]+', 'g');
text = text.replace(regExp, '');
// sort numerically by adding preceeding 0s to numbers
text = text.replace(/0*(\d+)(\.\d*)?/g,
function(p, p1, p2) {
return('000000000000000'.substr(p1.length) + p1 + p2);
}
);
// case insensitive
text = text.toLowerCase();
return(text);
}
// SplitSortJoin(): sort list items in one line
var SplitSortJoin = function(regExp, text) {
var sorted = null;
// split text into array of element / separator pairs
var array = [];
var regExpMatch;
var lastMatch = 0;
while ( (regExpMatch = regExp.exec(text)) != null) {
var element = text.substring(lastMatch, regExpMatch.index);
var separator = regExpMatch[0];
array.push([element, separator, Normalize(element)]);
lastMatch = regExp.lastIndex;
}
if (array.length > 0) {
var element = text.substring(lastMatch);
if (element != '') {
array.push([element, '', Normalize(element)]);
}
// sort array after normalized elements
array.sort(function(a, b) {
return(a[2] > b[2]);
});
// join, keep separator next to element if possible, otherwise use last separator
sorted = '';
for (var i = 0; i < array.length; i ++) {
if ( (array[i][1] == '') && (i < array.length - 1) ) {
array[i][1] = array[array.length - 1][1];
array[array.length - 1][1] = '';
}
sorted += array[i][0] + array[i][1];
}
}
return(sorted);
}
// extract sortable text
var pre = '';
var sortable = obj.changed.plain;
var post = '';
// 123 3 4 4 2 15 56 6
var regExpMatch = /^(((\|[\w ]+\=)|\||!|(:*;)+) *)(.*?)( *\n*)$/.exec(obj.changed.plain);
if (regExpMatch != null) {
pre = regExpMatch[1];
sortable = regExpMatch[5];
post = regExpMatch[6];
}
// sortable text enclosed in html
regExpMatch = /^(<[^>]>+)(.*?)(<\/[^>]>+)$/.exec(sortable);
if (regExpMatch != null) {
pre = pre + regExpMatch[1];
sortable = regExpMatch[2];
post = regExpMatch[3] + post;
}
// table cells
var sorted = SplitSortJoin(/ *((\||!){2,2}) *()/g, sortable);
if ( (sorted == null) || (/^(\|{1,1}|!{1,1})/.test(pre) == false) ) {
// bullets, dots, dashes, \|/:-,; in spaces
sorted = SplitSortJoin(/((&nbsp;| )+((\\|\||\/|:|-|,|;)+)(&nbsp;| )+|(&nbsp;| )*(•|•|•|•|·|·|�*xb7;|�*183;|–|–|–|–|—|—|―|―)(&nbsp;| )*)()/gi, sortable);
if (sorted == null) {
// ,;:
sorted = SplitSortJoin(/(&nbsp;| )*(,|;|:)(&nbsp;| )+/g, sortable);
if (sorted == null) {
// multiple spaces with
sorted = SplitSortJoin(/( +&nbsp;|&nbsp;&nbsp;|&nbsp; )(&nbsp;| )*()/g, sortable);
// simple spaces
if (sorted == null) {
sorted = SplitSortJoin(/ +/g, sortable);
}
}
}
}
// join pre, sorted, and post
if (sorted != null) {
sorted = sorted.replace(/ {2,}/, ' ');
sorted = sorted.replace(/ +$/, '');
post = post.replace(/ +(\n*|$)/, '$1');
obj.changed.plain = pre + sorted + post;
}
break;
}
// keep leading and trailing empty lines and table syntax
var pre = '';
var main = '';
Line 6,117 ⟶ 6,253:
}
// join cells in table rows
main = main.replace(/(^|\n)(\|[^\-\+\}](.|\n)*?(?=(\|\-|\{\||\|\}|$)|$))/g,
function(p, p1, p2, p3) {
Line 6,125 ⟶ 6,261:
);
// cycle through lines
var lines = main.split('\n');
var sortArray = [];
Line 6,132 ⟶ 6,268:
var sortKey = line;
// remove empty lines
if (line == '') {
continue;
Line 6,138 ⟶ 6,274:
sortKey = sortKey.replace(/\x00/g, '\n');
// remove html
sortKey = sortKey.replace(/<.*>/g, '');
// lowercase
sortKey = sortKey.toLowerCase();
// keep visible text of wikilinks only
sortKey = sortKey.replace(/\[\[[^\|\[\]]*\|/g, '');
sortKey = sortKey.replace(/\[\[|\]\]/g, '');
// keep visible text of external links only
sortKey = sortKey.replace(/\[(https?|ftp|irc|gopher):\S+/g, '');
// keep visible cell content only
sortKey = sortKey.replace(/((^|\n)(\||\!))(?![\+\-\}\|\!])[^\|\!]*(\||\!)(?!\4)/g, '$1');
sortKey = sortKey.replace(/(^|\n)\|-.*?(\n|$)/g, '$2');
// keep single ' only
sortKey = sortKey.replace(/'{2,}/g, '');
// remove decimal commas
sortKey = sortKey.replace(/(\d)\,(?=\d\d\d(\D|$))/g, '$1');
// sort numerically by adding preceeding 0s to numbers
sortKey = sortKey.replace(/0*(\d+)(\.\d*)?/g,
function(p, p1, p2) {
Line 6,168 ⟶ 6,304:
);
// non-breaking and other spaces
sortKey = sortKey.replace(/ |\s/g, ' ');
// remove umlauts (just guessing, but probably better than not doing it)
sortKey = sortKey.replace(/[à-æ]/g, 'a');
sortKey = sortKey.replace(/[ç]/g, 'c');
Line 6,183 ⟶ 6,319:
sortKey = sortKey.replace(/[ýÿ]/g, 'y');
// remove non-chars
sortKey = sortKey.replace(/[^\$\@\.\,\:\;\-\w\s'\u007f-\uffff]/g, '');
// join multiple spaces
sortKey = sortKey.replace(/ +/g, ' ');
// remove leading and trailing spaces
sortKey = sortKey.replace(/^ +| +$/g, '');
Line 6,195 ⟶ 6,331:
}
// sort lines
sortArray = sortArray.sort(
function(a, b) {
Line 6,207 ⟶ 6,343:
);
// join lines
var joined = '';
for (var i = 0; i < sortArray.length; i ++) {
Line 6,221 ⟶ 6,357:
break;
// undo all
case 'wikEdUndoAll':
if (wikEd.lastVersion == null) {
Line 6,232 ⟶ 6,368:
break;
// redo all
case 'wikEdRedoAll':
if (wikEd.lastVersion != null) {
Line 6,239 ⟶ 6,375:
break;
// create wikilink
case 'wikEdWikiLink':
if ( /\[\[((.|\n)*?)\]\]/.test(obj.changed.plain) ) {
Line 6,252 ⟶ 6,388:
break;
// create weblink
case 'wikEdWebLink':
if ( /\[((.|\n)*?)\]/.test(obj.changed.plain) ) {
Line 6,264 ⟶ 6,400:
break;
// decrease heading level
case 'wikEdDecreaseHeading':
// decrease heading
obj.changed.plain = obj.changed.plain.replace(/(^|\n)=(=+) *(.*?) *=+(?=\n|$)/g, '$1$2 $3 $2');
// remove heading
obj.changed.plain = obj.changed.plain.replace(/(^|\n)=(?!=) *(.*?) *=+(?=\n|$)/g, '$1$2');
// adjust closing tags
obj.changed.plain = obj.changed.plain.replace(/(^|\n)(=+) *(.*?) *=+(?=\n|$)/g, '$1$2 $3 $2');
obj.changed.keepSel = true;
break;
// increase heading level
case 'wikEdIncreaseHeading':
// increase heading
obj.changed.plain = obj.changed.plain.replace(/(^|\n)(=+) *(.*?) *=+(?=\n|$)/g, '$1=$2 $3 $2=');
// create new heading
if (/\n/.test(obj.changed.plain) == false) {
obj.changed.plain = obj.changed.plain.replace(/(^|\n)([^=\s].*?)(?=\n|$)/g, '$1== $2 ==');
}
// adjust closing tags
obj.changed.plain = obj.changed.plain.replace(/(^|\n)(=+) *(.*?) *=+(?=\n|$)/g, '$1$2 $3 $2');
obj.changed.keepSel = true;
break;
// increase bullet list
case 'wikEdIncreaseBulletList':
obj.changed.plain = obj.changed.plain.replace(/(.+)/g,
Line 6,305 ⟶ 6,441:
break;
// decrease bullet list
case 'wikEdDecreaseBulletList':
obj.changed.plain = obj.changed.plain.replace(/(.+)/g,
Line 6,316 ⟶ 6,452:
break;
// increase numbered list
case 'wikEdIncreaseNumberList':
obj.changed.plain = obj.changed.plain.replace(/(.+)/g,
Line 6,327 ⟶ 6,463:
break;
// decrease numbered list
case 'wikEdDecreaseNumberList':
obj.changed.plain = obj.changed.plain.replace(/(.+)/g,
Line 6,338 ⟶ 6,474:
break;
// increase indented list
case 'wikEdIncreaseIndentList':
obj.changed.plain = obj.changed.plain.replace(/(.+)/g,
Line 6,349 ⟶ 6,485:
break;
// decrease indented list
case 'wikEdDecreaseIndentList':
obj.changed.plain = obj.changed.plain.replace(/(.+)/g,
Line 6,360 ⟶ 6,496:
break;
// create definition list
case 'wikEdDefinitionList':
obj.changed.plain = obj.changed.plain.replace(/(.+)/g,
Line 6,370 ⟶ 6,506:
break;
// create image
case 'wikEdImage':
if (obj.changed.plain != '') {
Line 6,385 ⟶ 6,521:
break;
// create table
case 'wikEdTable':
if (obj.changed.plain != '') {
Line 6,406 ⟶ 6,542:
break;
// wikify: always done above
case 'wikEdWikify':
break;
// textify: strip html from pasted content
case 'wikEdTextify':
wikEd.Textify(obj.changed);
Line 6,418 ⟶ 6,554:
break;
// redirect
case 'wikEdRedirect':
var linkTarget;
Line 6,431 ⟶ 6,567:
}
// remove link text after |
linkTarget = linkTarget.replace(/\|(.|\n)*()/, '');
// remove formatting and spaces
linkTarget = linkTarget.replace(/^(=+|'+|<[^>]*>|\s+|\[)+((.|\n)*?)(=+|'+|<[^>]*>|\s+|\])+$/g, '$2');
linkTarget = linkTarget.replace(/</g, '<');
Line 6,443 ⟶ 6,579:
obj.changed.plain = '#REDIRECT [[' + linkTarget + ']]';
// append to summary
if (wikEd.wikiGlobals.wgUseAutomaticEditSummaries != true) {
if (wikEd.inputElement.summary != null) {
Line 6,458 ⟶ 6,594:
break;
// find and replace
case 'wikEdFindPrev':
case 'wikEdFindNext':
Line 6,468 ⟶ 6,604:
case 'wikEdReplaceAll':
// get the find text
var findText;
// unescape <, >, and &
obj.changed.plain = obj.changed.plain.replace(/</g, '<');
obj.changed.plain = obj.changed.plain.replace(/>/g, '>');
obj.changed.plain = obj.changed.plain.replace(/&/g, '&');
// copy selection/word under cursor to find field
if ( (parameters == 'shift') && ( (buttonId == 'wikEdFindNext') || (buttonId == 'wikEdReplaceNext') ) ) {
if (/\n/.test(obj.changed.plain) == false) {
Line 6,491 ⟶ 6,627:
}
// get the find text from the selection
if ( (buttonId == 'wikEdJumpPrev') || (buttonId == 'wikEdJumpNext') ) {
findText = obj.changed.plain;
Line 6,501 ⟶ 6,637:
}
// get the find text from the find field
else {
if (wikEd.inputElement.find.value != '') {
Line 6,512 ⟶ 6,648:
}
// get button status
var regExpChecked = wikEd.GetAttribute(wikEd.regExp, 'checked');
var caseSensitiveChecked = wikEd.GetAttribute(wikEd.caseSensitive, 'checked');
// get the replace text
var replaceText = wikEd.inputElement.replace.value;
// format the find and replace texts for a plain text search
var useRegExp = true;
if ( (regExpChecked == 'false') || (buttonId == 'wikEdJumpPrev') || (buttonId == 'wikEdJumpNext') ) {
Line 6,525 ⟶ 6,661:
}
// format the replace text for a regular expression search
if ( (buttonId == 'wikEdReplacePrev') || (buttonId == 'wikEdReplaceNext') || (buttonId == 'wikEdReplaceAll') ) {
if (useRegExp == true) {
// substitute \\ \n \r \t \' \" \127 \x1f \u12ef
replaceText = replaceText.replace(/\\\\/g, '\x00');
replaceText = replaceText.replace(/\\n/g, '\n');
Line 6,556 ⟶ 6,692:
}
// check the regexp
var replacedFlag = false;
var regExpFind;
Line 6,579 ⟶ 6,715:
}
// replace all
if (buttonId == 'wikEdReplaceAll') {
if (regExpFind.test(obj.changed.plain)) {
Line 6,590 ⟶ 6,726:
}
// replace an existing selection
else if ( (buttonId == 'wikEdReplacePrev') || (buttonId == 'wikEdReplaceNext') ) {
if (regExpFind.test(obj.selection.plain)) {
Line 6,622 ⟶ 6,758:
if (replacedFlag == false) {
// get direction
var backwards = false;
if ( (buttonId == 'wikEdFindPrev') || (buttonId == 'wikEdJumpPrev') || (buttonId == 'wikEdReplacePrev') ) {
Line 6,628 ⟶ 6,764:
}
// get case sensitive
var caseSensitive = false;
if (caseSensitiveChecked == 'true') {
Line 6,634 ⟶ 6,770:
}
// find all
if (buttonId == 'wikEdFindAll') {
var found;
var foundRanges = [];
// start at top of text
wikEd.RemoveAllRanges(obj.sel);
var range = wikEd.frameDocument.createRange();
Line 6,648 ⟶ 6,784:
range = obj.sel.addRange(range);
// cycle through matches
var scrollTop = wikEd.frameBody.scrollTop;
do {
// wikEd.Find(obj, findText, caseSensitive, backwards, wrap, useRegExp)
found = wikEd.Find(obj, findText, caseSensitive, false, false, useRegExp);
if (found == true) {
Line 6,659 ⟶ 6,795:
} while (found == true);
// scroll back
if (regExpChecked == 'false') {
wikEd.frameBody.scrollTop = scrollTop;
}
// add the found ranges, Webkit does not support multiple selections
wikEd.RemoveAllRanges(obj.sel);
for (var i = 0; i < foundRanges.length; i ++) {
Line 6,673 ⟶ 6,809:
}
// normal find
else {
obj.selectChanged = selectChanged;
Line 6,682 ⟶ 6,818:
}
// escape <, >, and &
if (obj.changed.plain != null) {
obj.changed.plain = obj.changed.plain.replace(/&/g, '&');
Line 6,689 ⟶ 6,825:
}
// save search history to settings
if ( (buttonId == 'wikEdFindPrev') || (buttonId == 'wikEdFindNext') || (buttonId == 'wikEdFindAll') ) {
wikEd.AddToHistory('find');
Line 6,700 ⟶ 6,836:
break;
// fixbasic: fix characters, spaces, empty lines, certain headings, needed for all fixing functions
// to do: only certain changes in multiline tags: comments, tables, subst
case 'wikEdFixBasic':
wikEd.FixBasic(obj.changed);
Line 6,759 ⟶ 6,895:
break;
// source on
case 'wikEdSource':
obj.changed.plain = obj.changed.code;
Line 6,769 ⟶ 6,905:
break;
// insert tags
case 'wikEdInsertTags':
var tagOpen = parameters[0] || '';
Line 6,784 ⟶ 6,920:
tagsampleText = sampleText.replace(/>/g, '>');
// single string to insert
if ( (tagOpen.length > 0) && (tagClose.length == 0) && (sampleText.length == 0) ) {
obj.changed = obj.cursor;
Line 6,790 ⟶ 6,926:
}
// opening and closing strings
else if ( (obj.changed.plain == '') && (sampleText.length > 0) ) {
obj.changed.plain = tagOpen + sampleText + tagClose;
// select sample text
selectChangedText = sampleText;
obj.changed.keepSel = true;
Line 6,803 ⟶ 6,939:
break;
// convert wiki tables to html // {{TABLE}}
case 'wikEdTablify':
obj.changed.keepSel = true;
Line 6,811 ⟶ 6,947:
break;
// update text view using current control button settings // {{TABLE}}
case 'wikEdUpdateAll':
obj.changed.keepSel = true;
Line 6,821 ⟶ 6,957:
break;
// custom edit functions
default:
if (CustomHandler != null) {
Line 6,832 ⟶ 6,968:
}
// pause frame spellchecking
var pauseFrameSpellchecking = false;
var frameSpellchecking = wikEd.frameBody.spellcheck;
Line 6,852 ⟶ 6,988:
}
// get the scroll position
var frameScrollTop = wikEd.frameBody.scrollTop;
var frameScrollLeft = wikEd.frameBody.scrollLeft;
// update the selection ranges, do not add any text changes
if (obj.changed.plain == null) {
if (buttonId != 'wikEdFindAll') {
Line 6,862 ⟶ 6,998:
obj.sel.addRange(obj.changed.range);
// scroll the selected text into the viewport
if (selectChanged != false) {
wikEd.ScrollToSelection();
Line 6,869 ⟶ 7,005:
}
// apply text changes
else {
// a text change erases the last version for redo all
if ( (buttonId != 'wikEdUndo') && (buttonId != 'wikEdRedo') && (buttonId != 'wikEdUndoAll') ) {
wikEd.lastVersion = null;
}
// highlight the syntax
obj.html = obj.changed.plain;
if (highlightSyntax == true) {
Line 6,886 ⟶ 7,022:
}
// at least highlight tab characters
else {
obj.html = obj.html.replace(/(\t)/g, '<span class="wikEdTabPlain">$1</span><!--wikEdTabPlain-->');
}
// display multiple blanks as blank-
obj.html = obj.html.replace(/(^|\n) /g, '$1 ');
obj.html = obj.html.replace(/ (\n|$)/g, ' $1');
Line 6,897 ⟶ 7,033:
obj.html = obj.html.replace(/ {2}/g, ' ');
// newlines to <br>
obj.html = obj.html.replace(/\n/g, '<br>');
// make changed range text the current selection
wikEd.RemoveAllRanges(obj.sel);
var range = obj.changed.range;
obj.sel.addRange(range);
// replace the selection with changed text
// Opera 9.50beta bug: inserthtml removes blanks and generates consecutive text nodes
if (obj.html != '') {
var reselectBefore = '';
Line 6,921 ⟶ 7,057:
}
// select the whole text after replacing the whole text and scroll to same height
if (obj.changed.from == 'whole') {
wikEd.RemoveAllRanges(obj.sel);
Line 6,932 ⟶ 7,068:
}
// select the changed text and scroll it into the viewport
else if (selectChanged != false) {
wikEd.RemoveAllRanges(obj.sel);
Line 6,939 ⟶ 7,075:
var endNodeReselect = wikEd.frameDocument.getElementById('wikEdScrollAfter' + wikEd.insertCounter);
range.setStartAfter(startNodeReselect);
// should be range.setEndAfter, but that causes caret at start of next line due to https://bugzilla.mozilla.org/show_bug.cgi?id=587461
range.setEndBefore(endNodeReselect);
obj.sel.addRange(range);
Line 6,946 ⟶ 7,082:
}
// remove selection, keep whole text auto-selection as warning
if (
( (obj.changed.keepSel != true) && (obj.changed.from != 'whole') ) ||
Line 6,960 ⟶ 7,096:
}
// focus edit area to continue editing as there is no selection that would be overwritten
wikEd.frameWindow.focus();
}
// reset button to active, reset cursor
if (buttonObj != null) {
if (buttonObj.className != 'wikEdButtonInactive') {
Line 6,972 ⟶ 7,108:
}
// grey out inactive buttons
wikEd.InactiveButtons();
// add event handlers to unhide refs and templates
if ( (highlightSyntax == true) && (obj.changed.plain != null) ) {
// add ref and template names to hide buttons
wikEd.HighlightNamedHideButtons();
// add event handlers to unhide refs and templates
wikEd.HideAddHandlers();
// add event handlers to make highlighted frame links ctrl-clickable
wikEd.LinkifyAddHandlers();
}
// resume frame spellchecking
if (pauseFrameSpellchecking == true) {
wikEd.frameBody.spellcheck = true;
Line 7,005 ⟶ 7,141:
wikEd.previewIsAjax = true;
// get response
var html = ajax.responseText;
// livepreview
if (html.indexOf('<livepreview>') != -1) {
html = html.replace(/\s*<\/livepreview>\s*()/, '');
Line 7,020 ⟶ 7,156:
}
// full preview page
else {
// attach <style> stylesheet declarations to document (GeSHi)
var regExpMatch;
while ( (regExpMatch = regExp.exec(html)) != null) { var css = regExpMatch[2];
var stylesheet = new wikEd.StyleSheet(document);
Line 7,031 ⟶ 7,168:
}
// get preview html
html = wikEd.StringGetInnerHTML(html, 'div', 'id', 'wikiPreview', true);
html = wikEd.StringGetInnerHTML(html, 'div', 'class', 'previewnote', true, false, true);
Line 7,038 ⟶ 7,175:
}
// clean form elements
html = html.replace(/<\/?form\b[^>]*>/g, '');
html = html.replace(/(<\/?input\b[^>]*?)\bname="search"([^>]*>)/g, '$1$2');
// remove cite errors for automatic section preview refs
html = html.replace(/(<div\b[^>]*?\bclass="wikEdPreviewRefs"[^>]*>(.|\s)*$)/,
function (p, p1, p2) {
Line 7,051 ⟶ 7,188:
wikEd.previewBox.innerHTML = html;
// init sortable tables (wikibits.js)
if (typeof(sortables_init) == 'function') {
sortables_init();
}
// init collapsible tables (common.js)
if (typeof(createCollapseButtons) == 'function') {
createCollapseButtons();
}
// scroll to button, textarea, or preview field
wikEd.ScrollToPreview();
// run scheduled custom functions
wikEd.ExecuteHook(wikEd.config.previewHook);
return;
};
Line 7,073 ⟶ 7,214:
wikEd.FilePreviewAjaxHandler = function(ajax) {
// get response
var html = ajax.responseText;
// html-ize
html = html.replace(/\s*<\/preview>\s*()/, '');
html = html.replace(/\s*<\/livepreview>\s*()/, '');
Line 7,086 ⟶ 7,227:
html = html.replace(/<\/?(br|p)\b.*?>/g, '\n');
// parse response into file url cache
var regExpFile = new RegExp('\\n((Image|File|' + wikEd.config.text['wikicode Image'] + '|' + wikEd.config.text['wikicode File'] + '):[^ ]+) +(\\d+) +(.*)', 'ig');
var regExpMatch;
Line 7,112 ⟶ 7,253:
}
// cycle through file preview spans and add missing images as background
for (var i = 0; i < wikEd.filePreviewNo; i ++) {
if (wikEd.filePreviewIds[i] != '') {
Line 7,142 ⟶ 7,283:
wikEd.DiffResponse = function(oldVersion, newVersion) {
// add trailing newline
if (oldVersion.substr(oldVersion.length - 1, 1) != '\n') {
oldVersion += '\n';
Line 7,150 ⟶ 7,291:
}
// call external diff program
var diffText = WDiffString(oldVersion, newVersion);
if (wikEd.config.fullDiff != true) {
Line 7,156 ⟶ 7,297:
}
// linkify blockwise with breaks at delete and block move tags
var diffTextLinkified = '';
var regExp = /<span\b[^>]+?\bclass="wDiffHtml(Delete|Block)"[^>]*>/g;
Line 7,177 ⟶ 7,318:
wikEd.DiffLinkify = function(html) {
// < > to \x00 \x01
html = html.replace(/</g, '\x00');
html = html.replace(/>/g, '\x01');
// external links
html = html.replace(/\b(((https?|ftp|irc|gopher):\/\/)|news:|mailto:)([^\x00-\x20\s"\[\]\x7f\|\{\}<>]|<[^>]*>)+?(?=([\!"\(\)\.\,\:\;\‘-•]*\s|[\x00-\x20\s"\[\]\x7f\|\{\}]))/gi,
function (p) {
Line 7,193 ⟶ 7,334:
title = title.replace(/^\s+|\s+$/g, '');
title = decodeURI(title);
var url = title.replace(/\s/g, '_');
url = encodeURI(url);
Line 7,199 ⟶ 7,340:
url = url.replace(/'/g, '%27');
url = url.replace(/#/g, '%23');
var linkTitle = title.replace(/"/g, '"');
// linkify all url text fragments between highlighting <span>s seperately
var anchorOpen = '<a href = "' + url + '" style="text-decoration: none; color: inherit; color: expression(parentElement.currentStyle.color);" title="' + linkTitle + '">';
var anchorClose = '</a>';
Line 7,210 ⟶ 7,351:
);
// linkify links and templates
if ( (wikEd.wikiGlobals.wgServer != null) && (wikEd.wikiGlobals.wgArticlePath != null) ) {
//
html = html.replace(/(\[\[([^|\[\]{}\n]+)(\|[^\[\]{}<>]*)?\]\])|(\{\{([^|\[\]{}\n]*)([^\[\]{}<>]*\}\})?)/g,
function (p, p1, p2, p3, p4, p5, p6) {
Line 7,220 ⟶ 7,361:
var whole = p;
// extract title
var title = articleName;
if (title == '') {
Line 7,231 ⟶ 7,372:
title = title.replace(/^\s+|\s+$/g, '');
// [[/subpage]] refers to a subpage of the current page, [[#section]] to a section of the current page
if ( (title.indexOf('/') == 0) || (title.indexOf('#') == 0) ) {
title = wikEd.pageName + title;
}
// create url
var url = title.replace(/\s/g, '_');
url = encodeURI(url);
Line 7,251 ⟶ 7,392:
url = wikEd.wikiGlobals.wgServer + wikEd.wikiGlobals.wgArticlePath.replace(/\$1/, url);
// linkify all text fragments between highlighting <span>s seperately
var anchorOpen = '<a href = "' + url + '" style = "text-decoration: none; color: inherit; color: expression(parentElement.currentStyle.color)" title="' + articleTitle + '">';
var anchorClose = '</a>';
Line 7,260 ⟶ 7,401:
}
// \x00 and \x01 back to < and >
html = html.replace(/\x00/g, '<');
html = html.replace(/\x01/g, '>');
Line 7,307 ⟶ 7,448:
}
// return whole html if node does not exist
if (endPos == null) {
if (defaultToWholeHTML == true) {
Line 7,314 ⟶ 7,455:
}
// return text before node
else if (getBeforeHTML == true) {
string = html.substr(0, startPos);
}
// return text after node
else if (getAfterHTML == true) {
string = html.substr(endPos + endLength);
}
// return innerHTML of node
else {
string = html.substring(startPos + startLength, endPos);
Line 7,339 ⟶ 7,480:
wikEd.ScrollToPreview = function() {
// reset fixed height to auto
wikEd.previewBox.style.height = 'auto';
Line 7,383 ⟶ 7,524:
}
// much faster than individual getElementById in SeaMonkey 1.1.18
var spans = wikEd.frameDocument.getElementsByTagName('span');
for (var i = 0; i < spans.length; i ++) {
Line 7,409 ⟶ 7,550:
var rules = '';
// references
for (var i = 0; i < wikEd.referenceArray.length; i ++) {
if (wikEd.referenceArray[i].added == true) {
Line 7,423 ⟶ 7,564:
}
// templates
for (var i = 0; i < wikEd.templateArray.length; i ++) {
if (wikEd.templateArray[i].added == true) {
Line 7,437 ⟶ 7,578:
}
// character entities
for (var i = 0; i < wikEd.charEntityArray.length; i ++) {
if (wikEd.charEntityArray[i].added == true) {
Line 7,455 ⟶ 7,596:
}
// add or replace existing css rules
if (rules != '') {
wikEd.HighlightNamedHideButtonsStylesheet.AddCSSRules(rules);
Line 7,500 ⟶ 7,641:
wikEd.HideShowHandler = function(event) {
// event compatibility fixes
event = wikEd.EventWrapper(event, this);
if (event == null) {
Line 7,507 ⟶ 7,648:
event.preventDefault();
// find hidden content node
var hideTarget
var hideInto
var hideButtonClass;
var hideClass;
var hideButton;
var hideContainer;
var hide;
if ( (event.type == 'mouseover') || (event.type == 'mouseout') || (event.type == 'click') ) {
hideTarget = event.currentTarget;
hideInto = event.safeRelatedTarget;
// <container><button></button></container><hide> text </hide>
// target == button
hideButton = hideTarget;
hideContainer = hideButton.parentNode;
if (hideContainer != null) {
if (/^wikEd(Ref|Templ|CharEntity)Container$/.test(hideContainer.className) == false) {
hideContainer = null;
}
else {
// get hide text
hide = wikEd.GetNextSiblingNode(hideContainer);
if (hide != null) {
if (/^wikEd(Ref|Templ|TemplNs|CharEntity)(Show)?$/.test(hide.className) == false) {
hide = null;
}
}
}
}
}
// target == hide text
hide = hideTarget;
hideContainer = wikEd.GetPreviousSiblingNode(hideTarget);
if (hideContainer != null) {
if (/^wikEd(Ref|Templ|CharEntity)Container$/.test(hideContainer.className) == false) {
hideContainer = null;
}
else {
// get button
hideButton = wikEd.GetFirstChildNode(hideContainer);
if (hideButton != null) {
if (/^wikEd(Ref|Templ|CharEntity)Button(Show)?\d*$/.test(hideButton.className) == false) {
hideButton = null;
}
}
}
}
}
return;
}
// get classes
hideButtonClass = hideButton.className;
hideClass = hide.className;
}
// schedule unhide on later shift or ctrl key push
if (event.type == 'mouseover') {
if (wikEd.config.unhideShift == true) {
if ( (event.type == 'mouseover') && (wikEd.config.unhideShift == true) && (event.shiftKey == false) && (event.ctrlKey == false) ) {
wikEd.scheduledUnhide = [hide, hideButton];
wikEd.AddEventListener(wikEd.frameDocument, 'keydown', wikEd.HideShowHandler, true);
wikEd.AddEventListener(hideButton, 'mouseout', wikEd.HideShowHandler, true);
return;
}
}
}
// scheduled unhide on shift or ctrl keydown
if (event.type == 'keydown') {
if ( (wikEd.scheduledUnhide != null) && ( (event.shiftKey == true) || (event.ctrlKey == true) ) ) {
hide = wikEd.scheduledUnhide[0];
hideButton = wikEd.scheduledUnhide[1];
hideButtonClass = hideButton.className;
hideClass = hide.className;
}
}
// open on hover
if ( (event.type == 'mouseover') || ( (event.type == 'keydown') && (wikEd.scheduledUnhide != null) ) ) {
if (hideButtonClass.indexOf('wikEdRefButton') == 0) {
hide.style.display = 'block';
Line 7,583 ⟶ 7,752:
}
// close after hover
else if (event.type == 'mouseout') {
if ( (hideInto != hideContainer) && (hideInto != hideButton) && (hideInto != hide) ) {
Line 7,605 ⟶ 7,774:
wikEd.AddEventListener(hideButton, 'mouseover', wikEd.HideShowHandler, true);
// move cursor out of hidden text
wikEd.UnhideCursor(hideContainer, hide);
}
Line 7,612 ⟶ 7,781:
}
// hide on click
else if (event.type == 'click') {
if (/^wikEd(Ref|Templ|CharEntity)ButtonShow\d*$/.test(hideButtonClass) == true) {
Line 7,625 ⟶ 7,794:
wikEd.AddEventListener(hideButton, 'mouseover', wikEd.HideShowHandler, true);
// move cursor out of hidden text
wikEd.UnhideCursor(hideContainer, hide);
}
// open on click
else if (/^wikEd(Ref|Templ|CharEntity)Button\d*$/.test(hideButtonClass) == true) {
if (hideButtonClass.indexOf('wikEdCharEntityButton') == 0) {
Line 7,649 ⟶ 7,818:
}
}
// clear scheduled unhide
if (wikEd.scheduledUnhide != null) {
wikEd.RemoveEventListener(wikEd.frameDocument, 'keydown', wikEd.HideShowHandler, true);
wikEd.scheduledUnhide = null;
}
return;
};
Line 7,659 ⟶ 7,835:
wikEd.UnhideCursor = function(firstHiddenParent, lastHiddenParent) {
// get selection and clone range
var sel = wikEd.GetSelection();
var range = sel.getRangeAt(sel.rangeCount - 1);
if (range != null) {
// check if selected text is hidden
var startHidden = false;
var node = range.startContainer;
Line 7,690 ⟶ 7,866:
}
// unselect hidden text
if ( (startHidden == false) && (endHidden == true) ) {
range.setEndBefore(firstHiddenParent);
Line 7,712 ⟶ 7,888:
wikEd.GetText = function(obj, whichFragment, wikify) {
// remove dynamically inserted nodes by other scripts
wikEd.CleanNodes(wikEd.frameDocument);
// get selection object
if (obj.sel == null) {
obj.sel = wikEd.GetSelection();
}
// cursor for the cursor position (always done)
if (obj.cursor == null) {
obj.cursor = {
Line 7,728 ⟶ 7,904:
};
// set cursor range
obj.cursor.range = wikEd.frameDocument.createRange();
wikEd.SetRangeStart(obj.cursor.range, obj.sel.focusNode, obj.sel.focusOffset);
Line 7,734 ⟶ 7,910:
}
// whole for the whole text
if (obj.whole == null) {
if (/whole|selectionWord|selectionLine|selectionPara|focusWord|focusLine|focusPara/.test(whichFragment) == true) {
Line 7,745 ⟶ 7,921:
};
// set whole range
obj.whole.range = wikEd.frameDocument.createRange();
obj.whole.range.setStart(wikEd.frameBody, 0);
obj.whole.range.setEnd(wikEd.frameBody, wikEd.frameBody.childNodes.length);
// get whole plain text
wikEd.GetInnerHTML(obj.whole, wikEd.frameBody);
obj.whole.code = obj.whole.html;
Line 7,760 ⟶ 7,936:
}
// selection for the selected text
if (obj.selection == null) {
if (/selection\b|selectionWord|selectionLine|selectionPara/.test(whichFragment) == true) {
Line 7,768 ⟶ 7,944:
};
// copy range to document fragment
if (obj.sel.rangeCount == 0) {
obj.sel.collapse(wikEd.frameBody, 0);
Line 7,775 ⟶ 7,951:
var documentFragment = obj.selection.range.cloneContents();
// get selected text
wikEd.GetInnerHTML(obj.selection, documentFragment);
obj.selection.code = obj.selection.html;
Line 7,785 ⟶ 7,961:
}
// focusWord, focusLine, and focusPara for the word, line, and paragraph under the cursor
if (obj.focusWord == null) {
if (/focusWord|focusLine|focusPara/.test(whichFragment) == true) {
Line 7,795 ⟶ 7,971:
};
// setup focusLine object for the line under the cursor
obj.focusLine = {
'from': 'focusLine',
Line 7,803 ⟶ 7,979:
};
// setup focusPara object for the paragraph under the cursor
obj.focusPara = {
'from': 'focusPara',
Line 7,811 ⟶ 7,987:
};
// find the word and line boundaries
wikEd.FindBoundaries(obj.focusWord, obj.focusLine, obj.focusPara, obj.whole, obj.cursor);
// get the wikified plain text for the word under the cursor
var documentFragment = obj.focusWord.range.cloneContents();
wikEd.GetInnerHTML(obj.focusWord, documentFragment);
Line 7,823 ⟶ 7,999:
obj.focusWord.plain = obj.focusWord.plain.replace(/\xa0/g, ' ');
// get the wikified plain text for the line under the cursor
var documentFragment = obj.focusLine.range.cloneContents();
wikEd.GetInnerHTML(obj.focusLine, documentFragment);
Line 7,832 ⟶ 8,008:
obj.focusLine.plain = obj.focusLine.plain.replace(/\xa0/g, ' ');
// get the wikified plain text for the paragraph under the cursor
var documentFragment = obj.focusPara.range.cloneContents();
wikEd.GetInnerHTML(obj.focusPara, documentFragment);
Line 7,843 ⟶ 8,019:
}
// selectionWord and selectionLine for the complete words and lines under the selection
if (obj.selectionWord == null) {
if (/selectionWord|selectionLine|selectionPara/.test(whichFragment) == true) {
// setup selectionWord object for the words under the selection
obj.selectionWord = {
'from': 'selectionWord',
Line 7,855 ⟶ 8,031:
};
// setup selectionLine object for the lines under the selection
obj.selectionLine = {
'from': 'selectionLine',
Line 7,863 ⟶ 8,039:
};
// setup focusPara object for the paragraph under the selection
obj.selectionPara = {
'from': 'selectionPara',
Line 7,871 ⟶ 8,047:
};
// find the word and line boundaries
wikEd.FindBoundaries(obj.selectionWord, obj.selectionLine, obj.selectionPara, obj.whole, obj.selection);
// get the wikified plain text for the words under the selection
var documentFragment = obj.selectionWord.range.cloneContents();
wikEd.GetInnerHTML(obj.selectionWord, documentFragment);
Line 7,883 ⟶ 8,059:
obj.selectionWord.plain = obj.selectionWord.plain.replace(/\xa0/g, ' ');
// get the wikified plain text for the lines under the selection
var documentFragment = obj.selectionLine.range.cloneContents();
wikEd.GetInnerHTML(obj.selectionLine, documentFragment);
Line 7,892 ⟶ 8,068:
obj.selectionLine.plain = obj.selectionLine.plain.replace(/\xa0/g, ' ');
// get the wikified plain text for the paragraph under the selection
var documentFragment = obj.selectionPara.range.cloneContents();
wikEd.GetInnerHTML(obj.selectionPara, documentFragment);
Line 7,914 ⟶ 8,090:
var found = false;
// get selection
if (obj.sel == null) {
obj.sel = wikEd.GetSelection();
Line 7,928 ⟶ 8,104:
obj.selectChanged = false;
// empty the range to avoid error messages for reverse direction ranges
obj.changed.range = wikEd.frameDocument.createRange();
// regexp instead of plain text search for browser lacking .find (Opera), built in .find() ignores newlines
if (useRegExp != true) {
if (typeof(wikEd.frameWindow.find) != 'function') {
Line 7,939 ⟶ 8,115:
}
// create the regexp
var regExpFind;
if (useRegExp == true) {
Line 7,954 ⟶ 8,130:
}
// use the fast built-in find function for non-regexp searches; Opera does not have .find
if (useRegExp != true) {
// parameters: window.find(string, caseSensitive, backwards, wrapAround, wholeWord, searchInFrames, showDialog)
found = wikEd.frameWindow.find(findText, caseSensitive, backwards, wrap, false, true, false);
if (found == true) {
Line 7,965 ⟶ 8,141:
}
// slow javascript regexp find and replace
else {
// perform find
if (obj.plainArray === undefined) {
wikEd.ParseDOM(obj, wikEd.frameBody);
Line 7,974 ⟶ 8,150:
var regExpMatch = [];
// find next, search to the right
if (backwards == false) {
// set start position for search to right
regExpFind.lastIndex = obj.plainFocus;
// execute the regexp search to the right
regExpMatch = regExpFind.exec(obj.plain);
// remember position for repeated searches
obj.plainFocus = regExpFind.lastIndex;
// wrap around, start at beginning
if ( (wrap == true) && (regExpMatch == null) ) {
regExpFind.lastIndex = 0;
Line 7,993 ⟶ 8,169:
}
// find previous, search to the left
else {
// cycle through the matches to the left
var regExpMatchNext;
do {
Line 8,006 ⟶ 8,182:
} while (regExpMatchNext.index < obj.plainAnchor);
// wrap around, find last occurrence
if ( (wrap == true) && (regExpMatch == null) ) {
do {
Line 8,015 ⟶ 8,191:
}
// select the find
if (regExpMatch != null) {
found = true;
Line 8,049 ⟶ 8,225:
wikEd.ScrollToSelection = function(frameScrollTop, frameScrollLeft, removeHelperNodes) {
// get selection and clone range
var obj = {};
obj.sel = wikEd.GetSelection();
Line 8,056 ⟶ 8,232:
}
// get selection plain text
range = obj.sel.getRangeAt(obj.sel.rangeCount - 1);
var documentFragment = range.cloneContents();
Line 8,064 ⟶ 8,240:
plainText = plainText.replace(/>/g, '>');
plainText = plainText.replace(/&/g, '&');
plainText = plainText.replace(/\xa0/g, ' ');
// select using backwards built-in find
if ( (typeof(wikEd.frameWindow.find) == 'function') && (plainText.length > 0) ) {
obj.sel.collapseToEnd();
// Chrome; parameters: wikEd.Find(obj, findText, caseSensitive, backwards, wrap, useRegExp)
var found = wikEd.Find(obj, plainText, true, true, false, false);
// Firefox (removes \n
if
}
// reinstate original range if it starts or ends with \n or spaces
if (/^(\n| )|(\n| )$/.test(plainText) == true) {
wikEd.RemoveAllRanges(obj.sel);
obj.sel.addRange(range);
}
}
// select empty range using backwards built-in find for previous character
else if ( (typeof(wikEd.frameWindow.find) == 'function') && (plainText.length == 0) ) {
var backwards = true;
// get plain text from start to selection
var rangeClone = range.cloneRange();
rangeClone.setStartBefore(wikEd.frameBody.firstChild);
Line 8,094 ⟶ 8,276:
plainText = plainText.replace(/^([\s\S]*?)([^\n]\n*)$/, '$2');
// get plain text from selection to end for potentially less newlines
if (plainText.length > 1) {
var plainTextBack = plainText;
Line 8,109 ⟶ 8,291:
plainText = plainText.replace(/^(\n*[^\n])([\s\S]*?)$/, '$1');
// backward or forward find
if (plainTextBack.length > plainText.length) {
backwards = false;
Line 8,118 ⟶ 8,300:
}
// Chrome; parameters: wikEd.Find(obj, findText, caseSensitive, backwards, wrap, useRegExp)
var found = wikEd.Find(obj, plainText, true, backwards, false, false);
// Firefox
if ( (found == false) && (/\n/.test(plainText) == true) ) {
plainText = plainText.replace(/\n/g, '');
Line 8,135 ⟶ 8,317:
}
// use inserted spans as scroll marker, breaks undo history in Chrome and Opera
else {
var rangeStart = range.cloneRange();
var rangeEnd = range.cloneRange();
// spans to be temporarily inserted before and after selection range to get range position
wikEd.insertCounter ++;
var scrollStartNode = wikEd.frameDocument.createElement('span');
Line 8,149 ⟶ 8,331:
scrollEndNode.id = 'wikEdScrollAfter' + wikEd.insertCounter;
// get the range border nodes and offsets
var startNode = range.startContainer;
var startOffset = range.startOffset;
Line 8,164 ⟶ 8,346:
}
// insert end node
if (endNode.nodeName == '#text') {
if (endOffset == 0) {
Line 8,182 ⟶ 8,364:
}
// insert start node
if (startNode.nodeName == '#text') {
if (startOffset == 0) {
Line 8,192 ⟶ 8,374:
else {
// collapse as a Firefox bug work around; http://stackoverflow.com/questions/665676
rangeStart.collapse(true);
rangeStart.insertNode(scrollStartNode);
Line 8,204 ⟶ 8,386:
wikEd.ScrollToNodes(scrollStartNode, scrollEndNode);
// set selection
range.setStartBefore(scrollStartNode);
range.setEndAfter(scrollEndNode);
Line 8,221 ⟶ 8,403:
wikEd.ScrollToNodes = function(scrollStartNode, scrollEndNode) {
// absolute span for line height detection (Opera and Chrome do not vertically align empty span at bottom)
var lineHeightNode = wikEd.frameDocument.createElement('span');
lineHeightNode.innerHTML = ' ';
Line 8,230 ⟶ 8,412:
scrollEndNode.removeChild(lineHeightNode);
// scroll to node coordinates
scrollStartNode.style.verticalAlign = 'top';
scrollEndNode.style.verticalAlign = 'top';
Line 8,244 ⟶ 8,426:
var y = frameScrollTop;
// current scroll position
// selection above viewport
if (endOffsetBottom < frameScrollTop) {
y = startOffsetTop;
}
// selection below viewport
else if (startOffsetTop > frameScrollTop + wikEd.frameBody.clientHeight) {
y = endOffsetBottom - wikEd.frameBody.clientHeight + lineHeight;
}
// selection left of viewport
if (endOffsetRight < frameScrollLeft) {
if (endOffsetRight <= wikEd.frameBody.clientWidth) {
Line 8,266 ⟶ 8,448:
}
// selection right of viewport
else if (startOffsetLeft > frameScrollLeft + wikEd.frameBody.clientWidth) {
x = endOffsetRight - wikEd.frameBody.clientWidth;
}
// do scroll
wikEd.frameWindow.scrollTo(x, y);
Line 8,284 ⟶ 8,466:
wikEd.WikiTableToHtml = function(obj) {
////
return;
};
Line 8,295 ⟶ 8,477:
wikEd.Textify = function(obj) {
// convert html to plain
obj.plain = obj.html;
obj.plain = obj.plain.replace(/ \n|\n /g, ' ');
obj.plain = obj.plain.replace(/\n/g, ' ');
// delete content tags
obj.plain = obj.plain.replace(/<(style|script|object|applet|embed)\b[^>]*>.*?<\/\1>/g, '');
// newlines
obj.plain = obj.plain.replace(/[\n ]*<br\b[^>]*>[\n ]*()/g, '\n');
// <div>...</div> to <br> for Safari, Chrome, WebKit
if ( (wikEd.safari == true) || (wikEd.chrome == true) || (wikEd.webkit == true) ) {
var isRemove = [];
Line 8,333 ⟶ 8,515:
}
// remove empty lines from block tags
obj.plain = obj.plain.replace(/(<(blockquote|center|div|p|pre|gallery)\b[^>]*>)[\s\x00]+/gi, '$1');
obj.plain = obj.plain.replace(/[\s\x00]+(<\/(blockquote|center|div|p|pre|gallery|source|poem|categorytree|hiero|imagemap|inputbox|timeline|references)>)/gi, '$1');
// remove highlighting pre tags
var isRemove = [];
obj.plain = obj.plain.replace(/(<(\/?)pre\b([^>]*)>)/g,
Line 8,356 ⟶ 8,538:
);
// blocks
obj.plain = obj.plain.replace(/<\/?(address|blockquote|center|div|hr|isindex|p|pre)\b.*?>/g, '\x00\x00');
// keep headings only if starting with a newline
obj.plain = obj.plain.replace(/[\s|\x00]*(^|\n|\x00)[\s|\x00]*<h[1-6]\b[^>]*>(.*?)<\/h[1-6]>[\s|\x00]*()/g, '\x00\x00$2\x00\x00');
// lists
obj.plain = obj.plain.replace(/<\/?(dir|dl|menu|ol|ul)\b.*?>/g, '\x00');
obj.plain = obj.plain.replace(/<\/(dd|dt|li)>/g, '\x00');
// forms
obj.plain = obj.plain.replace(/<\/?(select|textarea)\b.*?>/g, '\x00');
obj.plain = obj.plain.replace(/<\/(option|legend|optgroup)>/g, '\x00');
// tables
if (wikEd.tableMode == true) {
// override pasted table class // {{TABLE}}
obj.plain = obj.plain.replace(/(<table\b)([^>]*)(>)/gi,
function (p, p1, p2, p3) {
Line 8,386 ⟶ 8,568:
);
// keep table html markup // {{TABLE}}
obj.plain = obj.plain.replace(/[\s\x00]*(<table\b.*?>)/g, '\x00\x00$1');
obj.plain = obj.plain.replace(/(<\/table>)[\s\x00]*()/g, '$1\x00');
Line 8,393 ⟶ 8,575:
}
// textify table
else if (wikEd.tableMode == false) {
obj.plain = obj.plain.replace(/<\/?(table|caption)\b.*?>/g, '\x00');
Line 8,399 ⟶ 8,581:
}
// finish html to plain conversion
obj.plain = obj.plain.replace(/<.*?>/g, '');
// recover table html
obj.plain = obj.plain.replace(/\x01/g, '<');
obj.plain = obj.plain.replace(/\x02/g, '>');
// remove spaces
obj.plain = obj.plain.replace(/[ \t\xa0]+(\x00)/g, '$1');
obj.plain = obj.plain.replace(/(\x00)[ \t\xa0]+/g, '$1');
// trim down \x00 and \n
obj.plain = obj.plain.replace(/\x00+\n/g, '\n');
obj.plain = obj.plain.replace(/\n\x00+/g, '\n');
Line 8,417 ⟶ 8,599:
obj.plain = obj.plain.replace(/(<\/table>\n)\n+/g, '$1');
// remove empty lines and spaces from article start and end
if (obj.from == 'whole') {
obj.plain = obj.plain.replace(/^\s+|\s+$/g, '');
Line 8,432 ⟶ 8,614:
wikEd.InactiveButtons = function() {
// undo
if (wikEd.frameDocument.queryCommandEnabled('undo') == true ) {
document.getElementById('wikEdUndo').className = 'wikEdButton';
Line 8,442 ⟶ 8,624:
}
// redo
if (wikEd.frameDocument.queryCommandEnabled('redo') == true ) {
document.getElementById('wikEdRedo').className = 'wikEdButton';
Line 8,450 ⟶ 8,632:
}
// redo all
if (wikEd.lastVersion != null) {
document.getElementById('wikEdRedoAll').className = 'wikEdButton';
Line 8,469 ⟶ 8,651:
wikEd.FixBasic = function(obj) {
// non-breaking space character to normal space
obj.plain = obj.plain.replace(/\xa0/g, ' ');
// tab to space
obj.plain = obj.plain.replace(/ *\t[ \t]*()/g, ' ');
// remove trailing spaces
obj.plain = obj.plain.replace(/(\t| | )+\n/g, '\n');
// remove spaces in empty lines
obj.plain = obj.plain.replace(/\n( | |\t)+\n/g, '\n\n');
// empty line before and after headings, spaces around word (lookahead), remove bold, italics, and extra =
obj.plain = obj.plain.replace(/(^|\n)+(=+) *(.*?) *(=+)(?=(\n|$))/g,
function(p, p1, p2, p3, p4) {
Line 8,489 ⟶ 8,671:
);
// uppercase well known headings
var regExp = new RegExp('\\n=+ ' + wikEd.config.text['External links'] + '? =+\\n', 'gi');
obj.plain = obj.plain.replace(regExp, '\n== ' + wikEd.config.text['External links'] + ' ==\n');
Line 8,497 ⟶ 8,679:
obj.plain = obj.plain.replace(regExp, '\n== ' + wikEd.config.text.References + ' ==\n');
// add space after * # : ; (list) and after {| |- |+ | (table), spare #REDIRECT
obj.plain = obj.plain.replace(/(^|\n)([\*\#\:\;]+|\{\||\|\-|\|\+|\|(?!\})) *()/g, '$1$2 ');
obj.plain = obj.plain.replace(/(^|\n)# REDIRECT\b/gi, '$1#REDIRECT');
obj.plain = obj.plain.replace(/ +(?=\n)/g, '');
// empty line before and after tables
obj.plain = obj.plain.replace(/\n+(\{\|)/g, '\n\n$1');
obj.plain = obj.plain.replace(/(\n\|\}([^\}]|$)) *(.*)[\n|$]+/g, '$1\n\n$3\n\n');
// empty line before and after lists
obj.plain = obj.plain.replace(/(^|\n)([^\*\#\:\;\n].*)(?=\n[\*\#\:\;])/g, '$1$2\n\n');
obj.plain = obj.plain.replace(/(^|\n)([\*\#\:\;].*?)(?=\n[^\*\#\:\;\n])/g, '$1$2\n\n');
// split into lines and change single lines, used to handle tables
var lines = obj.plain.split('\n');
obj.plain = '';
Line 8,518 ⟶ 8,700:
var line = lines[i];
// do not change lines starting with a blank
if (/^ /.test(line) == false) {
// detect table
if (line.match(/^(\{\||\!|\|[^}])/) != null) {
tableflag = true;
Line 8,529 ⟶ 8,711:
}
// changes only to be done in tables
if (tableflag == true) {
// add spaces around ||
line = line.replace(/ *\|\| *()/g, ' || ');
}
// changes not to be done in tables
if (! tableflag) {
// empty line before and after images
var regExp = new RegExp('^(\\[\\[(Image|File|' + wikEd.config.text['wikicode Image'] + '|' + wikEd.config.text['wikicode File'] + '):.*?\\]\\])', 'ig');
line = line.replace(regExp, '\n$1');
Line 8,546 ⟶ 8,728:
line = line.replace(regExp, '$1\n');
// empty line before and after includes
line = line.replace(/^(\{\{.*?\}\})/g, '\n$1');
line = line.replace(/(\{\{.*?\}\})$/g, '$1\n');
Line 8,552 ⟶ 8,734:
}
// concatenate the lines
obj.plain += line;
if (i < lines.length - 1) {
Line 8,559 ⟶ 8,741:
}
// remove underscores in wikilinks
obj.plain = obj.plain.replace(/\[\[(.*?)((\|.*?)|)\]\]/g,
function (p, p1, p2, p3) {
Line 8,567 ⟶ 8,749:
);
// remove spaces in wikilinks, protect [[xxx| ]]
obj.plain = obj.plain.replace(/\[\[ *([^\|\[\]]*?) *\| +\]\]/g, '[[$1|\x00]]');
obj.plain = obj.plain.replace(/\[\[ *([^\|\[\]]*?) *\| *([^\[\][]*?) *\]\]/g, '[[$1|$2]]');
Line 8,573 ⟶ 8,755:
obj.plain = obj.plain.replace(/\x00/g, ' ');
// remove spaces in external links
obj.plain = obj.plain.replace(/\[ *(.*?) *\](?!\])/g, '[$1]');
// no space around pipes before curly brackets
obj.plain = obj.plain.replace(/ +\| +\}\}/g, '|}}');
// no empty line between headings and includes
obj.plain = obj.plain.replace(/\n(=+ .*? =+\n)\n+(\{\{.*?\}\})/g, '\n$1$2');
// spaces in comments
obj.plain = obj.plain.replace(/(<!--) *(.*?) *(-->)/g, '$1 $2 $3');
// empty line before and after categories
var regExp = new RegExp('( |\\n)*(\\[\\[(Category|' + wikEd.config.text['wikicode Category'] + ')\\s*:[^\\n]*?\\]\\])( |\\n)*', 'gi');
obj.plain = obj.plain.replace(regExp, '\n\n$2\n\n');
// categories not separated by empty lines (lookahead)
regExp = new RegExp('(\\[\\[(Category|' + wikEd.config.text['wikicode Category'] + ')\\s*:[^\\n]*?\\]\\])\\n*(?=\\[\\[(Category|' + wikEd.config.text['wikicode Category'] + ')\\s*:[^\\n]*?\\]\\])', 'gi');
obj.plain = obj.plain.replace(regExp, '$1\n');
// single empty lines only
obj.plain = obj.plain.replace(/\n{3,}/g, '\n\n');
// remove leading and trailing newlines
obj.plain = obj.plain.replace(/^\n+/, '');
obj.plain = obj.plain.replace(/\n{2,}$/, '\n');
Line 8,612 ⟶ 8,794:
wikEd.FixBasic(obj);
// protect punctuation in charents
obj.plain = obj.plain.replace(/(&([a-zA-Z0-9]{2,10}|#[0-9]{2,7}))(;)/g, '$1\x00$3');
// protect punctuation in URLs
var regExp = new RegExp('(\\b(http://|https://|ftp://|irc://|gopher://|news:|mailto:|file://)[!#%&()+,\\-./:;=?@~' + wikEd.letters + '_]*)', 'g');
obj.plain = obj.plain.replace(regExp,
Line 8,624 ⟶ 8,806:
);
// protect punctuation in filenames
regExp = new RegExp('([' + wikEd.letters + '_\\-])([.,:;?!])(?=([a-zA-Z]{2,4})([\\s:;?!.,()\\[\\]{}|]|$))', 'g');
obj.plain = obj.plain.replace(regExp, '$1\x00$2');
// protect punctuation in article names
obj.plain = obj.plain.replace(/(\[\[|\{\{)([^\]}|\n]*)/g,
function(p, p1, p2) {
Line 8,639 ⟶ 8,821:
obj.plain = obj.plain.replace(/(«) *()/g, '$1 ');
obj.plain = obj.plain.replace(/ *(»)/g, ' $1');
regExp = new RegExp('([' + wikEd.letters + '_\'"”\\]})]) *([.,])(?=(['+ wikEd.letters + '\'"”\\[{(\\s]|$))', 'g');
obj.plain = obj.plain.replace(regExp, '$1$2 ');
regExp = new RegExp('([' + wikEd.letters + '\'"”\\]})]) *([:;?!])', 'g');
obj.plain = obj.plain.replace(regExp, '$1 $2 ');
Line 8,666 ⟶ 8,847:
wikEd.FixUnicode = function(obj) {
obj.plain = obj.plain.replace(/&#0*160;|&#x0*a0;/gi, '&nbsp;');
obj.plain = obj.plain.replace(/&#0*32;|&#x0*20;/gi, ' ');
// replace supported chars: change decimal, hex, and character entities into actual char
for (var i = 0; i < wikEd.supportedChars.length; i ++) {
var replaceChar = String.fromCharCode(parseInt(wikEd.supportedChars[i][0], 16));
// decimal representation
var regExpStr = '&#0*' + parseInt(wikEd.supportedChars[i][0], 16) + ';|';
// hex representation
regExpStr += '&#x0*' + wikEd.supportedChars[i][0] + ';';
// case insensitive replace
var regExp = new RegExp(regExpStr, 'gi');
obj.plain = obj.plain.replace(regExp, replaceChar);
// character entity representation
regExpStr = '&' + wikEd.supportedChars[i][1] + ';';
// case sensitive replace
var regExp = new RegExp(regExpStr, 'g');
obj.plain = obj.plain.replace(regExp, replaceChar);
}
// replace unsupported chars in IE6: change decimal, hex, and chars into character entities
for (var i = 0; i < wikEd.problemChars.length; i ++) {
var replaceChar = '&' + wikEd.problemChars[i][1] + ';';
// decimal representation
var regExpStr = '&#0*' + parseInt(wikEd.problemChars[i][0], 16) + ';|';
// hex representation
regExpStr += '&#x0*' + wikEd.problemChars[i][0] + ';';
// case insensitive replace
var regExp = new RegExp(regExpStr, 'gi');
obj.plain = obj.plain.replace(regExp, replaceChar);
// actual character representation
regExpStr = '\\u' + wikEd.problemChars[i][0];
// case sensitive replace
var regExp = new RegExp(regExpStr, 'g');
obj.plain = obj.plain.replace(regExp, replaceChar);
}
// replace special chars (spaces and invisible characters): change decimal, hex, and chars into character entities
for (var i = 0; i < wikEd.specialChars.length; i ++) {
var replaceChar = '&' + wikEd.specialChars[i][1] + ';';
// decimal representation
var regExpStr = '&#0*' + parseInt(wikEd.specialChars[i][0], 16) + ';|';
// hex representation
regExpStr += '&#x0*' + wikEd.specialChars[i][0] + ';';
// case insensitive replace
var regExp = new RegExp(regExpStr, 'gi');
obj.plain = obj.plain.replace(regExp, replaceChar);
// actual character representation
regExpStr = '\\u' + wikEd.specialChars[i][0];
// case sensitive replace
var regExp = new RegExp(regExpStr, 'g');
obj.plain = obj.plain.replace(regExp, replaceChar);
}
// unicode line separator and paragraph separator
obj.plain = obj.plain.replace(/\u2028/g, '\n');
obj.plain = obj.plain.replace(/\u2029/g, '\n\n');
Line 8,746 ⟶ 8,930:
wikEd.FixRedirectCall = function(obj) {
// check if api is enabled
if ( ( (wikEd.wikiGlobals.wgEnableAPI != true) && (wikEd.wikiGlobals.wgEnableAPI != 'true') ) || (wikEd.scriptURL == '') ) {
return;
}
// reset redirects object
wikEd.redirectsCache = {};
// get wiki links
var links = '';
//
var regExpLink = /(\[\[\s*(:?)\s*([^\n#<>\[\]{}|]+)(\s*#[^\n\[\]\|]*?)?(\s*\|(.|\s)*?)?\]\]\s*)/g;
while ( (regExpMatch = regExpLink.exec(obj.plain)) != null) {
Line 8,766 ⟶ 8,950:
}
// prepare the request
var postFields = {};
postFields['titles'] = links;
Line 8,787 ⟶ 8,971:
var requestUrl = wikEd.scriptURL + 'api.php';
// make the ajax request
wikEd.AjaxRequest('POST', requestUrl, postFields, 'text/plain', function(ajax) {
// get response
var txt = ajax.responseText;
if ( (regExpMatch = txt.match(/<redirects>((.|\s)*?)<\/redirects>/)) != null) {
Line 8,799 ⟶ 8,983:
}
// parse redirects
var i = 0;
wikEd.redirectsCache.from = [];
Line 8,813 ⟶ 8,997:
}
// recurse through chained normalizations and redirects
wikEd.redirectsCache.toIndex = [];
for (var i = 0; i < wikEd.redirectsCache.to.length; i ++) {
Line 8,821 ⟶ 9,005:
}
// replace links
wikEd.EditButton(null, 'wikEdFixRedirectReplace');
return;
});
// end Ajax handler
return;
Line 8,856 ⟶ 9,040:
}
// cycle through parsed redirects
if (wikEd.redirectsCache.from != null) {
for (var i = 0; i < wikEd.redirectsCache.from.length; i ++) {
//
var regExp = new RegExp('\\[\\[\\s*(:?)\\s*(' + wikEd.redirectsCache.from[i] + ')(\\s*#[^\\n\\[\\]|]*?)?(\\s*\\|((.|\\s)*?))?\\s*\\]\\]', 'g');
obj.plain = obj.plain.replace(regExp,
Line 8,870 ⟶ 9,054:
var linkText = p5 || '';
// use normalized target
var linkTarget = redirect;
// lowercase link target if link text starts with lowercase (main space only)
if (wikEd.config.articlesCaseSensitive == false) {
if (/:/.test(linkTarget) != true) {
Line 8,882 ⟶ 9,066:
}
// remove text if identical to new target
if (linkText != '') {
if ( linkText.replace(/_/g, ' ') == linkTarget ) {
Line 8,889 ⟶ 9,073:
}
// keep replaced link as link text
else if (linkText == '') {
if (linkTarget != article) {
Line 8,896 ⟶ 9,080:
}
// return fixed link
var wikiLink;
if (linkText == '') {
Line 8,921 ⟶ 9,105:
wikEd.FixBasic(obj);
// change only outside <math> </math> wikicode
obj.plain = obj.plain.replace(/(.*?)((<math(\b.*?)>.*?<\/math>)|$)/gi,
function (p, p1, p2) {
// convert html entities into actual dash characters
p1 = p1.replace(/+/g, '+');
p1 = p1.replace(/−/g, '\u2212');
p1 = p1.replace(/·/g, '·');
// convert dash next to a number into a minus sign character
var regExp = new RegExp('([^' + wikEd.letters + '_,{])-(\\d)', 'g');
p1 = p1.replace(regExp, '$1\u2212$2');
// changes 2x3 to 2×3
p1 = p1.replace(/(\d *)x( *\d)/g, '$1\xd7$2');
// changes 10^3 to 10<sup>3</sup>
p1 = p1.replace(/(\d*\.?\d+)\^(\u2212?\d+\.?\d*)/g, '$1<sup>$2</sup>');
// change x^3 to x<sup>3</sup>
var regExp = new RegExp('([' + wikEd.letters + '_])\\^(\\u2212?\\d+\\.?\\d*) ', 'g');
p1 = p1.replace(regExp, '$1<sup>$2</sup>');
// change +/- to ±
p1 = p1.replace(/( |\d)\+\/(-|\u2212)( |\d)/g, '$1\xb1$3');
// htmlize single char superscripts
p1 = p1.replace(/(\xb9|¹)/g, '<sup>1</sup>');
p1 = p1.replace(/(\xb2|²)/g, '<sup>2</sup>');
Line 8,970 ⟶ 9,154:
var pseudoElements = '|Me|Et|Pr|Bu|e';
// fix common typos
obj.plain = obj.plain.replace(/\bh2o\b/g, 'H2O');
obj.plain = obj.plain.replace(/\bh3o+/g, 'H3O+');
obj.plain = obj.plain.replace(/\boh-/g, 'OH-');
// uppercase lowercased elements
var regExp = new RegExp('(^|[^a-zA-Z])(' + realElements.toLowerCase() + pseudoElements.toLowerCase() + ')([^a-zA-Z]|$)', 'g');
obj.plain = obj.plain.replace(regExp,
Line 8,986 ⟶ 9,170:
);
// fix superscripts
obj.plain = obj.plain.replace(/+/g, '+');
obj.plain = obj.plain.replace(/−/g, '\u2212');
Line 8,998 ⟶ 9,182:
);
// fix indices
regExp = new RegExp('(' + realElements + pseudoElements + '|\\))(\\d+)', 'g');
obj.plain = obj.plain.replace(regExp, '$1<sub>$2</sub>');
// fix prefixes
regExp = new RegExp('(\\d+) *(\\(|' + realElements + pseudoElements + ')', 'g');
obj.plain = obj.plain.replace(regExp, '$1$2');
// fix arrows
obj.plain = obj.plain.replace(/ *-+> *()/g, ' \u2192 ');
obj.plain = obj.plain.replace(/ *<-+ *()/g, ' \u2190 ');
// &hdarr; and "leftwards harpoon over rightwards harpoon" not supported in IE6
// obj.plain = obj.plain.replace(/ *(<=+>|&hdarr;|↔|\u2190 *\u2192) *()/g, ' \u21cc ');
obj.plain = obj.plain.replace(/ *(<==+>|&hdarr;|↔|\u21cc|\u2190 *\u2192) *()/g, ' <=> ');
// fix -
var regExp = new RegExp('([' + wikEd.letters + '_]|\\)|>) +(-|\\u2212) +([' + wikEd.letters + '_]|\\()', 'g');
obj.plain = obj.plain.replace(regExp, '$1 \u2212 $3');
Line 9,030 ⟶ 9,214:
wikEd.FixBasic(obj);
// convert into actual characters
obj.plain = obj.plain.replace(/&deg;|&#00b0;/g, '°');
obj.plain = obj.plain.replace(/&#00b5;|&mu;|&micro;/g, 'µ');
obj.plain = obj.plain.replace(/&Omega;|&#8486;/g, '\u03a9');
// add space before units, remove space around /, and use abreviations
var regExp = new RegExp('( */ *|\\d *)(Y|yotta|Z|zetta|E|exa|P|peta|T|tera|G|giga|M|mega|k|kilo|K|h|hecto|da|deca|d|deci|c|centi|m|mill?i|micro|u|µ|n|nano|p|pico|f|femto|a|atto|z|zepto|y|yocto|mibi|mebi|)(gramm?s?|g|metres?|meters?|m|amperes?|Amperes?|amps?|Amps?|A|Angstroms?|Angströms?|Å|Kelvins?|kelvins?|K|moles?|Moles?|mol|candelas?|cd|rad|Ci|sr|Hert?z|hert?z|Hz|newtons?|Newtons?|N|Joules?|joules?|J|watts?|Watts?|W|pascals?|Pascals?|Pa|lm|lx|C|volts?|Volts?|V|O|Farads?|F|Wb|T|H|S|bequerels?|Bequerels?|Bq|Gy|Sv|kat|centigrades?|°C|decibels?|db|dB|M|ohms?|Ohms?|\\u03a9|sec|seconds?|s|minutes?|min|hour?|h|bits?|Bits?|bit|bytes?|Bytes?|B|bps|Bps)(?=[^' + wikEd.letters + '_]|$)', 'g');
obj.plain = obj.plain.replace(regExp,
Line 9,095 ⟶ 9,279:
);
// fix prefix casing
var regExp = new RegExp(' K(bit/s|B/s)([^' + wikEd.letters + '_]|$)', 'g');
obj.plain = obj.plain.replace(regExp, ' k$1$2');
Line 9,101 ⟶ 9,285:
var regExp = new RegExp(' m(bit/s|B/s)([^' + wikEd.letters + '_]|$)', 'g');
obj.plain = obj.plain.replace(regExp, ' M$1$2');
var regExp = new RegExp(' g(bit/s|B/s)([^' + wikEd.letters + '_]|$)', 'g');
obj.plain = obj.plain.replace(regExp, ' G$1$2');
Line 9,123 ⟶ 9,307:
wikEd.FixBasic(obj);
// convert html character entities into actual dash characters
obj.plain = obj.plain.replace(/&mdash;/g, '—');
obj.plain = obj.plain.replace(/&ndash;/g, '–');
obj.plain = obj.plain.replace(/&minus;/g, '\u2212');
// remove spaces around em dashes
var regExp = new RegExp('([' + wikEd.letters + '\'"”\\]})])( |&nbsp;)*—( |&nbsp;)*([' + wikEd.letters + '\'"“\\[{(])', 'g');
obj.plain = obj.plain.replace(regExp, '$1—$4');
// convert -- to em dashes
var regExp = new RegExp('([' + wikEd.letters + '\'"”\\]})])( |&nbsp;)*--( |&nbsp;)*([' + wikEd.letters + '\'"“\\[{(])', 'g');
obj.plain = obj.plain.replace(regExp, '$1—$4');
// convert hyphen next to lone number into a minus sign character
var regExp = new RegExp('([' + wikEd.letters + '\'"”\\]>] ) *(\\u2212|–)(\\d)', 'g');
obj.plain = obj.plain.replace(regExp, '$1\u2212$3');
// convert minus or en dashes to dashes with spaces
var regExp = new RegExp('([' + wikEd.letters + '\'"”\\]}])( |&nbsp;)*(\\u2212|–)( |&nbsp;)*([' + wikEd.letters + '\'"“\\[{])', 'g');
obj.plain = obj.plain.replace(regExp, '$1 – $5');
// convert dashes to en dashes in dates
obj.plain = obj.plain.replace(/(^|[ \(\|])(\d\d(\d\d)?)(\u2212|-|–)(\d\d)(\u2212|-|–)(\d\d(\d\d)?)([ \)\}\|,.;—]|$)/gm, '$1$2–$5–$7$9');
Line 9,159 ⟶ 9,343:
wikEd.FixBasic(obj);
// remove syntax highlighting
obj.html = obj.plain;
obj.html = obj.html.replace(/\n/g, '<br>');
wikEd.RemoveHighlighting(obj);
// keep <br> in blockquote
obj.html = obj.html.replace(/(<blockquote\b.*?>)([\S\s]*?)(<\/blockquote>)/gi,
function (p, p1, p2, p3) {
Line 9,172 ⟶ 9,356:
);
// keep <br> in tables (and certain templates!?)
obj.html = obj.html.replace(/(<br\b[^>]*>\|)([^\}][\S\s]*?)(?=<br\b[^>]*>\|)/gi,
function (p, p1, p2) {
Line 9,180 ⟶ 9,364:
);
// detect outermost template tags
var depth = 0;
obj.html = obj.html.replace(/((\{\{)|\}\})/g,
Line 9,200 ⟶ 9,384:
);
// keep <br> in templates
obj.html = obj.html.replace(/<!--wikEdOuterTemplateStart-->([\S\s]*?)<!--wikEdOuterTemplateEnd-->/g,
function (p, p1) {
Line 9,207 ⟶ 9,391:
);
// detect outermost table tags
var depth = 0;
obj.html = obj.html.replace(/(((^|<br\b[^>]*>)\{\|)|<br\b[^>]*>\|\})/g,
Line 9,226 ⟶ 9,410:
);
// keep <br> in tables
obj.html = obj.html.replace(/<!--wikEdOuterTableStart-->([\S\s]*?)<!--wikEdOuterTableEnd-->/g,
function (p, p1) {
Line 9,233 ⟶ 9,417:
);
// turn visible html code into real html, exclude comments
obj.html = obj.html.replace(/<(\/?\w.*?)>/g, '<$1>');
// restore valid <br>s
obj.html = obj.html.replace(/\x00(.*?)\x01/g, '<$1>');
// wikify, keep user added attribute
wikEd.WikifyHTML(obj, true);
// turn real html into visible html code
obj.html = obj.html.replace(/<br\b[^>]*>[\n ]*()/g, '\n');
obj.html = obj.html.replace(/</g, '<');
Line 9,260 ⟶ 9,444:
wikEd.FixBasic(obj);
// uppercase lists
// start (listcode (char-ent|tag|category..|digit|non-word,non-ret))(word,non-digit..) end
var regExp = new RegExp('^((\\||[*#:;]+)[ \'"]*(\'+|&\\w+;|<.*?>|\\{\\{.*?\\}\\}.*|\\d|[^' + wikEd.letters + '_\\n])*)([^' + wikEd.letters + '_\\d\\n].*?)?$', 'gm');
obj.plain = obj.plain.replace(regExp,
Line 9,267 ⟶ 9,451:
if (p4.match(/^(http|ftp|alpha|beta|gamma|delta|epsilon|kappa|lambda|$)/) == null) {
// spaces cannot be added to p1 in above regExp !?
p4 = p4.replace(/^(\s*)(.*?)$/,
function (p, p1, p2) {
Line 9,279 ⟶ 9,463:
);
// uppercase link lists (link)
// 12table
obj.plain = obj.plain.replace(/^((\||[*#:;]+)[ '"]*\[\[)(.*?)(\]\])/gm,
function (p, p1, p2, p3, p4) {
// uppercase link
var regExp = new RegExp('^((&\\w+;|[^' + wikEd.letters + '_]|\\d)*)([' + wikEd.letters + '_].*)$', '');
p3 = p3.replace(regExp,
Line 9,295 ⟶ 9,479:
);
// uppercase comment
var regExp = new RegExp('(\\| *(&\\w+;|<.*?>|[^' + wikEd.letters + '_][^|]*)$', '');
p3 = p3.replace(regExp,
Line 9,309 ⟶ 9,493:
);
// uppercase headings
var regExp = new RegExp('^(=+ (&\\w+\\;|<.*?>|\\d|[^' + wikEd.letters + '_\\n])*)([' + wikEd.letters + '_].*? =+)$', 'gm');
obj.plain = obj.plain.replace(regExp,
Line 9,320 ⟶ 9,504:
);
// uppercase images
var regExp = new RegExp('(\\[\\[)(Image|File|' + wikEd.config.text['wikicode Image'] + '|' + wikEd.config.text['wikicode File'] + '):([' + wikEd.letters + '_])([^\\n]*\\]\\])', 'igm');
obj.plain = obj.plain.replace(regExp,
Line 9,342 ⟶ 9,526:
wikEd.FixBasic(obj);
// split into alternating plain text and {{lang}} template fragments (does not support nested templates)
var fragment = [];
var nextPos = 0;
Line 9,353 ⟶ 9,537:
fragment.push(obj.plain.substring(nextPos));
// cycle through the RegExTypoFix rules
for (var i = 0; i < wikEd.typoRulesFind.length; i ++) {
// cycle through the fragments, jump over {{lang}} templates
for (var j = 0; j < fragment.length; j = j + 2) {
fragment[j] = fragment[j].replace(wikEd.typoRulesFind[i], wikEd.typoRulesReplace[i]);
Line 9,362 ⟶ 9,546:
}
// re-assemble text
obj.plain = fragment.join('');
Line 9,388 ⟶ 9,572:
wikEd.RemoveElements = function(tagNameArray) {
// cycle through the element names
for (var i = 0; i < tagNameArray.length; i ++) {
var elementArray = wikEd.frameDocument.getElementsByTagName(tagNameArray[i]);
Line 9,405 ⟶ 9,589:
wikEd.FindBoundaries = function(word, line, para, whole, selection) {
// get the start node and offset
var startNode = selection.range.startContainer;
var startOffset = selection.range.startOffset;
// get the end node and offset
var endNode = selection.range.endContainer;
var endOffset = selection.range.endOffset;
Line 9,426 ⟶ 9,610:
}
// find the start and end nodes in the whole plain text arrays
var startNodeIndex;
var endNodeIndex;
Line 9,439 ⟶ 9,623:
}
// find last previous word and line boundary
var foundWord = false;
var foundLine = false;
Line 9,446 ⟶ 9,630:
var plainPrev = '';
// check text nodes left-wise for a boundary
var plain = '';
for (var i = startNodeIndex; i >= 0; i --) {
Line 9,455 ⟶ 9,639:
plain = plain.replace(/&/g, '&');
// boundary is a new paragraph
if ( (plainPrev == '\n') && (plain == '\n') ) {
para.range.setStartAfter(whole.plainNode[i + 1]);
Line 9,462 ⟶ 9,646:
}
// boundary is a newline
else if (plain == '\n') {
if (foundWord == false) {
Line 9,474 ⟶ 9,658:
}
// check text node for a word boundary
else if (foundWord == false) {
if (i == startNodeIndex) {
Line 9,487 ⟶ 9,671:
}
// boundary is start of text
if (foundPara == false) {
para.range.setStartBefore(whole.plainNode[0]);
Line 9,498 ⟶ 9,682:
}
// find next word and line boundary
regExp = new RegExp('[^' + wikEd.letters + '_]', 'g');
foundWord = false;
Line 9,504 ⟶ 9,688:
foundPara = false;
// check text nodes right-wise for a boundary
plain = '';
for (var i = endNodeIndex; i < whole.plainArray.length; i ++) {
Line 9,513 ⟶ 9,697:
plain = plain.replace(/&/g, '&');
// boundary is a double newline
if ( (plainPrev == '\n') && (plain == '\n') ) {
para.range.setEndBefore(whole.plainNode[i]);
Line 9,520 ⟶ 9,704:
}
// boundary is a newline
else if (plain == '\n') {
if (foundWord == false) {
Line 9,532 ⟶ 9,716:
}
// check text node for a word boundary
else if (foundWord == false) {
if (i == endNodeIndex) {
Line 9,548 ⟶ 9,732:
}
// boundary is end of text
if (foundPara == false) {
para.range.setEndAfter(whole.plainNode[whole.plainArray.length - 1]);
Line 9,571 ⟶ 9,755:
if ( (obj.html != '') || (wikify == true) ) {
// <div>...</div> to <br> for Safari, Chrome, WebKit
if ( (wikEd.safari == true) || (wikEd.chrome == true) || (wikEd.webkit == true) ) {
var isRemove = [];
Line 9,598 ⟶ 9,782:
}
// remove syntax highlighting
wikEd.RemoveHighlighting(obj);
// wikify, don't allow many attributes
if ( (obj.htmlCode == true) && (wikify != false) ) {
wikEd.WikifyHTML(obj, false);
Line 9,639 ⟶ 9,823:
var regExpMatch;
// delete tags: <style>
obj.html = obj.html.replace(/<(style)\b[^>]*>.*?<\/\1>/gi, '');
// remove MediaWiki section edit spans
obj.html = obj.html.replace(/<span[^>]*class="editsection"[^>]*>.*?<\/span>\s*()/gi, '');
// remove MediaWiki heading spans
obj.html = obj.html.replace(/<span\b[^>]*\bclass="mw-headline"[^>]*>(.*?)<\/span>\s*()/g, '$1');
// remove MediaWiki divs from article top
obj.html = obj.html.replace(/<h3\b[^>]*\bid="siteSub"[^>]*>.*?<\/h3>\s*()/g, '');
obj.html = obj.html.replace(/<div\b[^>]*\bid="contentSub"[^>]*>.*?<\/div>\s*()/g, '');
obj.html = obj.html.replace(/<div\b[^>]*\bid="jump-to-nav"[^>]*>.*?<\/div>\s*()/g, '');
// remove MediaWiki table of contents
obj.html = obj.html.replace(/<table\b[^>]*?\bid="toc"[^>]*>.*?<\/table>\s*()/g, '');
// remove MediaWiki print footer
obj.html = obj.html.replace(/<div\b[^>]*?\bclass="printfooter"[^>]*>[^<>"]+"<a\b[^>]*>[^<]+<\/a>"<\/div>\s*()/g, '');
// remove MediaWiki category list tags
while(/<div\b[^>]*\bid="catlinks"[^>]*>(.*?)<\/div>\s*()/g.test(obj.html) == true) {
obj.html = obj.html.replace(regExp, '$1');
Line 9,667 ⟶ 9,851:
}
// convert MS-Word non-standard lists: *
obj.html = obj.html.replace(/\s*<p [^>]*>\s*<!--\[if !supportLists\]-->.*?<!--\[endif\]-->\s*(.*?)\s*<\/p>\s*()/g, '* $1\n');
// collect MS-Word footnote texts
var footnotes = {};
obj.html = obj.html.replace(/<div\b[^>]* id="ftn(\d+)"[^>]*>\s*<p class="MsoFootnoteText">\s*<a(.|\n)*?<\/a>((.|\n)*?)<\/p>\s*<\/div>/g,
Line 9,679 ⟶ 9,863:
);
// add footnotes as <ref> tags
obj.html = obj.html.replace(/<a\b[^>]* name="_ftnref(\d+)"[^>]*>(.|\n)*?<!--\[endif\]-->\s*<\/span>\s*<\/span>\s*<\/a>/g,
function(p, p1) {
Line 9,687 ⟶ 9,871:
);
// remove MS-Word footnote separator
obj.html = obj.html.replace(/<!--\[if !supportFootnotes\]-->(\s|<br\b[^>]*>)*<hr\b[^>]*>\s*<!--\[endif\]-->(\s|<br\b[^>]*>)*()/g, '');
// correct name for MS-Word images
//
obj.html = obj.html.replace(/(<v:imagedata\b[^>]*? src="[^">]*?[\\\/]clip_image\d+(\.\w+)"[^>]*? o:title="([^">]*)"[^>]*>(.|\s)*?<img\b[^>]*? src="[^">]*?[\\\/])clip_image\d+\.\w+("[^>]*>)/g, '$1$3$2$5');
// convert <div class="poem">...</div> to <poem>...</poem>
var isPoem = [];
obj.html = obj.html.replace(/(<(\/?)div\b([^>]*)>)/gi,
Line 9,713 ⟶ 9,897:
);
// sanitize <span> <div> <p>
obj.html = obj.html.replace(/<(span|div|p)\b *(.*?) *\/?>/gi,
function (p, p1, p2) {
Line 9,720 ⟶ 9,904:
);
// remove <span> ... </span> pairs withhout attributes
var isRemove = [];
obj.html = obj.html.replace(/(<(\/?)span\b([^>]*)>)/gi,
Line 9,739 ⟶ 9,923:
);
// remove <p> ... </p> pairs withhout attributes
var isRemove = [];
obj.html = obj.html.replace(/(<(\/?)p\b([^>]*)>)/gi,
Line 9,758 ⟶ 9,942:
);
// escape character entities
obj.html = obj.html.replace(/&(?!(amp;|lt;|gt;))/g, '&');
// remove comments
obj.html = obj.html.replace(/<!--.*?-->/g, '');
// <hr> horizontal rule
obj.html = obj.html.replace(/(\s|<br\b[^>]*>|\x00)*<hr\b[^>]*>(\s|<br\b[^>]*>|\x00)*()/gi, '\x00\x00----\x00\x00');
// <i> <em> <dfn> <var> <cite> italic
obj.html = obj.html.replace(/<(i|em|dfn|var|cite)\b.*?>/gi, '\'\'');
obj.html = obj.html.replace(/<\/(i|em|dfn|var|cite)\b.*?>/gi, '\'\'');
// <b> <strong> bold
obj.html = obj.html.replace(/<(b|strong)\b.*?>/gi, '\'\'\'');
obj.html = obj.html.replace(/<\/(b|strong)\b.*?>/gi, '\'\'\'');
// <h1> .. <h6> headings
obj.html = obj.html.replace(/(\s|<br\b[^>]*>|\x00)*(^|\n|<br\b[^>]*>|\x00)(\s|<br\b[^>]*>|\x00)*<h1\b[^>]*>(.*?)<\/h1>(\s|<br\b[^>]*>|\x00)*()/gi, '\x00\x00= $4 =\x00\x00');
obj.html = obj.html.replace(/(\s|<br\b[^>]*>|\x00)*(^|\n|<br\b[^>]*>|\x00)(\s|<br\b[^>]*>|\x00)*<h2\b[^>]*>(.*?)<\/h2>(\s|<br\b[^>]*>|\x00)*()/gi, '\x00\x00== $4 ==\x00\x00');
Line 9,785 ⟶ 9,969:
obj.html = obj.html.replace(/<(h[0-6])\b[^>]*>(.*?)<\/\1>/gi, '$2');
// {{TABLE}}
// convert html tables to wikicode
if (wikEd.tableMode == false) {
// remove <thead> <tbody> <tfoot>
obj.html = obj.html.replace(/(\s|\x00|<br\b[^>]*>)<\/?(thead|tbody|tfoot)\b[^>]*>(\s|\x00|<br\b[^>]*>)*()/gi, '$1');
// remove <col></col> and <colgroup></colgroup>\s
obj.html = obj.html.replace(/(\s|<br\b[^>]*>|\x00)*<(col)\b[^>]*>.*?<\/\2>(|<br\b[^>]*>|\x00)*()/gi, '');
obj.html = obj.html.replace(/(\s|<br\b[^>]*>|\x00)*<(colgroup)\b[^>]*>.*?<\/\2>(|<br\b[^>]*>|\x00)*()/gi, '');
// line breaks in table cells
obj.html = obj.html.replace(/(<(td|th|caption)\b[^>]*>)(.*?)(<\/\2>)/gi,
function(p, p1, p2, p3, p4) {
Line 9,806 ⟶ 9,990:
);
// remove table closing tags
obj.html = obj.html.replace(/(\s|<br\b[^>]*>|\x00)*<\/(tr|thead|tbody|tfoot)>(\s|<br\b[^>]*>|\x00)*()/gi, '');
// <td> table cells
obj.html = obj.html.replace(/(\s|<br\b[^>]*>|\x00)*<td>(\s|<br\b[^>]*>|\x00)*()/gi, '\x00| ');
obj.html = obj.html.replace(/(\s|<br\b[^>]*>|\x00)*<(td) +([^>]*)>(\s|<br\b[^>]*>|\x00)*()/gi,
Line 9,823 ⟶ 10,007:
);
// <th> table cells
obj.html = obj.html.replace(/(\s|<br\b[^>]*>|\x00)*<th>(\s|<br\b[^>]*>|\x00)*()/gi, '\x00| ');
obj.html = obj.html.replace(/(\s|<br\b[^>]*>|\x00)*<(th) +([^>]*)>(\s|<br\b[^>]*>|\x00)*()/gi,
Line 9,837 ⟶ 10,021:
);
// <tr> table rows
obj.html = obj.html.replace(/(\s|<br\b[^>]*>|\x00)*<tr>(\s|<br\b[^>]*>|\x00)*()/gi, '\x00|-\x00');
obj.html = obj.html.replace(/(\s|<br\b[^>]*>|\x00)*<(tr) +([^>]*)>(\s|<br\b[^>]*>|\x00)*()/gi,
Line 9,845 ⟶ 10,029:
);
// <caption> table caption
obj.html = obj.html.replace(/(\s|<br\b[^>]*>|\x00)*<caption>(\s|<br\b[^>]*>|\x00)*()/gi, '\x00|+ ');
obj.html = obj.html.replace(/(\s|<br\b[^>]*>|\x00)*<(caption) +([^>]*)>(\s|<br\b[^>]*>|\x00)*()/gi,
Line 9,859 ⟶ 10,043:
);
// remove closing tags
obj.html = obj.html.replace(/\s*<\/(td|th|caption)>\s*()/gi, '');
// line breaks, also in table cells (continued)
obj.html = obj.html.replace(/<br\b[^>]*>[\n ]*()/gi, '\x00');
// <table>
obj.html = obj.html.replace(/[\s\x00]*<table>[\s\x00]*(\|-(?=[\n\x00]))?/gi, '\x00\x00{|\x00');
obj.html = obj.html.replace(/[\s\x00]*<(table) +([^>]*)>[\s\x00]*(\|-(?=[\n\x00]))?/gi,
Line 9,883 ⟶ 10,067:
}
// for table mode override pasted table class // {{TABLE}}
else if (wikEd.tableMode == true) {
obj.html = obj.html.replace(/(<table\b)([^>]*)(>)/gi,
Line 9,897 ⟶ 10,081:
);
// table block element needs only one newline
obj.html = obj.html.replace(/(\s|<br\b[^>]*>|\x00)*(<table\b.*?>)/gi, '\x00\x00$2');
obj.html = obj.html.replace(/(<\/table>)(\s|<br\b[^>]*>|\x00)*()/gi, '$1\x00');
}
// line breaks (continued)
if (wikEd.tableMode == true) {
obj.html = obj.html.replace(/<br\b[^>]*>[\n ]*()/gi, '\x00');
}
// convert links
obj.html = obj.html.replace(/<a(\b[^>]*)>(.*?)<\/a>/gi,
function (p, p1, p2) {
Line 9,924 ⟶ 10,108:
var linkTitle = '';
// get href value
var hrefValue;
var regExpMatchLink = linkParam.match(/\bhref="([^">]*)"/);
Line 9,930 ⟶ 10,114:
hrefValue = regExpMatchLink[1];
// get absolute path from ./index.php and ../../index.php
hrefValue = wikEd.RelativeToAbsolutePath(hrefValue);
// check for wiki article link and get parameters
//
var regExpArticle = new RegExp(wikEd.server + '(' + wikEd.articlePath + '([^"\\?#]+)|' + wikEd.script + '\\?([^"#]*))(#[^"]*)?');
var regExpMatchArticle = regExpArticle.exec(hrefValue);
if (regExpMatchArticle != null) {
// article name from url path <a href="../wiki/ hrefUrlArticle ">
hrefUrlArticle = regExpMatchArticle[2];
// article name from url parameters <a href="url? hrefUrlParam ">
hrefUrlParam = regExpMatchArticle[3];
// link anchor <a href="link #anchor">
linkArticleAnchor = regExpMatchArticle[4] || '';
if (linkArticleAnchor != '') {
Line 9,953 ⟶ 10,137:
}
// parse hrefUrlParam and check for special parameters
if (hrefUrlParam != null) {
var regExpMatchHref;
while ( (regExpMatchHref = regExpHref.exec(hrefUrlParam)) != null) {
var param = regExpMatchHref[2];
var value = regExpMatchHref[3];
Line 9,980 ⟶ 10,165:
}
// ISBN links
if (hrefParamAction == null) {
if ( (hrefParamISBN != null) && (hrefParamSpecial != true) ) {
Line 9,991 ⟶ 10,176:
}
// get article from href parameters
else if ( (hrefParamTitle != null) && (hrefParamSpecial != true) ) {
linkArticle = hrefParamTitle;
Line 9,998 ⟶ 10,183:
}
// get article name from url path
else if (hrefUrlArticle != null) {
linkArticle = hrefUrlArticle;
Line 10,005 ⟶ 10,190:
}
// get article name from <a title="">
else {
var regExpMatchTitle = /\btitle="([^">]+)"/.exec(linkParam);
Line 10,015 ⟶ 10,200:
}
// format wiki link
if (linkArticle != '') {
// check for wiki image
var regExpMatchImage = /^<img\b[^>]*?\bwidth="(\d+)"[^>]*?>$/.exec(linkText);
if (regExpMatchImage != null) {
Line 10,032 ⟶ 10,217:
}
// category link
var regExpCat = new RegExp('^(Category|' + wikEd.config.text['wikicode Category'] + ')\\s*:(.*)', 'i');
var regExpMatchCat = regExpCat.exec(linkArticle);
Line 10,039 ⟶ 10,224:
}
// wiki link
if (linkArticle == linkText.charAt(0).toUpperCase() + linkText.substr(1)) {
return('[[' + linkText + linkArticleAnchor + ']]');
}
// date link (English only)
var regExpMatchDate = /^(January|February|March|April|May|June|July|August|September|October|November|December) (\d{1,2})$/.exec(linkArticle);
if (regExpMatchDate != null) {
Line 10,054 ⟶ 10,239:
}
// lowercase the article name if the first char of the link text can exist in lower/uppercase and is lowercase
if ( linkText.charAt(0).toLowerCase() != linkText.charAt(0).toUpperCase() ) {
if ( linkText.charAt(0) == linkText.charAt(0).toLowerCase() ) {
Line 10,061 ⟶ 10,246:
}
// suffix links
var regExpStrSuffix = new RegExp('^' + linkArticle.replace(/(\W)/g, '\\$1') + '([' + wikEd.letters + '_]+)$');
var regExpMatchSuffix = regExpStrSuffix.exec(linkText);
Line 10,070 ⟶ 10,255:
}
// external link
if (hrefValue != '') {
// PubMed link
var regExpMatchPubMed = /^http:\/\/www\.ncbi\.nlm\.nih\.gov\/entrez\/query\.fcgi\?cmd=Retrieve&db=pubmed&.*?&list_uids=(\d+)/.exec(hrefValue);
if (regExpMatchPubMed != null) {
Line 10,079 ⟶ 10,264:
}
// DOI link
regExpMatchDOI = /^http:\/\/dx\.doi\.org\/(.*)/.exec(hrefValue);
if (regExpMatchDOI != null) {
Line 10,085 ⟶ 10,270:
}
// other external link
return('[' + hrefValue + ' ' + linkText + ']');
}
}
// return unchanged text
return(p1);
}
);
// clean up MediaWiki category list
var regExp = new RegExp('<span\\b[^>]*>(\\[\\[(Category|' + wikEd.config.text['wikicode Category'] + ')\\s*:[^\\]]+\\]\\])<\\/span>[\\s\\x00\\|]*', 'gi');
obj.html = obj.html.replace(regExp, '$1\x00');
// clean up DOI
obj.html = obj.html.replace(/\[\[Digital object identifier\|DOI\]\]:(\{\{doi\|[^\}\s]+\}\})/gi, '$1');
// convert images
obj.html = obj.html.replace(/<img\b([^>]*)>/gi,
function (p, p1) {
// get and format parameters
var address = '';
var regExpMatch = /\bsrc\s*=\s*('|")([^'"]*)('|")/i.exec(p1);
Line 10,143 ⟶ 10,328:
);
// convert lists: * # : ;
var listObj = {};
listObj.prefix = '';
Line 10,178 ⟶ 10,363:
obj.html = obj.html.replace(/[\n|\x00]+[#\*:\;]+ (?=[\n|\x00])/g, '');
// <> remove not allowed tags
obj.html = obj.html.replace(/(<\/?)(\/?)(\w+)(.*?>)/g,
function (p, p1, p2, p3, p4) {
// keep table tags if in table mode
if (wikEd.tableMode == true) {
if (
}
// keep html elements with name, id, or class starting with wikEdKeep
if (wikEd.keepFormatting == true) {
if ( /^(div|span|ins|del)$/i.test(p3) == true) {
if ( /\b(name|id|class)="wikEdKeep/.test(p4) == true) {
p = p.replace(/</g, '\x01');
p = p.replace(/>/g, '\x02');
return(p);
}
}
}
// keep allowed tags
if ( /^(big|blockquote|colgroup|center|code|del|div|font|ins|p|pre|s|small|span|strike|sub|sup|tt|u|rb|rp|rt|ruby|nowiki|math|noinclude|includeonly|ref|charinsert|fundraising|fundraisinglogo|gallery|source|poem|categorytree|hiero|imagemap|inputbox|timeline|references|syntaxhighlight)$/i.test(p3) == true) {
}
return('');
}
);
// sanitize attributes in opening html tags
obj.html = obj.html.replace(/<(\w+) +(.*?) *(\/?)>/g,
function (p, p1, p2, p3) {
Line 10,211 ⟶ 10,406:
);
// unformat underlined, italic or bold blanks
// corrupts existing text
// obj.html = obj.html.replace(/<u>('''|''|\s|\x00)*([\s\x00]+)('''|''|\s|\x00)*<\/u>/g, '$2');
// obj.html = obj.html.replace(/'''(''|\s|\x00)*([\s\x00]+)(''|\s|\x00)*'''/g, '$2');
// obj.html = obj.html.replace(/''([\s\x00]+)''/g, '$1');
// fix MS Word non-style heading formatting
obj.html = obj.html.replace(/(\x00(={1,6}) *)(<u>|'''|'')+(.*?)(<\/u>|'''|'\')+( *\2\x00)/gi, '$1$4$6');
// remove empty headings
obj.html = obj.html.replace(/\x00(={1,6})\s+\1\x00/g, '\x00');
// remove space-only lines
obj.html = obj.html.replace(/([\s\x00]*\x00[\s\x00]*)/g,
function (p, p1) {
Line 10,230 ⟶ 10,425:
);
// remove trailing linebreaks from table cells
obj.html = obj.html.replace(/\x00{2,}(\|)/g, '\x00$1');
// remove leading and trailing spaces
obj.html = obj.html.replace(/>\s+\x00/g, '>\x00');
obj.html = obj.html.replace(/\x00\s+</g, '\x00<');
// remove empty inline and block tag pairs
obj.html = obj.html.replace(/( *)<(big|colgroup|code|del|font|ins|pre|s|small|span|strike|sub|sup|tt|u|rb|rp|rt|ruby|nowiki|math|noinclude|includeonly|ref|charinsert|fundraising|fundraisinglogo)\b[^>]*><\/\1> *()/gi, '$1');
obj.html = obj.html.replace(/[\s\x00]*<(blockquote|center|div|gallery|source|poem|categorytree|hiero|imagemap|inputbox|timeline|references)\b[^>]*><\/\1>[\s\x00]*()/gi, '\x00\x00');
// remove empty lines from block tags
obj.html = obj.html.replace(/(<(blockquote|center|div|p|pre|gallery|source|poem|categorytree|hiero|imagemap|inputbox|timeline|references)\b[^>]*>[\s\x00])[\s\x00]+/gi, '$1');
obj.html = obj.html.replace(/[\s\x00]+([\s\x00]<\/(blockquote|center|div|p|pre|gallery|source|poem|categorytree|hiero|imagemap|inputbox|timeline|references)>)/gi, '$1');
// blockquote
obj.html = obj.html.replace(/(<blockquote\b[^>]*>[\s\x00]+)([\S\s]*?)([\s\x00]+<\/blockquote>)/gi,
function (p, p1, p2, p3) {
Line 10,253 ⟶ 10,448:
);
// escape < >
obj.html = obj.html.replace(/</g, '<');
obj.html = obj.html.replace(/>/g, '>');
// preserved table tags
obj.html = obj.html.replace(/\x01/g, '<');
obj.html = obj.html.replace(/\x02/g, '>');
// newlines to <br>
obj.html = obj.html.replace(/\x00+\n/g, '\n');
obj.html = obj.html.replace(/\n\x00+/g, '\n');
Line 10,268 ⟶ 10,463:
obj.html = obj.html.replace(/\n/g, '<br>');
// table block element needs only one newline
obj.html = obj.html.replace(/(<\/table><br\b[^>]*>)(<br\b[^>]*>)+/g, '$1');
// remove empty lines from article start and end
if (obj.from == 'whole') {
obj.html = obj.html.replace(/^(<br\b[^>]*>)+/gi, '');
Line 10,289 ⟶ 10,484:
var absolutePath = '';
// get current url
if (fullPath == null) {
fullPath = window.___location.href;
Line 10,296 ⟶ 10,491:
}
// ./index.php
if (/^\.\/()/.test(relativePath) == true) {
relativePath = relativePath.replace(/^\.\/()/, '');
Line 10,303 ⟶ 10,498:
}
// ../../index.php
else if (/^\.\.\/()/.test(relativePath) == true) {
while (regExp.test(relativePath) == true) {
relativePath = relativePath.replace(/^\.\.\/()/, '');
fullPath = fullPath.replace(/\/[^\/]*$/, '');
Line 10,312 ⟶ 10,508:
}
// full path
else {
absolutePath = relativePath;
Line 10,344 ⟶ 10,540:
var sanitized = '';
var regExpMatch;
while ( (regExpMatch = regExp.exec(attributes)) != null) {
var attrib = regExpMatch[1];
var attribValue = regExpMatch[4] || regExpMatch[5];
Line 10,352 ⟶ 10,549:
var valid = false;
// relaxed, for existing text tags
if (relaxed == true) {
if ('center|em|strong|cite|code|var|sub|supdl|dd|dt|tt|b|i|big|small|strike|s|u|rb|rp|ruby'.indexOf(tag) >= 0) {
Line 10,441 ⟶ 10,638:
}
// strict, for html code to be wikified from external sources (websites, Word)
else {
if ('center|em|strong|cite|code|var|sub|supdl|dd|dt|tt|b|i|big|small|strike|s|u|rb|rp|ruby|blockquote|pre|ins|del'.indexOf(tag) >= 0) {
Line 10,520 ⟶ 10,717:
}
// clean up
if (valid == true) {
// clean up defaults for align
if (attrib == 'align') {
if ('tr|td|th'.indexOf(tag) >= 0) {
Line 10,532 ⟶ 10,729:
}
// clean up defaults for valign
else if (attrib == 'valign') {
if ('tr|td|th'.indexOf(tag) >= 0) {
Line 10,541 ⟶ 10,738:
}
// clean up style
else if (attrib == 'style') {
// remove non-standard Mozilla styles
attribValue = attribValue.replace(/(^| )(-moz-[\w\-]+): [\w\-]+; *()/g, '$1');
attribValue = attribValue.replace(/(^| )([\w\-]+): [^;]*(-moz-[\w\-]+|windowtext)[^;]*; *()/g, '$1');
// remove dimensions from null values
attribValue = attribValue.replace(/\b0(%|in|cm|mm|em|ex|pt|pc|px)\b/g, '0');
// remove empty definitions and spaces
attribValue = attribValue.replace(/[\w\-]+ *\: *\; *()/g, '');
attribValue = attribValue.replace(/ *(;|:) *()/g, '$1 ');
Line 10,557 ⟶ 10,754:
}
// clean up class
else if (attrib == 'class') {
// remove MS Word classes
attribValue = attribValue.replace(/^Ms.*$/g, '');
}
Line 10,579 ⟶ 10,776:
wikEd.RemoveHighlighting = function(obj) {
// remove highlighting error messages
if (wikEd.config.highlightError == true) {
obj.html = obj.html.replace(/<span\b[^>]*?\bclass="wikEdHighlightError"[^>]*>.*?<\/span><!--wikEdHighlightError-->/g, '');
}
// remove highlighting and atttribute-free span tags
var isRemove = [];
obj.html = obj.html.replace(/(<(\/?)span\b([^>]*)>)/g,
Line 10,603 ⟶ 10,800:
);
// remove highlighting div tags
var isRemove = [];
obj.html = obj.html.replace(/(<(\/?)div\b([^>]*)>)/g,
Line 10,622 ⟶ 10,819:
);
// remove span tags from WebKit https://bugs.webkit.org/show_bug.cgi?id=13490
// filtering these tags does not help, they accumulate anyway
var isRemove = [];
obj.html = obj.html.replace(/(<(\/?)span\b([^>]*)>)/g,
Line 10,642 ⟶ 10,839:
);
// remove highlighting font tags from WebKit
var isRemove = [];
obj.html = obj.html.replace(/(<(\/?)font\b([^>]*)>)/g,
Line 10,661 ⟶ 10,858:
);
// remove highlighting div tags from WebKit
var isRemove = [];
//
obj.html = obj.html.replace(/(([\x00\x01]\s*)?<(\/?)div\b([^>]*)>(\s*[\x00\x01])?)/g,
function (p, p1, p2, p3, p4, p5) {
Line 10,687 ⟶ 10,884:
obj.html = obj.html.replace(/[\x00\x01]/g, '');
// comments
obj.html = obj.html.replace(/<!--wikEd[\w\/]+-->/g, '');
// newlines
obj.html = obj.html.replace(/[\n ]+/g, ' ');
// non-breaking spaces
obj.html = obj.html.replace(/ /g, '\xa0');
// check for pasted html content
if (obj.html.match(/<(?!br\b)/) != null) {
obj.htmlCode = true;
Line 10,717 ⟶ 10,914:
wikEd.parseObj.regExpTags = null;
// main regular expression search definitions
// [regular expression fragment, tag, tagClass, tagStart (regexp starts with newline)]
var tagArray = [
['\\b(((https?|ftp|irc|gopher):\\/\\/)|news:|mailto:)[^\\x00-\\x20\\s"\\[\\]\\x7f]+', 'inlineURL', 'block'], // inline link
// faster without (!?)
// ['[^\\{\\}\\[\\]\x00\x01_\\|\\!\\=\\*\\#\\:\\;"\'\\n\\\\~\\-]+', 'text', 'ignore'], // chew-up fragment to ignore plain text, triples regExp speed, check later if chewed into start of inlineLink; start-with-text tags (PMID,...) have to be tested for separately to benefit from his
['\x00(nowiki)\\b[^\x00\x01]*\x01(.|\\n)*?\x00/nowiki\\s*\x01', 'nowiki', 'block'], // <nowiki>...</nowiki>
Line 10,770 ⟶ 10,967:
['\\\'{2,}', 'boldItalic', 'multi'], // bold, italic
['__(' + wikEd.magicWords + ')__',
['~{3,5}', 'signature', 'block'], // signature
['(^|\\n)\\-{4,}', 'hr', 'block'], // hr
Line 10,777 ⟶ 10,974:
];
// parse tag array into regular expression string and parenthesized substring match-to-tag info array
var regExpStrings = [];
for (var i = 0; i < tagArray.length; i ++) {
Line 10,784 ⟶ 10,981:
var tagClass = tagArray[i][2];
// add parenthesized sub regExp to regexp array
regExpStrings.push('(' + regExpSub + ')');
// detect if a fragment starts with (^|\\n) to handle the leading newlines
var tagStart = false;
if (/^\(\^\|\\n\)/.test(regExpSub) == true) {
Line 10,793 ⟶ 10,990:
}
// save tag information for matched parenthesis
wikEd.parseObj.matchToTag.push( [tag, tagClass, tagStart] );
// add empty entry for all sub parentheses, ignore (? and \(
var pos = 0;
while ( (pos = regExpSub.indexOf('(', pos) + 1) > 0) {
Line 10,807 ⟶ 11,004:
}
// create regExp from or-joined parenthesized sub regExps
wikEd.parseObj.regExpTags = new RegExp(regExpStrings.join('|'), 'gi');
Line 10,838 ⟶ 11,035:
wikEd.HighlightSyntax = function(obj, noTimeOut) {
// start timer to cancel after wikEd.config.maxHighlightTime ms
var highlightStartDate = new Date();
// linkify raw watchlist
if (wikEd.watchlistEdit == true) {
obj.html = obj.html.replace(/(.*)/gm,
Line 10,860 ⟶ 11,057:
}
// < > & to \x00 \x01 &
obj.html = obj.html.replace(/</g, '\x00');
obj.html = obj.html.replace(/>/g, '\x01');
obj.html = obj.html.replace(/&/g, '&');
// trailing, leading, and multi spaces to nbsp
obj.html = obj.html.replace(/^ | $/gm, '\xa0');
obj.html = obj.html.replace(/(\n|\xa0 | ) /g, '$1\xa0');
// define parse object
var parseObj = {
// tree object that holds nodes to be sorted and joined for final text:
// { 'tag': , 'parent': , 'firstChild': , 'nextSibling': , 'start': , 'tagLength': , 'type': , 'pairedTagPos': , 'left': , 'right': , 'index':, 'noHide': }
'tree': [],
// main regular expression for syntactic elements
'regExp': null,
// last match
'regExpMatch': null,
// highlight whole text or fragment
'whole': false,
// ignore leading closing tags for fragment highlighting
'addedOpenTag': false,
// quick references
'lastOpenTag': null,
'lastOpenNode': 0,
// filtered ignore p tags
'lastOpenNodeFiltered': null,
'lastOpenTagFiltered': null,
Line 10,902 ⟶ 11,099:
};
// add root node
parseObj.tree[0] = { 'type': 'root' };
// clear array of link addresses and preview image ids
if (obj.whole == true) {
parseObj.whole = true;
Line 10,917 ⟶ 11,114:
}
//
var content = '';
var from = 0;
var commentsLength = 0;
var regExpMatch;
var regExpComments = /(\x00!--
while ( (regExpMatch = regExpComments.exec(obj.html)) != null) {
var tag;
if (regExpMatch[1] != null) {
tag = 'comment';
}
else if (regExpMatch[2] != null) {
tag = 'keep';
}
parseObj.tree.push( { 'tag': tag, 'start': regExpMatch.index - commentsLength, 'tagLength': 0, 'type': tag, 'left': regExpMatch[0] } );
content += obj.html.substring(from, regExpMatch.index);
commentsLength += regExpMatch[0].length;
Line 10,933 ⟶ 11,137:
obj.html = content;
}
//// opening block tags and templates break link?
// show main parsing regExp:
// WED('regExp', wikEd.parseObj.regExpTags.toString().replace(/\x00/g, '<').replace(/\x01/g, '>').replace(/\n/g, '\\n'));
// cycle through text and find tags with a regexp search
wikEd.parseObj.regExpTags.lastIndex = 0;
while ( (parseObj.regExpMatch = wikEd.parseObj.regExpTags.exec(obj.html)) != null) {
// cancel highlighting after wikEd.config.maxHighlightTime ms
if (noTimeOut != true) {
var currentDate = new Date();
Line 10,950 ⟶ 11,155:
}
var tagMatch
var tagFrom = parseObj.regExpMatch.index;
var tagLength = tagMatch.length;
Line 10,957 ⟶ 11,162:
var tagMatchParenth = 0;
// get regexp index number from first defined parenthesized submatch
var tag = '';
var tagClass = '';
Line 10,964 ⟶ 11,169:
if (typeof(parseObj.regExpMatch[i]) != 'undefined') {
// get tag information
tag = wikEd.parseObj.matchToTag[i][0];
tagClass = wikEd.parseObj.matchToTag[i][1];
Line 10,973 ⟶ 11,178:
}
// handle chew-up regExp matches that massively speed up regexp search
if (tagClass == 'ignore') {
// move regExp pointer back if chew-up regExp fragment has eaten into the start of an inline link
if (obj.html.charAt(wikEd.parseObj.regExpTags.lastIndex) == ':') {
var regExpMatch = /(https?|ftp|irc|gopher)$/.exec(tagMatch);
Line 10,986 ⟶ 11,191:
}
// detect and remove newline from leading (^|\n) in sub-regexp
var leadingNewline = false;
if (tagStart == true) {
Line 10,996 ⟶ 11,201:
}
// newlines close or end certain tags
if (leadingNewline == true) {
wikEd.HighlightBuildTree('newline', 'close', tagFrom, 0, parseObj);
}
// no wikicode in link target or template or parameter name, only after pipe in linkPiped, or parameterPiped
if ( (parseObj.lastOpenTag == 'link') || (parseObj.lastOpenTag == 'template') || (parseObj.lastOpenTag == 'parameter') ) {
Line 11,012 ⟶ 11,217:
) {
// convert opening tag to error and continue
var errorText;
if (parseObj.lastOpenTag == 'link') {
Line 11,029 ⟶ 11,234:
}
// handle current tag by dispatching infos to stack manager that builds a hierarchical tree
switch (tag) {
// non-ambiguous tags
case 'nowiki':
case 'pre':
Line 11,047 ⟶ 11,252:
break;
// bold and italic
case 'boldItalic':
switch (tagLength) {
Line 11,121 ⟶ 11,326:
break;
// templParam: template or template parameter
case 'paramTempl':
// template or parameter
var paramTemplTag = tag;
if (tagLength == 2) {
Line 11,133 ⟶ 11,338:
}
// open paramTempl
if (tagClass == 'open') {
wikEd.HighlightBuildTree(paramTemplTag, tagClass, tagFrom, tagLength, parseObj);
// add spare elements for later disambiguation
if (paramTemplTag == 'paramTempl') {
for (var pos = 2; pos < tagLength - 1; pos = pos + 2) {
Line 11,145 ⟶ 11,350:
}
// close paramTempl
else {
// no opening tag, delegate error handling
if ( (parseObj.lastOpenNode == 0) || (parseObj.lastOpenNode == null) ) {
wikEd.HighlightBuildTree(paramTemplTag, tagClass, tagFrom, tagLength, parseObj);
Line 11,159 ⟶ 11,364:
}
// close template or parameter, open and close defined
if (
( (paramTemplTag == 'template') && (parseObj.lastOpenTagFiltered == 'template') ) ||
Line 11,168 ⟶ 11,373:
}
// closing defines ambiguous opening
else if (
( (paramTemplTag == 'template') || (paramTemplTag == 'parameter') ) &&
Line 11,175 ⟶ 11,380:
) {
// redefine ambiguous opening
wikEd.HighlightTreeRedefine(parseObj.lastOpenNodeFiltered, paramTemplTag, openNode.tagLength - tagLength, tagLength, parseObj);
// adjust all ambiguous parents
var redefinedTag;
var redefinedLength;
Line 11,193 ⟶ 11,398:
}
// ignore spare paramTempl opening tags like p tags
if (redefinedLength == 0) {
redefinedTag = 'spare';
}
// mark remaining single { as error
else if (redefinedLength == 1) {
parseObj.tree.push( {
Line 11,209 ⟶ 11,414:
}
// this is a template
else if (redefinedLength == 2) {
node.tag = 'template';
}
// this is a parameter
else if (redefinedLength == 3) {
node.tag = 'parameter';
}
// redefine parent
wikEd.HighlightTreeRedefine(nodeNo, redefinedTag, null, redefinedLength, parseObj);
// all further opening paramTempl tags are spare
if (redefinedLength <= 3) {
redefinedTag = 'spare';
Line 11,228 ⟶ 11,433:
}
// up one level
nodeNo = node.parent;
}
wikEd.HighlightGetLevel(parseObj);
// and close innermost tag
wikEd.HighlightBuildTree(paramTemplTag, tagClass, tagFrom, tagLength, parseObj);
}
// opening defines ambiguous closing
else if ( (
(openNode.tag == 'template') ||
Line 11,247 ⟶ 11,452:
}
// both ambiguous
else if (
(paramTemplTag == 'paramTempl') &&
Line 11,267 ⟶ 11,472:
}
// opening and closing do not match
else {
parseObj.tree.push( {
Line 11,285 ⟶ 11,490:
break;
// table single elements
case 'header':
case 'headerSep':
Line 11,296 ⟶ 11,501:
break;
// wikilink
case 'link':
wikEd.HighlightBuildTree(tag, tagClass, tagFrom, 2, parseObj);
break;
// inline link block and external link
case 'inlineURL':
case 'external':
// trailing punctuation not part of inline links
if (tag == 'inlineURL') {
var regExpMatch;
Line 11,322 ⟶ 11,527:
}
// urls in templates or tables are interrupted by tag strings
if (tag == 'inlineURL') {
var node = parseObj.tree[parseObj.lastOpenNode];
while (node != null) {
// urls in templates are interrupted by }} and |
if ( (node.tag == 'template') || (node.tag == 'paramTempl') || (node.tag == 'parameter') || (node.tag == 'parameterPiped') ) {
var regExpMatch;
Line 11,339 ⟶ 11,544:
}
// urls in tables are interrupted by ||
else if (node.tag == 'table') {
var regExpMatch;
Line 11,354 ⟶ 11,559:
}
// dissect external [url text
if (tag == 'external') {
if (tagClass == 'open') {
Line 11,364 ⟶ 11,569:
}
// close ], ignore false positive non-tags that have no opening [
else {
var node = parseObj.tree[parseObj.lastOpenNode];
Line 11,386 ⟶ 11,591:
break;
// <html>
case 'html':
var htmlTag = parseObj.regExpMatch[tagMatchParenth + 1].toLowerCase();
Line 11,400 ⟶ 11,605:
break;
// <html />
case 'htmlEmpty':
var htmlTag = parseObj.regExpMatch[tagMatchParenth + 1];
Line 11,411 ⟶ 11,616:
break;
// |}}: table end or empty template parameter + template end
case 'pipeTemplateEnd':
if (parseObj.lastOpenTagFiltered == 'table') {
Line 11,422 ⟶ 11,627:
break;
// ]]: wikilink, file link, redirect
case 'doubleCloseBracket':
if (parseObj.lastOpenTagFiltered == 'file') {
Line 11,432 ⟶ 11,637:
break;
// \n|: table cell, wikilink separator, file parameter separator, redirect separator, empty template parameter
case 'newlinePipe':
switch (parseObj.lastOpenTagFiltered) {
Line 11,451 ⟶ 11,656:
break;
// ||: table cell separator, empty file parameter separator, empty template parameters
case 'doublePipe':
switch (parseObj.lastOpenTagFiltered) {
Line 11,472 ⟶ 11,677:
break;
// pipe |: table cell parameter separator, table caption parameter separator, wikilink separator, file parameter separator, template parameter, parameter default
case 'pipe':
switch (parseObj.lastOpenTagFiltered) {
Line 11,494 ⟶ 11,699:
break;
// list and preformatted (leading space) lines
case 'preform':
// ignore template parameters preceeded with newline-spaces
if (parseObj.lastOpenTagFiltered == 'template') {
wikEd.parseObj.regExpTags.lastIndex = tagFrom + tagLength - parseObj.regExpMatch[tagMatchParenth + 3].length;
Line 11,504 ⟶ 11,709:
case 'list':
// highlight line
wikEd.HighlightBuildTree(tag, tagClass, tagFrom, tagLength, parseObj);
// highlight tag
wikEd.HighlightBuildTree(tag + 'Tag', tagClass, tagFrom, parseObj.regExpMatch[tagMatchParenth + 2].length, parseObj);
// move text pointer after tag
wikEd.parseObj.regExpTags.lastIndex = tagFrom + tagLength - parseObj.regExpMatch[tagMatchParenth + 3].length;
break;
// newline, old
case 'newline':
wikEd.HighlightBuildTree(tag, 'close', tagFrom, 0, parseObj);
break;
// unrecognized tag
default:
parseObj.tree.push( { 'start': tagFrom, 'tagLength': tagLength, 'type': 'error', 'left': wikEd.config.text.wikEdErrorNoHandler } );
}
// quit after reaching $ 'newline'
if (tagMatch == '') {
break;
Line 11,530 ⟶ 11,735:
}
// do not tolerate trailing opening tags for whole text highlighting
if (parseObj.whole == true) {
// mark remaining unmatched opening tags
while ( (parseObj.lastOpenNode != 0) && (parseObj.lastOpenNode != null) ) {
wikEd.HighlightMarkLastOpenNode(wikEd.config.text.wikEdErrorNoClose, parseObj);
Line 11,539 ⟶ 11,744:
}
// show parsing tree before additional block highlighting:
// WED('parseObj.tree', parseObj.tree);
// wiki autolinking (case sensitive, newlines are actually allowed!)
var regExpMatch;
var regExpAutoLink = /((PMID)[ \xa0\t]+(\d+))|((RFC)[ \xa0\t]+(\d+))|((RFC)[ \xa0\t]+(\d+))|((ISBN)[ \xa0\t]+((97(8|9)( |-)?)?(\d( |-)?){9}(\d|x)))/g;
Line 11,549 ⟶ 11,754:
}
// named html colors in quotation marks
var regExpColorLight = /('|")(aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|blanchedalmond|burlywood|chartreuse|coral|cornsilk|cyan|darkgray|darkgrey|darkkhaki|darkorange|darksalmon|darkseagreen|floralwhite|fuchsia|gainsboro|ghostwhite|gold|goldenrod|greenyellow|honeydew|hotpink|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgray|lightgreen|lightgrey|lightpink|lightsalmon|lightskyblue|lightsteelblue|lightyellow|lime|linen|magenta|mediumaquamarine|mediumspringgreen|mediumturquoise|mintcream|mistyrose|moccasin|navajowhite|oldlace|orange|palegoldenrod|palegreen|paleturquoise|papayawhip|peachpuff|peru|pink|plum|powderblue|salmon|sandybrown|seashell|silver|skyblue|snow|springgreen|tan|thistle|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen)(\1)/gi;
while ( (regExpMatch = regExpColorLight.exec(obj.html) ) != null) {
Line 11,559 ⟶ 11,764:
}
// RGB hex colors #ddc, exclude links and character entities starting with &
var regExpColor3 = /(^|[^\/\w&])(#[0-9a-f]{3})(?=([^\d\w]|$))/gi;
while ( (regExpMatch = regExpColor3.exec(obj.html) ) != null) {
Line 11,565 ⟶ 11,770:
}
// RGB hex colors #d4d0cc, exclude links and character entities starting with &
var regExpColor6 = /(^|[^\/\w&])(#[0-9a-f]{6})(?=([^\d\w]|$))/gi;
while ( (regExpMatch = regExpColor6.exec(obj.html) ) != null) {
Line 11,571 ⟶ 11,776:
}
// RGB decimal colors rgb(128,64,265)
var regExpColorDec = /\brgb\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*\)/gi;
while ( (regExpMatch = regExpColorDec.exec(obj.html) ) != null) {
Line 11,577 ⟶ 11,782:
}
// single character highlighting: spaces, dashes
var regExpCharSpaceDash = new RegExp('[' + wikEd.charHighlightingStr + ']', 'g');
while ( (regExpMatch = regExpCharSpaceDash.exec(obj.html) ) != null) {
Line 11,583 ⟶ 11,788:
}
// control character highlighting
var regExpCharCtrl = new RegExp('[' + wikEd.controlCharHighlightingStr + ']', 'g');
while ( (regExpMatch = regExpCharCtrl.exec(obj.html) ) != null) {
Line 11,591 ⟶ 11,796:
}
// character entities
var regExpCharEntities = /&(\w+);/g;
while ( (regExpMatch = regExpCharEntities.exec(obj.html) ) != null) {
Line 11,599 ⟶ 11,804:
}
// merge wiki syntax in
wikEd.HighlightAddHtml(parseObj, obj);
// get file previews
if ( (wikEd.config.filePreview == true) && (wikEd.filePreviewRequest != '') ) {
wikEd.AjaxPreview(wikEd.filePreviewRequest, wikEd.FilePreviewAjaxHandler);
Line 11,608 ⟶ 11,813:
}
// merge html and plain text
wikEd.HighlightMergeHtml(parseObj, obj);
// free up array
parseObj.tree = [];
// \x00 and \x01 back to < and >
obj.html = obj.html.replace(/&/g, '&');
obj.html = obj.html.replace(/\x00/g, '<');
obj.html = obj.html.replace(/\x01/g, '>');
// remove comments
if (wikEd.config.removeHighlightComments == true) {
obj.html = obj.html.replace(/<!--wikEd[\w\/]+-->/g, '');
Line 11,655 ⟶ 11,860:
wikEd.HighlightBuildTree = function(tag, tagClass, tagFrom, tagLength, parseObj) {
// show parameters:
// WED('tag, tagClass, tagFrom, tagLength', tag + ' ,' + tagClass + ', ' + tagFrom + ', ' + tagLength);
// single-element tags (block)
if (tagClass == 'block') {
if ( (parseObj.lastOpenNode != 0) && (parseObj.lastOpenNode != null) ) {
var redefinedParentTag;
// change parent link to linkPiped, only one valid separator per link
if ( (tag == 'linkParam') && (parseObj.lastOpenTag == 'link') ) {
redefinedParentTag = 'linkPiped';
}
// change parent link to parameterPiped, only one valid separator per link
else if ( (tag == 'parameterDefault') && (parseObj.lastOpenTag == 'parameter') ) {
redefinedParentTag = 'parameterPiped';
}
// redefine parent tag
if (redefinedParentTag != null) {
parseObj.tree[parseObj.lastOpenNode].tag = redefinedParentTag;
Line 11,679 ⟶ 11,884:
}
// chain blocks
var newNode = parseObj.tree.length;
var previousSibling = null;
// first node
if (parseObj.tree[parseObj.lastOpenNode].firstChild == null) {
parseObj.tree[parseObj.lastOpenNode].firstChild = newNode;
}
// chain to previous blocks
else {
previousSibling = parseObj.tree[parseObj.lastOpenNode].lastChild;
Line 11,699 ⟶ 11,904:
}
// add new block to tree
parseObj.tree.push( {
'tag': tag,
Line 11,710 ⟶ 11,915:
}
// opening tags
else if (tagClass == 'open') {
// push new open element onto tree
var openNode = {
'tag': tag,
Line 11,723 ⟶ 11,928:
parseObj.lastOpenNode = parseObj.tree.push(openNode) - 1;
// get new top and second-to-top nodes, ignoring unpaired p tags
wikEd.HighlightGetLevel(parseObj);
}
// closing tags
else if (tagClass == 'close') {
// try until we find the correct opening tag after fixing the tree
while (true) {
// no opening tag on stack
if (parseObj.lastOpenNode == 0) {
// ignore unmatched =
if (tag == 'heading') {
break;
}
// ignore breaking newlines
if (tag != 'newline') {
// tolerate leading closing tags for fragment highlighting
if ( (parseObj.whole == false) && (parseObj.addedOpenTag == false) ) {
// add new closing element to tree
parseObj.tree.push( {
'tag': tag,
Line 11,757 ⟶ 11,962:
}
// add no open tag error to tree
else {
parseObj.tree.push( {
Line 11,770 ⟶ 11,975:
}
// ignore unpaired <p> and spare nodes and try again with parent
if ( (tag != 'p') && ( (parseObj.lastOpenTag == 'p') || (parseObj.lastOpenTag == 'spare') ) ) {
if (parseObj.lastOpenNode != null) {
Line 11,779 ⟶ 11,984:
}
// newline brakes heading or external link, remove corresponding opening tag from stack
if (tag == 'newline') {
// mark broken opening tags
var nodeNo = parseObj.lastOpenNode;
var node = null;
Line 11,804 ⟶ 12,009:
}
// correct piped link
switch (tag) {
case 'link':
Line 11,812 ⟶ 12,017:
break;
// correct piped parameter
case 'parameter':
if (parseObj.lastOpenTag == 'parameterPiped') {
Line 11,820 ⟶ 12,025:
}
// wrong closing element
if (tag != parseObj.lastOpenTag) {
// ignore common unmatched false positive non-tags: = and ]
if ( (tag == 'heading') ) {
break;
}
// check if there is an open tag for this close tag
var nodeNo = parseObj.lastOpenNode;
while ( (nodeNo != 0) && (nodeNo != null) ) {
Line 11,838 ⟶ 12,043:
if ( (nodeNo != 0) && (nodeNo != null) ) {
// treat open tags as wrong, close tag as correct
if (parseObj.tree[nodeNo].tag == tag) {
// mark remaining unmatched opening tags
var nodeNo = parseObj.lastOpenNode;
while ( (nodeNo != 0) && (nodeNo != null) ) {
Line 11,857 ⟶ 12,062:
}
// treat open tags as correct, treat close tag as wrong
else {
// add wrong close tag error to tree
parseObj.tree.push( {
'start': tagFrom,
Line 11,872 ⟶ 12,077:
}
// headings in templates are ignored but we do not want to hide that template
if (tag == 'heading') {
// check for heading in template or ref
var ignoreHeading = false;
var nodeNo = parseObj.tree[parseObj.lastOpenNode].parent;
Line 11,891 ⟶ 12,096:
}
// clean out opening heading
if (ignoreHeading == true) {
// add headings in template errors to tree
// convert opening tag to error
wikEd.HighlightMarkLastOpenNode(wikEd.config.text.wikEdErrorTemplHeading, parseObj);
Line 11,909 ⟶ 12,114:
}
// it is the correct closing element
// save element last text position to opening tag entry
var pairedTagPos;
parseObj.tree[parseObj.lastOpenNode].pairedTagPos = tagFrom;
pairedTagPos = parseObj.tree[parseObj.lastOpenNode].start + parseObj.tree[parseObj.lastOpenNode].tagLength
// add new closing element to tree
parseObj.tree.push( {
'tag': tag,
Line 11,925 ⟶ 12,130:
} );
// up one level
if ( (parseObj.lastOpenNode != 0) && (parseObj.lastOpenNode != null) ) {
parseObj.lastOpenNode = parseObj.tree[parseObj.lastOpenNode].parent;
Line 11,933 ⟶ 12,138:
}
// get new top and second-to-top nodes, ignoring unpaired p tags
wikEd.HighlightGetLevel(parseObj);
}
Line 11,951 ⟶ 12,156:
if ( (openNode.tag != 'p') && (openNode.tag != 'spare') ) {
// mark pipes
if ( (openNode.tag == 'linkPiped') || (openNode.tag = 'parameterPiped') || (openNode.tag = 'template') || (openNode.tag = 'paramTempl') ) {
var childNode = parseObj.tree[openNode.firstChild];
Line 11,964 ⟶ 12,169:
}
// mark unmatched opening tags
parseObj.tree[lastOpenNode] = {
'start': openNode.start,
Line 12,026 ⟶ 12,231:
wikEd.HighlightAddHtml = function(parseObj, obj) {
// cycle through currently existing parse array
var from = 0;
var i = 0;
Line 12,075 ⟶ 12,280:
var follow = '';
// detect interlink and namespace
//
var regExpLink = /^\s*(([\w\- ]+)\:\s*)?((\:\s*)?([^\:\|\[\]\{\}\n\t]*\s*\:\s*))?([^\|\n]+?)\s*(\|((.|\n)*))?\s*$/gi;
regExpLink.lastIndex = 0;
Line 12,082 ⟶ 12,287:
if ( (regExpMatch = regExpLink.exec(innerPlain)) != null) {
// get interwiki, namespace, article, paramters
if (regExpMatch[1] != null) {
inter = regExpMatch[1];
Line 12,100 ⟶ 12,305:
nsClean = nsClean.replace(/^ $/, '');
// change interwiki into more common namespace if ambiguous
if ( (interClean != '') && (nsClean == '') ) {
nsClean = interClean;
Line 12,109 ⟶ 12,314:
}
// detect cross-namespace links
linkClass = 'wikEdLink';
if (wikEd.pageNamespace != null) {
Line 12,123 ⟶ 12,328:
}
// highlight interwiki and namespace
if (article != '') {
// highlight interwiki
if (inter != '') {
wikEd.HighlightBuildTree('linkInter', 'block', tagFrom + 2, inter.length, parseObj);
}
// highlight namespace
if (ns != '') {
wikEd.HighlightBuildTree('linkNamespace', 'block', tagFrom + 2 + inter.length, ns.length, parseObj);
}
// linkify
var regExpCasing = new RegExp('(^|\\:)' + wikEd.config.text['wikicode Category'] + '(\\:|$)', 'i');
nsClean = nsClean.replace(regExpCasing, '$1' + wikEd.config.text['wikicode Category'] + '$2');
Line 12,166 ⟶ 12,371:
}
// linkify and preview
else {
var file = regExpMatch[1] + ':' + regExpMatch[2];
Line 12,172 ⟶ 12,377:
filePlain = filePlain.replace(/ /g,'_');
// add file preview box
if (wikEd.config.filePreview == true) {
// get image size
var filePreviewSize = wikEd.config.filePreviewSize;
var regExpMatch;
Line 12,185 ⟶ 12,390:
}
// get image url and size from cache
var style = '';
var fileObj = wikEd.filePreviewCache['wikEd' + filePlain + filePreviewSize];
Line 12,200 ⟶ 12,405:
}
// get image url and size through an ajax request
else {
style = 'display: none; height: ' + filePreviewSize + 'px; width: ' + filePreviewSize + 'px;';
Line 12,235 ⟶ 12,440:
var follow = '';
//
var regExpTempl = new RegExp('^\\s*((' + wikEd.templModifier + ')\\:\\s*)?((\\:\\s*)?([^:|\\[\\]{}\\s\\x00\\x01]*\\s*\\:))?\\s*([^:\\n\\x00\\x01{}]+?)\\s*(\\|((.|\\n)*?))?\\s*$', 'gi');
// detect parser variables and functions, might slow main regexp down
var regExpMatch;
var parserVar = false;
if ( (regExpMatch = regExpTempl.exec(innerPlain)) != null) {
// get modifier, namespace, template, paramters
if (regExpMatch[1] != null) {
mod = regExpMatch[1];
Line 12,264 ⟶ 12,469:
}
// {{VARIABLE}}
if (parserVar == false) {
if ( (template != '') && (ns == '') && (param == '') ) {
Line 12,275 ⟶ 12,480:
}
// {{VARIABLE:R}}
if (parserVar == false) {
if ( (ns != '') && (template == 'R') ) {
Line 12,286 ⟶ 12,491:
}
// {{FUNCTION:param|R}}
if (parserVar == false) {
if ( (ns != '') && ( (param == '') || (param == 'R') ) ) {
Line 12,297 ⟶ 12,502:
}
// {{function:param|param}}
if (parserVar == false) {
if (ns != '') {
Line 12,308 ⟶ 12,513:
}
// {{#function:param|param}}
if (parserVar == false) {
if (ns != '') {
Line 12,319 ⟶ 12,524:
}
// highlight template
if (parserVar == false) {
// highlight modifier
if (mod != '') {
wikEd.HighlightBuildTree('templateModifier', 'block', tagFrom + 2, mod.length, parseObj);
}
// highlight namespace
if (ns != '') {
wikEd.HighlightBuildTree('templateNamespace', 'block', tagFrom + 2 + mod.length, ns.length, parseObj);
}
// add missing template namespace and linkify
if (ns == ':') {
ns = '';
Line 12,338 ⟶ 12,543:
else if (ns == '') {
// no Template: addition for subpage linking
if (template.indexOf('/') != 0) {
ns = wikEd.config.text['wikicode Template'] + ':';
Line 12,351 ⟶ 12,556:
if (wikEd.refHide == true) {
// show first template immediately following a template or reference
var hideButtonClass = 'wikEdTemplButton';
if ( (node.parent != null) && (node.parent > 0) ) {
Line 12,445 ⟶ 12,650:
case 'ref':
// ref no hide
if (node.noHide == true) {
insertLeft = '<span class="wikEdRef">';
}
// ref hide
else {
var refName = '';
Line 12,491 ⟶ 12,696:
if (parseObj.tableMode == true) {
// wikitable
var regExpTable = /\{\| *((\w+ *= *('|")[^\n'"]*\3 *)*)(\n|$)/gi;
regExpTable.lastIndex = tagFrom;
Line 12,497 ⟶ 12,702:
if (regExpMatch == null) {
// html table
regExpTable = /<table\b\s*((\w+\s*=\s*('|")[^>'"]*\3\s*)*)\s*>/gi;
regExpTable.lastIndex = tagFrom;
Line 12,655 ⟶ 12,860:
switch (tag) {
// pushRight instead of insertRight if enclosed text can contain other highlighting, e.g. single character highlighting
case 'linkNamespace':
insertLeft = '<span class="wikEdLinkNs">';
Line 12,735 ⟶ 12,940:
case 'fileParam':
// make text parameters a caption
var params = '';
if (pairedTagPos != null) {
Line 12,949 ⟶ 13,154:
case 'comment':
insertLeft = '<span class="wikEdComment">' + node.left + '</span><!--wikEdComment-->';
break;
case 'keep':
insertLeft = '<span class="wikEdKeep">' + node.left + '</span><!--wikEdKeep-->';
break;
case 'error':
Line 12,964 ⟶ 13,172:
}
// add left html into existing entry
if (insertLeft != '') {
node.left = insertLeft;
node.index = i + 0.1;
}
// add left html as new array element to allow for overlapping highlighting as in hr
else if (pushLeft != '') {
parseObj.tree.push( { 'start': tagFrom, 'tagLength': 0, 'left': pushLeft, 'index': i
}
// add right html into existing entry
if (insertRight != '') {
node.right = insertRight;
node.index = i - 0.1;
}
// add right html as new array element to allow for overlapping highlighting as in html-like tags and urls
else if (pushRight != '') {
parseObj.tree.push( { 'start': tagTo, 'tagLength': 0, 'right': pushRight, 'index': i
}
if (pushRight2 != '') {
parseObj.tree.push( { 'start': pushRightPos2, 'tagLength': 0, 'right': pushRight2, 'index': i
}
from = tagTo;
Line 13,008 ⟶ 13,215:
}
// sort parse array by position
parseObj.tree.sort(
function(a, b) {
// by start position
if (a.start != b.start) {
return(a.start - b.start);
}
// by
return(a.index - b.index);
}
);
// add comments and highlighting
var from = 0;
var htmlArray = [];
// cycle through parse array and assemble html array
for (var i = 0; i < parseObj.tree.length; i ++) {
var node = parseObj.tree[i];
Line 13,040 ⟶ 13,242:
var tagTo = tagFrom + tagLength;
// drop overlapping highlighting //// |- in tables?!
if (tagFrom < from) {
continue;
}
// ignore root
if (tagFrom == null) {
continue;
}
// push leading plain text
htmlArray.push(obj.html.substring(from, tagFrom));
// push left html
if (htmlLeft != null) {
htmlArray.push(htmlLeft);
}
// push right html
if (htmlRight != null) {
htmlArray.push(obj.html.substring(tagFrom, tagTo));
Line 13,070 ⟶ 13,272:
htmlArray.push(obj.html.substring(from));
// join html array
obj.html = htmlArray.join('');
// display highlighted html:
// WED(obj.html.replace(/\x00/g, '<').replace(/\x01/g, '>'));
return;
Line 13,092 ⟶ 13,294:
var subpage = false;
// generate url from interlanguage or namespace prefix and title
if (linkUrl == null) {
// test for illegal characters
if ( (/[\{\|\}\[\]<>#]/.test(linkPrefix) == true) || (/[<>]/.test(linkUrl) == true) ) {
return('');
}
// remove highlighting code
linkPrefix = linkPrefix.replace(/<.*?>/g, '');
linkTitle = linkTitle.replace(/<.*?>/g, '');
// remove control chars
var regExp = new RegExp('[' + wikEd.controlCharHighlightingStr + '\t\n\r]', 'g');
linkPrefix = linkPrefix.replace(regExp, '');
linkTitle = linkTitle.replace(regExp, '');
// fix strange white spaces, leading colons
linkPrefix = linkPrefix.replace(/\s/g, ' ');
linkPrefix = linkPrefix.replace(/^ +/, '');
Line 13,122 ⟶ 13,324:
linkName = linkPrefix + linkTitle;
// character accentuation for Esperanto, see [[Help:Special_characters#Esperanto]]
if (wikEd.wikiGlobals.wgContentLanguage == 'eo') {
linkTitle = linkTitle.replace(/([cghjsu])(x+)/gi,
Line 13,143 ⟶ 13,345:
}
// [[/subpage]] refers to a subpage of the current page, [[#section]] to a section of the current page
if ( (linkPrefix == '') && ( (linkTitle.indexOf('/') == 0) || (linkTitle.indexOf('#') == 0) ) ) {
subpage = true;
}
// Wiktionary differentiates between lower and uppercased titles, interwiki should not be uppercased
if (subpage == true) {
linkUrl = linkPrefix + wikEd.pageName + linkTitle;
Line 13,170 ⟶ 13,372:
}
// url provided
else {
// test for templates
if (/\{|\}/.test(linkUrl) == true) {
return('');
Line 13,206 ⟶ 13,408:
//
// wikEd.UpdateTextarea: copy frame content or provided text to textarea
//
wikEd.UpdateTextarea = function(text) {
var obj = {};
if (text != null) {
obj.html = text;
}
// get frame content, remove dynamically inserted nodes by other scripts
else {
wikEd.CleanNodes(wikEd.frameDocument);
obj.html = wikEd.frameBody.innerHTML;
}
// remove trailing blanks and newlines at end of text
obj.html = obj.html.replace(/((<br\b[^>]*>)|\s)+$/g, '');
// remove leading spaces in lines
obj.html = obj.html.replace(/(<br\b[^>]*>)\n* *()/g, '$1');
// textify so that no html formatting is submitted
wikEd.Textify(obj);
obj.plain = obj.plain.replace(/ | |\xa0/g, ' ');
Line 13,231 ⟶ 13,437:
obj.plain = obj.plain.replace(/&/g, '&');
// copy to textarea
wikEd.textarea.value = obj.plain;
// remember frame scroll position
wikEd.frameScrollTop = wikEd.frameBody.scrollTop;
Line 13,242 ⟶ 13,448:
//
// wikEd.UpdateFrame: copy textarea content or provided html to frame
//
wikEd.UpdateFrame = function(html) {
// get textarea content
var obj = {};
}
else {
obj.html = wikEd.textarea.value;
obj.html = obj.html.replace(/&/g, '&');
obj.html = obj.html.replace(/>/g, '>');
obj.html = obj.html.replace(/</g, '<');
}
// Opera 0.9.51
obj.html = obj.html.replace(/\r\n|\n\r|\r/g, '\n');
// highlight the syntax
if (wikEd.highlightSyntax == true) {
obj.whole = true;
Line 13,263 ⟶ 13,474:
}
// at least display tabs
else {
obj.html = obj.html.replace(/(\t)/g, '<span class="wikEdTabPlain">$1</span><!--wikEdTabPlain-->');
}
// multiple blanks to blank-
obj.html = obj.html.replace(/(^|\n) /g, '$1 ');
obj.html = obj.html.replace(/ (\n|$)/g, ' $1');
Line 13,274 ⟶ 13,485:
obj.html = obj.html.replace(/ {2}/g, ' ');
// newlines to <br>
obj.html = obj.html.replace(/\n/g, '<br>');
// select the whole text after replacing the whole text and scroll to same height
if (wikEd.msie == true) {
Line 13,286 ⟶ 13,497:
}
// insert content into empty frame
if ( (wikEd.frameBody.firstChild == null) || (/^<br[^>]*>\s*$/.test(wikEd.frameBody.innerHTML) == true) ) {
wikEd.frameBody.innerHTML = obj.html;
}
// insert content into frame, preserve history
else {
var range = wikEd.frameDocument.createRange();
Line 13,298 ⟶ 13,509:
obj.sel.addRange(range);
// replace the frame content with the new text, do not scroll
var scrollOffset = window.pageYOffset || document.body.scrollTop;
if (obj.html != '') {
Line 13,309 ⟶ 13,520:
wikEd.RemoveAllRanges(obj.sel);
// scroll to previous position
if (wikEd.frameScrollTop != null) {
wikEd.frameBody.scrollTop = wikEd.frameScrollTop;
Line 13,316 ⟶ 13,527:
wikEd.frameScrollTop = null;
// add event handlers and labels
if (wikEd.highlightSyntax == true) {
// name ref and template buttons
wikEd.HighlightNamedHideButtons();
// add event handlers to unhide refs and templates
wikEd.HideAddHandlers();
// add event handlers to make highlighted frame links ctrl-clickable
wikEd.LinkifyAddHandlers();
}
Line 13,340 ⟶ 13,551:
wikEd.KeyHandler = function(event) {
// event compatibility fixes
event = wikEd.EventWrapper(event, this);
if (event == null) {
Line 13,348 ⟶ 13,559:
if (wikEd.useWikEd == true) {
// trap enter in find/replace input elements
if ( (event.type == 'keydown') && (event.keyCode == 13) ) {
if (event.target.id == 'wikEdFindText') {
Line 13,378 ⟶ 13,589:
}
// detect emulated accesskeys
else if ( (event.shiftKey == true) && (event.ctrlKey == false) && (event.altKey == true) && (event.metaKey == false) ) {
// get wikEd button id from keycode
var buttonId = wikEd.buttonKeyCode[event.keyCode];
if (buttonId != null) {
Line 13,387 ⟶ 13,598:
event.stopPropagation();
// execute the button click handler code
var obj = document.getElementById(buttonId);
objId = obj.id;
Line 13,408 ⟶ 13,619:
}
// MSIE workaround, breaks the undo history
else if (command == 'inserthtml') {
wikEd.frameDocument.selection.createRange().pasteHTML(option);
Line 13,424 ⟶ 13,635:
if (wikEd.GetAttribute(wikEd.findAhead, 'checked') == 'true') {
// get the find text
var findText = wikEd.findText.value;
if (findText == '') {
Line 13,430 ⟶ 13,641:
}
// remember input field selection
var findTextSelectionStart = wikEd.findText.selectionStart;
var findTextSelectionEnd = wikEd.findText.selectionEnd;
// remember frame selection
var sel = wikEd.GetSelection();
var range = sel.getRangeAt(sel.rangeCount - 1).cloneRange();
Line 13,440 ⟶ 13,651:
var scrollTop = wikEd.frameBody.scrollTop;
// collapse selection to the left
wikEd.RemoveAllRanges(sel);
range.collapse(true);
range = sel.addRange(range);
// create obj for regexp search
var obj = {};
// get the replace text
var replaceText = wikEd.inputElement.replace.value;
// get insensitive and regexp button states
var regExpChecked = wikEd.GetAttribute(wikEd.regExp, 'checked');
var caseSensitiveChecked = wikEd.GetAttribute(wikEd.caseSensitive, 'checked');
// get case sensitive setting
var caseSensitive = false;
if (caseSensitiveChecked == 'true') {
Line 13,461 ⟶ 13,672:
}
// get regexp setting
var useRegExp = false;
if (regExpChecked == 'true') {
Line 13,467 ⟶ 13,678:
}
// parameters: obj, findText, caseSensitive, backwards, wrap, useRegExp
found = wikEd.Find(obj, findText, caseSensitive, false, true, useRegExp);
// restore original frame selection
if (found == false) {
wikEd.frameBody.scrollTop = scrollTop;
Line 13,480 ⟶ 13,691:
obj.sel.addRange(obj.changed.range);
// scroll to selection
wikEd.ScrollToSelection();
}
// restore input field selection (needed for FF 3.6)
wikEd.findText.select();
wikEd.findText.setSelectionRange(findTextSelectionStart, findTextSelectionEnd);
}
return;
};
Line 13,499 ⟶ 13,709:
wikEd.MainSwitch = function() {
// disable function if browser is incompatible
if (wikEd.browserNotSupported == true) {
return;
}
// enable wikEd
if (wikEd.disabled == true) {
wikEd.disabled = false;
wikEd.SetPersistent('wikEdDisabled', '0', 0, '/');
// turn rich text frame on
if (wikEd.turnedOn == false) {
// setup wikEd
wikEd.TurnOn(false);
}
Line 13,532 ⟶ 13,742:
}
// run scheduled custom functions
wikEd.ExecuteHook(wikEd.config.onHook);
}
}
// disable wikEd
else {
wikEd.SetPersistent('wikEdDisabled', '1', 0, '/');
Line 13,550 ⟶ 13,760:
}
// turn classic textarea on
if (wikEd.useWikEd == true) {
wikEd.UpdateTextarea();
Line 13,556 ⟶ 13,766:
wikEd.SetEditArea(false);
// reset textarea dimensions
wikEd.textarea.style.height = (wikEd.textareaOffsetHeightInitial - wikEd.frameBorderHeight) + 'px';
wikEd.textarea.style.width = '100%';
Line 13,577 ⟶ 13,787:
wikEd.SetLogo();
// run scheduled custom functions
wikEd.ExecuteHook(wikEd.config.offHook);
}
Line 13,591 ⟶ 13,801:
wikEd.FullScreen = function(fullscreen, notFrame) {
// hide or show elements
var displayStyle;
if (fullscreen == true) {
Line 13,600 ⟶ 13,810:
}
// elements above input wrapper
var node = document.getElementById('editform').previousSibling;
while (node != null) {
Line 13,610 ⟶ 13,820:
document.getElementsByTagName('h1')[0].style.display = displayStyle;
// divs below input wrapper
var node = wikEd.inputWrapper.nextSibling;
while (node != null) {
Line 13,619 ⟶ 13,829:
}
// divs below input wrapper, some levels up
var node = document.getElementById('column-one');
while (node != null) {
Line 13,628 ⟶ 13,838:
}
// insert wrapper
document.getElementById('wikEdInsertWrapper').style.display = displayStyle;
// change styles
if (fullscreen == true) {
if (notFrame != true) {
Line 13,645 ⟶ 13,855:
}
// resize the frame
if (fullscreen == true) {
// end frame resizing
wikEd.RemoveEventListener(wikEd.frameDocument, 'mouseup', wikEd.ResizeStopHandler, true);
wikEd.RemoveEventListener(document, 'mouseup', wikEd.ResizeStopHandler, true);
Line 13,675 ⟶ 13,885:
}
// scroll to edit-frame
if (fullscreen == false) {
window.scroll(0, wikEd.GetOffsetTop(wikEd.inputWrapper) - 2);
}
// set the fullscreen button state
wikEd.Button(document.getElementById('wikEdFullScreen'), 'wikEdFullScreen', null, fullscreen);
// grey out or re-activate scroll-to buttons
var hideButtonClass;
if (fullscreen == true) {
Line 13,696 ⟶ 13,906:
document.getElementById('wikEdScrollToEdit2').className = hideButtonClass;
// resize the summary field
wikEd.ResizeSummary();
Line 13,711 ⟶ 13,921:
wikEd.ResizeSummary = function() {
// check if combo field exists
if (wikEd.summarySelect == null) {
return;
Line 13,737 ⟶ 13,947:
wikEd.ResizeComboInput = function(field) {
// check if combo field exists
if (wikEd.selectElement[field] == null) {
return;
}
// detect browser for MS IE fixes
var standardBrowser = true;
if (wikEd.selectElement[field].options.offsetWidth != null ) {
Line 13,748 ⟶ 13,958:
}
// set select height and top
if (standardBrowser == false) {
wikEd.selectElement[field].style.height = (wikEd.inputElement[field].clientHeight + 6) + 'px';
Line 13,755 ⟶ 13,965:
}
// add a dummy option if no option exists yet
var dummy;
var testOption = 1;
Line 13,766 ⟶ 13,976:
}
// set option widths to 0
if (standardBrowser == true) {
for (var i = 0; i < wikEd.selectElement[field].options.length; i ++) {
Line 13,773 ⟶ 13,983:
}
// get input width
var inputBorder = (wikEd.inputElement[field].offsetWidth - wikEd.inputElement[field].clientWidth);
var inputWidthInner = wikEd.inputElement[field].clientWidth;
var inputWidthOuter = wikEd.inputElement[field].offsetWidth;
// get select width
var selectWidthInner = wikEd.selectElement[field].clientWidth;
var selectWidthOuter = wikEd.selectElement[field].offsetWidth;
// get option width and calculate button width
var optionWidthInner;
var buttonWidth;
if (standardBrowser == true) {
// Firefox < 3.0
if ( typeof(wikEd.selectElement[field].options[testOption].clientLeft) == 'undefined' ) {
optionWidthInner = wikEd.selectElement[field].options[testOption].clientWidth;
Line 13,793 ⟶ 14,003:
}
// Firefox >= 3.0
else {
optionWidthInner = wikEd.selectElement[field].options[testOption].clientWidth;
Line 13,803 ⟶ 14,013:
}
// for long fields shorten input
if (inputWidthOuter + buttonWidth > 150) {
wikEd.inputElement[field].style.width = (inputWidthInner - inputBorder - buttonWidth) + 'px';
Line 13,809 ⟶ 14,019:
}
// otherwise increase select width
else {
wikEd.selectElement[field].style.width = (inputWidthOuter + buttonWidth) + 'px';
}
// delete dummy option
if (dummy == true) {
wikEd.selectElement[field].options[0] = null;
}
// set option widths to auto
if (standardBrowser == true) {
for (var i = 0; i < wikEd.selectElement[field].options.length; i ++) {
Line 13,835 ⟶ 14,045:
wikEd.ChangeComboInput = function(field) {
// get selection index (-1 for unselected)
var selected = wikEd.selectElement[field].selectedIndex;
if (selected >= 0) {
wikEd.selectElement[field].selectedIndex = -1;
// get selected option
var option = wikEd.selectElement[field].options[selected];
if (option.text != '') {
// jump to heading
if ( (field == 'find') && (/^=.*?=$/.test(option.value) == true) ) {
var obj = {};
Line 13,850 ⟶ 14,060:
findText = '^' + findText + '$';
// find and select heading text
var found = wikEd.Find(obj, findText, true, false, true, true);
wikEd.RemoveAllRanges(obj.sel);
obj.sel.addRange(obj.changed.range);
// and scroll it into the viewport
wikEd.ScrollToSelection();
return;
}
// update input field
else {
// add a tag to the summary box
if (field == 'summary') {
wikEd.inputElement[field].value = wikEd.AppendToSummary(wikEd.inputElement[field].value, option.text);
}
// add case and regexp checkboxes to find / replace fields
else if (option.value == 'setcheck') {
wikEd.Button(document.getElementById('wikEdCaseSensitive'), 'wikEdCaseSensitive', null, (option.text.charAt(0) == wikEd.checkMarker[true]) );
Line 13,875 ⟶ 14,085:
}
// add option text
else {
wikEd.inputElement[field].value = option.text;
}
// find the new text
if ( (field == 'find') && (wikEd.GetAttribute(wikEd.findAhead, 'checked') == 'true') ) {
wikEd.FindAhead();
Line 13,932 ⟶ 14,142:
if (wikEd.inputElement[field].value != '') {
// load history from saved settings
wikEd.LoadHistoryFromSettings(field);
// add current value to history
wikEd.fieldHist[field].unshift(wikEd.inputElement[field].value);
// add case and regexp checkboxes to find / replace value
if ( (field == 'find') || (field == 'replace') ) {
wikEd.fieldHist[field][0] =
Line 13,946 ⟶ 14,156:
}
// remove paragraph names from summary
if (field == 'summary') {
wikEd.fieldHist[field][0] = wikEd.fieldHist[field][0].replace(/^\/\* .*? \*\/ *()/, '');
}
// remove multiple old copies from history
var i = 1;
while (i < wikEd.fieldHist[field].length) {
Line 13,962 ⟶ 14,172:
}
// remove new value if it is a preset value
if (wikEd.config.comboPresetOptions[field] != null) {
var i = 0;
Line 13,976 ⟶ 14,186:
}
// cut history number to maximal history length
wikEd.fieldHist[field] = wikEd.fieldHist[field].slice(0, wikEd.config.historyLength[field]);
// save history to settings
if (wikEd.fieldHist[field][0] != '') {
wikEd.SaveHistoryToSetting(field);
Line 13,994 ⟶ 14,204:
wikEd.SetComboOptions = function(field) {
// load history from saved settings
wikEd.LoadHistoryFromSettings(field);
Line 14,000 ⟶ 14,210:
var selectedOption = null;
// delete options
var options = wikEd.selectElement[field].options;
for (var i = 0; i < options.length; i ++) {
Line 14,006 ⟶ 14,216:
}
// delete optgroup
option = document.getElementById(field + 'Optgroup');
if (option != null) {
Line 14,012 ⟶ 14,222:
}
// workaround for onchange not firing when selecting first option from unselected dropdown
option = document.createElement('option');
option.style.display = 'none';
Line 14,018 ⟶ 14,228:
wikEd.selectElement[field].options[j++] = option;
// add history entries
for (var i = 0; i < wikEd.fieldHist[field].length; i ++) {
if (wikEd.fieldHist[field][i] != null) {
Line 14,026 ⟶ 14,236:
option = document.createElement('option');
// replace spaces with nbsp to allow for multiple, leading, and trailing spaces
option.text = wikEd.fieldHist[field][i].replace(/ /g, '\xa0');
if ( (field == 'find') || (field == 'replace') ) {
Line 14,035 ⟶ 14,245:
}
// add preset entries
var startPreset = 0;
if (wikEd.config.comboPresetOptions[field] != null) {
Line 14,042 ⟶ 14,252:
if (wikEd.config.comboPresetOptions[field][i] != null) {
// replace spaces with nbsp to allow for multiple, leading, and trailing spaces
wikEd.config.comboPresetOptions[field][i] = wikEd.config.comboPresetOptions[field][i].replace(/ /g, '\xa0');
// select a dropdown value
if (wikEd.config.comboPresetOptions[field][i] == wikEd.inputElement[field].value) {
selectedOption = j;
Line 14,060 ⟶ 14,270:
}
// set the selection
wikEd.selectElement[field].selectedIndex = selectedOption;
// add a blank preset separator
if ( (startPreset > 1) && (startPreset < j) ) {
option = document.createElement('optgroup');
Line 14,071 ⟶ 14,281:
}
// add the TOC jumper to the find field
var startTOC = 0;
if (field == 'find') {
startTOC = j;
// get the whole plain text
var plain = wikEd.frameBody.innerHTML;
plain = plain.replace(/<br\b[^>]*>/g, '\n');
Line 14,085 ⟶ 14,295:
plain = plain.replace(/&/g, '&');
// cycle through the headings
var heading = plain.match(/(^|\n)=+.+?=+[^\n=]*[ =\t]*(?=(\n|$))/g);
if (heading != null) {
Line 14,094 ⟶ 14,304:
headingIndent = headingIndent.replace(/\=/g, '\xa0');
// add headings to the select element
option = document.createElement('option');
option.text = '\u21d2' + headingIndent + headingMatch[3];
Line 14,103 ⟶ 14,313:
}
// add a blank TOC separator
if ( (startTOC > 1) && (startTOC < j) ) {
option = document.createElement('optgroup');
Line 14,166 ⟶ 14,376:
wikEd.GetSelection = function() {
// standard
var sel;
if (typeof(wikEd.frameWindow.getSelection) == 'function') {
Line 14,172 ⟶ 14,382:
}
// MS IE compatibility
else if (typeof(wikEd.frameDocument.selection) == 'object') {
sel = wikEd.frameDocument.selection;
}
// make sure there is at least an empty range
if (sel.rangeCount == 0) {
sel.collapse(wikEd.frameBody, 0);
Line 14,196 ⟶ 14,406:
}
// MS IE compatibility
else if (typeof(sel.empty) == 'function') {
sel.empty();
Line 14,228 ⟶ 14,438:
if (startNode.nodeName == '#text') {
range.setStart(startNode, startOffset);
}
else if (startNode.childNodes.length == 0) {
range.setStart(startNode, 0);
}
else {
Line 14,248 ⟶ 14,461:
if (endNode.nodeName == '#text') {
range.setEnd(endNode, endOffset);
}
else if (endNode.childNodes.length == 0) {
///// range.setEndBefore(endNode);
range.setEnd(endNode, 0);
}
else {
Line 14,284 ⟶ 14,501:
var getStr = '';
// check for web storage
wikEd.DetectWebStorage();
// get a value from web storage
if (wikEd.webStorage == true) {
getStr = window.localStorage.getItem(name);
}
// get a Greasemonkey persistent value
else if (wikEd.greasemonkey == true) {
getStr = GM_getValue(name, '');
}
// get a cookie value
else {
getStr = wikEd.GetCookie(name);
Line 14,313 ⟶ 14,528:
wikEd.SetPersistent = function(name, value, expires, path, ___domain, secure) {
// check for web storage
wikEd.DetectWebStorage();
// set a value in web storage
if (wikEd.webStorage == true) {
if (expires == -1) {
Line 14,325 ⟶ 14,538:
window.localStorage.setItem(name, value);
}
// set a Greasemonkey persistent value
else if (wikEd.greasemonkey == true) {
if (expires == -1) {
Line 14,332 ⟶ 14,545:
}
// see http://wiki.greasespot.net/Greasemonkey_access_violation
setTimeout(function() {
GM_setValue(name, value);
Line 14,338 ⟶ 14,551:
}
// set a cookie value
else {
wikEd.SetCookie(name, value, expires, path, ___domain, secure);
}
return;
};
//
// wikEd.DetectWebStorage: detect if local storage is available (code copied to wikEdDiff.js)
//
wikEd.DetectWebStorage = function() {
if (wikEd.webStorage == null) {
wikEd.webStorage = false;
if (typeof(window.localStorage) == 'object') {
// web storage does not persist between local html page loads in firefox
if (/^file:\/\//.test(wikEd.pageOrigin) == false) {
wikEd.webStorage = true;
}
}
}
return;
Line 14,382 ⟶ 14,615:
if (expires != null) {
// generate a date 1 hour ago to delete the cookie
if (expires == -1) {
var cookieExpire = new Date();
Line 14,389 ⟶ 14,622:
}
// get date from expiration preset
else if (expires == 0) {
var cookieExpire = new Date();
Line 14,464 ⟶ 14,697:
}
// remove Web of Trust (WOT) tags
var divs = node.getElementsByTagName('div');
for (var i = 0; i < divs.length; i ++) {
var div = divs[i];
// test for WOT class names
var divClass = div.className;
if (/^wot-/.test(divClass) == true) {
Line 14,479 ⟶ 14,712:
}
// test for WOT attributes
var divAttrs = div.attributes;
for (var j = 0; j < divAttrs.length; ++ j) {
Line 14,515 ⟶ 14,748:
wikEd.ParseDOMRecursive(obj, topNode, anchorNode, anchorOffset, focusNode, focusOffset);
obj.plain = obj.plainArray.join('');
obj.plain = obj.plain.replace(/\xa0/g, ' ');
return;
};
Line 14,525 ⟶ 14,759:
wikEd.ParseDOMRecursive = function(obj, currentNode, anchorNode, anchorOffset, focusNode, focusOffset) {
// cycle through the child nodes of currentNode
var childNodes = currentNode.childNodes;
for (var i = 0; i < childNodes.length; i ++) {
var childNode = childNodes.item(i);
// check for selection, non-text nodes
if ( (currentNode == anchorNode) && (i == anchorOffset) ) {
obj.plainAnchor = obj.plainLength;
Line 14,538 ⟶ 14,772:
}
// check for selection, text nodes
if (childNode == obj.sel.anchorNode) {
obj.plainAnchor = obj.plainLength + obj.sel.anchorOffset;
Line 14,546 ⟶ 14,780:
}
// get text of child node
var value = null;
switch (childNode.nodeType) {
case childNode.ELEMENT_NODE:
// skip hidden elements
if (wikEd.GetStyle(childNode, 'display') == 'none') {
continue;
Line 14,573 ⟶ 14,807:
}
// add text to text object
if (value != null) {
// array of text fragments
obj.plainArray.push(value);
// array of text fragment node references
obj.plainNode.push(childNode);
// array of text fragment text positions
obj.plainStart.push(obj.plainLength);
// node references containing text positions
obj.plainPos[childNode] = obj.plainLength;
// current text length
obj.plainLength += value.length;
}
Line 14,602 ⟶ 14,836:
wikEd.GetInnerHTML = function(obj, currentNode) {
// initialize string
if (obj.html == null) {
obj.html = '';
Line 14,680 ⟶ 14,914:
wikEd.GetNextTextNode = function(obj, currentNode, currentLevel) {
// ascend until there is a sibling
while (currentNode != wikEd.frameBody) {
// check for sibling
var nextNode = null;
if ( (obj.backwards == true) && (currentNode.previousSibling != null) ) {
Line 14,692 ⟶ 14,926:
}
// found sibling
if (nextNode != null) {
currentNode = nextNode;
// found text-like node
if (
(currentNode.nodeName == '#text') ||
Line 14,707 ⟶ 14,941:
}
// recurse into child nodes
if ( (currentNode.nodeType == currentNode.ELEMENT_NODE) && (/wikEd.scroll(Before|After)/.test(currentNode.className) != true) ) {
wikEd.GetNextTextNodeChilds(obj, currentNode, currentLevel - 1);
Line 14,716 ⟶ 14,950:
}
// no sibling, ascend to parent
else {
currentNode = currentNode.parentNode;
Line 14,730 ⟶ 14,964:
wikEd.GetNextTextNodeChilds = function(obj, currentNode, currentLevel) {
// set direction
var childNodes = currentNode.childNodes;
if (childNodes.length == 0) {
Line 14,742 ⟶ 14,976:
}
// cycle through child nodes (left or right)
for (var i = start; ( (obj.backwards == true) && (i >= 0) ) || ( (obj.backwards != true) && (i < childNodes.length) ); i = i + add) {
var currentNode = childNodes.item(i);
// found text-like node
if (
(currentNode.nodeName == '#text') ||
Line 14,757 ⟶ 14,991:
}
// recurse into child nodes
if ( (currentNode.nodeType == currentNode.ELEMENT_NODE) && (/wikEd.scroll(Before|After)/.test(currentNode.className) != true) ) {
wikEd.GetNextTextNodeChilds(obj, currentNode, currentLevel - 1);
Line 14,781 ⟶ 15,015:
var ruleStyle = cssRules[ruleName];
// replace {wikedImage:image} in css rules with image path
ruleStyle = ruleStyle.replace(/\{wikEdImage:(\w+)\}/g,
function (p, p1) {
Line 14,788 ⟶ 15,022:
);
// replace {wikedText:text} in css rules with translation
ruleStyle = ruleStyle.replace(/\{wikEdText:(\w+)\}/g,
function (p, p1) {
Line 14,814 ⟶ 15,048:
this.styleElement = null;
// MS IE compatibility
if (contextObj.createStyleSheet) {
this.styleElement = contextObj.createStyleSheet();
}
// standards compliant browsers
else {
this.styleElement = contextObj.createElement('style');
Line 14,836 ⟶ 15,070:
this.AddCSSRule = function(selector, declaration) {
// MS IE compatibility
if (this.styleElement.addRule != null) {
if (declaration.length > 0) {
Line 14,843 ⟶ 15,077:
}
// standards compliant browsers
else {
if (this.styleElement.sheet != null) {
Line 14,860 ⟶ 15,094:
this.AddCSSRules = function(rules) {
// MS IE compatibility
if (this.styleElement.innerHTML == null) {
this.styleElement.cssText = rules;
}
// Safari, Chrome, WebKit
else if ( (wikEd.safari == true) || (wikEd.chrome == true) || (wikEd.webkit == true) ) {
if (this.styleElement.firstChild != null) {
Line 14,873 ⟶ 15,107:
}
// via innerHTML
else {
this.styleElement.innerHTML = rules;
Line 14,896 ⟶ 15,130:
}
// MS IE compatibility
else if (element.currentStyle != null) {
style = element.currentStyle[styleProperty];
// recurse up trough the DOM tree
if (style == 'inherit') {
style = wikEd.GetStyle(element.parentNode, styleProperty);
Line 14,919 ⟶ 15,153:
wikEd.AjaxPreview = function(textValue, ResponseHandler, livePreview) {
// prepare the url
var requestUrl;
if ( (wikEd.uploadEdit != true) && (wikEd.watchlistEdit != true) && (wikEd.viewDeleted != true) ) {
Line 14,936 ⟶ 15,170:
}
// prepare the form fields
var postFields = {};
if ( (wikEd.pageName != null) && (wikEd.wikiGlobals.wgCanonicalNamespace != 'Special') ) {
Line 14,965 ⟶ 15,199:
}
// make the ajax request
wikEd.AjaxRequest('POST', requestUrl, postFields, 'text/plain', ResponseHandler);
Line 14,982 ⟶ 15,216:
var formData;
// prepare POST request
if (requestMethod == 'POST') {
// assemble string body
if (typeof(FormData) != 'function') {
// create boundary
var boundary = wikEd.CreateRandomString(12);
// POST header, charset: WebKit workaround http://aautar.digital-radiation.com/blog/?p=1645
headers['Content-Type'] = 'multipart/form-data; charset=UTF-8; boundary=' + boundary;
// assemble body data
formData = '';
for (var fieldName in postFields) {
Line 15,005 ⟶ 15,239:
}
// use FormData object
else {
formData = new FormData();
Line 15,016 ⟶ 15,250:
}
// send the request using Greasemonkey GM_xmlhttpRequest
if (wikEd.greasemonkey == true) {
headers['User-Agent'] = navigator.userAgent;
// workaround for Error: Greasemonkey access violation: unsafeWindow cannot call GM_xmlhttpRequest.
// see http://wiki.greasespot.net/Greasemonkey_access_violation
setTimeout(function() {
new GM_xmlhttpRequest({
Line 15,041 ⟶ 15,275:
}
// use standard XMLHttpRequest
else {
// allow ajax request from local copy for testing
if (wikEd.config.allowLocalAjax == true) {
if (typeof(netscape) == 'object') {
Line 15,051 ⟶ 15,285:
}
// create new XMLHttpRequest object
if (typeof(XMLHttpRequest) == 'function') {
request = new XMLHttpRequest();
}
// IE
else if (typeof(ActiveXObject) == 'object') {
// IE 6
try {
request = new ActiveXObject('Microsoft.XMLHTTP');
}
// IE 5.5
catch(err) {
try {
Line 15,078 ⟶ 15,312:
}
// open the request
request.open(requestMethod, requestUrl, true);
// set the headers
for (var headerName in headers) {
if (headers.hasOwnProperty(headerName) == true) {
Line 15,088 ⟶ 15,322:
}
// set the mime type
if ( (request.overrideMimeType != null) && (overrideMimeType != null) ) {
request.overrideMimeType(overrideMimeType);
}
// send the request, catch security violations Opera 0.9.51
try {
request.send(formData);
Line 15,101 ⟶ 15,335:
}
// wait for the data
request.onreadystatechange = function() {
if (request.readyState != 4) {
Line 15,124 ⟶ 15,358:
}
// code already running in global context
if (wikEd.greasemonkey != true) {
var globalScopeCode = '';
Line 15,140 ⟶ 15,374:
}
// prepare code to be executed in global context for Greasemonkey
if ( (typeof(window.postMessage) == 'undefined') || (typeof(JSON) != 'object') ) {
return;
Line 15,152 ⟶ 15,386:
globalScopeCode += 'globalObj.wikEdGetGlobals = {};';
// add global scope variables
for (var i = 0; i < names.length; i ++) {
globalScopeCode += ''
Line 15,166 ⟶ 15,400:
globalScopeCode += 'window.postMessage(globalObjStr, \'' + origin + '\');';
// create head script to execute the code
var script = document.createElement('script');
script.id = 'wikEdGetGlobalScript' + wikEd.getGlobalsCounter;
Line 15,204 ⟶ 15,438:
}
// run scheduled functions only once
if (globalObj.hookNumber != null) {
wikEd.ExecuteHook(wikEd.gotGlobalsHook[globalObj.hookNumber], true);
}
// clean up head script
var script = document.getElementById(globalObj.scriptId);
wikEd.head.removeChild(script);
Line 15,226 ⟶ 15,460:
var attribValue = element.getAttribute(attribName);
// MS IE compatibility for checked
if (attribName == 'checked') {
if ( typeof(attribValue) == 'boolean' ) {
Line 15,365 ⟶ 15,599:
}
// avoid strange Mozilla security error https://bugzilla.mozilla.org/show_bug.cgi?id=101197, fixed in FF3.6
if ( (event.type == 'mouseout') || (event.type == 'mouseover') ) {
event.safeRelatedTarget = event.relatedTarget;
Line 15,391 ⟶ 15,625:
}
// new browsers
var nodeList = [];
if (document.getElementsByClassName != null) {
Line 15,397 ⟶ 15,631:
}
// querySelector (IE8 standards mode)
else if (parent.querySelectorAll != null) {
nodeList = parent.querySelectorAll(tagName + '.' + className);
}
// all others (slow)
else {
var tags = parent.getElementsByTagName(tagName);
Line 15,506 ⟶ 15,740:
wikEd.Debug = function(objectName, object, usePopup) {
// string
var value = '';
if (typeof(object) == 'string') {
Line 15,512 ⟶ 15,746:
}
// objects
else if (typeof(object) == 'object') {
// null
if (object == null) {
value = ': [null]';
}
// whole parse tree array
// { 'tag': , 'parent': , 'firstChild': , 'nextSibling': , 'start': , 'tagLength': , 'type': , 'pairedTagPos': , 'left': , 'right': , 'index': }
else if ( (typeof(object[0]) == 'object') && (typeof(object[0].type) == 'string') ) {
value = ': Parse tree full:\n';
Line 15,545 ⟶ 15,779:
}
// whole parse tree up
else if ( (typeof(object.tree) == 'object') && (typeof(object.lastOpenNode) == 'number') ) {
value = ': Parse tree upwards:\n';
Line 15,570 ⟶ 15,804:
}
// parse tree node
// { 'tag': , 'parent': , 'firstChild': , 'nextSibling': , 'start': , 'tagLength': , 'type': , 'pairedTagPos': , 'left': , 'right': , 'index': }
else if (typeof(object.type) == 'string') {
var node = object;
Line 15,582 ⟶ 15,816:
}
// DOM nodes
else if (typeof(object.nodeName) == 'string') {
value = ': [node; nodeName: ' + object.nodeName;
Line 15,608 ⟶ 15,842:
}
// default
else {
value = ': [' + object + ']';
Line 15,614 ⟶ 15,848:
}
// undefined
else if (typeof(object) == 'undefined') {
value = '';
}
// default
else {
value = ': ' + object;
}
// use debug textarea
var useDebug = false;
if (typeof(wikEd.debug) != 'undefined') {
Line 15,643 ⟶ 15,877:
else {
// cut text if having reached maximum length
value = objectName + value + '\n';
if (wikEd.debug.value.length > wikEd.config.debugMaxLength) {
Line 15,654 ⟶ 15,888:
}
// use popup alert
else if (usePopup == true) {
if (object == null) {
Line 15,664 ⟶ 15,898:
}
// use error console
else {
var msg;
Line 15,673 ⟶ 15,907:
msg = objectName + ': ' + value;
}
wikEd.ConsoleLog(msg);
}
return;
};
//
// wikEd.ConsoleLog: log message to console
//
wikEd.ConsoleLog = function(msg) {
if ( (typeof(mw) == 'object') && (typeof(mw.log) == 'function') ) {
mw.log(msg);
}
else {
msg = msg.replace(/([\'\\])/g, '\\$1');
setTimeout('throw new Error(\'wikEd.ConsoleLog: ' + msg + '\')', 0);
}
return;
Line 15,757 ⟶ 16,007:
wikEd.InitUnicode = function() {
// define only once
if (wikEd.supportedChars != null) {
return;
}
// supported chars in Mozilla and IE
wikEd.supportedChars = [
[ 'a1', 'iexcl'], // ¡
Line 15,982 ⟶ 16,232:
];
// reserved for internal wikEd use
wikEd.reservedChars = [
[ '26', 'amp'], // &
Line 15,990 ⟶ 16,240:
];
// special chars (spaces and invisible characters)
wikEd.specialChars = [
['2002', 'ensp'], // en space
Line 16,002 ⟶ 16,252:
];
// unsupported chars in IE6
wikEd.problemChars = [
[ '3d1', 'thetasym'], // ϑ
Line 16,032 ⟶ 16,282:
// index to all existing 253 HTML/XHTML character entities
var allCharEntities = wikEd.supportedChars.concat(wikEd.reservedChars, wikEd.specialChars, wikEd.problemChars);
for (var i = 0; i < allCharEntities.length; i ++) {
Line 16,038 ⟶ 16,288:
}
// syntax highlighting of ASCII control characters and invisibles (decimal value, title)
wikEd.controlCharHighlighting = {
'0': 'null',
Line 16,082 ⟶ 16,332:
}
// character syntax highlighting: strange spaces, hyphens, and dashes (decimal value, class = title)
wikEd.charHighlighting = {
'9': 'tab', // \u0009 ' '
Line 16,103 ⟶ 16,353:
}
// UniCode support for regexps, from http://xregexp.com/plugins/xregexp-unicode-base.js and /xregexp-unicode-categories.js
wikEd.letters = '0041-005A0061-007A00AA00B500BA00C0-00D600D8-00F600F8-02C102C6-02D102E0-02E402EC02EE0370-037403760377037A-037D03860388-038A038C038E-03A103A3-03F503F7-0481048A-05250531-055605590561-058705D0-05EA05F0-05F20621-064A066E066F0671-06D306D506E506E606EE06EF06FA-06FC06FF07100712-072F074D-07A507B107CA-07EA07F407F507FA0800-0815081A082408280904-0939093D09500958-0961097109720979-097F0985-098C098F09900993-09A809AA-09B009B209B6-09B909BD09CE09DC09DD09DF-09E109F009F10A05-0A0A0A0F0A100A13-0A280A2A-0A300A320A330A350A360A380A390A59-0A5C0A5E0A72-0A740A85-0A8D0A8F-0A910A93-0AA80AAA-0AB00AB20AB30AB5-0AB90ABD0AD00AE00AE10B05-0B0C0B0F0B100B13-0B280B2A-0B300B320B330B35-0B390B3D0B5C0B5D0B5F-0B610B710B830B85-0B8A0B8E-0B900B92-0B950B990B9A0B9C0B9E0B9F0BA30BA40BA8-0BAA0BAE-0BB90BD00C05-0C0C0C0E-0C100C12-0C280C2A-0C330C35-0C390C3D0C580C590C600C610C85-0C8C0C8E-0C900C92-0CA80CAA-0CB30CB5-0CB90CBD0CDE0CE00CE10D05-0D0C0D0E-0D100D12-0D280D2A-0D390D3D0D600D610D7A-0D7F0D85-0D960D9A-0DB10DB3-0DBB0DBD0DC0-0DC60E01-0E300E320E330E40-0E460E810E820E840E870E880E8A0E8D0E94-0E970E99-0E9F0EA1-0EA30EA50EA70EAA0EAB0EAD-0EB00EB20EB30EBD0EC0-0EC40EC60EDC0EDD0F000F40-0F470F49-0F6C0F88-0F8B1000-102A103F1050-1055105A-105D106110651066106E-10701075-1081108E10A0-10C510D0-10FA10FC1100-1248124A-124D1250-12561258125A-125D1260-1288128A-128D1290-12B012B2-12B512B8-12BE12C012C2-12C512C8-12D612D8-13101312-13151318-135A1380-138F13A0-13F41401-166C166F-167F1681-169A16A0-16EA1700-170C170E-17111720-17311740-17511760-176C176E-17701780-17B317D717DC1820-18771880-18A818AA18B0-18F51900-191C1950-196D1970-19741980-19AB19C1-19C71A00-1A161A20-1A541AA71B05-1B331B45-1B4B1B83-1BA01BAE1BAF1C00-1C231C4D-1C4F1C5A-1C7D1CE9-1CEC1CEE-1CF11D00-1DBF1E00-1F151F18-1F1D1F20-1F451F48-1F4D1F50-1F571F591F5B1F5D1F5F-1F7D1F80-1FB41FB6-1FBC1FBE1FC2-1FC41FC6-1FCC1FD0-1FD31FD6-1FDB1FE0-1FEC1FF2-1FF41FF6-1FFC2071207F2090-209421022107210A-211321152119-211D212421262128212A-212D212F-2139213C-213F2145-2149214E218321842C00-2C2E2C30-2C5E2C60-2CE42CEB-2CEE2D00-2D252D30-2D652D6F2D80-2D962DA0-2DA62DA8-2DAE2DB0-2DB62DB8-2DBE2DC0-2DC62DC8-2DCE2DD0-2DD62DD8-2DDE2E2F300530063031-3035303B303C3041-3096309D-309F30A1-30FA30FC-30FF3105-312D3131-318E31A0-31B731F0-31FF3400-4DB54E00-9FCBA000-A48CA4D0-A4FDA500-A60CA610-A61FA62AA62BA640-A65FA662-A66EA67F-A697A6A0-A6E5A717-A71FA722-A788A78BA78CA7FB-A801A803-A805A807-A80AA80C-A822A840-A873A882-A8B3A8F2-A8F7A8FBA90A-A925A930-A946A960-A97CA984-A9B2A9CFAA00-AA28AA40-AA42AA44-AA4BAA60-AA76AA7AAA80-AAAFAAB1AAB5AAB6AAB9-AABDAAC0AAC2AADB-AADDABC0-ABE2AC00-D7A3D7B0-D7C6D7CB-D7FBF900-FA2DFA30-FA6DFA70-FAD9FB00-FB06FB13-FB17FB1DFB1F-FB28FB2A-FB36FB38-FB3CFB3EFB40FB41FB43FB44FB46-FBB1FBD3-FD3DFD50-FD8FFD92-FDC7FDF0-FDFBFE70-FE74FE76-FEFCFF21-FF3AFF41-FF5AFF66-FFBEFFC2-FFC7FFCA-FFCFFFD2-FFD7FFDA-FFDC'.replace(/(\w{4})/g, '\\u$1');
|