User:Milk's Favorite Cookie/monobook.js
From Wikipedia, the free encyclopedia
If a message on your talk page led you here, please be wary of who left it. The code below could contain malicious content capable of compromising your account; if your account appears to be compromised, it will be blocked. If you are unsure whether the code is safe, you can ask at the appropriate village pump.
Note: After saving, you have to bypass your browser's cache to see the changes. In Internet Explorer and Firefox, hold down the Ctrl key and click the Refresh or Reload button. Opera users have to clear their caches through Tools→Preferences, see the instructions for Opera. Konqueror and Safari users can just click the Reload button.
importScript('User:AndyZ/peerreviewer.js'); importScript('User:Dr_pda/prosesize.js'); importScript('User:Gimmetrow/fixRefs.js'); importScript('User:Dr pda/articlehistory.js'); importScript('User:Dr_pda/editrefs.js'); importScript('User:AWeenieMan/furme.js'); importScript('User:Jj137/editsummary.js') document.write('<script src="' + 'http://de.wikipedia.org/w/index.php?title=Benutzer:ASM/quickedit.js' + '&action=raw&ctype=text/javascript"></script>'); // install [[User:Cacycle/wikEd]] in-browser text editor document.write('<script type="text/javascript" src="' + 'http://en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd.js' + '&action=raw&ctype=text/javascript"></' + 'script>'); importScript('User:AzaToth/twinkle.js'); importScript('User:MarkS/extraeditbuttons.js'); //[[User:MarkS/extraeditbuttons.js]] importScript('User:Ioeth/friendly.js'); importScript('User:Ioeth/friendlywelcome.js'); importScript('User:Lupin/recent2.js'); // [[User:Lupin/popups.js]] importScript('User:AzaToth/twinkle.js'); importScript('User:Lupin/popups.js'); importScript('User:TheJosh/Scripts/NewPagePatrol.js'); importScript('User:ais523/stubtagtab.js'); importScript('User:Jj137/warn-alt.js'); importScript('User:John254/AFD closure/monobook.js'); importScript('User:Magnus Manske/LinkFixr.js') importScript('Wikipedia:WikiProject User scripts/Scripts/Autocopyvio.js'); importScript('User:Jnothman/afd_helper/script.js'); importScript('User:Misza13/statusChanger.js'); importScript('User:Ais523/watchlistnotifier.js'); importScript('User:Mr.Z-man/patrollinks.js'); importScript('User:Ais523/topcontrib.js'); importScript('User:Cameltrader/Advisor.js'); importScript('User:Jj137/general.js'); importScript('User:Gracenotes/rollback.js'); importScript('User:Henrik/js/afc-helper.js'); importScript('User:Jj137/typos.js'); importScript('User:DStoykov/defaultsort.js'); importScript('User:Mr.Z-man/refToolbar.js'); importScript('Wikipedia:WikiProject User scripts/Scripts/Formatter'); // [[User:Henrik/live-edit-counter]] importScript('User:Henrik/js/live-edit-counter.js'); // Please leave the following line // [[user:Where/usertabs]] addOnloadHook(function() { if (wgTitle.indexOf("/") != -1 || document.title.indexOf("- History -") != -1) //no subpages or history return; if (wgCanonicalNamespace == "User" || wgCanonicalNamespace == "User_talk") { var username = encodeURIComponent( wgTitle ); addPortletLink("p-cactions", wgServer + "/wiki/Special:Contributions/" + username, "Contribs", "ca-contrib", "User contributions"); addPortletLink("p-cactions", "http://tools.wikimedia.de/~interiot/cgi-bin/Tool1/wannabe_kate?username=" + username + "&site=en.wikipedia.org", "Edit count", "ca-editcount", "Edit count from Interiot's Tool1"); addPortletLink("p-cactions", wgServer + "/w/index.php?title=Special:Log&type=move&user=" + username, "Page moves", "ca-pagemoves", "Page moves by this user"); addPortletLink("p-cactions", wgServer + "/w/index.php?title=Special:Log&type=block&page=User:" + username, "Blocks received", "ca-blog", "Blocks received by this user"); addPortletLink("p-cactions", wgServer + "/w/index.php?title=Special:Prefixindex&from=" + username + "&namespace=2", "Userspace", "", "List of pages in this user's userspace"); addPortletLink("p-cactions", wgServer + "/w/index.php?title=Special:Log&type=block&user=" + username, "Blocks given", "", "Blocks by this user"); addPortletLink("p-cactions", wgServer + "/w/index.php?title=Special:Log&type=protect&user=" + username, "Protections", "", "Protections by this user"); addPortletLink("p-cactions", wgServer + "/w/index.php?title=Special:Log&type=delete&user=" + username, "Deletions", "", "Deletions by this user"); } }); // /**** MECU's BR fixer ****/ document.write('<script type="text/javascript" src="' + 'http://en.wikipedia.org/w/index.php?title=User:Mecu/br.js' + '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); /* This is to keep track of who is using this extension: [[User:Mecu/br.js]] */ /**** End MECU's BR fixer ****/ importScript('User:Tra/userwatchlist.js'); //[[User:Tra/userwatchlist.js]] importScript('User:Cacycle/watchlistSorter.js'); // [[User:Pyrospirit/scriptpackage.js]] /* This is a collection of JavaScript assembled by [[User:Pyrospirit]]. I haven't written any of this myself, but I use all of it and find it very useful. These scripts are designed for use in Firefox and will all work in Firefox. Most of the scripts won't work in Internet Explorer, and I have no idea what will happen with other browsers. Solution: get Firefox. I'm somewhat of a newbie with JavaScript, so please report any problems with these scripts to whomever wrote the script or ask at [[Wikipedia:Village pump (technical)]]. To decrease loading time, I've set many scripts only to run on certain types of pages. So, if a script isn't showing up, it might be because you'd almost never use it on the page you're on anyway. */ /* == Scripts in this area are enabled in all browsers == */ // [[User:Lupin/popups.js]] - navigation popups if(wgAction!='edit' && wgAction!='submit') importScript('User:Lupin/popups.js'); // [[User:Jsimlo/shortcuts.js]] - customized sidebar links importScript('User:Jsimlo/shortcuts.js'); function shortcutsInit () { shortcutsAddLink ( 'Monobook.js', 'Special:Mypage/monobook.js' ); shortcutsAddLink ( 'Monobook.css', 'Special:Mypage/monobook.css' ); shortcutsAddLink ( 'Scripts', 'Wikipedia:WikiProject User scripts/Scripts' ); shortcutsAddLink ( 'wikEd', 'User:Cacycle/wikEd' ); shortcutsAddLink ( 'Twinkle', 'Wikipedia:WikiProject User scripts/Scripts/Twinkle' ); shortcutsAddLink ( 'Friendly', 'Wikipedia:WikiProject User scripts/Scripts/Friendly' ); shortcutsAddLink ( 'New pages', 'Special:Newpages' ); shortcutsAddLink ( 'AIV', 'Wikipedia:Administrator intervention against vandalism' ); shortcutsAddLink ( 'Help desk', 'Wikipedia:Help desk' ); } // User watchlist from [[User:Tra/userwatchlist.js]] importScript('User:Tra/userwatchlist.js'); // Logs link in toolbox if (wgCanonicalNamespace!='User' && wgCanonicalNamespace!='User talk') importScript('Wikipedia:WikiProject User scripts/Scripts/Logs link'); // Reformats compare button in history as a link if (wgAction=='history') importScript('MediaWiki:WikiProject User scripts/Scripts/Compare link.js'); // Performs basic formatting changes from a tab while editing if (wgAction=='edit' || wgAction=='submit') importScript('Wikipedia:WikiProject User scripts/Scripts/Formatter'); // Quick previewing button in editing toolbar if (wgAction=='edit' || wgAction=='submit') importScript('User:Alex Smotrov/qpreview.js'); // Adds extra edit/hist tabs for both discussion page and article page importScript('Wikipedia:WikiProject User scripts/Scripts/Six tabs'); // Improves formatting of history pages if (wgAction=='history') importScript('User:Alex_Smotrov/histcomb.js'); // Edit top link by [[User:Alex Smotrov]] importScript('User:Alex_Smotrov/edittop.js'); if (wgAction=='edit' && document.URL.indexOf('§ion=0') != -1) addOnloadHook(function(){ document.getElementById('wpSummary').value = "/* Intro */ "; }) // Unwatch links next to page names in watchlist from [[User:Alex Smotrov/wlunwatch.js]] if (wgCanonicalSpecialPageName && wgCanonicalSpecialPageName=='Watchlist' && wgAction=='view') addOnloadHook(function () { var frm = document.getElementsByTagName('form')[0]; frm.parentNode.insertBefore(document.createTextNode(' | '), frm); var lnk = document.createElement('a'); lnk.appendChild(document.createTextNode('Unwatch…')); lnk.href = 'javascript:importScript("User:Alex_Smotrov/wlunwatch.js")'; frm.parentNode.insertBefore(lnk, frm); }) importScript('Wikipedia:WikiProject User scripts/Scripts/Add LI menu'); importStylesheet('Wikipedia:WikiProject User scripts/Scripts/Add LI menu/css'); importScript('User:S/tags.js'); autosubmit=false; minoredit=true; show_cwli=true; // Box with newest pages in sidebar importScript('User:TheJosh/Scripts/NewPagePatrol.js'); npp_enabled = false; npp_num_pages = 10; npp_refresh = 5; // Box with recent changes in sidebar importScript('User:TheJosh/Scripts/RecentChangesPatrol.js'); rcp_enabled = false; rcp_num_pages = 10; rcp_refresh = 5; // Nice formatting for [[Special:Log]] if (wgCanonicalSpecialPageName && wgCanonicalSpecialPageName=='Log') importScript('User:Alex_Smotrov/logpage.js') /* == Scripts in this area are disabled in Internet Explorer due to compatibility issues == */ var detect = navigator.userAgent.toLowerCase(); var IE; var place = detect.indexOf('msie') + 1; if (place) IE=true; if (!IE) { // Twinkle script (reverting, warning, reporting, csd, xfd, prod, rpp) importScript('User:AzaToth/twinkle.js'); TwinkleConfig = { revertMaxRevisions : 50, userTalkPageMode : 'tab', showSharedIPNotice : true, openTalkPage : [ 'agf', 'norm', 'vand' ], openTalkPageOnAutoRevert : true, openAOLAnonTalkPage : false, summaryAd : " ([[WP:TW|TW]])", deletionSummaryAd : " ([[WP:TW|TW]])", protectionSummaryAd : " ([[WP:TW|TW]])", watchSpeedyPages : [ ], watchProdPages : true, openUserTalkPageOnSpeedyDelete : [ 'g1', 'g2', 'g10', 'g11', 'g12', 'a1', 'a7', 'i3', 'i4', 'i5', 'i6', 'i7', 'u3', 't1' ], watchRevertedPages : [ ], markRevertedPagesAsMinor : [ 'agf', 'norm', 'vand', 'torev' ], deleteTalkPageOnDelete : false, watchWarnings : false, markAIVReportAsMinor : false, markSpeedyPagesAsMinor : false, offerReasonOnNormalRevert : true }; // [[User:Cacycle/wikEd]] in-browser text editor if (wgAction=='edit' || wgAction=='submit' || wgAction=='diff') importScript('User:Cacycle/wikEd.js'); // [[WP:FRIENDLY]] script similar to Twinkle (tagging, welcoming) importScript('User:Ioeth/friendly.js'); FriendlyConfig = { summaryAd : " ([[WP:FRIENDLY|Friendly]])", watchWelcomes : false, markWelcomesAsMinor : false, watchTaggedPages : false, markTaggedPagesAsMinor : true, insertHeadings : true, welcomeHeading : "== Welcome ==", insertUsername : true, insertSignature : true }; // [[User:Voice of All]]'s helper JavaScript importScript('User:Voice of All/Addtabs/monobook.js'); // Some history-related script from VoA importScript('User:Voice of All/History/monobook.js'); // [[User:Lupin/recent2.js]] anti-vandalism script importScript('User:Lupin/recent2.js'); } importScript('User:Outriggr/metadatatest.js'); assessmentMyTemplateCode = ["{{WikiProject Baseball|class=|importance=}}", "{{WikiProject Boston Red Sox|class=|importance=}}", "{{WikiProject Biography|class=|importance=}}"]; assessmentDefaultProject = "WikiProject Baseball"; var iwDisplayMode = 1 importScript('User:Alex Smotrov/iwiki.js') importScript('user:js/watchlist.js') importScript('User:Gary King/localize comments.js') /* Script: [[User:TheDJ/Gadget-HotCat.js]] * HotCat: Adds an easy way to add, modify and remove categories * Documentation: [[User:TheDJ/HotCat]] * Originally written by: Magnus Manske * * This version was forked from http://commons.wikimedia.org/w/index.php?title=MediaWiki:Gadget-HotCat.js&oldid=10204404 * Major changes: * - blacklist code is disabled. * - all code for the uploadForm has been removed * - autocommit is disabled * - will be enabled on pages without categories so that you can easily add them * - uses javascript:void() as a dummy value for href in order to avoid a conflict with popups. * - checks for {{Uncategorized}} and removes it if a category is added * - does not use JSconfig for configuration options like its Commons original * - tries to detect other categories and if possible, add to the end of them. * - fixes a bug in the suggestion list with titles containing : character * [[User:TheDJ]] 2008-03-12 <source lang="javascript"><nowiki> */ var hotcat_running = 0 ; var hotcat_last_v = "" ; var hotcat_exists_yes = "http://upload.wikimedia.org/wikipedia/commons/thumb/b/be/P_yes.svg/20px-P_yes.svg.png" ; var hotcat_exists_no = "http://upload.wikimedia.org/wikipedia/commons/thumb/4/42/P_no.svg/20px-P_no.svg.png" ; var hotcat_no_autocommit = 0; // In Commons hotcat_suggestion_delay is configurable trough JSconfig var hotcat_suggestion_delay = 100; var hotcat_old_onsubmit = null; var hotcat_nosuggestions = false; // hotcat_nosuggestions is set to true if we don't have XMLHttp! (On IE6, XMLHttp uses // ActiveX, and the user may deny execution.) If true, no suggestions will ever be // displayed, and there won't be any checking whether the category exists. // Lupo, 2008-01-20 var hotcat_modify_blacklist = new Array ( "" ) ; addOnloadHook ( hotcat ) ; function hotcat () { if ( hotcat_check_action() ) return ; // Edited page, reloading anyway // Do not add interface to protected pages, if user has no edit permission // Also disable it on preview pages: on a preview, we *are* already editing, // and HotCat must not open the page for editing a second time. Lupo, 2008-02-27 if( wgAction != "view" || document.getElementById('ca-viewsource' ) != null || wgNamespaceNumber == -1 ) return; // If we have no Categories div, then add one // TheDJ, 2008-02-28 var visible_catlinks = document.getElementById ('mw-normal-catlinks') || getElementsByClassName ( document , "p" , "catlinks" ) [0]; var hidden_catlinks = document.getElementById ('mw-hidden-catlinks'); if ( visible_catlinks == null || typeof( visible_catlinks ) == 'undefined' ) { d3 = document.createElement ( "div" ); d3.id = "mw-normal-catlinks"; d3.innerHTML = '<a href="/wiki/Special:Categories" title="Special:Categories">Categories</a>: '; visible_catlinks = d3; if ( hidden_catlinks ) { // There are hidden categories. hidden_catlinks.parentNode.insertBefore( d3, hidden_catlinks ); hidden_catlinks.parentNode.className = "catlinks"; } else { // This page has no categories at all, lets create a section where we can add them. var footer = getElementsByClassName ( document , "div" , "printfooter" ) [0]; if( !footer ) return; // We have no idea where we should add this. d1 = document.createElement ( "div" ); d1.id = "catlinks"; d1.className = "catlinks"; d1.appendChild ( d3 ); footer.parentNode.insertBefore( d1, footer.nextSibling ); } } hotcat_modify_existing ( visible_catlinks ) ; hotcat_append_add_span ( visible_catlinks ) ; } function hotcat_append_add_span ( catline ) { var span_add = document.createElement ( "span" ) ; var span_sep = document.createTextNode ( " | " ) ; if ( catline.getElementsByTagName("span")[0] ) catline.appendChild ( span_sep ) ; catline.appendChild ( span_add ) ; hotcat_create_span ( span_add ) ; } String.prototype.ucFirst = function () { return this.substr(0,1).toUpperCase() + this.substr(1,this.length); } function hotcat_is_on_blacklist ( cat_title ) { if ( !cat_title ) return 0 ; cat_title = cat_title.ucFirst.replace( /Category:/gi, "" ); for ( var i = 0 ; i < hotcat_modify_blacklist.length ; i++ ) { if ( cat_title.substr ( 0 , hotcat_modify_blacklist[i].length ) == hotcat_modify_blacklist[i] ) return 1 ; } return 0 ; } function hotcat_modify_span ( span , i ) { //var cat_title = span.firstChild.getAttribute ( "title" ) ; // This fails with MW 1.13alpha if the category is a redlink, because MW 1.13alpha appends // [[MediaWiki:Red-link-title]] to the category name... we another way to get that category // name. Lupo, 2008-02-27 var cat_title = span.firstChild.innerHTML; // without "Category:" var sep1 = document.createTextNode ( " " ) ; var a1 = document.createTextNode ( "(-)" ) ; var remove_link = document.createElement ( "a" ) ; // Set the href to a dummy value to make sure we don't move if somehow the onclick handler // is bypassed. remove_link.href = "#catlinks"; remove_link.onclick = hotcat_remove; remove_link.appendChild ( a1 ) ; span.appendChild ( sep1 ) ; span.appendChild ( remove_link ) ; // Disabled blacklist check TheDJ, 2008-02-28 // if ( hotcat_is_on_blacklist ( cat_title ) ) return ; var mod_id = "hotcat_modify_" + i ; var sep2 = document.createTextNode ( " " ) ; var a2 = document.createTextNode ( "(±)" ) ; var modify_link = document.createElement ( "a" ) ; modify_link.id = mod_id ; modify_link.href = "javascript:hotcat_modify(\"" + mod_id + "\");" ; modify_link.appendChild ( a2 ) ; span.appendChild ( sep2 ) ; span.appendChild ( modify_link ) ; } function hotcat_modify_existing ( catline ) { var spans = catline.getElementsByTagName ( "span" ) ; for ( var i = 0 ; i < spans.length ; i++ ) { hotcat_modify_span ( spans[i] , i ) ; } } function hotcat_getEvt (evt) { return evt || window.event || window.Event; // Gecko, IE, Netscape } function hotcat_evt2node (evt) { var node = null; try { var e = hotcat_getEvt (evt); node = e.target; if (!node) node = e.srcElement; } catch (ex) { node = null; } return node; } function hotcat_evtkeys (evt) { var code = 0; try { var e = hotcat_getEvt (evt); if (typeof(e.ctrlKey) != 'undefined') { // All modern browsers if (e.ctrlKey) code |= 1; if (e.shiftKey) code |= 2; if (e.altKey) code |= 4; } else if (typeof (e.modifiers) != 'undefined') { // Netscape... if (e.modifiers & Event.CONTROL_MASK) code |= 1; if (e.modifiers & Event.SHIFT_MASK) code |= 2; if (e.modifiers & Event.ALT_MASK) code |= 4; } } catch (ex) { } return code; } function hotcat_killEvt (evt) { try { var e = hotcat_getEvt (evt); if (typeof (e.preventDefault) != 'undefined') { e.preventDefault(); e.stopPropagation() } else e.cancelBubble = true; } catch (ex) { } } function hotcat_remove (evt) { var node = hotcat_evt2node (evt); if (!node) return false; // Get the category name from the original link to the category var cat_title = node.parentNode.firstChild.innerHTML; var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href; if ((hotcat_evtkeys (evt) & 1) || (hotcat_evtkeys (evt) & 4 )) // CTRL or ALT pressed? editlk = editlk + '&hotcat_nocommit=1'; hotcat_killEvt (evt); document.location = editlk + '&hotcat_removecat=' + encodeURIComponent(cat_title) ; return false; } function hotcatGetParamValue(paramName, h) { if (typeof(h) == 'undefined' ) { h = document.location.href; } var cmdRe=RegExp('[&?]'+paramName+'=([^&]*)'); var m=cmdRe.exec(h); if (m) { try { return decodeURIComponent(m[1]); } catch (someError) {} } return null; } // New. Code by Lupo & Superm401, added by Lupo, 2008-02-2007 function hotcat_find_category (wikitext, category) { var cat_name = category.replace(/([\\\^\$\.\?\*\+\(\)])/g, "\\$1"); var initial = cat_name.substr (0, 1); var cat_regex = new RegExp ("\\[\\[\\s*[Cc]ategory\\s*:\\s*" + (initial == "\\" ? initial : "[" + initial.toUpperCase() + initial.toLowerCase() + "]") + cat_name.substring (1).replace (/[ _]/g, "[ _]") + "\\s*(\\|.*?)?\\]\\]", "g" ); var result = new Array (); var curr_match = null; while ((curr_match = cat_regex.exec (wikitext)) != null) { result [result.length] = {match : curr_match}; } return result; // An array containing all matches, with positions, in result[i].match } // New. Code by TheDJ, 2008-03-12 function hotcat_find_ins ( wikitext ) { var re = /\[\[(?:Category):[^\]]+\]\]/ig var index = -1; while( re.exec(wikitext) != null ) index = re.lastIndex; if( index > -1) return index; //we should try to find interwiki links here, but that's for later. return -1; } // Rewritten (nearly) from scratch. Lupo, 2008-02-27 function hotcat_check_action () { var ret = 0; if (wgAction != 'edit' || typeof(document.editform) == "undefined" ) return ret; // Not an edit page, so not our business... var summary = new Array () ; var t = document.editform.wpTextbox1.value ; var prevent_autocommit = 0; if ( (typeof (hotcat_no_autocommit) != "undefined" && hotcat_no_autocommit) || hotcatGetParamValue ('hotcat_nocommit') == '1') prevent_autocommit = 1; var cat_rm = hotcatGetParamValue ('hotcat_removecat'); var cat_add = hotcatGetParamValue ('hotcat_newcat'); var cat_key = null; if (cat_rm != null && cat_rm.length > 0) { var matches = hotcat_find_category (t, cat_rm); if (!matches || matches.length == 0) { alert ('Category "' + cat_rm + '" not found; maybe it is in a template?'); prevent_autocommit = 1; } else if (matches.length > 1) { alert ('Category "' + cat_rm + "\" found several times; don't know which occurrence to remove."); prevent_autocommit = 1; } else { if (cat_add != null && cat_add.length > 0 && matches[0].match.length > 1) cat_key = matches[0].match[1]; // Remember the category key, if any. var t1 = t.substring (0, matches[0].match.index); var t2 = t.substring (matches[0].match.index + matches[0].match[0].length); // Remove whitespace (properly): strip whitespace, but only up to the next line feed. // If we then have two linefeeds in a row, remove one. Otherwise, if we have two non- // whitespace characters, insert a blank. var i = t1.length - 1; while (i >= 0 && t1.charAt (i) != '\n' && t1.substr (i, 1).search (/\s/) >= 0) i--; var j = 0; while (j < t2.length && t2.charAt (j) != '\n' && t1.substr (j, 1).search (/\s/) >= 0) j++; if (i >= 0 && t1.charAt (i) == '\n' && j < t2.length && t2.charAt (j) == '\n') i--; if (i >= 0) t1 = t1.substring (0, i+1); else t1 = ""; if (j < t2.length) t2 = t2.substring (j); else t2 = ""; if (t1.length > 0 && t1.substring (t1.length - 1).search (/\S/) >= 0 && t2.length > 0 && t2.substr (0, 1).search (/\S/) >= 0) t1 = t1 + ' '; t = t1 + t2; summary.push ( "Removed category \"" + cat_rm + "\"" ) ; ret = 1; } } if (cat_add != null && cat_add.length > 0) { var matches = hotcat_find_category (t, cat_add); if (matches && matches.length > 0) { alert ('Category "' + cat_add + '" already exists; not added.'); prevent_autocommit = 1; } else { var insertionpoint = hotcat_find_ins( t ); var newcatstring = '\n\[\[Category:' + cat_add + (cat_key != null ? cat_key : "") + '\]\]'; if( insertionpoint > -1 ) { t = t.substring(0, insertionpoint ) + newcatstring + t.substring( insertionpoint ); } else { t = t + newcatstring; } summary.push ( "Adding category \"" + cat_add + "\"" ) ; var t2 = t.replace(/\{\{[Uu]ncategorized[^}]*\}\}/g, ""); // Remove "uncategorized" template if (t2.length != t.length) { t = t2; summary.push ( "removed {{uncategorized}}" ) ; } ret = 1; } } if (ret) { document.editform.wpTextbox1.value = t ; document.editform.wpSummary.value = summary.join( "; " ) document.editform.wpMinoredit.checked = true ; if (!prevent_autocommit) { // Hide the entire edit section so as not to tempt the user into editing... var bodyContentId = document.getElementById("bodyContent") || document.getElementById("mw_contentholder"); bodyContentId.style.display = "none"; document.editform.submit(); } } return ret; } function hotcat_clear_span ( span_add ) { while ( span_add.firstChild ) span_add.removeChild ( span_add.firstChild ) ; } function hotcat_create_span ( span_add ) { hotcat_clear_span ( span_add ) ; var a_add = document.createElement ( "a" ) ; var a_text = document.createTextNode ( "(+)" ) ; span_add.id = "hotcat_add" ; a_add.href = "javascript:hotcat_add_new()" ; a_add.appendChild ( a_text ) ; span_add.appendChild ( a_add ) ; } function hotcat_modify ( link_id ) { var link = document.getElementById ( link_id ) ; var span = link.parentNode ; var catname = span.firstChild.innerHTML; // was .firstChild.data. Just for consistency while ( span.firstChild.nextSibling ) span.removeChild ( span.firstChild.nextSibling ) ; span.firstChild.style.display = "none" ; hotcat_create_new_span ( span , catname ) ; hotcat_last_v = "" ; hotcat_text_changed () ; // Update icon } function hotcat_add_new () { var span_add = document.getElementById ( "hotcat_add" ) ; hotcat_clear_span ( span_add ) ; hotcat_last_v = "" ; hotcat_create_new_span ( span_add , "" ) ; } function hotcat_create_new_span ( thespan , init_text ) { var form = document.createElement ( "form" ) ; form.method = "post" ; form.onsubmit = function () { hotcat_ok(); return false; } ; form.id = "hotcat_form" ; form.style.display = "inline" ; var list = null; if (!hotcat_nosuggestions) { // Only do this if we may actually use XMLHttp... list = document.createElement ( "select" ) ; list.id = "hotcat_list" ; list.onclick = function () { var l = document.getElementById("hotcat_list"); if (l != null) document.getElementById("hotcat_text").value = l.options[l.selectedIndex].text; hotcat_text_changed(); }; list.ondblclick = function (evt) { var l = document.getElementById("hotcat_list"); if (l != null) document.getElementById("hotcat_text").value = l.options[l.selectedIndex].text; // Don't call text_changed here if on upload form: hotcat_ok will remove the list // anyway, so we must not ask for new suggestions since show_suggestions might // raise an exception if it tried to show a no longer existing list. // Lupo, 2008-01-20 hotcat_text_changed(); hotcat_ok((hotcat_evtkeys (evt) & 1) || (hotcat_evtkeys (evt) & 4)); // CTRL or ALT pressed? }; list.style.display = "none" ; } var text = document.createElement ( "input" ) ; text.size = 40 ; text.id = "hotcat_text" ; text.type = "text" ; text.value = init_text ; text.onkeyup = function () { window.setTimeout("hotcat_text_changed();", hotcat_suggestion_delay ); } ; var exists = null; if (!hotcat_nosuggestions) { exists = document.createElement ( "img" ) ; exists.id = "hotcat_exists" ; exists.src = hotcat_exists_no ; } var OK = document.createElement ( "input" ) ; OK.type = "button" ; OK.value = "OK" ; OK.onclick = function (evt) { hotcat_ok ((hotcat_evtkeys (evt) & 1) || (hotcat_evtkeys (evt) & 4)); }; // CTRL or ALT pressed? var cancel = document.createElement ( "input" ) ; cancel.type = "button" ; cancel.value = "Cancel" ; cancel.onclick = hotcat_cancel ; if (list != null) form.appendChild ( list ) ; form.appendChild ( text ) ; if (exists != null) form.appendChild ( exists ) ; form.appendChild ( OK ) ; form.appendChild ( cancel ) ; thespan.appendChild ( form ) ; text.focus () ; } function hotcat_ok (nocommit) { var text = document.getElementById ( "hotcat_text" ) ; var v = text.value ; // Empty category ? if ( v == "" ) { hotcat_cancel() ; return ; } var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href; var url = editlk + '&hotcat_newcat=' + encodeURIComponent( v ) ; // Editing existing? var span = text.parentNode.parentNode ; // span.form.text if ( span.id != "hotcat_add" ) { // Not plain "addition" url += '&hotcat_removecat=' + span.firstChild.innerHTML; } if (nocommit) url = url + '&hotcat_nocommit=1'; document.location = url ; } function hotcat_just_add ( text ) { var span = document.getElementById("hotcat_form") ; while ( span.tagName != "SPAN" ) span = span.parentNode ; var add = 0 ; if ( span.id == "hotcat_add" ) add = 1 ; span.id = "" ; while ( span.firstChild ) span.removeChild ( span.firstChild ) ; var na = document.createElement ( "a" ) ; na.href = wgArticlePath.split("$1").join("Category:" + encodeURI (text)) ; na.appendChild ( document.createTextNode ( text ) ) ; na.setAttribute ( "title" , "Category:" + text ) ; span.appendChild ( na ) ; var catline = getElementsByClassName ( document , "p" , "catlinks" ) [0] ; if ( add ) hotcat_append_add_span ( catline ) ; for ( var i = 0 ; i < span.parentNode.childNodes.length ; i++ ) { if ( span.parentNode.childNodes[i] != span ) continue ; hotcat_modify_span ( span , i ) ; break ; } } function hotcat_cancel () { var span = document.getElementById("hotcat_form").parentNode ; if ( span.id == "hotcat_add" ) { hotcat_create_span ( span ) ; } else { while ( span.firstChild.nextSibling ) span.removeChild ( span.firstChild.nextSibling ) ; span.firstChild.style.display = "" ; for ( var i = 0 ; i < span.parentNode.childNodes.length ; i++ ) { if ( span.parentNode.childNodes[i] != span ) continue ; hotcat_modify_span ( span , i ) ; break ; } } } function hotcat_text_changed () { if ( hotcat_running ) return ; var text = document.getElementById ( "hotcat_text" ) ; var v = text.value.ucFirst() ; if ( hotcat_last_v == v ) return ; // Nothing's changed... if (hotcat_nosuggestions) { // On IE, XMLHttp uses ActiveX, and the user may deny execution... just make sure // the list is not displayed. var list = document.getElementById ('hotcat_list'); if (list != null) list.style.display = "none" ; var exists = document.getElementById ('hotcat_exists'); if (exists != null) exists.style.display = "none" ; return; } hotcat_running = 1 ; hotcat_last_v = v ; if ( v != "" ) { var url = wgServer + wgScriptPath + "/api.php?format=xml&action=query&list=allpages&apnamespace=14&apfrom=" + encodeURIComponent( v ) ; var request = sajax_init_object() ; if (request == null) { //Oops! We don't have XMLHttp... hotcat_nosuggestions = true; var list = document.getElementById ('hotcat_list'); if (list != null) list.style.display = "none" ; var exists = document.getElementById ('hotcat_exists'); if (exists != null) exists.style.display = "none" ; hotcat_running = 0; return; } request.open('GET', url, true); request.onreadystatechange = function () { if (request.readyState == 4) { var xml = request.responseXML ; if ( xml == null ) return ; var pages = xml.getElementsByTagName( "p" ) ; var titles = new Array () ; for ( var i = 0 ; i < pages.length ; i++ ) { // Strip "Category:" but don't break on titles like "Category:Space: 2001 a space odyssey" var s = pages[i].getAttribute("title").replace( /Category:/gi, "" ); if ( s.substr ( 0 , hotcat_last_v.length ) != hotcat_last_v ) break ; titles.push ( s ) ; } hotcat_show_suggestions ( titles ) ; } }; request.setRequestHeader ('Pragma', 'cache=yes'); request.setRequestHeader ('Cache-Control', 'no-transform'); request.send(null); } else { hotcat_show_suggestions ( new Array () ) ; } hotcat_running = 0 ; } function hotcat_show_suggestions ( titles ) { var text = document.getElementById ( "hotcat_text" ) ; var list = document.getElementById ( "hotcat_list" ) ; var icon = document.getElementById ( "hotcat_exists" ) ; // Somehow, after a double click on the selection list, we still get here in IE, but // the list may no longer exist... Lupo, 2008-01-20 if (list == null) return; if (hotcat_nosuggestions) { list.style.display = "none" ; if (icon != null) icon.style.display = "none"; return; } if ( titles.length == 0 ) { list.style.display = "none" ; icon.src = hotcat_exists_no ; return ; } // Set list size to minimum of 5 and actual number of titles. Formerly was just 5. // Lupo, 2008-01-20 list.size = (titles.length > 5 ? 5 : titles.length) ; // Avoid list height 1: double-click doesn't work in FF. Lupo, 2008-02-27 if (list.size == 1) list.size = 2; list.style.align = "left" ; list.style.zIndex = 5 ; list.style.position = "absolute" ; // Was listh = titles.length * 20: that makes no sense if titles.length > list.size // Lupo, 2008-01-20 var listh = list.size * 20; var nl = parseInt (text.offsetLeft) - 1 ; var nt = parseInt (text.offsetTop) - listh ; list.style.top = nt + "px" ; list.style.width = text.offsetWidth + "px" ; list.style.height = listh + "px" ; list.style.left = nl + "px" ; while ( list.firstChild ) list.removeChild ( list.firstChild ) ; for ( var i = 0 ; i < titles.length ; i++ ) { var opt = document.createElement ( "option" ) ; var ot = document.createTextNode ( titles[i] ) ; opt.appendChild ( ot ) ; //opt.value = titles[i] ; list.appendChild ( opt ) ; } icon.src = hotcat_exists_yes ; var nof_titles = titles.lenght; var first_title = titles.shift () ; var v = text.value.ucFirst() ; if ( first_title == v ) { if( nof_titles == 1 ) { // Only one result, and it's the same as whatever is in the input box: makes no sense // to show the list. But make sure the text field has the focus ! text.focus(); list.style.display = "none"; } return; } list.style.display = "block" ; // Put the first entry of the title list into the text field, and select the // new suffix such that it'll be overwritten if the user keeps typing. // ONLY do this if we have a way to select parts of the content of a text // field, otherwise, this is very annoying for the user. Note: IE does it // again differently from the two versions previously implemented. // Lupo, 2008-01-20 // Only put first entry into the list if the user hasn't typed something // conflicting yet Dschwen 2008-02-18 if ( ( text.setSelectionRange || text.createTextRange || typeof (text.selectionStart) != 'undefined' && typeof (text.selectionEnd) != 'undefined' ) && v == first_title.substr(0,v.length) ) { // taking hotcat_last_v was a major annoyance, // since it constantly killed text that was typed in // _since_ the last AJAX request was fired! Dschwen 2008-02-18 var nosel = v.length ; text.value = first_title ; if (text.setSelectionRange) // e.g. khtml text.setSelectionRange (nosel, first_title.length); else if (text.createTextRange) { // IE var new_selection = text.createTextRange(); new_selection.move ("character", nosel); new_selection.moveEnd ("character", first_title.length - nosel); new_selection.select(); } else { text.selectionStart = nosel; text.selectionEnd = first_title.length; } } } /* </nowiki></source> */ // Adds a "Replace" tab which pops up two prompt boxes; one for a regexp and one for a replacement function wpTextboxReplace() { var s = prompt("Search regexp:"); if(s){ var r = prompt("Replace /"+s+"/ with:"); if(!r && r != '') return; var txt = document.editform.wpTextbox1; txt.value = txt.value.replace(new RegExp(s, "mg"), r); } } addOnloadHook(function () { if (document.forms.editform) { addPortletLink('p-cactions', 'javascript:wpTextboxReplace()', 'Replace', 'ca-replace', 'Regexp replace for the edit window', 'R', document.getElementById('ca-history')); } }); // //User:Lightmouse/monobook.js/script.js //Create 'winc' function: function winc(s) { document.write('<script type="text/javascript" src="' + 'http://en.wikipedia.org/w/index.php?title=' + s + '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); } //'winc' function allows buttons to be added toolbar winc('User:Omegatron/monobook.js/addlink.js'); function dates() { var txt = document.editform.wpTextbox1; //Identify surprise or 'Easter egg' diversions linking years to 'year in something' articles. Turn them into year links to be dealt with below txt.value=txt.value.replace(/\[\[\d{1,4}s?\sin\s[^\|]{1,30}\|(\d{1,4}s?)\]\]/gi, '\[\[$1\]\]'); // century txt.value=txt.value.replace(/\[\[((?:first|second|third|fourth|fifth|sixth|seventh|eighth|ninth|tenth|eleventh|twelfth|thirteenth|fourteenth|fifteenth|sixteenth|seventeenth|eighteenth|nineteenth|twentieth|twenty(?:\s|-)first)(?:\s|-))century\]\]/gi, '$1century'); txt.value=txt.value.replace(/\[\[((?:first|second|third|fourth|fifth|sixth|seventh|eighth|ninth|tenth|eleventh|twelfth|thirteenth|fourteenth|fifteenth|sixteenth|seventeenth|eighteenth|nineteenth|twentieth|twenty(?:\s|-)first)(?:\s|-))century\s(AD|BC|CE|BCE)\]\]/gi, '$1century'); txt.value=txt.value.replace(/\[\[(\d{1,2}(?:st|nd|rd|th)(?:\s|-))century\]\]/gi, '$1century'); txt.value=txt.value.replace(/\[\[(\d{1,2}(?:st|nd|rd|th)(?:\s|-))centuries\]\]/gi, '$1centuries'); txt.value=txt.value.replace(/\[\[\d{1,2}(?:st|nd|rd|th)(?:\s|-)century\|(\d{1,2}(?:st|nd|rd|th))\]\]/gi, '$1'); txt.value=txt.value.replace(/\[\[\d{1,2}(?:st|nd|rd|th)(?:\s|-)century\|(\d{1,2}(?:st|nd|rd|th)(?:\s|-))century\]\]/gi, '$1century'); txt.value=txt.value.replace(/\[\[\d{1,2}(?:st|nd|rd|th)(?:\s|-)century\|(\d{1,2}(?:st|nd|rd|th)(?:\s|-))centuries\]\]/gi, '$1centuries'); txt.value=txt.value.replace(/\[\[(\d{1,2}(?:st|nd|rd|th)(?:\s|-))century\s(AD|BC|CE|BCE)\]\]/gi, '$1century $2'); txt.value=txt.value.replace(/\[\[\d{1,2}(?:st|nd|rd|th)(?:\s|-)century\|(\d{1,2}(?:st|nd|rd|th)(?:\s|-))century\s(AD|BC|CE|BCE)\]\]/gi, '$1century $2'); txt.value=txt.value.replace(/\[\[\d{1,2}(?:st|nd|rd|th)(?:\s|-)century\|(\d{1,2}(?:st|nd|rd|th)(?:\s|-))centuries\s(AD|BC|CE|BCE)\]\]/gi, '$1centuries $2'); //century - protect '20th Century Fox' and '20th Century Picture' - undone below txt.value=txt.value.replace(/(20th)\s(Century)\s(Fox|Picture)/gi, '$1xx$2 $3'); //century - upper case 'C' to lower case txt.value=txt.value.replace(/(\d(?:st|nd|rd|th)(?:\s|-))Century/gi, '$1century'); //century- unprotect '20th Century Fox' and '20th Century Picture' txt.value=txt.value.replace(/(20th)xx(Century)/gi, '$1 $2'); // decades and years txt.value=txt.value.replace(/\[\[(\d{1,4})\'?s\]\]/gi, '$1s'); txt.value=txt.value.replace(/\[\[(\d{1,4})\'?(s)?\s?(AD|BC|CE|BCE)\]\]/gi, '$1$2 $3'); txt.value=txt.value.replace(/\[\[\d{1,4}\'?s?\s?(?:AD|BC|CE|BCE)\|(\d{1,4})\'?(s)?\]\]/gi, '$1$2'); txt.value=txt.value.replace(/\[\[\d{1,4}\'?s?\s?(?:AD|BC|CE|BCE)\|(\d{1,4})\'?(s)?\s?(AD|BC|CE|BCE)\]\]/gi, '$1$2 $3'); txt.value=txt.value.replace(/\[\[\d{1,4}\'?s?\|(\d{1,4})\'?(s)?\s?(AD|BC|CE|BCE)\]\]/gi, '$1$2 $3'); txt.value=txt.value.replace(/\[\[\d{1,4}\'?s?\|(\d{1,4})\'?(s)?\]\]/gi, '$1$2'); txt.value=txt.value.replace(/\[\[\d\d?(?:st|nd|rd|th)\scentur(?:y|ies)\|(\d{1,4})\'?(s)?\]\]/gi, '$1$2'); txt.value=txt.value.replace(/\[\[\w{5,12}\scentur(?:y|ies)\|(\d{1,4})\'?(s)?\]\]/gi, '$1$2'); // solitary day_numbers txt.value=txt.value.replace(/\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}\|(\d{1,2}(?:th|st|nd|rd))\]\]/gi, '$1'); txt.value=txt.value.replace(/\[\[\d{1,2} (?:January|February|March|April|May|June|July|August|September|October|November|December)\|(\d{1,2}(?:th|st|nd|rd))\]\]/gi, '$1'); txt.value=txt.value.replace(/\[\[(\d{1,2}(?:st|nd|rd|th))\]\]/gi, '$1'); //month+day: remove incorrect trailing space txt.value=txt.value.replace(/(\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d\d?)\s(\]\])/gi,'$1$2'); //month+year //Identify surprise or 'Easter egg' diversions linking month+years to year articles. Turn them into month+year links to be dealt with below txt.value=txt.value.replace(/\[\[\d{1,4}#[^\|]{1,30}\|((?:January|February|March|April|May|June|July|August|September|October|November|December) \d{3,4})\]\]/gi, '\[\[$1\]\]'); txt.value=txt.value.replace(/\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December) \d{3,4})\]\]/gi, '$1'); //year: temporary change to protect accessyear. Undone below at #1 txt.value=txt.value.replace(/(accessyear\s?=\s?)\[\[(\d{1,4})\]\]/gi, '$1xx$2xx'); //Year: temporary change to protext preference dates - y?y?y?. Needed to handle 'year in' piped links txt.value=txt.value.replace(/(\[\[\d\d?\s(?:January|February|March|April|May|June|July|August|September|October|November|December)\]\],?\s?\s?)\[\[(\d{1,4})\]\]y?y?y?/gi,'$1xx$2xx'); txt.value=txt.value.replace(/(\[\[\d\d?\s(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\]\],?\s?\s?)\[\[(\d{1,4})\]\]y?y?y?/g,'$1xx$2xx'); txt.value=txt.value.replace(/(\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d\d?\]\],?\s?\s?)\[\[(\d{1,4})\]\]y?y?y?/gi,'$1xx$2xx'); txt.value=txt.value.replace(/(\[\[(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d\d?\]\],?\s?\s?)\[\[(\d{1,4})\]\]y?y?y?/g,'$1xx$2xx'); txt.value=txt.value.replace(/\[\[(\d{1,4})\]\]y?y?y?(,?\s?\-?\s?\[\[(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d\d?\]\])/g,'xx$1xx$2'); txt.value=txt.value.replace(/\[\[(\d{1,4})\]\]y?y?y?(,?\s?\-?\s?\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d\d?\]\])/gi,'xx$1xx$2'); txt.value=txt.value.replace(/\[\[(\d{1,4})\]\]y?y?y?(,?\s?\-?\s?\[\[\d\d?\s(?:January|February|March|April|May|June|July|August|September|October|November|December)\]\])/gi,'xx$1xx$2'); txt.value=txt.value.replace(/\[\[(\d{1,4})\]\]y?y?y?(,?\s?\-?\s?\[\[\d\d\-\d\d\]\]y?y?y?)/gi,'xx$1xx$2'); //year: now remove unprotected linked years txt.value=txt.value.replace(/\[\[(\d{1,4})\]\]/gi, '$1'); //year: #1. Undo temporary change to protect accessyear and date preference dates txt.value=txt.value.replace(/xx(\d{1,4})xx/gi, '\[\[$1\]\]'); //'present' txt.value=txt.value.replace(/\[\[Present \(time\)\|(Present)\]\]/gi, '$1'); txt.value=txt.value.replace(/\[\[(Present)\]\]/gi, '$1'); //Season txt.value=txt.value.replace(/\[\[(spring\s\(season\)|summer|winter|autumn)\]\]/gi, '$1'); txt.value=txt.value.replace(/\[\[spring\s\(season\)\|(spring)\]\]/gi, '$1'); //Identify surprise or 'Easter egg' diversions linking months to year articles. txt.value=txt.value.replace(/\[\[\d{1,4}#[^\|]{1,30}\|(January|February|March|April|May|June|July|August|September|October|November|December)\]\]/gi, '$1'); // months txt.value=txt.value.replace(/\[\[\s?(January|February|March|April|May|June|July|August|September|October|November|December)\s?\]\]/gi, '$1'); txt.value=txt.value.replace(/\[\[(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\]\]/g, '$1'); txt.value=txt.value.replace(/\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\|(January|February|March|April|May|June|July|August|September|October|November|December)\]\]/gi, '$1'); //Treat 'Sept' (i.e. month abbreviation) differently from 'sept' (i.e. family) txt.value=txt.value.replace(/\[\[(Sept)\]\]/g, '$1'); txt.value=txt.value.replace(/\[\[January\|(Jan)\]\]/gi, '$1'); txt.value=txt.value.replace(/\[\[February\|(Feb)\]\]/gi, '$1'); txt.value=txt.value.replace(/\[\[March\|(Mar)\]\]/gi, '$1'); txt.value=txt.value.replace(/\[\[April\|(Apr)\]\]/gi, '$1'); txt.value=txt.value.replace(/\[\[May\|(May)\]\]/gi, '$1'); txt.value=txt.value.replace(/\[\[June\|(Jun)\]\]/gi, '$1'); txt.value=txt.value.replace(/\[\[July\|(Jul)\]\]/gi, '$1'); txt.value=txt.value.replace(/\[\[August\|(Aug)\]\]/gi, '$1'); txt.value=txt.value.replace(/\[\[September\|(Sep)\]\]/gi, '$1'); txt.value=txt.value.replace(/\[\[October\|(Oct)\]\]/gi, '$1'); txt.value=txt.value.replace(/\[\[November\|(Nov)\]\]/gi, '$1'); txt.value=txt.value.replace(/\[\[December\|(Dec)\]\]/g, '$1'); //month piped to number txt.value=txt.value.replace(/\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\|(\d{1,4})\]\]/gi, '$1'); //Month+day_number "March 7th" -> "March 7" txt.value=txt.value.replace(/\[\[(January|February|March|April|May|June|July|August|September|October|November|December) (\d?\d)(?:th|st|nd|rd)\]\]/gi, '\[\[$1 $2\]\]'); txt.value=txt.value.replace(/\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December) \d?\d)\]\](?:th|st|nd|rd)/gi, '\[\[$1\]\]'); txt.value=txt.value.replace(/\[\[(\d?\d)(?:th|st|nd|rd) (January|February|March|April|May|June|July|August|September|October|November|December)\]\]/gi, '\[\[$1 $2\]\]'); //Month+day_number piped into number. Preferences do not work. They don't work in sequence because digits in the two dates must be adjacent txt.value=txt.value.replace(/([^\[]{4})\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December) \d?\d)\]\](\s?\-?\s?)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}\|(\d{1,2})\]\]/gi, '$1$2$3$4'); //same again but with ndash or mdash instead of hyphen txt.value=txt.value.replace(/([^\[]{4})\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December) \d?\d)\]\](\s?&[nm]dash;\s?)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}\|(\d{1,2})\]\]/gi, '$1$2$3$4'); //same again but with slash instead of hyphen txt.value=txt.value.replace(/([^\[]{4})\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December) \d?\d)\]\](\/)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}\|(\d{1,2})\]\]/gi, '$1$2$3$4'); txt.value=txt.value.replace(/([^\[]{4})\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December) \d?\d)\]\](\s?\-?\s?)\[\[(\d{1,2})\]\]/gi, '$1$2$3$4'); //same again but with ndash instead of hyphen txt.value=txt.value.replace(/([^\[]{4})\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December) \d?\d)\]\](\s?&[nm]dash;\s?)\[\[(\d{1,2})\]\]/gi, '$1$2$3$4'); //same again but with slash instead of hyphen txt.value=txt.value.replace(/([^\[]{4})\[\[((?:January|February|March|April|May|June|July|August|September|October|November|December) \d?\d)\]\](\/)\[\[(\d{1,2})\]\]/gi, '$1$2$3$4'); txt.value=txt.value.replace(/([^\[]{4})\[\[(\d?\d) (?:January|February|March|April|May|June|July|August|September|October|November|December)\]\](\s?\-?\s?)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}\|(\d{1,2})\]\]/gi, '$1$2$3$4'); //same again but with ndash instead of hyphen txt.value=txt.value.replace(/([^\[]{4})\[\[(\d?\d) (?:January|February|March|April|May|June|July|August|September|October|November|December)\]\](\s?&[nm]dash;\s?)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}\|(\d{1,2})\]\]/gi, '$1$2$3$4'); //same again but with slash instead of hyphen txt.value=txt.value.replace(/([^\[]{4})\[\[(\d?\d) (?:January|February|March|April|May|June|July|August|September|October|November|December)\]\](\/)\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}\|(\d{1,2})\]\]/gi, '$1$2$3$4'); txt.value=txt.value.replace(/([^\[]{4})\[\[(\d?\d) (?:January|February|March|April|May|June|July|August|September|October|November|December)\]\](\s?\-?\s?)\[\[(\d{1,2})\]\]/gi, '$1$2$3$4'); //same again but with ndash instead of hyphen txt.value=txt.value.replace(/([^\[]{4})\[\[(\d?\d) (?:January|February|March|April|May|June|July|August|September|October|November|December)\]\](\s?&[nm]dash;\s?)\[\[(\d{1,2})\]\]/gi, '$1$2$3$4'); //same again but with slash instead of hyphen txt.value=txt.value.replace(/([^\[]{4})\[\[(\d?\d) (?:January|February|March|April|May|June|July|August|September|October|November|December)\]\](\/)\[\[(\d{1,2})\]\]/gi, '$1$2$3$4'); txt.value=txt.value.replace(/\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December) \d{1,2}\|(\d{1,2})\]\]/gi, '$1'); txt.value=txt.value.replace(/\[\[\d{1,2} (?:January|February|March|April|May|June|July|August|September|October|November|December)\|(\d{1,2})\]\]/gi, '$1'); txt.value=txt.value.replace(/\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d{1,2}\|((?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{1,2})\]\]/g, '$1'); //month+day piped into month+day or vice versa txt.value=txt.value.replace(/\[\[\d{1,2}\s(?:January|February|March|April|May|June|July|August|September|October|November|December)\|((?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d{1,2})\]\]/gi, '$1'); txt.value=txt.value.replace(/\[\[(?:January|February|March|April|May|June|July|August|September|October|November|December)\s\d{1,2}\|(\d{1,2}\s(?:January|February|March|April|May|June|July|August|September|October|November|December))\]\]/gi, '$1'); // days of the week in full. Optional plurals txt.value=txt.value.replace(/\[\[(Mondays?|Tuesdays?|Wednesdays?|Thursdays?|Fridays?|Saturdays?|Sundays?)\]\]/gi, '$1'); // days of the week abbreviated. Leave out 'Sun' as potentially valid link to the Sun. Leave out 'SAT' in upper case as potential link to 'Scholastic achievement/aptitude test'. txt.value=txt.value.replace(/\[\[(Mon|Tue|Tues|Wed|Thu|Thur|Thurs|Fri)\]\]/gi, '$1'); txt.value=txt.value.replace(/\[\[(Sat)\]\]/g, '$1'); txt.value=txt.value.replace(/\[\[Mondays?\|(Mondays?|Mon)\]\]/gi, '$1'); txt.value=txt.value.replace(/\[\[Tuesdays?\|(Tuesdays?|Tues?)\]\]/gi, '$1'); txt.value=txt.value.replace(/\[\[Wednesdays?\|(Wednesdays?|Wed)\]\]/gi, '$1'); txt.value=txt.value.replace(/\[\[Thursdays?\|(Thursdays?|Thur?)\]\]/gi, '$1'); txt.value=txt.value.replace(/\[\[Fridays?\|(Fridays?|Fri)\]\]/gi, '$1'); txt.value=txt.value.replace(/\[\[Saturdays?\|(Saturdays?|Sat)\]\]/gi, '$1'); txt.value=txt.value.replace(/\[\[Sundays?\|(Sundays?|Sun)\]\]/gi, '$1'); //4 digit years piped into 2 txt.value=txt.value.replace(/\[\[\d{1,4}\|(\d{1,2})\]\]/gi, '$1'); } function formatgeneral() { var txt = document.editform.wpTextbox1; //remove flagicons from birth and death txt.value=txt.value.replace(/(birth\s?=\s?)\{\{flagicon\|[^\}]{1,30}\}\}/gi, '$1'); txt.value=txt.value.replace(/(death\s?=\s?)\{\{flagicon\|[^\}]{1,30}\}\}/gi, '$1'); txt.value=txt.value.replace(/(birth_?place\s?=\s?)\{\{flagicon\|[^\}]{1,30}\}\}/gi, '$1'); txt.value=txt.value.replace(/(death_?place\s?=\s?)\{\{flagicon\|[^\}]{1,30}\}\}/gi, '$1'); //symbol for 'times' txt.value=txt.value.replace(/×/gi, '×'); //symbol for superscript 2 and 3 //txt.value=txt.value.replace(/<sup>2<\/sup>/gi, '²'); //txt.value=txt.value.replace(/<sup>3<\/sup>/gi, '³'); //Attempt to deal with naval infobox txt.value=txt.value.replace(/General\sCharacteristics/g, 'General characteristics'); //turn letter 'x' into symbol '×' txt.value=txt.value.replace(/(\d)\sx\s(\d{1,3})\sin\s\(/gi, '$1 × $2 in ('); txt.value=txt.value.replace(/(\d)\sx\s(\d{1,3})\sinch\s/gi, '$1 × $2 inch '); // Convert degree symbols into ° symbol, ensure preceding space txt.value=txt.value.replace(/°/g, '°'); txt.value=txt.value.replace(/º/g, '°'); //aviation specifications: protect 'main=' and 'alt=' - undone below txt.value=txt.value.replace(/((?:main|alt)\s?=\s?)(\d)/gi, '$1xx$2'); // Celsius spelling errors txt.value=txt.value.replace(/celsius/gi, 'Celsius'); txt.value=txt.value.replace(/celcius/gi, 'Celsius'); //Fix common naming error (be careful with this one) txt.value=txt.value.replace(/centigrade/gi, 'Celsius'); //Celsius or Fahrenheit txt.value=txt.value.replace(/°\s([CF])/g, '°$1'); txt.value=txt.value.replace(/° ([CF])/g, '°$1'); txt.value=txt.value.replace(/°\s?(celsius)/gi, '°C'); txt.value=txt.value.replace(/° (celsius)/gi, '°C'); txt.value=txt.value.replace(/(\d)\s?(°[CF])/g, '$1 $2'); txt.value=txt.value.replace(/deg[^\(]([CF])/gi, '°$1'); txt.value=txt.value.replace(/deg\s?([CF])/gi, '°$1'); txt.value=txt.value.replace(/deg ([CF])/gi, '°$1'); txt.value=txt.value.replace(/deg\.?\s?([CF])/gi, '°$1'); txt.value=txt.value.replace(/degrees?\s([CF])([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '°$1$2'); txt.value=txt.value.replace(/degrees? ([CF])([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '°$1$2'); txt.value=txt.value.replace(/(\d)\s?° ([CF])/g, '$1 °$2'); txt.value=txt.value.replace(/(\d)°([CF])/g, '$1 °$2'); txt.value=txt.value.replace(/(\d)°\[\[/g, '$1 °[['); txt.value=txt.value.replace(/(\d)° (\[\[[CF])/gi, '$1 °$2'); txt.value=txt.value.replace(/(\d)(\[\[Celsius|°C\]\])/gi, '$1 $2'); txt.value=txt.value.replace(/(\d)(\[\[Fahrenheit|°F\]\])/gi, '$1 $2'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(-?\d[\d,\.]{0,16})(?:\s|-| |)°?F([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1{{convert|$2|°F|°C|abbr=on}}$3'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(-?\d[\d,\.]{0,16})(?:\s|-| |)(?:deg|degree|degrees)(?:\s|-| |)Fahrenheit([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|°F|°C}}$3'); // Convert &sup to superscript txt.value=txt.value.replace(/²/g, '²'); txt.value=txt.value.replace(/³/g, '³'); //metre //delink this common unit txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-|)\[\[(metres|meters|metre|meter)\]\]([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1$2 $3$4'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-|)\[\[(metre|meter)\]\]s([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1$2 $3s$4'); //space before 'm' only when lower case. Check for dollars and pounds to avoid 'm' used for millions in money. txt.value=txt.value.replace(/(\(\d[\d,\.]{0,16})(?:\s|-|)m([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1 m$2'); //convert 'metres' to 'm' when in parentheses txt.value=txt.value.replace(/(\(\d[\d,\.]{0,16})(?:\s|-|)(?:metres|meters|metre|meter)(\))/g, '$1 m$2'); txt.value=txt.value.replace(/(\(\d[\d,\.]{0,16}) (?:metres|meters|metre|meter)(\))/g, '$1 m$2'); txt.value=txt.value.replace(/({convert\|\d{1,16}\|(?:m|ft)[^\}]{0,16})\|lk=(?:on|in|out)/g, '$1'); //metre per second txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-|)(?:m\/second|m\/sec)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1$2 m/s$3'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16}) (?:m\/second|m\/sec)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1$2 m/s$3'); txt.value=txt.value.replace(/({convert\|\d{1,16}\|(?:m\s|ft\s)[^\}]{0,16})\|lk=(?:on|in|out)/g, '$1'); //square metre txt.value=txt.value.replace(/(\d)(?:\s|-| |)sq(?:\s|\.\s|-| )m([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 m²$2'); txt.value=txt.value.replace(/({convert\|\d{1,16}\|(?:sqm|sqft)[^\}]{0,16})\|lk=(?:on|in|out)/g, '$1'); // millimetre txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-|)mm([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1$2 mm$3'); // centimetre, cubic centimetre txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-|)(cm|cc)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1$2 $3$4'); // kilometre //delink this common unit txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-|)\[\[(kilometres|kilometers|kilometre|kilometer)\]\]([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1$2 $3$4'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16}) \[\[(kilometres|kilometers|kilometre|kilometer)\]\]([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1$2 $3$4'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-|)\[\[(?:kilometres?|kilometers?)\|(km)\]\]([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1$2 $3$4'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16}) \[\[(?:kilometres?|kilometers?)\|(km)\]\]([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1$2 $3$4'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-|)kms?([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1$2 km$3'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16}) kms?([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1$2 km$3'); txt.value=txt.value.replace(/({convert\|\d{1,16}\|(?:mi|km)[^\}]{0,16})\|lk=(?:on|in|out)/g, '$1'); //square kilometre txt.value=txt.value.replace(/(\d)(\s|-| )\[\[km²\]\]/gi, '$1$2km²'); txt.value=txt.value.replace(/(\d)\s?sq\.?(?:\s|-| |)kms?(\s|\.)/gi, '$1 km²$2'); txt.value=txt.value.replace(/({convert\|\d{1,16})00\|ha/g, '$1|sqkm'); txt.value=txt.value.replace(/({convert\|\d{1,16})(\d)0\|ha/g, '$1.$2|sqkm'); txt.value=txt.value.replace(/({convert\|\d{1,16})(\d\d)\|ha/g, '$1.$2|sqkm'); txt.value=txt.value.replace(/({convert\|\d{1,16}\|sqmi\|)ha/g, '$1sqkm'); txt.value=txt.value.replace(/({convert\|\d{1,16}\|(?:sqkm|sqmi)[^\}]{0,16})\|lk=(?:on|in|out)/g, '$1'); txt.value=txt.value.replace(/({convert\|\d{3,16}\|acre\|)ha/g, '$1sqkm'); //kilometre per second txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-|)(?:km\/second|km\/sec)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1$2 km/s$3'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16}) (?:km\/second|km\/sec)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1$2 km/s$3'); // kilometre per hour txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-|)(?:km\/hr|km\/ph|kph|kmph|kmh)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1$2 km/h$3'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16}) (?:km\/hr|km\/ph|kph|kmph|kmh)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1$2 km/h$3'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-|)\[\[(?:km\/hr|km\/ph|kph|kmph|kmh)\]\]([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1$2 km/h$3'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16}) \[\[(?:km\/hr|km\/ph|kph|kmph|kmh)\]\]([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1$2 km/h$3'); //millilitre txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-|)(ml)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1$2 $3$4'); // ensure spaces and correct case in kilowatt txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-|)kW([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1$2 kW$3'); // ensure spaces and correct case in hertz txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-|)Hz([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1$2 Hz$3'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-|)kHz([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1$2 kHz$3'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-|)GHz([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1$2 GHz$3'); // ensure spaces in megahertz. Must be upper case to avoid clashing with millihertz txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-|)MHz([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1$2 MHz$3'); // frames per second txt.value=txt.value.replace(/frames\/s([:;,\.?!]?\s[^\d\(\)\/\\])/gi, 'frame/s$1'); // kilogram txt.value=txt.value.replace(/kilogrammes/gi, 'kilograms'); txt.value=txt.value.replace(/kilogramme/gi, 'kilogram'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-|)\[\[(kilograms?)\]\]([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1$2 $3$4'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16}) \[\[(kilograms?)\]\]([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1$2 $3$4'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-|)grammes([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1$2 grams$3'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-|)gramme([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1$2 gram$3'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-|)(?:kgs?|\[\[kg\]\])([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1$2 kg$3'); txt.value=txt.value.replace(/({convert\|\d{1,16}\|(?:kg|lb)[^\}]{0,16})\|lk=(?:on|in|out)/g, '$1'); //foot //convert 'foot' to 'ft' when in parentheses txt.value=txt.value.replace(/(\(\d[\d,\.]{0,16})(?:\s|-|)(?:feet|foot)(\))/g, '$1 ft$2'); txt.value=txt.value.replace(/(\(\d[\d,\.]{0,16}) (?:feet|foot)(\))/g, '$1 ft$2'); //remove trailing period when in parentheses txt.value=txt.value.replace(/(\(\d[\d,\.]{0,16})(?:\s|-|)ft\.(\))/g, '$1 ft$2'); txt.value=txt.value.replace(/(\(\d[\d,\.]{0,16}) ft\.(\))/g, '$1 ft$2'); // square foot //convert 'sq foot' to 'sq ft' txt.value=txt.value.replace(/(\d)(\s|-)sq\.?(\s|-|)(feet|foot|ft)/gi, '$1 sq ft'); txt.value=txt.value.replace(/(\d) sq\.? (feet|foot|ft)/gi, '$1 sq ft'); //convert 'square ft' to 'sq ft' txt.value=txt.value.replace(/(\d)(\s|-)square(\s|-)ft/gi, '$1 sq ft'); txt.value=txt.value.replace(/(\d) square ft/gi, '$1 sq ft'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)sq(?:\s|-| |)ft([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|sqft|sqm|abbr=on}}$3'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)square(?:\s|-| |)feet([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|sqft|sqm}}$3'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)square(?:\s|-| |)foot([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|sqft|sqm|sing=on}}$3'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)([\d,]{1,16})(?:\s|-| |)thousand(?:\s|-| |)(?:sq|square)\.?(?:\s|-| |)ft([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2000|sqft|sqm|abbr=on}}$3'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)([\d,]{1,16})(?:\s|-| |)thousand(?:\s|-| |)(?:sq|square)\.?(?:\s|-| |)feet([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2000|sqft|sqm}}$3'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)([\d,]{1,16})(?:\s|-| |)thousand(?:\s|-| |)(?:sq|square)\.?(?:\s|-| |)foot([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2000|sqft|sqm|sing=on}}$3'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)([\d,]{1,16})(?:\s|-| |)million(?:\s|-| |)(?:sq|square)\.?(?:\s|-| |)ft([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2000000|sqft|sqm|abbr=on}}$3'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)([\d,]{1,16})(?:\s|-| |)million(?:\s|-| |)(?:sq|square)\.?(?:\s|-| |)feet([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2000000|sqft|sqm}}$3'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)([\d,]{1,16})(?:\s|-| |)million(?:\s|-| |)(?:sq|square)\.?(?:\s|-| |)foot([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2000000|sqft|sqm|sing=on}}$3'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)([\d,]{1,16})\.(\d)(?:\s|-| |)million(?:\s|-| |)(?:sq|square)\.?(?:\s|-| |)ft([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2$300000|sqft|sqm|abbr=on}}$4'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)([\d,]{1,16})\.(\d)(?:\s|-| |)million(?:\s|-| |)(?:sq|square)\.?(?:\s|-| |)feet([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2$300000|sqft|sqm}}$4'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)([\d,]{1,16})\.(\d)(?:\s|-| |)million(?:\s|-| |)(?:sq|square)\.?(?:\s|-| |)foot([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2$300000|sqft|sqm|sing=on}}$4'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)([\d,]{1,16})\.(\d\d)(?:\s|-| |)million(?:\s|-| |)(?:sq|square)\.?(?:\s|-| |)ft([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2$30000|sqft|sqm|abbr=on}}$4'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)([\d,]{1,16})\.(\d\d)(?:\s|-| |)million(?:\s|-| |)(?:sq|square)\.?(?:\s|-| |)feet([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2$30000|sqft|sqm}}$4'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)([\d,]{1,16})\.(\d\d)(?:\s|-| |)million(?:\s|-| |)(?:sq|square)\.?(?:\s|-| |)foot([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2$30000|sqft|sqm|sing=on}}$4'); //feet per second txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-|)(?:ft\/second|ft\/sec)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1$2 ft/s$3'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16}) (?:ft\/second|ft\/sec)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1$2 ft/s$3'); //feet per second:plural txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)feet\sper\ssecond([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|ft/s|m/s}}$3'); //feet per second:singular txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)foot\sper\ssecond([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|ft/s|m/s|sing=on}}$3'); //feet per second:abbreviated txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)ft\/s([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|ft/s|m/s|abbr=on}}$3'); // foot and inch txt.value=txt.value.replace(/(ength[.]{1,3})(\d{1,4})\s?['’]\s?(\d{1,3})\s?["”]/gi, '$1$2 ft $3 in'); txt.value=txt.value.replace(/(idth[.]{1,3})(\d{1,4})\s?['’]\s?(\d{1,3})\s?["”]/gi, '$1$2 ft $3 in'); txt.value=txt.value.replace(/([\(\|:]\s?\d{1,4})\s?['’]\s?(\d{1,3})\s?["”]([^NESW])/g, '$1 ft $2 in$3'); txt.value=txt.value.replace(/(\d)\s?ft\s?(\d{1,3})\s?in/gi, '$1 ft $2 in'); // yard txt.value=txt.value.replace(/(\d)\s?yds([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 yd$2'); txt.value=txt.value.replace(/(\d) yds([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 yd$2'); txt.value=txt.value.replace(/sq\.?\s?yds?/gi, 'sq yd'); txt.value=txt.value.replace(/yd\.\)/gi, 'yd)'); //yards: plural txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)(?:yards|\[\[yard\]\]s|\[\[yards\]\])([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|yd|m}}$3'); //yards: singular txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)(?:yard|\[\[yard\]\])([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|yd|m|sing=on}}$3'); //yards: abbreviated txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)yd([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|yd|m|abbr=on}}$3'); //yards: in full txt.value=txt.value.replace(/([^y]\sone(?:\s|-| |)yards?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (1 m)$2'); txt.value=txt.value.replace(/([^y]\stwo(?:\s|-| |)yards?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (2 m)$2'); txt.value=txt.value.replace(/([^y]\sthree(?:\s|-| |)yards?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (3 m)$2'); txt.value=txt.value.replace(/([^y]\sfour(?:\s|-| |)yards?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (4 m)$2'); txt.value=txt.value.replace(/([^y]\sfive(?:\s|-| |)yards?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (5 m)$2'); txt.value=txt.value.replace(/([^y]\ssix(?:\s|-| |)yards?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (5 m)$2'); txt.value=txt.value.replace(/([^y]\sseven(?:\s|-| |)yards?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (6 m)$2'); txt.value=txt.value.replace(/([^y]\seight(?:\s|-| |)yards?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (7 m)$2'); txt.value=txt.value.replace(/([^y]\snine(?:\s|-| |)yards?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (8 m)$2'); txt.value=txt.value.replace(/([^y]\sten(?:\s|-| |)yards?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (9 m)$2'); txt.value=txt.value.replace(/([^y]\seleven(?:\s|-| |)yards?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (10 m)$2'); txt.value=txt.value.replace(/([^y]\stwelve(?:\s|-| |)yards?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (11 m)$2'); txt.value=txt.value.replace(/([^y]\sthirteen(?:\s|-| |)yards?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (12 m)$2'); txt.value=txt.value.replace(/([^y]\sfourteen(?:\s|-| |)yards?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (13 m)$2'); txt.value=txt.value.replace(/([^y]\sfifteen(?:\s|-| |)yards?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (14 m)$2'); txt.value=txt.value.replace(/([^y]\ssixteen(?:\s|-| |)yards?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (15 m)$2'); txt.value=txt.value.replace(/([^y]\sseventeen(?:\s|-| |)yards?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (16 m)$2'); txt.value=txt.value.replace(/([^y]\seighteen(?:\s|-| |)yards?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (16 m)$2'); txt.value=txt.value.replace(/([^y]\snineteen(?:\s|-| |)yards?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (17 m)$2'); txt.value=txt.value.replace(/([^y]\stwenty(?:\s|-| |)yards?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (18 m)$2'); // knot txt.value=txt.value.replace(/(\d)(\s|-| )(?:kts|kt|knt)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1$2knots$3'); txt.value=txt.value.replace(/\[knot\s\(unit\)\|/gi, '[knot (speed)|'); txt.value=txt.value.replace(/\[\[kts\]\]/gi, '[[knot (speed)|knots]]'); txt.value=txt.value.replace(/\|kts\]\]/gi, '|knots]]'); //nautical mile - rename 'miles' as 'nautical miles' when followed by knots or conversion code txt.value=txt.value.replace(/(\d)(?:\s|-| |)miles\s(?:at|@)\s([\d\.]{1,9}(?:\s|-| |)knots|{{convert)/gi, '$1 nautical miles at $2'); txt.value=txt.value.replace(/(\d)(\s|-| )(?:mi|nm|nmi)\s(?:at|@)\s([\d\.]{1,9}(?:\s|-| |)knots|{{convert)/gi, '$1$2nmi at $3'); //nautical mile: plural unlinked txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)nautical(?:\s|-| |)miles([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|nmi|km}}$3'); //nautical mile: plural linked with 's' inside link txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)\[\[nautical(?:\s|-| |)miles\]\]([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|nmi|km}}$3'); //nautical mile: plural linked with 's' outside link txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)\[\[nautical(?:\s|-| |)mile\]\]s([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|nmi|km}}$3'); //nautical mile: singular unlinked txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)nautical(?:\s|-| |)mile([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|nmi|km|sing=on}}$3'); //nautical mile: singular linked txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)\[\[nautical(?:\s|-| |)mile\]\]([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|nmi|km|sing=on}}$3'); //nautical mile: abbreviated txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)(?:\[\[nautical\smile\|nmi?\]\]|nmi)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|nmi|km|abbr=on}}$3'); //nautical mile: in full txt.value=txt.value.replace(/([^y]\sone(?:\s|-| |)nautical(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (1.9 km)$2'); txt.value=txt.value.replace(/([^y]\stwo(?:\s|-| |)nautical(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (4 km)$2'); txt.value=txt.value.replace(/([^y]\sthree(?:\s|-| |)nautical(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (6 km)$2'); txt.value=txt.value.replace(/([^y]\sfour(?:\s|-| |)nautical(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (7 km)$2'); txt.value=txt.value.replace(/([^y]\sfive(?:\s|-| |)nautical(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (9 km)$2'); txt.value=txt.value.replace(/([^y]\ssix(?:\s|-| |)nautical(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (11 km)$2'); txt.value=txt.value.replace(/([^y]\sseven(?:\s|-| |)nautical(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (13 km)$2'); txt.value=txt.value.replace(/([^y]\seight(?:\s|-| |)nautical(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (15 km)$2'); txt.value=txt.value.replace(/([^y]\snine(?:\s|-| |)nautical(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (17 km)$2'); txt.value=txt.value.replace(/([^y]\sten(?:\s|-| |)nautical(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (19 km)$2'); txt.value=txt.value.replace(/([^y]\seleven(?:\s|-| |)nautical(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (20 km)$2'); txt.value=txt.value.replace(/([^y]\stwelve(?:\s|-| |)nautical(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (22 km)$2'); txt.value=txt.value.replace(/([^y]\sthirteen(?:\s|-| |)nautical(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (24 km)$2'); txt.value=txt.value.replace(/([^y]\sfourteen(?:\s|-| |)nautical(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (26 km)$2'); txt.value=txt.value.replace(/([^y]\sfifteen(?:\s|-| |)nautical(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (28 km)$2'); txt.value=txt.value.replace(/([^y]\ssixteen(?:\s|-| |)nautical(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (30 km)$2'); txt.value=txt.value.replace(/([^y]\sseventeen(?:\s|-| |)nautical(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (31 km)$2'); txt.value=txt.value.replace(/([^y]\seighteen(?:\s|-| |)nautical(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (33 km)$2'); txt.value=txt.value.replace(/([^y]\snineteen(?:\s|-| |)nautical(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (35 km)$2'); txt.value=txt.value.replace(/([^y]\stwenty(?:\s|-| |)nautical(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (37 km)$2'); //knot - plural txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)(?:knots|\[\[knot\s\(speed\)\|(?:knots\]\]|knot\]\]s))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|knot|km/h}}$3'); //knot - singular txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)(?:knot|\[\[knot\s\(speed\)\|knot\]\])([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|knot|km/h|sing=on}}$3'); //knot - abbreviation txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)(?:kts?|\[\[knot\s\(speed\)\|kts?\]\])([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|knot|km/h|abbr=on}}$3'); //mile - delink this common unit txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-|)\[\[(miles?)\]\]([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1$2 $3$4'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16}) \[\[(miles?)\]\]([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1$2 $3$4'); //mile - lower case to avoid proper names like 'Five Mile Road' //mile - protect 'miles per hour' - undone below txt.value=txt.value.replace(/(miles?)\s(per)/gi, '$1xx$2'); //miles: plural txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)(?:miles|\[\[miles\]\]|\[\[mile\]\]s)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1{{convert|$2|mi|km}}$3'); //miles: singular txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)(?:mile|\[\[mile\]\])([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1{{convert|$2|mi|km|sing=on}}$3'); //miles: abbreviated txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)mi([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1{{convert|$2|mi|km|abbr=on}}$3'); //miles: in full txt.value=txt.value.replace(/([^y]\sone(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1 (1.6 km)$2'); txt.value=txt.value.replace(/([^y]\stwo(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1 (3 km)$2'); txt.value=txt.value.replace(/([^y]\sthree(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1 (5 km)$2'); txt.value=txt.value.replace(/([^y]\sfour(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1 (6 km)$2'); txt.value=txt.value.replace(/([^y]\sfive(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1 (8 km)$2'); txt.value=txt.value.replace(/([^y]\ssix(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1 (10 km)$2'); txt.value=txt.value.replace(/([^y]\sseven(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1 (11 km)$2'); txt.value=txt.value.replace(/([^y]\seight(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1 (13 km)$2'); txt.value=txt.value.replace(/([^y]\snine(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1 (14 km)$2'); txt.value=txt.value.replace(/([^y]\sten(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1 (16 km)$2'); txt.value=txt.value.replace(/([^y]\seleven(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1 (18 km)$2'); txt.value=txt.value.replace(/([^y]\stwelve(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1 (19 km)$2'); txt.value=txt.value.replace(/([^y]\sthirteen(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1 (19 km)$2'); txt.value=txt.value.replace(/([^y]\sfourteen(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1 (21 km)$2'); txt.value=txt.value.replace(/([^y]\sfifteen(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1 (24 km)$2'); txt.value=txt.value.replace(/([^y]\sixteen(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1 (26 km)$2'); txt.value=txt.value.replace(/([^y]\sseventeen(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1 (27 km)$2'); txt.value=txt.value.replace(/([^y]\seighteen(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1 (29 km)$2'); txt.value=txt.value.replace(/([^y]\snineteen(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1 (30 km)$2'); txt.value=txt.value.replace(/([^y]\stwenty(?:\s|-| |)miles?)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1 (32 km)$2'); //mile - unprotect 'miles per hour' txt.value=txt.value.replace(/(miles?)xx(per)/gi, '$1 $2'); //mile per hour txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)m\.?p\.?h([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1{{convert|$2|mi/h|km/h|abbr=on}}$3'); // square mile txt.value=txt.value.replace(/(\d)(?:\s|-)sq(?:\s|\.\s|-)mi([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 sq mi$2'); txt.value=txt.value.replace(/\[\[(square\smile)\]\]/gi, '$1'); txt.value=txt.value.replace(/\[\[square\smile\|(sq\smi)\]\]/gi, '$1'); txt.value=txt.value.replace(/(sq)(?:\s|-| |)(mile)/gi, '$1uare $2'); // square mile:plural txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)square(?:\s|-| |)miles([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|sqmi|sqkm}}$3'); // square mile:singular txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)square(?:\s|-| |)mile([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|sqmi|sqkm|sing=on}}$3'); // square mile:abbreviated txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)sq(?:\s|-| |)mi([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|sqmi|sqkm|abbr=on}}$3'); //acre foot:plural txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)([\d,]{3,16}[\d,\.]{0,16})(?:\s|-| |)acre(?:\s|-| |)feet([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1{{convert|$2|acre feet}}$3'); //acre foot:singular txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)([\d,]{3,16}[\d,\.]{0,16})(?:\s|-| |)acre(?:\s|-| |)foot([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1{{convert|$2|acre feet|sing=on}}$3'); //acre foot:abbreviation txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)([\d,]{3,16}[\d,\.]{0,16})(?:\s|-| |)(?:acre|ac\.?)(?:\s|-| |)(?:foot|feet|ft)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1{{convert|$2|acre ft|abbr=on}}$3'); //acre //acres - temporary change to protect acre feet. changed below txt.value=txt.value.replace(/(acre.feet)/gi, 'xtempx$1ytempy'); txt.value=txt.value.replace(/(\d)-(acre)/gi, '$1 $2'); txt.value=txt.value.replace(/(\d)(?:\s|-| |)surface(?:\s|-| |)acre/gi, '$1 acre'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)([\d,]{1,16})(?:\s|-| |)thousand(?:\s|-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2000|acre|sqkm}}$3'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)([\d,]{1,16})(?:\s|-| |)thousand(?:\s|-| |)(?:acre|\[\[acre\]\])([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2000|acre|sqkm|sing=on}}$3'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)([\d,]{1,16})(?:\s|-| |)million(?:\s|-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2000000|acre|sqkm}}$3'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)([\d,]{1,16})(?:\s|-| |)million(?:\s|-| |)(?:acre|\[\[acre\]\])([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2000000|acre|sqkm|sing=on}}$3'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)([\d,]{1,16})\.(\d)(?:\s|-| |)million(?:\s|-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2$300000|acre|sqkm}}$4'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)([\d,]{1,16})\.(\d)(?:\s|-| |)million(?:\s|-| |)(?:acre|\[\[acre\]\])([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2$300000|acre|sqkm|sing=on}}$4'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)([\d,]{1,16})\.(\d\d)(?:\s|-| |)million(?:\s|-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2$30000|acre|sqkm}}$4'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)([\d,]{1,16})\.(\d\d)(?:\s|-| |)million(?:\s|-| |)(?:acre|\[\[acre\]\])([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2$30000|acre|sqkm|sing=on}}$4'); txt.value=txt.value.replace(/([^y]\sone(?:\s|-| |)million(?:\s|-| |)acres?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (4,000 km²)$2'); txt.value=txt.value.replace(/(\sa(?:\s|-| |)million(?:\s|-| |)acres?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (4,000 km²)$2'); txt.value=txt.value.replace(/([^y]\stwo(?:\s|-| |)million(?:\s|-| |)acres?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (8,000 km²)$2'); txt.value=txt.value.replace(/([^y]\sthree(?:\s|-| |)million(?:\s|-| |)acres?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (12,000 km²)$2'); txt.value=txt.value.replace(/([^y]\sfour(?:\s|-| |)million(?:\s|-| |)acres?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (16,000 km²)$2'); txt.value=txt.value.replace(/([^y]\sfive(?:\s|-| |)million(?:\s|-| |)acres?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (20,000 km²)$2'); txt.value=txt.value.replace(/([^y]\ssix(?:\s|-| |)million(?:\s|-| |)acres?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (24,000 km²)$2'); txt.value=txt.value.replace(/([^y]\sseven(?:\s|-| |)million(?:\s|-| |)acres?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (28,000 km²)$2'); txt.value=txt.value.replace(/([^y]\seight(?:\s|-| |)million(?:\s|-| |)acres?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (32,000 km²)$2'); txt.value=txt.value.replace(/([^y]\snine(?:\s|-| |)million(?:\s|-| |)acres?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (36,000 km²)$2'); txt.value=txt.value.replace(/([^y]\sten(?:\s|-| |)million(?:\s|-| |)acres?)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (40,000 km²)$2'); //acre:plural txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)([\d,]{3,16}[\d,\.]{0,16})(?:\s|-| |)(?:acres|\[\[acres\]\]|\[\[acre\]\]s)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1{{convert|$2|acre|sqkm}}$3'); //acre:singular txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)([\d,]{3,16}[\d,\.]{0,16})(?:\s|-| |)(?:acre|\[\[acre\]\])([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1{{convert|$2|acre|sqkm|sing=on}}$3'); //undo protection for acre feet txt.value=txt.value.replace(/xtempx(acre.feet)ytempy/gi, '$1'); // foot pound txt.value=txt.value.replace(/(\W)lbs?[\s-.·•\/]{1,2}ft([^²\w])/gi, '$1ft·lbf$2'); txt.value=txt.value.replace(/(\W)lbs?ft([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1ft·lbf$2'); txt.value=txt.value.replace(/ftlbs?([:;,\.?!]?\s[^\d\(\)\/\\])/gi, 'ft·lbf$1'); txt.value=txt.value.replace(/ft[\s-.·•\/]{1,2}lbs?([:;,\.?!]?\s[^\d\(\)\/\\])/gi, 'ft·lbf$1'); txt.value=txt.value.replace(/ftlbs?([:;,\.?!]?\s[^\d\(\)\/\\])/gi, 'ft·lbf$1'); txt.value=txt.value.replace(/ft[\s-.·•\/]{1,2}lbf([^\|])/gi, 'ft·lbf$1'); txt.value=txt.value.replace(/ft[\s-.·•\/]{1,2}lbff/gi, 'ft·lbf'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)pounds?(?:\s|-| |)feet([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1{{convert|$2|ft.lbf|N.m}}$3'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)foot(?:\s|-| |)pounds([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1{{convert|$2|ft.lbf|N.m}}$3'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)pound(?:\s|-| |)foot([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1{{convert|$2|ft.lbf|N.m|sing=on}}$3'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)foot(?:\s|-| |)pound([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1{{convert|$2|ft.lbf|N.m|sing=on}}$3'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)ft.lbf([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1{{convert|$2|ft.lbf|N.m|abbr=on}}$3'); // pound force txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(\s|-| |)lbs?.?\s(thrust|of\sthrust|force|of\sforce)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1$2$3lbf $4$5'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16}000)(?:\s|-| |)pounds\sforce([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|lbf|kN}}$3'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)pounds\sforce([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|lbf|N}}$3'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16}000)(?:\s|-| |)pound\sforce([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|lbf|kN|sing=on}}$3'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)pound\sforce([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|lbf|N|sing=on}}$3'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16}000)(?:\s|-| |)lbf([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|lbf|kN|abbr=on}}$3'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)lbf([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|lbf|abbr=on}}$3'); // pound weight. Parsed after foot pound and pound force txt.value=txt.value.replace(/\[\[pound\s\(weight\)\|([^\]]{1,30})\]\]/gi, '[[pound (mass)|$1]]'); txt.value=txt.value.replace(/\|lbs?\.\]\]/gi, '|lb]]'); txt.value=txt.value.replace(/(\d)\s?lbs?([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 lb$2'); txt.value=txt.value.replace(/(\d\+?)\s?lbs?([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 lb$2'); txt.value=txt.value.replace(/(\d) lbs?([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 lb$2'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)lb([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|lb|abbr=on}}$3'); //pounds and ounces - plural txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)pounds(?:\s|-| |)(\d[\d,\.]{0,16})(?:\s|-| |)ounces?([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|lb|$3|oz|kg}}$4'); //pounds and ounces - singular txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)pound(?:\s|-| |)(\d[\d,\.]{0,16})(?:\s|-| |)ounces?([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|lb|$3|oz|kg|sing=on}}$4'); //pounds and ounces - abbreviated txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)lbs?\.?,?(?:\s|-| |)(\d[\d,\.]{0,16})(?:\s|-| |)oz\.?([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|lb|$3|oz|kg|abbr=on}}$4'); //foot and inch: plural txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)feet\.?(?:\s|-| |)(\d[\d,\.]{0,16})(?:\s|-| |)(?:in|ins|inch|inches)\.?([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|ft|$3|in|m}}$4'); //foot and inch: singular txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)foot\.?(?:\s|-| |)(\d[\d,\.]{0,16})(?:\s|-| |)(?:in|ins|inch|inches)\.?([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|ft|$3|in|m|sing=on}}$4'); //foot and inch: abbreviated txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)ft\.?(?:\s|-| |)(\d[\d,\.]{0,16})(?:\s|-| |)(?:in|ins|inch|inches)\.?([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|ft|$3|in|m|abbr=on}}$4'); //foot (again). Parsed after 'foot per second' and 'foot pound' //foot: plural txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)feet([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|ft|m}}$3'); //foot: singular txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)foot([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|ft|m|sing=on}}$3'); //foot: abbreviated txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)ft\.?([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|ft|m|abbr=on}}$3'); //inch: plural txt.value=txt.value.replace(/([^\Wt'’]\s)(\d[\d,\.]{0,16})(?:\s|-| |)inches([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|in|mm}}$3'); // inch: plural with number in words txt.value=txt.value.replace(/([^ty]\sthree(?:\s|-| |)(?:inches|\[\[inches\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (76 mm) $2'); txt.value=txt.value.replace(/([^ty]\sfour(?:\s|-| |)(?:inches|\[\[inches\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (102 mm) $2'); txt.value=txt.value.replace(/([^ty]\sfive(?:\s|-| |)(?:inches|\[\[inches\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (127 mm) $2'); txt.value=txt.value.replace(/([^ty]\ssix(?:\s|-| |)(?:inches|\[\[inches\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (152 mm) $2'); txt.value=txt.value.replace(/([^ty]\sseven(?:\s|-| |)(?:inches|\[\[inches\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (178 mm) $2'); txt.value=txt.value.replace(/([^ty]\seight(?:\s|-| |)(?:inches|\[\[inches\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (203 mm) $2'); txt.value=txt.value.replace(/([^ty]\snine(?:\s|-| |)(?:inches|\[\[inches\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (229 mm) $2'); txt.value=txt.value.replace(/([^ty]\sten(?:\s|-| |)(?:inches|\[\[inches\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (254 mm) $2'); txt.value=txt.value.replace(/([^ty]\seleven(?:\s|-| |)(?:inches|\[\[inches\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (279 mm) $2'); txt.value=txt.value.replace(/([^ty]\stwelve(?:\s|-| |)(?:inches|\[\[inches\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (305 mm) $2'); txt.value=txt.value.replace(/([^ty]\sthirteen(?:\s|-| |)(?:inches|\[\[inches\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (330 mm) $2'); txt.value=txt.value.replace(/([^ty]\sfourteen(?:\s|-| |)(?:inches|\[\[inches\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (356 mm) $2'); txt.value=txt.value.replace(/([^ty]\sfifteen(?:\s|-| |)(?:inches|\[\[inches\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (381 mm) $2'); txt.value=txt.value.replace(/([^ty]\ssixteen(?:\s|-| |)(?:inches|\[\[inches\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (406 mm) $2'); //inch: singular txt.value=txt.value.replace(/([^\Wt'’]\s)(\d[\d,\.]{0,16})(?:\s|-| |)(?:inch|\[\[inch\]\])([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|in|mm|sing=on}}$3'); txt.value=txt.value.replace(/({convert\|\d{1,16}\|(?:in|mm|cm)[^\}]{0,16})\|lk=(?:on|in|out)/g, '$1'); // inch: singular with number in words txt.value=txt.value.replace(/([^ty]\sthree(?:\s|-| |)(?:inch|\[\[inch\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (76 mm) $2'); txt.value=txt.value.replace(/([^ty]\sfour(?:\s|-| |)(?:inch|\[\[inch\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (102 mm) $2'); txt.value=txt.value.replace(/([^ty]\sfive(?:\s|-| |)(?:inch|\[\[inch\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (127 mm) $2'); txt.value=txt.value.replace(/([^ty]\ssix(?:\s|-| |)(?:inch|\[\[inch\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (152 mm) $2'); txt.value=txt.value.replace(/([^ty]\sseven(?:\s|-| |)(?:inch|\[\[inch\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (178 mm) $2'); txt.value=txt.value.replace(/([^ty]\seight(?:\s|-| |)(?:inch|\[\[inch\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (203 mm) $2'); txt.value=txt.value.replace(/([^ty]\snine(?:\s|-| |)(?:inch|\[\[inch\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (229 mm) $2'); txt.value=txt.value.replace(/([^ty]\sten(?:\s|-| |)(?:inch|\[\[inch\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (254 mm) $2'); txt.value=txt.value.replace(/([^ty]\seleven(?:\s|-| |)(?:inch|\[\[inch\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (279 mm) $2'); txt.value=txt.value.replace(/([^ty]\stwelve(?:\s|-| |)(?:inch|\[\[inch\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (305 mm) $2'); txt.value=txt.value.replace(/([^ty]\sthirteen(?:\s|-| |)(?:inch|\[\[inch\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (330 mm) $2'); txt.value=txt.value.replace(/([^ty]\sfourteen(?:\s|-| |)(?:inch|\[\[inch\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (356 mm) $2'); txt.value=txt.value.replace(/([^ty]\sfifteen(?:\s|-| |)(?:inch|\[\[inch\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (381 mm) $2'); txt.value=txt.value.replace(/([^ty]\ssixteen(?:\s|-| |)(?:inch|\[\[inch\]\]))([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 (406 mm) $2'); // horsepower txt.value=txt.value.replace(/\.28\s?(bhp|ihp|shp)\.29\|/gi, '($1)|'); txt.value=txt.value.replace(/(\d)(?:\s|-|)(horsepower|hp|bhp|ihp|shp)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 $2$3'); txt.value=txt.value.replace(/(\d) (horsepower|hp|bhp|ihp|shp)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 $2$3'); txt.value=txt.value.replace(/(\d)(?:\s|-|)horse(?:\s|-|)power([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 horsepower$2'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)(?:horsepower|\[\[horsepower\]\])([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|hp}}$3'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)(indicated(?:\s|-| |)horsepower)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|ihp}}$4'); txt.value=txt.value.replace(/([^\d\(\)\/\\]\s)(\d[\d,\.]{0,16})(?:\s|-| |)(hp|bhp|ihp|shp)([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1{{convert|$2|$3|abbr=on}}$4'); txt.value=txt.value.replace(/({convert\|\d{1,16}\|)horsepower\|/gi, '$1horsepower|'); txt.value=txt.value.replace(/({convert\|\d{1,16}\|)hp\|/gi, '$1hp|'); txt.value=txt.value.replace(/({convert\|\d{1,16}\|)bhp\|/gi, '$1bhp|'); txt.value=txt.value.replace(/({convert\|\d{1,16}\|)ihp\|/gi, '$1ihp|'); txt.value=txt.value.replace(/({convert\|\d{1,16}\|)shp\|/gi, '$1shp|'); // rpm txt.value=txt.value.replace(/(\d)\s?rpm([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 rpm$2'); txt.value=txt.value.replace(/(\d) rpm([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 rpm$2'); txt.value=txt.value.replace(/(\d)\-rpm([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 rpm$2'); // decibel txt.value=txt.value.replace(/(\d)\s?(dB)\b/g, '$1 $2'); // bits per second txt.value=txt.value.replace(/(\d)\s?([KkMmGgTt])?(?:bps|bits\/s|b\/s)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1 $2bit/s$3'); //txt.value=txt.value.replace(/(\d)\s?bps([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 bit/s$2'); txt.value=txt.value.replace(/(\d) ([KkMmGgTt])?(?:bps|bits\/s|b\/s)([:;,\.?!]?\s[^\d\(\)\/\\])/g, '$1 $2bit/s$3'); //txt.value=txt.value.replace(/(\d) bps([:;,\.?!]?\s[^\d\(\)\/\\])/gi, '$1 bit/s$2'); txt.value=txt.value.replace(/bits?\/sec([:;,\.?!]?\s[^\d\(\)\/\\])/gi, 'bit/s$1'); // bytes per second txt.value=txt.value.replace(/([KkMmGgTt])(?:Bps|bytes?\/s)([:;,\.?!]?\s[^\d\(\)\/\\])/g, ' $1byte/s$2'); txt.value=txt.value.replace(/bytes?\/s([:;,\.?!]?\s[^\d\(\)\/\\])/gi, 'byte/s$1'); // capitalization of prefix with bits and bytes txt.value=txt.value.replace(/K(bit|B|byte)\/s/g, 'k$1/s'); txt.value=txt.value.replace(/m(bit|B|byte)\/s/g, 'M$1/s'); txt.value=txt.value.replace(/g(bit|B|byte)\/s/g, 'G$1/s'); txt.value=txt.value.replace(/t(bit|B|byte)\/s/g, 'T$1/s'); // space with bits and bytes txt.value=txt.value.replace(/([^\w]\d)\s?(k|M|G|T)(bit|B)/g, '$1 $2$3'); //aviation specifications: unprotect 'main=' and 'alt=' txt.value=txt.value.replace(/((?:main|alt)\s?=\s?)xx(\d)/gi, '$1$2'); //change format of convert template variables txt.value=txt.value.replace(/({convert\|[^}]{1,16}km):h/g, '$1/h'); txt.value=txt.value.replace(/({convert\|[^}]{1,16}mi):h/g, '$1/h'); txt.value=txt.value.replace(/({convert\|[^}]{1,16}ft):s/g, '$1/s'); txt.value=txt.value.replace(/({convert\|[^}]{1,16}m):s/g, '$1/s'); //replace other templates with convert template txt.value=txt.value.replace(/{{mi\sto\skm\|(\d{1,9})}}/gi, '{{convert|$1|mi|km}}'); txt.value=txt.value.replace(/{{mi\sto\skm\|(\d{1,9})\|round[^\}]{1,5}}}/gi, '{{convert|$1|mi|km}}'); txt.value=txt.value.replace(/{{mi2\sto\skm2\|(\d{1,9})}}/gi, '{{convert|$1|mi|km}}'); txt.value=txt.value.replace(/{{mi2\sto\skm2\|(\d{1,9})\|round[^\}]{1,5}}}/gi, '{{convert|$1|mi|km}}'); //remove commas from numerical values in convert template txt.value=txt.value.replace(/({convert\|\d{1,16}),(\d)/g, '$1$2'); txt.value=txt.value.replace(/({convert\|\d{1,16}),(\d)/g, '$1$2'); txt.value=txt.value.replace(/({convert\|\d{1,16}),(\d)/g, '$1$2'); txt.value=txt.value.replace(/({convert\|\d{1,16}),(\d)/g, '$1$2'); txt.value=txt.value.replace(/({convert\|\d{1,16}),(\d)/g, '$1$2'); //remove leading zeros from convert template txt.value=txt.value.replace(/({convert\|)0(\d)/g, '$1$2'); txt.value=txt.value.replace(/({convert\|)0(\d)/g, '$1$2'); txt.value=txt.value.replace(/({convert\|)0(\d)/g, '$1$2'); //Remove surprise or 'Easter egg' diversions linking unit name to orders of magnitude articles txt.value=txt.value.replace(/\[\[1\s?_?E\s?[\-\+]?\d{1,2}\s?..?\|([^\]]{1,50})\]\]/gi, '$1'); txt.value=txt.value.replace(/\[\[Orders\sof\smagnitude\s\([^\)]{1,30}\)\|([^\]]{1,50})\]\]/gi, '$1'); } function run_dates() { var txt = document.editform.wpTextbox1; dates(); // Add a tag to the summary box var txt = document.editform.wpSummary; var summary = "Copyedited."; if (txt.value.indexOf(summary) == -1) { if (txt.value.match(/[^\*\/\s][^\/\s]?\s*$/)) { txt.value += " | "; } txt.value += summary; } // Press the diff button to check it document.editform.wpDiff.click() } addOnloadHook(function () { if(document.forms.editform) { addLink('p-cactions', 'javascript:run_dates()', 'dates', 'ca-unitfixer', 'Fixes some unit formatting', '', ''); } }); function run_formatgeneral() { var txt = document.editform.wpTextbox1; formatgeneral(); // Add a tag to the summary box var txt = document.editform.wpSummary; var summary = "Copyedited."; if (txt.value.indexOf(summary) == -1) { if (txt.value.match(/[^\*\/\s][^\/\s]?\s*$/)) { txt.value += " | "; } txt.value += summary; } // Press the diff button to check it document.editform.wpDiff.click() } addOnloadHook(function () { if(document.forms.editform) { addLink('p-cactions', 'javascript:run_formatgeneral()', 'units', 'ca-unitfixer', 'Fixes some unit formatting', '', ''); } }); function combined() { var txt = document.editform.wpTextbox1; formatgeneral(); dates(); // Add a tag to the summary box var txt = document.editform.wpSummary; var summary = "Copyedited."; if (txt.value.indexOf(summary) == -1) { if (txt.value.match(/[^\*\/\s][^\/\s]?\s*$/)) { txt.value += " | "; } txt.value += summary; } // Press the diff button to check it document.editform.wpDiff.click() } //PLEASE READ [[User:Milk's Favorite Cookie/comments]] before using this. //ONLY USE THIS FOR YOUR OWN COMMENTS - NOT ANYONE ELSE'S... function refbuttons() { if (mwCustomEditButtons) { var time = new Date(); var curday = time.getDate(); var curmonth = time.getMonth()+1; var nowyear = time.getYear()+1900; var nowday = curday.toString(); if (curday <10) { nowday = "0"+nowday;} var nowmonth = curmonth.toString(); if (curmonth <10) { nowmonth = "0"+nowmonth;} mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/commons/b/bc/Featured_article_star.svg", "speedTip": "Resolved Comments", "tagOpen": "{{hide|header={{{1|<includeonly>~~</includeonly>~~<noinclude><nowiki>~~</nowiki></noinclude>}}}|Content=", "tagClose": "}}", "sampleText": ""}; } } addOnloadHook(refbuttons); // For description, see [[User:Mr.Z-man/refbuttons]] function refbuttons() { if (mwCustomEditButtons) { var time = new Date(); var curday = time.getDate(); var curmonth = time.getMonth()+1; var nowyear = time.getYear()+1900; var nowday = curday.toString(); if (curday <10) { nowday = "0"+nowday;} var nowmonth = curmonth.toString(); if (curmonth <10) { nowmonth = "0"+nowmonth;} mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/commons/9/91/Button_cite_web.png", "speedTip": "Web citation", "tagOpen": "<ref>{{cite web |url= |title= |accessdate=" + nowyear + "-" + nowmonth + "-" + nowday + " |last= |first= |coauthors= |date= |work= |publisher=", "tagClose": "}}</ref>", "sampleText": ""}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/commons/2/2c/Button_cite_news.png", "speedTip": "News citation", "tagOpen": "<ref>{{cite news |first= |last= |authorlink= |coauthors= |title= |url= |work= |publisher= |date= |accessdate=" + nowyear + "-" + nowmonth + "-" + nowday, "tagClose": "}}</ref>", "sampleText": ""}; mwCustomEditButtons[mwCustomEditButtons.length] = { "imageFile": "http://upload.wikimedia.org/wikipedia/commons/e/ef/Button_cite_book.png", "speedTip": "Book citation", "tagOpen": "<ref>{{cite book |title= |last= |first= |authorlink= |coauthors= |year= |publisher= |location= |isbn=", "tagClose": "}}</ref>", "sampleText": ""}; } } addOnloadHook(refbuttons);

