User:Cacycle/wikEd dev.js: Difference between revisions

Content deleted Content added
0.9.101 test
0.9.105 test
Line 4:
 
// version info
wikEd.programVersion = '0.9.101105';
wikEd.programDate = 'OctoberSeptember 0905, 20112012';
 
/*
Line 377:
// wikEd.InitImages: define built-in image URLs
wikEd.InitImages = function() {
 
WED('wikEd.config.imagePath', wikEd.config.imagePath);
wikEd.InitImage(wikEd.config.image, {
'barDash': '5/52/WikEd_bar_dash.png',
Line 486 ⟶ 484:
 
// frame
'.wikEdFrameHtml': 'height: 100%; width: 100%; padding: 0; margin: 0; background: transparent; background-image: url({wikEdImage:resizeGrip}); background-attachment: fixed; background-position: right bottom; background-repeat: no-repeat; line-height: normal;',
 
'.wikEdFrameBodyPlain': 'height: auto; min-height: 100%; width: auto; background: transparent; margin: 0; padding: 0; padding-left: 0.25em; overflow: auto; font-family: monospace;',
 
'.wikEdFrameBodySyntax': 'height: auto; min-height: 100%; width: auto; background: transparent; margin: 0; padding: 0; padding-left: 0.25em; overflow: auto; font-family: monospace; text-shadow: white -1px -1px 0, white -1px 0 0, white -1px 1px 0, white 0 -1px 0, white 0 1px 0, white 1px -1px 0, white 1px 0 0, white 1px 1px 0;',
'::selection': 'text-shadow: none; color: #fff; background: #006;',
'::-moz-selection': 'text-shadow: none; color: #fff; background: #006;', // broken in Firefox 10.0, see Bugzilla 724241/596316
'::-webkit-selection': 'text-shadow: none; color: #fff; background: #006;',
 
'.wikEdFrameBodyNewbie': 'height: auto; min-height: 100%; width: auto; background: transparent; margin: 0; padding: 0; padding-left: 0.25em; overflow: auto; font-family: monospace;',
Line 598 ⟶ 600:
 
// refs
'.wikEdFrameBodySyntax .wikEdRefContainer': 'display: noneblock; position: fixed; left: -10000em;',
 
'.wikEdRefContainer': 'position: relative; top: 1em;',
Line 617 ⟶ 619:
 
// templates
'.wikEdFrameBodySyntax .wikEdTemplContainer': 'display: noneblock; position: fixed; left: -10000em;',
'.wikEdTemplContainer': 'position: relative; top: 1em;',
'.wikEdTemplContainer button': 'padding: 0.1em; position: relative; top: -1em;',
Line 636 ⟶ 638:
 
// character entities
'.wikEdFrameBodySyntax .wikEdCharEntityContainer': 'display: noneblock; position: fixed; left: -10000em;',
 
'.wikEdCharEntityContainer': 'position: relative; right: -0.25em;',
Line 656 ⟶ 658:
'.wikEdFrameBodySyntax .wikEdRef .wikEdLinkName, .wikEdFrameBodySyntax .wikEdTempl .wikEdLinkName, .wikEdFrameBodySyntax .wikEdRef .wikEdLinkTarget, .wikEdFrameBodySyntax .wikEdTempl .wikEdLinkTarget, .wikEdFrameBodySyntax .wikEdRef .wikEdLinkText, .wikEdFrameBodySyntax .wikEdTempl .wikEdLinkText': 'color: #66f; font-weight: normal;',
 
// wikEd.frameBodyNewbiewikEdFrameBodyNewbie ref and template hiding
'.wikEdFrameBodyNewbie .wikEdRefContainer + .wikEdRef, .wikEdFrameBodyNewbie .wikEdTemplContainer + .wikEdTempl, .wikEdFrameBodyNewbie .wikEdTemplContainer .wikEdTemplNs,':
'position: fixed; left: -10000em;',

'.wikEdFrameBodyNewbie wikEd.refContainerwikEdRefContainer + .wikEdRefShow, .wikEdFrameBodyNewbie .wikEdTemplContainer + .wikEdTemplShow, .wikEdFrameBodyNewbie .wikEdTemplContainer + .wikEdTemplNsShow':
'display: noneblock; position: relative; color: #000; background: #f8f8f8; font-weight: normal; border: 1px solid; border-color: #444 #ccc #ccc #444; padding: 1em 0.25em 1em 0.25em; position: relative;',
 
'.wikEdFrameBodyNewbie .wikEdRefButton:before, .wikEdFrameBodyNewbie .wikEdTemplButton:before, .wikEdFrameBodyNewbie .wikEdRefButtonShow:before, .wikEdFrameBodyNewbie .wikEdTemplButtonShow:before':
Line 665 ⟶ 670:
'.wikEdRefButton:before, .wikEdTemplButton:before, .wikEdRefButtonShow:before, .wikEdTemplButtonShow:before':
'line-height: 0.75em; font-size: 65%; color: #000; font-family: sans-serif;',
 
'.wikEdCharEntityButton:before, .wikEdCharEntityButtonShow:before':
'',
 
'.wikEdFrameBodyNewbie .wikEdRefButton:before, .wikEdFrameBodyNewbie .wikEdRefButtonShow:before':
'content: "{wikEdText:hideRef}"',
 
'.wikEdFrameBodyNewbie .wikEdCharEntity, .wikEdFrameBodyNewbie .wikEdCharEntityShow':
'display: none; color: #000; border: 1px solid; border-color: #444 #ccc #ccc #444; background: #f8f8f8; border-color: rgba(64, 64, 64, 0.5) rgba(255, 255, 255, 0.75) rgba(255, 255, 255, 0.75) rgba(64, 64, 64, 0.5); background: rgba(192, 192, 192, 0.3); font-weight: normal;position: relative;',
 
'.wikEdFrameBodyNewbie .wikEdTemplButton:before, .wikEdFrameBodyNewbie .wikEdTemplButtonShow:before':
'content: "{wikEdText:hideTempl}";',
 
// wikEdFrameBodyNewbie char entity hiding
'.wikEdFrameBodyNewbie .wikEdCharEntity':
'position: fixed; left: -10000em;',
 
'.wikEdFrameBodyNewbie .wikEdCharEntityShow':
'display: inline; position: relative; color: #000; border: 1px solid; border-color: #444 #ccc #ccc #444; background: #f8f8f8; border-color: rgba(64, 64, 64, 0.5) rgba(255, 255, 255, 0.75) rgba(255, 255, 255, 0.75) rgba(64, 64, 64, 0.5); background: rgba(192, 192, 192, 0.3); font-weight: normal;',
 
'.wikEdCharEntityButton:before, .wikEdCharEntityButtonShow:before':
'',
 
// table edit
Line 1,248 ⟶ 1,257:
if (typeof(wikEd.config) == 'undefined') { wikEd.config = {}; }
 
// wikEd code home base URL, also defined in wikEdDiff.js
if (typeof(wikEd.config.homeBaseUrl) == 'undefined') { wikEd.config.homeBaseUrl = '//en.wikipedia.org/'; }
 
// diff script URL, also defined in wikEdDiff.js
if (typeof(wikEd.config.diffScriptSrc) == 'undefined') { wikEd.config.diffScriptSrc = wikEd.config.homeBaseUrl + 'w/index.php?title=User:Cacycle/diff.js&action=raw&ctype=text/javascript'; }
 
Line 1,308 ⟶ 1,317:
'no': wikEd.config.homeBaseUrl + 'w/index.php?action=raw&ctype=text/javascript&title=User:Dvyjones/wikEd_international_no.js',
'nn': wikEd.config.homeBaseUrl + 'w/index.php?action=raw&ctype=text/javascript&title=User:Frokor/wikEd_international_nn.js',
'fa': wikEd.config.homeBaseUrl + 'w/index.php?action=raw&ctype=text/javascript&title=User:Reza1615/wikEd_international_fa.js',
'pl': wikEd.config.homeBaseUrl + 'w/index.php?action=raw&ctype=text/javascript&title=User:Konradek/wikEd_international_pl.js',
'pt': wikEd.config.homeBaseUrl + 'w/index.php?action=raw&ctype=text/javascript&title=User:Mosca/wikEd_international_pt.js',
Line 1,327 ⟶ 1,337:
 
// wikEd.InitMediaWikiSkinIds: define Mediawiki page and skin detection, logo placement
// format: skin name: [ dom element to add logo to ('': top right), logo to this list or list contained in this parent element, rearrange page elements, [skin detection element id list], enable local preview / diff ],
wikEd.InitMediaWikiSkinIds = function() {
wikEd.InitObject(wikEd.config.MediaWikiSkinIds, {
Line 1,335 ⟶ 1,345:
 
// vector (see https://bugzilla.wikimedia.org/show_bug.cgi?id=19527)
vector_old: [ 'personal', true, true, ['content', 'bodyContent', 'siteSub', 'contentSub', 'left-navigation', 'namespaces'] ],
vector_new: [ 'p-personal', true, true, ['content', 'bodyContent', 'siteSub', 'contentSub', 'left-navigation', 'p-namespaces', 'p-cactions'] ],
 
// citizendium.org
Line 1,351 ⟶ 1,361:
quartz: [ 'welcome', false, true, ['articleWrapper', 'bodyContent', 'siteSub', 'contentSub', 'sidebar'] ],
searchwikia: [ 'header-li-buttons', false, true, ['header', 'header-container', 'header-go-button', 'article-container', 'article', 'article-text'] ],
oasis: [ 'AccountNavigation', false, false, ['WikiaHeader', 'WikiaPage'], false ],
 
// custom skins developed on wiki.mozilla.org and developer.mozilla.org
Line 1,358 ⟶ 1,369:
// custom skins
gumaxdd: [ 'gumax-p-login', true, true, ['gumax-header', 'gumax-content-body'] ],
pixeled: [ 'topright', true, true, ['contentwrapper', 'catnav', 'morefoot'] ],
 
// custom MediaWiki identifier
Line 1,647 ⟶ 1,659:
if (typeof(wikEd.rearrange) == 'undefined') { wikEd.rearrange = false; }
if (typeof(wikEd.logoToList) == 'undefined') { wikEd.logoToList = false; }
if (typeof(wikEd.enableLocalPreview) == 'undefined') { wikEd.enableLocalPreview = false; }
if (typeof(wikEd.skin) == 'undefined') { wikEd.skin = ''; }
 
Line 1,994 ⟶ 2,007:
}
if (nameMatch != null) {
var scriptName = nameMatch[1] || '';
if (scriptName != '') {
 
Line 2,044 ⟶ 2,057:
var rearrange = wikEd.config.MediaWikiSkinIds[skin][2];
var skinIds = wikEd.config.MediaWikiSkinIds[skin][3];
var enableLocalPreview = wikEd.config.MediaWikiSkinIds[skin][4];
for (var i = 0; i < skinIds.length; i ++) {
if (document.getElementById(skinIds[i]) == null) {
Line 2,054 ⟶ 2,068:
wikEd.rearrange = rearrange;
wikEd.logoToList = logoToList;
wikEd.enableLocalPreview = enableLocalPreview;
break;
}
Line 2,421 ⟶ 2,436:
wikEd.wikiGlobals.wgServer = regExpMatch[1];
wikEd.wikiGlobals.wgArticlePath = regExpMatch[1] + regExpMatch[2] + '$1';
wikEd.wikiGlobals.wgPageName = regExpMatch[4] || '';
wikEd.wikiGlobals.wgTitle = decodeURIComponent( regExpMatch[4].replace(/_/g, ' ') );
}
Line 2,615 ⟶ 2,630:
}
 
// check if we use the wikEd.editor user interface of the vector skin or custom other
 
// wikEd.wikiEditor = document.getElementById('wikiEditor-ui');
wikEd.wikiEditor = wikEd.GetElementsByClassName('wikiEditor-ui', 'div')[0];
 
if (wikEd.wikiEditor == null) {
wikEd.textareaContainervar parent = wikEd.textarea.parentNode;
if ( (parent.nodeName == 'DIV') && (parent.firstChild == wikEd.textarea) ) {
wikEd.textareaContainer = parent;
}
else {
wikEd.textareaContainer = wikEd.textarea;
}
}
else {
Line 2,782 ⟶ 2,800:
 
// create preview wrapper for preview and diff box
if (wikEd.enableLocalPreview != false) {
wikEd.localPrevWrapper = document.createElement('div');
wikEd.localPrevWrapper.id = document.createElement('wikEdLocalPrevWrapperdiv');
wikEd.localPrevWrapper.classNameid = 'wikEdLocalPrevWrapper';
wikEd.localPrevWrapper.style.displayclassName = 'nonewikEdLocalPrevWrapper';
wikEd.localPrevWrapper.style.display = 'none';
if (wikEd.rearrange == true) {
if (wikEd.rearrange == true) {
wikEd.inputWrapper.appendChild(wikEd.localPrevWrapper);
}
else if (wikEd.saveButton != null) {
wikEd.saveButton.parentNode.appendChild(wikEd.localPrevWrapper);
}
else if (wikEd.previewButton != null) {
wikEd.previewButton.parentNode.appendChild(wikEd.localPrevWrapper);
}
else if (wikEd.diffPreviewButton != null) {
wikEd.diffPreviewButton.parentNode.appendChild(wikEd.localPrevWrapper);
}
}
 
Line 3,160 ⟶ 3,180:
 
// add local preview button next to submit button
if (wikEd.enableLocalPreview != false) {
var previewSpan = document.createElement('span');
var previewSpan.innerHTML = wikEddocument.MakeButtonCodecreateElement(82, 'buttonspan');
previewSpan.innerHTML = wikEd.MakeButtonCode(82, 'button');
if (wikEd.previewButton != null) {
if (wikEd.previewButton != null) {
wikEd.previewButton.parentNode.insertBefore(previewSpan, wikEd.previewButton.nextSibling);
}
else if (wikEd.saveButton != null) {
wikEd.saveButton.parentNode.insertBefore(previewSpan, wikEd.saveButton.nextSibling);
}
 
// add local diff button next to submit button
if ( ( (wikEd.diffPreviewButton != null) || (wikEd.watchlistEdit == true) ) && (wikEd.readOnly == false) ) {
var diffSpan = document.createElement('span');
diffSpan.innerHTML = wikEd.MakeButtonCode(83, 'button');
if (wikEd.diffPreviewButton != null) {
wikEd.diffPreviewButton.parentNode.insertBefore(diffSpan, wikEd.diffPreviewButton.nextSibling);
}
else if (previewSpanwikEd.saveButton != null) {
previewSpanwikEd.saveButton.parentNode.insertBefore(diffSpanpreviewSpan, previewSpanwikEd.saveButton.nextSibling);
}
 
else if (wikEd.previewButton != null) {
// add local diff button next to submit button
wikEd.previewButton.parentNode.insertBefore(diffSpan, wikEd.previewButton.nextSibling);
if ( ( (wikEd.diffPreviewButton != null) || (wikEd.watchlistEdit == true) ) && (wikEd.readOnly == false) ) {
var diffSpan = document.createElement('span');
diffSpan.innerHTML = wikEd.MakeButtonCode(83, 'button');
if (wikEd.diffPreviewButton != null) {
wikEd.diffPreviewButton.parentNode.insertBefore(diffSpan, wikEd.diffPreviewButton.nextSibling);
}
else if (previewSpan != null) {
previewSpan.parentNode.insertBefore(diffSpan, previewSpan.nextSibling);
}
else if (wikEd.previewButton != null) {
wikEd.previewButton.parentNode.insertBefore(diffSpan, wikEd.previewButton.nextSibling);
}
}
}
Line 3,754 ⟶ 3,776:
sep = '?';
}
 
wikEd.AjaxRequest('GET', wikEd.config.regExTypoFixURL + sep + wikEd.programVersion, null, 'text/plain', function(ajax) {
 
Line 3,761 ⟶ 3,783:
 
// parse regexp rules
var regExp = /<(?:Typo)?\s+(?:word="(.*?)"\s+)?find="(.*?)"\s+replace="(.*?)"\s*\/?>/g;
while ( (regExpMatch = regExp.exec(rulesTxt)) != null) {
 
Line 6,919 ⟶ 6,941:
tagsampleText = sampleText.replace(/</g, '&lt;');
tagsampleText = sampleText.replace(/>/g, '&gt;');
 
 
// single string to insert
Line 6,924 ⟶ 6,947:
obj.changed = obj.cursor;
obj.changed.plain = tagOpen;
}
else if ( (tagOpen.length == 0) && (tagClose.length == 0) && (sampleText.length > 0) ) {
obj.changed = obj.cursor;
obj.changed.plain = sampleText;
}
 
Line 7,060 ⟶ 7,087:
if (obj.changed.from == 'whole') {
wikEd.RemoveAllRanges(obj.sel);
wikEd.frameBody.scrollTop = frameScrollTop;
var range = wikEd.frameDocument.createRange();
range.setStartBefore(wikEd.frameBody.firstChild);
Line 7,066 ⟶ 7,092:
obj.sel.addRange(range);
selectChanged = false;
 
// scheduling needed for Firefox 9.0.1
setTimeout( function() { wikEd.frameBody.scrollTop = frameScrollTop; }, 0);
}
 
Line 7,076 ⟶ 7,105:
range.setStartAfter(startNodeReselect);
// should be range.setEndAfter, but that causes caret at start of next line due to https://bugzilla.mozilla.org/show_bug.cgi?id=587461
range.setEndBeforesetEndAfter(endNodeReselect);
obj.sel.addRange(range);
wikEd.ScrollToNodes(startNodeReselect, endNodeReselect);
Line 7,278 ⟶ 7,307:
 
//
// wikEd.DiffResponse: calculate calculate and linkify the diff between two versions (code copied to wikEdDiff.js)
//
 
Line 7,322 ⟶ 7,351:
html = html.replace(/&gt;/g, '\x01');
 
// split into valid html tags and plain text fragments
// external links
var linkified = '';
html = html.replace(/\b(((https?|ftp|irc|gopher):\/\/)|news:|mailto:)([^\x00-\x20\s"\[\]\x7f\|\{\}<>]|<[^>]*>)+?(?=([\!"\(\)\.\,\:\;\‘-•]*\s|[\x00-\x20\s"\[\]\x7f\|\{\}]))/gi,
var regExp = /(<[^<>]*>)|([^<>]+|<|>)/g;
function (p) {
while ( (regExpMatch = regExp.exec(html)) != null) {
var whole = p;
var tag = regExpMatch[1] || '';
var plain = regExpMatch[2] || '';
 
// process tags
var title = whole;
if (tag != '') {
title = title.replace(/\x00!--.*?--\x01/g, '');
linkified += tag;
title = title.replace(/.*--\x01|\x00!--.*/g, '');
}
title = title.replace(/<.*?>/g, '');
title = title.replace(/^.*>|<.*$/g, '');
title = title.replace(/^\s+|\s+$/g, '');
title = decodeURI(title);
 
