User:MoreThings/Sandbox

//

// version info window.wikEdProgramVersion = window.wikEdProgramVersion || '0.9.77'; window.wikEdProgramDate   = window.wikEdProgramDate    || 'April 1, 2009';

/*

Program description and Greasemonkey metadata

wikEd is a full-featured JavaScript in-browser editor for Wikipedia and other MediaWiki edit pages. The program works currently ONLY for Mozilla, Firefox, SeaMonkey, Safari, and Chrome browsers. The code has to be saved as UTF-8 in your editor to preserve Unicode characters like ♥ (heart)

// ==UserScript== // @name       wikEd // @namespace  http://en.wikipedia.org/wiki/User:Cacycle/ // @description A full-featured in-browser editor for Wikipedia and other MediaWiki edit pages // @include    * // @exclude // // @homepage   http://en.wikipedia.org/wiki/User:Cacycle/wikEd // @source     http://en.wikipedia.org/wiki/User:Cacycle/wikEd.js // @author      Cacycle (http://en.wikipedia.org/wiki/User:Cacycle) // @license    Released into the public domain // ==/UserScript==

Installation on a MediaWiki wiki (using monobook.js)
1. PLEASE DO NOT COPY THE WHOLE PROGRAM (in order to get the frequent updates and bug fixes and to save disk space) 2. See http://en.wikipedia.org/wiki/User:Cacycle/wikEd for more detailed instructions 3. Copy the following short block of code to User:YOURUSERNAME/monobook.js 4. Click SHIFT-Reload to update to the newest version

// START wikEd INSTALLATION CODE

// install User:Cacycle/wikEd in-browser text editor document.write(' ');

// END wikEd INSTALLATION CODE

General installation for all MediaWiki wikis (using Greasemonkey)
1. Install Greasemonkey for Firefox from: https://addons.mozilla.org/en-US/firefox/addon/748 2. Install wikEd by opening this address: http://en.wikipedia.org/w/index.php?action=raw&ctype=text/javascript&title=User:Cacycle/wikEd.user.js



// // WikEdInitGlobalsConfigs: initialize user configurable variables //

window.WikEdInitGlobalConfigs = 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(wikEdText) == 'undefined') { window.wikEdText = {}; }

// // WikEdInitText: define built-in user interface texts //

window.WikEdInitText = function { WikEdInitObject(wikEdText, {

// logo 'wikEdLogo alt':              'wikEd', 'wikEdLogo title':            'wikEd {wikEdProgramVersion} ({wikEdProgramDate}) Click to disable', 'wikEdLogo error alt':        'wikEd error', 'wikEdLogo error title':      'Loading error - wikEd {wikEdProgramVersion} ({wikEdProgramDate}) Click to disable', 'wikEdLogo browser alt':      '(wikEd)', 'wikEdLogo browser title':    'Browser not supported - wikEd {wikEdProgramVersion} ({wikEdProgramDate})', 'wikEdLogo disabled alt':     '(wikEd)', 'wikEdLogo disabled title':   'Disabled - wikEd {wikEdProgramVersion} ({wikEdProgramDate}) Click to enable',

// top jumper 'wikEdScrollToEdit4 alt':     'Scroll to edit', 'wikEdScrollToEdit4 title':   'Scroll to edit field',

// button bar grip titles 'wikEdGripFormat title':      'Formatting buttons (click to hide or show)', 'wikEdGripTextify title':     'Textify and wikify buttons (click to hide or show)', 'wikEdGripCustom1 title':     'Custom buttons (click to hide or show)', 'wikEdGripFind title':        'Find buttons (click to hide or show)', 'wikEdGripFix title':         'Fixing buttons (click to hide or show)', 'wikEdGripCustom2 title':     'Custom buttons (click to hide or show)', 'wikEdGripControl title':     'wikEd control buttons (click to hide or show)',

// formatting buttons, top row 'wikEdUndo alt':              'Undo', 'wikEdUndo title':            'Undo', 'wikEdRedo alt':              'Redo', 'wikEdRedo title':            'Redo', 'wikEdBold alt':              'Bold', 'wikEdBold title':            'Bold text', 'wikEdItalic alt':            'Italic', 'wikEdItalic title':          'Italic text', 'wikEdUnderline alt':         'Underline', 'wikEdUnderline title':       'Underline text', 'wikEdStrikethrough alt':     'Strikethrough', 'wikEdStrikethrough title':   'Strikethrough text', 'wikEdNowiki alt':            'Nowiki', 'wikEdNowiki title':          'Nowiki markup text', 'wikEdSuperscript alt':       'Superscript', 'wikEdSuperscript title':     'Superscript text', 'wikEdSubscript alt':         'Subscript', 'wikEdSubscript title':       'Subscript text', 'wikEdRef alt':               'Ref', 'wikEdRef title':             'In-text reference (shift-click: named tag)', 'wikEdCase alt':              'Case', 'wikEdCase title':            'Toggle between lowercase, uppercase first, and uppercase', 'wikEdSort alt':              'Sort', 'wikEdSort title':            'Sort lines alphabetically', 'wikEdRedirect alt':          'Redirect', 'wikEdRedirect title':        'Create redirect, deletes whole text', 'wikEdUndoAll alt':           'Undo all', 'wikEdUndoAll title':         'Undo all changes', 'wikEdRedoAll alt':           'Redo all', 'wikEdRedoAll title':         'Redo all changes',

// formatting buttons, bottom row 'wikEdWikiLink alt':          'Link', 'wikEdWikiLink title':        'Wiki link', 'wikEdWebLink alt':           'Weblink', 'wikEdWebLink title':         'External weblink', 'wikEdHeading alt':           'Heading', 'wikEdHeading title':         'Increase heading levels (shift-click: decrease)', 'wikEdBulletList alt':        'Bullet list', 'wikEdBulletList title':      'Increase bulleted list level (shift-click: decrease)', 'wikEdNumberList alt':        'Number list', 'wikEdNumberList title':      'Increase numbered list level (shift-click: decrease)', 'wikEdIndentList alt':        'Indent list', 'wikEdIndentList title':      'Increase indention (shift-click: decrease)', 'wikEdDefinitionList alt':    'Def list', 'wikEdDefinitionList title':  'Definition list', 'wikEdImage alt':             'Image', 'wikEdImage title':           'Image', 'wikEdTable alt':             'Table', 'wikEdTable title':           'Table', 'wikEdReferences alt':        'References', 'wikEdReferences title':      'References location (shift-click: References section)',

// textify buttons 'wikEdWikify alt':            'Wikify', 'wikEdWikify title':          'Convert pasted content to wiki code, update highlighting', 'wikEdTextify alt':           'Textify', 'wikEdTextify title':         'Convert pasted content to plain text, update highlighting',

// find and replace buttons, top row 'wikEdFindAll alt':           'Find all', 'wikEdFindAll title':         'Find all matches', 'wikEdFindPrev alt':          'Find prev', 'wikEdFindPrev title':        'Find previous match', 'wikEdFindSelect title':      'Select a previous search or jump to a heading', 'wikEdFindNext alt':          'Find next', 'wikEdFindNext title':        'Find next match (shift-click: get selection)', 'wikEdJumpPrev alt':          'Selected prev', 'wikEdJumpPrev title':        'Find the selected text backwards', 'wikEdJumpNext alt':          'Selected next', 'wikEdJumpNext title':        'Find the selected text forwards',

// find and replace buttons, bottom row 'wikEdReplaceAll alt':        'Replace all', 'wikEdReplaceAll title':      'Replace all matches in whole text or selection', 'wikEdReplacePrev alt':       'Replace prev', 'wikEdReplacePrev title':     'Replace previous match', 'wikEdReplaceSelect title':   'Select a previous replacement', 'wikEdReplaceNext alt':       'Replace next (shift-click: get selection)', 'wikEdReplaceNext title':     'Replace next match', 'wikEdCaseSensitive alt':     'Case sensitive', 'wikEdCaseSensitive title':   'Search is case sensitive', 'wikEdRegExp alt':            'RegExp', 'wikEdRegExp title':          'Search field is a regular expression', 'wikEdFindAhead alt':         'Find ahead', 'wikEdFindAhead title':       'Find ahead as you type (case-insensitive non-regexp search)',

// fix buttons, top row 'wikEdFixBasic alt':          'Fix basic', 'wikEdFixBasic title':        'Fix blanks and empty lines, also done by other fixing functions', 'wikEdFixHtml alt':           'Fix html', 'wikEdFixHtml title':         'Fix html to wikicode', 'wikEdFixCaps alt':           'Fix caps', 'wikEdFixCaps title':         'Fix caps in headers and lists', 'wikEdFixUnicode alt':        'Fix Unicode', 'wikEdFixUnicode title':      'Fix Unicode character representations', 'wikEdFixAll alt':            'Fix all', 'wikEdFixAll title':          'Fix basic, html, capitalization, and Unicode', 'wikEdFixRedirect alt':       'Fix redirects', 'wikEdFixRedirect title':     'Fix redirects',

// fix buttons, bottom row 'wikEdFixDashes alt':         'Fix dashes', 'wikEdFixDashes title':       'Fix dashes', 'wikEdFixPunct alt':          'Fix punctuation', 'wikEdFixPunct title':        'Fix spaces before punctuation', 'wikEdFixMath alt':           'Fix math', 'wikEdFixMath title':         'Fix math', 'wikEdFixChem alt':           'Fix chem', 'wikEdFixChem title':         'Fix chemical formulas', 'wikEdFixUnits alt':          'Fix units', 'wikEdFixUnits title':        'Fix units', 'wikEdFixRegExTypo alt':      'Fix typos', 'wikEdFixRegExTypo title':    'Fix typos using the AutoWikiBrowser RegExTypoFixer rules',

// wikEd control buttons, top row 'wikEdRefHide alt':           'Hide ', 'wikEdRefHide title':         'Toggle tag hiding', 'wikEdTextZoom alt':          'Text zoom', 'wikEdTextZoom title':        'Text zoom cycling (shift-click: reverse)', 'wikEdClearHistory alt':      'Clear history', 'wikEdClearHistory title':    'Clear the find, replace, and summary history', 'wikEdScrollToPreview alt':   'Scroll to preview', 'wikEdScrollToPreview title': 'Scroll to preview field', 'wikEdScrollToEdit alt':      'Scroll to edit', 'wikEdScrollToEdit title':    'Scroll to edit field',

// wikEd control buttons, bottom row 'wikEdUseWikEd alt':          'Use wikEd', 'wikEdUseWikEd title':        'Toggle between classic text area and wikEd', 'wikEdHighlightSyntax alt':   'Syntax', 'wikEdHighlightSyntax title': 'Toggle automatic syntax highlighting', 'wikEdSource alt':            'Source', 'wikEdCloseToolbar title':    'Close the standard non-wikEd toolbar', 'wikEdCloseToolbar alt':      'Close toolbar', 'wikEdSource title':          'Show the source code for testing purposes', 'wikEdUsing alt':             'Using', 'wikEdUsing title':           'Automatically add \'\'…using wikEd\'\' to summaries', 'wikEdDiff alt':              'wikEdDiff', 'wikEdDiff title':            'Toggle automatic improved diff view', 'wikEdFullScreen alt':        'Fullscreen', 'wikEdFullScreen title':      'Toggle the fullscreen mode', 'wikEdTableMode alt':         'Table mode', 'wikEdTableMode title':       'Toggle table edit mode',

// summary buttons 'wikEdClearSummary alt':      'Clear summary', 'wikEdClearSummary title':    'Clear the summary field', 'wikEdSummarySelect title':   'Select a previous summary', 'wikEdPresetSummary': [ '/* */ ', 'copyedit', 'reply', 'article created', 'intro rewrite', 'linkfix', 'fixing typos', 'removing linkspam', 'reverting test', 'reverting vandalism', 'formatting source text', '{wikEdUsing}' ],			'wikEdSummaryUsing':          '…using wikEd',

// button title acceskey 'alt-shift':                  'alt-shift-',

// submit buttons 'wikEdLocalPreviewImg alt':   'Preview below', 'wikEdLocalPreview title':    'Show preview below', 'wikEdLocalDiffImg alt':      'Changes below', 'wikEdLocalDiff title':       'Show current changes below', 'wikEdHelpPageLink':          ' | wikEd help',

// preview and changes buttons, top 'wikEdClose alt':             'Close', 'wikEdClose title':           'Close preview box', 'wikEdScrollToPreview2 alt':  'Scroll to preview', 'wikEdScrollToPreview2 title': 'Scroll to preview field', 'wikEdScrollToEdit2 alt':     'Scroll to edit', 'wikEdScrollToEdit2 title':   'Scroll to edit field',

// preview and changes buttons, bottom 'wikEdClose alt':             'Close', 'wikEdClose title':           'Close preview box', 'wikEdScrollToPreview3 alt':  'Scroll to preview', 'wikEdScrollToPreview3 title': 'Scroll to preview field', 'wikEdScrollToEdit3 alt':     'Scroll to edit', 'wikEdScrollToEdit3 title':   'Scroll to edit field',

// preview field 'wikEdPreviewLoading':        '...',

// formatting functions 'image filename':             'filename', 'image width':                'width', 'table caption':              'caption', 'table heading':              'heading', 'table cell':                 'cell', 'redirect article link':      'article link',

// fixing functions 'External links':             'External links', 'See also':                   'See also', 'References':                 'References',

// language specific wiki code 'wikicode Image':             'Image', 'wikicode File':              'File', 'wikicode Category':          'Category', 'wikicode Template':          'Template', 'wikEdReferencesSection':     '\n== References ==\n\n \n'; if (obj.focusLine.plain != '') { obj.changed.plain = '\n' + obj.changed.plain + '\n'; }			}			else { obj.changed.plain = '\n{| class="wikitable" border="1"\n|+ ' + wikEdText['table caption'] + ' \n! ' + wikEdText['table heading'] + ' !! ' + wikEdText['table heading'] + ' \n|-\n| ' + wikEdText['table cell'] + ' || ' + wikEdText['table cell'] + ' \n|-\n| ' + wikEdText['table cell'] + ' || ' + wikEdText['table cell'] + ' \n|}\n'; if (obj.focusLine.plain != '') { obj.changed.plain = '\n' + obj.changed.plain + '\n'; }			}			break;

// wikify: always done above case 'wikEdWikify': break;

// textify: strip html from pasted content case 'wikEdTextify': WikEdTextify(obj.changed); break;

// redirect case 'wikEdRedirect': var linkTarget; if (obj.selection.plain != '') { linkTarget = obj.selection.plain; }			else if (obj.selectionWord.plain != '') { linkTarget = obj.selectionWord.plain; }			else { linkTarget = ' ' + wikEdText['redirect article link'] + ' '; }

// remove link text after | linkTarget = linkTarget.replace(/\|.*/, '');

// remove formatting and spaces linkTarget = linkTarget.replace(/^(=+|\'+|<[^>]*>|\s+|\[)+(.*?)(=+|\'+|<[^>]*>|\s+|\])+$/g, '$2'); linkTarget = linkTarget.replace(/\s+/g, ' '); linkTarget = linkTarget.replace(/^\s+|\s+$/g, '');

obj.changed.plain = '#REDIRECT ' + linkTarget + '';

// append to summary if (wikEdInputElement['summary'] != null) { if ( (obj.selection.plain != ) || (obj.selectionWord.plain != ) ) { wikEdInputElement['summary'].value = wikEdInputElement['summary'].value.replace(/#REDIRECT( \[\^\*\]\])?(, *)?/g, ''); wikEdInputElement['summary'].value = WikEdAppendToSummary(wikEdInputElement['summary'].value, '#REDIRECT ' + linkTarget + ''); }				else { wikEdInputElement['summary'].value = WikEdAppendToSummary(wikEdInputElement['summary'].value, '#REDIRECT'); }			}			selectChanged = false; break;

// find and replace case 'wikEdFindPrev': case 'wikEdFindNext': case 'wikEdJumpPrev': case 'wikEdJumpNext': case 'wikEdReplacePrev': case 'wikEdReplaceNext': case 'wikEdFindAll': case 'wikEdReplaceAll':

// get the find text var findText;

// unescape <, >, and & obj.changed.plain = obj.changed.plain.replace(/&lt;/g, '<'); obj.changed.plain = obj.changed.plain.replace(/&gt;/g, '>'); obj.changed.plain = obj.changed.plain.replace(/&amp;/g, '&');

// copy selection/word under cursor to find field if ( (parameters == 'shift') && ( (buttonId == 'wikEdFindNext') || (buttonId == 'wikEdReplaceNext') ) ) { if (/\n/.test(obj.changed.plain) == false) { if (buttonId == 'wikEdFindNext') { wikEdInputElement['find'].value = obj.changed.plain; }					else { wikEdInputElement['replace'].value = obj.changed.plain; }					obj.changed.keepSel = true; obj.changed.plain = null; break; }			}

// get the find text from the find field if ( (buttonId == 'wikEdJumpPrev') || (buttonId == 'wikEdJumpNext') ) { findText = obj.changed.plain; if (obj.selection.plain == '') { obj.changed.keepSel = true; obj.changed.plain = null; break; }			}

// get the find text from the find field else { if (wikEdInputElement['find'].value != '') { findText = wikEdInputElement['find'].value; }				else { obj.changed.plain = null; break; }			}

// get button status var regExpChecked = WikEdGetAttribute(wikEdRegExp, 'checked'); var caseSensitiveChecked = WikEdGetAttribute(wikEdCaseSensitive, 'checked');

// handle newlines and special blanks for built-in search if (regExpChecked == 'false') { findText = findText.replace(/\n/g, ''); findText = findText.replace(/\s/g, ' '); }

// get the replace text var replaceText = wikEdInputElement['replace'].value; var regExpFind;

// set regexp flags var regExpFlags = 'g'; if (caseSensitiveChecked == 'false') { regExpFlags += 'i'; }

// format the find and replace texts for a plain text search if ( (regExpChecked == 'false') || (buttonId == 'wikEdJumpPrev') || (buttonId == 'wikEdJumpNext') ) { regExpFind = new RegExp(findText.replace(/([\\^\$\*\+\?\.\(\)\[\]\{\}\:\=\!\|\,\-])/g, '\\$1'), regExpFlags); }

// format the find and replace texts for a regular expression search else { try { regExpFind = new RegExp(findText, regExpFlags); }				catch (err) { return; }

// substitute \\ \n \r \t \' \" \127 \x1f \u12ef				replaceText = replaceText.replace(/\\\\/g, '\x00');				replaceText = replaceText.replace(/\\n/g, '\n');				replaceText = replaceText.replace(/\\r/g, '\r');				replaceText = replaceText.replace(/\\t/g, '\t');				replaceText = replaceText.replace(/\\\'/g, '\'');				replaceText = replaceText.replace(/\\\"/g, '\"');

replaceText = replaceText.replace(/\\([0-7]{3})/g,					function(p, p1) {						return(String.fromCharCode(parseInt(p1, 8)));					}				); replaceText = replaceText.replace(/\\x([0-9a-fA-F]{2})/g,					function(p, p1) {						return(String.fromCharCode(parseInt(p1, 16)));					}				); replaceText = replaceText.replace(/\\u([0-9a-fA-F]{4})/g,					function(p, p1) {						return(String.fromCharCode(parseInt(p1, 16)));					}				); replaceText = replaceText.replace(/\x00/g, '\\'); }

// replace all var replacedFlag = false; if (buttonId == 'wikEdReplaceAll') { if (regExpFind.test(obj.changed.plain)) { obj.changed.plain = obj.changed.plain.replace(regExpFind, replaceText); replacedFlag = true; }				else { obj.changed.plain = null; }			}

// replace an existing selection else if ( (buttonId == 'wikEdReplacePrev') || (buttonId == 'wikEdReplaceNext') ) { if (regExpFind.test(obj.selection.plain)) { var replaced = obj.selection.plain.replace(regExpFind, replaceText); if (obj.changed.plain != replaced) { obj.changed.plain = replaced; replacedFlag = true; }					else { obj.changed.plain = null; }				}				else { obj.changed.plain = null; }			}			else if (				(buttonId == 'wikEdFindNext') || (buttonId == 'wikEdFindPrev') ||				(buttonId == 'wikEdJumpNext') || (buttonId == 'wikEdJumpPrev')			) { obj.changed.plain = null; }

if (				(buttonId == 'wikEdFindNext') || (buttonId == 'wikEdFindPrev') ||				(buttonId == 'wikEdJumpNext') || (buttonId == 'wikEdJumpPrev') ||				(buttonId == 'wikEdReplaceNext') || (buttonId == 'wikEdReplacePrev') ||				(buttonId == 'wikEdFindAll')			) { if (replacedFlag == false) {

// get direction var backwards = false; if ( (buttonId == 'wikEdFindPrev') || (buttonId == 'wikEdJumpPrev') || (buttonId == 'wikEdReplacePrev') ) { backwards = true; }

// get case sensitive var caseSensitive = false; if (caseSensitiveChecked == 'true') { caseSensitive = true; }

// find all if (buttonId == 'wikEdFindAll') { var found; var foundRanges = [];

// start at top of text WikEdRemoveAllRanges(obj.sel); var range = wikEdFrameDocument.createRange; range.setStartBefore(wikEdFrameBody.firstChild); range.collapse(true); range = obj.sel.addRange(range);

// cycle through matches var scrollTop = wikEdFrameBody.scrollTop; do {

// use regexp seach if (regExpChecked == 'true') { found = WikEdFind(obj, findText, caseSensitive, false, false, regExpFind); }

// use built-in sarch else { found = WikEdFind(obj, findText, caseSensitive, false, false, null); }							if (found == true) { foundRanges.push(obj.changed.range.cloneRange); }						} while (found == true);

// scroll back if (regExpChecked == 'false') { wikEdFrameBody.scrollTop = scrollTop; }

// add the found ranges WikEdRemoveAllRanges(obj.sel); for (range in foundRanges) { obj.sel.addRange(foundRanges[range]); }						obj.changed.plain = null; }

// normal find else { if (regExpChecked == 'true') { WikEdFind(obj, findText, caseSensitive, backwards, true, regExpFind); }						else { WikEdFind(obj, findText, caseSensitive, backwards, true, null); selectChanged = false; }					}				}			}

// escape <, >, and & if (obj.changed.plain != null) { obj.changed.plain = obj.changed.plain.replace(/&/g, '&amp;'); obj.changed.plain = obj.changed.plain.replace(//g, '&gt;'); }

// save search history to settings if ( (buttonId == 'wikEdFindPrev') || (buttonId == 'wikEdFindNext') || (buttonId == 'wikEdFindAll') ) { WikEdAddToHistory('find'); }			if ( (buttonId == 'wikEdReplacePrev') || (buttonId == 'wikEdReplaceNext') || (buttonId == 'wikEdReplaceAll') ) { WikEdAddToHistory('find'); WikEdAddToHistory('replace'); }			obj.changed.keepSel = true; 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': WikEdFixBasic(obj.changed); obj.changed.keepSel = true; break; case 'wikEdFixPunct': WikEdFixPunct(obj.changed); obj.changed.keepSel = true; break; case 'wikEdFixMath': WikEdFixMath(obj.changed); obj.changed.keepSel = true; break; case 'wikEdFixChem': WikEdFixChem(obj.changed); obj.changed.keepSel = true; break; case 'wikEdFixUnicode': WikEdFixUnicode(obj.changed); obj.changed.keepSel = true; break; case 'wikEdFixRedirect': WikEdFixRedirectCall(obj.changed); return; case 'wikEdFixRedirectReplace': WikEdFixRedirectReplace(obj.changed); obj.changed.keepSel = true; break; case 'wikEdFixUnits': WikEdFixUnits(obj.changed); obj.changed.keepSel = true; break; case 'wikEdFixDashes': WikEdFixDashes(obj.changed); obj.changed.keepSel = true; break; case 'wikEdFixHtml': WikEdFixHTML(obj.changed); obj.changed.keepSel = true; break; case 'wikEdFixRegExTypo': if ( (wikEdRegExTypoFix == true) && (wikEdTypoRulesFind.length > 0) ) { WikEdFixTypos(obj.changed); }			else { obj.changed.plain = null; }			obj.changed.keepSel = true; break; case 'wikEdFixCaps': WikEdFixCaps(obj.changed); obj.changed.keepSel = true; break; case 'wikEdFixAll': WikEdFixAll(obj.changed); obj.changed.keepSel = true; break;

// source on		case 'wikEdSource': obj.changed.plain = obj.changed.code; obj.changed.plain = obj.changed.plain.replace(/(<(br|p)\b[^>]*>)/g, '$1\n'); obj.changed.plain = obj.changed.plain.replace(/&/g, '&amp;'); obj.changed.plain = obj.changed.plain.replace(//g, '&gt;'); highlightSyntax = false; break;

// insert tags case 'wikEdInsertTags': var tagOpen = parameters[0] || ''; var tagClose = parameters[1] || ''; var sampleText = parameters[2] || ''; tagOpen = tagOpen.replace(/&/g, '&amp;'); tagOpen = tagOpen.replace(//g, '&gt;'); tagClose = tagClose.replace(/&/g, '&amp;'); tagClose = tagClose.replace(//g, '&gt;'); tagsampleText = sampleText.replace(/&/g, '&amp;'); tagsampleText = sampleText.replace(//g, '&gt;');

// single string to insert if ( (tagOpen.length > 0) && (tagClose.length == 0) && (sampleText.length == 0) ) { obj.changed = obj.cursor; obj.changed.plain = tagOpen; }

// 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; }			else { obj.changed.plain = tagOpen + obj.changed.plain + tagClose; }

// convert wiki tables to html // case 'wikEdTablify': obj.changed.keepSel = true; if (wikEdTableMode == true) { WikEdWikiTableToHtml(obj.changed); }			break;

// update text view using current control button settings // case 'wikEdUpdateAll': obj.changed.keepSel = true; if (parameters != null) { if (parameters.keepSel == false) { obj.changed.keepSel = false; }			}			break;

// custom edit functions default: if (CustomHandler != null) { CustomHandler(obj); }			else { alert('Unknown edit function \ + buttonId + '\); }			break; }

// update the selection only, do not change the text if (obj.changed.plain == null) { if (buttonId != 'wikEdFindAll') { WikEdRemoveAllRanges(obj.sel); obj.sel.addRange(obj.changed.range);

// scroll the selected text into the viewport by using a backwards find if (selectChanged != false) {

// get the plain text of the selection if (obj.sel.rangeCount == 0) { obj.sel.collapse(wikEdFrameBody, 0); }				var plainText = obj.sel.getRangeAt(obj.sel.rangeCount - 1).cloneContents.textContent;

// collapse the selection to the end and search backwards if (plainText.length > 0) { plainText = plainText.replace(/\n/g, ''); obj.changed.range.collapse(false);

// parameters: window.find(string, caseSensitive, backwards, wrapAround, wholeWord, searchInFrames, showDialog) wikEdFrameWindow.find(plainText, true, true, false, false, false, false); }			}		}	}

// apply text changes else {

// a text change erases the last version for redo all if ( (buttonId != 'wikEdUndo') && (buttonId != 'wikEdRedo') && (buttonId != 'wikEdUndoAll') ) { wikEdLastVersion = null; }

// highlight the syntax obj.html = obj.changed.plain; if (highlightSyntax == true) { if (obj.changed.from == 'whole') { obj.whole = true; }			WikEdHighlightSyntax(obj); }

// at least display tabs else { obj.html = obj.html.replace(/(\t)/g, ' $1 '); }

// display multiple blanks as blank- obj.html = obj.html.replace(/(^|\n) /g, '$1 '); obj.html = obj.html.replace(/ (\n|$)/g, ' $1'); obj.html = obj.html.replace(/ /g, '  '); obj.html = obj.html.replace(/ /g, '  ');

// newlines to

obj.html = obj.html.replace(/\n/g, ' ');

// make changed range text the current selection WikEdRemoveAllRanges(obj.sel); obj.sel.addRange(obj.changed.range); //// range over not handled correctly by Seamonkey

// get the scroll position var scrollTop; if (obj.changed.from == 'whole') { scrollTop = wikEdFrameBody.scrollTop; }

// replace the selection with changed text if (obj.html != '') { WikEdFrameExecCommand('inserthtml', obj.html); }		else if (obj.sel.isCollapsed == false) { WikEdFrameExecCommand('delete'); }

// select the whole text after replacing the whole text and scroll to same height if (obj.changed.from == 'whole') { WikEdRemoveAllRanges(obj.sel); wikEdFrameBody.scrollTop = scrollTop; var range = wikEdFrameDocument.createRange; range.setStartBefore(wikEdFrameBody.firstChild); range.setEndAfter(wikEdFrameBody.lastChild); obj.sel.addRange(range); selectChanged = false; }

// select the changed text and scroll it into the viewport by using a backwards find if (selectChanged != false) {

// get the text content of the changed text if (selectChangedText == '') { var div = document.createElement('div'); div.innerHTML = obj.changed.plain; selectChangedText = div.textContent; }

// find the text if (selectChangedText.length > 0) { selectChangedText = selectChangedText.replace(/\n/g, '');

// parameters: window.find(string, caseSensitive, backwards, wrapAround, wholeWord, searchInFrames, showDialog) if (selectChangedText != '') { wikEdFrameWindow.find(selectChangedText, true, true, false, false, false, false); }			}		}	}

// remove selection, keep whole text auto-selection as warning if (		( (obj.changed.keepSel != true) && (obj.changed.from != 'whole') ) ||		(obj.changed.keepSel == false) ||		(buttonId == 'wikEdRedirect') ||		( (buttonId == 'wikEdWikify') && (parameters == 'whole') )	) { if (obj.sel.rangeCount == 0) { obj.sel.collapse(wikEdFrameBody, 0); }		else { obj.sel.getRangeAt(obj.sel.rangeCount - 1).collapse(false); }	}

// reset button to active, reset cursor if (buttonObj != null) { if (buttonObj.className != 'wikEdButtonInactive') { buttonObj.className = 'wikEdButton'; }		buttonObj.style.cursor = 'auto'; }

// grey out inactive buttons WikEdInactiveButtons;

// focus the frame if (wikEdUseWikEd == true) { wikEdFrameWindow.focus; }

// add event handler to make highlighted frame links ctrl-clickable if ( (highlightSyntax == true) && (obj.changed.plain != null) ) { WikEdFollowLinks; }

return; }

// // WikEdScrollToPreview: scroll to edit buttons, textarea, or preview field depending on current position //

window.WikEdScrollToPreview = function {

// reset fixed height to auto wikEdPreviewBox.style.height = 'auto';

var scrollOffset = window.pageYOffset; var inputOffset = WikEdGetOffsetTop(wikEdInputWrapper); var editOffset = WikEdGetOffsetTop(wikEdEditWrapper); var submitOffset = WikEdGetOffsetTop(wikEdSaveButton); var editHeight = wikEdEditWrapper.clientHeight;

if (scrollOffset > submitOffset) { window.scroll(0, submitOffset); }	else if (scrollOffset > (editHeight / 2 + editOffset) ) { window.scroll(0, submitOffset); }	else if (scrollOffset > editOffset) { window.scroll(0, editOffset); }	else { window.scroll(0, inputOffset); }	return; }

// // WikEdFollowLinks: register click handlers to make highlighted frame links ctrl-clickable //

window.WikEdFollowLinks = function {

if (wikEdFollowLinks == true) { for (var linkId in wikEdFollowLinkHash) { if (typeof(wikEdFollowLinkHash[linkId]) != 'string') { continue; }			var linkSpan = wikEdFrameDocument.getElementById(linkId); if (linkSpan != null) { WikEdAddEventListener(linkSpan, 'click', WikEdFollowLinkHandler, true); }		}	}	return; }

// // WikEdGetText: get the text fragments to manipulate //

window.WikEdGetText = function(obj, whichFragment, wikify) {

// remove dynamically inserted nodes by other scripts WikEdCleanNodes(wikEdFrameDocument);

// get selection object if (obj.sel == null) { obj.sel = WikEdGetSelection; }

// cursor for the cursor position (always done) if (obj.cursor == null) { obj.cursor = { 'from': 'cursor', 'keepSel': null, 'plain': '' };

// set cursor range obj.cursor.range = wikEdFrameDocument.createRange; obj.cursor.range.setStart(obj.sel.focusNode, obj.sel.focusOffset); obj.cursor.range.setEnd(obj.sel.focusNode, obj.sel.focusOffset); }

// whole for the whole text if (obj.whole == null) { if (/whole|selectionWord|selectionLine|selectionPara|focusWord|focusLine|focusPara/.test(whichFragment) == true) { obj.whole = { 'plainArray': [], 'plainNode': [], 'plainStart': [], 'from': 'whole', 'keepSel': null };

// set whole range obj.whole.range = wikEdFrameDocument.createRange; obj.whole.range.setStartBefore(wikEdFrameBody.firstChild); obj.whole.range.setEndAfter(wikEdFrameBody.lastChild);

// get whole plain text WikEdGetInnerHTML(obj.whole, wikEdFrameBody); obj.whole.code = obj.whole.html; WikEdRemoveHighlightingWikify(obj.whole, wikify); obj.whole.plain = obj.whole.html; obj.whole.plain = obj.whole.plain.replace(/]*>[\r\n ]*/g, '\n'); obj.whole.plain = obj.whole.plain.replace(/\xa0/g, ' '); }	}

// selection for the selected text if (obj.selection == null) { if (/selection\b|selectionWord|selectionLine|selectionPara/.test(whichFragment) == true) { obj.selection = { 'from': 'selection', 'keepSel': null };

// copy range to document fragment if (obj.sel.rangeCount == 0) { obj.sel.collapse(wikEdFrameBody, 0); }			obj.selection.range = obj.sel.getRangeAt(obj.sel.rangeCount - 1); var documentFragment = obj.selection.range.cloneContents;

// get selected text WikEdGetInnerHTML(obj.selection, documentFragment); obj.selection.code = obj.selection.html; WikEdRemoveHighlightingWikify(obj.selection, wikify); obj.selection.plain = obj.selection.html; obj.selection.plain = obj.selection.plain.replace(/]*>[\r\n ]*/g, '\n'); obj.selection.plain = obj.selection.plain.replace(/\xa0/g, ' '); }	}

// focusWord, focusLine, and focusPara for the word, line, and paragraph under the cursor if (obj.focusWord == null) { if (/focusWord|focusLine|focusPara/.test(whichFragment) == true) { obj.focusWord = { 'from': 'focusWord', 'keepSel': false, 'range': wikEdFrameDocument.createRange, 'tableEdit': obj.tableEdit };

// setup focusLine object for the line under the cursor obj.focusLine = { 'from': 'focusLine', 'keepSel': false, 'range': wikEdFrameDocument.createRange, 'tableEdit': obj.tableEdit };

// setup focusPara object for the paragraph under the cursor obj.focusPara = { 'from': 'focusPara', 'keepSel': false, 'range': wikEdFrameDocument.createRange, 'tableEdit': obj.tableEdit };

// find the word and line boundaries WikEdFindBoundaries(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; WikEdGetInnerHTML(obj.focusWord, documentFragment); obj.focusWord.code = obj.focusWord.html; WikEdRemoveHighlightingWikify(obj.focusWord, wikify); obj.focusWord.plain = obj.focusWord.html; obj.focusWord.plain = obj.focusWord.plain.replace(/]*>[\r\n ]*/g, '\n'); 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; WikEdGetInnerHTML(obj.focusLine, documentFragment); obj.focusLine.code = obj.focusLine.html; WikEdRemoveHighlightingWikify(obj.focusLine, wikify); obj.focusLine.plain = obj.focusLine.html; obj.focusLine.plain = obj.focusLine.plain.replace(/]*>[\r\n ]*/g, '\n'); 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; WikEdGetInnerHTML(obj.focusPara, documentFragment); obj.focusPara.code = obj.focusPara.html; WikEdRemoveHighlightingWikify(obj.focusPara, wikify); obj.focusPara.plain = obj.focusPara.html; obj.focusPara.plain = obj.focusPara.plain.replace(/]*>[\r\n ]*/g, '\n'); obj.focusPara.plain = obj.focusPara.plain.replace(/\xa0/g, ' '); }	}

// 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', 'keepSel': false, 'range': wikEdFrameDocument.createRange, 'tableEdit': obj.tableEdit };

// setup selectionLine object for the lines under the selection obj.selectionLine = { 'from': 'selectionLine', 'keepSel': false, 'range': wikEdFrameDocument.createRange, 'tableEdit': obj.tableEdit };

// setup focusPara object for the paragraph under the selection obj.selectionPara = { 'from': 'selectionPara', 'keepSel': false, 'range': wikEdFrameDocument.createRange, 'tableEdit': obj.tableEdit };

// find the word and line boundaries WikEdFindBoundaries(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; WikEdGetInnerHTML(obj.selectionWord, documentFragment); obj.selectionWord.code = obj.selectionWord.html; WikEdRemoveHighlightingWikify(obj.selectionWord, wikify); obj.selectionWord.plain = obj.selectionWord.html; obj.selectionWord.plain = obj.selectionWord.plain.replace(/]*>[\r\n ]*/g, '\n'); 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; WikEdGetInnerHTML(obj.selectionLine, documentFragment); obj.selectionLine.code = obj.selectionLine.html; WikEdRemoveHighlightingWikify(obj.selectionLine, wikify); obj.selectionLine.plain = obj.selectionLine.html; obj.selectionLine.plain = obj.selectionLine.plain.replace(/]*>[\r\n ]*/g, '\n'); 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; WikEdGetInnerHTML(obj.selectionPara, documentFragment); obj.selectionPara.code = obj.selectionPara.html; WikEdRemoveHighlightingWikify(obj.selectionPara, wikify); obj.selectionPara.plain = obj.selectionPara.html; obj.selectionPara.plain = obj.selectionPara.plain.replace(/]*>[\r\n ]*/g, '\n'); obj.selectionPara.plain = obj.selectionPara.plain.replace(/\xa0/g, ' '); }	}	return; }

// // WikEdFind: custom find function with regexp properties, sets obj.changed.range, uses obj ranges //

window.WikEdFind = function(obj, findText, caseSensitive, backwards, wrap, regExp) {

if (obj.sel.rangeCount == 0) { obj.sel.collapse(wikEdFrameBody, 0); }	var range = obj.sel.getRangeAt(obj.sel.rangeCount - 1); var found = false;

// empty the range to avoid error messages for reverse direction ranges obj.changed.range = wikEdFrameDocument.createRange;

// use the fast built-in find function for non-regexp searches if (regExp == null) {

// parameters: window.find(string, caseSensitive, backwards, wrapAround, wholeWord, searchInFrames, showDialog) found = wikEdFrameWindow.find(findText, caseSensitive, backwards, wrap, false, true, false); if (found == true) { range = obj.sel.getRangeAt(obj.sel.rangeCount - 1); }		obj.changed.range = range.cloneRange; }

// slow javascript regexp find and replace else {

// perform find if (obj.plainArray === undefined) { WikEdParseDOM(obj, wikEdFrameBody); }		var regExpMatch = [];

// find next, search to the right if (backwards == false) {

// set start position for search to right regExpMatch = regExp.exec(obj.plain); regExp.lastIndex = obj.plainFocus;

// execute the regexp search to the right regExpMatch = regExp.exec(obj.plain);

// remember position for repeated searches obj.plainFocus = regExp.lastIndex;

// wrap around, start at beginning if ( (wrap == true) && (regExpMatch == null) ) { regExp.lastIndex = 0; regExpMatch = regExp.exec(obj.plain); }		}

// find previous, search to the left else {

// cycle through the matches to the left var regExpMatchNext; do { regExpMatch = regExpMatchNext; regExpMatchNext = regExp.exec(obj.plain); if (regExpMatchNext == null) { break; }			} while (regExpMatchNext.index < obj.plainAnchor);

// wrap around, find last occurrence if ( (wrap == true) && (regExpMatch == null) ) { do { regExpMatch = regExpMatchNext; regExpMatchNext = regExp.exec(obj.plain); } while (regExpMatchNext != null); }		}

// select the find if (regExpMatch != null) { found = true; var i = 0; while ( (obj.plainStart[i + 1] <= regExpMatch.index) && (obj.plainStart[i + 1] != null) ) { i ++; }			var j = i;			while ( (obj.plainStart[j + 1] <= regExpMatch.index + regExpMatch[0].length) && (obj.plainStart[j + 1] != null) ) { j ++; }			obj.changed.range.setStart(obj.plainNode[i], regExpMatch.index - obj.plainStart[i]); obj.changed.range.setEnd (obj.plainNode[j], regExpMatch.index + regExpMatch[0].length - obj.plainStart[j]); }	}

//// range over not handled correctly by Seamonkey return(found); }

// // WikEdWikiTableToHtml: convert wiki tables to html // //

window.WikEdWikiTableToHtml = function(obj) {

////	return; }

// // WikEdTextify: strip html off of text //

window.WikEdTextify = function(obj) {

// convert html to plain obj.plain = obj.html; obj.plain = obj.plain.replace(/\n/g, ' ');

// delete tags obj.plain = obj.plain.replace(/<(style|script|object|applet|embed)\b[^>]*>.*?<\/\1>/g, '');

// newlines obj.plain = obj.plain.replace(/<br\b[^>]*> */g, '\n');

// 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,		function (p, p1, p2, p3) {			if (p2 == ) {				if (/\bclass=\"wikEd\w+\"/.test(p3)) {					isRemove.push(true);					return();				}				isRemove.push(false);				return(p1);			}			if (isRemove.pop == true) {				return('');			}			return(p1);		}	);

// 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 (wikEdTableMode == true) {

// override pasted table class // obj.plain = obj.plain.replace(/(<table\b)([^>]*)(>)/gi,			function (p, p1, p2, p3) {				if (p2.match(/\bclass=/) != null) {					p2 = p2.replace(/\bclass\s*=\s*([\'\"]?)[^<>\'\"\n]*?\2/g, 'class="wikEdTableEdit"');				}				else {					p2 = ' class="wikEdTableEdit"';				}				return(p1 + p2 + p3);			}		);

// keep table html markup // obj.plain = obj.plain.replace(/[\s\x00]*(<table\b[^>]*>)/g, '\x00\x00$1'); obj.plain = obj.plain.replace(/(<\/table>)[\s\x00]*/g, '$1\x00');

obj.plain = obj.plain.replace(/<(\/?(table|caption|tr|th|td)\b[^>]*)>/g, '\x01$1\x02'); }

// textify table else if (wikEdTableMode == false) { obj.plain = obj.plain.replace(/<\/?(table|caption)\b[^>]*>/g, '\x00'); obj.plain = obj.plain.replace(/<\/(tr|th|td)>/g, '\x00'); }

// 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'); obj.plain = obj.plain.replace(/\n*\x00(\x00|\n)+/g, '\n\n'); obj.plain = obj.plain.replace(/\x00/g, '\n'); 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, ''); }

return; }

// // WikEdInactiveButtons: grey out inactive buttons, called after every change and click //

window.WikEdInactiveButtons = function {

// undo if (wikEdFrameDocument.queryCommandEnabled('undo') == true ) { document.getElementById('wikEdUndo').className = 'wikEdButton'; document.getElementById('wikEdUndoAll').className = 'wikEdButton'; }	else { document.getElementById('wikEdUndo').className = 'wikEdButtonInactive'; document.getElementById('wikEdUndoAll').className = 'wikEdButtonInactive'; }

// redo if (wikEdFrameDocument.queryCommandEnabled('redo') == true ) { document.getElementById('wikEdRedo').className = 'wikEdButton'; }	else { document.getElementById('wikEdRedo').className = 'wikEdButtonInactive'; }

// redo all if (wikEdLastVersion != null) { document.getElementById('wikEdRedoAll').className = 'wikEdButton'; }	else { document.getElementById('wikEdRedoAll').className = 'wikEdButtonInactive'; }	return; }

// // WikEdFixBasic: fix characters, spaces, empty lines, certain headings, needed for all fixing functions //

//// change: double spaces ok after dot

window.WikEdFixBasic = 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]*?) *(=+)(?=(\n|$))/g,		function(p, p1, p2, p3, p4) {			p3 = p3.replace(/\'{2,}/g, '');			return('\n\n' + p2 + ' ' + p3 + ' ' + p2 + '\n\n');		}	);

// uppercase well known headings var regExp = new RegExp('\\n=+ ' + wikEdText['External links'] + '? =+\\n', 'gi'); obj.plain = obj.plain.replace(regExp, '\n== ' + wikEdText['External links'] + ' ==\n'); regExp = new RegExp('\\n=+ ' + wikEdText['See also'] + ' =+\\n', 'gi'); obj.plain = obj.plain.replace(regExp, '\n== ' + wikEdText['See also'] + ' ==\n'); regExp = new RegExp('\\n=+ ' + wikEdText['References'] + '? =+\\n', 'gi'); obj.plain = obj.plain.replace(regExp, '\n== ' + wikEdText['References'] + ' ==\n');

// add space after * # : ; (list) and after {| |- | (table) obj.plain = obj.plain.replace(/(^|\n)([\*\#\:\;]+|\{\||\|\-|\|\}|\|) */g, '$1$2 '); obj.plain = obj.plain.replace(/ +\n/g, '\n');

// empty line before and after tables obj.plain = obj.plain.replace(/\n+(\{\|)/g, '\n\n$1'); obj.plain = obj.plain.replace(/(\n\|\}([^\}]|$)) *([^\n]*)[\n|$]+/g, '$1\n\n$3\n\n');

// empty line before and after lists obj.plain = obj.plain.replace(/(^|\n)([^\*\#\:\;\n][^\n]*)(?=\n[\*\#\:\;])/g, '$1$2\n\n'); obj.plain = obj.plain.replace(/(^|\n)([\*\#\:\;][^\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 = ''; var tableflag = false;

for (var i = 0; i < lines.length; i++) { var line = lines[i];

// do not change lines starting with a blank if (/^ /.test(line) == false) {

// detect table if (line.match(/^(\{\||\!|\|[^}])/) != null) { tableflag = true; }			else if (line.match(/^\|\}/) != null) { tableflag = false; }

// 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|' + wikEdText['wikicode Image'] + '|' + wikEdText['wikicode File'] + '):.*?\\]\\])', 'ig'); line = line.replace(regExp, '\n$1');

regExp = new RegExp('(\\[\\[(Image|File|' + wikEdText['wikicode Image'] + '|' + wikEdText['wikicode File'] + '):.*?(\\[\\[.*?\\]\\].*?)*\\]\\])$', 'ig'); line = line.replace(regExp, '$1\n');

// empty line before and after includes line = line.replace(/^(\{\{.*?\}\})/g, '\n$1'); line = line.replace(/(\{\{.*?\}\})$/g, '$1\n'); }		}

// concatenate the lines obj.plain += line; if (i < lines.length - 1) { obj.plain += '\n'; }	}

// remove underscores in wikilinks obj.plain = obj.plain.replace(/\[\[(.*?)((\|.*?)|)\]\]/g,		function (p, p1, p2) {			p1 = p1.replace(/_/g, ' ');			return( + p1 + p2 + );		}	);

// remove spaces in wikilinks obj.plain = obj.plain.replace(/\[\[ *([^\n]*?) *\]\]/g, '$1');

// remove spaces in external links obj.plain = obj.plain.replace(/\[ *([^\n]*?) *\]/g, '[$1]');

// no space around pipes before brackets obj.plain = obj.plain.replace(/ +\| +\]\]/g, '|]]');

// 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)\n+(\{\{.*?\}\})/g, '\n$1$2');

// spaces in comments obj.plain = obj.plain.replace(/(&lt;!--) *([^\n]*?) *(--&gt;)/g, '$1 $2 $3');

// empty line before and after categories var regExp = new RegExp('( |\\n)*(\\[\\[(Category|' + wikEdText['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|' + wikEdText['wikicode Category'] + ')\\s*:[^\\n]*?\\]\\])\\n*(?=\\[\\[(Category|' + wikEdText['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');

return; }

// // WikEdFixPunct: remove (or add) space before .,:; //

window.WikEdFixPunct = function(obj) {

WikEdFixBasic(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 obj.plain = obj.plain.replace(/(\b(http:\/\/|https:\/\/|ftp:\/\/|irc:\/\/|gopher:\/\/|news:|mailto:|file:\/\/)[\!\#\%\&\(\)\+-\/\:\;\=\?\@\w\~ŠŒŽœžŸŠŒŽšœžŸÀ-ÖØ-öø-\u0220\u0222-\u0233ΆΈΉΊΌΎΏΑ-ΡΣ-ώ\u0400-\u0481\u048a-\u04ce\u04d0-\u04f5\u04f8\u04f9]*)/g,		function(p, p1, p2) {			p = p.replace(/([\.\,\:\;\?\!](?!$))/g, '\x00$1');			return(p);		}	);

// protect punctuation in filenames obj.plain = obj.plain.replace(/([a-zA-Z_ŠŒŽšœžŸÀ-ÖØ-öø-\u0220\u0222-\u0233ΆΈΉΊΌΎΏΑ-ΡΣ-ώ\u0400-\u0481\u048a-\u04ce\u04d0-\u04f5\u04f8\u04f9\-])([\.\,\:\;\?\!])(?=([a-zA-Z]{3,4})([\s\:\;\?\!\.\,\(\)\[\]\{\}\|]|$))/g, '$1\x00$2');

// protect punctuation in article names obj.plain = obj.plain.replace(/(\[\[|\{\{)([^\]\}\|\n]*)/g,		function(p, p1, p2) {			p = p.replace(/([\.\,\:\;\?\!])/g, '\x00$1');			return(p);		}	);

if (wikEdFixPunctFrench == true) { obj.plain = obj.plain.replace(/(«) */g, '$1 '); obj.plain = obj.plain.replace(/ *(»)/g, ' $1'); obj.plain = obj.plain.replace(/([a-zA-Z_ŠŒŽšœžŸÀ-ÖØ-öø-\u0220\u0222-\u0233ΆΈΉΊΌΎΏΑ-ΡΣ-ώ\u0400-\u0481\u048a-\u04ce\u04d0-\u04f5\u04f8\u04f9\'\"”\]\}\)]) *([\.\,])(?=([a-zA-ZŠŒŽšœžŸÀ-ÖØ-öø-\u0220\u0222-\u0233ΆΈΉΊΌΎΏΑ-ΡΣ-ώ\u0400-\u0481\u048a-\u04ce\u04d0-\u04f5\u04f8\u04f9\'\"”\[\{\(\s]|$))/g, '$1$2 '); obj.plain = obj.plain.replace(/([a-zA-Z_ŠŒŽšœžŸÀ-ÖØ-öø-\u0220\u0222-\u0233ΆΈΉΊΌΎΏΑ-ΡΣ-ώ\u0400-\u0481\u048a-\u04ce\u04d0-\u04f5\u04f8\u04f9\'\"”\]\}\)]) *([\:\;\?\!])/g, '$1 $2 ');	}	else {		obj.plain = obj.plain.replace(/([a-zA-Z_ŠŒŽšœžŸÀ-ÖØ-öø-\u0220\u0222-\u0233ΆΈΉΊΌΎΏΑ-ΡΣ-ώ\u0400-\u0481\u048a-\u04ce\u04d0-\u04f5\u04f8\u04f9\'\"”\]\}\)]) *([\.\,\:\;])(?=([a-zA-ZŠŒŽšœžŸÀ-ÖØ-öø-\u0220\u0222-\u0233ΆΈΉΊΌΎΏΑ-ΡΣ-ώ\u0400-\u0481\u048a-\u04ce\u04d0-\u04f5\u04f8\u04f9\'\"”\[\{\(\s]|$))/g, '$1$2 ');	}	obj.plain = obj.plain.replace(/\x00/g, );	obj.plain = obj.plain.replace(/ +$/g, );	obj.plain = obj.plain.replace(/ +\n/g, '\n');	obj.plain = obj.plain.replace(/ {2,}/g, ' ');

return; }

// // WikEdFixUnicode: fix unicode character representations //

window.WikEdFixUnicode = function(obj) {

// replace supported chars: change decimal, hex, and character entities into actual char for (var i = 0; i < wikEdSupportedChars.length; i ++) { var replaceChar = String.fromCharCode(parseInt(wikEdSupportedChars[i][0], 16));

// decimal representation var regExpStr = '&amp;#0*' + parseInt(wikEdSupportedChars[i][0], 16) + ';|';

// hex representation regExpStr += '&amp;#x0*' + wikEdSupportedChars[i][0] + ';';

// case insensitive replace var regExp = new RegExp(regExpStr, 'gi'); obj.plain = obj.plain.replace(regExp, replaceChar);

// character entity representation regExpStr = '&amp;' + wikEdSupportedChars[i][1] + ';';

// case sensitive replace 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 < wikEdProblemChars.length; i ++) { replaceChar = '&amp;' + wikEdProblemChars[i][1] + ';';

// decimal representation regExpStr = '&amp;#0*' + parseInt(wikEdProblemChars[i][0], 16) + ';|';

// hex representation regExpStr += '&amp;#x0*' + wikEdProblemChars[i][0] + ';';

// case insensitive replace regExp = new RegExp(regExpStr, 'gi'); obj.plain = obj.plain.replace(regExp, replaceChar);

// actual character representation regExpStr = '\\u' + wikEdProblemChars[i][0];

// case sensitive replace 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 < wikEdSpecialChars.length; i ++) { var replaceChar = '&amp;' + wikEdSpecialChars[i][1] + ';';

// decimal representation var regExpStr = '&amp;#0*' + parseInt(wikEdSpecialChars[i][0], 16) + ';|';

// hex representation regExpStr += '&amp;#x0*' + wikEdSpecialChars[i][0] + ';';

// case insensitive replace var regExp = new RegExp(regExpStr, 'gi'); obj.plain = obj.plain.replace(regExp, replaceChar);

// actual character representation regExpStr = '\\u' + wikEdSpecialChars[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');

return; }

// // WikEdFixRedirectCall: parse link targets into wikEdRedirects object using AJAX API call //

window.WikEdFixRedirectCall = function(obj) {

// check if api is enabled if ( (wikEdWikiGlobals['wgEnableAPI'] != 'true') || (wikEdScriptURL == '') ) { return; }

// reset redirects object wikEdRedirects = {};

// get wiki links var url = '';

//             1     2  2   3                   34    1	var regExp = /(\[\[\s*(:?)\s*([^\n#<>\[\]\{\}\|]+)(\s*#[^\n\[\]\|]*?)?(\s*\|(.|\s)*?)?\]\]\s*)/g; while ( (regExpMatch = regExp.exec(obj.plain)) != null) { url += encodeURIComponent(regExpMatch[3] + '|'); }

// no wikilinks found if (url == '') { return; }

// make the ajax request url = wikEdScriptURL + 'api.php?action=query&redirects&format=xml&titles=' + url; WikEdAjaxRequest('GET', url, null, null, null, null, function(ajax, obj) {

// get response var txt = ajax.responseText;

if ( (regExpMatch = txt.match(/ ((.|\s)*?)<\/redirects>/)) != null) { var redirects = regExpMatch[1];

if ( (regExpMatch = txt.match(/ ((.|\s)*?)<\/normalized>/)) != null) { redirects = regExpMatch[1] + redirects; }

// parse redirects var i = 0; wikEdRedirects.from = []; wikEdRedirects.to = []; wikEdRedirects.allFrom = '';

var regExp = /<(r|n) .*?\bfrom=\"([^\">]*)\".*?\bto=\"([^\"]*)\"[^>]*>/g; while ( (regExpMatch = regExp.exec(txt)) != null) { wikEdRedirects.from[i] = regExpMatch[2]; wikEdRedirects.allFrom += i + '="' + regExpMatch[2] + '"'; wikEdRedirects.to[i] = regExpMatch[3]; i ++; }

// recurse through chained normalizations and redirects wikEdRedirects.toIndex = []; for (var i = 0; i < wikEdRedirects.to.length; i ++) { wikEdRedirects.toIndex[i] = WikEdResolveRedirects(i); }

}

// replace links WikEdEditButton(null, 'wikEdFixRedirectReplace');

return; }); // end Ajax handler

return; }

// // WikEdResolveRedirects: recursively follow redirects, called from WikEdFixRedirectCall Ajax handler //  uses wikEdRedirects.allFrom as a regExp hash

window.WikEdResolveRedirects = function(i) { var toRegExp = wikEdRedirects.to[i].replace(/(\W)/g, '\\$1'); var regExp = new RegExp('(\\d+)=\\"' + toRegExp + '\\"'); if ( (regExpMatch = wikEdRedirects.allFrom.match(regExp)) != null) { i = WikEdResolveRedirects( parseInt(regExpMatch[1]) ); }	return(i); }

// // WikEdFixRedirectReplace: replace redirects using wikEdRedirects object prepared in WikEdFixRedirectCall //

window.WikEdFixRedirectReplace = function(obj) {

if (wikEdRedirects.from == null) { return; }

// cycle through parsed redirects if (wikEdRedirects.from != null) { for (var i = 0; i < wikEdRedirects.from.length; i ++) {

var regExp = /(\[\[\s*(:?)\s*([^\n#<>\[\]\{\}\|]+)(\s*#[^\n\[\]\|]*?)?(\s*\|(.|\s)*?)?\]\])/g;

//                                      1  1    2                              23    #                 3 4      |56     6  54			var regExp = new RegExp('\\[\\[\\s*(:?)\\s*(' + wikEdRedirects.from[i] + ')(\\s*#[^\\n\\[\\]\\|]*?)?(\\s*\\|((.|\\s)*?))?\\s*\\]\\]', 'g'); obj.plain = obj.plain.replace(regExp,				function(p, p1, p2, p3, p4, p5) {					var prefix = p1;					var article = p2;					var redirect = wikEdRedirects.to[ wikEdRedirects.toIndex[i] ];					var fragmentId = p3 || ;					var linkText = p5 || ;

// use normalized target var linkTarget = redirect;

// lowercase link target if link text starts with lowercase (main space only) if (wikEdArticlesCaseSensitive == false) { if (/:/.test(linkTarget) != true) { if (article.charAt(0).toLowerCase == article.charAt(0)) { linkTarget = linkTarget.charAt(0).toLowerCase + linkTarget.substr(1); }						}					}

// remove text if identical to new target if (linkText != '') { if ( linkText.replace(/_/g, ' ') == linkTarget ) { linkText = ''; }					}

// keep replaced link as link text else if (linkText == '') { if (linkTarget != article) { linkText = article; }					}

// return fixed link var wikiLink; if (linkText == '') { wikiLink =  + prefix + linkTarget + fragmentId + ; }					else { wikiLink =  + linkText + ; }					return(wikiLink); }			);		}	}	return; }

// // WikEdFixMath: math character fixer, originally from User:Omegatron //

window.WikEdFixMath = function(obj) {

WikEdFixBasic(obj);

// change only outside $$ $$ wikicode obj.plain = obj.plain.replace(/(.*?)((&lt;math(\b.*?)&gt;.*?&lt;\/math&gt;)|$)/gi,		function (p, p1, p2) {

// convert html entities into actual dash characters p1 = p1.replace(/&plus;/g, '+'); p1 = p1.replace(/&minus;/g, '\u2212'); p1 = p1.replace(/&middot;/g, '·');

// convert dash next to a number into a minus sign character p1 = p1.replace(/([^\wŠŒŽšœžŸÀ-ÖØ-öø-\u0220\u0222-\u0233ΆΈΉΊΌΎΏΑ-ΡΣ-ώ\u0400-\u0481\u048a-\u04ce\u04d0-\u04f5\u04f8\u04f9\,\{])-(\d)/g, '$1\u2212$2');

// changes 2x3 to 2×3 p1 = p1.replace(/(\d *)x( *\d)/g, '$1\xd7$2');

// changes 10^3 to 103 p1 = p1.replace(/(\d*\.?\d+)\^(\u2212?\d+\.?\d*)/g, '$1&lt;sup&gt;$2&lt;/sup&gt;');

// change x^3 to x3			p1 = p1.replace(/([\wŠŒŽšœžŸÀ-ÖØ-öø-\u0220\u0222-\u0233ΆΈΉΊΌΎΏΑ-ΡΣ-ώ\u0400-\u0481\u048a-\u04ce\u04d0-\u04f5\u04f8\u04f9])\^(\u2212?\d+\.?\d*) /g, '$1&lt;sup&gt;$2&lt;/sup&gt;');

// change +/- to ± p1 = p1.replace(/( |\d)\+\/(-|\u2212)( |\d)/g, '$1\xb1$3');

// htmlize single char superscripts p1 = p1.replace(/(\xb9|&sup1;)/g, '&lt;sup&gt;1&lt;/sup&gt;'); p1 = p1.replace(/(\xb2|&sup2;)/g, '&lt;sup&gt;2&lt;/sup&gt;'); p1 = p1.replace(/(\xb3|&sup3;)/g, '&lt;sup&gt;3&lt;/sup&gt;');

return(p1 + p2); }	);	return; }

// // WikEdFixChem: fix chemical formulas //

window.WikEdFixChem = function(obj) {

WikEdFixBasic(obj);

var realElements = 'H|He|Li|Be|B|C|N|O|F|Ne|Na|Mg|Al|Si|P|S|Cl|Ar|K|Ca|Sc|Ti|V|Cr|Mn|Fe|Co|Ni|Cu|Zn|Ga|Ge|As|Se|Br|Kr|Rb|Sr|Y|Zr|Nb|Mo|Tc|Ru|Rh|Pd|Ag|Cd|In|Sn|Sb|Te|I|Xe|Cs|Ba|Hf|Ta|W|Re|Os|Ir|Pt|Au|Hg|Tl|Pb|Bi|Po|At|Rn|Fr|Ra|Rf|Db|Sg|Bh|Hs|Mt|Ds|Rg|La|Ce|Pr|Nd|Pm|Sm|Eu|Gd|Tb|Dy|Ho|Er|Tm|Yb|Lu|Ac|Th|Pa|U|Np|Pu|Am|Cm|Bk|Cf|Es|Fm|Md|No|Lr'; 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,		function (p, p1, p2, p3) {			if (p2 != 'e') {				p2 = p2.charAt(0).toUpperCase + p2.substr(1).toLowerCase;			}			return(p1 + p2 + p3);		}	);

// fix superscripts obj.plain = obj.plain.replace(/&plus;/g, '+'); obj.plain = obj.plain.replace(/&minus;/g, '\u2212'); obj.plain = obj.plain.replace(/&middot;/g, '·'); regExp = new RegExp('(' + realElements + pseudoElements + '|\\))(\\d*(\\+|-|\\u2212))', 'g');	obj.plain = obj.plain.replace(regExp, function (p, p1, p2, p3) { p2 = p2.replace(/-/g, '\u2212'); return(p1 + '&lt;sup&gt;' + p2 + '&lt;/sup&gt;'); }	);

// fix indices regExp = new RegExp('(' + realElements + pseudoElements + '|\\))(\\d+)', 'g');	obj.plain = obj.plain.replace(regExp, '$1&lt;sub&gt;$2&lt;/sub&gt;');

// fix prefixes regExp = new RegExp('(\\d+) *(\\(|' + realElements + pseudoElements + ')', 'g');	obj.plain = obj.plain.replace(regExp, '$1$2');

// fix arrows obj.plain = obj.plain.replace(/ *-+&gt; */g, ' \u2192 '); obj.plain = obj.plain.replace(/ *&lt;-+ */g, ' \u2190 ');

// &hdarr; and "leftwards harpoon over rightwards harpoon" not supported in IE6 //	obj.plain = obj.plain.replace(/ *(&lt;=+&gt;|&hdarr;|&harr;|\u2190 *\u2192) */g, ' \u21cc '); obj.plain = obj.plain.replace(/ *(&lt;==+&gt;|&hdarr;|&harr;|\u21cc|\u2190 *\u2192) */g, ' <=> ');

// fix - obj.plain = obj.plain.replace(/([\wŠŒŽšœžŸÀ-ÖØ-öø-\u0220\u0222-\u0233ΆΈΉΊΌΎΏΑ-ΡΣ-ώ\u0400-\u0481\u048a-\u04ce\u04d0-\u04f5\u04f8\u04f9]|\)|&gt;) +(-|\u2212) +([\wŠŒŽšœžŸÀ-ÖØ-öø-\u0220\u0222-\u0233ΆΈΉΊΌΎΏΑ-ΡΣ-ώ\u0400-\u0481\u048a-\u04ce\u04d0-\u04f5\u04f8\u04f9]|\/g, '$1 \u2212 $3');

return; }

// // WikEdFixUnits: unit formatter //

window.WikEdFixUnits = function(obj) {

WikEdFixBasic(obj);

// convert into actual characters obj.plain = obj.plain.replace(/&amp;deg;|&amp;#00b0;/g, '°'); obj.plain = obj.plain.replace(/&amp;#00b5;|&amp;mu;|&amp;micro;/g, 'µ'); obj.plain = obj.plain.replace(/&amp;Omega;|&amp;#8486;/g, '\u03a9');

// add space before units, remove space around /, and use abreviations obj.plain = obj.plain.replace(/( *\/ *|\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)(?=[^\wŠŒŽšœžŸÀ-ÖØ-öø-\u0220\u0222-\u0233ΆΈΉΊΌΎΏΑ-ΡΣ-ώ\u0400-\u0481\u048a-\u04ce\u04d0-\u04f5\u04f8\u04f9]|$)/g,		function (p, p1, p2, p3) {

p1 = p1.replace(/ *\/ */g, '/'); p1 = p1.replace(/(\d) */g, '$1 ');

p2 = p2.replace(/yotta/g, 'Y'); p2 = p2.replace(/zetta/g, 'Z'); p2 = p2.replace(/exa/g, 'E'); p2 = p2.replace(/peta/g, 'P'); p2 = p2.replace(/tera/g, 'T'); p2 = p2.replace(/giga/g, 'G'); p2 = p2.replace(/mega/g, 'M'); p2 = p2.replace(/kilo/g, 'k'); p2 = p2.replace(/K/g, 'k'); p2 = p2.replace(/hecto/g, 'h'); p2 = p2.replace(/deca/g, 'da'); p2 = p2.replace(/deci/g, 'd'); p2 = p2.replace(/centi/g, 'c'); p2 = p2.replace(/mill?i/g, 'm'); p2 = p2.replace(/micro|u/g, 'µ'); p2 = p2.replace(/nano/g, 'n'); p2 = p2.replace(/pico/g, 'p'); p2 = p2.replace(/femto/g, 'f'); p2 = p2.replace(/atto/g, 'a'); p2 = p2.replace(/zepto/g, 'z'); p2 = p2.replace(/yocto/g, 'y'); p2 = p2.replace(/mibi/g, 'mebi');

p3 = p3.replace(/gramm?s?/g, 'g'); p3 = p3.replace(/metres?|meters?/g, 'm'); p3 = p3.replace(/amperes?|Amperes?|amps?|Amps?/g, 'A'); p3 = p3.replace(/Angstroms?|Angströms?/g, 'Å'); p3 = p3.replace(/Kelvins?|kelvins?/g, 'K'); p3 = p3.replace(/moles?|Moles?/g, 'mol'); p3 = p3.replace(/candelas?/g, 'cd'); p3 = p3.replace(/Hert?z|hert?z/g, 'Hz'); p3 = p3.replace(/newtons?|Newtons?/g, 'N'); p3 = p3.replace(/Joules?|joules?/g, 'J'); p3 = p3.replace(/watts?|Watts?/g, 'W'); p3 = p3.replace(/pascals?|Pascals?/g, 'Pa'); p3 = p3.replace(/volts?|Volts?/g, 'V'); p3 = p3.replace(/ohms?|Ohms?/g, '\u03a9'); p3 = p3.replace(/bequerels?|Bequerels?/g, 'Bq'); p3 = p3.replace(/Farads?/g, 'F'); p3 = p3.replace(/bits?|Bits?/g, 'bit'); p3 = p3.replace(/bytes?|Bytes?/g, 'B'); p3 = p3.replace(/sec|seconds?/g, 's'); p3 = p3.replace(/minutes?/g, 'min'); p3 = p3.replace(/hours?/g, 'h'); p3 = p3.replace(/sec|seconds?/g, 's'); p3 = p3.replace(/bps/g, 'bit/s'); p3 = p3.replace(/Bps/g, 'B/s');

return(p1 + p2 + p3); }	);

// fix prefix casing obj.plain = obj.plain.replace(/ K(bit\/s|B\/s)([^\wŠŒŽšœžŸÀ-ÖØ-öø-\u0220\u0222-\u0233ΆΈΉΊΌΎΏΑ-ΡΣ-ώ\u0400-\u0481\u048a-\u04ce\u04d0-\u04f5\u04f8\u04f9]|$)/g, ' k$1$2'); obj.plain = obj.plain.replace(/ m(bit\/s|B\/s)([^\wŠŒŽšœžŸÀ-ÖØ-öø-\u0220\u0222-\u0233ΆΈΉΊΌΎΏΑ-ΡΣ-ώ\u0400-\u0481\u048a-\u04ce\u04d0-\u04f5\u04f8\u04f9]|$)/g, ' M$1$2'); obj.plain = obj.plain.replace(/ g(bit\/s|B\/s)([^\wŠŒŽšœžŸÀ-ÖØ-öø-\u0220\u0222-\u0233ΆΈΉΊΌΎΏΑ-ΡΣ-ώ\u0400-\u0481\u048a-\u04ce\u04d0-\u04f5\u04f8\u04f9]|$)/g, ' G$1$2'); obj.plain = obj.plain.replace(/ t(bit\/s|B\/s)([^\wŠŒŽšœžŸÀ-ÖØ-öø-\u0220\u0222-\u0233ΆΈΉΊΌΎΏΑ-ΡΣ-ώ\u0400-\u0481\u048a-\u04ce\u04d0-\u04f5\u04f8\u04f9]|$)/g, ' T$1$2'); obj.plain = obj.plain.replace(/ e(bit\/s|B\/s)([^\wŠŒŽšœžŸÀ-ÖØ-öø-\u0220\u0222-\u0233ΆΈΉΊΌΎΏΑ-ΡΣ-ώ\u0400-\u0481\u048a-\u04ce\u04d0-\u04f5\u04f8\u04f9]|$)/g, ' E$1$2');

return; }

// // WikEdFixDashes: fixes dashes and minus signs //

window.WikEdFixDashes = function(obj) {

WikEdFixBasic(obj);

// convert html character entities into actual dash characters obj.plain = obj.plain.replace(/&amp;mdash;/g, '—'); obj.plain = obj.plain.replace(/&amp;ndash;/g, '–'); obj.plain = obj.plain.replace(/&amp;minus;/g, '\u2212');

// remove spaces around em dashes obj.plain = obj.plain.replace(/([a-zA-Z\'\"”\]\}\)])( |&amp;nbsp;)*—( |&amp;nbsp;)*([a-zA-Z\'\"“\[\{\(])/g, '$1—$4');

// convert -- to em dashes obj.plain = obj.plain.replace(/([a-zA-Z\'\"”\]\}\)])( |&amp;nbsp;)*--( |&amp;nbsp;)*([a-zA-Z\'\"“\[\{\(])/g, '$1—$4');

// convert hyphen next to lone number into a minus sign character obj.plain = obj.plain.replace(/([a-zA-Z\'\"”\]\>] ) *(\u2212|–)(\d)/g, '$1\u2212$3');

// convert minus or en dashes to dashes with spaces obj.plain = obj.plain.replace(/([a-zA-Z\'\"”\]\}])( |&amp;nbsp;)*(\u2212|–)( |&amp;nbsp;)*([a-zA-Z\'\"“\[\{])/g, '$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');

return; }

// // WikEdFixHTML: fix html to wikicode //

window.WikEdFixHTML = function(obj) {

WikEdFixBasic(obj);

// remove syntax highlighting obj.html = obj.plain; obj.html = obj.html.replace(/\n/g, ' '); WikEdRemoveHighlighting(obj);

// keep in blockquote obj.html = obj.html.replace(/(&lt;blockquote\b.*?&gt;)([\S\s]*?)(&lt;\/blockquote&gt;)/gi,		function (p, p1, p2, p3) {			p2 = p2.replace(/&lt;(br\b.*?)&gt;<br\b[^>]*>/g, '\x00$1\x01\n');			return(p1 + p2 + p3);		}	);

// keep in tables (and certain templates!?) obj.html = obj.html.replace(/(<br\b[^>]*>\|)([^\}][\S\s]*?)(?=<br\b[^>]*>\|)/gi,		function (p, p1, p2) {			p2 = p2.replace(/&lt;(br\b.*?)&gt;/g, '\x00$1\x01');			return(p1 + p2);		}	);

// detect outermost template tags var depth = 0; obj.html = obj.html.replace(/((\{\{)|\}\})/g,		function (p, p1, p2) {			if (p2 != ) {				depth ++;				if (depth == 1) {					return( + p1);				}				return(p1);			}			depth --;			if (depth == 0) {				return(p1 + '');			}			return(p1);		}	);

// keep in templates obj.html = obj.html.replace(/([\S\s]*?)/g,		function (p, p1) {			return(p1.replace(/&lt;(br\b.*?)&gt;/g, '\x00$1\x01'));		}	);

// detect outermost table tags var depth = 0; obj.html = obj.html.replace(/(((^|<br\b[^>]*>)\{\|)|<br\b[^>]*>\|\})/g,		function (p, p1, p2, p3) {			if (p2 != ) {				depth ++;				if (depth == 1) {					return( + p1);				}				return(p1);			}			depth --;			if (depth == 0) {				return(p1 + '');			}			return(p1);		}	);

// keep in tables obj.html = obj.html.replace(/([\S\s]*?)/g,		function (p, p1) {			return(p1.replace(/&lt;(br\b.*?)&gt;/g, '\x00$1\x01'));		}	);

// turn visible html code into real html, exclude comments obj.html = obj.html.replace(/&lt;(\/?\w.*?)&gt;/g, '<$1>');

// restore valid s	obj.html = obj.html.replace(/\x00(.*?)\x01/g, '&lt;$1&gt;');

// wikify, keep user added attribute WikEdWikifyHTML(obj, true);

// turn real html into visible html code obj.html = obj.html.replace(/<br\b[^>]*>[\r\n ]*/g, '\n'); obj.html = obj.html.replace(/</g, '&lt;'); obj.html = obj.html.replace(/>/g, '&gt;'); obj.plain = obj.html;

return; }

// // WikEdFixCaps: fix capitalizing of lists, linklists, images, headings //

window.WikEdFixCaps = function(obj) {

WikEdFixBasic(obj);

// uppercase lists // start (listcode (char-ent|tag|category..|digit|non-word,non-ret))(word,non-digit..) end obj.plain = obj.plain.replace(/^((\||[\*\#\:\;]+)[ \'\"]*(\'+|\&\w+\;|&lt;[^\n]*?&gt;|\{\{.*?\}\}[^\n]*|\d|[^\wŠŒŽšœžŸÀ-ÖØ-öø-\u0220\u0222-\u0233ΆΈΉΊΌΎΏΑ-ΡΣ-ώ\u0400-\u0481\u048a-\u04ce\u04d0-\u04f5\u04f8\u04f9\n])*)([^\wŠŒŽšœžŸÀ-ÖØ-öø-\u0220\u0222-\u0233ΆΈΉΊΌΎΏΑ-ΡΣ-ώ\u0400-\u0481\u048a-\u04ce\u04d0-\u04f5\u04f8\u04f9\d\n\r].*?)?$/gm,		function (p, p1, p2, p3, p4) {			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) {						p2 = p2.charAt(0).toUpperCase + p2.substr(1);						return(p1 + p2);					}				); }			return(p1 + p4); }	);

// uppercase link lists (link) //                               12 table list   2            13       34    4 obj.plain = obj.plain.replace(/^((\||[\*\#\:\;]+)[ \'\"]*\[\[)([^\n]*?)(\]\])/gm,		function (p, p1, p2, p3,p4) {

// uppercase link p3 = p3.replace(/^((\&\w+\;|[^\wŠŒŽšœžŸÀ-ÖØ-öø-\u0220\u0222-\u0233ΆΈΉΊΌΎΏΑ-ΡΣ-ώ\u0400-\u0481\u048a-\u04ce\u04d0-\u04f5\u04f8\u04f9]|\d)*)([a-zA-ZŠŒŽšœžŸÀ-ÖØ-öø-\u0220\u0222-\u0233ΆΈΉΊΌΎΏΑ-ΡΣ-ώ\u0400-\u0481\u048a-\u04ce\u04d0-\u04f5\u04f8\u04f9_].*)$/,				function (p, p1, p2, p3) {					if (p3.match(/^(http|ftp|alpha|beta|gamma|delta|epsilon|kappa|lambda)/) == null) {						p3 = p3.charAt(0).toUpperCase + p3.substr(1);					}					return(p1 + p3);				}			);

// uppercase comment p3 = p3.replace(/(\| *(\&\w+\;|&lt;[^\n]*?&gt;|[^\wŠŒŽšœžŸÀ-ÖØ-öø-\u0220\u0222-\u0233ΆΈΉΊΌΎΏΑ-ΡΣ-ώ\u0400-\u0481\u048a-\u04ce\u04d0-\u04f5\u04f8\u04f9\|]|\d)*)([a-zA-ZŠŒŽšœžŸÀ-ÖØ-öø-\u0220\u0222-\u0233ΆΈΉΊΌΎΏΑ-ΡΣ-ώ\u0400-\u0481\u048a-\u04ce\u04d0-\u04f5\u04f8\u04f9_][^\|]*)$/,				function (p, p1, p2, p3) {					if (p3.match(/^(http|ftp|alpha|beta|gamma|delta|epsilon|kappa|lambda)/) == null) {						p3 = p3.charAt(0).toUpperCase + p3.substr(1);					}					return(p1 + p3);				}			); return(p1 + p3 + p4); }	);

// uppercase headings obj.plain = obj.plain.replace(/^(=+ (\&\w+\;|&lt;[^\n]*?&gt;|\d|[^\wŠŒŽšœžŸÀ-ÖØ-öø-\u0220\u0222-\u0233ΆΈΉΊΌΎΏΑ-ΡΣ-ώ\u0400-\u0481\u048a-\u04ce\u04d0-\u04f5\u04f8\u04f9\n])*)([a-zA-ZŠŒŽšœžŸÀ-ÖØ-öø-\u0220\u0222-\u0233ΆΈΉΊΌΎΏΑ-ΡΣ-ώ\u0400-\u0481\u048a-\u04ce\u04d0-\u04f5\u04f8\u04f9_].*? =+)$/gm,		function (p, p1, p2, p3) {			if (p3.match(/^(http|ftp|alpha|beta|gamma|delta|epsilon|kappa|lambda)/) == null) {				p3 = p3.charAt(0).toUpperCase + p3.substr(1);			}			return(p1 + p3);		}	);

// uppercase images regExp = new RegExp('(\\[\\[)((Image|File|' + wikEdText['wikicode Image'] + ')|(' + wikEdText['wikicode File'] + ')):([\\wŠŒŽšœžŸÀ-ÖØ-öø-\\u0220\\u0222-\\u0233ΆΈΉΊΌΎΏΑ-ΡΣ-ώ\\u0400-\\u0481\\u048a-\\u04ce\\u04d0-\\u04f5\\u04f8\\u04f9])([^\\n]*\\]\\])', 'igm'); obj.plain = obj.plain.replace(regExp,		function (p, p1, p2, p3, p4, p5, p6) {			if (p3 != '') {				p3 = wikEdText['wikicode Image'];			}			else {				p4 = wikEdText['wikicode File'];			}			return(p1 + p3 + p4 + ':' + p5.toUpperCase + p6);		}	);

return; }

// // WikEdFixTypos: fix typos using the AutoWikiBrowser/RegExTypoFix list (.test is not faster) //

window.WikEdFixTypos = function(obj) {

WikEdFixBasic(obj);

//	split into alternating plain text and template fragments (does not support nested templates) var fragment = []; var nextPos = 0; var regExp = new RegExp('', 'gi'); while ( (regExpMatch = regExp.exec(obj.plain)) != null) { fragment.push(obj.plain.substring(nextPos, regExpMatch.index)); fragment.push(regExpMatch[0]); nextPos = regExp.lastIndex; }	fragment.push(obj.plain.substring(nextPos));

// cycle through the RegExTypoFix rules for (var i = 0; i < wikEdTypoRulesFind.length; i ++) {

// cycle through the fragments, jump over templates for (var j = 0; j < fragment.length; j = j + 2) { fragment[j] = fragment[j].replace(wikEdTypoRulesFind[i], wikEdTypoRulesReplace[i]); }	}

// re-assemble text obj.plain = fragment.join('');

return; }

// // WikEdFixAll: //

window.WikEdFixAll = function(obj) { WikEdFixBasic(obj); WikEdFixUnicode(obj); WikEdFixHTML(obj); WikEdFixCaps(obj); return; }

// // WikEdRemoveElements: remove elements by tag name //

window.WikEdRemoveElements = function(tagNameArray) {

// cycle through the element names for (var property in tagNameArray) { if ((tagNameArray[property]) != 'string') { continue; }		var elementArray = wikEdFrameDocument.getElementsByTagName(tagNameArray[property]); for (var i = 0; i < elementArray.length; i ++) { elementArray[i].parentNode.removeChild(elementArray[i]); }	}	return; }

// // WikEdFindBoundaries: find word boundaries and line boundaries starting from selection.range //

window.WikEdFindBoundaries = function(word, line, para, whole, selection) {

// get the start node and offset var startNode = selection.range.startContainer; var startNodeOffset = selection.range.startOffset;

// get the end node and offset var endNode = selection.range.endContainer; var endNodeOffset = selection.range.endOffset;

//// todo: when selecting whole lines with BR do not walk into next line

if (startNode.nodeType == 1) { startNode = startNode.childNodes[startNodeOffset]; startNodeOffset = 0; }	if (endNode.nodeType == 1) { endNode = endNode.childNodes[endNodeOffset]; endNodeOffset = 0; }

// find the start and end nodes in the whole plain text arrays var startNodeIndex; var endNodeIndex; for (var i = 0; i < whole.plainNode.length; i ++) { if (startNode == whole.plainNode[i]) { startNodeIndex = i;		} if (endNode == whole.plainNode[i]) { endNodeIndex = i;			break; }	}

// find last previous word and line boundary var foundWord = false; var foundLine = false; var foundPara = false; var regExp = new RegExp('.*[^\\w\\-ŠŒŽšœžŸÀ-ÖØ-öø-\\u0220\\u0222-\\u0233ΆΈΉΊΌΎΏΑ-ΡΣ-ώ\\u0400-\\u0481\\u048a-\\u04ce\\u04d0-\\u04f5\\u04f8\\u04f9]', 'g'); var plainPrev = '';

// check text nodes left-wise for a boundary var plain = ''; for (var i = startNodeIndex; i >= 0; i --) { plainPrev = plain; plain = whole.plainArray[i]; plain = plain.replace(/&amp;/g, '&'); plain = plain.replace(/&lt;/g, '<'); plain = plain.replace(/&gt;/g, '>');

// boundary is a new paragraph if ( (plainPrev == '\n') && (plain == '\n') ) { para.range.setStartAfter(whole.plainNode[i + 1]); foundPara = true; break; }

// boundary is a newline else if (plain == '\n') { if (foundWord == false) { word.range.setStartAfter(whole.plainNode[i]); foundWord = true; }			if (foundLine == false) { line.range.setStartAfter(whole.plainNode[i]); foundLine = true; }		}

// check text node for a word boundary else if (foundWord == false) { if (i == startNodeIndex) { plain = plain.substr(0, startNodeOffset); }			regExp.lastIndex = 0; if (regExp.exec(plain) != null) { word.range.setStart(whole.plainNode[i], regExp.lastIndex); foundWord = true; }		}	}

// boundary is start of text if (foundPara == false) { para.range.setStartBefore(whole.plainNode[0]); }	if (foundLine == false) { line.range.setStartBefore(whole.plainNode[0]); }	if (foundWord == false) { word.range.setStartBefore(whole.plainNode[0]); }

// find next word and line boundary regExp = new RegExp('[^\\w\\-ŠŒŽšœžŸÀ-ÖØ-öø-\\u0220\\u0222-\\u0233ΆΈΉΊΌΎΏΑ-ΡΣ-ώ\\u0400-\\u0481\\u048a-\\u04ce\\u04d0-\\u04f5\\u04f8\\u04f9]', 'g'); foundWord = false; foundLine = false; foundPara = false;

// check text nodes right-wise for a boundary plain = ''; for (var i = endNodeIndex; i < whole.plainArray.length; i ++) { plainPrev = plain; plain = whole.plainArray[i]; plain = plain.replace(/&amp;/g, '&'); plain = plain.replace(/&lt;/g, '<'); plain = plain.replace(/&gt;/g, '>');

// boundary is a double newline if ( (plainPrev == '\n') && (plain == '\n') ) { para.range.setEndBefore(whole.plainNode[i]); foundPara = true; break; }

// boundary is a newline else if (plain == '\n') { if (foundWord == false) { word.range.setEndBefore(whole.plainNode[i]); foundWord = true; }			if (foundLine == false) { line.range.setEndBefore(whole.plainNode[i]); //// crashes for empty selection foundLine = true; }		}

// check text node for a word boundary else if (foundWord == false) { if (i == endNodeIndex) { regExp.lastIndex = endNodeOffset; }			else { regExp.lastIndex = 0; }			var regExpArray = regExp.exec(plain); if (regExpArray != null) { word.range.setEnd(whole.plainNode[i], regExpArray.index); foundWord = true; }		}	}

// boundary is end of text if (foundPara == false) { para.range.setEndAfter(whole.plainNode[whole.plainArray.length - 1]); }	if (foundLine == false) { line.range.setEndAfter(whole.plainNode[whole.plainArray.length - 1]); }	if (foundWord == false) { word.range.setEndAfter(whole.plainNode[whole.plainArray.length - 1]); }

return; }

// // remove syntax highlighting and wikify //

window.WikEdRemoveHighlightingWikify = function(obj, wikify) {

if ( (obj.html != '') || (wikify == true) ) {

// ... to for Safari, Chrome, WebKit if ( (wikEdSafari == true) || (wikEdChrome == true) || (wikEdWebKit == true) ) { var isRemove = []; obj.html = obj.html.replace(/(<(\/?)div\b([^>]*)>)/g,				function (p, p1, p2, p3) {					if (p2 == ) {						if (p3 == ) {							isRemove.push(true);							return('\x00');						}						isRemove.push(false);						return(p1);					}					if (isRemove.pop == true) {						return('\x01');					}					return(p1);				}			); obj.html = obj.html.replace(/\x01\x00/g, '\x01'); obj.html = obj.html.replace(/[\x00\x01]/g, ' '); }

// remove syntax highlighting WikEdRemoveHighlighting(obj);

// wikify, don't allow many attributes if ( (obj.htmlCode == true) && (wikify != false) ) { WikEdWikifyHTML(obj, false); }	}	return; }

// // WikEdWikifyHTML: //  obj.html contains the text to be wikified //  expects < > &lt; &gt; &amp;  spaces instead of   (not \n) //  returns (not \n)

/*	allowed and converted tags: br|p h1|h2|h3|h4|h5|h6 hr i|dfn|cite|em|var b|strong table|caption|col|thead|tfoot|tbody|tr|td|th dl|dt|dd|li|ol|ul a not allowed yet: bdo|q|kbd|samp|abbr|acronym|label other allowed tags: big|blockquote|colgroup|center|code|del|div|font|ins|pre|s|small|span|strike|sub|sup|tt|u|rb|rp|rt|ruby mediawiki tags (inline/block): nowiki|math|noinclude|includeonly|ref|charinsert|fundraising|fundraisinglogo gallery|source|poem|categorytree|hiero|imagemap|inputbox|timeline|references



window.WikEdWikifyHTML = function(obj, relaxed) {

var regExpStr; var regExp; var regExpMatch;

// delete tags: 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 regExp = /<div\b[^>]*\bid=\"catlinks\"[^>]*>(.*?)<\/div>\s*/g; while(regExp.test(obj.html) == true) { obj.html = obj.html.replace(regExp, '$1'); }	regExp = /<p\b[^>]*?\bclass=\"catlinks\"[^>]*>(.*?)<a\b[^>]*>[^<>]+<\/a>: (.*?)<\/p>/g; while(regExp.test(obj.html) == true) { obj.html = obj.html.replace(regExp, '$1$2'); }

// convert MS-Word non-standard lists: * obj.html = obj.html.replace(/\s*<p [^>]*>\s*.*?\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,		function(p, p1, p2, p3) {			footnotes[p1] = p3.replace(/^(\s|<br\b[^>]*>)|(\s|<br\b[^>]*>)$/g, );			return();		}	);

// add footnotes as tags obj.html = obj.html.replace(/<a\b[^>]* name="_ftnref(\d+)"[^>]*>(.|\n)*?\s*<\/span>\s*<\/span>\s*<\/a>/g,		function(p, p1) {			var ref = '&lt;ref name="footnote_' + p1 + '"&gt;' + footnotes[p1] + '&lt;/ref&gt;';			return(ref);		}	);

// remove MS-Word footnote separator obj.html = obj.html.replace(/(\s|<br\b[^>]*>)*<hr\b[^>]*>\s*(\s|<br\b[^>]*>)*/g, '');

// correct name for MS-Word images //                            1                                                    2    2                  3      3       4    4                                 1             5            5	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 ... to ... 	var isPoem = []; obj.html = obj.html.replace(/(<(\/?)div\b([^>]*)>)/gi,		function (p, p1, p2, p3) {			if (p2 == '') {				if (/\bclass=\"poem\"/.test(p3) == true) {					isPoem.push(true);					return(' ');				}				isPoem.push(false);				return(p1);			}			if (isPoem.pop == true) {				return(' ');			}			return(p1);		}	);

// sanitize obj.html = obj.html.replace(/<(span|div|p)\b *(.*?) *\/?>/gi,		function (p, p1, p2) {			return('<' + p1 + WikEdSanitizeAttributes(p1, p2, relaxed) + '>');		}	);

// remove ... pairs withhout attributes var isRemove = []; obj.html = obj.html.replace(/(<(\/?)span\b([^>]*)>)/gi,		function (p, p1, p2, p3) {			if (p2 == ) {				if (p3 == ) {					isRemove.push(true);					return();				}				isRemove.push(false);				return(p1);			}			if (isRemove.pop == true) {				return();			}			return(p1);		}	);

// remove ... pairs withhout attributes var isRemove = []; obj.html = obj.html.replace(/(<(\/?)p\b([^>]*)>)/gi,		function (p, p1, p2, p3) {			if (p2 == ) {				if (p3 == ) {					isRemove.push(true);					return('\x00\x00');				}				isRemove.push(false);				return(p1);			}			if (isRemove.pop == true) {				return('\x00\x00');			}			return(p1);		}	);

// escape character entities obj.html = obj.html.replace(/&(?!(amp;|lt;|gt;))/g, '&amp;');

// remove comments obj.html = obj.html.replace(//g, '');

// horizontal rule obj.html = obj.html.replace(/(\s|<br\b[^>]*>|\x00)*<hr\b[^>]*>(\s|<br\b[^>]*>|\x00)*/gi, '\x00\x00\x00\x00');

// <i> 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> bold obj.html = obj.html.replace(/<(b|strong)\b[^>]*>/gi, '\'\'\''); obj.html = obj.html.replace(/<\/(b|strong)\b[^>]*>/gi, '\'\'\'');

// .. 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'); obj.html = obj.html.replace(/(\s|<br\b[^>]*>|\x00)*(^|\n|<br\b[^>]*>|\x00)(\s|<br\b[^>]*>|\x00)*<h3\b[^>]*>(.*?)<\/h3>(\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)*<h4\b[^>]*>(.*?)<\/h4>(\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)*<h5\b[^>]*>(.*?)<\/h5>(\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)*<h6\b[^>]*>(.*?)<\/h6>(\s|<br\b[^>]*>|\x00)*/gi, '\x00\x00====== $4 ======\x00\x00');

obj.html = obj.html.replace(/<(h[0-6])\b[^>]*>(.*?)<\/\1>/gi, '$2');

// // convert html tables to wikicode if (wikEdTableMode == false) {

// remove obj.html = obj.html.replace(/(\s|\x00|<br\b[^>]*>)<\/?(thead|tbody|tfoot)\b[^>]*>(\s|\x00|<br\b[^>]*>)*/gi, '$1');

// remove and  \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) {				p3 = p3.replace(/^(\s|<br\b[^>]*>|\x00>)+/gi, );				p3 = p3.replace(/(\s|<br\b[^>]*>|\x00>)+$/gi, );				p3 = p3.replace(/<br\b[^>]*> */gi, '&lt;br /&gt;');				return(p1 + p3 + p4);			}		);

// remove table closing tags obj.html = obj.html.replace(/(\s|<br\b[^>]*>|\x00)*<\/(tr|thead|tbody|tfoot)>(\s|<br\b[^>]*>|\x00)*/gi, '');

// table cells obj.html = obj.html.replace(/(\s|<br\b[^>]*>|\x00)* (\s|<br\b[^>]*>|\x00)*/gi, '\x00| '); obj.html = obj.html.replace(/(\s|<br\b[^>]*>|\x00)*<(td) +([^>]*)>(\s|<br\b[^>]*>|\x00)*/gi,			function (p, p1, p2, p3, p4) {				p3 = WikEdSanitizeAttributes(p2, p3, relaxed);				if (p3 == '') {					return('\x00| ');				}				else {					return('\x00|' + p3 + ' | ');				}			}		);

// table cells obj.html = obj.html.replace(/(\s|<br\b[^>]*>|\x00)* (\s|<br\b[^>]*>|\x00)*/gi, '\x00| '); obj.html = obj.html.replace(/(\s|<br\b[^>]*>|\x00)*<(th) +([^>]*)>(\s|<br\b[^>]*>|\x00)*/gi,			function (p, p1, p2, p3, p4) {				p3 = WikEdSanitizeAttributes(p2, p3, relaxed);				if (p3 == '') {					return('\x00| ');				}				else {					return('\x00|' + p3 + ' | ');				}			}		);

// table rows obj.html = obj.html.replace(/(\s|<br\b[^>]*>|\x00)* (\s|<br\b[^>]*>|\x00)*/gi, '\x00|-\x00'); obj.html = obj.html.replace(/(\s|<br\b[^>]*>|\x00)*<(tr) +([^>]*)>(\s|<br\b[^>]*>|\x00)*/gi,			function (p, p1, p2, p3, p4) {				return('\x00|-' + WikEdSanitizeAttributes(p2, p3, relaxed) + '\x00');			}		);

// table caption obj.html = obj.html.replace(/(\s|<br\b[^>]*>|\x00)* (\s|<br\b[^>]*>|\x00)*/gi, '\x00|+ '); obj.html = obj.html.replace(/(\s|<br\b[^>]*>|\x00)*<(caption) +([^>]*)>(\s|<br\b[^>]*>|\x00)*/gi,			function (p, p1, p2, p3, p4) {				p3 = WikEdSanitizeAttributes(p2, p3, relaxed);				if (p3 == '') {					return('\x00|+ ');				}				else {					return('\x00|+' + p3 + ' | ');				}			}		);

// 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[^>]*>[\r\n ]*/gi, '\x00');

// 		obj.html = obj.html.replace(/[\s\x00]* [\s\x00]*(\|-(?=[\n\x00]))?/gi, '\x00\x00{|\x00'); obj.html = obj.html.replace(/[\s\x00]*<(table) +([^>]*)>[\s\x00]*(\|-(?=[\n\x00]))?/gi,			function (p, p1, p2) {				var table = '\x00\x00{|';				if (wikEdWikifyTableParameters != '') {					table += ' ' + wikEdWikifyTableParameters;				}				else {					table += WikEdSanitizeAttributes(p1, p2);				}				return(table);			}		); obj.html = obj.html.replace(/[\s\x00]*<\/table>[\s\x00]*/gi, '\x00|}\x00\x00');

}

// for table mode override pasted table class // else if (wikEdTableMode == true) { obj.html = obj.html.replace(/(<table\b)([^>]*)(>)/gi,			function (p, p1, p2, p3) {				if (p2.match(/\bclass=/)) {					p2 = p2.replace(/\bclass\s*=\s*([\'\"]?)[^<>\'\"\n]*?\2/g, 'class="wikEdTableEdit"');				}				else {					p2 = ' class="wikEdTableEdit"';				}				return(p1 + p2 + p3);			}		);

// 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 (wikEdTableMode == true) { obj.html = obj.html.replace(/<br\b[^>]*>[\r\n ]*/gi, '\x00'); }

// convert links var regExpMatch = []; var regExpStr = '(<a(\\b[^>]*)>(.*?)</a>)'; var regExp = new RegExp(regExpStr, 'gi'); obj.html = obj.html.replace(regExp,		function (p, p1, p2, p3) {			var linkParam = p2;			var linkText = p3;			var hrefUrlParam;			var hrefUrlArticle;			var imgWidth = ;			var hrefParamTitle;			var hrefParamISBN;			var hrefParamSpecial;			var linkArticleAnchor = ;			var linkArticle = ;			var linkTitle = ;

// get href value var hrefValue; regExpMatch = linkParam.match(/ href=\"([^\">]*)\"/);			if (regExpMatch != null) {				hrefValue = regExpMatch[1];

// get absolute path from ./index.php and ../../index.php hrefValue = WikEdRelativeToAbsolutePath(hrefValue);

// check for wiki article link and get parameters //                                1                        2 article   2                       3article 314 anchor 4                          6                       7   8 urlpar 87539 anchor 9 regExpStr = wikEdServer + '(' + wikEdArticlePath + '([^\\"\\?#]+)|' + wikEdScript + '\\?([^\\"#]*))(#[^\\"]*)?';				regExp = new RegExp(regExpStr);				regExpMatch = regExp.exec(hrefValue);				if (regExpMatch != null) {

// article name from url path <a href="../wiki/ hrefUrlArticle "> if (regExpMatch[2] != null) { hrefUrlArticle = regExpMatch[2]; }

// article name from url parameters <a href="url? hrefUrlParam "> else if (regExpMatch[3] != null) { hrefUrlParam = regExpMatch[3]; }

// link anchor <a href="link #anchor"> if (regExpMatch[4] != null) { linkArticleAnchor = regExpMatch[4]; linkArticleAnchor = linkArticleAnchor.replace(/\.([0-9A-F]{2})/g, '%$1'); linkArticleAnchor = decodeURIComponent(linkArticleAnchor); linkArticleAnchor = linkArticleAnchor.replace(/_\d+$/g, ''); }

// parse hrefUrlParam and check for special parameters if (hrefUrlParam != null) { regExp = new RegExp('(^|&amp;)(\\w+)=([^\\"\\&]+)', 'g');						while ( (regExpMatch = regExp.exec(hrefUrlParam)) != null) {							switch (regExpMatch[2]) {								case 'title':									hrefParamTitle = regExpMatch[3];									break;								case 'isbn':									hrefParamISBN = regExpMatch[3];									break;								case 'redlink':									break;								case 'action':									hrefParamAction = regExpMatch[3];									if (hrefParamAction == 'edit') {										break;									}								default:									hrefParamSpecial = true;							}						}					}

// ISBN links if ( (hrefParamISBN != null) && (hrefParamSpecial != true) ) { var isbn = hrefParamISBN; regExpMatch = /((\d\-?){13}|(\d\-?){10})/.exec(linkText); if (regExpMatch != null) { isbn = regExpMatch[1]; }						return('ISBN ' + isbn); }

// get article from href parameters else if ( (hrefParamTitle != null) && (hrefParamSpecial != true) ) { linkArticle = hrefParamTitle; linkArticle = linkArticle.replace(/_/g, ' '); linkArticle = decodeURIComponent(linkArticle); }

// get article name from url path else if (hrefUrlArticle != null) { linkArticle = hrefUrlArticle; linkArticle = linkArticle.replace(/_/g, ' '); linkArticle = decodeURIComponent(linkArticle); }

// get article name from else { regExpMatch = / title=\"([^\">]+)\"/.exec(linkParam);						if (regExpMatch != null) {							linkArticle = regExpMatch[1];						}					}				}

// format wiki link if (linkArticle != '') {

// check for wiki image regExpStr = '^<img\\b[^>]*?\\bwidth=\\"(\\d+)\\"[^>]*?>$'; regExp = new RegExp(regExpStr); regExpMatch = regExp.exec(linkText); if (regExpMatch != null) { imgWidth = regExpMatch[1]; imgWidth = '|' + imgWidth + 'px'; if ( (linkTitle != '') && (linkTitle != 'Enlarge') ) { linkTitle = '|' + linkTitle; return( + linkArticle + imgWidth + linkTitle + ); }						else { return( + linkArticle + imgWidth + ); }					}

// category link var regExp = new RegExp('^(Category|' + wikEdText['wikicode Category'] + ')\\s*:(.*)', 'i'); regExpMatch = regExp.exec(linkArticle); if (regExpMatch != null) { return( + wikEdText['wikicode Category'] + ':' + regExpMatch[1].charAt(0).toUpperCase + linkText.substr(1) + ); }

// wiki link if (linkArticle == linkText.charAt(0).toUpperCase + linkText.substr(1)) { return( + linkText + linkArticleAnchor + ); }

// date link (English only) regExpMatch = /^(January|February|March|April|May|June|July|August|September|October|November|December) (\d{1,2})$/.exec(linkArticle); if (regExpMatch != null) { var month = regExpMatch[1]; var day = regExpMatch[2]; if (linkText == (day + ' ' + month) ) { return( + linkArticle + linkArticleAnchor + ); }					}

// 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 ) { linkArticle = linkArticle.charAt(0).toLowerCase + linkArticle.substr(1); }					}

// suffix links regExpStr = '^' + linkArticle.replace(/(\W)/g, '\\$1') + '([\\wŠŒŽšœžŸÀ-ÖØ-öø-\\u0220\\u0222-\\u0233ΆΈΉΊΌΎΏΑ-ΡΣ-ώ\\u0400-\\u0481\\u048a-\\u04ce\\u04d0-\\u04f5\\u04f8\\u04f9]+)$'; regExp = new RegExp(regExpStr); regExpMatch = regExp.exec(linkText); if (regExpMatch != null) { return( + linkArticle + linkArticleAnchor +  + regExpMatch[1]); }					return( + linkText + ); }

// external link if (hrefValue != '') {

// PubMed link regExpMatch = /^http:\/\/www\.ncbi\.nlm\.nih\.gov\/entrez\/query\.fcgi\?cmd=Retrieve&amp;db=pubmed&amp;.*?&amp;list_uids=(\d+)/.exec(hrefValue); if (regExpMatch != null) { return('PMID ' + regExpMatch[1]); }

// DOI link regExpMatch = /^http:\/\/dx\.doi\.org\/(.*)/.exec(hrefValue); if (regExpMatch != null) { return(''); }

// other external link return('[' + hrefValue + ' ' + linkText + ']'); }			}

// return unchanged text return(p1); }	);

// clean up MediaWiki category list var regExp = new RegExp('<span\\b[^>]*>(\\[\\[(Category|' + wikEdText['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);			if (regExpMatch != null) {				address = regExpMatch[2].replace(/^ +| +$/g, '');			}

var imgAlt = ''; regExpMatch = /\balt\s*=\s*(\'|\")([^\'\"]*)(\'|\")/i.exec(p1);			if (regExpMatch != null) {				imgAlt = regExpMatch[2].replace(/^ +| +$/g, );				imgAlt = imgAlt.replace(/&amp;nbsp;|[\n\x00]/g, ' ');				imgAlt = imgAlt.replace(/ {2,}/g, ' ');				imgAlt = imgAlt.replace(/^ | $/g, );				if (imgAlt != '') {					imgAlt = '|' + imgAlt;				}			}

var imgWidth = ''; regExpMatch = /\bwidth\s*=\s*(\'|\")([^\'\"]*)(\'|\")/i.exec(p1);			if (regExpMatch != null) {				imgWidth = '|' + regExpMatch[2].replace(/^ +| +$/g, '') + 'px';			}

var imgLink = ''; regExpMatch = /([^\/]+)$/.exec(address); if (regExpMatch != null) { imgLink = regExpMatch[1]; if (imgLink != '') { return( + wikEdText['wikicode Image'] + ':' + imgLink + imgWidth + imgAlt + ); }			}			return(''); }	);

// convert lists: * # : ; var listObj = {}; listObj.prefix = ''; obj.html = obj.html.replace(/[\s\x00]*<(\/?(ol|ul|li|dl|dd|dt))\b[^>]*>[\s\x00]*/gi,		function (p, p1, p2, p3, p4) {			switch (p1.toLowerCase) {				case 'ol':					listObj.prefix += '#';					return('\x00');				case 'ul':					listObj.prefix += '*';					return('\x00');				case 'dl':					listObj.prefix += ':';					return('\x00');				case '/ol':				case '/ul':				case '/dl':					listObj.prefix = listObj.prefix.substr(0, listObj.prefix.length - 1);					return('\x00\x00');				case 'li':				case 'dd':					return('\x00' + listObj.prefix + ' ');				case 'dt':					return('\x00' + listObj.prefix.replace(/:$/, ';') + ' ');				case '/li':				case '/dt':				case '/dd':					return();			}			return();		}	); 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) {			if (wikEdTableMode == true) {				if ( /^(table|tr|td|th|thead|tbody|tfoot|col|colgroup|caption)$/i.test(p3) ) {					var tag = p1 + p2 + p3 + p4;					tag = tag.replace(/</g, '\x01');					tag = tag.replace(/>/g, '\x02');					return(tag);				}				else {					return();				}			}			else 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)$/i.test(p3) ) {				return(p1 + p2 + p3 + p4);			}			else {				return();			}		}	);

// sanitize attributes in opening html tags obj.html = obj.html.replace(/<(\w+) +(.*?) *(\/?)>/g,		function (p, p1, p2, p3) {			if (p3 != '') {				p3 = ' ' + p3;			}			return('<' + p1 + WikEdSanitizeAttributes(p1, p2, relaxed) + p3 + '>');		}	);

// unformat underlined, italic or bold blanks obj.html = obj.html.replace(/ (\'\'\'|\'\'|\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>|\'\'\'|\'\')+( *\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) {			return(p1.replace(/\n/g, '\x00'));		}	); obj.html = obj.html.replace(/\x00\s+/g, '\x00'); obj.html = obj.html.replace(/\s+(?=\x00)/g, '\x00');

// 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) {			p2 = p2.replace(/\x00/g, ' \n');			return(p1 + p2 + p3);		}	);

// escape < > obj.html = obj.html.replace(/</g, '&lt;'); obj.html = obj.html.replace(/>/g, '&gt;');

// preserved table tags obj.html = obj.html.replace(/\x01/g, '<'); obj.html = obj.html.replace(/\x02/g, '>');

// newlines to

obj.html = obj.html.replace(/\x00+\n/g, '\n'); obj.html = obj.html.replace(/\n\x00+/g, '\n'); obj.html = obj.html.replace(/\n*\x00(\x00|\n)+/g, '\n\n'); obj.html = obj.html.replace(/\x00/g, '\n'); obj.html = obj.html.replace(/\n/g, ' ');

// 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, ''); obj.html = obj.html.replace(/(<br\b[^>]*>)+$/gi, ''); }

return; }

// // WikEdRelativeToAbsolutePath //  broken for editing article names containing "/", https://bugzilla.mozilla.org/show_bug.cgi?id=430910

window.WikEdRelativeToAbsolutePath = function(relativePath, fullPath) {

var absolutePath = '';

// get current url if (fullPath == null) { fullPath = window.location.href; fullPath = fullPath.replace(/#.*/, ''); fullPath = fullPath.replace(/\?.*/, ''); }

// ./index.php if (/^\.\//.test(relativePath) == true) { relativePath = relativePath.replace(/^\.\//, ''); fullPath = fullPath.replace(/\/[^\/]*$/, ''); absolutePath = fullPath + '/' + relativePath; }

// ../../index.php else if (/^\.\.\//.test(relativePath) == true) { while (/^\.\.\//.test(relativePath) == true) { relativePath = relativePath.replace(/^\.\.\//, ''); fullPath = fullPath.replace(/\/[^\/]*$/, ''); }		absolutePath = fullPath + '/' + relativePath; }

// full path else { absolutePath = relativePath; }	return(absolutePath); }

// // WikEdSanitizeAttributes: see Sanitizer.php //

window.WikEdSanitizeAttributes = function(tag, attributes, relaxed) { var common; var tablealign; var tablecell; var table; if (relaxed == true) { common = 'dir|style|class'; // not needed: lang|id|title tablealign = '|align|char|charoff|valign'; table = '|summary|width|border|frame|rules|cellspacing|cellpadding|align|bgcolor'; tablecell = '|abbr|axis|headers|scope|rowspan|colspan|nowrap|width|height|bgcolor'; }	else { common = 'dir'; table = '|border|cellspacing|cellpadding|align|bgcolor'; tablealign = '|align|valign'; tablecell = '|rowspan|colspan|nowrap|bgcolor'; }	tag = tag.toLowerCase; var sanitized = ''; var regExp = /(\w+)\s*=\s*((\'|\")(.*?)\3|(\w+))/g;	var regExpMatch;	while ( (regExpMatch = regExp.exec(attributes)) != null) {		var attrib = regExpMatch[1];		var attribValue = regExpMatch[4] || regExpMatch[5];		if (attribValue == '') {			continue;		}		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) { if (common.indexOf(attrib) >= 0) { valid = true; } }			else if ('div|span|h1|h2|h3|h4|h5|h6|p'.indexOf(tag) >= 0) { if ((common + '|align').indexOf(attrib) >= 0) { valid = true; } }			else if ('blockquote'.indexOf(tag) >= 0) { if ((common + '|cite').indexOf(attrib) >= 0) { valid = true; } }			else if ('br'.indexOf(tag) >= 0) { if ('style|clear'.indexOf(attrib) >= 0) { valid = true; } }			else if ('pre'.indexOf(tag) >= 0) { if ((common + '|width').indexOf(attrib) >= 0) { valid = true; } }			else if ('ins|del'.indexOf(tag) >= 0) { if ((common + '|cite|datetime').indexOf(attrib) >= 0) { valid = true; } }			else if ('ul'.indexOf(tag) >= 0) { if ((common + '|type').indexOf(attrib) >= 0) { valid = true; } }			else if ('ol'.indexOf(tag) >= 0) { if ((common + '|type|start').indexOf(attrib) >= 0) { valid = true; } }			else if ('li'.indexOf(tag) >= 0) { if ((common + '|type|value').indexOf(attrib) >= 0) { valid = true; } }			else if ('table'.indexOf(tag) >= 0) { if ((common + table).indexOf(attrib) >= 0) { valid = true; } }			else if ('caption'.indexOf(tag) >= 0) { if ((common + '|align').indexOf(attrib) >= 0) { valid = true; } }			else if ('thead|tfoot|tbody'.indexOf(tag) >= 0) { if ((common + tablealign).indexOf(attrib) >= 0) { valid = true; } }			else if ('colgroup|col'.indexOf(tag) >= 0) { if ((common + '|span|width' + tablealign).indexOf(attrib) >= 0) { valid = true; } }			else if ('tr'.indexOf(tag) >= 0) { if ((common + '|bgcolor' + tablealign).indexOf(attrib) >= 0) { valid = true; } }			else if ('td|th'.indexOf(tag) >= 0) { if ((common + tablecell + tablealign).indexOf(attrib) >= 0) { valid = true; } }			else if ('font'.indexOf(tag) >= 0) { if ((common + '|size|color|face').indexOf(attrib) >= 0) { valid = true; } }			else if ('hr'.indexOf(tag) >= 0) { if ((common + '|noshade|size|width').indexOf(attrib) >= 0) { valid = true; } }			else if ('rt'.indexOf(tag) >= 0) { if ((common + '|rbspan').indexOf(attrib) >= 0) { valid = true; } }			else if ('ref'.indexOf(tag) >= 0) { if (('name').indexOf(attrib) >= 0) { valid = true; } }			else if ('references'.indexOf(tag) >= 0) { }			else if ('source'.indexOf(tag) >= 0) { if (('lang').indexOf(attrib) >= 0) { valid = true; } }			else if ('poem'.indexOf(tag) >= 0) { if (common.indexOf(attrib) >= 0) { valid = true; } }			else if ('categorytree'.indexOf(tag) >= 0) { if ((common + '|mode|depth|onlyroot|hideroot|hideprefix|showcount|namespaces').indexOf(attrib) >= 0) { valid = true; } }			else if ('charinsert'.indexOf(tag) >= 0) { }			else if ('fundraising'.indexOf(tag) >= 0) { }			else if ('fundraisinglogo'.indexOf(tag) >= 0) { }			else if ('hiero'.indexOf(tag) >= 0) { }			else if ('imagemap'.indexOf(tag) >= 0) { }			else if ('inputbox'.indexOf(tag) >= 0) { }			else if ('timeline'.indexOf(tag) >= 0) { }			else if ('gallery'.indexOf(tag) >= 0) { if ((common + '|perrow|widths|heights').indexOf(attrib) >= 0) { valid = true; } }		}

// 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) { if (common.indexOf(attrib) >= 0) { valid = true; } }			else if ('div|span|h1|h2|h3|h4|h5|h6|p'.indexOf(tag) >= 0) { if ((common + '|align').indexOf(attrib) >= 0) { valid = true; } }			else if ('br'.indexOf(tag) >= 0) { if ('clear'.indexOf(attrib) >= 0) { valid = true; } }			else if ('ul'.indexOf(tag) >= 0) { if ((common + '|type').indexOf(attrib) >= 0) { valid = true; } }			else if ('ol'.indexOf(tag) >= 0) { if ((common + '|type|start').indexOf(attrib) >= 0) { valid = true; } }			else if ('li'.indexOf(tag) >= 0) { if ((common + '|type|value').indexOf(attrib) >= 0) { valid = true; } }			else if ('table'.indexOf(tag) >= 0) { if ((common + table).indexOf(attrib) >= 0) { valid = true; } }			else if ('caption'.indexOf(tag) >= 0) { if ((common + '|align').indexOf(attrib) >= 0) { valid = true; } }			else if ('thead|tfoot|tbody'.indexOf(tag) >= 0) { if ((common + tablealign).indexOf(attrib) >= 0) { valid = true; } }			else if ('colgroup|col'.indexOf(tag) >= 0) { if ((common + '|span' + tablealign).indexOf(attrib) >= 0) { valid = true; } }			else if ('tr'.indexOf(tag) >= 0) { if ((common + '|bgcolor' + tablealign).indexOf(attrib) >= 0) { valid = true; } }			else if ('td|th'.indexOf(tag) >= 0) { if ((common + tablecell + tablealign).indexOf(attrib) >= 0) { valid = true; } }			else if ('font'.indexOf(tag) >= 0) { if ((common + '|color').indexOf(attrib) >= 0) { valid = true; } }			else if ('hr'.indexOf(tag) >= 0) { if ((common + '|noshade|size').indexOf(attrib) >= 0) { valid = true; } }			else if ('rt'.indexOf(tag) >= 0) { if ((common + '|rbspan').indexOf(attrib) >= 0) { valid = true; } }			else if ('ref'.indexOf(tag) >= 0) { if (('name').indexOf(attrib) >= 0) { valid = true; } }			else if ('references'.indexOf(tag) >= 0) { }			else if ('source'.indexOf(tag) >= 0) { if (('lang').indexOf(attrib) >= 0) { valid = true; } }			else if ('poem'.indexOf(tag) >= 0) { if (common.indexOf(attrib) >= 0) { valid = true; } }			else if ('categorytree'.indexOf(tag) >= 0) { if ((common + '|mode|depth|onlyroot|hideroot|hideprefix|showcount|namespaces').indexOf(attrib) >= 0) { valid = true; } }			else if ('charinsert'.indexOf(tag) >= 0) { }			else if ('fundraising'.indexOf(tag) >= 0) { }			else if ('fundraisinglogo'.indexOf(tag) >= 0) { }			else if ('hiero'.indexOf(tag) >= 0) { }			else if ('imagemap'.indexOf(tag) >= 0) { }			else if ('inputbox'.indexOf(tag) >= 0) { }			else if ('timeline'.indexOf(tag) >= 0) { }			else if ('gallery'.indexOf(tag) >= 0) { }		}

// clean up		if (valid == true) {

// clean up defaults for align if (attrib == 'align') { if ('tr|td|th'.indexOf(tag) >= 0) { if (attribValue == 'left') { attribValue = ''; }				}			}

// clean up defaults for valign else if (attrib == 'valign') { if ('tr|td|th'.indexOf(tag) >= 0) { if (attribValue == 'top') { attribValue = ''; }				}			}

// 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 '); attribValue = attribValue.replace(/( |;)+$/g, ';'); }

// clean up class else if (attrib == 'class') {

// remove MS Word classes attribValue = attribValue.replace(/^Ms.*$/g, ''); }

if (attribValue != '') { sanitized += ' ' + attrib + '="' + attribValue + '"'; }		}	}	return(sanitized); }

// // // WikEdRemoveHighlighting: remove syntax highlighting in obj.html; sets obj.htmlCode if text contains html code //   expects instead of \n

window.WikEdRemoveHighlighting = function(obj) {

// remove highlighting and atttribute-free span tags var isRemove = []; obj.html = obj.html.replace(/(<(\/?)span\b([^>]*)>)/g,		function (p, p1, p2, p3) {			if (p2 == ) {				if (/\bclass=\"wikEd\w+\"/.test(p3)) {					isRemove.push(true);					return();				}				isRemove.push(false);				return(p1);			}			if (isRemove.pop == true) {				return('');			}			return(p1);		}	);

// remove highlighting div tags var isRemove = []; obj.html = obj.html.replace(/(<(\/?)div\b([^>]*)>)/g,		function (p, p1, p2, p3) {			if (p2 == ) {				if (/\bclass=\"wikEd\w+\"/.test(p3)) {					isRemove.push(true);					return();				}				isRemove.push(false);				return(p1);			}			if (isRemove.pop == true) {				return('');			}			return(p1);		}	);

// remove highlighting pre tags var isRemove = []; obj.html = obj.html.replace(/(<(\/?)pre\b([^>]*)>)/g,		function (p, p1, p2, p3) {			if (p2 == ) {				if (/\bclass=\"wikEd\w+\"/.test(p3)) {					isRemove.push(true);					return();				}				isRemove.push(false);				return(p1);			}			if (isRemove.pop == true) {				return('');			}			return(p1);		}	);

// remove highlighting span tags in WebKit https://bugs.webkit.org/show_bug.cgi?id=12248 var isRemove = []; obj.html = obj.html.replace(/(<(\/?)span\b([^>]*)>)/g,		function (p, p1, p2, p3) {			if (p2 == ) {				if (/\bclass=\"Apple-style-span\"/.test(p3)) {					isRemove.push(true);					return();				}				isRemove.push(false);				return(p1);			}			if (isRemove.pop == true) {				return('');			}			return(p1);		}	);

// remove highlighting font tags in WebKit var isRemove = []; obj.html = obj.html.replace(/(<(\/?)font\b([^>]*)>)/g,		function (p, p1, p2, p3) {			if (p2 == ) {				if (/\bclass=\"Apple-style-span\"/.test(p3)) {					isRemove.push(true);					return();				}				isRemove.push(false);				return(p1);			}			if (isRemove.pop == true) {				return('');			}			return(p1);		}	);

// comments obj.html = obj.html.replace(//g, '');

// newlines obj.html = obj.html.replace(/[\n\r ]+/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; }	else { obj.htmlCode = false; }	return; }

// // WikEdHighlightSyntax: highlight syntax in obj.html; if singleLine is set, no block syntax will be highlighted; call WikEdRemoveHighlighting first //  expects < > &lt; &gt; &amp;  \xa0 instead of    \n instead of

window.WikEdHighlightSyntax = function(obj, singleLine) {

var html = obj.html;

// start timer to cancel after wikEdMaxHighlightTime var startDate = new Date;

// MS IE compatibility fix: use \n instead of \r\n html = html.replace(/\r\n?/g, '\n');

// &lt; &gt; &amp; to \x00 \x01 \x02 html = html.replace(/&lt;/g, '\x00'); html = html.replace(/&gt;/g, '\x01'); html = html.replace(/&amp;/g, '\x02');

// #REDIRECT html = html.replace(/(^|\n)(#)(redirect\b)/gi, '$1 $3 ');

// nowiki (no html highlighting) html = html.replace(/(\x00nowiki\b.*?\x01)(.*?)(\x00\/nowiki\b.*?\x01)/gi,		function (p, p1, p2, p3) {			p2 = p2.replace(/\x00/g, '&lt;');			p2 = p2.replace(/\x01/g, '&gt;');			return(p1 + p2 + p3);		}	);

// check spent time if (new Date - startDate > wikEdMaxHighlightTime / 10) { return; }

// blocks

// lists * # : ; html = html.replace(/^((\x00!--.*?--\x01)*)([\*\#\:\;]+)(.*?)$/gm, ' $1 $3 $4 '); if (singleLine != true) { html = html.replace(/((<span class=\"wikEdListLine\">[^\n]*\n)+)/g, ' $1'); html = html.replace(/(<span class=\"wikEdListLine\">[^\n]*)(\n)(?!<span class=\"wikEdListLine\">)/g, '$1 $2'); }

// #REDIRECT (finish) html = html.replace(/(<span class=\"wikEdWikiRedir\">)(.*?<\/span>)/g, '$1#$2');

// various blocks if (singleLine != true) { html = html.replace(/(\x00(blockquote|center|div|pre|gallery|source|poem|categorytree|hiero|imagemap|inputbox|timeline)\b[^\x01]*\x01.*?\x00\/\2\x01)/gi, ' $1 '); }

// space-pre if (singleLine != true) { html = html.replace(/^((\x00!--.*?--\x01)*)[\xa0 ]([\xa0 ]*)(.*?)$/gm, ' $1 $3 $4 '); html = html.replace(/((<span class=\"wikEdSpaceLine\">[^\n]*\n)+)/g, ' $1'); html = html.replace(/(<span class=\"wikEdSpaceLine\">[^\n]*)(\n)(?! )/g, '$1 $2'); }

// check spent time if (new Date - startDate > wikEdMaxHighlightTime / 10) { return; }

// horizontal rule html = html.replace(/(^|\n)((\x00!--.*?--\x01|<[^>]*>)*)((\x00!--.*?--\x01|<[^>]*>)*)(\n|$)/g, '$1 $2$4 $5$7'); html = html.replace(/(\x00hr\x01)/g, ' $1 ');

// == headings html = html.replace(/(^|\n)((\x00!--.*?--\x01|<[^>]*>)*)(=+[\xa0 ]*)([^\n]*?)([\xa0 ]*=+)(?=([\xa0 ]|<[^>]*>|\x00!--.*?--\x01)*(\n|$))/g,		function (p, p1, p2, p3, p4, p5, p6) {			p4 = p4.replace(/(=+)/g, ' $1 ');			p6 = p6.replace(/(=+)/g, ' $1 ');			var regExp = new RegExp('^' + wikEdText['External links'] + '?|' + wikEdText['External links'] + '|' + wikEdText['See also'] + '|' + wikEdText['References'] + '$', 'i');			if (regExp.test(p5) == true) {				p1 = p1 + ' ';				p6 = p6 + ' ';			}			else {				p1 = p1 + ' ';				p6 = p6 + ' ';			}			return(p1 + p2 + p4 + p5 + p6);		}	);

// tables                                     {|   |+   |-   ! |}           | //                      12                2 13                      4        4   35   5	html = html.replace(/^((\x00!--.*?--\x01)*)(\{\||\|\+|\|\-|\!|\|\}([^\}\]]|$)|\|)(.*?)$/gm, ' $1 $3 $5 '); if (singleLine != true) { html = html.replace(/(^|\n)((<[^>]*>|\x00!--.*?--\x01)*\{\|)/g, '$1 $2'); html = html.replace(/(^|\n)((<[^>]*>|\x00!--.*?--\x01)*\|\}(<[^>]*>)*)/g, '$1$2 '); html = html.replace(/(\x00table\b[^\x01]*\x01)/gi, ' $1'); html = html.replace(/(\x00\/table\x01)/gi, '$1 '); }

// wiki markup if (singleLine != true) { html = html.replace(/(\x00(gallery)\b[^\x01]*\x01)/gi, ' $1'); html = html.replace(/(\x00\/(gallery)\x01)/gi, '$1 '); }

// various block tags html = html.replace(/(\x00\/?(blockquote|center|div|pre|gallery|source|poem|categorytree|hiero|imagemap|inputbox|timeline)\b[^\x01]*\x01)/gi, ' $1 ');

// check spent time if (new Date - startDate > wikEdMaxHighlightTime / 5) { return; }

// ... pairs with (wikEdBlockTag) and withhout attributes (wikEdUnknown) var isRemove = []; html = html.replace(/(\x00(\/?)p\b([^\x01]*?)\x01)/g,		function (p, p1, p2, p3) {			if (p2 == ) {				if (p3 == ) {					isRemove.push(true);					return(' ' + p1 + ' ');				}				if (/\/$/.test(p3)) {					return(' ' + p1 + ' ');				}				isRemove.push(false);				return(' ' + p1 + ' ');			}			if (isRemove.pop == true) {				return(' ' + p1 + ' ');			}			return(' ' + p1 + ' ');		}	);

// inline elements

//  	html = html.replace(/(\x00sup\b[^\x01]*\x01((.|\n)*?)\x00\/sup\x01)/gi, ' $1 '); html = html.replace(/(\x00sub\b[^\x01]*\x01((.|\n)*?)\x00\/sub\x01)/gi, ' $1 '); html = html.replace(/(\x00(ins|u)\b[^\x01]*\x01((.|\n)*?)\x00\/(ins|u)\x01)/gi, ' $1 '); html = html.replace(/(\x00(del|s|strike)\b[^\x01]*\x01((.|\n)*?)\x00\/(del|s|strike)\x01)/gi, ' $1 ');

// and wiki markup if (wikEdRefHide != true) { html = html.replace(/\x00(ref\b[^\x01]*?\/)\x01/gi, ' &lt;$1&gt; '); html = html.replace(/(\x00ref\b[^\x01]*\x01((.|\n)*?)\x00\/ref\x01)/gi, ' $1 '); }

// various inline tags html = html.replace(/(\x00\/?(sub|sup|ins|u|del|s|strike|big|br|colgroup|code|font|small|span|tt|rb|rp|rt|ruby)\b[^\x01]*\x01)/gi, ' $1 ');

// wiki markup html = html.replace(/\x00((references)\b[^\x01]*?\/)\x01/gi, ' &lt;$1&gt; ');

// wiki markup html = html.replace(/(\x00(math|noinclude|includeonly|charinsert|fundraising|fundraisinglogo|gallery|source|poem|categorytree|hiero|imagemap|inputbox|timeline|references)\b[^\x01]*\x01((.|\n)*?)(\x00)\/\2\x01)/gi, ' $1 ');

// unsupported or not needed <> tags html = html.replace(/(\x00\/?)(\w+)(.*?\/?\x01)/g,		function (p, p1, p2, p3) {			if ( ! /^(col|thead|tfoot|tbody|big|br|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)$/i.test(p2) ) {				p1 = ' ' + p1;				p3 = p3 + ' ';			}			return(p1 + p2 + p3);		}	);

// comments html = html.replace(/(\x00!--(.|\n)*?--\x01)/g, ' $1 ');

// named html colors in quotation marks html = html.replace(/(\'|\")(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)/g, '$1<span style="background-color: $2;" class="wikEdColorsLight">$2 $3'); html = html.replace(/(\'|\")(black|blue|blueviolet|brown|cadetblue|chocolate|cornflowerblue|crimson|darkblue|darkcyan|darkgoldenrod|darkgreen|darkmagenta|darkolivegreen|darkorchid|darkred|darkslateblue|darkslategray|darkslategrey|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|forestgreen|gray|green|grey|indianred|indigo|lightseagreen|lightslategray|lightslategrey|limegreen|maroon|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumvioletred|midnightblue|navy|olive|olivedrab|orangered|orchid|palevioletred|purple|red|rosybrown|royalblue|saddlebrown|seagreen|sienna|slateblue|slategray|slategrey|steelblue|teal|tomato)(\1)/g, '$1<span style="background-color: $2;" class="wikEdColorsDark">$2 $3');

// check spent time if (new Date - startDate > wikEdMaxHighlightTime / 2) { return; }

// RGB hex colors #d4d0cc, exclude links and character entities starting with & html = html.replace(/(^|[^\/\w\x02])(#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2}))(?=(\W|$))/g,		function (p, p1, p2, p3, p4, p5) {			var luminance = parseInt(p3, 16) * 0.299 + parseInt(p4, 16) * 0.587 + parseInt(p5, 16) * 0.114;			if (luminance > 128) {				return(p1 + '<span style="background-color: ' + p2 + '" class="wikEdColorsLight">' + p2 + ' ');			}			else {				return(p1 + '<span style="background-color: ' + p2 + '" class="wikEdColorsDark">' + p2 + ' ');			}		}	);

// RGB hex colors #ddc, exclude links and character entities starting with & html = html.replace(/(^|[^\/\w\x02])(#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F]))(?=(\W|$))/g,		function (p, p1, p2, p3, p4, p5) {			var luminance = parseInt(p3, 16) * 16 * 0.299 + parseInt(p4, 16) * 16 * 0.587 + parseInt(p5, 16) * 16 * 0.114;			if (luminance > 128) {				return(p1 + '<span style="background-color: ' + p2 + '" class="wikEdColorsLight">' + p2 + ' ');			}			else {				return(p1 + '<span style="background-color: ' + p2 + '" class="wikEdColorsDark">' + p2 + ' ');			}		}	);

// RGB decimal colors rgb(128,64,265) html = html.replace(/(rgb\(\s*(\d+),\s*(\d+),\s*(\d+)\s*\))/gi,		function (p, p1, p2, p3, p4) {			var luminance = p2 * 0.299 + p3 * 0.587 + p4 * 0.114;			if (luminance > 128) {				return('<span style="background-color: ' + p1 + '" class="wikEdColorsLight">' + p1 + ' ');			}			else {				return('<span style="background-color: ' + p1 + '" class="wikEdColorsDark">' + p1 + ' ');			}		}	);

// clear array of link addresses if (obj.whole == true) { wikEdFollowLinkIdNo = 0; wikEdFollowLinkHash = {}; }	obj.whole = false;

// URLs html = html.replace(/(^|.)((http:\/\/|https:\/\/|ftp:\/\/|irc:\/\/|gopher:\/\/|news:|mailto:|file:\/\/)[\!\#\%\&\(\)\+-\/\:\;\=\?\@\w\~ŠŒŽœžŸŠŒŽšœžŸÀ-ÖØ-öø-\u0220\u0222-\u0233ΆΈΉΊΌΎΏΑ-ΡΣ-ώ\u0400-\u0481\u048a-\u04ce\u04d0-\u04f5\u04f8\u04f9]*)/g,		function (p, p1, p2, p3) {			var trailingChar = '';

// do not include trailing punctuation for in-text links if (p1 != '[') { var linkMatch = p2.match(/^(.*?)([\,\.\!\?\:\;])$/); if (linkMatch != null) { p2 = linkMatch[1]; trailingChar = linkMatch[2]; }			}

return(p1 + '<span class="wikEdURLLink"' + WikEdFollowLinkUrl(null, null, p2) + '>' + p2 + ' ' + trailingChar); }	);

// URLs with text html = html.replace(/(\[)( *<span class=\"wikEdURLLink\"[^>]*>.*?<\!--wikEdURLLink--> *)([^\]\n]*?)( *\])/gi,		function (p, p1, p2, p3, p4) {

// link text p3 = p3.replace(/(.*)/, ' $1 ');

// link tags p1 = p1.replace(/(\[)/, ' $1 '); p4 = p4.replace(/(\])/, ' $1 ');

return(p1 + p2 + p3 + p4); }	);

// highlight images // p11 needed to prevent freezing for certain nested tags //                           1       23                                                                                 3     24                456   78                        9                                  7 6 5 10  11 //                            ( File|    Image                          |    File                          )  :  )( name           )(( | (( wikilink             ) ( link              ) non-link     )*)*) var regExpImg = new RegExp('(\\[\\[)((Image|File|' + wikEdText['wikicode Image'] + '|' + wikEdText['wikicode File'] + ') *: *)([^\\[\\]\\|\\n]*)((\\|((\\[\\[[^\\]\\n]*\\]\\])?(\\[[^\\[\\]\\n]*\\])?[^\\[\\]\\|]*)*)*)(.*?)(\\]\\])', 'gi');	html = html.replace(regExpImg,		function (p, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11) {			var linkTitle = p4;			linkTitle = linkTitle.replace(/\|.*/g, );			linkTitle = linkTitle.replace(/\n.*/g, );

p1 = '<span class="wikEdImage"' + WikEdFollowLinkUrl(p2, linkTitle) + '>' + p1; p11 = p11 + ' '; p2 = ' ' + p2; p4 = p4 + ' ';

// parameters and capture p5 = p5.replace(/((\^\\]|\[\^\\]\]|[^\]\|])+)/g,				function (p, p1) {					if (/^(thumb|thumbnail|frame|right|left|center|none|\d+px|\d+x\d+px)$/.test(p1) == true) {						p1 = ' ' + p1 + ' ';					}					else {						p1 = ' ' + p1 + ' ';					}					return(p1);				}			);

// link tags p1 = p1.replace(/(\[+)/, ' $1 '); p11 = p11.replace(/(\]+)/, ' $1 '); p5 = p5.replace(/(\|)/g, ' $1 '); return(p1 + p2 + p4 + p5 + p10 + p11); }	);

// check spent time if (new Date - startDate > wikEdMaxHighlightTime / 2) { return; }

//  links, categories html = html.replace(/(\[\[)([^\[\]]*)(\]\])/g,		function (p, p1, p2, p3) {

// omit image tags var regExpImg = new RegExp('^(<[^>]*>)*(Image|File|' + wikEdText['wikicode Image'] + '|' + wikEdText['wikicode File'] + ')\\s*:', 'i'); if (regExpImg.test(p2) == true) { return(p1 + p2 + p3); }

// get url var linkParam = ''; var linkInter = ''; var linkMatch = p2.match(/^\s*(([\w ŠŒŽšœžŸÀ-ÖØ-öø-\u0220\u0222-\u0233ΆΈΉΊΌΎΏΑ-ΡΣ-ώ\u0400-\u0481\u048a-\u04ce\u04d0-\u04f5\u04f8\u04f9\-]*\s*:)*)\s*([^\|]+)/); if (linkMatch != null) { linkInter = linkMatch[1]; linkParam = WikEdFollowLinkUrl(linkInter, linkMatch[3]); }

// category var regExpCat = new RegExp('^\\s*(Category|' + wikEdText['wikicode Category'] + ')\\s*:', 'i'); if (regExpCat.test(p2)) { var regExp = new RegExp('\\s*[\\w\\- ŠŒŽšœžŸÀ-ÖØ-öø-\\u0220\\u0222-\\u0233ΆΈΉΊΌΎΏΑ-ΡΣ-ώ\\u0400-\\u0481\\u048a-\\u04ce\\u04d0-\\u04f5\\u04f8\\u04f9]+\\s*:\\s*(Category|' + wikEdText['wikicode Category'] + ')\\s*:', 'i'); if (p2.match(regExp) != null) { p1 = '<span class="wikEdCatInter"' + linkParam + '>' + p1; p3 = p3 + ' '; }				else { p1 = '<span class="wikEdCat"' + linkParam + '>' + p1; p3 = p3 + ' '; }				p2 = p2.replace(/^(\s*)(([\w ]*:)+)/, '$1 $2 '); p2 = p2.replace(/(\s*)([^>:\|]+)(\s*\|\s*|$)/, '$1 $2 $3'); p2 = p2.replace(/(\|\s*)(.*)/,					function (p, p1, p2) {						p2 = p2.replace(/(.*?)(\s*(\||$))/g, ' $1 $2');						return(p1 + p2);					}				); }

// wikilink else { if (linkInter != '') { p1 = '<span class="wikEdLinkInter"' + linkParam + '>' + p1; p3 = p3 + ' '; }				else { p1 = '<span class="wikEdLink"' + linkParam + '>' + p1; p3 = p3 + ' '; }				p2 = p2.replace(/^(\s*)(([\w ]*:)+)/, '$1 $2 '); p2 = p2.replace(/(\s*)([^>:\|]+)(\s*\|\s*|$)/, '$1 $2 $3'); p2 = p2.replace(/(\|\s*)(.*)/,					function (p, p1, p2) {						p2 = p2.replace(/(.*?)(\s*(\||$))/g, ' $1 $2');						return(p1 + p2);					}				); }

// link tags p1 = p1.replace(/(\[+)/, ' $1 '); p2 = p2.replace(/(\|)/g, ' $1 '); p3 = p3.replace(/(\]+)/, ' $1 '); return(p1 + p2 + p3); }	);

// check spent time if (new Date - startDate > wikEdMaxHighlightTime) { return; }

// signature ~ html = html.replace(/(~{3,5})/g, ' $1 ');

// magic words var regExp = new RegExp('(__' + wikEdMagicWords + '__)', 'gi'); html = html.replace(regExp, ' $1 ');

// template parameter html = html.replace(/(\{\{\{)(\s*)([^\{\}\|]*?)(\s*)(\|.*?)?(\}\}\})/g,	'   ');

// parser variables and functions

// start var regExp = new RegExp('(\\{\\{)(\\s*)((' + wikEdTemplModifier + '):\\s*)?(' + wikEdParserVariables + ')(\\s*)(\}\})', 'g'); html = html.replace(regExp, ' $1 $2$3 $5 $6 $7  ');

// parser start var regExp = new RegExp('(\\{\\{)(\\s*)((' + wikEdTemplModifier + '):\\s*)?(' + wikEdParserVariablesR + ')(:\\s*R)?(\\s*)(\}\})', 'g'); html = html.replace(regExp, ' $1 $2$3 $5 $6$7 $8  ');

// parser start var regExp = new RegExp('(\\{\\{)(\\s*)((' + wikEdTemplModifier + '):\\s*)?(' + wikEdParserFunctionsR + '):', 'g'); html = html.replace(regExp, ' $1 $2$3 $5 :');

// parser start var regExp = new RegExp('(\\{\\{)(\\s*)((' + wikEdTemplModifier + '):\\s*)?(' + wikEdParserFunctions + '):', 'gi'); html = html.replace(regExp, ' $1 $2$3 $5 :');

// parser start var regExp = new RegExp('(\\{\\{)(\\s*)((' + wikEdTemplModifier + '):\\s*)?#(' + wikEdParserFunctionsHash + '):', 'gi'); html = html.replace(regExp, ' $1 $2$3 #$5 :');

// parser function modifier var regExp = new RegExp('( \\{\\{ )(' + wikEdTemplModifier + '):', 'gi'); html = html.replace(regExp, '$1 $2 :');

// check spent time if (new Date - startDate > wikEdMaxHighlightTime) { return; }

// simple non-nested var regExp = new RegExp('(\\{\\{)(\\s*)((' + wikEdTemplModifier + '):\\s*)?([^\\{\\}\\<\\>\\x00\\x01\\n]+)(\\}\\})', 'gi'); html = html.replace(regExp,		function (p, p1, p2, p3, p4, p5, p6) {			p3 = p3 || ;			p4 = p4 || ;

// template tags p1 = ' ' + p1 + ' '; p6 = ' ' + p6 + ' ';

// get url var linkParam = ''; var linkInter; var linkMatch = p5.match(/^\s*(([\wŠŒŽšœžŸÀ-ÖØ-öø-\u0220\u0222-\u0233ΆΈΉΊΌΎΏΑ-ΡΣ-ώ\u0400-\u0481\u048a-\u04ce\u04d0-\u04f5\u04f8\u04f9]*\s*:)*)\s*([^\|]+)/); if (linkMatch != null) { linkInter = linkMatch[1]; if (linkInter == '') { linkInter = wikEdText['wikicode Template'] + ':'; }				linkParam = WikEdFollowLinkUrl(linkInter, linkMatch[3]) }			if (linkInter != '') { p1 = '<span class="wikEdTemplInter" ' + linkParam + '>' + p1; p6 = p6 + ' '; }			else { p1 = '<span class="wikEdTempl" ' + linkParam + '>' + p1; p6 = p6 + ' '; }			p3 = p3.replace(/^(.*?)(:\s*)$/, ' $1 $2'); p5 = p5.replace(/^(\s*)((\w*:)+)/, '$1 $2 '); p5 = p5.replace(/(\s*)([^>:\|]+)(\s*\|\s*|$)/, '$1 $2 $3'); p5 = p5.replace(/(\|\s*)(.*)/,				function (p, p1, p2) {					p2 = p2.replace(/(.*?)(\s*(\||$))/g, ' $1 $2');					return(p1 + p2);				}			);

// template tags p5 = p5.replace(/(\|)/g, ' $1 ');

return(p1 + p2 + p3 + p5 + p6); }	);

// check spent time if (new Date - startDate > wikEdMaxHighlightTime) { return; }

// template start var regExp = new RegExp('(\\{\\{)(\\s*)((' + wikEdTemplModifier + '):\\s*)?([^\\{\\}\\<\\>\\x00\\x01\\n\\|]+)', 'gi'); html = html.replace(regExp,		function (p, p1, p2, p3, p4, p5) {			p3 = p3 || ;			p4 = p4 || ;			var linkMatch = p5.match(/^\s*(([\wŠŒŽšœžŸÀ-ÖØ-öø-\u0220\u0222-\u0233ΆΈΉΊΌΎΏΑ-ΡΣ-ώ\u0400-\u0481\u048a-\u04ce\u04d0-\u04f5\u04f8\u04f9]*\s*:)*)\s*([^\|]+)/);			var linkParam = ;			var linkInter;			if (linkMatch != null) {				linkInter = linkMatch[1];				if (linkInter == ) {					linkInter = wikEdText['wikicode Template'] + ':';				}				linkParam = WikEdFollowLinkUrl(linkInter, linkMatch[3]);			}			p3 = p3.replace(/^(.*?)(:\s*)$/, ' $1 $2');			return('<span class="wikEdTempl"' + linkParam + '> ' + p1 + ' ' + p2 + p3 + ' ' + p5 + ' ');		}	);

// highlighting curly template brackets at template end html = html.replace(/(\}\})(?!<\/span>)/g, '$1 '); html = html.replace(/(\}\})(?!<\/span>)/g, ' $1 ');

// check spent time if (new Date - startDate > wikEdMaxHighlightTime) { return; }

// <b> <i> html = html.replace(/(\'\'\')(\'*)(.*?)(\'*)(\'\'\')/g, ' $2$3$4 '); html = html.replace(/(\'\')(.*?)(\'\')/g, ' $1$2$3 '); html = html.replace(/(<span class=\"wikEdBold\">)/g, '$1\'\'\''); html = html.replace(/(<\/span>)/g, '\'\'\'$1'); html = html.replace(/(\'{2,})/g, ' $1 ');

// nowiki (remove highlighting) html = html.replace(/(\x00nowiki\b[^\x01]*\x01)((.|\n)*?)(\x00\/nowiki\x01)/gi,		function (p, p1, p2, p3, p4) {			p1 = ' ' + p1 + ' ';			p2 = p2.replace(/<[^>]*>/g, '');			p4 = ' ' + p4 + '  ';			return(p1 + p2 + p4);		}	);

// hide (fade) if (wikEdRefHide == true) {

// escape html = html.replace(/\x00(ref\b[^\x01]*?\/)\x01/g, ' &lt;$1&gt; ');

// remove inner highlighting html = html.replace(/(\x00ref\b[^\x01]*\x01)((.|\n)*?)(\x00\/ref\x01)/gi,			function (p, p1, p2, p3, p4) {				p2 = p2.replace(/<[^>]*>/g, '');				var str = ' ' + p1 + p2 + p4 + ' ';				return(str);			}		); }

// check spent time if (new Date - startDate > wikEdMaxHighlightTime) { return; }

// \x00 and \x01 back to &lt; and &gt; html = html.replace(/\x00/g, '&lt;'); html = html.replace(/\x01/g, '&gt;'); html = html.replace(/\x02/g, '&amp;');

// check spent time if (new Date - startDate > wikEdMaxHighlightTime) { return; }

// control character highlighting var regExp = new RegExp('([' + wikEdControlCharHighlightingStr + '])', 'g'); html = html.replace(regExp,		function (p, p1) {			p1 = '<span class="wikEdCtrl" title="' + wikEdControlCharHighlighting[p1.charCodeAt(0).toString] + '">' + p1 + ' ';			return(p1);		}	);

// single character highlighting: spaces, dashes var regExp = new RegExp('<[^>]*>|([' + wikEdCharHighlightingStr + '])', 'g'); html = html.replace(regExp,		function (p, p1) {			p1 = p1 || ;			if (p1 != ) {				var decimalValue = p1.charCodeAt(0).toString;				var titleClass = wikEdCharHighlighting[decimalValue];				p1 = '<span class="' + titleClass + '" title="' + wikEdText[titleClass] + '">' + p1 + ' ';				return(p1);			}			else {				return(p);			}		}	);

// remove comments if (wikEdRemoveHighlightComments == true) { html = html.replace(//g, ''); }

obj.html = html; return; }

// // WikEdFollowLinkUrl: prepare the span tag parameters for ctrl-click opening of highlighted links //  add support for /subpage

window.WikEdFollowLinkUrl = function(linkPrefix, linkTitle, linkUrl) {

var linkName = '';

// generate url from interlanguage or namespace prefix and title if (linkUrl == null) {

// test for templates if ( (/\{|\}/.test(linkPrefix) == true) || (/\{|\}/.test(linkTitle) ) == true) { return(''); }

// remove highlighting code linkPrefix = linkPrefix.replace(/<[^>]*>/g, ''); linkTitle = linkTitle.replace(/<[^>]*>/g, '');

// remove control chars var regExp = new RegExp('[' + wikEdControlCharHighlightingStr + '\t\n\r]', 'g'); linkPrefix = linkPrefix.replace(regExp, ''); linkTitle = linkTitle.replace(regExp, '');

// remove strange white spaces linkPrefix = linkPrefix.replace(/\s/, ' '); linkTitle = linkTitle.replace(/\s/, ' '); linkPrefix = linkPrefix.replace(/^:+ */g, ''); linkPrefix = linkPrefix.replace(/ /, '_'); linkTitle = linkTitle.replace(/ /g, '_');

// Wiktionary differentiates between lower and uppercased titles linkUrl = linkPrefix + linkTitle; linkUrl = encodeURI(linkUrl); linkUrl = linkUrl.replace(/%25(\d\d)/g, '%$1'); linkUrl = linkUrl.replace(/\'/g, '%27'); linkUrl = linkUrl.replace(/#/g, '%23'); if (wikEdWikiGlobals['wgArticlePath'] == null) { linkUrl = ''; }		else { linkUrl = wikEdWikiGlobals['wgArticlePath'].replace(/\$1/, linkUrl); linkName = linkPrefix + linkTitle; }	}

// url provided else {

// test for templates if (/\{|\}/.test(linkUrl) == true) { return(''); }		linkName = linkUrl; linkUrl = encodeURI(linkUrl); linkUrl = linkUrl.replace(/%25(\d\d)/g, '%$1'); linkUrl = linkUrl.replace(/\'/g, '%27'); }	linkName = linkName.replace(/</g, '&lt;'); linkName = linkName.replace(/>/g, '&gt;'); linkName = linkName.replace(/\"/g, '&quot;');	linkName = linkName.replace(/\'/g, '\\x27');

var linkParam = ''; if (linkUrl != '') { var linkId = 'wikEdFollowLink' + wikEdFollowLinkIdNo; wikEdFollowLinkIdNo ++;

linkParam += 'id="' + linkId + '" title="' + linkName + ' ' + wikEdText['followLink'] + '"'; wikEdFollowLinkHash[linkId] = linkUrl; }	return(linkParam) }

// // WikEdUpdateTextarea: copy frame content to textarea //

window.WikEdUpdateTextarea = function {

// remove dynamically inserted nodes by other scripts WikEdCleanNodes(wikEdFrameDocument);

// get frame content var obj = {}; obj.html = wikEdFrameBody.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 WikEdTextify(obj); obj.plain = obj.plain.replace(/ |&#160;|\xa0/g, ' '); obj.plain = obj.plain.replace(/&lt;/g, '<'); obj.plain = obj.plain.replace(/&gt;/g, '>'); obj.plain = obj.plain.replace(/&amp;/g, '&');

// copy to textarea wikEdTextarea.value = obj.plain;

// remember frame scroll position wikEdFrameScrollTop = wikEdFrameBody.scrollTop;

return; }

// // WikEdUpdateFrame: copy textarea content to frame //

window.WikEdUpdateFrame = function {

// get textarea content var obj = {}; obj.html = wikEdTextarea.value; obj.html = obj.html.replace(/&/g, '&amp;'); obj.html = obj.html.replace(/>/g, '&gt;'); obj.html = obj.html.replace(/</g, '&lt;');

// highlight the syntax if (wikEdHighlightSyntax == true) { obj.whole = true; WikEdHighlightSyntax(obj); }

// at least display tabs else { obj.html = obj.html.replace(/(\t)/g, ' $1 '); }

// multiple blanks to blank- obj.html = obj.html.replace(/(^|\n) /g, '$1 '); obj.html = obj.html.replace(/ (\n|$)/g, ' $1'); obj.html = obj.html.replace(/ /g, '  '); obj.html = obj.html.replace(/ /g, '  ');

// newlines to

obj.html = obj.html.replace(/\n/g, ' ');

// select the whole text after replacing the whole text and scroll to same height if (wikEdMSIE == true) {

}	else { obj.sel = WikEdGetSelection; WikEdRemoveAllRanges(obj.sel); }

// insert content into empty frame if ( (wikEdFrameBody.firstChild == null) || (/^<br[^>]*>\s*$/.test(wikEdFrameBody.innerHTML) == true) ) { wikEdFrameBody.innerHTML = obj.html; }

// insert content into frame, preserve history else { var range = wikEdFrameDocument.createRange; range.setStartBefore(wikEdFrameBody.firstChild); range.setEndAfter(wikEdFrameBody.lastChild); obj.sel.addRange(range);

// replace the frame content with the new text if (obj.html != '') { WikEdFrameExecCommand('inserthtml', obj.html); }		else { WikEdFrameExecCommand('delete'); }		WikEdRemoveAllRanges(obj.sel);

// scroll to previous position if (wikEdFrameScrollTop != null) { wikEdFrameBody.scrollTop = wikEdFrameScrollTop; }

}	wikEdFrameScrollTop = null;

// add event handler to make highlighted frame links ctrl-clickable if (wikEdHighlightSyntax == true) { WikEdFollowLinks; }

return; }

// // WikEdShiftAltHandler: event handler for emulated accesskey keydown events in main document and frame //

window.WikEdShiftAltHandler = function(event) {

// MS IE compatibility fix event = WikEdEvent(event); if (event == null) { return; }

if (wikEdUseWikEd == true) { if ( (event.shiftKey == true) && (event.ctrlKey == false) && (event.altKey == true) && (event.metaKey == false) ) {

// get wikEd button id from keycode var buttonId = wikEdButtonKeyCode[event.keyCode]; if (buttonId != null) { event.preventDefault; event.stopPropagation;

// execute the button click handler code var obj = document.getElementById(buttonId); objId = obj.id; eval(wikEdEditButtonHandler[buttonId]); }		}	}	return; }

// // WikEdFrameExecCommand: wrapper for execCommand method //

window.WikEdFrameExecCommand = function(command, option) {

wikEdFrameDocument.execCommand(command, false, option); return; }

// // WikEdFindAhead: non-regexp and case-insensitive find-as-you-type, event handler for find field //

window.WikEdFindAhead = function {

if (WikEdGetAttribute(wikEdFindAhead, 'checked') == 'true') {

// get the find text var findText = wikEdFindText.value; if (findText == '') { return; }

// remember position var sel = WikEdGetSelection; var range = sel.getRangeAt(sel.rangeCount - 1).cloneRange; var rangeClone = range.cloneRange; var scrollTop = wikEdFrameBody.scrollTop; sel.removeAllRanges; sel.addRange(range); range.collapse(true);

// parameters: window.find(string, caseSensitive, backwards, wrapAround, wholeWord, searchInFrames, showDialog) // Mozilla bug: searchInFrames must be true, otherwise wrapAround does not work var found = wikEdFrameWindow.find(findText, false, false, true, false, true, false);

// add original selection if (found == false) { wikEdFrameBody.scrollTop = scrollTop; sel.removeAllRanges; sel.addRange(rangeClone); }	}	return; }

// // WikEdMainSwitch: click handler for program logo //

window.WikEdMainSwitch = function {

// disable function if browser is incompatible if (wikEdBrowserNotSupported == true) { return; }

// enable wikEd if (wikEdDisabled == true) { wikEdDisabled = false; WikEdSetPersistent('wikEdDisabled', '0', 0, '/');

// turn rich text frame on		if (wikEdTurnedOn == false) {

// setup wikEd WikEdTurnOn(false); }		else { WikEdSetLogo; var useWikEd = false; if (WikEdGetAttribute(document.getElementById('wikEdUseWikEd'), 'checked') == 'true') { useWikEd = true; }			WikEdSetEditArea(useWikEd); wikEdUseWikEd = useWikEd; if (wikEdUseWikEd == true) { WikEdUpdateFrame; }			wikEdButtonsWrapper.style.display = 'block'; wikEdButtonBarPreview.style.display = 'block'; if (wikEdButtonBarJump != null) { wikEdButtonBarJump.style.display = 'block'; }

// run scheduled custom functions WikEdExecuteHook(wikEdOnHook); }	}

// disable wikEd else { WikEdSetPersistent('wikEdDisabled', '1', 0, '/'); if (wikEdTurnedOn == false) { wikEdUseWikEd = false; wikEdDisabled = true; }		else { if (wikEdFullScreenMode == true) { WikEdFullScreen(false); }

// turn classic textarea on			if (wikEdUseWikEd == true) { WikEdUpdateTextarea; }			WikEdSetEditArea(false);

// reset textarea dimensions wikEdTextarea.style.height = wikEdTextareaHeightInitial + 'px'; wikEdTextarea.style.width = '100%';

wikEdFrameHeight = wikEdTextareaHeightInitial + 'px'; wikEdFrameWidth = 'auto'; wikEdFrame.style.height = wikEdFrameHeight; wikEdFrameOuter.style.width = wikEdFrameWidth;

wikEdButtonsWrapper.style.display = 'none'; wikEdButtonBarPreview.style.display = 'none'; wikEdLocalPrevWrapper.style.display = 'none'; wikEdPreviewBox.style.height = 'auto'; if (wikEdButtonBarJump != null) { wikEdButtonBarJump.style.display = 'none'; }

wikEdUseWikEd = false; wikEdDisabled = true; WikEdSetLogo;

// run scheduled custom functions WikEdExecuteHook(wikEdOffHook); }	}	return; }

// // WikEdFullScreen: change to fullscreen edit area or back to normal view //

window.WikEdFullScreen = function(fullscreen, notFrame) {

// hide or show elements var displayStyle; if (fullscreen == true) { displayStyle = 'none'; }	else { displayStyle = 'block'; }

// elements above input wrapper var node = document.getElementById('editform').previousSibling; while (node != null) { if ( (node.nodeName == 'DIV') || (node.nodeName == 'H3') ) { node.style.display = displayStyle; }		node = node.previousSibling; }	document.getElementsByTagName('H1')[0].style.display = displayStyle;

// divs below input wrapper var node = wikEdInputWrapper.nextSibling; while (node != null) { if (node.nodeName == 'DIV') { node.style.display = displayStyle; }		node = node.nextSibling; }

// divs below input wrapper, some levels up	var node = document.getElementById('column-one'); while (node != null) { if (node.nodeName == 'DIV') { node.style.display = displayStyle; }		node = node.nextSibling; }

// insert wrapper document.getElementById('wikEdInsertWrapper').style.display = displayStyle;

// change styles if (fullscreen == true) { if (notFrame != true) { wikEdInputWrapper.className = 'wikEdInputWrapperFull'; }		wikEdButtonBarPreview.className = 'wikEdButtonBarPreviewFull'; }	else { if (notFrame != true) { wikEdInputWrapper.className = 'wikEdInputWrapper'; }		wikEdButtonBarPreview.className = 'wikEdButtonBarPreview'; }

// resize the frame if (fullscreen == true) {

// end frame resizing WikEdRemoveEventListener(wikEdFrameDocument, 'mouseup', WikEdResizeStopHandler, true); WikEdRemoveEventListener(document, 'mouseup', WikEdResizeStopHandler, true); WikEdRemoveEventListener(wikEdFrameDocument, 'mousemove', WikEdResizeDragHandlerFrame, true); WikEdRemoveEventListener(document, 'mousemove', WikEdResizeDragHandlerDocument, true); wikEdResizeFrameMouseOverGrip = false; WikEdRemoveEventListener(wikEdFrameDocument, 'mousedown', WikEdResizeStartHandler, true); wikEdFrameBody.style.cursor = 'auto'; wikEdResizeFrameActive = false;

var consoleTop = WikEdGetOffsetTop(wikEdConsoleWrapper); var consoleHeight = wikEdConsoleWrapper.offsetHeight; var frameHeight = wikEdFrame.offsetHeight; var windowHeight = WikEdGetWindowInnerHeight; var windowWidth = WikEdGetWindowInnerWidth; var frameHeightNew = frameHeight + (windowHeight - (consoleTop + consoleHeight) ) - 2; wikEdFrame.style.height = frameHeightNew + 'px'; wikEdFrameOuter.style.width = '100%'; }	else { wikEdFrame.style.height = wikEdFrameHeight; wikEdFrameOuter.style.width = wikEdFrameWidth; }

// scroll to edit-frame if (fullscreen == false) { window.scroll(0, WikEdGetOffsetTop(wikEdInputWrapper) - 2); }

// set the fullscreen button state WikEdButton(document.getElementById('wikEdFullScreen'), 'wikEdFullScreen', null, fullscreen);

// grey out or re-activate scroll-to buttons var buttonClass; if (fullscreen == true) { buttonClass = 'wikEdButtonInactive'; }	else { buttonClass = 'wikEdButton'; }	document.getElementById('wikEdScrollToPreview').className = buttonClass; document.getElementById('wikEdScrollToPreview2').className = buttonClass; document.getElementById('wikEdScrollToEdit').className = buttonClass; document.getElementById('wikEdScrollToEdit2').className = buttonClass;

// resize the summary field WikEdResizeSummary;

wikEdFullScreenMode = fullscreen;

return; }

// // WikEdResizeSummary: recalculate the summary width after resizing the window //

window.WikEdResizeSummary = function {

// check if combo field exists if (wikEdSummarySelect == null) { return; }

wikEdSummaryText.style.width = ''; wikEdSummarySelect.style.width = '';

wikEdSummaryTextWidth = wikEdSummaryWrapper.clientWidth - ( WikEdGetOffsetLeft(wikEdSummaryText) - WikEdGetOffsetLeft(wikEdSummaryWrapper) ); if (wikEdSummaryTextWidth < 150) { wikEdSummaryTextWidth = 150; }	wikEdSummaryText.style.width = wikEdSummaryTextWidth + 'px'; WikEdResizeComboInput('summary'); return; }

// // WikEdResizeComboInput: set the size of the background select boxes so that the button is visible //  calculates the select button width as the difference between select and option width //  adjusts widths so that only the select button is visible behind the input field //

window.WikEdResizeComboInput = function(field) {

// check if combo field exists if (wikEdSelectElement[field] == null) { return; }

// detect browser for MS IE fixes var standardBrowser = true; if (wikEdSelectElement[field].options.offsetWidth != null ) { standardBrowser = false; }

// set select height and top if (standardBrowser == false) { wikEdSelectElement[field].style.height = (wikEdInputElement[field].clientHeight + 6) + 'px'; wikEdSelectElement[field].style.top = '3px'; wikEdInputElement[field].style.top = '3px'; }

// add a dummy option if no option exists yet var dummy; var testOption = 1; if (standardBrowser == true) { if (wikEdSelectElement[field].options.length == 0) { testOption = 0; wikEdSelectElement[field].options[0] = new Option(''); dummy = true; }	}

// set option widths to 0 if (standardBrowser == true) { for (var i = 0; i < wikEdSelectElement[field].options.length; i ++) { wikEdSelectElement[field].options[i].style.width = '0'; }	}

// get input width var inputBorder = (wikEdInputElement[field].offsetWidth - wikEdInputElement[field].clientWidth); var inputWidthInner = wikEdInputElement[field].clientWidth; var inputWidthOuter = wikEdInputElement[field].offsetWidth;

// get select width var selectWidthInner = wikEdSelectElement[field].clientWidth; var selectWidthOuter = wikEdSelectElement[field].offsetWidth;

// get option width and calculate button width var optionWidthInner; var buttonWidth; if (standardBrowser == true) {

// Firefox < 3.0 if ( typeof(wikEdSelectElement[field].options[testOption].clientLeft) == 'undefined' ) { optionWidthInner = wikEdSelectElement[field].options[testOption].clientWidth; buttonWidth = selectWidthInner - optionWidthInner - 6; }

// Firefox >= 3.0 else { optionWidthInner = wikEdSelectElement[field].options[testOption].clientWidth; buttonWidth = selectWidthInner - optionWidthInner; }	}	else { buttonWidth = selectWidthOuter - selectWidthInner - 4; }

// for long fields shorten input if (inputWidthOuter + buttonWidth > 150) { wikEdInputElement[field].style.width = (inputWidthInner - inputBorder - buttonWidth) + 'px'; wikEdSelectElement[field].style.width = (inputWidthInner) + 'px'; }

// otherwise increase select width else { wikEdSelectElement[field].style.width = (inputWidthOuter + buttonWidth) + 'px'; }

// delete dummy option if (dummy == true) { wikEdSelectElement[field].options[0] = null; }

// set option widths to auto if (standardBrowser == true) { for (var i = 0; i < wikEdSelectElement[field].options.length; i ++) { wikEdSelectElement[field].options[i].style.width = 'auto'; }	}	return; }

// // WikEdChangeComboInput: set the input value to selected option; onchange event handler for select boxes //

window.WikEdChangeComboInput = function(field) {

wikEdInputElement[field].focus;

// get selection index (-1 for unselected) var selected = wikEdSelectElement[field].selectedIndex; if (selected >= 0) { wikEdSelectElement[field].selectedIndex = -1;

// get selected option var option = wikEdSelectElement[field].options[selected]; if (option.text != '') {

// jump to heading if ( (field == 'find') && (/^=.*?=$/.test(option.value) == true) ) {

// parameters: window.find(string, caseSensitive, backwards, wrapAround, wholeWord, searchInFrames, showDialog) // Mozilla bug: searchInFrames must be true, otherwise wrapAround does not work wikEdFrameWindow.find(option.value, true, false, true, false, true, false); }

// update input field else {

// add a tag to the summary box if (field == 'summary') { wikEdInputElement[field].value = WikEdAppendToSummary(wikEdInputElement[field].value, option.text); }

// add case and regexp checkboxes to find / replace fields else if (option.value == 'setcheck') { WikEdButton(document.getElementById('wikEdCaseSensitive'), 'wikEdCaseSensitive', null, (option.text.charAt(0) == wikEdCheckMarker[true]) ); WikEdButton(document.getElementById('wikEdRegExp'), 'wikEdRegExp', null, (option.text.charAt(1) == wikEdCheckMarker[true]) ); wikEdInputElement[field].value = option.text.substr(3); }

// add option text else { wikEdInputElement[field].value = option.text; }

// find the new text if ( (field == 'find') && (WikEdGetAttribute(wikEdFindAhead, 'checked') == 'true') ) { WikEdFindAhead; }			}		}	}	return; }

// // WikEdAppendToSummary: append a phrase to the summary text //

window.WikEdAppendToSummary = function(summary, append) {

summary = summary.replace(/^[, ]+/, ''); summary = summary.replace(/[, ]+$/, ''); if (summary != '') { if (summary.match(/ \*\/$/) != null) { summary += ' '; }		else if (summary.match(/[\.\;\:]$/) != null) { summary += ' '; }		else if (summary.match(/^[\wŠŒŽšœžŸÀ-ÖØ-öø-\u0220\u0222-\u0233ΆΈΉΊΌΎΏΑ-ΡΣ-ώ\u0400-\u0481\u048a-\u04ce\u04d0-\u04f5\u04f8\u04f9\(\)\"\'\+\-]/) == null) {			summary += ' ';		}		else {			summary += ', ';		}	}	summary += append;

return(summary); }

// // WikEdAddToHistory: add an input value to the saved history //

window.WikEdAddToHistory = function(field) {

if (wikEdInputElement[field].value != '') {

// load history from saved settings WikEdLoadHistoryFromSettings(field);

// add current value to history wikEdFieldHist[field].unshift(wikEdInputElement[field].value);

// add case and regexp checkboxes to find / replace value if ( (field == 'find') || (field == 'replace') ) { wikEdFieldHist[field][0] = wikEdCheckMarker[ (WikEdGetAttribute(wikEdCaseSensitive, 'checked') == 'true') ] + wikEdCheckMarker[ (WikEdGetAttribute(wikEdRegExp, 'checked') == 'true') ] + ' ' + wikEdFieldHist[field][0]; }

// remove paragraph names from summary if (field == 'summary') { wikEdFieldHist[field][0] = wikEdFieldHist[field][0].replace(/^\/\* .*? \*\/ */, ''); }

// remove multiple old copies from history var i = 1; while (i < wikEdFieldHist[field].length) { if (wikEdFieldHist[field][i] == wikEdFieldHist[field][0]) { wikEdFieldHist[field].splice(i, 1); }			else { i ++; }		}

// remove new value if it is a preset value if (wikEdComboPresetOptions[field] != null) { var i = 0; while (i < wikEdComboPresetOptions[field].length) { if (wikEdComboPresetOptions[field][i] == wikEdFieldHist[field][0]) { wikEdFieldHist[field].shift; break; }				else { i ++; }			}		}

// cut history number to maximal history length wikEdFieldHist[field] = wikEdFieldHist[field].slice(0, wikEdHistoryLength[field]);

// save history to settings if (wikEdFieldHist[field][0] != '') { WikEdSaveHistoryToSetting(field); }	}	return; }

// // WikEdSetComboOptions: generate the select options from saved history; onfocus handler for select box //

window.WikEdSetComboOptions = function(field) {

// load history from saved settings WikEdLoadHistoryFromSettings(field);

var option = {}; var selectedOption = null;

// delete options var options = wikEdSelectElement[field].options; for (var i = 0; i < options.length; i ++) { wikEdSelectElement[field].remove(i); }

// delete optgroup option = document.getElementById(field + 'Optgroup'); if (option != null) { wikEdSelectElement[field].removeChild(option); }

// workaround for onchange not firing when selecting first option from unselected dropdown option = document.createElement('option'); option.style.display = 'none'; j = 0; wikEdSelectElement[field].options[j++] = option;

// add history entries for (var i = 0; i < wikEdFieldHist[field].length; i ++) { if (wikEdFieldHist[field][i] != null) { if (wikEdFieldHist[field][i] == wikEdInputElement[field].value) { selectedOption = j;			} option = document.createElement('option');

// replace spaces with nbsp to allow for multiple, leading, and trailing spaces option.text = wikEdFieldHist[field][i].replace(/ /g, '\xa0'); if ( (field == 'find') || (field == 'replace') ) { option.value = 'setcheck'; }			wikEdSelectElement[field].options[j++] = option; }	}

// add preset entries var startPreset = 0; if (wikEdComboPresetOptions[field] != null) { startPreset = j;		for (var i = 0; i < wikEdComboPresetOptions[field].length; i ++) { if (wikEdComboPresetOptions[field][i] != null) {

// replace spaces with nbsp to allow for multiple, leading, and trailing spaces wikEdComboPresetOptions[field][i] = wikEdComboPresetOptions[field][i].replace(/ /g, '\xa0');

// select a dropdown value if (wikEdComboPresetOptions[field][i] == wikEdInputElement[field].value) { selectedOption = j;				}

option = document.createElement('option'); option.text = wikEdComboPresetOptions[field][i].replace(/ /g, '\xa0'); if (field == 'summary') { option.text = option.text.replace(/\{wikEdUsing\}/g, wikEdSummaryUsing); }				wikEdSelectElement[field].options[j++] = option; }		}	}

// set the selection wikEdSelectElement[field].selectedIndex = selectedOption;

// add a blank preset separator if ( (startPreset > 1) && (startPreset < j) ) { option = document.createElement('optgroup'); option.label = '\xa0'; option.id = field + 'Optgroup'; wikEdSelectElement[field].insertBefore(option, wikEdSelectElement[field].options[startPreset]); }

// add the TOC jumper to the find field var startTOC = 0; if (field == 'find') { startTOC = j;

// get the whole plain text var plain = wikEdFrameBody.innerHTML; plain = plain.replace(/<br\b[^>]*>/g, '\n'); plain = plain.replace(/<.*?>/g, '');

// cycle through the headings var heading = plain.match(/(^|\n)=+[^\n]+?=+[^\n=]*[ =\t]*(?=(\n|$))/g); if (heading != null) { for (var i = 0; i < heading.length; i ++) { var headingMatch = heading[i].match(/\n?((=+) *([^\n]+?)( *\2))/); var headingIndent = headingMatch[2] headingIndent = headingIndent.replace(/^=/g, ''); headingIndent = headingIndent.replace(/=/g, '\xa0');

// add headings to the select element option = document.createElement('option'); option.text = '\u21d2' + headingIndent + headingMatch[3]; option.value = headingMatch[1]; wikEdSelectElement[field].options[j++] = option; }		}	}

// add a blank TOC separator if ( (startTOC > 1) && (startTOC < j) ) { option = document.createElement('optgroup'); option.label = '\xa0'; option.id = field + 'Optgroup'; wikEdSelectElement[field].insertBefore(option, wikEdSelectElement[field].options[startTOC]); }

return; }

// // WikEdClearHistory: clear the history of combo input fields //

window.WikEdClearHistory = function(field) { WikEdSetPersistent(wikEdSavedName[field], '', 0, '/'); WikEdSetComboOptions(field); return; }

// // WikEdLoadHistoryFromSettings: get the input box history from the respective saved settings //

window.WikEdLoadHistoryFromSettings = function(field) { var setting = WikEdGetPersistent(wikEdSavedName[field]); if (setting != '') { setting = decodeURIComponent(setting); wikEdFieldHist[field] = setting.split('\n'); }	else { wikEdFieldHist[field] = []; }	return; }

// // WikEdSaveHistoryToSetting: save the input box history to the respective saved settings //

window.WikEdSaveHistoryToSetting = function(field) {

var setting = ''; setting = wikEdFieldHist[field].join('\n') setting = setting.replace(/\n$/, ''); setting = encodeURIComponent(setting); WikEdSetPersistent(wikEdSavedName[field], setting, 0, '/'); return; }

// // WikEdGetSelection: cross-browser method to get the current selection //

window.WikEdGetSelection = function {

// standard var sel; if (typeof(wikEdFrameWindow.getSelection) == 'function') { sel = wikEdFrameWindow.getSelection; }

// MS IE compatibility else if (typeof(wikEdFrameDocument.selection) == 'object') { sel = wikEdFrameDocument.selection; }

// make sure there is at least an empty range if (sel.rangeCount == 0) { sel.collapse(wikEdFrameBody, 0); }

return(sel); }

// // WikEdClearSelection: cross-browser method to clear the currently selected text //

window.WikEdRemoveAllRanges = function(sel) {

if (typeof(sel.removeAllRanges) == 'function') { sel.removeAllRanges; }

// MS IE compatibility else if (typeof(sel.empty) == 'function') { sel.empty; }	return; }

// // WikEdGetSavedSetting: get a wikEd setting //

window.WikEdGetSavedSetting = function(settingName, preset) {

var setting = WikEdGetPersistent(settingName); if (setting == '') { setting = preset; }	else if (setting == '1') { setting = true; }	else { setting = false; }	return(setting); }

// // WikEdGetPersistent: get a cookie or a Greasemonkey persistent value (code copied to wikEdDiff.js) //

window.WikEdGetPersistent = function(name) {

var getStr = '';

// get a Greasemonkey persistent value if (wikEdGreasemonkey == true) { getStr = GM_getValue(name, ''); }

// get a cookie value else { getStr = WikEdGetCookie(name); }	return(getStr); }

// // WikEdSetPersistent: set a cookie or a Greasemonkey persistent value, deletes the value for expire = -1 //

window.WikEdSetPersistent = function(name, value, expires, path, domain, secure) {

// set a Greasemonkey persistent value if (wikEdGreasemonkey == true) { if (expires == -1) { GM_setValue(name, ''); }		else { GM_setValue(name, value); }	}

// set a cookie value else { WikEdSetCookie(name, value, expires, path, domain, secure); }	return; }

// // WikEdGetCookie: get a cookie (code copied to wikEdDiff.js) //

window.WikEdGetCookie = function(cookieName) {

var cookie = ' ' + document.cookie; var search = ' ' + cookieName + '='; var cookieValue = ''; var offset = 0; var end = 0; offset = cookie.indexOf(search); if (offset != -1) { offset += search.length; end = cookie.indexOf(';', offset) if (end == -1) { end = cookie.length; }		cookieValue = cookie.substring(offset, end); cookieValue = cookieValue.replace(/\\+/g, ' '); cookieValue = decodeURIComponent(cookieValue); }	return(cookieValue); }

// // WikEdSetCookie: set a cookie, deletes a cookie for expire = -1 //

window.WikEdSetCookie = function(name, value, expires, path, domain, secure) {

var cookie = name + '=' + encodeURIComponent(value);

if (expires != null) {

// generate a date 1 hour ago to delete the cookie if (expires == -1) { var cookieExpire = new Date; expires = cookieExpire.setTime(cookieExpire.getTime - 60 * 60 * 1000); expires = cookieExpire.toUTCString; }

// get date from expiration preset else if (expires == 0) { var cookieExpire = new Date; expires = cookieExpire.setTime(cookieExpire.getTime + wikEdCookieExpireSec * 1000); expires = cookieExpire.toUTCString; }		cookie += '; expires=' + expires; }	if (path != null) { cookie += '; path=' + path; }	if (domain != null) { cookie += '; domain=' + domain; }	if (secure != null) { cookie += '; secure'; }	document.cookie = cookie; return; }

// // WikEdGetOffsetTop: get element offset relative to window top (code copied to wikEdDiff.js) //

window.WikEdGetOffsetTop = function(element) { var offset = 0; do { offset += element.offsetTop; } while ( (element = element.offsetParent) != null ); return(offset); }

// // WikEdGetOffsetLeft: get element offset relative to left window border //

window.WikEdGetOffsetLeft = function(element) { var offset = 0; do { offset += element.offsetLeft; } while ( (element = element.offsetParent) != null ); return(offset); }

// // WikEdAppendScript: append script to head //

window.WikEdAppendScript = function(scriptUrl) {

var head = document.getElementsByTagName('head')[0]; var script = document.createElement('script'); script.type = 'text/javascript'; script.src = scriptUrl; head.appendChild(script); return; }

// // WikEdCleanNodes: remove DOM elements dynamically inserted by other scripts //

window.WikEdCleanNodes = function(node) {

if (wikEdCleanNodes == false) { return; }

// 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) { var divParent = div.parentNode; if (divParent != null) { divParent.removeChild(div); }			continue; }

// test for WOT attributes var divAttrs = div.attributes; for (var j = 0; j < divAttrs.length; ++ j) { var attr = divAttrs.item(j); if ( (attr.nodeName == 'wottarget') || (/^link[0-9a-f]{30,}/.test(attr.nodeName) == true) ) { var divParent = div.parentNode; if (divParent != null) { divParent.removeChild(div); }				break; }		}	}	return; }

// define leaf elements for WikEdGetInnerHTML window.wikEdLeafElements = []; wikEdLeafElements['IMG'] = true; wikEdLeafElements['HR'] = true; wikEdLeafElements['BR'] = true; wikEdLeafElements['INPUT'] = true;

// // WikEdParseDOM: parses a DOM subtree and and adds plain text into a complex data structure //

window.WikEdParseDOM = function(obj, topNode) {

obj.plainLength = 0; obj.plainArray = []; obj.plainNode = []; obj.plainStart = []; obj.plainPos = []; WikEdParseDOMRecursive(obj, topNode); obj.plain = obj.plainArray.join('');

return; }

// // WikEdParseDOMRecursive: parses a DOM tree and and adds plain text into the data structure //

window.WikEdParseDOMRecursive = function(obj, currentNode) {

// cycle through the child nodes of currentNode for (var property in currentNode.childNodes) { var childNode = currentNode.childNodes[property]; if (typeof(childNode) == 'string') { continue; }		if (childNode == null) { break; }

// check for selection if (childNode == obj.sel.focusNode) { obj.plainFocus = obj.plainLength + obj.sel.focusOffset; }		if (childNode == obj.sel.anchorNode) { obj.plainAnchor = obj.plainLength + obj.sel.anchorOffset; }		var value = null;

// get text of child node switch (childNode.nodeType) { case 1: if ( (childNode.childNodes.length == 0) && (wikEdLeafElements[childNode.nodeName] == true) ) { if (childNode.nodeName == 'BR') { value = '\n'; }				}				else { WikEdParseDOMRecursive(obj, childNode); }				break; case 3: value = childNode.nodeValue; value = value.replace(/\n/g, ' '); break; case 5: value = '&' + childNode.nodeName + ';'; break; }

// 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; }	}	return; }

// // WikEdGetInnerHTML: get the innerHTML from a document fragment //

window.WikEdGetInnerHTML = function(obj, currentNode) {

// initialize string if (obj.html == null) { obj.html = ''; }	if (obj.plain == null) { obj.plain = ''; }	if (obj.plainArray == null) { obj.plainArray = []; obj.plainNode = []; obj.plainStart = []; }

for (var i = 0; i < currentNode.childNodes.length; i ++) { var childNode = currentNode.childNodes.item(i); switch (childNode.nodeType) { case 1: obj.html += '<' + childNode.nodeName.toLowerCase; for (var j = 0; j < childNode.attributes.length; j ++) { if (childNode.attributes.item(j).nodeValue != null) { obj.html += ' ' + childNode.attributes.item(j).nodeName + '="' + childNode.attributes.item(j).nodeValue.replace(/</g, '&lt;').replace(/>/g, '&gt;') + '"'; }				}				if ( (childNode.childNodes.length == 0) && wikEdLeafElements[childNode.nodeName] ) { obj.html += '>'; if (childNode.nodeName == 'BR') { obj.plainArray.push('\n'); obj.plainNode.push(childNode); obj.plainStart.push(obj.plain.length); obj.plain += '\n'; }				}				else { obj.html += '>'; WikEdGetInnerHTML(obj, childNode); obj.html += '</' + childNode.nodeName.toLowerCase + '>' }				break; case 3: var value = childNode.nodeValue; value = value.replace(/\n/g, ' '); // important for pasted page content obj.plainArray.push(value);       // plain array contains & < > instead of &amp; &lt; &gt; obj.plainNode.push(childNode); obj.plainStart.push(obj.plain.length); value = value.replace(/&/g, '&amp;'); value = value.replace(/</g, '&lt;'); value = value.replace(/>/g, '&gt;'); obj.html += value; obj.plain += value; break; case 4: obj.html += '<![CDATA[' + childNode.nodeValue + ']]>'; break; case 5: var value = '&' + childNode.nodeName + ';'; obj.plainArray.push(value); obj.plainNode.push(childNode); obj.plainStart.push(obj.plain.length); value = value.replace(/&/g, '&amp;'); obj.html += value; obj.plain += value; break; case 8: obj.html += ''; break; }	}	return; }

// // WikEdApplyCSS: Attach css rules to document //

window.WikEdApplyCSS = function(cssDocument, cssRules) {

var stylesheet = new WikEdStyleSheet(cssDocument); var rules = ''; for (var ruleName in cssRules) { var ruleStyle = cssRules[ruleName]; if (typeof(ruleStyle) != 'string') { continue; }

// replace {wikedImage:imagePath} in css rules with image path ruleStyle = ruleStyle.replace(/\{wikEdImage:(\w+)\}/g,			function (p, p1) {				return(wikEdImage[p1]);			}		);

rules += ruleName + ' {' + ruleStyle + '}\n'; }	stylesheet.addRules(rules); return; }

// // WikEdStyleSheet: create a new style sheet object (code copied to wikEdDiff.js) //

window.WikEdStyleSheet = function(contextObj) {

if (contextObj == null) { contextObj = document; }	this.styleElement = null;

// MS IE compatibility if (contextObj.createStyleSheet) { this.styleElement = contextObj.createStyleSheet; }

// standards compliant browsers else { this.styleElement = contextObj.createElement('style'); this.styleElement.from = 'text/css'; var insert = contextObj.getElementsByTagName('head')[0]; if (insert != null) { this.styleElement.appendChild(contextObj.createTextNode('')); // Safari 3 fix insert.appendChild(this.styleElement); }	}

// // WikEdStyleSheet.addRule: add one rule at the time using DOM method, very slow //

this.addRule = function(selector, declaration) {

// MS IE compatibility if (this.styleElement.addRule != null) { if (declaration.length > 0) { this.styleElement.addRule(selector, declaration); }		}

// standards compliant browsers else { if (this.styleElement.sheet != null) { if (this.styleElement.sheet.insertRule != null) { this.styleElement.sheet.insertRule(selector + ' { ' + declaration + ' } ', 0); }			}		}	}

// // WikEdStyleSheet.addRules: add all rules at once, much faster //

this.addRules = function(rules) {

// MS IE compatibility if (this.styleElement.innerHTML == null) { this.styleElement.cssText = rules; }

// Safari, Chrome, WebKit else if ( (wikEdSafari == true) || (wikEdChrome == true) || (wikEdWebKit == true) ) { this.styleElement.appendChild(contextObj.createTextNode(rules)); }

// via innerHTML else { this.styleElement.innerHTML = rules; }		return; } }

// // WikEdGetStyle: get computed style properties for non-inline css definitions //

window.WikEdGetStyle = function(element, styleProperty) {

var style; if (element != null) { if ( (document.defaultView != null) && (document.defaultView.getComputedStyle != null) ) { style = document.defaultView.getComputedStyle(element, null)[styleProperty]; }

// MS IE compatibility else if (element.currentStyle != null) { style = element.currentStyle[styleProperty];

// recurse up trough the DOM tree if (style == 'inherit') { style = WikEdGetStyle(element.parentNode, styleProperty); }		}		else { style = element.style[styleProperty]; }	}	return(style); }

// // WikEdAjaxRequest: cross browser wrapper for Ajax requests (code copied to wikEdDiff.js) //

window.WikEdAjaxRequest = function(requestMethod, requestUrl, headerName, headerValue, bodyData, overrideMimeType, responseHandler) {

var request;

// use Greasemonkey GM_xmlhttpRequest if (wikEdGreasemonkey == true) {

var headerArray = { 'User-Agent': navigator.userAgent } if (headerName != null) { headerArray[headerName] = headerValue; }		request = new GM_xmlhttpRequest({			'method': requestMethod,			'url':     requestUrl,			'headers': headerArray,			'data':    bodyData,			'onreadystatechange':				function(ajax) {					if (ajax.readyState != 4) {						return;					}					responseHandler(ajax);					return;				}		}); }

// use standard XMLHttpRequest else {

// allow ajax request from local copy for testing if (wikEdAllowLocalAjax == true) { if (typeof(netscape) == 'object') { netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserRead'); }		}

// new ajax request object try { request = new XMLHttpRequest; }

// IE 6 catch(err) { try { request = new ActiveXObject('Microsoft.XMLHTTP'); }

// IE 5.5 catch(err) { try { request = new ActiveXObject('Msxml2.XMLHTTP'); }				catch(err) { return; }			}		}		request.open(requestMethod, requestUrl, true); if (headerName != null) { request.setRequestHeader(headerName, headerValue); }		if ( (request.overrideMimeType != null) && (overrideMimeType != null) ) { request.overrideMimeType(overrideMimeType); }		request.send(bodyData); request.onreadystatechange = function { if (request.readyState != 4) { return; }			responseHandler(request); return; }	}	return; }

// // WikEdGetGlobal: access values of global variables from Greasemonkey scripts using the 'location hack' (code copied to wikEdDiff.js) //

window.WikEdGetGlobal = function(globalName) { var globalValue; if (wikEdGreasemonkey == true) { if (wikEdGetGlobalNode == null) { wikEdGetGlobalNode = document.getElementById('wikEdGetGlobalNode'); }		if (wikEdGetGlobalNode == null) { wikEdGetGlobalNode = document.createElement('textarea'); wikEdGetGlobalNode.id = 'wikEdGetGlobalNode'; wikEdGetGlobalNode.style.display = 'none'; wikEdGetGlobalNode.style.visibility = 'hidden'; document.body.appendChild(wikEdGetGlobalNode); }		location.href = 'javascript:void(typeof(' + globalName + ')!=\'undefined\'?(' + globalName + '!=null?(document.getElementById(\'wikEdGetGlobalNode\').value=' + globalName + '.toString):null):null)'; globalValue = wikEdGetGlobalNode.value; }	else { try { globalValue = eval(globalName + '.toString;'); }		catch(err) { } }	return(globalValue); }

// // WikEdGetAttribute: MS IE compatibility wrapper for element.getAttribute //

window.WikEdGetAttribute = function(element, attribName) {

var attribValue = element.getAttribute(attribName);

// MS IE compatibility for checked if (attribName == 'checked') { if ( typeof(attribValue) == 'boolean' ) { if (attribValue == true) { attribValue = 'true'; }			else { attribValue = 'false'; }		}	}	return(attribValue); }

// // WikEdGetWindowInnerHeight: MS IE compatibility wrapper for window.innerHeight //

window.WikEdGetWindowInnerHeight = function {

var value = window.innerHeight; if (value == null) { if (document.documentElement != null) { value = document.documentElement.clientHeight; }		if ( (value == null) || (value == 0) ) { value = document.body.clientHeight }	}	return(value); }

// // WikEdGetWindowInnerWidth: MS IE compatibility wrapper for window.innerWidth //

window.WikEdGetWindowInnerWidth = function {

var value = window.innerWidth; if (value == null) { if (document.documentElement != null) { value = document.documentElement.clientWidth; }		if ( (value == null) || (value == 0) ) { value = document.body.clientWidth }	}	return(value); }

// // WikEdAddEventListener: wrapper for addEventListener (http://ejohn.org/projects/flexible-javascript-events/) //

window.WikEdAddEventListener = function(domElement, eventType, eventHandler, useCapture) {

if (domElement != null) { if (domElement.attachEvent != null) { domElement['wikEd' + eventType + eventHandler] = eventHandler; domElement[eventType + eventHandler] = function { domElement['wikEd' + eventType + eventHandler](window.event); }			domElement.attachEvent('on' + eventType, domElement[eventType + eventHandler] ); }		else { domElement.addEventListener(eventType, eventHandler, useCapture); }	}	return; }

// // WikEdRemoveEventListener: wrapper for removeEventListener //

window.WikEdRemoveEventListener = function(domElement, eventType, eventHandler, useCapture) {

if (domElement.detachEvent != null) { domElement.detachEvent('on' + eventType, domElement[eventType + eventHandler]); domElement[eventType + eventHandler] = null; }	else { domElement.removeEventListener(eventType, eventHandler, useCapture); }	return; }

// // WikEdEvent: MS IE compatibility fix for event object //

window.WikEdEvent = function(event) {

var eventAlt; if (window.event != null) { eventAlt = window.event; }	else if (wikEdFrameWindow.event != null) { eventAlt = wikEdFrameWindow.event; }	if (eventAlt != null) { event = eventAlt; event.stopPropagation = function { event.cancelBubble = true; };		event.preventDefault = function { event.returnValue = false; };		event.target = event.srcElement; if (event.type == 'mouseout') { event.relatedTarget = event.toElement; }		else if (event.type == 'mouseover') { event.relatedTarget = event.fromElement; }	}	return(event); }

// // WikEdDebug: print the value of variables //  use either a single value or a description followed by a value //  popup = true: use alert popup if debug textarea is not yet setup //

window.WikEdDebug = function(objectName, object, usePopup) {

var useDebug; if (typeof(wikEdDebug) != 'undefined') { if (wikEdDebug != null) { useDebug = true; }	}

// use debug textarea if (useDebug == true) { wikEdDebugWrapper.style.position = 'static'; wikEdDebugWrapper.style.visibility = 'visible'; wikEdDebug.style.display = 'block'; if (objectName == null) { wikEdDebug.value = ''; }		else { if (object == null) { wikEdDebug.value = objectName + '\n' + wikEdDebug.value; }			else { wikEdDebug.value = objectName + ': ' + object + '\n' + wikEdDebug.value; }		}	}

// use popup alert else if (usePopup == true) { if (object == null) { alert(objectName); }		else { alert(objectName + ': ' + object); }	}

// use error console else { var msg; if (object == null) { msg = objectName + ''; }		else { msg = objectName + ': ' + object; }		msg = msg.replace(/\'/g, '\\\''); setTimeout('throw new Error(\'WikEdDebug: ' + msg + '\')', 0); }	return; }

// // WikEdDebugTimer: show all measured timepoints //  add a new time measurement: wikEdDebugTimer.push([1234, new Date]);

window.WikEdDebugTimer = function { var times = ''; var start = wikEdDebugTimer[0][1].getTime; var prev = 0; for (var i = 0; i < wikEdDebugTimer.length; i ++) { var curr = wikEdDebugTimer[i][1].getTime - start; var diff = curr - prev; var prev = curr; times += wikEdDebugTimer[i][0] + ': ' + curr + ' ms (+ ' + diff + ' ms)\n'; }	WikEdDebug(times); wikEdDebugTimer = []; }

// // WikEdInsertTags: overrides the insertTags function in wikibits.js used by the standard button toolbar and the editpage special chars //

window.WikEdInsertTags = function(tagOpen, tagClose, sampleText) {

if (wikEdUseWikEd == true) { WikEdEditButton(document.getElementById('wikEdInsertTags'), 'wikEdInsertTags', [tagOpen, tagClose, sampleText]); }	else if (WikEdInsertTagsOriginal != null) { WikEdInsertTagsOriginal(tagOpen, tagClose, sampleText); }	return; }

// // WikEdInsertAtCursor: overrides the insertAtCursor function in wikia.com MediaWiki:Functions.js //

window.WikEdInsertAtCursor = function(myField, myValue) {

if (wikEdUseWikEd == true) { if (myField == wikEdTextarea) { WikEdEditButton(document.getElementById('wikEdInsertTags'), 'wikEdInsertTags', [ myValue ]); }	}	else if (WikEdInsertAtCursorOriginal != null) { WikEdInsertAtCursorOriginal(myField, myValue); }	return; }

// // WikEdExecuteHook: executes scheduled custom functions from functionsHook array //

window.WikEdExecuteHook = function(functionsHook) {

for (var i = 0; i < functionsHook.length; i++) { functionsHook[i]; }	return; }

// // WikEdInitUnicode: define character tables used in WikedFixUnicode //  see http://kmi.open.ac.uk/projects/ceryle/doc/docs/NOTE-charents.html //  removed because of internal use: < ['003c', 'lt']; > ['003e', 'gt']; & ['0026', 'amp'], ['00a0', 'nbsp']

window.WikEdInitUnicode = function {

// define only once if (wikEdSupportedChars != null) { return; }

// supported chars in Mozilla and IE	wikEdSupportedChars = [ [ 'a1', 'iexcl'],  // ¡ [ 'a2', 'cent'],   // ¢ [ 'a3', 'pound'],  // £ [ 'a4', 'curren'], // ¤ [ 'a5', 'yen'],    // ¥ [ 'a6', 'brvbar'], // ¦ [ 'a7', 'sect'],   // § [ 'a8', 'uml'],    // ¨ [ 'a9', 'copy'],   // © [ 'aa', 'ordf'],   // ª [ 'ab', 'laquo'],  // « [ 'ac', 'not'],    // ¬ [ 'ae', 'reg'],    // ® [ 'af', 'macr'],   // ¯ [ 'b0', 'deg'],    // ° [ 'b1', 'plusmn'], // ± [ 'b2', 'sup2'],   // ² [ 'b3', 'sup3'],   // ³ [ 'b4', 'acute'],  // ´ [ 'b5', 'micro'],  // µ [ 'b6', 'para'],   // ¶ [ 'b7', 'middot'], // · [ 'b8', 'cedil'],  // ¸ [ 'b9', 'sup1'],   // ¹ [ 'ba', 'ordm'],   // º [ 'bb', 'raquo'],  // » [ 'bc', 'frac14'], // ¼ [ 'bd', 'frac12'], // ½ [ 'be', 'frac34'], // ¾ [ 'bf', 'iquest'], // ¿ [ 'c0', 'Agrave'], // À [ 'c1', 'Aacute'], // Á [ 'c2', 'Acirc'],  // Â [ 'c3', 'Atilde'], // Ã [ 'c4', 'Auml'],   // Ä [ 'c5', 'Aring'],  // Å [ 'c6', 'AElig'],  // Æ [ 'c7', 'Ccedil'], // Ç [ 'c8', 'Egrave'], // È [ 'c9', 'Eacute'], // É [ 'ca', 'Ecirc'],  // Ê [ 'cb', 'Euml'],   // Ë [ 'cc', 'Igrave'], // Ì [ 'cd', 'Iacute'], // Í [ 'ce', 'Icirc'],  // Î [ 'cf', 'Iuml'],   // Ï [ 'd0', 'ETH'],    // Ð [ 'd1', 'Ntilde'], // Ñ [ 'd2', 'Ograve'], // Ò [ 'd3', 'Oacute'], // Ó [ 'd4', 'Ocirc'],  // Ô [ 'd5', 'Otilde'], // Õ [ 'd6', 'Ouml'],   // Ö [ 'd7', 'times'],  // × [ 'd8', 'Oslash'], // Ø [ 'd9', 'Ugrave'], // Ù [ 'da', 'Uacute'], // Ú [ 'db', 'Ucirc'],  // Û [ 'dc', 'Uuml'],   // Ü [ 'dd', 'Yacute'], // Ý [ 'de', 'THORN'],  // Þ [ 'df', 'szlig'],  // ß [ 'e0', 'agrave'], // à [ 'e1', 'aacute'], // á [ 'e2', 'acirc'],  // â [ 'e3', 'atilde'], // ã [ 'e4', 'auml'],   // ä [ 'e5', 'aring'],  // å [ 'e6', 'aelig'],  // æ [ 'e7', 'ccedil'], // ç [ 'e8', 'egrave'], // è [ 'e9', 'eacute'], // é [ 'ea', 'ecirc'],  // ê [ 'eb', 'euml'],   // ë [ 'ec', 'igrave'], // ì [ 'ed', 'iacute'], // í [ 'ee', 'icirc'],  // î [ 'ef', 'iuml'],   // ï [ 'f0', 'eth'],    // ð [ 'f1', 'ntilde'], // ñ [ 'f2', 'ograve'], // ò [ 'f3', 'oacute'], // ó [ 'f4', 'ocirc'],  // ô [ 'f5', 'otilde'], // õ [ 'f6', 'ouml'],   // ö [ 'f7', 'divide'], // ÷ [ 'f8', 'oslash'], // ø [ 'f9', 'ugrave'], // ù [ 'fa', 'uacute'], // ú [ 'fb', 'ucirc'],  // û [ 'fc', 'uuml'],   // ü [ 'fd', 'yacute'], // ý [ 'fe', 'thorn'],  // þ [ 'ff', 'yuml'],   // ÿ [ '27', 'apos'],   // ' [ '22', 'quot'],   // "		[ '152', 'OElig'],  // Œ		[ '153', 'oelig'],  // œ		[ '160', 'Scaron'], // Š		[ '161', 'scaron'], // š		[ '178', 'Yuml'],   // Ÿ		[ '2c6', 'circ'],   // ˆ		[ '2dc', 'tilde'],  // ˜		['2013', 'ndash'],  // –		['2014', 'mdash'],  // —		['2018', 'lsquo'],  // ‘		['2019', 'rsquo'],  // ’		['201a', 'sbquo'],  // ‚		['201c', 'ldquo'],  // “		['201d', 'rdquo'],  // ”		['201e', 'bdquo'],  // „		['2020', 'dagger'], // †		['2021', 'Dagger'], // ‡		['2030', 'permil'], // ‰		['2039', 'lsaquo'], // ‹		['203a', 'rsaquo'], // ›		['20ac', 'euro'],   // €		[ '192', 'fnof'],   // ƒ		[ '391', 'Alpha'],  // Α		[ '392', 'Beta'],   // Β		[ '393', 'Gamma'],  // Γ		[ '394', 'Delta'],  // Δ		[ '395', 'Epsilon'],// Ε		[ '396', 'Zeta'],   // Ζ		[ '397', 'Eta'],    // Η		[ '398', 'Theta'],  // Θ		[ '399', 'Iota'],   // Ι		[ '39a', 'Kappa'],  // Κ		[ '39b', 'Lambda'], // Λ		[ '39c', 'Mu'],     // Μ [ '39d', 'Nu'],    // Ν [ '39e', 'Xi'],    // Ξ [ '39f', 'Omicron'],// Ο [ '3a0', 'Pi'],    // Π [ '3a1', 'Rho'],   // Ρ [ '3a3', 'Sigma'], // Σ [ '3a4', 'Tau'],   // Τ [ '3a5', 'Upsilon'],// Υ [ '3a6', 'Phi'],   // Φ [ '3a7', 'Chi'],   // Χ [ '3a8', 'Psi'],   // Ψ [ '3a9', 'Omega'], // Ω [ '3b1', 'alpha'], // α [ '3b2', 'beta'],  // β [ '3b3', 'gamma'], // γ [ '3b4', 'delta'], // δ [ '3b5', 'epsilon'],// ε [ '3b6', 'zeta'],  // ζ [ '3b7', 'eta'],   // η [ '3b8', 'theta'], // θ [ '3b9', 'iota'],  // ι [ '3ba', 'kappa'], // κ [ '3bb', 'lambda'], // λ [ '3bc', 'mu'],    // μ [ '3bd', 'nu'],    // ν [ '3be', 'xi'],    // ξ [ '3bf', 'omicron'],// ο [ '3c0', 'pi'],    // π [ '3c1', 'rho'],   // ρ [ '3c2', 'sigmaf'], // ς [ '3c3', 'sigma'], // σ [ '3c4', 'tau'],   // τ [ '3c5', 'upsilon'],// υ [ '3c6', 'phi'],   // φ [ '3c7', 'chi'],   // χ [ '3c8', 'psi'],   // ψ [ '3c9', 'omega'], // ω ['2022', 'bull'],  // • ['2026', 'hellip'], // … ['2032', 'prime'], // ′ ['2033', 'Prime'], // ″ ['203e', 'oline'], // ‾ ['2044', 'frasl'], // ⁄ ['2122', 'trade'], // ™ ['2190', 'larr'],  // ← ['2191', 'uarr'],  // ↑ ['2192', 'rarr'],  // → ['2193', 'darr'],  // ↓ ['2194', 'harr'],  // ↔ ['21d2', 'rArr'],  // ⇒ ['21d4', 'hArr'],  // ⇔ ['2200', 'forall'], // ∀ ['2202', 'part'],  // ∂ ['2203', 'exist'], // ∃ ['2207', 'nabla'], // ∇ ['2208', 'isin'],  // ∈ ['220b', 'ni'],    // ∋ ['220f', 'prod'],  // ∏ ['2211', 'sum'],   // ∑ ['2212', 'minus'], // − ['221a', 'radic'], // √ ['221d', 'prop'],  // ∝ ['221e', 'infin'], // ∞ ['2220', 'ang'],   // ∠ ['2227', 'and'],   // ∧ ['2228', 'or'],    // ∨ ['2229', 'cap'],   // ∩ ['222a', 'cup'],   // ∪ ['222b', 'int'],   // ∫ ['2234', 'there4'], // ∴ ['223c', 'sim'],   // ∼ ['2248', 'asymp'], // ≈ ['2260', 'ne'],    // ≠ ['2261', 'equiv'], // ≡ ['2264', 'le'],    // ≤ ['2265', 'ge'],    // ≥ ['2282', 'sub'],   // ⊂ ['2283', 'sup'],   // ⊃ ['2286', 'sube'],  // ⊆ ['2287', 'supe'],  // ⊇ ['2295', 'oplus'], // ⊕ ['22a5', 'perp'],  // ⊥ ['25ca', 'loz'],   // ◊ ['2660', 'spades'], // ♠ ['2663', 'clubs'], // ♣ ['2665', 'hearts'], // ♥ ['2666', 'diams']  // ♦ ];

// special chars (spaces and invisible characters) wikEdSpecialChars = [ ['2002', 'ensp'],  //   en space [ 'ad', 'shy'],    // ­ soft hyphen ['2003', 'emsp'],  //   em space ['2009', 'thinsp'], //   thin space ['200c', 'zwnj'],  // ‌ zero width non-joiner ['200d', 'zwj'],   // ‍ zero width joiner ['200e', 'lrm'],   // ‎ left-to-right mark ['200f', 'rlm']    // ‏ right-to-left mark ];

// unsupported chars in IE6 wikEdProblemChars = [ [ '3d1', 'thetasym'], // ϑ [ '3d2', 'upsih'],   // ϒ [ '3d6', 'piv'],     // ϖ ['2118', 'weierp'],  // ℘ ['2111', 'image'],   // ℑ ['211c', 'real'],    // ℜ ['2135', 'alefsym'], // ℵ ['21b5', 'crarr'],   // ↵ ['21d0', 'lArr'],    // ⇐ ['21d1', 'uArr'],    // ⇑ ['21d3', 'dArr'],    // ⇓ ['2205', 'empty'],   // ∅ ['2209', 'notin'],   // ∉ ['2217', 'lowast'],  // ∗ ['2245', 'cong'],    // ≅ ['2284', 'nsub'],    // ⊄ ['22a5', 'perp'],    // ⊥ ['2297', 'otimes'],  // ⊗ ['22c5', 'sdot'],    // ⋅ ['2308', 'lceil'],   // ⌈ ['2309', 'rceil'],   // ⌉ ['230a', 'lfloor'],  // ⌊ ['230b', 'rfloor'],  // ⌋ ['2329', 'lang'],    // 〈 ['232a', 'rang']     // 〉 ];

// syntax highlighting of ASCII control characters and invisibles (decimal value, title) wikEdControlCharHighlighting = { '0': 'null', '1': 'start of heading', '2': 'start of text', '3': 'end of text', '4': 'end of transmission', '5': 'enquiry', '6': 'acknowledge', '7': 'bell', '8': 'backspace', '11': 'vertical tab', '12': 'form feed, new page', '14': 'shift out', '15': 'shift in', '16': 'data link escape', '17': 'device control 1', '18': 'device control 2', '19': 'device control 3', '20': 'device control 4', '21': 'negative acknowledge', '22': 'synchronous idle', '23': 'end of trans. block', '24': 'cancel', '25': 'end of medium', '26': 'substitute', '27': 'escape', '28': 'file separator', '29': 'group separator', '30': 'record separator', '31': 'unit separator', '8204': 'zero width non-joiner', // \u200c '8205': 'zero width joiner',    // \u200d '8206': 'left-to-right mark',   // \u200e '8207': 'right-to-left mark',   // \u200f '8232': 'line separator',       // \u2028 '8233': 'paragraph separator'   // \u2028 };	for (var decimalValue in wikEdControlCharHighlighting) { if (typeof(wikEdControlCharHighlighting[decimalValue]) != 'string') { continue; }		wikEdControlCharHighlightingStr += '\\' + String.fromCharCode(decimalValue); }

// character syntax highlighting: strange spaces, hyphens, and dashes (decimal value, class = title) wikEdCharHighlighting = { '9':   'wikEdTab',        // \u0009 '	' '8194': 'wikEdEnSpace',   // \u2002 ' ' '8195': 'wikEdEmSpace',   // \u2003 ' ' '8201': 'wikEdThinSpace', // \u2009 ' ' '45':  'wikEdHyphenDash', // \u00a0 '-' '173': 'wikEdSoftHyphen', // \u00ad '­' '8210': 'wikEdFigureDash', // \u2012 '‒' '8211': 'wikEdEnDash',    // \u2013 '–' '8212': 'wikEdEmDash',    // \u2014 '—' '8213': 'wikEdBarDash',   // \u2015 '―' '8722': 'wikEdMinusDash'  // \u2212 '−' };	for (var decimalValue in wikEdCharHighlighting) { if (typeof(wikEdCharHighlighting[decimalValue]) != 'string') { continue; }		wikEdCharHighlightingStr += '\\' + String.fromCharCode(decimalValue); }

return; }

// call wikEd startup WikEdStartup;

//