// process plain tags
var url = title.replace(/\s/g, '_');
else {
url = encodeURI(url);
url = url.replace(/"/g, '%22');
url = url.replace(/'/g, '%27');
url = url.replace(/#/g, '%23');
 
// escape bogus < or >
var linkTitle = title.replace(/"/g, '&quot;');
plain = plain.replace(/>/g, '&gt;');
plain = plain.replace(/</g, '&lt;');
 
// external links 123 3 2 14 4 5 6 65
// linkify all url text fragments between highlighting <span>s seperately
plain = plain.replace(/\b(((https?|ftp|irc|gopher):\/\/)|news:|mailto:)([^\x00-\x20\s"\[\]\x7f\|\{\}<>]|<[^>]*>)+?(?=([\!"\(\)\.\,\:\;\‘-•]*\s|[\x00-\x20\s"\[\]\x7f\|\{\}]|$))/gi,
var anchorOpen = '<a href = "' + url + '" style="text-decoration: none; color: inherit; color: expression(parentElement.currentStyle.color);" title="' + linkTitle + '">';
function (p) {
var anchorClose = '</a>';
var whole = p;
whole = whole.replace(/(<[^>]*>)/g, anchorClose + '$1' + anchorOpen);
return(anchorOpen + whole + anchorClose);
}
);
 
var title = whole;
// linkify links and templates
title = title.replace(/\x00!--.*?--\x01/g, '');
if ( (wikEd.wikiGlobals.wgServer != null) && (wikEd.wikiGlobals.wgArticlePath != null) ) {
title = title.replace(/.*--\x01|\x00!--.*()/g, '');
title = title.replace(/<.*?>/g, '');
title = title.replace(/^.*>|<.*$/g, '');
title = title.replace(/^\s+|\s+$/g, '');
title = decodeURI(title);
 
var url = title;
// 1 [[ 2title 23 | text 3 ]]1 4 {{ 5title 56 6 4
url = encodeURI(url);
html = html.replace(/(\[\[([^|\[\]{}\n]+)(\|[^\[\]{}<>]*)?\]\])|(\{\{([^|\[\]{}\n]*)([^\[\]{}<>]*\}\})?)/g,
url = url.replace(/ /g, '%20');
function (p, p1, p2, p3, p4, p5, p6) {
var articleName url = p2 ||url.replace(/"/g, '%22');
var templateName url = p5 ||url.replace(/'/g, '%27');
url = url.replace(/#/g, '%23');
var whole = p;
 
// var extractlinkTitle = title.replace(/"/g, '&quot;');
var title = articleName;
if (title == '') {
title = templateName;
}
title = title.replace(/\x00!--.*?--\x01/g, '');
title = title.replace(/.*--\x01|\x00!--.*/g, '');
title = title.replace(/<.*?>/g, '');
title = title.replace(/^.*>|<.*$/g, '');
title = title.replace(/^\s+|\s+$/g, '');
 
// linkify all url text fragments between highlighting <span>s seperately
// [[/subpage]] refers to a subpage of the current page, [[#section]] to a section of the current page
var anchorOpen = '<a href = "' + url + '" style="text-decoration: none; color: inherit; color: expression(parentElement.currentStyle.color);" title="' + linkTitle + '">';
if ( (title.indexOf('/') == 0) || (title.indexOf('#') == 0) ) {
var anchorClose = '</a>';
title = wikEd.pageName + title;
whole = whole.replace(/(<[^>]*>)/g, anchorClose + '$1' + anchorOpen);
return(anchorOpen + whole + anchorClose);
}
);
 
// createlinkify urllinks and templates
if ( (wikEd.wikiGlobals.wgServer != null) && (wikEd.wikiGlobals.wgArticlePath != null) ) {
var url = title.replace(/\s/g, '_');
url = encodeURI(url);
url = url.replace(/"/g, '%22');
url = url.replace(/'/g, '%27');
url = url.replace(/#/g, '%23');
var articleTitle = title.replace(/"/g, '&quot;');
if (templateName != '') {
if (/:/.test(title) == false) {
url = 'Template:' + url;
articleTitle = 'Template:' + articleTitle;
}
}
url = wikEd.wikiGlobals.wgServer + wikEd.wikiGlobals.wgArticlePath.replace(/\$1/, url);
 
// 1 [[ 2title 23 | text 3 ]]1 4 {{ 5title 56 6 4
// linkify all text fragments between highlighting <span>s seperately
plain = plain.replace(/(\[\[([^|\[\]{}\n]+)(\|[^\[\]{}<>]*)?\]\])|(\{\{([^|\[\]{}\n]*)([^\[\]{}<>]*\}\})?)/g,
var anchorOpen = '<a href = "' + url + '" style = "text-decoration: none; color: inherit; color: expression(parentElement.currentStyle.color)" title="' + articleTitle + '">';
function (p, p1, p2, p3, p4, p5, p6) {
var anchorClose = '</a>';
var articleName = p2 || '';
whole = whole.replace(/(<[^>]*>)/g, anchorClose + '$1' + anchorOpen);
var templateName = p5 || '';
return(anchorOpen + whole + anchorClose);
var whole = p;
 
// extract title
var title = articleName;
if (title == '') {
title = templateName;
}
title = title.replace(/\x00!--.*?--\x01/g, '');
title = title.replace(/.*--\x01|\x00!--.*()/g, '');
title = title.replace(/<.*?>/g, '');
title = title.replace(/^.*>|<.*$/g, '');
title = title.replace(/^\s+|\s+$/g, '');
 
// [[/subpage]] refers to a subpage of the current page, [[#section]] to a section of the current page
if ( (title.indexOf('/') == 0) || (title.indexOf('#') == 0) ) {
title = wikEd.pageName + title;
}
 
// create url
var url = title.replace(/\s/g, '_');
url = encodeURI(url);
url = url.replace(/"/g, '%22');
url = url.replace(/'/g, '%27');
url = url.replace(/#/g, '%23');
var articleTitle = title.replace(/"/g, '&quot;');
if (templateName != '') {
if (/:/.test(title) == false) {
url = 'Template:' + url;
articleTitle = 'Template:' + articleTitle;
}
}
url = wikEd.wikiGlobals.wgServer + wikEd.wikiGlobals.wgArticlePath.replace(/\$1/, url);
 
// linkify all text fragments between highlighting <span>s seperately
var anchorOpen = '<a href = "' + url + '" style = "text-decoration: none; color: inherit; color: expression(parentElement.currentStyle.color)" title="' + articleTitle + '">';
var anchorClose = '</a>';
whole = whole.replace(/(<[^>]*>)/g, anchorClose + '$1' + anchorOpen);
return(anchorOpen + whole + anchorClose);
}
);
}
linkified += plain;
);
}
}
 
// \x00 and \x01 back to &lt; and &gt;
htmllinkified = htmllinkified.replace(/\x00/g, '&lt;');
htmllinkified = htmllinkified.replace(/\x01/g, '&gt;');
 
return(htmllinkified);
};
 
Line 7,434 ⟶ 7,486:
regExpParse.lastIndex = startPos;
while ( (regExpMatch = regExpParse.exec(html)) != null) {
ifvar p1 = (regExpMatch[1] ==|| '') {;
if (p1 == '') {
level ++;
}
Line 7,725 ⟶ 7,778:
}
}
 
// scheduled unhide on shift or ctrl keydown
if (event.type == 'keydown') {
Line 7,738 ⟶ 7,791:
// open on hover
if ( (event.type == 'mouseover') || ( (event.type == 'keydown') && (wikEd.scheduledUnhide != null) ) ) {
 
if (hideButtonClass.indexOf('wikEdRefButton') == 0) {
hideClass = hideClass.replace(/Show/, '') + 'Show';
hide.style.display = 'block';
hide.className = hideClass;
}
 
else if (hideButtonClass.indexOf('wikEdTemplButton') == 0) {
hide.style.display = 'block';
}
else if (hideButtonClass.indexOf('wikEdCharEntity') == 0) {
hide.style.display = 'inline';
}
wikEd.RemoveEventListener(hideButton, 'mouseover', wikEd.HideShowHandler, true);
wikEd.AddEventListener(hide, 'mouseout', wikEd.HideShowHandler, true);
Line 7,769 ⟶ 7,817:
}
if (hideOut == true) {
 
hide.style.display = 'none';
hideClass = hideClass.replace(/Show/, '');
hide.className = hideClass;
 
wikEd.RemoveEventListener(hide, 'mouseout', wikEd.HideShowHandler, true);
wikEd.RemoveEventListener(hideButton, 'mouseout', wikEd.HideShowHandler, true);
Line 7,784 ⟶ 7,835:
else if (event.type == 'click') {
if (/^wikEd(Ref|Templ|CharEntity)ButtonShow\d*$/.test(hideButtonClass) == true) {
hide.style.display = 'none';
 
hideButtonClass = hideButtonClass.replace(/Show/, '');
hideClass = hideClass.replace(/Show/, '');
hide.className = hideClass;
 
hideButtonClass = hideButtonClass.replace(/Show/, '');
hideButton.className = hideButtonClass;
hideButton.title = wikEd.config.text[hideButtonClass.replace(/\d+$/g, '') + 'Tooltip'];
Line 7,800 ⟶ 7,851:
// open on click
else if (/^wikEd(Ref|Templ|CharEntity)Button\d*$/.test(hideButtonClass) == true) {
 
if (hideButtonClass.indexOf('wikEdCharEntityButton') == 0) {
hide.style.display = 'inline';
}
else {
hide.style.display = 'block';
}
hideButtonClass = hideButtonClass.replace(/Button(Show)?/, 'ButtonShow');
hideClass += 'Show';
hideClass = hideClass.replace(/Show/, '') + 'Show';
hide.className = hideClass;
 
hideButtonClass = hideButtonClass.replace(/Button(Show)?/, 'ButtonShow');
hideButton.className = hideButtonClass;
hideButton.title = wikEd.config.text[hideButtonClass.replace(/\d+$/g, '') + 'Tooltip'];
Line 7,818 ⟶ 7,864:
}
}
 
// clear scheduled unhide
if (wikEd.scheduledUnhide != null) {
Line 8,484 ⟶ 8,530:
// delete content tags
obj.plain = obj.plain.replace(/<(style|script|object|applet|embed)\b[^>]*>.*?<\/\1>/g, '');
 
// delete outlook tags
obj.plain = obj.plain.replace(/<(w:|m:)\b[^>]*>.*?<\/\1>/g, '');
 
// newlines
Line 8,490 ⟶ 8,539:
// <div>...</div> to <br> for Safari, Chrome, WebKit
if ( (wikEd.safari == true) || (wikEd.chrome == true) || (wikEd.webkit == true) ) {
obj.plain = wikEd.RemoveTag(obj.plain, 'div', null, '\x00', '\x00');
var isRemove = [];
obj.plain = obj.plain.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.plain = obj.plain.replace(/\x00\n\x01/g, '\x01');
obj.plain = obj.plain.replace(/\x01\n/g, '\x01');
Line 8,521 ⟶ 8,554:
// remove highlighting pre tags
var isRemove = [];
obj.plain = wikEd.RemoveTag(obj.plain.replace(, 'pre', /(<(\bclass="wikEd[\w\/?)pre\b([^>]*+"/)>)/g,;
function (p, p1, p2, p3) {
if (p2 == '') {
if (/\bclass="wikEd[\w\/]+"/.test(p3) == true) {
isRemove.push(true);
return('');
}
isRemove.push(false);
return(p1);
}
if (isRemove.pop() == true) {
return('');
}
return(p1);
}
);
 
// blocks
Line 9,588 ⟶ 9,606:
 
wikEd.FindBoundaries = function(word, line, para, whole, selection) {
 
if (whole.plain == '') {
return;
}
 
// get the start node and offset
Line 9,757 ⟶ 9,779:
// <div>...</div> to <br> for Safari, Chrome, WebKit
if ( (wikEd.safari == true) || (wikEd.chrome == true) || (wikEd.webkit == true) ) {
obj.html = wikEd.RemoveTag(obj.html, 'div', null, '\x00', '\x00');
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(/\x00\s*<br>\s*\x01/g, '\x01');
obj.html = obj.html.replace(/\x01\s*<br>/g, '\x01');
Line 9,879 ⟶ 9,885:
 
// convert <div class="poem">...</div> to <poem>...</poem>
obj.html = wikEd.RemoveTag(obj.html, 'div', /\bclass="poem"/, '<poem>', '</poem>');
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('<poem>');
}
isPoem.push(false);
return(p1);
}
if (isPoem.pop() == true) {
return('<poem>');
}
return(p1);
}
);
 
// sanitize <span> <div> <p> <font>
obj.html = obj.html.replace(/<(span|div|p|font)\b *(.*?) *\/?>/gi,
function (p, p1, p2) {
return('<' + p1 + wikEd.SanitizeAttributes(p1, p2, relaxed) + '>');
Line 9,904 ⟶ 9,894:
);
 
// remove <span> ...and </spanfont> pairs withhout attributes
obj.html = wikEd.RemoveTag(obj.html, 'span|font');
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 <p> ... </p> pairs withhout attributes
obj.html = wikEd.RemoveTag(obj.html, 'p', null, '\x00\x00', '\x00\x00');
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
Line 10,433 ⟶ 10,391:
 
// remove empty inline and block tag pairs
obj.html = wikEd.RemoveEmptyTags(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 = wikEd.RemoveEmptyTags(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
Line 10,474 ⟶ 10,432:
return;
};
 
 
//
// wikEd.RemoveEmptyTag: recursively remove empty html tag pairs
//
 
wikEd.RemoveEmptyTags = function(html, tag, replace) {
 
var tagRegExp;
if (typeof(tag) == 'string') {
tagRegExp = new RegExp('<(' + tag + ')\\b[^>]*><\/\\1>', 'gi');
}
else {
tagRegExp = tag;
}
 
if (replace == null) {
replace = '';
}
 
while (tagRegExp.test(html) == true) {
html = html.replace(tagRegExp, replace);
}
return(html);
}
 
 
//
// wikEd.RemoveTag: recursively remove html tag pairs
//
 
wikEd.RemoveTag = function(html, tag, attribRegExp, replaceOpen, replaceClose) {
 
var tagRegExp;
if (typeof(tag) == 'string') {
// 1 2 23 3 4 4 1
tagRegExp = new RegExp('(<(\\/?)(' + tag + ')\\b([^>]*)>)', 'g');
}
else {
tagRegExp = tag;
}
if (replaceOpen == null) {
replaceOpen = '';
}
 
if (replaceClose == null) {
replaceClose = '';
}
 
var isRemove = [];
html = html.replace(tagRegExp,
function (p, p1, p2, p3, p4) {
p2 = p2 || '';
p4 = p4 || '';
if (p2 == '') {
WED('p4', p4);
if (
( (attribRegExp == null) && (p4 == '') ) ||
(attribRegExp.test(p4) == true)
) {
isRemove.push(true);
return(replaceOpen);
}
isRemove.push(false);
return(p1);
}
if (isRemove.pop() == true) {
return(replaceClose);
}
return(p1);
}
);
return(html);
}
 
 
Line 10,782 ⟶ 10,814:
 
// remove highlighting and atttribute-free span tags
obj.html = wikEd.RemoveTag(obj.html, 'span', /\bclass="wikEd[\w\/]+"/);
var isRemove = [];
obj.html = obj.html.replace(/(<(\/?)span\b([^>]*)>)/g,
function (p, p1, p2, p3) {
if (p2 == '') {
if (/\bclass="wikEd[\w\/]+"/.test(p3) == true) {
isRemove.push(true);
return('');
}
isRemove.push(false);
return(p1);
}
if (isRemove.pop() == true) {
return('');
}
return(p1);
}
);
 
// remove highlighting div tags
obj.html = wikEd.RemoveTag(obj.html, 'div', /\bclass="wikEd[\w\/]+"/, '\x00', '\x00');
var isRemove = [];
obj.html = obj.html.replace(/(<(\/?)div\b([^>]*)>)/g,
function (p, p1, p2, p3) {
if (p2 == '') {
if (/\bclass="wikEd[\w\/]+"/.test(p3) == true) {
isRemove.push(true);
return('');
}
isRemove.push(false);
return(p1);
}
if (isRemove.pop() == true) {
return('');
}
return(p1);
}
);
 
// remove span and font tags from WebKit https://bugs.webkit.org/show_bug.cgi?id=13490
// filtering these tags does not help, they accumulate anyway
obj.html = wikEd.RemoveTag(obj.html, 'span|font', /\bclass="(Apple-style-span|Apple-.*?)"/, '\x00', '\x00');
var isRemove = [];
obj.html = obj.html.replace(/(<(\/?)span\b([^>]*)>)/g,
function (p, p1, p2, p3) {
if (p2 == '') {
if (/\bclass="(Apple-style-span|Apple-.*?)"/.test(p3) == true) {
isRemove.push(true);
return('\x00');
}
isRemove.push(false);
return(p1);
}
if (isRemove.pop() == true) {
return('\x01');
}
return(p1);
}
);
 
// remove highlighting font tags from WebKit
var isRemove = [];
obj.html = obj.html.replace(/(<(\/?)font\b([^>]*)>)/g,
function (p, p1, p2, p3) {
if (p2 == '') {
if (/\bclass="(Apple-style-span|Apple-.*?)"/.test(p3) == true) {
isRemove.push(true);
return('\x00');
}
isRemove.push(false);
return(p1);
}
if (isRemove.pop() == true) {
return('\x01');
}
return(p1);
}
);
 
// remove highlighting div tags from WebKit
Line 11,122 ⟶ 11,087:
while ( (regExpMatch = regExpComments.exec(obj.html)) != null) {
var tag;
ifvar p1 = (regExpMatch[1] != null)|| {'';
var p2 = regExpMatch[2] || '';
if (p1 != '') {
tag = 'comment';
}
else if (regExpMatch[2]p2 != null'') {
tag = 'keep';
}
Line 12,288 ⟶ 12,255:
 
// get interwiki, namespace, article, paramters
ifvar p1 = (regExpMatch[1] != null)|| {'';
interif (p1 != regExpMatch[1];'') {
inter = p1;
interClean = inter;
interClean = interClean.replace(/\s/g, ' ');
Line 12,297 ⟶ 12,265:
}
 
ifvar p3 = (regExpMatch[3] != null)|| {'';
nsif (p3 != regExpMatch[3];'') {
ns = p3;
nsClean = ns;
nsClean = nsClean.replace(/\s/g, ' ');
Line 12,321 ⟶ 12,290:
}
}
 
article = regExpMatch[6] || '';
param = regExpMatch[8] || '';
 
if (regExpMatch[8] != null) {
param = regExpMatch[8];
}
 
// highlight interwiki and namespace
Line 12,449 ⟶ 12,415:
 
// get modifier, namespace, template, paramters
ifvar p1 = (regExpMatch[1] != null)|| {'';
modif (p1 != regExpMatch[1];'') {
mod = p1;
interClean = mod.replace(/\s+$/g, '');
interClean = inter.replace(/:$/g, '');
}
 
ifvar p3 = (regExpMatch[3] != null)|| {'';
nsif (p3 != regExpMatch[3];'') {
ns = p3;
nsClean = ns.replace(/^\s+|\s+$/g, '');
nsClean = nsClean.replace(/\s*\:\s*()/g, ':');
Line 12,463 ⟶ 12,431:
}
 
template = regExpMatch[6] || '';
param = regExpMatch[8] || '';
 
if (regExpMatch[8] != null) {
param = regExpMatch[8];
}
 
// {{VARIABLE}}
Line 12,551 ⟶ 12,516:
}
}
var hideStyle = '';
var hideClass = 'wikEdTempl';
if ( (template != '') && (parserVar == false) ) {
Line 12,566 ⟶ 12,530:
hideClass = 'wikEdTemplShow';
hideButtonStyle = ' style="display: block"';
hideStyle = ' style="display: block"';
}
}
Line 12,575 ⟶ 12,538:
}
}
insertLeft += '<span class="' + hideClass + '"' + hideStyle + '><span class="wikEdTemplTag">';
insertRight = '</span><!--wikEdTemplTag--><span class="wikEdTemplName"' + follow + '>';
break;
Line 12,660 ⟶ 12,623:
var regExpMatch;
if ( (regExpMatch = /(\bname\s*=\s*('|"))([^\x01]+?)\2/i.exec(tagMatch)) != null) {
refName = regExpMatch[3] || '';
wikEd.HighlightBuildTree('refName', 'block', tagFrom + regExpMatch.index + regExpMatch[1].length, regExpMatch[3].length, parseObj);
}
else if ( (regExpMatch = /(\bname\s*=\s*)(\w+)/i.exec(tagMatch)) != null) {
refName = regExpMatch[2] ;
wikEd.HighlightBuildTree('refName', 'block', tagFrom + regExpMatch.index + regExpMatch[1].length, regExpMatch[2].length, parseObj);
}
Line 12,710 ⟶ 12,673:
if (regExpMatch != null) {
if (regExpMatch.index == tagFrom) {
var params = regExpMatch[1] || '';
if (params != '') {
params += ' ';
Line 12,900 ⟶ 12,863:
idNumber = regExpMatch[0];
}
insertLeft = '<span class="wikEdPMID" ' + wikEd.HighlightLinkify('', '', 'http://www.ncbi.nlm.nih.gov/pubmed/' + idNumber) + '>';
insertRight = '</span><!--wikEdPMID-->';
break;
Line 12,918 ⟶ 12,881:
idNumber = regExpMatch[0].replace(/\D/g, '');
}
insertLeft = '<span class="wikEdISBN" ' + wikEd.HighlightLinkify('', '', 'http://tools.ietf.org/html/rfc' + idNumber) + '>';
pushRight = '</span><!--wikEdISBN-->';
break;
Line 13,175 ⟶ 13,138:
if (insertLeft != '') {
node.left = insertLeft;
node.index = i + 0.1;
}
 
// add left html as new array element to allow for overlapping highlighting as in hr
else if (pushLeft != '') {
parseObj.tree.push( { 'start': tagFrom, 'tagLength': 0, 'left': pushLeft, 'index': i +- 0.25 } );
}
 
Line 13,186 ⟶ 13,149:
if (insertRight != '') {
node.right = insertRight;
node.index = i - 0.1;
}
 
// add right html as new array element to allow for overlapping highlighting as in html-like tags and urls
else if (pushRight != '') {
parseObj.tree.push( { 'start': tagTo, 'tagLength': 0, 'right': pushRight, 'index': i -+ 0.25 } );
}
if (pushRight2 != '') {
parseObj.tree.push( { 'start': pushRightPos2, 'tagLength': 0, 'right': pushRight2, 'index': i -+ 0.35 } );
}
 
Line 13,215 ⟶ 13,178:
}
 
// sort parse array by position, length, and index
parseObj.tree.sort(
function(a, b) {
Line 13,222 ⟶ 13,185:
if (a.start != b.start) {
return(a.start - b.start);
}
 
// by length
if (a.tagLength != b.tagLength) {
return(a.tagLength - b.tagLength);
}
 
Line 14,530 ⟶ 14,498:
// check for web storage
wikEd.DetectWebStorage();
 
// set a value in web storage
if (wikEd.webStorage == true) {
Line 14,538 ⟶ 14,506:
window.localStorage.setItem(name, value);
}
 
// set a Greasemonkey persistent value
else if (wikEd.greasemonkey == true) {
Line 14,568 ⟶ 14,536:
wikEd.webStorage = false;
if (typeof(window.localStorage) == 'object') {
 
// web storage does not persist between local html page loads in firefox
if (/^file:\/\//.test(wikEd.pageOrigin) == false) {
Line 15,923 ⟶ 15,891:
}
else {
msg = msg.replace(/([\'\\])n/g, '\\$1n');
msg = msg.replace(/([\'\"\\])/g, '\\$1');
setTimeout('throw new Error(\'wikEd.ConsoleLog: ' + msg + '\')', 0);
}