বিষয়বস্তুতে চলুন

ব্যবহারকারী:রবি/common.js: সংশোধিত সংস্করণের মধ্যে পার্থক্য

ভারতপিডিয়া থেকে
রবি (আলোচনা | অবদান)
সম্পাদনা সারাংশ নেই
রবি (আলোচনা | অবদান)
সম্পাদনা সারাংশ নেই
ট্যাগ: মোবাইল সম্পাদনা মোবাইল ওয়েব সম্পাদনা উচ্চতর মোবাইল সম্পাদনা
 
(একই ব্যবহারকারী দ্বারা সম্পাদিত ২৯টি মধ্যবর্তী সংশোধন দেখানো হচ্ছে না)
১ নং লাইন: ১ নং লাইন:
/**
mw.loader.load('//bn.bharatpedia.org/index.php?title=ব্যবহারকারী:রবি/রোলব্যাক নিশ্চিতকারক.js&action=raw&ctype=text/javascript');
* AjaxQuickDelete from <https://commons.wikimedia.org/wiki/MediaWiki:Gadget-AjaxQuickDelete.js>
mw.loader.load('//commons.m.wikimedia.org/w/index.php?title=MediaWiki:Gadget-HotCat.js&action=raw&ctype=text/javascript');
*
* Changelog:
* - 2010: Created in 2010 by [[User:Ilmari Karonen]] as Ajax-based replacement for [[MediaWiki:Quick-delete-code.js]].
* - Rewritten by [[User:DieBuche]].
* - Botdetection and encoding fixer by [[User:Lupo]].
* - 2011-2012: Validation and further development [[User:Rillke]], 2011-2012.
* - 2018: dropped IE8 support.
*
* TODO:
* - Fix problems with moves of videos.
* - Support move of timed text for videos.
*
* This pages has automated validation on save. Interested? See [[:commons:Commons:User scripts/reports]].
*/
// <nowiki>


/* eslint indent:[error,tab,{outerIIFEBody:0}] */
$(document).ready(function() {
/* eslint-disable one-var, vars-on-top, camelcase, no-underscore-dangle, valid-jsdoc */
/* global $:false, mw:false, importScript:false */


( function () {
function customAlert(msg,duration){
'use strict';
var pageId = mw.config.get('wgArticleId');
var div = document.createElement('div');
div.style ='position: fixed; right:500px; top:100px;height:51px;padding-top:13px;width:300px;font-size:25px; display:block;border: solid 1px black;background-color:white';
div.innerHTML = "<center><img src='https://upload.wikimedia.org/wikipedia/commons/thumb/a/a1/Chulito_verde.jpg/21px-Chulito_verde.jpg'>"+"  "+msg+"</center>";
setTimeout(function() {
div.parentNode.removeChild(div);
},duration);
document.body.appendChild(div);};
var bnSpellChecker = function() {
$('#wpTextbox1').wikiEditor('addToToolbar', {
            'section': 'main',
            'group': 'insert',
            'tools': {
                'bnSpellChecker': {
                  label: 'বানান শুদ্ধি করুন',
                  type: 'button',
          icon: '//upload.wikimedia.org/wikipedia/commons/thumb/0/01/Lachit_SpellChecker.png/25px-Lachit_SpellChecker.png',
                  action: {
                        type: 'callback',
                        execute: function() {
                       
  getText = $('#wpTextbox1').val();
  x = getText.replace(/  +/g, " ");


// Guard against multiple inclusions
  //wiki special
if ( window.AjaxQuickDelete ) {
  x = x.replace(/\u09DF/g, 'য়');
return;
  x = x.replace(/{{ /g, '{{');
}
//  x = x.replace(/ডঃ/g, 'ড°');
  x = x.replace(/ঐতিয্য/g, 'ঐতিহ্য');
  x = x.replace(/নিম্নপ্রদত্ব/g, 'নিম্নপ্রদত্ত');
  x = x.replace(/কাহানি/g, 'কাহিনী');
  x = x.replace(/মনোনিত/g, 'মনোনীত');


var AQD,
  // From Dibya Dutta's Pratishapan
conf = mw.config.get( [
  x = x.replace(/৷/g, "।");
'wgArticleId',
  x = x.replace(/ ।/g, "।");
'wgCanonicalNamespace',
  x = x.replace(/ ৷/g, "।");
'wgCanonicalSpecialPageName',
  x = x.replace(/ \?/g, "?");
'wgCategories',
  x = x.replace(/ ॥/g, "॥");
'wgFormattedNamespaces',
  x = x.replace(/ !/g, "!");
'wgNamespaceNumber',
  x = x.replace(/ ;/g, ";");
'wgPageName',
  x = x.replace(/ ,/g, ',');
'wgRestrictionEdit',
  x = x.replace(/।।/g, '');
'wgUserGroups',
  x = x.replace(/৷৷/g, "॥");
'wgUserLanguage',
  x = x.replace(/াে/g, "ো");
'wgUserName',
  x = x.replace(/ো/g, "ো");
'wgIsRedirect'
  x = x.replace(/অাা/g, '');
] ),
  x = x.replace(/অা/g, 'আ');
nsNr = conf.wgNamespaceNumber,
  x = x.replace(/আা/g, 'আ');
pageName = conf.wgPageName;


// A bunch of helper functions
  //Lachit Spellchecker
function _firstItem( o ) {
    x = x.replace(/য়/g, 'য়');
for ( var i in o ) {
//  x = x.replace(/ন্ট/g, 'ণ্ট');
if ( Object.prototype.hasOwnProperty.call( o, i ) ) {
    x = x.replace(/থ্থ/g, 'ত্থ');
return o[ i ];
    x = x.replace(/ট্ন/g, 'ত্ন');
}
    x = x.replace(/ধ্ধ/g, 'দ্ধ');
}
    x = x.replace(/ন্ঠ/g, 'ণ্ঠ');
}
  //  x = x.replace(/ন্ড/g, 'ণ্ড');
    x = x.replace(/ণ্দ/g, 'ন্দ');
    x = x.replace(/ণ্ধ/g, 'ন্ধ');
    x = x.replace(/ন্ঢ/g, 'ণ্ঢ');
    x = x.replace(/ণ্ত/g, 'ন্ত');
    x = x.replace(/ণ্জ/g, 'ঞ্জ');
    x = x.replace(/ন্জ/g, 'ঞ্জ');
    x = x.replace(/ন্চ/g, 'ঞ্চ');
    x = x.replace(/ন্ছ/g, 'ঞ্ছ');
    x = x.replace(/ণ্চ/g, 'ঞ্চ');
    x = x.replace(/ণ্ছ/g, 'ঞ্ছ');
    x = x.replace(/ণ্স/g, 'ন্স');
    x = x.replace(/ষ্ন/g, 'ষ্ণ');
//  x = x.replace(/স্ট/g, 'ষ্ট'); (প্রতিবর্ণীতে ভুল ফলাফল দিচ্ছে)
    x = x.replace(/স্হ/g, 'স্থ');
    x = x.replace(/ষ্হ/g, 'স্থ');
    x = x.replace(/ন্হ/g, 'ন্থ');
    x = x.replace(/স্ঠ/g, 'ষ্ঠ');
    x = x.replace(/ঙঁ/g, 'ঙ');
    x = x.replace(/ঞঁ/g, 'ঞ');
    x = x.replace(/নঁ/g, 'ন');
    x = x.replace(/ণঁ/g, 'ণ');
    x = x.replace(/মঁ/g, 'ম');
    x = x.replace(/অা/g, 'আ');
    x = x.replace(/অাা/g, 'আ');
    x = x.replace(/অাা/g, 'আ');


$.ucFirst = function ( s ) {
return s[ 0 ].toUpperCase() + s.slice( 1 );
};


// Create the AjaxQuickDelete-singleton (object literal)
AQD = window.AjaxQuickDelete = {
// When maintaining this script always bump this number!
version: '1.1.3',
/**
* Runs before document ready and before translation is available
* (important event-binders should be attached as fast as possible)
*/
preinstall: function () {
// Promote our gadget when user opened old move page
if ( conf.wgCanonicalSpecialPageName === 'Movepage' && Number( $( 'select[name="wpNewTitleNs"]' ).val() ) === 6 ) {
$( '#mw-movepage-table' ).before(
'<div class="mw-message-box mw-message-box-warning">Consider using <i>Move & Replace</i> from the menu on file pages (open with a single click) when moving files to care for global usage and redirects.</div>'
);
}


this.doNothing = ( !conf.wgArticleId || nsNr < 0 || /^Commons:Deletion/.test( pageName ) );
    //crucial part starts
    // do not fiddle here
    //removes multiple question marks, exclamation


if ( this.doNothing ) {
    x = x.replace(/\?\?\?/g, '?'); //removes triple question marks with spaces
return;
    x = x.replace(/\?\?/g, '?'); //removed double question marks with spaces
}
    // x = x.replace(/!!!/g, '!'); //removes triple exclamation with spaces NOT FOR WIKI
    // x = x.replace(/!!/g, '!'); //removes double exclamation with spaces NOT FOR WIKI


// Check user group
    // crucial part ends
if ( conf.wgUserGroups.indexOf( 'sysop' ) !== -1 ) {
this.userRights = 'sysop';
} else if ( conf.wgUserGroups.indexOf( 'filemover' ) !== -1 ) {
this.userRights = 'filemover';
} else {
this.userRights = [ 'autopatrolled', 'patroller', 'image-reviewer' ].filter( function ( g ) {
return conf.wgUserGroups.indexOf( g ) !== -1;
} )[ 0 ];
}


if ( [ 'filemover', 'sysop' ].indexOf( this.userRights ) !== -1 && nsNr === 6 ) {
    // brings the question marks, exclamation, full stop before inverted comma
// Change "Move" to "Move & Replace"
    // new in Version 3.0
var $moveLink = $( '#ca-move' ),
//    x = x.replace(/"। /g, '।" ');  // ” = RIGHT DOUBLE QUOTATION MARK “ = LEFT DOUBLE QUOTATION MARK
$moveLanchor = $moveLink.find( 'a' );
    x = x.replace(/"\?/g, '?"');  // ” = RIGHT DOUBLE QUOTATION MARK “ = LEFT DOUBLE QUOTATION MARK
this.$moveLink = $moveLink = $moveLanchor.length ? $moveLanchor : $moveLink;
    x = x.replace(/"! /g, '!" '); // ” = RIGHT DOUBLE QUOTATION MARK “ = LEFT DOUBLE QUOTATION MARK


$moveLink.text( $moveLink.text() + ' & Replace' )
.attr( 'title', 'Click in order to ' + $moveLink.attr( 'title' ) + ' and replace usage. Default form though new tab.' )
.on( 'click', function ( e ) {
e.preventDefault();
AQD.moveFile();
} );
}
},
/**
* Set up the AjaxQuickDelete object and add the toolbox link.  Called via document.ready during page loading.
*/
install: function () {
// Disallow performing operations on empty or special pages
if ( this.doNothing ) {
return;
}


// Check edit restrictions and do not install anything if protected
    //corrects commonly mistaken words
if ( conf.wgRestrictionEdit && conf.wgRestrictionEdit.length &&
conf.wgUserGroups.indexOf( conf.wgRestrictionEdit[ 0 ] ) === -1 ) {
return;
}


// Trigger a jQuery event for other scripts that like to know
  x = x.replace(/অংক/g, 'অঙ্ক');
// when this script has loaded all translations and is ready to install
  x = x.replace(/অংকন/g, 'অঙ্কন');
$( document ).triggerHandler( 'scriptLoaded', [ 'AjaxQuickDelete' ] );
  x = x.replace(/অংকুর/g, 'অঙ্কুর');
  x = x.replace(/অংগ /g, 'অঙ্গ ');
  x = x.replace(/অংগন/g, 'অঙ্গন');
  x = x.replace(/অংগাংগী/g, 'অঙ্গাঙ্গি');
  x = x.replace(/অকল্যান/g, 'অকল্যাণ');
  x = x.replace(/অকারন/g, 'অকারণ');
  x = x.replace(/অগ্রগন্য/g, 'অগ্রগণ্য');
  x = x.replace(/অগ্রহায়ন/g, 'অগ্রহায়ণ');
  x = x.replace(/অচিন্ত/g, 'অচিন্ত্য');
  x = x.replace(/অচিন্ত্যনীয়/g, 'অচিন্তনীয়');
  x = x.replace(/অঞ্জলী/g, 'অঞ্জলি');
  x = x.replace(/অণ্বেষণ/g, 'অন্বেষণ');
  x = x.replace(/অতিথী/g, 'অতিথি');
  x = x.replace(/অতিব /g, 'অতীব ');
  x = x.replace(/অতিষ্ট/g, 'অতিষ্ঠ');
  x = x.replace(/অত্যাধিক/g, 'অত্যধিক');
  x = x.replace(/অত্যান্ত/g, 'অত্যন্ত');
  x = x.replace(/অদ্ভূত/g, 'অদ্ভুত');
  x = x.replace(/অদ্যপি/g, 'অদ্যাপি');
  x = x.replace(/অদ্যবদি/g, 'অদ্যাবধি');
  x = x.replace(/অধঃস্তন/g, 'অধস্তন');
  x = x.replace(/অধিকরন/g, 'অধিকরণ');
  x = x.replace(/অধীনস্ত/g, 'অধীনস্থ');
  x = x.replace(/অধ্যাবসায়/g, 'অধ্যবসায়');
  x = x.replace(/অধ্যায়ণ/g, 'অধ্যয়ন');
  x = x.replace(/অধ্যূষিত/g, 'অধ্যুষিত');
  x = x.replace(/অনিন্দসুন্দর/g, 'অনিন্দ্যসুন্দর');
  x = x.replace(/অনিষ্ঠ/g, 'অনিষ্ট');
  x = x.replace(/অনু /g, 'অণু ');
  x = x.replace(/অনুকুল/g, 'অনুকূল');
  x = x.replace(/অনুর্ধ্ব/g, 'অনূর্ধ্ব');
  x = x.replace(/অনুসঙ্গ/g, 'অনুষঙ্গ');
  x = x.replace(/অন্তঃসত্তা/g, 'অন্তসত্ত্বা');
  x = x.replace(/অন্তকরণ/g, 'অন্তঃকরণ');
  x = x.replace(/অন্তর্ভূক্ত/g, 'অন্তর্ভুক্ত');
  x = x.replace(/অন্তর্মুখি/g, 'অন্তর্মুখী');
  x = x.replace(/অন্যমনষ্ক/g, 'অন্যমনস্ক');
  x = x.replace(/অপসৃয়মান/g, 'অপসৃয়মাণ');
  x = x.replace(/অপাংক্তেয়/g, 'অপাঙ্‌ক্তেয়');
  x = x.replace(/অপেক্ষমান/g, 'অপেক্ষমাণ');
  x = x.replace(/অভিভুত/g, 'অভিভূত');
  x = x.replace(/অভিমুখি /g, 'অভিমুখী ');
  x = x.replace(/অভ্যন্তরিক/g, 'আভ্যন্তরিক');
  x = x.replace(/অভ্যস্থ/g, 'অভ্যস্ত');
  x = x.replace(/অমানুসিক/g, 'অমানুষিক');
  x = x.replace(/অমাবশ্যা/g, 'অমাবস্যা');
  x = x.replace(/অমিতাক্ষর/g, 'অমিত্রাক্ষর');
  x = x.replace(/অর্ধ্ব/g, 'অর্ধ');
  x = x.replace(/অর্পণা/g, 'অপর্ণা');
  x = x.replace(/অলংঘ/g, 'অলঙ্ঘ্য');
  x = x.replace(/অশিরিরী/g, 'অশরীরী');
  x = x.replace(/অসুয়া/g, 'অসূয়া');
  x = x.replace(/অস্তমান/g, 'অস্তায়মান');
  x = x.replace(/অহঃরহ/g, 'অহরহ');
  x = x.replace(/আঁড়াআড়ি/g, 'আড়াআড়ি');
  x = x.replace(/আঁড়িপাতা/g, 'আড়িপাতা');
  x = x.replace(/আকষ্কিক/g, 'আকস্মিক');
  x = x.replace(/আকাংখা/g, 'আকাঙ্ক্ষা');
  x = x.replace(/আকাবাকা/g, 'আঁকাবাঁকা');
  x = x.replace(/আকুতি/g, 'আকূতি');
  x = x.replace(/আকূল/g, 'আকুল');
  x = x.replace(/আক্রমন/g, 'আক্রমণ');
  x = x.replace(/আটপৌড়ে/g, 'আটপৌরে');
  x = x.replace(/আড়ষ্ঠ/g, 'আড়ষ্ট');
  x = x.replace(/আড়ৎ/g, 'আড়ত');
  x = x.replace(/আতংক/g, 'আতঙ্ক');
  x = x.replace(/আত্মস্যাৎ/g, 'আত্মসাৎ');
  x = x.replace(/আদ্যান্ত/g, 'আদ্যন্ত');
  x = x.replace(/আদ্র/g, 'আর্দ্র');
  x = x.replace(/আনবিক/g, 'আণবিক');
  x = x.replace(/আনুষাঙ্গিক/g, 'আনুষঙ্গিক');
  x = x.replace(/আপাতঃদৃষ্টে/g, 'আপাতদৃষ্টে');
  x = x.replace(/আপাততঃ/g, 'আপাতত');
  x = x.replace(/আপোষ/g, 'আপোস');
  x = x.replace(/আভ্যন্তরীণ/g, 'অভ্যন্তরীণ');
  x = x.replace(/আয়ত্ব/g, 'আয়ত্ত');
  x = x.replace(/আয়ত্বাধীন/g, 'আয়ত্তাধীন');
  x = x.replace(/আরাম্ভ/g, 'আরম্ভ');
  x = x.replace(/আলিংগন/g, 'আলিঙ্গন');
  x = x.replace(/আলোচ্যমান/g, 'আলোচ্য');
  x = x.replace(/আশংকা/g, 'আশঙ্কা');
  x = x.replace(/আশক্তি/g, 'আসক্তি');
  x = x.replace(/আশ্বস্থ/g, 'আশ্বস্ত');
  x = x.replace(/আস্তাকুঁড়/g, 'আঁস্তাকুড়');
  x = x.replace(/ইংগিত/g, 'ইঙ্গিত');
  x = x.replace(/ইতঃস্তত/g, 'ইতস্তত');
  x = x.replace(/ইতিপূর্বে/g, 'ইতঃপূর্বে');
  x = x.replace(/ইতিমধ্যে/g, 'ইতোমধ্যে');
  x = x.replace(/ইদানিং/g, 'ইদানীং');
  x = x.replace(/ইয়ত্বা/g, 'ইয়ত্তা');
  x = x.replace(/ইষ্ঠ/g, 'ইষ্ট');
  x = x.replace(/ইষৎ/g, 'ঈষৎ');
  x = x.replace(/ঈস্পিত/g, 'ঈপ্সিত');
  x = x.replace(/উচিৎ/g, 'উচিত');
  x = x.replace(/উচ্চৈস্বরে/g, 'উচ্চৈঃস্বরে');
  x = x.replace(/উচ্ছ্বল/g, 'উচ্ছল');
  x = x.replace(/উজ্বল/g, 'উজ্জ্বল');
  x = x.replace(/উত্তরন/g, 'উত্তরণ');
  x = x.replace(/উত্তরসুরী/g, 'উত্তরসূরি');
  x = x.replace(/উত্তলন/g, 'উত্তোলন');
  x = x.replace(/উত্যক্ত/g, 'উত্ত্যক্ত');
  x = x.replace(/উদীচি/g, 'উদীচী');
  x = x.replace(/উদ্দান/g, 'উদ্যান');
  x = x.replace(/উদ্দ্যোগ/g, 'উদ্যোগ');
  x = x.replace(/উদ্ধত্য/g, 'ঔদ্ধত্য');
  x = x.replace(/উদ্বিঘ্ন/g, 'উদ্বিগ্ন');
  x = x.replace(/উদ্ভিজ/g, 'উদ্ভিজ্জ');
  x = x.replace(/উদ্ভুত/g, 'উদ্ভূত');
  x = x.replace(/উনবিংশ/g, 'ঊনবিংশ');
  x = x.replace(/উপকুল/g, 'উপকূল');
  x = x.replace(/উপচার্য/g, 'উপাচার্য');
  x = x.replace(/উপরোক্ত/g, 'উপরিউক্ত');
  x = x.replace(/উপলক্ষ্য/g, 'উপলক্ষ');
  x = x.replace(/উভয়চর/g, 'উভচর');
  x = x.replace(/উর্ধ্ব/g, 'ঊর্ধ্ব');
  x = x.replace(/উর্মি/g, 'ঊর্মি');
  x = x.replace(/উশৃঙ্খল/g, 'উচ্ছৃঙ্খল');
  x = x.replace(/উষর/g, 'ঊষর');
  x = x.replace(/উহ্য/g, 'ঊহ্য');
  x = x.replace(/উৎকর্ষতা/g, 'উৎকর্ষ');
  x = x.replace(/ঊনিশ/g, 'উনিশ');
  x = x.replace(/এককৃত/g, 'একীকৃত');
  x = x.replace(/একনিষ্ট/g, 'একনিষ্ঠ');
  x = x.replace(/একভূত/g, 'একীভূত');
  x = x.replace(/একাধিক্রমে/g, 'একাদিক্রমে');
  x = x.replace(/এক্ষুণি/g, 'এক্ষুনি');
  x = x.replace(/এতদ্‌সঙ্গে/g, 'এতৎসঙ্গে');
  x = x.replace(/এতদ্‌সত্ত্বেও/g, 'এতৎসত্ত্বেও');
  x = x.replace(/এশিয় /g, 'এশীয় ');
  x = x.replace(/ঐকবদ্ধ/g, 'ঐক্যবদ্ধ');
  x = x.replace(/ঐক্যতা/g, 'একতা');
  x = x.replace(/ঐক্যতান/g, 'ঐকতান');
  x = x.replace(/ঐক্যমত/g, 'ঐকমত্য');
  x = x.replace(/ওতঃপ্রোত/g, 'ওতপ্রোত');
  x = x.replace(/ঔচিত্ত/g, 'ঔচিত্য');
  x = x.replace(/কংকণ/g, 'কঙ্কণ');
  x = x.replace(/কংকাল/g, 'কঙ্কাল');
  x = x.replace(/কচিৎ/g, 'ক্বচিৎ');
  x = x.replace(/কটুক্তি/g, 'কটূক্তি');
  x = x.replace(/কতৃক/g, 'কর্তৃক');
  x = x.replace(/কতৃত্ত্ব/g, 'কর্তৃত্ব');
  x = x.replace(/কতৃপক্ষ/g, 'কর্তৃপক্ষ');
  x = x.replace(/কথপোকথন/g, 'কথোপকথন');
  x = x.replace(/কদাচিত/g, 'কদাচিৎ');
  x = x.replace(/ কনা/g, ' কণা');
  x = x.replace(/কনিষ্ট/g, 'কনিষ্ঠ');
  x = x.replace(/কন্ঠশিল্পী/g, 'কণ্ঠশিল্পী');
  x = x.replace(/কন্ঠস্ত/g, 'কণ্ঠস্থ');
  x = x.replace(/কয়েদী/g, 'কয়েদি');
  x = x.replace(/করনিক/g, 'করণিক');
  x = x.replace(/কর্তী/g, 'কর্ত্রী');
  x = x.replace(/কর্মচারি/g, 'কর্মচারী');
  x = x.replace(/কলংক/g, 'কলঙ্ক');
  x = x.replace(/কলসী/g, 'কলসি');
  x = x.replace(/কল্যান/g, 'কল্যাণ');
  x = x.replace(/কল্যানীয়াষু/g, 'কল্যাণীয়াসু');
  x = x.replace(/কল্যানীয়েসু/g, 'কল্যাণীয়েষু');
  x = x.replace(/কষ্ঠি/g, 'কষ্টি');
  x = x.replace(/কাঁচ/g, 'কাচ');
  x = x.replace(/কাঁছাকাছি/g, 'কাছাকাছি');
  x = x.replace(/কাংখিত/g, 'কাঙ্খিত');
  x = x.replace(/কাকলী/g, 'কাকলি');
  x = x.replace(/কাচা/g, 'কাঁচা');
  x = x.replace(/কাতলা/g, 'কাৎলা');
  x = x.replace(/কার্যতঃ/g, 'কার্যত');
  x = x.replace(/কিংবদন্তী/g, 'কিংবদন্তি');
  x = x.replace(/কিম্বা/g, 'কিংবা');
  x = x.replace(/কুটনীতি/g, 'কূটনীতি');
  x = x.replace(/কুৎসিৎ/g, 'কুৎসিত');
  x = x.replace(/কূটিল/g, 'কুটিল');
  x = x.replace(/কৃচ্ছতা/g, 'কৃচ্ছ্রতা');
  x = x.replace(/কৃচ্ছসাধন/g, 'কৃচ্ছ্রসাধন');
  x = x.replace(/কৃষিজীবি/g, 'কৃষিজীবী');
  x = x.replace(/কৃষ্টিবান/g, 'কৃষ্টিমান');
  x = x.replace(/কেন্দ্রিয়/g, 'কেন্দ্রীয়');
  x = x.replace(/কেরাণী/g, 'কেরানি');
  x = x.replace(/কোণাকুণি/g, 'কোনাকুনি');
  x = x.replace(/কৌতুহল/g, 'কৌতূহল');
  x = x.replace(/কৌতূক/g, 'কৌতুক');
  x = x.replace(/ক্রুর/g, 'ক্রূর');
  x = x.replace(/ক্ষীয়মান/g, 'ক্ষীয়মাণ');
  x = x.replace(/ক্ষুন্ন/g, 'ক্ষুণ্ণ');
  x = x.replace(/ক্ষুব্দ/g, 'ক্ষুব্ধ');
  x = x.replace(/ক্ষেপন/g, 'ক্ষেপণ');
  x = x.replace(/ক্ষেপনাস্ত্র/g, 'ক্ষেপণাস্ত্র');
  x = x.replace(/খঞ্জনী/g, 'খঞ্জনি');
  x = x.replace(/খুটিনাটি/g, 'খুঁটিনাটি');
  x = x.replace(/খুড়ী/g, 'খুড়ি');
  x = x.replace(/খুশী/g, 'খুশি');
  x = x.replace(/খেতমজুর/g, 'ক্ষেতমজু');
  x = x.replace(/খেলাধূলা/g, 'খেলাধুলা');
  x = x.replace(/খেলোয়ার/g, 'খেলোয়াড়');
  x = x.replace(/খোজ/g, 'খোঁজ');
  x = x.replace(/খোলাখোলি/g, 'খোলাখুলি');
  x = x.replace(/গংগা/g, 'গঙ্গা');
  x = x.replace(/গগণ/g, 'গগন');
  x = x.replace(/গড্ডালিকা/g, 'গড্ডলিকা');
  x = x.replace(/গত্যান্তর/g, 'গত্যন্তর');
  x = x.replace(/ গন /g, ' গণ ');
  x = x.replace(/গননা/g, 'গণনা');
  x = x.replace(/গনিত/g, 'গণিত');
  x = x.replace(/গন্য /g, 'গণ্য ');
  x = x.replace(/গন্‌জ/g, 'গঞ্জ');
  x = x.replace(/গবেষনা/g, 'গবেষণা');
  x = x.replace(/গরীব/g, 'গরিব');
  x = x.replace(/গর্ধব/g, 'গর্ধভ');
  x = x.replace(/গাড়ী/g, 'গাড়ি');
  x = x.replace(/গার্হস্থ /g, 'গার্হস্থ্য ');
  x = x.replace(/গীর্জা/g, 'গির্জা');
  x = x.replace(/গুড়া/g, 'গুঁড়া');
  x = x.replace(/গুড়ো/g, 'গুঁড়ো');
  x = x.replace(/গুণে গুণে/g, 'গুনে গুনে');
  x = x.replace(/গৃহস্ত/g, 'গৃহস্থ');
  x = x.replace(/গৃহিত/g, 'গৃহীত');
  x = x.replace(/গোধুলি/g, 'গোধূলি');
  x = x.replace(/গোষ্ঠি/g, 'গোষ্ঠী');
  x = x.replace(/গোস্পদ/g, 'গোষ্পদ');
  x = x.replace(/গ্রন্থী/g, 'গ্রন্থি');
  x = x.replace(/গ্রহন/g, 'গ্রহণ');
  x = x.replace(/গ্রহিতা/g, 'গ্রহীতা');
  x = x.replace(/গ্রামীন/g, 'গ্রামীণ');
  x = x.replace(/গ্রীক/g, 'গ্রিক');
  x = x.replace(/গ্রীস/g, 'গ্রিস');
  x = x.replace(/ঘনিষ্ট/g, 'ঘনিষ্ঠ');
  x = x.replace(/ঘরণী/g, 'ঘরনি');
  x = x.replace(/ ঘাটি/g, ' ঘাঁটি');
  x = x.replace(/ঘুরাঘুরি/g, 'ঘোরাঘুরি');
  x = x.replace(/ঘুর্ণীয়মান/g, 'ঘূর্ণায়মান');
  x = x.replace(/ঘুর্নি/g, 'ঘূর্ণি');
  x = x.replace(/ঘুসখোর/g, 'ঘুষখোর');
  x = x.replace(/ঘূণ/g, 'ঘুণ');
  x = x.replace(/ঘোষনা/g, 'ঘোষণা');
  x = x.replace(/ঘ্রান/g, 'ঘ্রাণ');
  x = x.replace(/চত্তর/g, 'চত্বর');
  x = x.replace(/চরক/g, 'চড়ক');
  x = x.replace(/চাকরানী/g, 'চাকরানি');
  x = x.replace(/চাকরী/g, 'চাকরি');
  x = x.replace(/চাকুরী/g, 'চাকুরী');
  x = x.replace(/চাতুর্যতা/g, 'চাতুর্য');
  x = x.replace(/চীৎকার/g, 'চিৎকার');
  x = x.replace(/চুড়মার/g, 'চুরমার');
  x = x.replace(/চুড়ান্ত/g, 'চূড়ান্ত');
  x = x.replace(/চূষ্য/g, 'চোষ্য');
  x = x.replace(/চৌচিড়/g, 'চৌচির');
  x = x.replace(/ছাকনি/g, 'ছাঁকনি');
  x = x.replace(/ ছাকা/g, ' ছাঁকা');
  x = x.replace(/ছাত্রীবাস/g, 'ছাত্রীনিবাস');
  x = x.replace(/ছোওয়া/g, 'ছোঁয়া');
  x = x.replace(/ছোকড়া/g, 'ছোকরা');
  x = x.replace(/ছোটখাট /g, 'ছোটোখাটো ');
  x = x.replace(/ছোটাছোটি/g, 'ছোটাছুটি');
  x = x.replace(/জংগল/g, 'জঙ্গল');
  x = x.replace(/জগত/g, 'জগৎ');
  x = x.replace(/জঘণ্য/g, 'জঘন্য');
  x = x.replace(/জটীল/g, 'জটিল');
  x = x.replace(/জবানবন্দী/g, 'জবানবন্দি');
  x = x.replace(/জরুরী/g, 'জরুরি');
  x = x.replace(/জাগরুক/g, 'জাগরূক');
  x = x.replace(/জাতিয়/g, 'জাতীয়');
  x = x.replace(/জাতী /g, 'জাতি ');
  x = x.replace(/জাতীয়করন/g, 'জাতীয়করণ');
  x = x.replace(/জানুয়ারী/g, 'জানুয়ারি');
  x = x.replace(/জিনিষ/g, 'জিনিস');
  x = x.replace(/জীবীকা/g, 'জীবিকা');
  x = x.replace(/জেষ্ঠ্য/g, 'জ্যেষ্ঠ');
  x = x.replace(/জৈষ্ঠ্য/g, 'জ্যৈষ্ঠ');
  x = x.replace(/জ্বরাজীর্ণ/g, 'জরাজীর্ণ');
  x = x.replace(/টাকশাল/g, 'টাঁকশাল');
  x = x.replace(/টেঁকসই/g, 'টেকসই');
  x = x.replace(/ডাইনী/g, 'ডাইনি');
  x = x.replace(/তক্ষুণি/g, 'তক্ষুনি');
  x = x.replace(/তছরূপ/g, 'তছরুপ');
  x = x.replace(/তড়িত/g, 'তড়িৎ');
  x = x.replace(/ততক্ষণাৎ/g, 'তৎক্ষণাৎ');
  x = x.replace(/ততধিক/g, 'ততোধিক');
  x = x.replace(/তত্তজ্ঞান/g, 'তত্ত্বজ্ঞান');
  x = x.replace(/তত্তাবদায়ক/g, 'তত্ত্বাবধায়ক');
  x = x.replace(/তত্তাবধান/g, 'তত্ত্বাবধান');
  x = x.replace(/তদসংক্রান্ত/g, 'তৎসংক্রান্ত');
  x = x.replace(/তদানুসারে/g, 'তদনুসারে');
  x = x.replace(/তদ্রুপ/g, 'তদ্রূপ');
  x = x.replace(/তফাত/g, 'তফাৎ');
  x = x.replace(/তরংগ/g, 'তরঙ্গ');
  x = x.replace(/তরান্বিত/g, 'ত্বরান্বিত');
  x = x.replace(/তর্জনি/g, 'তর্জনী');
  x = x.replace(/তষ্কর/g, 'তস্কর');
  x = x.replace(/তাঁতী/g, 'তাঁতি');
  x = x.replace(/তাবত/g, 'তাবৎ');
  x = x.replace(/তিতীক্ষা/g, 'তিতিক্ষা');
  x = x.replace(/তিরষ্কার/g, 'তিরস্কার');
  x = x.replace(/ত্বরিৎ/g, 'ত্বরিত');
  x = x.replace(/ত্যজ্য/g, 'ত্যাজ্য');
  x = x.replace(/ত্রান/g, 'ত্রাণ');
  x = x.replace(/ত্রিভূজ/g, 'ত্রিভুজ');
  x = x.replace(/তৎবিষয়ক/g, 'তদ্বিষয়ক');
  x = x.replace(/থুত্থুরে/g, 'থুত্থুড়ে');
  x = x.replace(/দক্ষিন/g, 'দক্ষিণ');
  x = x.replace(/দণ্ডবত/g, 'দণ্ডবৎ');
  x = x.replace(/দরকারী/g, 'দরকারি');
  x = x.replace(/দরুণ/g, 'দরুন');
  x = x.replace(/দারিদ্রতা/g, 'দরিদ্রতা, দারিদ্র');
  x = x.replace(/দারুন/g, 'দারুণ');
  x = x.replace(/দিকভ্রান্ত/g, 'দিগভ্রান্ত');
  x = x.replace(/দিক্ষা/g, 'দীক্ষা');
  x = x.replace(/দিঘী/g, 'দিঘি');
  x = x.replace(/দীর্ঘসূত্রিতা/g, 'দীর্ঘসূত্রতা');
  x = x.replace(/দুতাবাস/g, 'দূতাবাস');
  x = x.replace(/দুরবীক্ষন/g, 'দূরবীক্ষণ');
  x = x.replace(/দুরাবস্থা/g, 'দুরবস্থা');
  x = x.replace(/দুষ /g, 'দোষ ');
  x = x.replace(/দুষ্কৃতীকারী/g, 'দুষ্কৃতকারী');
  x = x.replace(/দূরবীক্ষন/g, 'দূরবীক্ষণ');
  x = x.replace(/দূরবীণ/g, 'দূরবীন');
  x = x.replace(/দূরারোগ্য/g, 'দুরারোগ্য');
  x = x.replace(/দূরুহ/g, 'দুরূহ');
  x = x.replace(/দূর্গ/g, 'দুর্গ');
  x = x.replace(/দৃঢ়করণ/g, 'দৃঢ়ীকরণ');
  x = x.replace(/দৃষ্টিকোন/g, 'দৃষ্টিকোণ');
  x = x.replace(/দৃষ্ঠিভঙ্গি/g, 'দৃষ্টিভঙ্গি');
  x = x.replace(/দেদীপ্যমাণ/g, 'দেদীপ্যমান');
  x = x.replace(/দেরী/g, 'দেরি');
  x = x.replace(/দৈনতা/g, 'দীনতা, দৈন্য');
  x = x.replace(/দোষনীয়/g, 'দূষণীয়');
  x = x.replace(/দৌরাত্ম/g, 'দৌরাত্ম্য');
  x = x.replace(/দ্বন্দ/g, 'দ্বন্দ্ব');
  x = x.replace(/দ্বিতীয়তঃ/g, 'দ্বিতীয়ত');
  x = x.replace(/ধজা/g, 'ধ্বজা');
  x = x.replace(/ধরণ/g, 'ধরন');
  x = x.replace(/ধাধা/g, 'ধাঁধা');
  x = x.replace(/ধারন/g, 'ধারণ');
  x = x.replace(/ধারনা/g, 'ধারণা');
  x = x.replace(/ধুমপান/g, 'ধূমপান');
  x = x.replace(/ধুর্ত/g, 'ধূর্ত');
  x = x.replace(/ধুলি/g, 'ধূলি');
  x = x.replace(/ধুসর/g, 'ধূসর');
  x = x.replace(/ধূলা/g, 'ধুলা');
  x = x.replace(/ধ্বনী/g, 'ধ্বনি');
  x = x.replace(/ধ্বস/g, 'ধ্স');
  x = x.replace(/ধ্বস্তাধ্বস্তি/g, 'ধ্স্তাধস্তি');
  x = x.replace(/নচেত/g, 'নচেৎ');
  x = x.replace(/নচ্ছাড়/g, 'নচ্ছাড়');
  x = x.replace(/নবীণ/g, 'নবীন');
  x = x.replace(/নমষ্কার/g, 'নমস্কার');
  x = x.replace(/নিক্কন/g, 'নিক্বণ');
  x = x.replace(/নিন্দ্যনীয়/g, 'নিন্দনীয়');
  x = x.replace(/নিরব/g, 'নীরব');
  x = x.replace(/নিরস /g, 'নীরস ');
  x = x.replace(/নিরুপন/g, 'নিরূপণ');
  x = x.replace(/নিরোগ/g, 'নীরোগ');
  x = x.replace(/নির্দোষী/g, 'নির্দোষ');
  x = x.replace(/নির্ধনী/g, 'নির্ধন');
  x = x.replace(/নির্নয়/g, 'নির্ণয়');
  x = x.replace(/নিস্কাশন/g, 'নিষ্কাশন');
  x = x.replace(/নিস্প্রভ/g, 'নিষ্প্রভ');
  x = x.replace(/নিস্প্রয়োজন/g, 'নিষ্প্রয়োজন');
  x = x.replace(/নিহারীকা/g, 'নীহারিকা');
  x = x.replace(/নীচে/g, 'নিচে');
  x = x.replace(/নীজ/g, 'নিজ');
  x = x.replace(/নীরলস/g, 'নিরলস');
  x = x.replace(/নূন্যতম/g, 'ন্যূনতম');
  x = x.replace(/নৃসংশ/g, 'নৃশংস');
  x = x.replace(/নৈশব্দ্য/g, 'নৈঃশব্দ্য');
  x = x.replace(/ন্যয়/g, 'ন্যায়');
  x = x.replace(/ন্যয্য/g, 'ন্যায্য');
  x = x.replace(/পংক/g, 'পঙ্ক');
  x = x.replace(/পংক্তি/g, 'পঙক্তি');
  x = x.replace(/পক্ক/g, 'পক্ব');
  x = x.replace(/পড়শী/g, 'পড়শি');
  x = x.replace(/পড়াশুনা/g, 'পড়াশোনা');
  x = x.replace(/পথমধ্যে/g, 'পথিমধ্যে');
  x = x.replace(/পথিকৃত/g, 'পথিকৃৎ');
  x = x.replace(/পন্য /g, 'পণ্য ');
  x = x.replace(/পরবর্তীতে /g, 'পরবর্তীকালে ');
  x = x.replace(/পরমানু/g, 'পরমাণু');
  x = x.replace(/পরষ্পর/g, 'পরস্পর');
  x = x.replace(/পরাস্থ/g, 'পরাস্ত');
  x = x.replace(/পরিনাম/g, 'পরিণাম');
  x = x.replace(/পরিবহণ/g, 'পরিবহন');
  x = x.replace(/পরিমান/g, 'পরিমাণ');
  x = x.replace(/পরিষ্ফুট/g, 'পরিস্ফুট');
  x = x.replace(/পরিস্কার/g, 'পরিষ্কার');
  x = x.replace(/পশ্চাদপট/g, 'পশ্চাৎপট');
  x = x.replace(/পশ্চাদপদ/g, 'পশ্চাৎপদ');
  x = x.replace(/পশ্চাৎগামী/g, 'পশ্চাদগামী');
  x = x.replace(/পশ্চাৎভূমি/g, 'পশ্চাদভূমি');
  x = x.replace(/পারদর্শীতা/g, 'পারদর্শিতা');
  x = x.replace(/পারমানবিক/g, 'পারমাণবিক');
  x = x.replace(/পার্বন/g, 'পার্বণ');
  x = x.replace(/পালংক/g, 'পালঙ্ক');
  x = x.replace(/পাষান/g, 'পাষাণ');
  x = x.replace(/পিচাশ/g, 'পিশাচ');
  x = x.replace(/পিঠস্থান/g, 'পীঠস্থান');
  x = x.replace(/পিপিলিকা/g, 'পিপীলিকা');
  x = x.replace(/পুংখানুপুংখ/g, 'পুঙ্খানুপুঙ্খ');
  x = x.replace(/পুজা/g, 'পূজা');
  x = x.replace(/পুণবিবেচনা/g, 'পুনর্বিবেচনা');
  x = x.replace(/পুন্য/g, 'পুণ্য');
  x = x.replace(/পুরষ্কার/g, 'পুরস্কার');
  x = x.replace(/পুর্ন/g, 'পূর্ণ');
  x = x.replace(/পুস্করিনী/g, 'পুষ্করিণী');
  x = x.replace(/পূজো/g, 'পুজো');
  x = x.replace(/পূবালী/g, 'পুবালি');
  x = x.replace(/পূর্ণগঠন/g, 'পুনর্গঠন');
  x = x.replace(/পৈত্রিক/g, 'পৈতৃক');
  x = x.replace(/পোষাক/g, 'পোশাক');
  x = x.replace(/পৌনঃপৌনিক/g, 'পৌনঃপুনিক');
  x = x.replace(/পৌরহিত্য/g, 'পৌরোহিত্য');
  x = x.replace(/প্রজ্জলন/g, 'প্রজ্বলন');
  x = x.replace(/প্রজ্জলিত/g, 'প্রজ্বলিত');
  x = x.replace(/প্রণয়ণ/g, 'প্রণয়ন');
  x = x.replace(/প্রতিকুল/g, 'প্রতিকূল');
  x = x.replace(/প্রতিযোগীতা/g, 'প্রতিযোগিতা');
  x = x.replace(/প্রত্যয়ণ/g, 'প্রত্যায়ন');
  x = x.replace(/প্রথমতঃ/g, 'প্রথমত');
  x = x.replace(/প্রধানতঃ/g, 'প্রধানত');
  x = x.replace(/প্রনালী/g, 'প্রণালী');
  x = x.replace(/প্রনিধান/g, 'প্রণিধান');
  x = x.replace(/প্রবাহমাণ/g, 'প্রবাহমান');
  x = x.replace(/প্রবীন/g, 'প্রবীণ');
  x = x.replace(/প্রভুত/g, 'প্রভূত');
  x = x.replace(/প্রয়ান/g, 'প্রয়াণ');
  x = x.replace(/প্রশস্থ/g, 'প্রশস্ত');
  x = x.replace(/প্রসংগ/g, 'প্রসঙ্গ');
  x = x.replace(/প্রসংশা/g, 'প্রশংসা');
  x = x.replace(/প্রাংগন/g, 'প্রাঙ্গণ');
  x = x.replace(/প্রাণপন/g, 'প্রাণপণ');
  x = x.replace(/প্রানীজগৎ/g, 'প্রাণীজগৎ');
  x = x.replace(/প্রানীবিদ্যা/g, 'প্রাণীবিদ্যা');
  x = x.replace(/ফলতঃ/g, 'ফলত');
  x = x.replace(/ফলপ্রসু/g, 'ফলপ্রসূ');
  x = x.replace(/ফাল্গুণ/g, 'ফাল্গুন');
  x = x.replace(/ফেব্রুয়ারী/g, 'ফেব্রুয়ারি');
  x = x.replace(/বংগ/g, 'বঙ্গ');
  x = x.replace(/বনষ্পতি/g, 'বনস্পতি');
  x = x.replace(/বনিক/g, 'বণিক');
  x = x.replace(/বন্টন/g, 'বণ্টন');
  x = x.replace(/বন্দোপাধ্যায়/g, 'বন্দ্যোপাধ্যায়');
  x = x.replace(/বয়ষ্ক/g, 'বয়স্ক');
  x = x.replace(/বয়োকনিষ্ট/g, 'বয়ঃকনিষ্ঠ');
  x = x.replace(/বর্ণালী/g, 'বর্ণালি');
  x = x.replace(/বর্ত্তমান/g, 'বর্তমান');
  x = x.replace(/বর্ষন/g, 'বর্ষণ');
  x = x.replace(/বাঁশী/g, 'বাঁশি');
  x = x.replace(/বাকদত্তা/g, 'বাগদত্তা');
  x = x.replace(/বাঞ্চনীয়/g, 'বাঞ্ছনীয়');
  x = x.replace(/বাঞ্চা/g, 'বাঞ্ছা');
  x = x.replace(/ বাড়ী/g, ' বাড়ি');
  x = x.replace(/বাদুর/g, 'বাদুড়');
  x = x.replace(/বানিজ্য/g, 'বাণিজ্য');
  x = x.replace(/বিদ্যান/g, 'বিদ্বান');
  x = x.replace(/বিপদগ্রস্থ/g, 'বিপদগ্রস্ত');
  x = x.replace(/বিপদজনক/g, 'বিপজ্জনক');
  x = x.replace(/বিপনন/g, 'বিপণন');
  x = x.replace(/বিপনী/g, 'বিপণী');
  x = x.replace(/বিশ্বস্থ/g, 'বিশ্বস্ত');
  x = x.replace(/বিষ্ফোরণ/g, 'বিস্ফোরণ');
  x = x.replace(/বীভৎস্য/g, 'বীভৎস');
  x = x.replace(/বুদ্ধিজীবি/g, 'বুদ্ধজীবী');
//  x = x.replace(/বেশী/g, 'বেশি'); দ্ব্যর্থক শব্দ, দুটো ভিন্ন অর্থ প্রকাশ করে
  x = x.replace(/ব্যকরণ/g, 'ব্যাকরণ');
  x = x.replace(/ব্যপক/g, 'ব্যাপক');
  x = x.replace(/ব্যহত/g, 'ব্যাহত');
  x = x.replace(/ব্যাতিক্রম/g, 'ব্যতিক্রম');
  x = x.replace(/ব্যাথা/g, 'ব্যথা');
  x = x.replace(/ব্যাপি/g, 'ব্যাপী');
  x = x.replace(/ব্যাবধান/g, 'ব্যবধান');
  x = x.replace(/ব্যাবহার/g, 'ব্যবহার');
  x = x.replace(/ব্যাভিচার/g, 'ব্যভিচার');
  x = x.replace(/ব্যায় /g, 'ব্যয় ');
  x = x.replace(/ব্যার্থ/g, 'ব্যর্থ');
  x = x.replace(/ব্যুৎপত্তি/g, 'বুৎপত্তি');
  x = x.replace(/ব্রাক্ষণ/g, 'ব্রাহ্মণ');
  x = x.replace(/ভংগ/g, 'ভঙ্গ');
  x = x.replace(/ভংগী/g, 'ভঙ্গি');
  x = x.replace(/ভংগুর/g, 'ভঙ্গুর');
  x = x.replace(/ভনিতা/g, 'ভণিতা');
  x = x.replace(/ভবিষ্যৎবাণী/g, 'ভবিষ্যদ্বাণী');
  x = x.replace(/ভরনপোষণ/g, 'ভরণপোষণ');
  x = x.replace(/ভষ্ম/g, 'ভস্ম');
  x = x.replace(/ভাষ্কর/g, 'ভাস্কর');
  x = x.replace(/ভিখারী/g, 'ভিখারি');
  x = x.replace(/ভিরু/g, 'ভীরু');
  x = x.replace(/ভীড়/g, 'ভিড়');
  x = x.replace(/ভুড়ি/g, 'ভুঁড়ি');
  x = x.replace(/ভুতপূর্ব/g, 'ভূতপূর্ব');
  x = x.replace(/ভুমিষ্ট/g, 'ভূমিষ্ঠ');
  x = x.replace(/ভুয়সী/g, 'ভূয়সী');
  x = x.replace(/ভুরিভোজন/g, 'ভূরিভোজন');
  x = x.replace(/ভূবন/g, 'ভুবন');
  x = x.replace(/ভূয়া/g, 'ভুয়া');
  x = x.replace(/ভূল/g, 'ভুল');
  x = x.replace(/ভৌগলিক/g, 'ভৌগোলিক');
  x = x.replace(/ভ্রমন/g, 'ভ্রমণ');
  x = x.replace(/ভ্রাম্যমান/g, 'ভ্রাম্যমাণ');
  x = x.replace(/ভ্রুক্ষেপ/g, 'ভ্রূক্ষেপ');
  x = x.replace(/মজুরী/g, 'মজুরি');
  x = x.replace(/মণিষা/g, 'মনীষা');
  x = x.replace(/মনমালিন্য/g, 'মনোমালিন্য');
  x = x.replace(/মনিষী/g, 'মনীষী');
  x = x.replace(/মন্ত্রনালয়/g, 'মন্ত্রণালয়');
  x = x.replace(/ময়ুর/g, 'ময়ূর');
  x = x.replace(/মরুদ্যান/g, 'মরূদ্যান');
  x = x.replace(/মশারী/g, 'মশারি');
  x = x.replace(/মস্তিস্ক/g, 'মস্তিষ্ক');
  x = x.replace(/মহত্ত/g, 'মহত্ত্ব');
  x = x.replace(/মহামতী/g, 'মহামতি');
  x = x.replace(/মহামারি/g, 'মহামারী');
  x = x.replace(/মহিয়সী/g, 'মহীয়সী');
  x = x.replace(/ মাংশ /g, ' মাংস ');
  x = x.replace(/মানিক্য/g, 'মানিক');
  x = x.replace(/মাসী/g, 'মাসি');
  x = x.replace(/মাহাত্ম/g, 'মাহাত্ম্য');
  x = x.replace(/মিতালী/g, 'মিতালি');
  x = x.replace(/মিমাংসা/g, 'মীমাংসা');
  x = x.replace(/মিরিচিকা/g, 'মরীচিকা');
  x = x.replace(/মুখস্ত/g, 'মুখস্থ');
  x = x.replace(/মুঢ়/g, 'মূঢ়');
  x = x.replace(/মুত্র/g, 'মূত্র');
  x = x.replace(/মুদ্রন/g, 'মুদ্রণ');
  x = x.replace(/মুমুর্ষ/g, 'মুমূর্ষু');
  x = x.replace(/মুর্খ/g, 'মূর্খ');
  x = x.replace(/মুর্তি/g, 'মূর্তি');
  x = x.replace(/মুর্ধন্য/g, 'মূর্ধন্য');
  x = x.replace(/মুষ্ঠি/g, 'মুষ্টি');
  x = x.replace(/মুহুর্ত/g, 'মুহূর্ত');
  x = x.replace(/মুহূর্মুহু/g, 'মুহুর্মুহু');
  x = x.replace(/মুহ্যবান/g, 'মোহ্যমান/মুহ্যমান');
  x = x.replace(/মূখ্য/g, 'মুখ্য');
  x = x.replace(/মূল্যায়ণ/g, 'মূল্যায়ন');
  x = x.replace(/মৃয়মান/g, 'ম্রিয়মাণ');
  x = x.replace(/মোটামোটি/g, 'মোটামুটি');
  x = x.replace(/মৌনতা/g, 'মৌন');
  x = x.replace(/যক্ষা/g, 'যক্ষ্মা');
  x = x.replace(/যথেষ্ঠ/g, 'যথেষ্ট');
  x = x.replace(/যদ্যাপি/g, 'যদ্যপি');
  x = x.replace(/যন্ত্রনা/g, 'যন্ত্রণা');
  x = x.replace(/যাদুঘর/g, 'জাদুঘর');
  x = x.replace(/রংগ/g, 'রঙ্গ');
  x = x.replace(/রঙিণ/g, 'রঙিন');
  x = x.replace(/রঙ্গিণ/g, 'রঙ্গিন');
  x = x.replace(/রথি/g, 'রথী');
  x = x.replace(/রসায়ণ/g, 'রসায়ন');
  x = x.replace(/রাংগামাটি/g, 'রাঙ্গামাটি');
  x = x.replace(/রামায়ন/g, 'রামায়ণ');
  x = x.replace(/রাষ্ট্রিয়/g, 'রাষ্ট্রীয়');
  x = x.replace(/রূপায়ন/g, 'রূপায়ণ');
  x = x.replace(/রোপন/g, 'রোপণ');
  x = x.replace(/লংকা/g, 'লঙ্কা');
  x = x.replace(/লংঘন/g, 'লঙ্ঘন');
  x = x.replace(/লক্ষী/g, 'লক্ষ্মী');
  x = x.replace(/লক্ষ্যণীয়/g, 'লক্ষণীয়');
  x = x.replace(/লঘুকরণ/g, 'লঘূকরণ');
  x = x.replace(/লজ্জাষ্কর/g, 'লজ্জাকর');
  x = x.replace(/লবন/g, 'লবণ');
  x = x.replace(/লাইব্রেরী/g, 'লাইব্রেরি');
  x = x.replace(/লাবন্য/g, 'লাবণ্য');
  x = x.replace(/শংকর/g, 'শঙ্কর');
  x = x.replace(/শংকা/g, 'শঙ্কা');
  x = x.replace(/শংকিত/g, 'শঙ্কিত');
  x = x.replace(/শরীক/g, 'শরিক');
  x = x.replace(/শশাংক/g, 'শশাঙ্ক');
  x = x.replace(/শশুর/g, 'শ্বশুর');
  x = x.replace(/শশ্মান/g, 'শ্মশান');
  x = x.replace(/শাড়ী/g, 'শাড়ি');
  x = x.replace(/শাষণ/g, 'শাসন');
  x = x.replace(/শারীরীক/g, 'শারীরিক');
  x = x.replace(/শাশুড়ী/g, 'শাশুড়ি');
  x = x.replace(/শিক্ষাঙ্গন/g, 'শিক্ষাঙ্গণ');
  x = x.replace(/শিরচ্ছেদ/g, 'শিরশ্ছেদ');
  x = x.replace(/শিরধার্য/g, 'শিরোধার্য');
  x = x.replace(/শিরনাম/g, 'শিরোনাম');
  x = x.replace(/শিরমণি/g, 'শিরোমণি');
  x = x.replace(/শুভাকাংখী/g, 'শুভাকাঙ্খী');
  x = x.replace(/শুশ্রুষা/g, 'শুশ্রূষা');
  x = x.replace(/শূণ্য/g, 'শুন্য');
  x = x.replace(/শৃংখলা/g, 'শৃঙ্খলা');
  x = x.replace(/শ্বাশত/g, 'শাশ্বত');
  x = x.replace(/শ্রদ্ধাঞ্জলী/g, 'শ্রদ্ধাঞ্জলি');
  x = x.replace(/শ্রদ্ধাভাজনীয়/g, 'শ্রদ্ধাভাজন');
  x = x.replace(/শ্রদ্ধাষ্পদ/g, 'শ্রদ্ধাস্পদ');
  x = x.replace(/শ্রমজীবি/g, 'শ্রমজীবী');
  x = x.replace(/শ্রাবন/g, 'শ্রাবণ');
  x = x.replace(/শ্রীমতি/g, 'শ্রীমতী');
  x = x.replace(/শ্রেষ্ট/g, 'শ্রেষ্ঠ');
  x = x.replace(/ষষ্ট/g, 'ষষ্ঠ');
  x = x.replace(/ষষ্ঠদশ/g, 'ষোড়শ');
  x = x.replace(/সংগা/g, 'সংজ্ঞা');
  x = x.replace(/সংগী/g, 'সঙ্গী');
  x = x.replace(/সখ/g, 'শখ');
  x = x.replace(/সতীন/g, 'সতিন');
  x = x.replace(/সত্বেও/g, 'সত্ত্বেও');
  x = x.replace(/সত্যয়িত/g, 'সত্যায়িত');
  x = x.replace(/সদ্যজাত/g, 'সদ্যোজাত');
  x = x.replace(/সদ্যস্নাত/g, 'সদ্যঃস্নাত');
  x = x.replace(/সনাক্ত/g, 'শনাক্ত');
  x = x.replace(/সন্মান/g, 'সম্মান');
  x = x.replace(/সন্মানীত/g, 'সম্মানীত');
  x = x.replace(/সন্মুখ/g, 'সম্মুখ');
  x = x.replace(/সন্মেলন/g, 'সম্মেলন');
  x = x.replace(/সমীচিন/g, 'সমীচীন');
  x = x.replace(/সম্বরণ/g, 'সংবরণ');
  x = x.replace(/সম্বর্ধনা/g, 'সংবর্ধনা');
  x = x.replace(/সম্বলিত/g, 'সংবলিত');
  x = x.replace(/সরকারী/g, 'সরকারি');
  x = x.replace(/সরণী/g, 'সরণি');
  x = x.replace(/সরনী/g, 'সরণি');
  x = x.replace(/সর্বাঙ্গীন/g, 'সর্বাঙ্গীণ');
  x = x.replace(/সলজ্জিত/g, 'সলজ্জ');
  x = x.replace(/সশংকিত/g, 'সশঙ্ক');
  x = x.replace(/সহকারি/g, 'সহকারী');
  x = x.replace(/সাংগ/g, 'সাঙ্গ');
  x = x.replace(/সাক্ষাতকার/g, 'সাক্ষাৎকার');
  x = x.replace(/সাড়াশী/g, 'সাঁড়াশি');
  x = x.replace(/সাধারন/g, 'সাধারণ');
  x = x.replace(/সান্তনা/g, 'সান্ত্বনা');
  x = x.replace(/সামগ্রীক/g, 'সামগ্রিক');
  x = x.replace(/সৌখিন/g, 'শৌখিন');
  x = x.replace(/স্বচ্ছল/g, 'সচ্ছল');
  x = x.replace(/স্বরস্বতী/g, 'সরস্বতী');
  x = x.replace(/স্বস্ত্রীক/g, 'সস্ত্রীক');
  x = x.replace(/স্বাতন্ত্র/g, 'স্বাতন্ত্র্য');
  x = x.replace(/স্বাধীকার/g, 'স্বাধিকার');
  x = x.replace(/স্বায়ত্ত্বশাসন/g, 'স্বায়ত্তশাসন');
  x = x.replace(/স্মরন/g, 'স্মরণ');
  x = x.replace(/স্রোতঃস্বতী/g, 'স্রোতস্বতী');
  x = x.replace(/হীনমন্যতা/g, 'হীনম্মন্যতা');
  x = x.replace(/হৃদপিণ্ড/g, 'হৃৎপিণ্ড');
  x = x.replace(/হৃদস্পন্দন/g, 'হৃৎস্পন্দন');
  x = x.replace(/হৃৎরোগ/g, 'হৃদরোগ');


var link;
//added by YAHYA
// Set up toolbox link
    x = x.replace(/আঘাট/g, 'আঘাত');
if ( nsNr === 14 ) {
    x = x.replace(/সাংঘাটিক/g, 'সাংঘাতিক');
// In categories the discuss-category link
    x = x.replace(/আবিস্কার/g, 'আবিষ্কার');
link = mw.util.addPortletLink( 'p-tb', '#', this.i18n.toolboxLinkDiscuss, 't-ajaxquickdiscusscat' );
    x = x.replace(/আনুসংগিক/g, 'আনুষঙ্গিক');
if ( link ) {
    x = x.replace(/শীততাপ/g, 'শীতাতপ');
link.addEventListener( 'click', function ( e ) {
    x = x.replace(/অতীষ্ঠ/g, 'অতিষ্ঠ');
e.preventDefault();
    x = x.replace(/আষ্ফালন/g, 'আস্ফালন');
mw.loader.using( 'jquery.ui' ).then( function () {
    x = x.replace(/আয়ত্ব/g, 'আয়ত্ত');
AQD.discussCategory();
    x = x.replace(/ঐশ্চর্য/g, 'ঐশ্বর্য');
} );
    x = x.replace(/ক্রুটি/g, 'ত্রুটি');
} );
    x = x.replace(/অংকণ/g, 'অঙ্কন');
}
    x = x.replace(/কোরাণ/g, 'কোরান');
} else {
    x = x.replace(/খরছ/g, 'খরচ');
// On other pages, the nominate-for-deletion link
    x = x.replace(/আরো /g, 'আরও ');
link = mw.util.addPortletLink( 'p-tb', '#', this.i18n.toolboxLinkDelete, 't-ajaxquickdelete' );
    x = x.replace(/বাহ্যিক লিঙ্ক/g, 'বহিঃসংযোগ');
if ( link ) {
    x = x.replace(/বাহ্যিক লিংক/g, 'বহিঃসংযোগ');
link.addEventListener( 'click', function ( e ) {
e.preventDefault();
AQD.nominateForDeletion();
} );
}
}


// Install AjaxMoveButton for filemovers and administrators
//নতুন শব্দ এই লাইনের উপরে যোগ হবে।
if ( this.$moveLink ) {
// Change Move & Replace link to fully localized text
this.$moveLink.html( $( '<span>' ).text( this.i18n.dropdownMove ) );
// Add quicklinks to template
$( '#AjaxRenameLink' ).append( '<a href="javascript:AjaxQuickDelete.moveFile();">' + this.i18n.moveAndReplace + '</a>' )
.append( '<a href="javascript:AjaxQuickDelete.loadAndDeclineRequest(\'move\');" class="ajaxDeleteDeclineMove"><sup> ' + this.i18n.anyDecline + '</sup></a>' );
// Install x-To-DR. See [[Template:X-To-DR]]
$( '#mw-imagepage-content .convert-to-dr' )
.find( '.ctdr-btn-convert' ).on( 'click', this._convertToDR ).show().end()
// Currently filemover rights required
.find( '.ctdr-btn-remove' ).on( 'click', this._removeAnyTag ).show();
} else if ( this.userRights ) {
$( '#mw-imagepage-content .convert-to-dr .ctdr-btn-convert' ).on( 'click', this._convertToDR ).show();
}


// Install "Process Duplicates"-Link (either in template
    // wiki formatting
// or if no template was detected and MediaWiki found dupes, behind the link in the dupe-section)
  x = x.replace(/। </g, '।<');
if ( this.userRights === 'sysop' && nsNr === 6 ) {
  x = x.replace(/! -/g, '!-');
var dupeSection = $( '#AjaxDupeProcess' );
  x = x.replace(/“।/g, '।”');
if ( dupeSection.length ) {
  x = x.replace(/। ”/g, '।”');
dupeSection.append( $( '<a>', {
  x = x.replace(/! \|/g, '!|');
href: '#',
  x = x.replace(/! }/g, '!}');
text: this.i18n.processDupes,
  x = x.replace(/! !/g, '!!');
style: 'font-weight:bold',
  x = x.replace(/। "/g, '।" ');
click: function ( e ) {
  x = x.replace(/! "/g, '!" ');
e.preventDefault();
AQD.processDupes();
}
} ) ).show();
} else {
dupeSection = $( '#mw-imagepage-section-duplicates .mw-imagepage-duplicates' );
if ( dupeSection.length ) {
dupeSection.find( 'li:first' )
.append( $( '<span>', {
style: 'display:none',
id: 'AjaxDupeDestination',
text: dupeSection.find( 'a' ).attr( 'title' )
} ) )
.append( ' ', $( '<sup>' ).append( $( '<a>', {
href: '#',
text: '[' + this.i18n.processDupes + ']',
style: 'background:#CEB',
click: function ( e ) {
e.preventDefault();
AQD.processDupes();
}
} ) ) );
}
}
}
// Extra buttons
// Wait until the user's js was loaded and executed
mw.loader.using( 'user', function () {
if ( mw.user.options.get( 'gadget-QuickDelete' ) ) {
mw.loader.using( 'ext.gadget.QuickDelete' ).always( function () {
AQD.doInsertTagButtons();
} );
}
} );
},


/**
// some more formatting for bnwiki
* Ensure that all variables are in a good state
  x = x.replace(/ <ref>/g, '<ref>');
* You must call this method before doing anything!
  x = x.replace(/ <ref /g, '<ref ');
* TODO: Never override pageName, always clean task queue
  x = x.replace(/{{reflist/g, '{{সূত্র তালিকা');
*/
  x = x.replace(/{{Reflist/g, '{{সূত্র তালিকা');
initialize: function () {
  x = x.replace(/<\/references>/g, '{{সূত্র তালিকা}}');
pageName = conf.wgPageName;
this.tasks = [];
this.destination = undefined;
this.details = undefined;
this.declineReason = undefined;
this.notifyUser = true;
this.watchlist = 'preferences';
},


/**
  // fixing error
* If a file exists, exchange the messages (very hackish)
* so the user is prompted to choose another destination
* TODO: Develop an improved solution
*/
fileExists: function () {
this.i18n.moveDestination = this.i18n.moveOtherDestination;
this.moveFile();
},


/**
    x = x.replace(/বৈচিত্র/g, 'বৈচিত্র্য');
* For moving files
    x = x.replace(/বৈচিত্র্য্য/g, 'বৈচিত্র্য');
*/
    x = x.replace(/তামুল/g, 'তামোল');
moveFile: function () {
    x = x.replace(/ফূর্তি/g, 'স্ফূর্তি');
var o = this;
    x = x.replace(/স্ফুর্তি/g, 'স্ফূর্তি');
    x = x.replace(/স্স্স্ফূর্তি/g, 'স্ফূর্তি');
    x = x.replace(/স্স্ফূর্তি/g, 'স্ফূর্তি');
    x = x.replace(/নৈশব্দ/g, 'নৈঃশব্দ্য');
    x = x.replace(/নৈঃশব্দ/g, 'নৈঃশব্দ্য');
    x = x.replace(/নৈঃশব্দ্য্য্য/g, 'নৈঃশব্দ্য');
    x = x.replace(/নৈঃশব্দ্য্য/g, 'নৈঃশব্দ্য');
    x = x.replace(/নৈঃশব্দ্যতা/g, 'নৈঃশব্দ্য');
    x = x.replace(/বৈশিষ্ট্য্য/g, 'বৈশিষ্ট্য');
    x = x.replace(/নিরালস্য্য/g, 'নিরালস্য');
    x = x.replace(/দৈর্ঘ্য্য/g, 'দৈর্ঘ্য');
    x = x.replace(/কেচাঁ/g, 'কেঁচা');
    x = x.replace(/কেঁচাঁ/g, 'কেঁচা');
    x = x.replace(/অন্তঃসত্বা/g, 'অন্তঃসত্ত্বা');
    x = x.replace(/অন্তসত্তা/g, 'অন্তঃসত্ত্বা');
    x = x.replace(/অন্তঃসত্তা/g, 'অন্তঃসত্ত্বা');
    x = x.replace(/ন্দ্ব্ব/g, 'ন্দ্ব');
    x = x.replace(/ধ্ব্ব/g, 'ধ্ব');
    x = x.replace(/ত্ব্ব/g, 'ত্ব');
    x = x.replace(/ঁঁ/g, 'ঁ');
    x = x.replace(/মাননি\u09DF/g, 'মাননী\u09DF');
    x = x.replace(/মাননিয়/g, 'মাননীয়');
    x = x.replace(/বিদূষী/g, 'বিদুষী');
    x = x.replace(/বয়সীয়াল/g, 'বয়সিয়াল');
    x = x.replace(/রিস্কা/g, 'রিক্সা');
    //x = x.replace(/অনসুয়া/g, 'অনসূয়া');
    x = x.replace(/অনুসূয়া/g, 'অনসুয়া');
    x = x.replace(/মুমূর্ষুু/g, 'মুমূর্ষু');
    x = x.replace(/নিরবিচ্ছিন্ন/g, 'নিরবচ্ছিন্ন');
    x = x.replace(/ণ্ধ/g, 'ন্ধ');


o.initialize();
    // removes double space between anything
    x = x.replace(/  /g, ' '); // makes double space into one
    x = x.replace(/  /g, ' '); //makes triple space into one


mw.loader.using( [ 'jquery.ui' ] ).then( function () {
    x = x.replace(/য়/g, '\u09DF');
o.showProgress();


if ( $( '#AjaxRenameLink' ).length ) {
  $('#wpTextbox1').val(x);
o.possibleDestination = $( '#AjaxRenameDestination' ).text();
    customAlert('বানান শুদ্ধি সম্পন্ন!','3000');
o.possibleReason = o.cleanReason( $( '#AjaxRenameReason' ).text() );
                        }
}
                    }
                }
            }
        });


// Let's be sure we have a fresh token and the latest MIME-Info
    };
o.addTask( 'getMoveToken' );
   
/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar … */
    if ($.inArray(mw.config.get('wgAction'), ['edit', 'submit']) !== -1) {
        $.when(mw.loader.using('ext.wikiEditor'), $.ready)
            .then(bnSpellChecker);
    }
});


var linkstoimage = $( '#mw-imagepage-section-linkstoimage' );
if ( $( '#globalusage' ).length || (
linkstoimage.length &&
linkstoimage.find( 'a' ).not( '.mw-redirect' ).length -
linkstoimage.find( '.mw-imagepage-linkstoimage-ns2 a[href^="/wiki/User:OgreBot/Uploads"]' ).length
) ) {
o.inUse = true;
o.addTask( 'chkPreMoveDecline' );
}


o.addTask( 'promptForMoveTarget' );
// This script aligns dates into one of two formats allowed by [[WP:MOSNUM]].
// PLEASE READ THE DOCUMENTATION at [[User:Ohconfucius/script/MOSNUM dates]] (click on the link above) before using.


o.addTask( 'doesFileExist' );
// Feedback and constructive criticism are welcome
o.fileNameExistsCB = 'fileExists';
o.addTask( 'movePage' );
o.addTask( 'removeTemplate' );
o.addTask( 'queryRedirects' );
o.addTask( 'replaceUsage' );


// finally reload the page to show changed page
/**
o.addTask( 'reloadPage' );
* TemplateScript adds configurable templates and scripts to the sidebar, and adds an example regex editor.
 
* @see https://meta.wikimedia.org/wiki/TemplateScript
o.nextTask();
*/
} );
// <pre>
},
if ($.inArray(mw.config.get('wgAction'), ['edit', 'submit']) !== -1) {
 
$.ajax(
promptForMoveTargetCB: function ( AQD ) {
'//tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js',
if ( AQD.inUse ) {
{dataType: 'script', cache: true}
$( '#AjaxQuestion2' ).prop( 'disabled', true );
).done(function () {
}
$.when(
},
mw.loader.using(['mediawiki.util']),
 
$.ajax('//en.wikipedia.org/w/index.php?title=User:Ohconfucius/script/MOSNUM_utils.js&action=raw&ctype=text/javascript',
promptForMoveTarget: function () {
{dataType: 'script', cache: true}),
var toAppend;
$.ready
this.showProgress();
).done(function () {
var add = function() {
            return mw.util.addPortletLink.apply(mw.util, arguments);
};


if ( mw.user.options.get( 'gadget-RenameLink' ) ) {
$(add('p-tb', '#', 'DATES to dmy', 'dmy-unitfixer', 'Align all dates to dmy', '', '')).click(ohc_all_to_dmy_driver);
toAppend = [ $( '<a>' )
$(add('p-tb', '#', 'DATES to mdy', 'mdy-unitfixer', 'Align all dates to mdy', '', '')).click(ohc_all_to_mdy_driver);
.text( this.i18n.moreInformation )
// $(add('p-tb', '#', 'Expand ref dates', 't-expandref', 'Expand month names within refs', '', '')).click(ohc_expand_ref_dates_driver);
.on( 'click', function () {
// $(add('p-tb', '#', 'Expand all dates', 't-expandall', 'Expand month names throughout', '', '')).click(ohc_expand_all_dates_driver);
if ( !AQD.rGetPolicy ) {
$( add('p-tb', '#', 'US-slash dates', 't-US', 'US-slash', '', '') ).click(ohc_US_slash_dates_driver);
importScript( 'MediaWiki:RenameRequest.js' );
$( add('p-tb', '#', 'UK-slash dates', 't-UK', 'UK-slash', '', '') ).click(ohc_UK_slash_dates_driver);
mw.hook( 'aqd.renamerequest.i18n' ).fire();
});
}
});
mw.hook( 'aqd.renamerequest.run' ).fire( { exec: this } );
}
} ).button( {
icons: { primary: 'ui-icon-script' },
showLabel: true,
text: false
} ).css( {
fontSize: '.6em',
margin: '0',
width: '2.5em',
'float': 'right'
} ), '<br>' ];
}
mw.hook( 'aqd.prompt' ).remove( this.promptForMoveTargetCB ).add( this.promptForMoveTargetCB );


this.prompt( [ {
function ohc_fix_unambiguous_dates()
message: this.i18n.moveDestination,
{
prefill: this.cleanFileName( this.possibleDestination || pageName ),
// resolvable ambiguous date formats
returnvalue: 'destination',
// UK style
appendNode: toAppend,
ohc_regex(/([^-\w/:\.])@DD\.@MM\.@YYYY(?=[^-–/\w&])/gi, "$1@Day @Month @YYYY", function(d) {
cleanUp: true,
if (d.d == d.m) return true;
noEmpty: true
if (d.d > 12) return true;
}, {
return false;
message: this.i18n.reasonForMove,
});
prefill: ( ( this.reason || this.possibleReason || '' ).trim().replace( /'{2,}/g, '' ).replace( /\s{2,}/g, ' ' ) ),
ohc_regex(/([^-\w/:\.])@DD\/@MM\/@YYYY(?=[^-–/\w&])/gi, "$1@Day @Month @YYYY", function(d) {
returnvalue: 'reason',
if (d.d == d.m) return true;
cleanUp: true,
if (d.d > 12) return true;
noEmpty: false
return false;
}, {
});
message: this.i18n.leaveRedirect,
prefill: true,
returnvalue: 'wpLeaveRedirect',
// cleanUp: false,
noEmpty: false,
type: 'checkbox'
}, {
message: this.i18n.useCORSForReplace,
prefill: !window.aqdCORSOptOut,
returnvalue: 'replaceUsingCORS',
// cleanUp: false,
noEmpty: false,
type: 'checkbox'
}
], this.i18n.movingFile );
},
 
/* Warn other filemovers */
chkPreMoveDecline: function () {
$( '#mw-imagepage-section-linkstoimage' ).find( 'a' ).each( function () {
if ( $( this ).text() === 'Commons:File renaming/Recently declined rename requests' ) {
// eslint-disable-next-line no-alert
alert( AQD.i18n.warnRename );
return false;
}
} );
this.nextTask();
},
 
/**
* For loading jquery UI to decline a request
*/
loadAndDeclineRequest: function ( reason ) {
var that = this;
mw.loader.using('jquery.ui').then(function () {
that.declineRequest.call( that, reason );
} );
},


/**
// US style
* For declining a request
ohc_regex(/([^-\w/:\.])@MM\.@DD\.@YYYY(?=[^-–/\w&])/gi, "$1@Month @Day, @YYYY", function(d) {
*/
if (d.d > 12) return true;
declineRequest: function ( reason ) {
return false;
reason = reason || this.declineReason;
});
// No valid reason stated, see the rename guidelines or not an exact duplicate
ohc_regex(/([^-\w/:\.])@MM\/@DD\/@YYYY(?=[^-–/\w&])/gi, "$1@Month @Day, @YYYY", function(d) {
this.initialize();
if (d.d > 12) return true;
return false;
});
}


this.addTask( 'getMoveToken' );
function ohc_US_slash_dates_to_mdy()
this.addTask( 'removeTemplate' );
{
//ranges
ohc_regex(/([^-\d/:\.])@MM\/@DD\/@YYNN(&nbsp;|\s)?(?:(?:[-–—]|&[mn]dash;)(?:&nbsp;|\s)?)@MM\/@DD\/@YYNN(?=[^-–/\w&])/gi, "$1@Mon1 @Day1, @Year1$2 – @Mon2 @Day2, @Year2");
ohc_regex(/([^-\d/:\.])@MM\.@DD\.@YYNN(&nbsp;|\s)?(?:(?:[-–—]|&[mn]dash;)(?:&nbsp;|\s)?)@MM\.@DD\.@YYNN(?=[^-–/\w&])/gi, "$1@Mon1 @Day1, @Year1$2 – @Mon2 @Day2, @Year2");
ohc_regex(/(\| ?)@MM\/@DD\/@YYNN(&nbsp;|\s)?(?:(?:[-–—]|&[mn]dash;)(?:&nbsp;|\s)?)@MM\/@DD\/@YYNN(?=\s*\|)/gi, "$1@Mon1 @Day1, @Year1$2 – @Mon2 @Day2, @Year2");
ohc_regex(/(\| ?)@MM\.@DD\.@YYNN(&nbsp;|\s)?(?:(?:[-–—]|&[mn]dash;)(?:&nbsp;|\s)?)@MM\.@DD\.@YYNN(?=\s*\|)/gi, "$1@Mon1 @Day1, @Year1$2 – @Mon @Day2, @Year2");


// finally reload the page to show the template was removed
// resolvable ambiguous date formats
this.addTask( 'reloadPage' );
ohc_regex(/([^-\d/:\.])@MM\/@DD\/@YYNN(?=[^-–/\w&])/gi, '$1@Month @Day, @YYYY');
 
ohc_regex(/([^-\d/:\.])@MM\.@DD\.@YYNN(?=[^-–/\w&])/gi, '$1@Month @Day, @YYYY');
// TODO extend the reason (for summary)
ohc_regex(/([^-\d/:\.])@MM[-–]@DD[-–]@YYNN(?=[^-–/\w&])/gi, '$1@Month @Day, @YYYY');
switch ( reason ) {
ohc_regex(/(\| ?)@MM\/@DD\/@YYNN(?=\s*\|)/gi, '$1@Month @Day, @YYYY');
case 'move':
ohc_regex(/(\| ?)@MM\.@DD\.@YYNN(?=\s*\|)/gi, '$1@Month @Day, @YYYY');
reason = 'rename request declined: does not comply with [[COM:FR|renaming guidelines]]';
// ohc_regex(/(\| ?)@MM[-–]@DD[-–]@YYNN(?=\s*\|)/gi, '$1@Month @Day, @YYYY');
if ( window.AjaxDeclineMoveWatchFile ) {
}
this.watchlist = 'watch';
}
function ohc_UK_slash_dates_to_dmy()
break;
{
}
//ranges
ohc_regex(/([^-\d/:\.])@DD\/@MM\/@YYNN(&nbsp;|\s)?(?:(?:[-–—]|&[mn]dash;)(?:&nbsp;|\s)?)@DD\/@MM\/@YYNN(?=[^-–/\w&])/gi, "$1@Day1 @Mon1 @Year1$2 – @Day2 @Mon2 @Year2");
ohc_regex(/([^-\d/:\.])@DD\.@MM\.@YYNN(&nbsp;|\s)?(?:(?:[-–—]|&[mn]dash;)(?:&nbsp;|\s)?)@DD\.@MM\.@YYNN(?=[^-–/\w&])/gi, "$1@Day1 @Mon1 @Year1$2 – @Day2 @Mon2 @Year2");
ohc_regex(/(\| ?)@DD\/@MM\/@YYNN(&nbsp;|\s)?(?:(?:[-–—]|&[mn]dash;)(?:&nbsp;|\s)?)@DD\/@MM\/@YYNN(?=\s*\|)/gi, "$1@Day1 @Mon1 @Year1$2 – @Day2 @Mon2 @Year2");
ohc_regex(/(\| ?)@DD\.@MM\.@YYNN(&nbsp;|\s)?(?:(?:[-–—]|&[mn]dash;)(?:&nbsp;|\s)?)@DD\.@MM\.@YYNN(?=\s*\|)/gi, "$1@Day1 @Mon1 @Year1$2 – @Day2 @Mon2 @Year2");


this.prompt( [ {
// resolvable ambiguous date formats
message: '',
ohc_regex(/([^-\d/:\.])@DD\/@MM\/@YYNN(?=[^-–/\w&])/gi, '$1@Day @Month @YYYY');
prefill: reason || '',
ohc_regex(/([^-\d/:\.])@DD\.@MM\.@YYNN(?=[^-–/\w&])/gi, '$1@Day @Month @YYYY');
returnvalue: 'declineReason',
ohc_regex(/([^-\d/:\.])@DD[-–]@MM[-–]@YYNN(?=[^-–/\w&])/gi, '$1@Day @Month @YYYY');
cleanUp: false,
ohc_regex(/(\| ?)@DD\/@MM\/@YYNN(?=\s*\|)/gi, '$1@Day @Month @YYYY');
noEmpty: true,
ohc_regex(/(\| ?)@DD\.@MM\.@YYNN(?=\s*\|)/gi, '$1@Day @Month @YYYY');
byteLimit: 250
// ohc_regex(/(\| ?)@DD[-–]@MM[-–]@YYNN(?=\s*\|)/gi, '$1@Day @Month @YYYY');
} ], this.i18n.declineRequest );
}


},
function ohc_remove_leading_zeroes()
 
{
// This method is generlaly used directly by user scripts without going
ohc_regex(/(\D[^\w\/])@Month\s@ZD@th?,?\s@YYYY(?=\W\D)/gi, "$1@LMonth @Day, @LYear");
// through other methods or setup functions. Needs to be standalone,
ohc_regex(/(\D[^\w\/])@Month\s@ZD@th?(?=\W\D)/gi, "$1@LMonth @Day");
// and ensures loading of its own dependencies.
ohc_regex(/(\D[^\w\/])@ZD@th?\s@Month\s@YYYY(?=\W\D)/gi, "$1@Day @LMonth @LYear");
insertTagOnPage: function ( tag, img_summary, talk_tag, talk_summary, prompt_text, page, optin_notify ) {
ohc_regex(/(\D[^\w\/])@ZD@th?\s@Month(?=\W\D)/gi, "$1@Day @LMonth");
var o = this;
}
this.initialize();
 
mw.loader.using( [ 'jquery.ui' ], function () {
o.pageName = ( page || pageName ).replace( /_/g, ' ' );
o.tag = tag.replace( '%USER%', conf.wgUserName ) + '\n';
o.img_summary = img_summary;
 
// first schedule some API queries to fetch the info we need…
// get token
o.addTask( 'findCreator' );
o.addTask( 'prependTemplate' );


if ( o.isMobile() && /(?:copyvio|nsd|npd|nld)/.test( tag ) ) {
function ohc_delink_dates()
o.addTask( 'listMobileUploadSpeedy' );
{
}
//add missing space between wikilinks
regex(/(\]\])(\[\[)/gi, '$1 $2');  //remove (?!file:) to ensure a space between all links
// rem redundant quote marks and parentheses
regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)\'\'\'([^|}\[\]]*)\'\'\'(?=\s*[|}])/gi, "$1$2");
regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)\'\'([^|}\[\]]*)\'\'(?=\s*[|}])/gi, "$1$2");
regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)\"([^|}\[\]]*)\"(?=\s*[|}])/gi, "$1$2");
regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)\(([^|}\[\]]*)\)(?=\s*[|}])/gi, "$1$2");


var prompt = [];
//delink unpiped dates
//delink full dates
ohc_regex(/\[\[@Day[\s_](?:of[\s_])?@Month(?:\]\]\s?\[\[\| )@YYYY\]\]/gi, "@Day @LMonth @YYYY");
ohc_regex(/\[\[@Month (?:the\s)?@Day(?:\]\],? \[\[|, )@YYYY\]\]/gi, "@LMonth @Day, @YYYY");


// Cave: insertTagOnPage is inserted as javascript link and therefore talk_tag can be "undefined"/string
//delink yyyy-mm-dd dates
if ( talk_tag && talk_tag !== 'undefined' ) {
ohc_regex(/\[\[@YYYY(?:\]\]-\[\[|-)@MM-@DD\]\]/gi, "@YYYY-@MM-@DD");
o.talk_tag = talk_tag.replace( '%FILE%', o.pageName );
ohc_regex(/@YYYY-\[\[@MM-@DD\]\]/gi, "@YYYY-@MM-@DD");
o.talk_summary = talk_summary.replace( '%FILE%', '[[:' + o.pageName + ']]' );


o.usersNeeded = true;
//underscore and nbsp in linked dates
ohc_regex(/\[\[@DD@th?(?:\s|_|&nbsp;)@Month\]\]/gi, "@Day @LMonth");
ohc_regex(/\[\[@Month(?:\s|_|&nbsp;)@DD@th?\]\]@th?/gi, "@LMonth @Day"); //consolidated regex with flexible removal of ordinal simple date
ohc_regex(/\[\[@Day @Month\]\]/gi, "@Day @LMonth");
ohc_regex(/\[\[@Month @YYYY\]\]/gi, "@LMonth @YYYY");
ohc_regex(/\[\[@YYYY\]\]/gi, "@YYYY");


prompt.push( {
//remove leading zero and links from linked date
message: o.i18n.notifyUser,
ohc_regex(/\[\[@Month(?:[ _]|&nbsp;)@ZD@th\]\]/gi, "@LMonth @Day");
prefill: true,
ohc_regex(/\[\[@ZD@th(?:[ _]|&nbsp;)@Month\]\]/gi, "@Day @LMonth");
returnvalue: 'notifyUser',
type: 'checkbox'
} );
o.addTask( 'notifyUploaders' );
}
o.addTask( 'reloadPage' );


if ( tag.indexOf( '%PARAMETER%' ) !== -1 ) {
// remove nowrap template from dm and md dates
prompt.push( {
ohc_regex(/(date[ ]*=[ ]*)\{\{(?:j|no ?(?:break|wrap))\|(?:@DD(?:[ _]|&nbsp;)@Month)( @yyyy|)\}\}/gi, '$1@DD @LMonth$2');
message: '',
ohc_regex(/(date[ ]*=[ ]*)\{\{(?:j|no ?(?:break|wrap))\|(?:@Month(?:[ _]|&nbsp;)@DD)( @yyyy|)\}\}/gi, '$1@LMonth @DD$2');
prefill: '',
returnvalue: 'reason',
//delink single dm or 'dth the m'
cleanUp: true,
ohc_regex(/(?:the\s)?\[\[@Day@th?[\s_](?:of[\s_])?@Month\]\]/gi, "@Day @LMonth");
noEmpty: true,
//delink single md or 'm the dth'
minLength: 1
ohc_regex(/\[\[@Month[\s_](?:the[\s_])?@Day@th?\]\](?=\W)/gi, "@LMonth @Day");
} );


o.prompt( prompt, prompt_text || o.i18n.reasonForDeletion );
//month+day piped
} else if ( optin_notify && prompt.length && o.talk_summary ) {
ohc_regex(/\[\[(?:@dd@th?[\s_](?:of[\s_])?@month|@month[\s_]@dd@th?)\|((?:@month |)@day)@th?\]\]/gi, "$1");
o.prompt( prompt, o.talk_summary );
ohc_regex(/\[\[(?:@dd@th?[\s_](?:of[\s_])?@month|@month[\s_]@dd@th?)\|@Day@th?[\s_](@month|)\]\]/gi, "@Day $1");
} else {
o.nextTask();
}
} );
},


discussCategory: function () {
// ohc_regex(/\[\[@month @dd(?:#[^|]+|)\|([^|\]]+)@th?\]\]/gi, "$1");
// reset task list in case an earlier error left it non-empty
// ohc_regex(/\[\[@dd @month(?:#[^|]+|)\|([^|\]]+)@th?\]\]/gi, "$1");
this.initialize();
ohc_regex(/\[\[@month @yyyy(?:#[^|]+|)\|([^|\]]+)\]\]/gi, "$1");


this.pageName = pageName.replace( /_/g, ' ' );
//month+day+year pseudo-ISO dates
this.startDate = new Date();
ohc_regex(/\[\[@Month @DD\|\d\d-\d\d\]\]-(?:\[\[)?(?:@yyyy[^|]*\|)?@YYYY(?:\]\])/gi, "@Day @LMonth @YYYY");
// eslint-disable-next-line no-useless-escape
ohc_regex(/\[\[@DD\s@Month\|\d\d-\d\d\]\]-(?:\[\[)?(?:@yyyy[^|]*\|)?@YYYY(?:\]\])/gi, "@Day @LMonth @YYYY");
this.tag = '{{subst:cfd}}\n';
this.img_summary = 'This category needs discussion';
// eslint-disable-next-line no-useless-escape
this.talk_tag = '{{subst:cdw|1=' + pageName + '}}';
this.talk_summary = '[[:' + pageName + ']] needs discussion';
this.subpage_summary = 'Starting category discussion';


// set up some page names we'll need later
//'[[month day|xxXxx]]Xyyyy ' to 'month day, year'
this.requestPage = 'Commons:Categories for discussion/' + this.formatDate( 'YYYY/MM/' ) + pageName;
ohc_regex(/\[\[@Month\s@Day\|@dd.@dd\]\].@YYYY/gi, "@LMonth @Day, @YYYY");
this.dailyLogPage = 'Commons:Categories for discussion/' + this.formatDate( 'YYYY/MM' );
//'[[day month|xxXxx]]Xyyyy' to 'day month year'
ohc_regex(/\[\[@Day\s@Month\|@dd.@dd\]\].@YYYY/gi, "@Day @LMonth @YYYY");


// first schedule some API queries to fetch the info we need…
// century
this.addTask( 'findCreator' );
regex(/\[\[((?:first|second|third|(?:four|fif|six|seven|eigh|nin|ten|eleven|twelf|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twentie)th|twenty[\s\-]first[\s\-])centur(?:y|ies)(?:\s(?:AD|BC|CE|BCE))?)\]\]/gi, '$1');
regex(/\[\[(?:first|second|third|(?:four|fif|six|seven|eigh|nin|ten|eleven|twelf|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twentie)th|twenty[\s\-]first)[\s\-_]centur(?:y|ies)(?:\s(?:AD|BC|CE|BCE))?\|([^\]]{1,30})\]\]/gi, '$1');
regex(/\[\[(\d{1,2}(?:st|[nr]d|th))[\s\-_](centur(?:y|ies))(\s(?:AD|BC|CE|BCE)|)\]\]/gi, '$1 $2$3');
ohc_regex(/\[\[\d{1,2}@th[\s\-_]centur(?:y|ies)(?:\s(?:AD|BC|CE|BCE)|)\|([^\]]{1,30})\]\]/gi, '$1');


// …then schedule the actual edits
// months
this.addTask( 'prependTemplate' );
ohc_regex(/\[\[@Month\]\]/gi, "@LMonth");
this.addTask( 'createRequestSubpage' );
ohc_regex(/\[\[@FullMonth\|([^\]]{1,30})\]\]/gi, "$1");
this.addTask( 'listRequestSubpage' );
this.addTask( 'notifyUploaders' );


// finally reload the page to show the deletion tag
// decades and years
this.addTask( 'reloadPage' );
regex(/(\d{1,3}0)[‘`´’′]?s/g, '$1s');
regex(/\[\[(\d{1,3}0)\'?s\]\]/g, '$1s');
regex(/\[\[\d{1,3}0\'?s?\|([^\]]{1,30})\]\]/g, '$1');
regex(/\[\[(\d{1,3}0)\'?(s)?\s(AD|BC|CE|BCE)\]\]/gi, '$1$2 $3');
regex(/\[\[(\d{1,4}[\s_]?)(AD|BC|CE|BCE)\]\]/gi, '$1$2');
regex(/\[\[(AD|BC|CE|BCE)([\s_]?)(\d{1,4})\]\]/gi, '$1$2$3');
ohc_regex(/([-–])\[\[\s?@yyyy\s?\|\s?(\d{2,4})\s?\]\]/gi, '$1$2'); //piped year
regex(/\[\[([12]\d{3}|[1-9]\d{0,2})\]\]/gi, '$1');
regex(/\[\[\d{1,3}0\'?s?\s(?:AD|BC|CE|BCE)\|([^\]]{1,30})\]\]/gi, '$1');
regex(/\[\[\d{1,3}0\'?s?\s\(decade\)\|([^\]]{1,30})\]\]/gi, '$1');


var lazyLoadNode = this.createLazyLoadNode( this.i18n.moreInformation, 'MediaWiki:Gadget-AjaxQuickDelete.js/DiscussCategoryInfo', '#AjaxQuickDeleteCatInfo' );
//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
ohc_regex(/\[\[@yyyy in[^|\]]+\|@Day @Month @YYYY\]\]/gi, "@Day @LMonth @YYYY");
ohc_regex(/\[\[@yyyy in[^|\]]+\|@Month @Day,? @YYYY\]\]/gi, "@LMonth @Day, @YYYY");
ohc_regex(/\[\[@yyyy#[^|\]]+\|(@month\s|)(@yyyy)\]\]/gi, "$1$2");
ohc_regex(/\[\[@yyyy#[^|\]]+\|(@month|@yyyy)\]\]/gi, "$1");
ohc_regex(/\[\[(@month\s@yyyy)\]\]/gi, "$1");
ohc_regex(/\[\[@month\s@yyyy\|([^\]]{1,30})\]\]/gi, "$1");
ohc_regex(/\[\[(?:List of |)Bollywood films of @yyyy\|@YYYY\]\](?= [^\[]{2}^B)/gi, "@YYYY");


this.prompt( [ {
ohc_regex(/(\[\[@yyyy[^|\]]+\|@yyyy)(\]\])( season)/gi, "$1$3$2");
message: '',
prefill: '',
returnvalue: 'reason',
cleanUp: true,
appendNode: lazyLoadNode,
noEmpty: true,
parseReason: true
}
], this.i18n.reasonForDiscussion );


},
//removed piped years when in full date (excepting disambiguated parentheses - updated 24/2/2012)
nominateForDeletion: function ( page ) {
// ohc_regex(/\[\[[^|\]\(\)]{1,32}\|@YYYY\]\]/gi, '@Year'); // 23/6/2021 – disabled delinking "other" year-in articles
var o = this;


// reset task list in case an earlier error left it non-empty
//Identify surprise or 'Easter egg' diversions linking months to year or "year in" articles.
this.initialize();
ohc_regex(/\[\[\d{1,4}#[^|\]]+\|@Month\]\]/gi, "@LMonth");
ohc_regex(/\[\[@yyyy \w[^|\]]{3,12}\|@Year\]\]/gi, '@Year');


mw.loader.using( [ 'mediawiki.String', 'jquery.ui' ], function () {
// month and day piped
o.pageName = ( page || pageName ).replace( /_/g, ' ' );
ohc_regex(/\[\[@month[\s_]@day\|@MM-@DD\]\]/gi, "@MM-@DD");
o.startDate = new Date();
ohc_regex(/\[\[@month[\s_]@day\|([^\]]{1,30})\]\]/gi, "$1");
ohc_regex(/\[\[@day(?:\s|_|@th )(?:of[\s_]|)?@month\|([^\]]{1,30})\]\]/gi, "$1");


// set up some page names we'll need later
//years piped
var requestPage = o.pageName,
regex(/\[\[\d{1,4}\|([^\]]{1,30})\]\]/gi, '$1');
mwString = require( 'mediawiki.String' );
}


// MediaWiki has an ugly limit of 255 bytes per title, excluding the namespace
function ohc_fix_common_errors()
while ( mwString.byteLength( requestPage ) + mwString.byteLength( o.requestPagePrefix.replace( /^.+?:/, '' ) ) >= 255 ) {
{
requestPage = requestPage.slice( 0, requestPage.length - 1 ).trim();
ohc_regex(/(\d)<sup>@th<\/sup>/gi, '$1th');
}
// remove dashbot comment from dates
 
regex(/<!-- ?DASHBot ?-->/gi, '');
o.requestPage = o.requestPagePrefix + requestPage;
ohc_regex(/(\|\s*(?:date|year)\s*=)\s*c(?:irca|a\.)?\s?((?:@day |)@month @year)(?=[\s\n]*[<|}])/gi, '$1c. $2'); //add space
o.dailyLogPage = o.requestPagePrefix + o.formatDate( 'YYYY/MM/DD' );
//common cs1 errors
 
regex(/(\|\s*(?:date|year)\s*=)\s*(1[7-9]\d|20[0-1])\?(?=[\s\n]*[<|}])/gi, '$1c. $20');  
o.tag = '{{delete|reason=%PARAMETER%|subpage=' + requestPage + o.formatDate( '|year=YYYY|month=MON|day=DAY}}\n' );
regex(/(\|\s*(?:date|year)\s*=\s*(1[7-9])\d{2})[-–](\d{2})(?=[\s\n]*[<|}])/gi, '$1–$2$3');
 
// regex(/(\|\s*(?:date|year)\s*=\s*(20)[0-1]\d)[-–]([0-2]\d)(?=[\s\n]*[<|}])/gi, '$1–$2$3');  
switch ( nsNr ) {
regex(/(\|\s*(?:date|year)\s*=\s*)@YYYY\s*[-–/]\s*@YYYY(?=[\s\n]*[<|}])/gi, '$1@YYYY1–@YYYY2'); //common cs1 error
// On MediaWiki pages, wrap inside comments (for css and js)
regex(/(\|\s*(?:date)\s*=)\s*s(pring|ummer),?\s*((?:1[7-9]\d|20[0-1])\d)(?=[\s\n]*[<|}])/gi, '$1S$2 $3'); //common cs1 error
case 8:
regex(/(\|\s*(?:date)\s*=)\s*a(utumn),?\s*((?:1[7-9]\d|20[0-1])\d)(?=[\s\n]*[<|}])/gi, '$1A$2 $3'); //common cs1 error
o.tag = '/*' + o.tag + '*/';
regex(/(\|\s*(?:date)\s*=)\s*f(all),?\s*((?:1[7-9]\d|20[0-1])\d)(?=[\s\n]*[<|}])/gi, '$1F$2 $3'); //common cs1 error
break;
regex(/(\|\s*(?:date)\s*=)\s*w(inter),?\s*((?:1[7-9]\d|20[0-1])\d)(?=[\s\n]*[<|}])/gi, '$1W$2 $3'); //common cs1 error
// On templates and creator/institution-templates: Wrap inside <noinclude>s.
ohc_regex(/(\|\s*access-?date\s*=)\s*(@month @year)(?=[\s\n]*[<|}])/gi, '$11 $2'); //common cs1 error
case 10:
// ohc_regex(/(\|\s*date\s*=\s*)@year\?(?=[\s\n]*[<|}])/gi, '$1@Year'); //common cs1 error
case 100:
// ohc_regex(/(\|\s*(?:date|year)\s*=)\s*@year\?(?=[\s\n]*[<|}])/gi, '$1c. @Year'); //common cs1 error
case 106:
// ohc_regex(/(\|\s*(?:date|year)\s*=)\s*(@month @year)\?(?=[\s\n]*[<|}])/gi, '$1c. $2'); //common cs1 error
o.tag = '<noinclude>' + o.tag + '</noinclude>';
ohc_regex(/(\|\s*access-?date\s*=)\s*@month @day, (1[7-9]\d{2}|2000)(?=[\s\n]*[<|}])/gi, '$1'); //rem access date before Wikipedia (জানুয়ারি 2001)
break;
ohc_regex(/(\|\s*access-?date\s*=)\s*@day @month.? (1[7-9]\d{2}|2000)(?=[\s\n]*[<|}])/gi, '$1'); //rem access date before Wikipedia (জানুয়ারি 2001)
case 828: // Lua comments
ohc_regex(/(\|\s*access-?date\s*=)\s*31( (?:এপ্রিল|জুন|সেপ্টেম্বর|নভেম্বর) @year)(?=[\s\n]*[<|}])/gi, '$130$2'); //rem nonsense access date (short months)
o.tag = '\n--[=[ ' + o.tag + ' ]=]\n';
ohc_regex(/(\|\s*access-?date\s*=)\s*29( ফেব্রুয়ারি (?:200[1235679]|201[1345789]))(?=[\s\n]*[<|}])/gi, '$128$2'); //rem nonsense access date 29 ফেব্রুয়ারি (non-leap year)
}
ohc_regex(/(\|\s*access-?date\s*=)\s*(?:3[01])( ফেব্রুয়ারি @yyyy)(?=[\s\n]*[<|}])/gi, '$128$2'); //rem nonsense access dates ফেব্রুয়ারি
 
regex(/(\|\s*access-?date\s*=)\s*(\d{4})(?=[\s\n]*[<|}])/gi, ''); //common cs1 error
if ( o.templateReplace ) {
o.declineReason = o.img_summary;
//month+day+year pseudo-ISO dates
}
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*@dd)-@Mon-@YYYY/gi, "$1 @FullMonth @YYYY");
o.img_summary = 'Nominating for deletion';
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@YYYY-@DD-@Mon/gi, "$1 @DD @FullMonth @YYYY");
// eslint-disable-next-line no-useless-escape
o.talk_tag = '{{subst:idw|1=' + requestPage + '}}';
o.talk_summary = '[[:' + o.pageName + ']] has been nominated for deletion';
o.subpage_summary = 'Starting deletion request';
// without \n it breaks the redirect syntax
if ( conf.wgIsRedirect ) {
o.tag += '\n';
}
 
// first schedule some API queries to fetch the info we need…
o.addTask( 'findCreator' );
 
// …then schedule the actual edits
o.addTask( o.templateReplace ? 'replaceTemplate' : 'prependTemplate' );
o.addTask( 'createRequestSubpage' );
o.addTask( 'listRequestSubpage' );
o.addTask( 'purge' );
o.addTask( 'notifyUploaders' );
if ( o.isMobile() ) {
o.addTask( 'listMobileUpload' );
}
 
// finally reload the page to show the deletion tag
o.addTask( 'reloadPage' );


var lazyLoadNode = o.createLazyLoadNode( o.i18n.moreInformation, 'MediaWiki:Gadget-AjaxQuickDelete.js/DeleteInfo', '#AjaxQuickDeleteDeleteInfo' );
regex(/(\|\s*(?:date|year)\s*=)\s*(?:(?:date |)unknown|(?:not? |non-|un)date[ds])(?=[\s\n]*[<|}])/gi, '$1n.d.'); //common cs1 error
o.prevDRNode = $( '<ul>' ).attr( 'id', 'AjaxDeletePrevRequests' );
regex(/(\|\s*(?:date|year)\s*=)\s*n\.?d(?=[\s\n]*[<|}])/gi, '$1n.d.'); //common cs1 error
o.secureCall( 'checkForFormerDR' );
regex(/(\|\s*)year(\s*=\s*)(?=n\.?d\.)(?=[\s\n]*[<|}])/gi, '$1date$2'); //common cs1 error
var toAppend = $( '<div>' ).append( $( '<div>' ).attr( 'class', 'ajaxDeleteLazyLoad' ).css( {
'max-height': Math.max( Math.round( $( window ).height() / 2 ) - 250, 100 ),
'min-height': 0,
overflow: 'auto'
} ).append( o.prevDRNode ), '<br>', lazyLoadNode );


o.prompt( [ {
  // remove parasitic metadata -  days of the week/descriptives
message: '',
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)(?:[^|}\d]*|)@Day\s+@Month\s+@YYYY((?:[a-z]\b|)\s?)[^|<}]*(?=[\s\n]*[<|}])/gi, "$1@Day @Month @YYYY$2"); //rem negate "<", "hyphens" "dashes" 26/6/2020
prefill: o.reason || '',
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)[^|}]*@Month\s+@Day,\s+@YYYY((?:[a-z]\b|)\s?)[^|<}]*(?=[\s\n]*[<|}])/gi, "$1@Month @Day, @YYYY$2"); //rem negate "<", "hyphens" "dashes" 26/6/2020
returnvalue: 'reason',
// ohc_regex(/(\|\s*date\s*=\s*)(?:[^|}–<]*\D|)@Day\s+@Month\s+@YYYY ?– ?@Day\s+@Month\s+@YYYY[^|}–<]*(?=[\s\n]*[<|}])/gi, "$1@Day1 @Mon1 @Year1 – @Day2 @Mon2 @Year2");
cleanUp: true,
// ohc_regex(/(\|\s*date\s*=\s*)[^|}–<]*@Month\s+@Day,\s+@YYYY ?– ?@Month @Day, @YYYY[^|}–<]*(?=[\s\n]*[<|}])/gi, "$1@Mon1 @Day1, @Year1 – @@Mon2 Day2, @Year2");
noEmpty: true,
// regex(/(\|\s*author\s*=\s*)(?:posted|published)(?: by\b| on\b|)[\s:](?=\w)/gi, "$1");
appendNode: toAppend,
// regex(/(\|\s*(?:date|archive-?date|access-?date|author|year)\s*=\s*)(?:accessed|retrieved|entered|posted|published|(?:last |)updated?|©)(?: by\b| on\b|)[\s:]*(?=\w)/gi, "$1");
parseReason: true
regex(/(\|\s*(?:author|first|last)\s*=\s*)(?:by\b|on\b)[\s:]*(?=\w)/gi, "$1");
}
regex(/(\|\s*(?:date|archive-?date|access-?date|author|first|last)\s*=\s*)(?:(?:Mon|Tues|Wednes|Thurs|Fri|Satur|Sun)day,?)\s/gi, "$1");
], o.i18n.reasonForDeletion );
regex(/(\|\s*(?:date|archive-?date|access-?date|author|first|last)\s*=\s*)(?:Mon|Tues?|Wed|Thur?|Fri|Sat)[\.,]?\s/gi, "$1"); //<!-- rem "Sun" - false positives -->
} );
},
 
// Check whether there was a deletion request for the same title in the past
checkForFormerDR: function () {
// Don't search for "kept" when nominating talk pages
if ( nsNr % 2 === 0 ) {
this.talkPage = conf.wgFormattedNamespaces[ nsNr + 1 ] + ':' + this.pageName.replace( conf.wgCanonicalNamespace + ':', '' );
this.queryAPI( {
prop: 'templates',
titles: this.talkPage,
tltemplates: 'Template:Kept',
tllimit: 1
}, 'formerDRTalk' );
}
this.queryAPI( {
list: 'backlinks',
bltitle: this.pageName,
blnamespace: 4,
blfilterredir: 'nonredirects',
bllimit: 500
}, 'formerDRRequestpage' );
},
formerDRTalk: function ( r ) {
var pgs = r.query.pages;
$.each( pgs, function ( id, pg ) {
if ( Array.isArray( pg.templates ) ) {
$( '<li>' ).append( $( '<a>', {
text: AQD.i18n.keptAfterDR,
href: mw.util.getUrl( AQD.talkPage )
} ) ).prependTo( AQD.prevDRNode );
} else if ( pg.missing === undefined ) {
$( '<li>' ).append( $( '<a>', {
text: AQD.i18n.hasTalkpage,
href: mw.util.getUrl( AQD.talkPage )
} ) ).appendTo( AQD.prevDRNode );
}
} );
},
formerDRRequestpage: function ( r ) {
var bls = r.query.backlinks,
_addItem = function ( t, m, bl ) {
$( '<li>' ).append( $( '<a>', {
text: t.replace( '%PAGE%', bl.title ),
href: mw.util.getUrl( bl.title )
} ) )[ m ]( AQD.prevDRNode );
};
$.each( bls, function ( i, bl ) {
if ( this.requestPage === bl.title ) {
_addItem( AQD.i18n.mentionedInDR, 'prependTo', bl );
} else if ( /^Commons:Deletion requests\/\D/.test( bl.title ) ) {
_addItem( AQD.i18n.mentionedInDR, 'appendTo', bl );
} else if ( /^Commons:Village pump\//.test( bl.title ) ) {
_addItem( AQD.i18n.mentionedInForum, 'appendTo', bl );
}


} );
  // remove deprecated parameters (|day= and |month)
},
ohc_regex(/(\|\s*)day(?:\s*=\s*)@DD ?\| ?month(?:\s*=\s*)@Month ?\| ?year(?:\s*=\s*)@YYYY(?=[|}\s])/gi, '$1date=@Day @Month @Year');
ohc_regex(/(\|\s*)year(?:\s*=\s*)@YYYY ?\| ?month(?:\s*=\s*)@Month ?\| ?day(?:\s*=\s*)@DD(?=[|}\s])/gi, '$1date=@Month @Day, @Year');
// typos
ohc_regex(/(date *= *)@Day @Month ?@th/gi, '$1@Day @Month');  
ohc_regex(/(date *= *)@Day @Month\w(?= \d{3,4})/gi, '$1@Day @Month');


renderNode: function ( $node, remotecontent, selector ) {
ohc_regex(/(date *= *(?:[12]?\d|30|31) )(জানুয়ারি|Febr)[\w ]?[aur]{3,4}\w{0,2}(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1$2uary');
if ( selector ) {
ohc_regex(/(date *= *(?:[12]?\d|30|31) )J[anu]{3,5}r\w{0,2}(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1জানুয়ারি');
selector = ' ' + selector;
ohc_regex(/(date *= *(?:[12]?\d) )Febua?r\w{0,2}(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1ফেব্রুয়ারি');
}
ohc_regex(/(date *= *(?:[12]?\d|30|31) )M\w{2,3}ch(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1মার্চ');
ohc_regex(/(date *= *(?:[12]?\d|30) )A[bpv\[]\w{2,3}l\w?(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1এপ্রিল');
ohc_regex(/(date *= *(?:[12]?\d|30|31) )Ma[tui](?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1মে');
ohc_regex(/(date *= *(?:[12]?\d|30) )J\wn\w(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1জুন');
ohc_regex(/(date *= *(?:[12]?\d|30) )J\w{1,2}e(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1জুন');
ohc_regex(/(date *= *(?:[12]?\d|30|31) )জুলাই\w{1,2}(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1জুলাই');
ohc_regex(/(date *= *(?:[12]?\d|30|31) )A[oug]{2,3}\w{1,4}t(?:\w|us)?(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1আগষ্ট');
ohc_regex(/(date *= *(?:[12]?\d|30|31) )(সেপ্টেম্বর|নভেম্বর|ডিসেম্বর)\w{2,4}b[er]{1,2}\w?(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1$2ember');
ohc_regex(/(date *= *(?:[12]?\d|30) )S\w{0,2}p[ \[]?\w{2,5}[er]{2,3}\w?(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1সেপ্টেম্বর');
ohc_regex(/(date *= *(?:[12]?\d|30|31) )O\w{0,2}t\w{1,3}[er]{2,3}\w?(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1অক্টোবর');
ohc_regex(/(date *= *(?:[12]?\d|30) )[MN]\w{1,2}[bv] ?\w{1,3}b[er]{1,2}\w?(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1নভেম্বর');  
ohc_regex(/(date *= *(?:[12]?\d|30|31) )D[ie]?[cs] ?\w{1,4}b[er]{1,2}\w?(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1ডিসেম্বর');


$node.load( mw.util.wikiScript() + '?' + $.param( {
ohc_regex(/(date *= *)@Month\w(?=(?: (?:[12]?\d|30|31),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1@Month'); //rem stray digit at the end of year string
action: 'render',
title: remotecontent,
ohc_regex(/(date *= *)(জানুয়ারি|Febr)[\w ]?[aur]{3,4}\w{0,2}(?=(?: (?:[12]?\d|30|31),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1$2uary');
uselang: conf.wgUserLanguage
ohc_regex(/(date *= *)J[anu]{3,5}r\w{0,2}(?=(?: (?:[12]?\d|30|31),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1জানুয়ারি');
} ) + ( selector || '' ), function () {
ohc_regex(/(date *= *)Febua?r\w{0,2}(?=(?: (?:[12]?\d),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1ফেব্রুয়ারি');
$node.find( 'a' ).attr( 'href', function ( i, v ) {
ohc_regex(/(date *= *)M\w{2,3}ch(?=(?: (?:[12]?\d|30|31),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1মার্চ');
return v.replace( 'MediaWiki:Anoneditwarning', conf.wgPageName );
ohc_regex(/(date *= *)A[bpv\[]\w{2,3}l\w?(?=(?: (?:[12]?\d|30),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1এপ্রিল');
} );
ohc_regex(/(date *= *)Ma[tui](?=(?: (?:[12]?\d|30|31),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1মে');
} );
ohc_regex(/(date *= *)J\wn\w(?=(?: (?:[12]?\d|30),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1জুন');
return $node;
ohc_regex(/(date *= *)J\w{1,2}e(?=(?: (?:[12]?\d|30),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1জুন');
},
ohc_regex(/(date *= *)জুলাই\w{1,2}(?=(?: (?:[12]?\d|30|31),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1জুলাই');
ohc_regex(/(date *= *)A[oug]{2,3}\w{1,4}t(?:\w|us)?(?=(?: (?:[12]?\d|30|31),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1আগষ্ট');
ohc_regex(/(date *= *)(সেপ্টেম্বর|নভেম্বর|ডিসেম্বর)\w{2,4}b[er]{1,2}\w?(?=(?: (?:[12]?\d|30|31),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1$2ember');  
ohc_regex(/(date *= *)S\w{0,2}p[ \[]?\w{2,5}[er]{2,3}\w?(?=(?: (?:[12]?\d|30),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1সেপ্টেম্বর');  
ohc_regex(/(date *= *)O\w{0,2}t\w{1,3}[er]{2,3}\w?(?=(?: (?:[12]?\d|30|31),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1অক্টোবর');  
ohc_regex(/(date *= *)[MN]\w{1,2}[bv] ?\w{1,3}b[er]{1,2}\w?(?=(?: (?:[12]?\d|30),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1নভেম্বর');  
ohc_regex(/(date *= *)D[ie]?[cs] ?\w{1,4}b[er]{1,2}\w?(?=(?: (?:[12]?\d|30|31),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1ডিসেম্বর');


createLazyLoadNode: function ( label, page, selector ) {
//insert comma to separate date from army unit
return $( '<div>', { style: 'min-height:40px;' } ).append( $( '<a>', {
ohc_regex(/@FullMonth ((?:the |)\d\d*@th (?:Air(?:borne|)|Arm(?:ou?red|y)|Artillery|Battalion|Brigade|Co(?:mpan|)y|Division|Fleet|Group|Infantry|Land|Panzer|Regiment|Squadron|Sqn)\b)/g, "@Month, $1");
href: '#',
text: label
} ).on( 'click', function ( e ) {
e.preventDefault();
var $content = $( this ).parent().find( '.ajaxDeleteLazyLoad' ),
$contentInner = $content.find( '.ajax-quick-delete-loading' );
if ( $contentInner.length ) {
// first time invoked, do the XHR to load the content
AQD.renderNode( $content, $contentInner.data( 'aqdPage' ), selector );
}
$content.toggle( 'fast' );
} ), $( '<div>', {
// eslint-disable-next-line quote-props
'class': 'ajaxDeleteLazyLoad',
style: 'display:none;'
} ).append( $( '<span>', {
// eslint-disable-next-line quote-props
'class': 'ajax-quick-delete-loading',
text: this.i18n.loading
} ).data( 'aqdPage', page ) ) );
},
extractFromHTML: function ( $el ) {
$el = $( $el ).parent();


// …extract the regular expression from html
// remove parasitic metadata - time
this.templateRegExp = $el.find( '.ctdr-regex' ).text();
ohc_regex(/(\|\s*\w*date\s*=\s*@yyyy-@mm-@dd)\s?(?:T[0-2]\d:[0-5]\d:[0-5]\d(?:\s*|&nbsp;|)(?:GMT\s*|UTC\s*|[A-Z]{1,2}[DS]T\s*|Z))(?=\s*[|}])/g, "$1");
ohc_regex(/(\|\s*\w*date\s*=\s*@month @day,? @yyyy)\s?(?:,? [0-2]?\d[\.:][0-5]\d(?:\s*|&nbsp;)(?:[apAP][mM]\s*|)(?:GMT\s*|UTC\s*|[A-Z]{1,2}[DS]T\s*|))(?=\|)/g, "$1");
ohc_regex(/(\|\s*\w*date\s*=\s*@day @month,? @yyyy)\s?(?:,? [0-2]?\d[\.:][0-5]\d(?:\s*|&nbsp;)(?:[apAP][mM]\s*|)(?:GMT\s*|UTC\s*|[A-Z]{1,2}[DS]T\s*|))(?=\|)/g, "$1");
ohc_regex(/(\|\s*\w*date\s*=\s*\w[\w\s]+@month @day,? @yyyy)\s?(?:,? [0-2]?\d[\.:][0-5]\d(?:\s*|&nbsp;)(?:[apAP][mM]\s*|)(?:GMT\s*|UTC\s*|[A-Z]{1,2}[DS]T\s*|))(?=\|)/g, "$1");
ohc_regex(/(\|\s*\w*date\s*=\s*\w[\w\s]+@day @month,? @yyyy)\s?(?:,? [0-2]?\d[\.:][0-5]\d(?:\s*|&nbsp;)(?:[apAP][mM]\s*|)(?:GMT\s*|UTC\s*|[A-Z]{1,2}[DS]T\s*|))(?=\|)/g, "$1");
ohc_regex(/(\|\s*\w*date\s*=[^:|}]*)\s?(?:T?[0-2]\d:[0-5]\d:[0-5]\d(?:\s*|&nbsp;|)(?:GMT\s*|UTC\s*|[A-Z]{1,2}[DS]T\s*|Z))/g, "$1");


var m = this.templateRegExp.match( /^\/(.+)\/(i)?$/ );
//  add back spaces or comma or remove other single artefact after date string
if ( !m || !m[ 1 ] ) {
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)(?:on |)@Day\s{,2}@Month\s{,2}@YYYY[^a-z{}]?(?=\s*[|}\n])/gi, "$1@Day @Month @YYYY$2");
m = new Error( this.i18n.templateRegExp );
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)(?:on |)@Month\s{,2}@Day,?\s{,2}@YYYY[^a-z{}]?(?=\s*[|}\n])/gi, "$1@Month @Day, @YYYY$2");
this.fail( m );
//long-hand palliative for observed failure to insert spaces
throw m;
ohc_regex(/(\|\s*(?:archive|access|air)-?date\s*=\s*)(?:on |)([0-2]?\d|30|31)\s*(জানুয়ারি|ফেব্রুয়ারি|মার্চ|এপ্রিল|মে|জুন|জুলাই|আগষ্ট|সেপ্টেম্বর|অক্টোবর|নভেম্বর|ডিসেম্বর)\s*((?:19\d|20[0-1])\d\s?)[^|{}\s<>]*(?=\s*[|}])/gi, "$1$2 $3 $4");
}
// ohc_regex(/(\|\s*(?:publication|)-?date\s*=\s*)(?:on |)@Day\s*@Month\s*@YYYY([a-z]\s?|\s?)\w*[^|{}<>]*(?=[|}])/gi, "$1@Day @Month @YYYY$2");
this.templateRegExp = new RegExp( m[ 1 ], m[ 2 ] );
// ohc_regex(/(\|\s*(?:publication|)-?date\s*=\s*)(?:on |)@Month\s*@Day,\s*@YYYY([a-z]\s?|\s?)\w*[^|{}<>]*(?=[|}])/gi, "$1@Month @Day, @YYYY$2");
 
// …and the decline reason
this.declineReason = $el.find( '.ctdr-template-decline-reason' ).text();
 
// …and the template name itself
m = $el.find( '.ctdr-template-name' ).text();


this.reason = 'This file was initially tagged by %USER%' + ( m ? ( ' as \'\'\'' + m + '\'\'\'' ) : '' );
//remove extraneous bracket //from Batty
ohc_regex(/{{(\s*[Cc]it(?:e|ation))([^}]+)(\s*\|\s*(?:archive-?|access-?|publication-?)?date\s*=\s*)([\w\s-]+)\](?=\s*[\|}<])/gi, '{{$1$2$3$4');


},
//fix bda template redirect
removeProgress: function () {
// regex(/\{\{bda\|([^}]+)\}\}/gi, '{{birth date and age|$1}}');
this.showProgress();
// regex(/\{\{dda\|([^}]+)\}\}/gi, '{{death date and age|$1}}');
return this.nextTask();
},
/**
* Remove any tag
* @context DOM-Element
* This function must be called with the DOM-Element as this-arg!
*/
_removeAnyTag: function ( e ) {
AQD.extractFromHTML( e.currentTarget || this );
AQD.removeAnyTag();
return false;
},
removeAnyTag: function () {
// this.initialize();
this.addTask( 'declineRequest' );
this.nextTask();
},
/**
* Convert any tag to a deletion request
* @context DOM-Element
* This function must be called with the DOM-Element as this-arg!
*/
_convertToDR: function ( e ) {
e = e.currentTarget || this;
AQD.extractFromHTML( e );
AQD.convertToDR( e );
return false;
},
convertToDR: function ( el ) {
// reset task list in case an earlier error left it non-empty
this.initialize();
this.declineReason = 'This file does not qualify for [[COM:SPEEDY|speedy-deletion]] and a regular deletion request will be started.';
this.templateReplace = true;
// first schedule a API query to fetch the info we need…
this.addTask( 'findTemplateAdder' );
this.addTask( 'getMoveToken' );
// prompt before conversion for user decision
this.addTask( 'removeTemplate' );
this.addTask( 'removeProgress' );
this.addTask( 'nominateForDeletion' );
// Hide the buttons to prevent attempts of duplicate removal
$( el ).closest( '.convert-to-dr' ).hide();
// … and go!
this.nextTask();
},
findTemplateAdder: function () {
var query = {
prop: 'revisions',
rvprop: 'content|user',
titles: pageName.replace( /_/g, ' ' ),
rvlimit: 50
};
this.queryAPI( query, 'findTemplateAdderCB' );
},
findTemplateAdderCB: function ( result ) {
var reason,
user,
pgRevs, // for debug
template;
$.each( result.query.pages, function ( id, pg ) {
pgRevs = pg.revisions;
pgRevs.forEach( function ( rv ) {
var m = rv[ '*' ].match( AQD.templateRegExp );
if ( m ) {
user = rv.user;
if ( m.length > 1 && !template ) {
template = m[ 1 ];
}


if ( m.length > 2 && !reason ) {
//zap redundant {{date}}, {{accessdate}} {{retrieved}}, {{monthname}} and {{#dateformat}}
reason = m[ 2 ];
// regex(/({{(?:end|start)[-–]date)\|df=y(?:es|)/gi, "$1"); //rem deprecated parameter - disabled: doesn't work here, so ejected to the formatting script
}
ohc_regex(/{{#formatdate:@YYYY-@MM-@DD(?:[^\}]*)}}/gi, "@Day @Month @YYYY");
regex(/{{#formatdate:([^}]+)}}/gi, "$1");
regex(/\{\{#dateformat:([^}\|]+)(?:\|dmy|\|mdy)?\}\}/gi, '$1');
// ohc_regex(/(date[ ]*=[ ]*)\{\{(?:Start|End) ?date(?:\|df=y(?:es|)|)\|@YYYY\|@MM\|@DD(?:\|df=y(?:es|)|)\}\}/gi, '$1@Month @DD, @YYYY');  //stripping start/end template notes inside "|date=" parameter (line 72)
ohc_regex(/{{#formatdate:@YYYY-@MM-@DD(?:\|(?:[dmy]{3}|iso)|)}}/gi, "@Day @Month @YYYY");
ohc_regex(/\{\{date\|@YYYY-@MM-@DD\}\}/gi, "@Day @Month @YYYY");
ohc_regex(/\{\{date\|(@DD[\-\s]@Mon|@Mon[\-\s]@DD)\}\}/gi, "@Day @Month");
regex(/\{\{date\|([^}\|]+)(?:\|l?(?:[dmy]{3}|iso|none|link))?\}\}/gi, '$1');
ohc_regex(/[ ]*\{\{accessdate\|@YYYY-@MM-@DD[ ]*\}\}/gi, " Retrieved @YYYY-@MM-@DD");
ohc_regex(/[ ]*\{\{retrieved[ ]*\|[ ]accessdate=([\-\w, ]*)\}\}/gi, " Retrieved $1");
// ohc_regex(/(date[ ]*=[ ]*|\w{2,}[ ]*)\{\{(?:start|end).date[^|}]*(?:\|df=y(?:es|)|)\|@YYYY(?:\|df=y(?:es|)|)\}\}/gi, '$1@YYYY');  //stripping start/end template (disabling to placate Pigsonthewing)
// ohc_regex(/\{\{(?:Start|End) date(?:\|df=y(?:es|)|)\|@YYYY\|@MM\}\}/gi, '@Month @YYYY')  //stripping start/end template notes
// ohc_regex(/<!--(?:Use)? \{\{(?:Start|End) date\|@YYYY\|@MM\|@DD\}\} -->/gi, ''); //stripping start/end template notes
ohc_regex(/(\{\{MONTHNAME\|@MM\}\})/gi, "@Month")


} else {
//expand one and two-digit years in ranges
return false;
regex(/(\()@Month @YYYY[-–]@Month @YYNN(\))/gi, '$1@Month1 @YYYY1 – @Month2 @YYYY2$2');
}
regex(/(\(1[789])(\d)(1)[-–]([2-9]\))/gi, '$1$2$3–$2$4');
} );
regex(/(\(1[789])(\d)(2)[-–]([3-9]\))/gi, '$1$2$3–$2$4');
} );
regex(/(\(1[789])(\d)(3)[-–]([4-9]\))/gi, '$1$2$3–$2$4');
if ( !user ) {
regex(/(\(1[789])(\d)(4)[-–]([5-9]\))/gi, '$1$2$3–$2$4');
mw.log.warn( pgRevs );
regex(/(\(1[789])(\d)(5)[-–]([6-9]\))/gi, '$1$2$3–$2$4');
throw new Error( this.i18n.findTemplateAdderErr );
regex(/(\(1[789])(\d)(6)[-–]([7-9]\))/gi, '$1$2$3–$2$4');
}
regex(/(\(1[789])(\d)(7)[-–]([8-9]\))/gi, '$1$2$3–$2$4');
this.reason = this.reason.replace( '%USER%', '[[User:' + user + '|' + user + ']]' );
regex(/(\(1[789])(\d)(8)[-–](9\))/gi, '$1$2$3–$2$4');
if ( template ) {
regex(/(\(20)([01])(1)[-–]([2-9]\))/gi, '$1$2$3–$2$4');
this.reason += ' (' + template + ')';
regex(/(\(20)([01])(2)[-–]([3-9]\))/gi, '$1$2$3–$2$4');
}
regex(/(\(20)([01])(3)[-–]([4-9]\))/gi, '$1$2$3–$2$4');
regex(/(\(20)([01])(4)[-–]([5-9]\))/gi, '$1$2$3–$2$4');
regex(/(\(20)([01])(5)[-–]([6-9]\))/gi, '$1$2$3–$2$4');
regex(/(\(20)([01])(6)[-–]([7-9]\))/gi, '$1$2$3–$2$4');
regex(/(\(20)([01])(7)[-–]([8-9]\))/gi, '$1$2$3–$2$4');
regex(/(\(20)([01])(8)[-–](9\))/gi, '$1$2$3–$2$4');


if ( reason ) {
ohc_regex(/(\W)@DD@th?, @DD@th?((?:[ ]|&nbsp;)(?:and|&|to|or)(?:[ ]|&nbsp;))@DD@th?(?:\sof\s?)?([ ]|&nbsp;)@Month(?=\W)/gi, '$1@Day1, @Day2$2@Day3$3@LMonth');
this.reason += ' and the most recent rationale was: <tt>' + reason + '</tt>';
ohc_regex(/(\W)@DD@th?((?:[ ]|&nbsp;)(?:and|&|to|or)(?:[ ]|&nbsp;))@DD@th?(?:\sof\s?|)([ ]|&nbsp;)@Month(?=\W)/gi, '$1@Day1$2@Day2$3@LMonth');
}
ohc_regex(/(\W)the @DD@th(?:\sof|)\s@Month,? @YYYY(?=\W\D)/g, '$1@Day @LMonth @YYYY');
ohc_regex(/(\W)the @DD@th(?:\sof|)\s@Month(?=\W\D)/g, '$1@Day @LMonth');
ohc_regex(/(\W)@Day@th?(?:\sof|)([ _]|&nbsp;|{{(?:break|nbsp)}})@Month(?=[^|\]\w])/gi, '$1@Day$2@LMonth');
ohc_regex(/(\W)@Month\s(?:the\s)?@DD@th?,(?:\sthe\s)?(?: |&nbsp;)@DD@th?(\s(?:and|&|to|or)(?:[ _]|&nbsp;))(?:the\s)?@DD@th?(?=[^|\]\w])/gi, '$1@LMonth @Day1, @Day2$2@Day3');
ohc_regex(/(\W)(@month)\s(@day)((?:,\s@day){0,6}),?(\/|\s?[-–]\s?|\s(?:and|&|to|or)\s+?)@Day@th?(?:,?(?:[ _]|&nbsp;)|\sof\s)?(\d{3,4}\W\D)/gi, '$1$2 $3$4$5@Day, $6');
ohc_regex(/(\W)(@month)\s(@day)((?:,\s@day){0,6}),?(\/|\s?[-–]\s?|\s(?:and|&|to|or)\s+?)@Day@th?(?=\W\D)/gi, '$1$2 $3$4$5@Day');
ohc_regex(/(\W)@Month([ _]|&nbsp;|{{(?:break|nbsp)}})(?:the\s)?@DD@th?,? @Year/gi, '$1@LMonth$2@Day, @Year');
ohc_regex(/(\W)@Month @Day(?:\sof|,|)([ _]|&nbsp;|{{(?:break|nbsp)}})@Year(?=[^|\]\w])/gi, '$1@Month @Day,$2@Year');


this.nextTask();
// consolidating/amalgamating date fields
},
ohc_regex(/(\|[ ]*date[ ]*=[ ]*@day)\s*\|[ ]*month=[ ]*(@month)\s*\|[ ]*year=[ ]*(@yyyy[ ]*)(?=[|}\s])/gi, "$1 $2 $3");
ohc_regex(/(\|[ ]*date[ ]*=[ ]*@day.?@month)\s*\|[ ]*year=[ ]*(@yyyy[ ]*)(?=[|}\s])/gi, "$1 $2");
ohc_regex(/(\|[ ]*date[ ]*=[ ]*@month.?@day)\s*\|[ ]*year=[ ]*(@yyyy[ ]*)(?=[|}\s])/gi, "$1 $2");


processDupes: function () {
// eliminating dates and time placed in author parameter
// reset task list in case an earlier error left it non-empty
//removing artefacts from Indian news sites (TNN আগষ্ট 30, 2012, 05.46AM)
this.initialize();
ohc_regex(/(\|\s*author\s*=\s*(?:[A-Z]{2,3}\b))(?:[^|}]*)\d{4}, [\d\.:]{4,5}(&nbsp;|)[AP]M IST(?=[ ]*\|)/g, '$1$2');
// ohc_regex(/(\|\s*author=(?:[^\[\]|{}]*))(TNN|PTI) @day @month @yyyy, [\d\.:]{4,5}(&nbsp;|)[AP]M IST(?=[ ]*\|)/g, '$1$2');


if ( $( '#globalusage' ).length || !$( '#mw-imagepage-nolinkstoimage' ).length ) {
ohc_regex(/(\|\s*author\s*=\s*)@month @day,? @yyyy\s?(?:,? [0-2]?\d[\.:][0-5]\d(?:\s*|&nbsp;)(?:[apAP][mM]\s*|)(?:GMT\s*|UTC\s*|[A-Z]{1,2}[DS]T\s*|)|)(?=\|)/g, "$1");
this.inUse = true;
ohc_regex(/(\|\s*author\s*=\s*)@day @month,? @yyyy\s?(?:,? [0-2]?\d[\.:][0-5]\d(?:\s*|&nbsp;)(?:[apAP][mM]\s*|)(?:GMT\s*|UTC\s*|[A-Z]{1,2}[DS]T\s*|)|)(?=\|)/g, "$1");
}
ohc_regex(/(\|\s*author\s*=\s*\w[\w\s]+)@month @day,? @yyyy(?:[^\[\]|{}]*)(?=[|}])/g, "$1");
ohc_regex(/(\|\s*author\s*=\s*\w[\w\s]+)@day @month,? @yyyy(?:[^\[\]|{}]*)(?=[|}])/g, "$1");
ohc_regex(/(\|\s*author\s*=\s*(?:\w[\w\s]+)?)@dd-@mm-@yyyy/gi, "$1");
ohc_regex(/(\|\s*author\s*=\s*(?:\w[\w\s]+)?)@YYYY-@MM-@DD ?/gi, "$1");
regex(/(\|\s*(?:date|archive-?date|access-?date|author)\s*=\s*(?:\w[\w\s]+)?)[0-2]\d:[0-5]\d(?:[ ]|&nbsp;)?(?:[ap]m|[ap]\.m\.|)(?: ?(?:[A-Z]{1,2}T|UTC)[\.,]?|)/gi, "$1");
// ohc_regex(/(\|\s*author\s*=\s*(?:\w[\w\s]+)?)\s*[0-2]\d[\.:][0-5]\d(?:[\.:][0-5]\d|)/gi, "$1"); //let's see later if we need this


this.addTask( 'getDupeDetails' );
// eliminating mm-dd-yyyy dates
this.addTask( 'compareDetails' );
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@MM[-–\/\.=\s](1[3-9]|2\d|3[01])[-–\/\.=\s]@YYYY/gi, "$1@Month $2, @YYYY");
this.addTask( 'mergeDescriptions' );
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Mon[-–\/\.=\s](1[3-9]|2\d|3[01])[-–\/\.=\s]@YYYY/gi, "$1@Month $2, @YYYY");
this.addTask( 'saveDescription' );
ohc_regex(/[ ](?:Accessed|Retrieved)(?:(?: online|) on|:?)[ ]@MM[-–\/\.=\s](1[3-9]|2\d|3[01])[-–\/\.=\s]@YYYY(?=\D)/gi, " Retrieved @Month $1, @YYYY");
this.addTask( 'replaceUsage' );
// ohc_regex(/[ ](?:Accessed|Retrieved)(?:(?: online|) on|:?)[ ]@YYYY,? @Month @DD(?=\D)/gi, " Retrieved @Day @Month @YYYY");
this.addTask( 'queryRedirects' );
this.addTask( 'deletePage' );
this.addTask( 'redirectPage' );
this.addTask( 'reloadPage' );
this.destination = $( '#AjaxDupeDestination' ).text();
this.nextTask();
},


getDupeDetails: function () {
ohc_regex(/([ =|])@Mon[-–](1[3-9]|2\d|3[01])[-–]@YYYY(?=[^-–\d/])/gi, "$1@Mon $2, @YYYY");
this.queryAPI( {
ohc_regex(/([ =|])@Mon\/(1[3-9]|2\d|3[01])\/@YYYY(?=[^-–\d/])/gi, "$1@Mon $2, @YYYY");
curtimestamp: 1,
ohc_regex(/([ =|])@Mon\.(1[3-9]|2\d|3[01])\.@YYYY(?=[^-–\d/])/gi, "$1@Mon $2, @YYYY");
meta: 'tokens',
ohc_regex(/([ =|])@Mon (1[3-9]|2\d|3[01]) @YYYY(?=[^-–\d/])/gi, "$1@Mon $2, @YYYY");
prop: 'imageinfo|revisions|info',
ohc_regex(/([ =|])@MM[-–](1[3-9]|2\d|3[01])[-–]@YYYY(?=[^-–\d/])/gi, "$1@Mon $2, @YYYY");
rvprop: 'content|timestamp',
ohc_regex(/([ =|])@MM\/(1[3-9]|2\d|3[01])\/@YYYY(?=[^-–\d/])/gi, "$1@Mon $2, @YYYY");
inprop: 'watched',
ohc_regex(/([ =|])@MM\.(1[3-9]|2\d|3[01])\.@YYYY(?=[^-–\d/])/gi, "$1@Mon $2, @YYYY");  
iiprop: 'sha1|size|url',
ohc_regex(/([ =|])@MM (1[3-9]|2\d|3[01]) @YYYY(?=[^-–\d/])/gi, "$1@Mon $2, @YYYY");
iiurlwidth: 365,
redirects: 1,
titles: pageName.replace( /_/g, ' ' ) + '|' + this.destination
}, 'getDupeDetailsCB' );
this.showProgress( 'Fetching details' );
},


getDupeDetailsCB: function ( result ) {
// eliminating dd-mm-yyyy dates (assumed default)
this.details = [];
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@DD[-–\/\.=\s]@MM[-–\/\.=\s]@YYYY/gi, "$1@Day @Month @YYYY");
if ( result ) {
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@DD[-–\/\.=\s]@Mon[-–\/\.=\s]@YYYY/gi, "$1@Day @Month @YYYY");
var q = result.query,
ohc_regex(/[ ](?:Accessed|Retrieved)(?:(?: online|) on|:?)[ ]@DD[-–\/\.=\s]@MM[-–\/\.=\s]@YYYY(?=\D)/gi, " Retrieved @Day @Month @YYYY");
id,
ohc_regex(/[ ](?:Accessed|Retrieved)(?:(?: online|) on|:?)[ ]@YYYY,? @Month @DD(?=\D)/gi, " Retrieved @Day @Month @YYYY");
pg,
ohc_regex(/([ =|])@DD[-–]@Mon[-–]@YYYY(?=[^-–\d/])/gi, "$1@Day @Month @YYYY");  
ii,
ohc_regex(/([ =|])@DD\/@Mon\/@YYYY(?=[^-–\d/])/gi, "$1@Day @Month @YYYY");  
n,
ohc_regex(/([ =|])@DD\.@Mon\.@YYYY(?=[^-–\d/])/gi, "$1@Day @Month @YYYY");
pages = q.pages;
ohc_regex(/([ =|])@DD @Mon @YYYY(?=[^-–\d/])/gi, "$1@Day @Month @YYYY");
 
ohc_regex(/([ =|])@DD[-–]@MM[-–]@YYYY(?=[^-–\d/])/gi, "$1@Day @Month @YYYY");  
for ( id in pages ) {
ohc_regex(/([ =|])@DD\/@MM\/@YYYY(?=[^-–\d/])/gi, "$1@Day @Month @YYYY");  
if ( Object.prototype.hasOwnProperty.call( pages, id ) ) {
ohc_regex(/([ =|])@DD\.@MM\.@YYYY(?=[^-–\d/])/gi, "$1@Day @Month @YYYY");
pg = pages[ id ];
ohc_regex(/([ =|])@DD @MM @YYYY(?=[^-–\d/])/gi, "$1@Day @Month @YYYY");  
if ( !pg.imageinfo ) {
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@DD[-–\/\.=\s]@Month[-–\/\.=\s]@YYNN(?=\s*[|}\n])/gi, '$1@Day @Month @YYYY');
// Nothing we can change so prevent users reporting
this.disableReport = true;
throw new Error( ( ( pg.title.trim() === '{{{1}}}' ) ?
this.i18n.dupeParaErr :
this.i18n.dupeExistErr.replace( '%TITLE%', pg.title ) ) + ' (pg.imageinfo is undefined)' );
}
ii = pg.imageinfo[ 0 ];
n = {
title: pg.title,
size: ii.size,
width: ii.width,
height: ii.height,
thumburl: ii.thumburl,
thumbwidth: ii.thumbwidth,
thumbheight: ii.thumbheight,
descriptionurl: ii.descriptionurl,
sha1: ii.sha1,
content: pg.revisions[ 0 ][ '*' ],
starttimestamp: result.curtimestamp
};
this.details.push( n );
this.csrftoken = q.tokens.csrftoken;
 
if ( pg.watched !== undefined ) {
this.pageWasWatched = true;
}


}
//convert yyyy-dd-mm to yyyy-mm-dd
}
ohc_regex(/{{(\s*[Cc]it(?:e|ation))([^}]+)(\s*\|\s*(?:publication|archive|access|air|)-?date\s*=\s*(?:1[0-9]|20)\d{2})[-/\.=\s](1[3-9]|2\d|3[01])[-/\.=\s](0?\d|1[0-2])(\s*[\|}<])/gi, '{{$1$2$3-$5-$4$6'); //from Batty
}
if ( this.details.length < 2 ) {
this.disableReport = true;
throw new Error( this.i18n.noPageFound );
}
// If order (old=0, new=1) is incorrect: Reverse
if ( this.details[ 0 ].title !== pageName.replace( /_/g, ' ' ) ) {
this.details.reverse();
}


this.nextTask();
// eliminating other errant formats
},
ohc_regex(/(\|(?:[\w ]*)date\s*=\s*)([0-2]?\d|30|31) @Month \2,? @YYYY(?=\s*[|}])/gi, "$1$2 @Month @YYYY"); //repeated digits
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Day ?@Month ?200([01]\d)[^\s|}]?(?=\s*[|}])/gi, "$1@Day @Month 20$2");
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month ?@Day,? ?200([01]\d)[^\s|}]?(?=\s*[|}])/gi, "$1@Month @Day, 20$2");


/**
ohc_regex(/([ ]\()@DD-@MM-@YYYY(\)\W)/gi, '$1@Day @Month @YYYY$2');
* Edit the current page to add the specified tag.  Assumes that the page hasn't
ohc_regex(/([ ]\()@DD-@Month-@YYYY(\)\W)/gi, '$1@Day @Month @YYYY$2');
* been tagged yet; if it is, a duplicate tag will be added.
ohc_regex(/(\|(?:[\w ]*)date\s*=\s*)@Month, @DD, @YYYY(?=\s*[|}])/gi, "$1@Day @Month @YYYY");
*/
ohc_regex(/(\|(?:[\w ]*)date\s*=\s*)@DD[\.,] @Month,? @YYYY(?=\s*[|}])/gi, "$1@Day @Month @YYYY");
prependTemplate: function () {
ohc_regex(/(\|(?:[\w ]*)date\s*=\s*)@YYYY,? @Month @DD(?=\s*[|}])/gi, "$1@Day @Month @YYYY");
var page = {
ohc_regex(/(\|(?:[\w ]*)date\s*=\s*)@YYYY,? @DD @Month(?=\s*[|}])/gi, "$1@Day @Month @YYYY");
title: this.pageName,
ohc_regex(/[ ]\(@YYYY,? @Month @DD\)/gi, " (@Day @Month @YYYY)");
text: this.tag,
ohc_regex(/[ ]\(@YYYY @MM @DD\)/gi, " (@Day @Month @YYYY)");
editType: 'prependtext',
ohc_regex(/[ ]\(@YYYY, @DD @Month\)/gi, " (@Day @Month @YYYY)");
watchlist: window.AjaxDeleteWatchFile ? 'watch' : this.watchlist,
ohc_regex(/(\|(?:[\w ]*)date\s*=\s*)@YYYY,? @Month(?=\s*[|}])/gi, "$1@Month @YYYY");
minor: false
ohc_regex(/[ ]\(@YYYY, @Month\)/gi, " (@Month @YYYY)");
};
ohc_regex(/[ ]\(@Mon@YYYY\)/gi, " (@Mon @YYYY)");


this.showProgress( this.i18n.addingAnyTemplate );
//CS1 errors ISO-like dates (too few or too many digits)
this.savePage( page, this.img_summary, 'nextTask' );
ohc_regex(/(date\s*=\s*)(?:\[\[)?@YYYY(?:\]\][–—‐]\[\[|[–—‐])@MM[\-–—‐]@DD(?:\]\])?(?=\s*[|}])/gi, "$1@YYYY-@ZM-@ZD"); //ndashes and emdashes
},
ohc_regex(/(\|\s*access-?date\s*=)\s*@YYYY-0[–—]@DD(?=\s*[|}])/gi, ""); //rem nonsense access date
ohc_regex(/(\|(?:[\w ]*)date\s*=\s*)@YYYY[-–—]@MM[-–—]@DD(?=\s*[|}])/gi, "$1@YYYY-@ZM-@ZD"); //ndashes and emdashes
// ohc_regex(/(\|(?:[\w ]*)date\s*=\s*)@YYYY[\-–—‐]@MM(?=\s*[|}])/gi, "$1@Month @YYYY"); //transform "yyyy-mm" to "month year"
ohc_regex(/(<ref[^>]*>[^<]+?)([\s\(])@YYYY[–—]@MM[–—]@DD([^-\w\/%,<][^<]*?<\/ref>)/gi, "$1$2@Day @Month @YYYY$3");
ohc_regex(/(<ref[^>]*>[^<]+?)([\s\(])@YYYY[-]@MM[-]([1-9])([^-\w\/%,<][^<]*?<\/ref>)/gi, "$1$2$3 @Month @YYYY$4"); 


/**
// spaces and commas between month and year
* Edit the current page to add the specified tag and the changed content.
ohc_regex(/@Month(?:,?|\s+of|)(\s|&nbsp;)@YYYY(?=\D)/gi, "@LMonth$1@YYYY");
*/
replaceTemplate: function ( text ) {
var page = {
title: this.destination || pageName,
text: text || this.tag + this.pageContent,
editType: 'text',
starttimestamp: this.starttimestamp,
timestamp: this.timestamp,
watchlist: window.AjaxDeleteWatchFile ? 'watch' : this.watchlist,
minor: false
};


this.templateReplace = false;
// fix month names (capitalize, remove dots)
this.showProgress( this.i18n.addingAnyTemplate );
ohc_regex(/(\W)@DD\s@FullMonth(\s+|\s*,)/gi, "$1@Day @FullMonth$2");
this.savePage( page, ( this.declineReason || this.img_summary ), 'nextTask' );
ohc_regex(/(\W)@DD\s@Mon(\s+|\s*,)/gi, "$1@Day @Mon$2");
},
ohc_regex(/(\W)@FullMonth\s@DD(\s+|\s*,)/gi, "$1@FullMonth @Day$2");
ohc_regex(/(\W)@Mon\s@DD(\s+|\s*,)/gi, "$1@Mon @Day$2");
regex(/(\d(?:st|nd|rd|th) )C(entur(?:ies|y))(?=[ ]*(=|BC|AD|CE))/g, '$1c$2');
// regex(/(\d(?:st|nd|rd|th) )C(entur(?:ies|y))(?![ \-][A-Z]\w*|''|")/g, '$1c$2');


/**
//spaces and commas - in date formats
* Create the DR subpage (or append a new request to an existing subpage).
ohc_regex(/(\D\W\[?\[?@dd)[ ]+(@month)(\]\])?[ ]*,[ ]*(\[?\[?@yyyy(\sAD|\sBC|\sCE|\sBCE|)\]?\]?\W\D)/gi, "$1 $2$3 $4");
* The request page will always be watchlisted.
ohc_regex(/(\D\W\[?\[?)(@month)[ ]+(@dd)(\]?\]?)(?:[ ]*,[ ]*)(\[?\[?@yyyy(\sAD|\sBC|\sCE|\sBCE|)\]?\]?\W\D)/gi, "$1$2 $3$4, $5");
*/
ohc_regex(/(\D\W\[?\[?)(@month)[ ]+(@dd)(\]?\]?)[ ]+(\[?\[?@yyyy(\sAD|\sBC|\sCE|\sBCE|)\]?\]?\W\D)/gi, "$1$2 $3$4, $5");
createRequestSubpage: function () {
this.templateAdded = true; // we've got this far; if something fails, user can follow instructions on template to finish
var page = {
title: this.requestPage,
// eslint-disable-next-line no-useless-escape
text: '\n=== [[:' + this.pageName + ']] ===\n' + this.reason + ' ~~~~\n',
watchlist: 'watch',
editType: 'appendtext'
};
if ( this.isMobile() ) {
page.text += '\n<noinclude>[[Category:MobileUpload-related deletion requests]]</noinclude>';
}


this.showProgress( this.i18n.creatingNomination );
ohc_regex(/(@month)(?:, | of )(@yyyy\w)/gi, "$1 $2"); //repeat after delinking
this.savePage( page, this.subpage_summary, 'nextTask' );
},


/**
// spaces and commas - md-md and dm-dm date ranges
* Transclude the nomination page onto today's DR log page, creating it if necessary.
ohc_regex(/(\D\W)@Month\s@DD(&nbsp;|\s)(?:[-–—]|&[mn]dash;)(?:&nbsp;|\s)?@Month\s@DD(?=\W\D)/gi, "$1@LMonth1 @Day1$2– @LMonth2 @Day2");
* The log page will never be watchlisted (unless the user is already watching it).
ohc_regex(/(\D\W)@Month\s@DD(?:[-–—]|&[mn]dash;)(?:&nbsp;|\s)?@Month\s@DD(?=\W\D)/gi, "$1@LMonth1 @Day1 – @LMonth2 @Day2");
*/
ohc_regex(/(\D\W)@DD\s@Month(&nbsp;|\s)(?:[-–—]|&[mn]dash;)(?:&nbsp;|\s)?@DD\s@Month(?=\W\D)/gi, "$1@Day1 @LMonth1$2– @Day2 @LMonth2");
listRequestSubpage: function () {
ohc_regex(/(\D\W)@DD\s@Month(?:[-–—]|&[mn]dash;)(?:&nbsp;|\s)?@DD\s@Month(?=\W\D)/gi, "$1@Day1 @LMonth1 – @Day2 @LMonth2");
var page = {};
page.title = this.dailyLogPage;


// Impossible when using appendtext. Shouldn't not be severe though, since DRBot creates those pages before they are needed.
// spaces and commas - d-dm and md-d date ranges
// if (!page.text) page.text = "{{"+"subst:" + this.requestPagePrefix + "newday}}"; // add header to new log pages
ohc_regex(/(\D\W)@Month(\s|&nbsp;)@DD@th?(?:(?:\s*|&nbsp;|)[-–](?:\s*|&nbsp;|))@DD@th?(?=\W\D)/gi, "$1@LMonth1$2@Day1–@Day2");
page.text = '\n{{' + this.requestPage + '}}\n';
ohc_regex(/(\D\W)@DD@th?(?:(?:\s*|&nbsp;|)[-–](?:\s*|&nbsp;|))@DD@th?(\s|&nbsp;)@Month(?=\W\D)/gi, "$1@Day1–@Day2$2@LMonth1");
page.watchlist = 'preferences';
page.editType = 'appendtext';


this.showProgress( this.i18n.listingNomination );
// spaces and commas between month and year (again)
ohc_regex(/@Month(?:,\s+|\s+of\s+)@YYYY(\w)/gi, "@LMonth @YYYY$1");
}


this.savePage( page, 'Listing [[' + this.requestPage + ']]', 'nextTask' );
/** ------------------------------------------------------------------------- */
},
/// ISO to long format


isMobile: function () {
function ohc_ISO_to_dmy_in_citations()
var isMobile = false,
{
cats = conf.wgCategories;
//ISO dates within single citation
ohc_regex(/(\|\s*(?:publication|archive|access|air|designation\d?_|)-?date\s*=\s*)@YYYY[-–]@MM[-–]@DD(?=\W\D)/gi, "$1@Day @Month @YYYY");
}


for ( var i = 0, len = cats.length; i < len; i++ ) {
function ohc_ISO_to_mdy_in_citations()
isMobile = isMobile || /^Uploaded with Mobile/.test( cats[ i ] );
{
}
//ISO dates within single citation
ohc_regex(/(\|\s*(?:publication|archive|access|air|designation\d?_|)-?date\s*=\s*)@YYYY[-–]@MM[-–]@DD(?=\W\D)/gi,  "$1@Month @Day, @YYYY");
}


return isMobile;
function ohc_ISO_to_dmy_in_references()
},
{
//multiple calls for multiple dates within single citation
ohc_regex(/(<ref[^>]*>[^<]+?)([\s\(])@YYYY[-–]@MM[-–]@DD([^-\w\/%,<][^<]*?<\/ref>)/gi, "$1$2@Day @Month @YYYY$3");
ohc_regex(/(<ref[^>]*>[^<]+?)([\s\(])@YYYY[-–]@MM[-–]@DD(<\/ref>)/gi, "$1$2@Day @Month @YYYY$3");
}


listMobileUpload: function () {
function ohc_ISO_to_mdy_in_references()
var page = {
{
title: 'Commons:Deletion requests/mobile tracking',
//multiple calls for multiple dates within single citation
text: '\n{{' + this.requestPage + '}}\n',
ohc_regex(/(<ref[^>]*>[^<]+?)([\s\(])@YYYY[-–]@MM[-–]@DD([^-\w\/%,<][^<]*?<\/ref>)/gi, "$1$2@Month @Day, @YYYY$3");
watchlist: 'preferences',
ohc_regex(/(<ref[^>]*>[^<]+?)([\s\(])@YYYY[-–]@MM[-–]@DD(<\/ref>)/gi, "$1$2@Month @Day, @YYYY$3");
editType: 'appendtext'
}
};


this.showProgress( this.i18n.listingMobile );
// currently unused
 
function ohc_ISO_to_dmy_anywhere()
this.savePage( page, 'Listing [[' + this.requestPage + ']]', 'nextTask' );
{
},
//multiple calls for multiple dates within single citation
 
ohc_regex(/([^-\w/])@YYYY[-–]@MM[-–]@DD([^-\w/])/gi, '$1@Day @Month @YYYY$2');
listMobileUploadSpeedy: function () {
ohc_regex(/([^-\w/])@YYYY[-–]@MM[-–]@DD([^-\w/])/gi, '$1@Day @Month @YYYY$2');
var page = {
ohc_regex(/([^-\w/])@YYYY[-–]@MM[-–]@DD([^-\w/])/gi, '$1@Day @Month @YYYY$2');
title: 'Commons:Mobile app/deletion request tracking',
}
text: '\n# [[:' + this.pageName + ']]',
watchlist: 'preferences',
editType: 'appendtext'
};


this.showProgress( this.i18n.listingMobile );
// currently unused
function ohc_ISO_to_mdy_anywhere()
{
//multiple calls for multiple dates within single citation
ohc_regex(/([^-\w/])@YYYY[-–]@MM[-–]@DD([^-\w/])/gi, '$1@Month @Day, @YYYY$2');
ohc_regex(/([^-\w/])@YYYY[-–]@MM[-–]@DD([^-\w/])/gi, '$1@Month @Day, @YYYY$2');
ohc_regex(/([^-\w/])@YYYY[-–]@MM[-–]@DD([^-\w/])/gi, '$1@Month @Day, @YYYY$2');
}


this.savePage( page, 'Listing [[' + this.pageName + ']]', 'nextTask' );
function ohc_delink_ISO_to_dmy()
},
{
ohc_ISO_to_dmy_in_citations();
ohc_ISO_to_dmy_in_references();
regex(/([^\w\/\-%,])@YYYY-@MM-@DD(<\s?\/ref.*?>)/g, '$1@Day @Month @Year$2');
ohc_regex(/(\|\|[ ]*)@YYYY[-–]@MM[-–]@DD([ ]*\|\|)/gi, '$1{{dts|format=dmy|@YYYY|@MM|@DD}}$2');  //dts template for sortable tables
ohc_regex(/(\{\{dts\|format=)mdy\|/gi, '$1dmy|'); //flip dts template formats
}


/**
function ohc_delink_ISO_to_mdy()
* Check the users talkpage is not blocked indefinite
{
*/
ohc_ISO_to_mdy_in_citations();
verifyUserNotify: function ( user ) {
ohc_ISO_to_mdy_in_references();
this.queryAPI( {
regex(/([^\w\/\-%,])@YYYY-@MM-@DD(<\s?\/ref.*?>)/g, '$1@Month @Day, @Year$2');
prop: 'info',
ohc_regex(/(\|\|[ ]*)@YYYY[-–]@MM[-–]@DD([ ]*\|\|)/gi, '$1{{dts|@YYYY|@MM|@DD}}$2'); //dts template for sortable tables (mdy is default)
titles: this.userTalkPrefix + user,
ohc_regex(/(\{\{dts\|)format=(?:mdy|dmy|) ?\|/gi, '$1'); //flip dts template formats
redirects: 1,
}
inprop: 'protection'
}, 'verifyUserNotifyCB' );
},
verifyUserNotifyCB: function ( result ) {
var page;
this.notifyUser = true; // reset
if ( !result || !result.query || !result.query.pages ) {
mw.log.warn( 'Verify user: result.query.pages is undefined. ', result );
return this.uploaderNotified();
}


result = result.query.pages;
function ohc_delink_year_in_X()
for ( var pg in result ) {
{
pg = result[ pg ];
// ohc_regex(/\{\{(?:avyear|by|baseball\syear|fy|ly|mlby|mlb\syear|scy|sdy)\|(@year)\}\}/gi, "$1"); //disabled 3/5/21 discussion at https://en.wikipedia.org/w/index.php?title=Wikipedia_talk:WikiProject_Baseball&oldid=1021203365#Links_to_baseball_year_articles_in_infobox?
page = pg.title;
// ohc_regex(/\{\{(?:avyear|by|baseball\syear|fy|ly|mlby|mlb\syear|scy|sdy)\|@year\|(@year)\}\}/gi, "$1");
pg = pg.protection;
ohc_regex(/\[\[@yyyy\sin\s[^|\]]+\|((?:(?:@day |)@month |)@yyyy)\]\]/gi, '$1');
if ( pg ) {
regex(/\[\[(?:\d{4}[-–]\d{2} in English football)\|((?:(?:@Day |)@Month |)@YYYY)\]\]/gi, '$1');  
for ( var p = 0; p < pg.length; p++ ) {
var pt = pg[ p ];
if ( pt && pt.type === 'edit' && pt.level === 'sysop' ) {
// Disable report for protected userpages
this.disableReport = true;
// Disable notify for indefinite protected
if ( pt.expiry === 'infinity' ) {
this.notifyUser = false;
}


}
regex(/\[\[\d{4} Major League Baseball season\|(\d{4})(\sseason)?\]\]/gi, '$1$2');
}
}
}
}
if ( this.notifyUser && page ) {
page = {
title: page,
// eslint-disable-next-line no-useless-escape
text: '\n' + this.talk_tag + ' ~~~~\n',
editType: 'appendtext',
redirect: true,
minor: false
};
if ( window.AjaxDeleteWatchUserTalk ) {
page.watchlist = 'watch';
}


this.savePage( page, this.talk_summary, 'uploaderNotified' );
} else {
this.uploaderNotified();
}
},


/**
// format parameter must be 'dmy' or 'mdy'
* Notify any uploaders/creators of this page using {{idw}}.
function ohc_fix_dts_template(format)
*/
{
notifyUploaders: function () {
// dts - format=dmy in this case (per D12000)
this.uploadersToNotify = 0;
// per {{dts}} doc, remove the obsolete link=off param
if ( this.notifyUser ) {
regex(/(\{\{dts[^}]*)(?:\|link=off)/gi, '$1');
for ( var user in this.uploaders ) {
ohc_regex(/(\{\{dts\s*\|\s*@year\s*\|\s*@month\s*\|\s*@day\s*\|\s*format=)(?:dmy|mdy)(\}\})/gi, '$1'+format+'$2');
if ( Object.prototype.hasOwnProperty.call( this.uploaders, user ) ) {
ohc_regex(/(\{\{dts\s*\|\s*format=)(?:dmy|mdy)(\s*\|\s*@year\s*\|\s*@month\s*\|\s*@day\s*\}\})/gi, '$1'+format+'$2');
if ( user === conf.wgUserName ) {
ohc_regex(/(\{\{dts\s*\|\s*@year\s*\|\s*@month\s*\|\s*@day\s*)(\}\})/gi, '$1|format='+format+'$2');
// notifying yourself is pointless
continue;
}
this.verifyUserNotify( user );
this.showProgress( this.i18n.notifyingUploader.replace( '%USER%', user ) );
this.uploadersToNotify++;
}
}
}
if ( !this.uploadersToNotify ) {
this.nextTask();
}


},
  // stripping – {{dts}} serves no purpose inside date parameters
ohc_regex(/(\|(?:[\w ]*)date\s*=\s*)\{\{dts\s*\|\s*format=(?:dmy|mdy)\s*\|\s*([|}]*)\}\}(?=\s*[|}])/gi, "$1$2");
ohc_regex(/(\|(?:[\w ]*)date\s*=\s*)\{\{dts\s*\|\s*([|}]*)(?:\|\s*format=(?:dmy|mdy)\s*|)\}\}(?=\s*[|}])/gi, "$1$2");
ohc_regex(/(\|(?:[\w ]*)date\s*=\s*)\{\{dts\s*\|\s*format=(?:dmy|mdy)\s*\|\s*@YYYY(\s*\|\s*|-)@MM(\s*\|\s*|-)@DD\s*\}\}(?=\s*[|}])/gi, "$1@YYYY-@MM-@DD ");
ohc_regex(/(\|(?:[\w ]*)date\s*=\s*)\{\{dts\s*\|\s*@YYYY(\s*\|\s*|-)@MM(\s*\|\s*|-)@DD\s*\|\s*format=(?:dmy|mdy)\s*\}\}(?=\s*[|}])/gi, "$1@YYYY-@MM-@DD ");
}


uploaderNotified: function () {
// format parameter must be 'dmy' or 'mdy'
this.uploadersToNotify--;
function ohc_fix_gr_template(format)
if ( !this.uploadersToNotify ) {
{
this.nextTask();
// GR - date formatting parameter
}
// per {GR} doc, insert date formatting param
 
regex(/(\{\{GR\|\d\d?)(?!\|date)/gi, '$1|dateform=' + format);
},
}


/**
function ohc_dates_to_dmy()
* Compile a list of uploaders to notify. Users who have only reverted the file to an
{
* earlier version will not be notified.
regex(/\|df=[mdy]{3}(?:-all|)(?=\s*[|}])/gi, '');
* DONE: notify creator of non-file pages
regex(/\|format=mdy/gi, '|format=dmy');
* DONE: notify fileimporter (2019-09-09)
//change start and end templates; vgrelease new v=2 or mdy is default
*/
regex(/(\{\{(?:start date|end date)[^|}]*\|)df=ye?s?\|([^}]*df=ye?s?)/gi, '$1$2');
findCreator: function () {
regex(/(\{\{vgrelease new[^|}]*\|)(?:v=1\||)([A-Z]{2,3}\|)/g, '$1v=2|$2');
var q = {
ohc_regex(/(\|\s*(?:begin|end|first|last)\s*=\s*)@YYYY[-–]@MM[-–]@DD(?=\W\D)/gi, "$1@Day @Month @YYYY"); //spotted at [[Template:Infobox recurring event]]
curtimestamp: 1,
meta: 'tokens',
//change birth and death templates
prop: 'revisions',
regex(/(\{\{(?:(?:Birth|Death) date(?: and age|)|launch|release|start)[^}]*\|)m(f=ye?s?)/gi, '$1d$2'); // substitute df for mf
titles: this.pageName,
regex(/(\{\{(?:(?:Birth|Death) date(?: and age|)|launch|release|start|film ?date|Wayback)[\|\d]+)(\}\})/gi, '$1|df=y$2'); //insert df parameter
rvprop: 'timestamp|user',
regex(/(\{\{(?:(?:Birth|Death) date(?: and age|)|launch|release|start|film ?date|Wayback)[\|\d]+\|)df=ye?s?\|([^}]*df=ye?s?)/gi, '$1$2'); //put date format parameter at the end
rvdir: 'newer',
regex(/(\{\{(?:start date|end date)\|)df=ye?s?\|((?:1[789]|20)\d{2}\}\})/gi, '$1$2'); //date format parameter not needed – year only
rvslots: 'main',
rvlimit: 1
};


if ( nsNr === 6 ) {
//convert date ranges (md,d,d-dy to d,d,d-dmy; md,d,d-d to d,d,d-dm; md,d,d to d,d,dm)
$.extend( q, {
ohc_regex(/(\D\W)@Month((?:\s@day?,?){1,6}),?(\/|\s?(?:[-–]|&ndash;)\s?|(?:[ _]|&nbsp;)(?:and|&|to|or)(?:[ _]|&nbsp;)+?)@Day,?\s(?:of\s)?(@yyyy\W\D)/gi, "$1$2$3@Day @LMonth $4");
prop: q.prop + '|imageinfo',
ohc_regex(/(\D\W)@Month((?:\s@day?,?){1,6}),?(\/|\s?(?:[-–]|&ndash;)\s?|(?:[ _]|&nbsp;)(?:and|&|to|or)(?:[ _]|&nbsp;)+?)@Day(?=\W\D)/gi, "$1$2$3@Day @LMonth");
rvprop: q.rvprop + '|content',
iiprop: 'user|comment|sha1',
iilimit: '50',
list: 'logevents',
letype: 'import',
leprop: 'user',
letitle: this.pageName
} );
}


this.showProgress( this.i18n.preparingToEdit );
// ohc_regex(/(\D\W)@Month((?:\s@day?,?){1,6}) @Day(?=\W\D)/gi, "$1$2 @Day @LMonth"); //disabling as unlikely and ungrammatical constructions causing false positives
this.queryAPI( q, 'findCreatorCB' );
},


findCreatorCB: function ( r ) {
//'md, md,' to 'dm, dm,'
this.uploaders = {};
ohc_regex(/(\D\W)@Month @Day, @Month @Day(?=[,\.]\W\D)/gi, "$1@Day1 @LMonth1, @Day2 @LMonth2");


if ( !r || !r.query || !r.query.pages ) {
//convert simple mdy dates to dmy
this.disableReport = true;
ohc_regex(/(p(?:g?\.?|age) ?\d+|p(?:p\.?|ages) ?\d+[-–]\d+), @Month((?:\s@day?,?){1,6}) @Day(?=\W\D)/gi, "$1. $2 @Day @LMonth");
throw new Error( this.i18n.noPageFound );
ohc_regex(/(\D\W)@Month\s@Day,?\s@Year(\s?(?:AD|BC|CE|BCE)\W\D)/gi, "$1@Day @LMonth @Year$2");
}
ohc_regex(/(\|\s*term_(?:end|start)\d\s*=\s*|\D\W)@Month\s@Day,?\s@YYYY(?=\W\D)/gi, "$1@Day @LMonth @Year");
var q = r.query,
ohc_regex(/(\|\s*term_(?:end|start)\d\s*=\s*|\D\W)@Month\s@Day(?=\W\D)/gi, "$1@Day @LMonth");
pg = _firstItem( q.pages ),
rv;
 
if ( !pg || !pg.revisions ) {
throw new Error( this.i18n.noCreatorFound );
}
 
// The csrftoken only changes between sessions
this.csrftoken = q.tokens.csrftoken;
rv = pg.revisions[ 0 ];


// First handle non-file pages
//Month+day_number " 7th মার্চ" -> "7 মার্চ"
if ( nsNr !== 6 || !pg.imageinfo ) {
ohc_regex(/(\D\W)@Day\s@Month\s@YYYY(?=\W\D)/gi, "$1@Day @LMonth @Year");
this.starttimestamp = r.curtimestamp;
ohc_regex(/(\D\W)@Day\s@Month(?=\W\D)/gi, "$1@Day @LMonth");
this.timestamp = rv.timestamp;
ohc_regex(/(\D\W)@Month\s@Day,?\s@Year(?=\W\D)/gi, "$1@Day @LMonth @Year");


if ( ( this.pageCreator = rv.user ) ) {
//dates with embedded nbsp
this.uploaders[ this.pageCreator ] = true;
ohc_regex(/(\D\W)@Month([ _]|&nbsp;)(\d{1,2},(?: |&nbsp;)\d{1,2}(?:\s(?:and|&|to|or)(?:[ _]|&nbsp;))\d{1,2})(?=[^|\]\w])/gi, '$1$3$2@LMonth ');
}
ohc_regex(/(\D\W)@Month([ _]|&nbsp;|{{(?:break|nbsp)}})@Day,([ _]|&nbsp;|{{(?:break|nbsp)}})@YYYY(?=[^|\]\w])/gi, '$1@Day$2@Month$3@Year');


} else {
//remove comma
var info = pg.imageinfo,
ohc_regex(/(\D\W)@Day\s@Month,\s?@Year(?=\W\D)/gi, "$1@Day @LMonth @Year");
i = info.length,
content = rv.slots.main[ '*' ],
seenHashes = {};
// Iterate in reverse order (sha1 check)
for ( --i; i >= 0; i-- ) {
var iii = info[ i ],
rev = seenHashes[ iii.sha1 ];
// Skip reverts and remove users
if ( iii.sha1 && rev ) {
for ( rev; rev > i; rev-- ) {
var u = info[ rev - 1 ].user;
if ( this.uploaders[ u ] < rev ) {
delete this.uploaders[ u ];
}


}
// remove "the" from "on the dd month"
continue;
ohc_regex(/(on |by )the @Day\s@Month(?=[ ,\)\.])/gi, "$1@Day @LMonth");
}
seenHashes[ iii.sha1 ] = i + 1;
// No need to check again the whole shebang
if ( this.uploaders[ iii.user ] ) {
continue;
}


// Now exclude bots which only reupload a new version:
//remove space from date range conversion
if ( mw.libs.commons.isSmallChangesBot( iii.user ) ) {
ohc_regex(/(\D ) @Day(\/|\s?(?:[-–]|&ndash;)\s?|(?:[ _]|&nbsp;)(?:and|&|to|or)(?:[ _]|&nbsp;)+?)/gi, "$1@Day$2");
continue;
}
}


// Outsourced to MediaWiki:Gadget-libCommons.js
function ohc_dates_to_mdy()
iii = mw.libs.commons.getUploadBotUser( iii.user, content, iii.comment, rv.user );
{
if ( iii ) {
//change birth and death templates – mf=y is the default; vgrelease new v=2 or mdy is default
this.uploaders[ iii ] = i + 1;
regex(/\|df=[mdy]{3}(?:-all|)(?=\s*[|}])/gi, '');
}
regex(/\|df=y(?:es|)(?=[|}\s])/gi, '');
regex(/(mf=y(?:es|)\|[^}]*\|)(?:mf=y(?:es|)\|)/gi, '$1');
regex(/(\{\{vgrelease new[^|}]*\|)(?:v=2\||)([A-Z]{2,3}\|)/g, '$1$2');
ohc_regex(/(\|\s*(?:begin|end|first|last)\s*=\s*)@YYYY[-–]@MM[-–]@DD(?=\W\D)/gi, "$1@Month @Day, @YYYY");


}
//convert date ranges (d,d,d-dmy to md,d,d-dy; d,d,d-dm to md,d,d-d; dm,d,d to md,d,d)
// Get fileimporter
ohc_regex(/(\D\W)@Day((?:, @day){0,5})(\/|\s?(?:[-–]|&ndash;)\s?|\s(?:and|&|to|or)\s+?)@Day\s@Month,? @YYYY(?=\W\D)/gi, "$1@LMonth @Day1$2$3@Day2, @YYYY");
if ( ( info = q.logevents ) && ( i = info.length ) ) {
ohc_regex(/(\D\W)@Day((?:, @day){0,5})(\/|\s?(?:[-–]|&ndash;)\s?|\s(?:and|&|to|or)\s+?)@Day\s@Month(?=\W\D)/gi, "$1@LMonth @Day1$2$3@Day2");
for ( --i; i >= 0; i-- ) {
// ohc_regex(/(\D\W)@Day((?:, @day){0,5})\s@Month,? @YYYY(?=\W\D)/gi, "$1@LMonth @Day1$2, @YYYY"); //disabling as unlikely and ungrammatical constructions causing false positives
if ( info[ i ].user ) {
// ohc_regex(/(\D\W)@Day((?:, @day){0,5})\s@Month(?=\W\D)/gi, "$1@LMonth @Day1$2"); //disabling as unlikely and ungrammatical constructions causing false positives
this.uploaders[ info[ i ].user ] = true;
}
}
 
}


}
//'dm, dm,' to 'md, md,'
this.nextTask();
ohc_regex(/(\D\W)@Day @Month, @Day @Month(?=[,\.]?\W\D)/gi, "$1@LMonth1 @Day1, @LMonth2 @Day2");
},


getMoveToken: function () {
//convert simple dmy dates to mdy
this.showProgress( this.i18n.preparingToEdit );
ohc_regex(/(p(?:g?\.?|age) ?\d+|p(?:p\.?|ages) ?\d+[-–]\d+), @Month((?:\s@day?,?){1,6}) @Day(?=\W\D)/gi, "$1. @LMonth $2 @Day");
var query = {
ohc_regex(/(\D\W)@Day(\s|&nbsp;)@Month,?(\s|&nbsp;)@Year(?=\W\D)/gi, "$1@LMonth$2@Day,$3@Year");
curtimestamp: 1,
ohc_regex(/(\|\s*term_(?:end|start)\d\s*=\s*|\D\W)@Day[ ]+@Month,?\s@YYYY(?=\W\D)/gi, "$1@LMonth @Day, @Year");
prop: 'info|revisions',
ohc_regex(/(\|\s*term_(?:end|start)\d\s*=\s*|\D\W)@Day[ ]+@Month(?=\W\D)/gi, "$1@LMonth @Day");
meta: 'tokens',
rvprop: 'content|timestamp',
inprop: 'watched',
titles: this.pageName || pageName.replace( /_/g, ' ' )
};
if ( !this.declineReason ) {
query.prop += '|imageinfo';
query.iiprop = 'mediatype|mime|timestamp';
}
this.queryAPI( query, 'getMoveTokenCB' );
},


/**
//Month+day_number "মার্চ 7th" -> "মার্চ 7"
* @brief [callback] Prepare page for saving before
ohc_regex(/(\D\W)@Month\s@Day@th?,?\s@YYYY(?=\W\D)/gi, "$1@LMonth @Day, @YYYY");
* @param [in] result of query
ohc_regex(/(\D\W)@Day@th?(\s|&nbsp;)@Month(\s|&nbsp;)@YYYY(?=\W\D)/gi, "$1@LMonth$2@Day,$3@YYYY");
* @return csrftoken, pageContent, starttimestamp, timestamp, imagetimestamp, mimeFileExtension, pageWasWatched
ohc_regex(/(\D\W)@Month(\s|&nbsp;)@Day(?=\W\D)/gi, "$1@LMonth$2@Day");
*/
ohc_regex(/(\D\W)@Day@th?(\s|&nbsp;)@Month([,\.])(?=\W\D)/gi, "$1@LMonth$2@Day$3");
getMoveTokenCB: function ( result ) {
var q = result.query || {},
pg = _firstItem( q.pages );
if ( !pg || !pg.revisions ) {
this.disableReport = true;
throw new Error( this.i18n.noPageFound );
}
// The csrftoken only changes between sessions
$.extend( this, {
csrftoken: q.tokens.csrftoken,
pageContent: pg.revisions[ 0 ][ '*' ],
starttimestamp: result.curtimestamp,
timestamp: pg.revisions[ 0 ].timestamp
} );


if ( pg.watched !== undefined ) {
//add comma where missing
this.pageWasWatched = true;
ohc_regex(/(\D\W)@Month\s@Day,?\s@YYYY,?(?=\s\w)/gi, "$1@LMonth @Day, @YYYY,");
}
//rem superfluous comma where applicable
ohc_regex(/(\D[^\w\/])@Month\s@ZD,,(?=\W\D|\b)/gi, "$1@LMonth @Day,");
}


var ii = pg.imageinfo;
function ohc_fix_dmy_redundancies()
if ( ii && ii.length && ii[ 0 ].mime ) {
{
ii = ii[ 0 ];
//month-range redundancies (repeating month names)
this.imagetimestamp = ii.timestamp;
ohc_regex(/([\D]@dd)@th? @Month[ ]{1,2}((?:to|and|-|)[ ]{1,2}@dd)@th? @Month/, "$1 $2 @LMonth", function(d1, d2) {
this.mimeFileExtension = ii.mime
if (d1.m == d2.m) return true;
.toLowerCase()
return false;
.replace( 'image/jpeg', 'jpg' )
});
.replace( /image\/(?:x-|vnd\.)?(png|gif|xcf|djvu|svg|tiff)(?:\+xml)?/, '$1' )
}
.replace( /application\/(ogg|pdf)/, '$1' )
//not currently used
.replace( /video\/(webm)/, '$1' )
function ohc_fix_mdy_redundancies()
.replace( 'audio/midi', 'mid' )
{
.replace( /audio\/(?:x-|vnd\.)?wave?/, 'wav' )
//month-range redundancies (repeating month names)
.replace( /audio\/(?:x-)?flac/, 'flac' );
ohc_regex(/(@Month[ ]{1,2}@dd)@th? (to|and|-|–)[ ]{1,2}@Month[ ]{1,2}@DD@th?/, "$1 $2 @LDay", function(d1, d2) {
if ( this.mimeFileExtension.length > 5 ) {
if (d1.m == d2.m) return true;
this.mimeFileExtension = '';
return false;
} else if ( this.mimeFileExtension === 'ogg' ) {
});
switch ( ii.mediatype ) {
}
case 'AUDIO':
this.mimeFileExtension = 'oga';
break;
case 'VIDEO':
this.mimeFileExtension = 'ogv';
break;
}
}
}
this.nextTask();
},
 
doesFileExist: function () {
if ( !this.destination ) {
// eslint-disable-next-line no-alert
return alert( this.i18n.moveDestination );
}
this.destination = this.cleanFileName( this.destination );
var query = {
prop: 'info|revisions',
titles: this.destination,
rvprop: 'content',
rvlimit: 2
};
// usually you would use 'redirects': 1, to detect the redirect target but
// in this case you would get the revisions for the target and not the redirect
 
this.showProgress( this.i18n.checkFileExists );
this.queryAPI( query, 'doesFileExistCB' );
},
 
/**
*  Return nextTask if the page does not exist
*  or it is a redirect with one revision to the source
*/
doesFileExistCB: function ( result ) {
if ( !result || !result.query || !result.query.pages ) {
throw new Error( 'Checking filename: result.query.pages is undefined. ' + this.destination );
}


var exists = true,
function ohc_expand_ref_dates()
pg = _firstItem( result.query.pages ),
{
getRedirRegExp = function ( title ) {
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month @YYYY(?=\s*[|}])/gi, "$1@FullMonth @YYYY");
title = title.replace( /^(File|Image):/, '' ).replace( /_/g, ' ' );
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Day @Month @YYYY(?=\s*[|}])/gi, "$1@Day @FullMonth @YYYY");
return new RegExp( '^\\s*#REDIRECT\\s*\\[\\[File\\:[' +
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month @Day, @YYYY(?=\s*[|}])/gi, "$1@FullMonth @Day, @YYYY");
mw.util.escapeRegExp( title[ 0 ].toUpperCase() ) + mw.util.escapeRegExp( title[ 0 ].toLowerCase() ) + ']' +
mw.util.escapeRegExp( title.slice( 1 ) ).replace( / /g, '[ _]' ) +
'\\s*\\]\\]',
'' );
};


if ( pg.missing !== undefined ) {
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)((?:[01-2]?\d|30|31) |)@Month @YYYY ?(?:-|–|&ndash;) ?((?:[01-3]?\d|30|31) |)@Month @YYYY(?=\s*[|}])/gi, "$1$2 @FullMonth1 @YYYY1 – $3@FullMonth2 @YYYY2");
exists = false;
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month @Day(, (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month @Day, @YYYY(?=\s*[|}])/gi, "$1@FullMonth1 @Day1$2 – @FullMonth2 @Day2, @YYYY");
} else if ( !pg.revisions || pg.revisions.length === 1 && getRedirRegExp( pageName )
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Day @Month,?( (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Day @Month @YYYY(?=\s*[|}])/gi, "$1@Day1 @FullMonth1$2 – @Day2 @FullMonth2 @YYYY");
.test( pg.revisions[ 0 ][ '*' ].replace( 'Image:', 'File:' ) ) ) {
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month,?( (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month,? @YYYY(?=\s*[|}])/gi, "$1@FullMonth1$2 – @FullMonth2 @YYYY");
// There seems to be no way to find out whether a title is a redirect
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)((?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month @YYYY(?=\s*[|}])/gi, "$1@$2 – @FullMonth @YYYY");
// and whether the redirect only consists of one revision
exists = false;
}


if ( exists ) {
ohc_regex(/(<ref[^>]*>(?:[^<]+?[\s\(]|))((?:[01-2]?\d|30|31) |)@Month @YYYY ?(?:-|–|&ndash;) ?((?:[01-3]?\d|30|31) |)@Month @YYYY(?=(?:[^-\w\/%,<][^<]*?|)<\/ref>)/gi, "$1$2@FullMonth1 @YYYY1 – $3@FullMonth2 @YYYY2");
if ( this.fileNameExistsCB ) {
ohc_regex(/(<ref[^>]*>(?:[^<]+?[\s\(]|))@Month @Day(, (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month @Day, @YYYY(?=(?:[^-\w\/%,<][^<]*?|)<\/ref>)/gi, "$1@FullMonth1 @Day1$2 – @FullMonth2 @Day2, @YYYY");
this[ this.fileNameExistsCB ]( pg.title.replace( /^File:/, '' ) );
ohc_regex(/(<ref[^>]*>(?:[^<]+?[\s\(]|))@Day @Month,?( (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Day @Month @YYYY(?=(?:[^-\w\/%,<][^<]*?|)<\/ref>)/gi, "$1@Day1 @FullMonth1$2 – @Day2 @FullMonth2 @YYYY");
}
ohc_regex(/(<ref[^>]*>(?:[^<]+?[\s\(]|))@Month,?( (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month,? @YYYY(?=(?:[^-\w\/%,<][^<]*?|)<\/ref>)/gi, "$1@FullMonth1$2 – @FullMonth2 @YYYY");
return;
ohc_regex(/(<ref[^>]*>(?:[^<]+?[\s\(]|))((?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month @YYYY(?=(?:[^-\w\/%,<][^<]*?|)<\/ref>)/gi, "$1$2 – @FullMonth @YYYY");
}
}
this.nextTask();
},


removeTemplate: function () {
function ohc_expand_all_dates()
this.replaceWith = ( this.replaceWith || ( this.templateRegExp ? '' : '$1$2' ) );
{
// Remove the template from the text. In case there is an empty line before, remove this also.
ohc_regex(/([^-\w/])@Month @YYYY(?=[^-\w/])/gi, '$1@FullMonth @YYYY');
var newText = this.pageContent
ohc_regex(/([^-\w/])@Day @Month @YYYY(?=[^-\w/])/gi, '$1@Day @FullMonth @YYYY');
.replace(
ohc_regex(/([^-\w/])@Month @Day, @YYYY(?=[^-\w/])/gi, '$1@FullMonth @Day, @YYYY');
( this.templateRegExp || /(?:([^=])\n)?\{\{(?:rename|rename media|move)\s*\|.*?\}\}(?:\n([^=]))?/i ),
this.replaceWith
);
if ( newText === this.pageContent ) {
return this.nextTask();
}


this.showProgress( this.i18n.removingTemplate );
ohc_regex(/([^-\w/])((?:[01-2]?\d|30|31) |)@Month @YYYY ?(?:-|–|&ndash;) ?((?:[01-3]?\d|30|31) |)@Month @YYYY(?=[^-\w/])/gi, "$1$2@FullMonth1 @YYYY1 – $3@FullMonth2 @YYYY2");
newText = this.pageContent = newText.trim();
ohc_regex(/([^-\w/])@Month @Day(, (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month @Day, @YYYY(?=[^-\w/])/gi, "$1@FullMonth1 @Day1$2 – @FullMonth2 @Day2, @YYYY");
ohc_regex(/([^-\w/])@Day @Month,?( (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Day @Month @YYYY(?=[^-\w/])/gi, "$1@Day1 @FullMonth1$2 – @Day2 @FullMonth2 @YYYY");
ohc_regex(/([^-\w/])@Month,?( (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month,? @YYYY(?=[^-\w/])/gi, "$1@FullMonth1$2 – @FullMonth2 @YYYY");
ohc_regex(/([^-\w/])((?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month @YYYY(?=[^-\w/])/gi, "$1$2 – @FullMonth @YYYY");


// We have another save request
ohc_regex(/([ ]\(|\|\s*)@Day @Month @YYYY(?=\)\W|\s*[|\n])/gi, "$1@Day @FullMonth @YYYY");
if ( this.templateReplace ) {
ohc_regex(/([ ]\(|\|\s*)@Month @Day,? @YYYY(?=\)\W|\s*[|\n])/gi, "$1@FullMonth @Day, @YYYY");
this.img_summary = this.declineReason;
ohc_regex(/([ ]\((?:c\. |))@Month @YYYY ?(?:-|–|&nbsp;) ?@Day @Month @YYYY(?=\)\W)/gi, "$1@FullMonth1 @YYYY1 – @Day @FullMonth2 @YYYY2");
return this.nextTask();
ohc_regex(/([ ]\((?:c\. |))@Month @YYYY ?(?:-|–|&nbsp;) ?@Month @YYYY(?=\)\W)/gi, "$1@FullMonth1 @YYYY1 – @FullMonth2 @YYYY2");
}
ohc_regex(/([ ]\((?:c\. |))@YYYY ?(?:-|–|&nbsp;) ?@Month @YYYY(?=\)\W)/gi, "$1@YYYY1 – @FullMonth @YYYY2");
if ( !this.declineReason ) {
ohc_regex(/([ ]\((?:c\. |))@Month ?(?:-|–|&nbsp;) ?@Month @YYYY(?=\)\W)/gi, "$1@FullMonth1 – @FullMonth2 @YYYY");
this.img_summary = 'Removing template; rename done';
ohc_regex(/([ ]\((?:c\. |))@Month @YYYY(?=\)\W)/gi, "$1@FullMonth @YYYY");
}
}


// If nothing remains, add the no-license-template (this also to prevent abuse filter blocking this edit because of page blanking)
function ohc_abbrev_ref_dates()
this.replaceTemplate( newText || '{{subst:nld}}' );
{
},
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Day @Month @YYYY(?=\s*[|}])/gi, "$1@Day @Mon @YYYY");
 
ohc_regex(/(<ref[^>]*>(?:[^<]+?[\s\(]|))([12]?\d|30|31) (জানুয়ারি|ফেব্রুয়ারি|মার্চ|এপ্রিল|মে|জুন|জুলাই|আগষ্ট|অক্টোবর|Oct|নভেম্বর|ডিসেম্বর)(?:r?uary|ch|il|[ey]|ust|(?:t?em|o)ber)( (?:19\d|20[01])\d)(?=(?:[^-\w\/%,<][^<]*?|)<\/ref>)/gi, "$1$2 $3$4");
replaceUsage: function () {
ohc_regex(/([ ]\()@Day @Month @YYYY([^-\w\/])/gi, "$1@Day @Mon @YYYY$2");
if ( !this.inUse ) {
return this.nextTask();
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month @Day, @YYYY(?=\s*[|}])/gi, "$1@Mon @Day, @YYYY");
}
ohc_regex(/(<ref[^>]*>(?:[^<]+?[\s\(]|))(জানুয়ারি|ফেব্রুয়ারি|মার্চ|এপ্রিল|মে|জুন|জুলাই|আগষ্ট|অক্টোবর|Oct|নভেম্বর|ডিসেম্বর)(?:r?uary|ch|il|[ey]|ust|(?:t?em|o)ber) ([12]?\d|30|31),( (?:19\d|20[01])\d)(?=(?:[^-\w\/%,<][^<]*?|)<\/ref>)/gi, "$1$2 $3,$4");
 
ohc_regex(/([^-\w\/])@Month @Day, @YYYY([^-\w\/])/gi, '$1@Mon @Day, @YYYY$2');
this.showProgress( this.i18n.replacingUsage );
}
var reasonShort = '[[COM:Duplicate|Duplicate]]:';
 
//not currently used
if ( !this.details ) {
function ohc_abbrev_all_dates()
AQD.reason = AQD.reason.replace( /\[\[Commons:File[_ ]renaming[^[\]]*\]\]:? ?/i, '' );
{
reasonShort = '[[COM:FR|File renamed]]:';
ohc_regex(/([^-\w/])@Day @Month @YYYY(?=[^-\w/])/gi, '$1@Day @Mon @YYYY');
}
ohc_regex(/([^-\w/])@Month @Day, @YYYY(?=[^-\w/])/gi, '$1@Mon @Day, @YYYY');
mw.loader.using( 'ext.gadget.libGlobalReplace', function () {
}
if ( AQD.replaceUsingCORS ) {
mw.libs.globalReplace( pageName, AQD.destination, reasonShort, AQD.reason )
.fail( function ( err ) {
throw new Error( err );
} )
.done( function () {
AQD.nextTask();
} )
.progress( function ( r ) {
AQD.showProgress( r );
mw.log( r );
 
} );
} else {
mw.libs.globalReplaceDelinker( pageName, AQD.destination, reasonShort + ' ' + AQD.reason, function () {
AQD.nextTask();
}, function ( err ) {
throw new Error( err );
} );
}
} );
},
redirectPage: function () {
var page = {
title: pageName,
text: '#REDIRECT [[' + this.destination + ']]',
editType: 'text',
watchlist: AQD.pageWasWatched ? 'watch' : 'preferences'
};


this.showProgress( this.i18n.redirectingFile );
//not currently used
this.savePage( page, 'Redirecting to duplicate file', 'nextTask' );
function ohc_dmy_publication_dates()
},
{
saveDescription: function () {
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month @Day,? @YYYY/gi, "$1@Day @Month @YYYY"); // conversion of dates in references outside of the protection loop (eg for quotations etc.)
var page = {
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)(?:\[\[)?@YYYY(?:\]\][-–]\[\[|[-–])@MM[-–]@DD(?:\]\])?(?=\s*[|}])/gi, "$1@Day @Month @YYYY");
title: this.destination,
//replace ISO dates (within parentheses) only within refs
text: this.newPageText,
ohc_regex(/(<ref[^>]*>[^<]+?)([ ]\()@YYYY-@MM-@DD(\))(\W[^<]*?<\/ref>)/gi, "$1$2@Day @Month @YYYY$3$4");
editType: 'text',
}
watchlist: AQD.pageWasWatched ? 'watch' : 'preferences'
};


this.showProgress( this.i18n.savingDescription );
function ohc_mdy_publication_dates()
this.savePage( page, 'Merging details from duplicate ([[' + pageName + ']])', 'nextTask' );
{
},
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Day @Month @YYYY/gi, "$1@Month @Day, @YYYY"); // conversion of dates in references outside of the protection loop (eg for quotations etc.)
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)(?:\[\[)?@YYYY(?:\]\][-–]\[\[|[-–])@MM[-–]@DD(?:\]\])?(?=\s*[|}])/gi, "$1@Month @Day, @YYYY");  
//replace ISO dates (within parentheses) only within refs
ohc_regex(/(<ref[^>]*>[^<]+?)([ ]\()@YYYY-@MM-@DD(\))(\W[^<]*?<\/ref>)/gi, "$1$2@Month @Day, @YYYY$3$4");
}


/**
function ohc_Bigendian_ref_dates() {
*  Updates the redirects to the current page
// Add a tag to the summary box
*  when moving or processing dupes immediately
regex(/(\{\{use (?:mdy|dmy) dates)(?:\|cs1-dates=\w{1,2}|)(\|[^\}\|]+\}\})/gi, '$1|cs1-dates=y$2');
*  to prevent double redirects
}
*/
queryRedirects: function () {
mw.loader.using( 'mediawiki.api' ).then( function () {
return new mw.Api().loadMessagesIfMissing( [
'Whatlinkshere'
] );
} ).then( function () {
AQD.showProgress( mw.msg( 'Whatlinkshere' ) );
// TODO: Replace also the redirects inclusions!?
AQD.queryAPI( {
generator: 'backlinks',
gblfilterredir: 'redirects',
prop: 'revisions',
rvprop: 'content',
gbltitle: AQD.pageName || pageName.replace( /_/g, ' ' )
}, AQD.queryRedirectsCB ?
AQD.queryRedirectsCB :
'updateRedirects' );
} );
},


updateRedirects: function ( result ) {
/** ------------------------------------------------------------------------ **/
AQD.redirectsToUpdate = 0;
/// EDIT SUMMARIES & USE DMY TEMPLATE
if ( result.query && result.query.pages ) {
// this function modified 2019-03-27 from [[Special:Permalink/846525463]]
this.showProgress( this.i18n.updRedir );
// format parameter must be 'dmy' or 'mdy'
$.each( result.query.pages, function ( id, pg ) {
function ohc_use_dates_template(format)  
var rv = pg.revisions[ 0 ];
{
if ( !rv || !rv[ '*' ] ) {
var txt = document.editform.wpTextbox1;
return;
// current month-year
}
var currentDate = new Date();
var currmonth = currentDate.getMonth();
var curryear = currentDate.getFullYear();
var myMonths = ["জানুয়ারি", "ফেব্রুয়ারি", "মার্চ", "এপ্রিল", "মে", "জুন", "জুলাই", "আগষ্ট", "সেপ্টেম্বর", "অক্টোবর", "নভেম্বর", "ডিসেম্বর"];
var curryyyymm = myMonths[currmonth] + ' ' + curryear;


// Update only redirects with same mimetype
// step 1: normalize redirect template names to canonical template names 'Use dmy dates' or 'Use mdy dates' according to 'format' argument
if ( AQD.checkFileExt( pg.title, AQD.destination, true ) ) {
// rename redirects 'dmy', 'mdy', 'usedmydates', 'usemdydates' ('usedmydates' and 'usemdydates' are not currently listed as redirects but might be encountered?)
return mw.log( 'Redirect skipped, not same mimetype.', pg.title );
regex(/\{\{ *(?:use(?:dmy|mdy)dates|dmy|mdy) *([\|\}])/gi, '{{Use ' + format + ' dates$1');
}
// rename redirects 'usedmy', 'usemdy', 'use dmy', 'use mdy' to canonical form
regex(/\{\{ *use *(?:dmy|mdy) *([\|\}])/gi, '{{Use ' + format + ' dates$1');
// strip leading / trailing whitespace from 'use xxx dates'
regex(/\{\{ *use (?:dmy|mdy) dates *([\|\}])/gi, '{{Use ' + format + ' dates$1');


var page = {
// step 2: look for a canonical template name (the above might not have had anthing to work on) ; if found continue, write new template else
title: pg.title,
var rxpdd = new RegExp("{{Use " + format + " dates", "gi"); // here we search for canonical form {{use xxx dates}} that has current date
text: rv[ '*' ].replace( /#\s*REDIRECT\s*\[\[.+/, '#REDIRECT [[' + AQD.destination + ']]' ),
var dflagfound = txt.value.search(rxpdd);
editType: 'text',
if (dflagfound === -1) {
watchlist: 'preferences'
txt.value = '{{Use ' + format + ' dates|date=' + curryyyymm + '}}\r\n' + txt.value; // not found so insert new template at top of wikitext
};
return; // and done
}


AQD.savePage( page, 'Updating redirect while processing [[' + pageName.replace( /_/g, ' ' ) + ']]', 'updateRedirectsCB' );
// step 3: rewrite existing canonical templates; add or refresh |date= to current month year; preserve |cs1-dates= as is
AQD.redirectsToUpdate++;
regex(/(\{\{use (?:dmy|mdy) dates)\| *date *=[^\|]*\| *cs1\-dates *= *([^\|\}]*?) *\}\}/gi, '$1|date=' + curryyyymm + '|cs1-dates=$2}}'); // with |date= followed by |cs1-dates=
} );
regex(/(\{\{use (?:dmy|mdy) dates)\| *cs1\-dates *= *([^\|\}]*?) *\| *date *=[^\}]*\}\}/gi, '$1|date=' + curryyyymm + '|cs1-dates=$2}}'); // with |cs1-dates= followed by |date=
}
regex(/(\{\{use (?:dmy|mdy) dates)\| *date *=[^\|\}]*\}\}/gi, '$1|date=' + curryyyymm + '}}'); // with |date=
if ( !AQD.redirectsToUpdate ) {
regex(/(\{\{use (?:dmy|mdy) dates)\| *cs1\-dates *= *([^\|\}]*?) \}\}/gi, '$1|date=' + curryyyymm + '|cs1-dates=$2}}'); // with |cs1-dates
AQD.nextTask();
regex(/(\{\{use (?:dmy|mdy) dates)\}\}/gi, '$1|date=' + curryyyymm + '}}'); // no parameters so add |date=curryyyymm
}
regex(/(\{\{[\t_ ]*use[\t_ ]+(?:dmy|mdy)[\t_ ]+dates[^{}]*\}\})([\r\n\t ]*)(\{\{[\t ]*short description[^{}]*\}\})/gi, '$3$2$1'); // repositioning "short description" template at the top
}


},


updateRedirectsCB: function () {
AQD.redirectsToUpdate--;
if ( !AQD.redirectsToUpdate ) {
AQD.nextTask();
}


},
/** ------------------------------------------------------------------------ **/
/// DATE PROTECTION


/**
var linkmap = [];
* Pseudo-Modal JS windows.
*/
prompt: function ( questions, title, width ) {
var o = this,
dlgButtons = {};
dlgButtons[ this.i18n.submitButtonLabel ] = function () {
questions.forEach( function ( v, i ) {
var response = document.getElementById( 'AjaxQuestion' + i );
response = ( v.type === 'checkbox' ) ? response.checked : response.value;
if ( v.cleanUp ) {
if ( v.returnvalue === 'reason' ) {
response = AQD.cleanReason( response );
}


if ( v.returnvalue === 'destination' ) {
function ohc_protect_dates()
response = AQD.cleanFileName( response );
{
}
// protects dates within links, quotes, etc
 
// the sensitive part is stored and replaced with a unique identifier,
}
// which is later replaced with the stored part.
AQD[ v.returnvalue ] = response;
if ( v.returnvalue === 'reason' && AQD.tag ) {
var protect_function = function(s, begin, replace, end) {
AQD.tag = AQD.tag.replace( '%PARAMETER%', response );
linkmap.push(replace);
if ( AQD.talk_tag ) {
return begin + "⍌"+(linkmap.length-1)+"⍍" + end;
AQD.talk_tag = AQD.talk_tag.replace( '%PARAMETER%', response );
};
}
//\|x=
AQD.img_summary = AQD.img_summary.replace( '%PARAMETER%', response )
regex(/(<timeline>)([\s\S]*?)(<\/timeline>)/gi, protect_function);
.replace( '%PARAMETER-LINKED%', '[[:' + response + ']]' );
regex(/(<!--)([^<\{\}]*?)(-->)/gi, protect_function);
}
regex(/(<math>)([\s\S]*?)(<\/math>)/gi, protect_function);
} );
regex(/((?:{(?:Wikimedia |)Commons ?|C ?))(Cat(?:egory|))\|[^{}*](})/gi, protect_function);
$( this ).dialog( 'close' );
regex(/(<ref)([^>]+)(>)/gi, protect_function);
AQD.nextTask();
regex(/((?:Category|Image|File):)([^|\]]*)([|\]])/gi, protect_function);
};
regex(/(\{(?:See ?also|Main))(\|[^}]*)(\})/gi, protect_function);
dlgButtons[ this.i18n.cancelButtonLabel ] = function () {
regex(/(\{\{(?:double ?|external ?|wide ?)image\s?\|)([^}]+)(\})/gi, protect_function);
$( this ).dialog( 'close' );
regex(/(\{\{(?:harvnb|r|wikisource)\|)([^}]+)(\})/gi, protect_function);
};
regex(/(\{\{(?:Canadian federal by-election))([^}]+)(\}\})/gi, protect_function);
 
var $submitButton,
regex(/(\[(?:https?:|ftp:))([^\]]*)(\])/gi, protect_function);
$AjaxDeleteContainer = $( '<div>', { id: 'AjaxDeleteContainer' } ),
regex(/(>[ ]*(?:https?:|ftp:))([^< >\]]*)([ ]*<)/gi, protect_function);
_parseReason = function () {
// regex(/(https?:|ftp:)([^\s\]]*)([\s\]])/gi, protect_function);
var $el = $( this ),
regex(/(<blockquote>)([\s\S]*?)(<\/blockquote>)/gi, protect_function);
$parserResultNode = $el.data( 'parserResultNode' );
regex(/(<noinclude>)([\s\S]*?)(<\/noinclude>)/gi, protect_function);
 
regex(/(<gallery)([\s\S]*?)(<\/gallery>)/gi, protect_function);
if ( !$parserResultNode ) {
regex(/(<poem>)([\s\S]*?)(<\/poem>)/gi, protect_function);
return;
regex(/(\{[^\{]{0,6}(?:quot[^|]{1,7}\s?|sic)\|)([^}]+)(\})/gi, protect_function);
}
regex(/((?:image\d?|image_skyline|image[ _]location\d?|image[ _]name|image[ _]file|img|map\d|pic)\s*=)([^|}]*)([|}])/gi, protect_function);
 
regex(/([\|\{]\s*(?:file(?:name\d?|)|image\d?|image location\d?|img|pic|Cover|(?:trans-?|)title|quote|chapter|journal|url|archiveurl|work|doi|club|at|volume|reporter)\s*=)([^|\}⍍]*)([|}])/gi, protect_function);
$parserResultNode.css( 'color', '#877' );
regex(/([\|\{]\s*(?:file(?:name\d?|)|image\d?|image location\d?|img|pic|Cover|(?:trans-?|)title|quote|chapter|journal|url|archiveurl|work|doi|club|at|volume|reporter)\s*=)([^|\}⍍]*)([|}])/gi, protect_function);
 
regex(/([\|\{]\s*(?:season)\s*=)(\s*\[\[[^\]]*\]\]\s*)([|}])/gi, protect_function);
var _gotParsedText = function ( r ) {
regex(/([\|\{]\s*(?:[xy])\s*=)(\s*[^\|]+\s*)(\|)/gi, protect_function);
try {
regex(/(\{\{navsource\|)([^}]+)(\})/gi, protect_function);
$parserResultNode.html( r );
regex(/(\{\{(?:singlechart)\|)([^}]+)(\})/gi, protect_function);
$parserResultNode.css( 'color', '#000' );
regex(/(\{\{(?:defaultsort|graph):)([^}]+)(\})/gi, protect_function);
} catch ( ex ) {}
regex(/(["“])([^"”\n]*)(["”])/gi, protect_function);
};
regex(/(.)(\(\{\{by\|[12]\d{3}\}\}[-–]\{\{by\|)([12]\d{3}[ ]*\}\}\))/gi, protect_function);
mw.loader.using( [ 'ext.gadget.libAPI' ], function () {
regex(/(.)(\(\{\{by\|[12]\d{3}\}\}(?:[-–]present|))(\))/gi, protect_function);
mw.libs.commons.api.parse( $el.val(), conf.wgUserLanguage, pageName, _gotParsedText );
regex(/(\[\[)(4AD)(\]\]|\|)/gi, protect_function);
} );
},
 
_validateInput = function ( event ) {
var $el = $( this ),
v = $el.data( 'v' );
 
if ( v.noEmpty ) {
$submitButton.button( 'option', 'disabled', $el.val().trim().length < ( v.minLength || 8 ) );
}
 
if (
( $el.prop( 'nodeName' ) !== 'TEXTAREA' ) &&
( event.which === 13 ) &&
( v.enterToSubmit !== false ) &&
!$submitButton.button( 'option', 'disabled' )
) {
$submitButton.trigger( 'click' );
}
 
},
 
_convertToTextarea = function () {
var $el = $( this ),
$input = $el.data( 'toConvert' ),
$tarea = $( '<textarea>', {
id: $input.attr( 'id' ),
style: 'height:10em; width:98%; display:none;'
} );
 
$el.off().fadeOut();
$input.parent().prepend(
$tarea
.data( 'v', $input.data( 'v' ) ).data( 'parserResultNode', $input.data( 'parserResultNode' ) )
.val( $input.val() ).on( 'keyup', _parseReason ).on( 'keyup input', _validateInput ) );
$tarea.slideDown();
$input.remove();
};
 
questions.forEach( function ( v, i ) {
v.type = ( v.type || 'text' );
if ( v.type === 'textarea' ) {
$AjaxDeleteContainer.append( '<label for="AjaxQuestion' + i + '">' + v.message + '</label>' )
.append( '<textarea rows=20 id="AjaxQuestion' + i + '">' );
} else {
$AjaxDeleteContainer.append( '<label for="AjaxQuestion' + i + '">' + v.message + '</label>' )
.append( '<input type="' + v.type + '" id="AjaxQuestion' + i + '" style="width:97%;">' );
}
 
var curQuestion = $AjaxDeleteContainer.find( '#AjaxQuestion' + i );
 
if ( v.parseReason ) {
var $parserResultNode = $( '<div>', {
id: 'AjaxQuestionParse' + i,
html: '&nbsp;'
} );
$AjaxDeleteContainer.append( '<br><label for="AjaxQuestionParse' + i + '">' +
o.i18n.previewLabel + '</label>' ).append( $parserResultNode );
 
curQuestion.data( 'parserResultNode', $parserResultNode ).keyup( _parseReason );
}
if ( v.type !== 'textarea' ) {
$AjaxDeleteContainer.append( '<br>' );
}
 
$AjaxDeleteContainer.append( v.appendNode ? v.appendNode : '<br>' );
 
if ( typeof v.byteLimit === 'number' ) {
mw.loader.using( 'jquery.lengthLimit', function () {
curQuestion.byteLimit( v.byteLimit );
} );
}


curQuestion.data( 'v', v );
//retraining redirects containing a date
curQuestion.on( 'keyup input', _validateInput );
regex(/(\[\[)(?:সেপ্টেম্বর 3 Society)(\]\]|\|)/gi, '$1Jiusan Society$2');
regex(/(\[\[)(?:জুন 4th incident)(\]\]|\|)/gi, '$1Tiananmen Square protests of 1989$2');
regex(/(\[\[)(?:5@th? অক্টোবর (?:\(Serbia\)|overthrow))(\]\]|\|)/gi, '$1Overthrow of Slobodan Milošević$2');
regex(/(\[\[)(?:অক্টোবর 5@th?(?: \(Serbia\)| overthrow|, 2000))(\]\]|\|)/gi, '$1Overthrow of Slobodan Milošević$2');


// SECURITY: prefill could contain evil jsCode. Never use it unescaped!
//protect alternate meanings of 'মে' and 'মার্চ' (note: not case insensitive)
// Use .val() or { value: prefill } or '<input value="' + mw.html.escape() + '" …>
// ohc_regex(/([^\w])(@day,?\s{0,3}মে)([^\w][^\d])/g, protect_function); //disabled 26 মে – not case senstitve: false negatives in converting dates in মে
curQuestion.val( v.prefill );
ohc_regex(/([^\w])(মার্চ\s@day)(\s(?:mile|kilomet|met))/g, protect_function);
if ( v.type === 'checkbox' ) {
curQuestion.prop( 'checked', v.prefill ).attr( 'style', 'margin-left: 5px' );
}


} );
//protect all links containing a date and some text
 
ohc_regex(/(\[\[)(\s*\w[^\]\|\n]+?@day[^\]\|\n]+?@fullmonth[^\]\|\n]*)(\]\]|\|)/gi, protect_function);
if ( mw.user.isAnon() ) {
ohc_regex(/(\[\[)([^\]\|\n]*?@day[^\]\|\n]+?@fullmonth(?:,? @year|) \D[^\]\|\n]+\w\s*)(\]\]|\|)/gi, protect_function);
AQD.renderNode( $( '<div>', { id: 'ajaxDeleteAnonwarning' } ), 'MediaWiki:Anoneditwarning' ).appendTo( $AjaxDeleteContainer );
ohc_regex(/(\[\[)(\s*\w[^\]\|\n]+?@fullmonth[^\]\|\n]+?@day[^\]\|\n]*)(\|)/gi, protect_function);
}
ohc_regex(/(\[\[)([^\]\|\n]*?@fullmonth[^\]\|\n]+?@day(?:, @year|) \D[^\]\|\n]+\w\s*)(\]\]|\|)/gi, protect_function);
 
$( '<div>' ).append( $AjaxDeleteContainer ).dialog( {
width: ( width || 600 ),
modal: true,
title: title,
dialogClass: 'wikiEditor-toolbar-dialog',
close: function () {
$( this ).dialog( 'destroy' ).remove();
if ( AQD.currentTask === 'formerDRRequestpage' ) {
mw.util.$content.find( '.convert-to-dr' ).show();
}
},
buttons: dlgButtons,
open: function () {
// Look out for http://bugs.jqueryui.com/ticket/6830 / jQuery UI 1.9
var $buttons = $( this ).parent().find( '.ui-dialog-buttonpane button' );
$submitButton = $buttons.eq( 0 ).specialButton( 'proceed' );
$buttons.eq( 1 ).specialButton( 'cancel' );
}
} );


questions.forEach( function ( v, i ) {
//protects certain dates
var curQuestion = $AjaxDeleteContainer.find( '#AjaxQuestion' + i );
regex(/(\[\[)(4AD)([\s\S])/gi, protect_function);
curQuestion.trigger( 'keyup' );
regex(/([\s\S])(মার্চ (?:8|14) Alliance)([\s\S])/gi, protect_function);
if ( v.type === 'text' ) {
regex(/([\s\S])(23rd মার্চ 1931: Shaheed)([\s\S])/gi, protect_function);
var $q = curQuestion.wrap( '<div style="position:relative;">' ).parent(),
regex(/([\s\S])(Long মার্চ [1-7])([\s\S])/gi, protect_function);
$i = $.createIcon( 'ui-icon-arrow-4-diag' ).attr( 'title', AQD.i18n.expandToTextarea );
regex(/([\s\S])(National সেপ্টেম্বর 11 Memorial & Museum)([\s\S])/gi, protect_function);
$( '<span>', {
regex(/([\s\S])(Queen Elizabeth II সেপ্টেম্বর 11th Garden)([\s\S])/gi, protect_function);
// eslint-disable-next-line quote-props
regex(/([\s\S])(Bombay মার্চ 12)([\s\S])/gi, protect_function);
'class': 'ajaxTextareaConverter' } ).append( $i ).appendTo( $q ).data( 'toConvert', curQuestion ).on( 'click', _convertToTextarea );
regex(/([\s\S])(movement 2 জুন)([\s\S])/gi, protect_function);
}
regex(/([\s\S])(6th\sof অক্টোবর City)([\s\S])/gi, protect_function);
} );
regex(/([\s\S])(Party Workers' Liberation Front 30th of মে)([\s\S])/gi, protect_function);
 
regex(/([\s\S])(4th\sof আগষ্ট regime)([\s\S])/gi, protect_function);
$( '#AjaxQuestion0' ).trigger( 'focus' ).trigger( 'select' );
regex(/([\s\S])(19th\sof এপ্রিল movement)([\s\S])/gi, protect_function);
mw.hook( 'aqd.prompt' ).fire( o );
regex(/([\s\S])(জুন 4th (?:incident|museum))([\s\S])/gi, protect_function);
},
regex(/([\s\S])(The Battle Of Marston Moor \(জুলাই 2nd,? 1644\))([\s\S])/gi, protect_function);
 
regex(/([\s\S])(Night of জানুয়ারি 16th)([\s\S])/gi, protect_function);
/**
regex(/([\s\S])(Observance of 5th নভেম্বর Act)([\s\S])/gi, protect_function);
* Open a jQuery dialog with preview-images and some options
regex(/(\[\[)(13 মে incident)(\|)/gi, protect_function);
* and information to compare the two files
regex(/(\'\'\')(22nd\sof মে)(\'\'\')/gi, protect_function);
*/
regex(/(\[\[)(22nd\sof মে \(film\))([|\]\'])/gi, protect_function);
compareDetails: function () {
regex(/(\[\[)(জুলাই 12, 2007, Baghdad airstrike)(\|)/gi, protect_function);
 
var d = this.details[ 0 ],
regex(/(\[\[)(নভেম্বর 1828)(\]\])/gi, protect_function);
f = this.details[ 1 ],
regex(/(.)(4th\sof জুলাই)(.)/gi, protect_function);
$swapButton,
regex(/(\[\[)((?:2300|2000)\s?AD)(\]\])/gi, protect_function);
$overlayButton;
regex(/(\[\[)(29 ফেব্রুয়ারি)(\]\])/gi, protect_function);
 
regex(/(\[\[)(ফেব্রুয়ারি 29)(\]\])/gi, protect_function);
if ( d.sha1 === f.sha1 ) {
this.exactDupes = true;
this.nextTask();
return;
}
 
var $imgD = $( '<div>' ).append( $( '<img>', {
src: d.thumburl,
height: d.thumbheight,
width: d.thumbwidth
} ), $( '<div>', {
id: 'AjaxDeleteImgDel',
html: Math.round( d.size / 1000 ) + ' KiB <br>' + d.width + '×' + d.height + '<br>'
} ).append(
$( '<a>', {
href: d.descriptionurl,
text: d.title,
target: '_blank'
} ) ) ),
$imgF = $( '<div>' ).append( $( '<img>', {
src: f.thumburl,
height: f.thumbheight,
width: f.thumbwidth
} ), $( '<div>', {
id: 'AjaxDeleteImgKeep',
html: Math.round( f.size / 1000 ) + ' KiB <br>' + f.width + '×' + f.height + '<br>'
} ).append(
$( '<a>', {
href: f.descriptionurl,
text: f.title,
target: '_blank'
} ) ) ),
dlgButtons = {};
 
dlgButtons[ this.i18n.submitButtonLabel ] = function () {
$( this ).dialog( 'close' );
AQD.nextTask();
};
dlgButtons[ this.i18n.inverseButtonLabel ] = function () {
$( this ).dialog( 'close' );
AQD.destination = pageName.replace( /_/g, ' ' );
pageName = f.title;
AQD.details.reverse();
AQD.inUse = true;
setTimeout( function () {
AQD.compareDetails();
}, 20 );
};
dlgButtons[ this.i18n.swapImagesButtonLabel ] = function () {
if ( $imgD[ 0 ].nextSibling === $imgF[ 0 ] ) {
$imgD.before( $imgF );
} else {
$imgF.before( $imgD );
}
};
var $fClone;
dlgButtons[ this.i18n.overlayButtonLabel ] = function () {
if ( $fClone ) {
$fClone.remove();
$fClone = 0;
} else {
$fClone = $imgF.clone().appendTo( $imgF.parent() );
$fClone.css( 'position', 'absolute' );
var pos = $imgD.position();
$fClone.css( {
top: pos.top - 1, left: pos.left - 1
} )
.fadeTo( 0, 0.65 );
// These modules should be already loaded for the dialog but let's be sure
mw.loader.using( [ 'jquery.ui'], function () {
// Set width to auto because AjaxQuickDelete.css sets it to a fixed size
$fClone.css( {
background: 'rgba(200, 200, 200, 0.5)',
width: 'auto',
border: '1px solid #0c9'
} ).draggable();
$fClone.find( 'img' ).resizable();
// In IE, opacity is not fully inerhited
$fClone.children( 'div' ).fadeTo( 0, 0.7 );
} );
}
};
 
this.showProgress();
 
var $AjaxDupeContainer = $( '<div>', { id: 'AjaxDupeContainer' } ).append( $imgD, $imgF );
$( '<div>' ).append( $AjaxDupeContainer ).dialog( {
width: 800,
modal: true,
title: this.i18n.compareDetails,
draggable: false,
dialogClass: 'wikiEditor-toolbar-dialog',
close: function () {
$( this ).dialog( 'destroy' ).remove();
},
buttons: dlgButtons,
open: function () {
var $buttons = $( this ).parent().find( '.ui-dialog-buttonpane button' );
$buttons.eq( 0 ).specialButton( 'proceed' );
$buttons.eq( 1 ).button( { icons: { primary: 'ui-icon-refresh' } } );
$swapButton = $buttons.eq( 2 ).button( { icons: { primary: 'ui-icon-transfer-e-w' } } );
$overlayButton = $buttons.eq( 3 ).button( { icons: { primary: 'ui-icon-newwin' } } );
$swapButton.css( 'float', ( ( $swapButton.css( 'float' ) === 'left' ) ? 'right' : 'left' ) );
$overlayButton.css( 'float', ( ( $overlayButton.css( 'float' ) === 'left' ) ? 'right' : 'left' ) );
}
} );
mw.loader.load( [ 'ext.gadget.libGlobalReplace', 'ext.gadget.libWikiDOM' ] );
},


mergeDescriptions: function () {
// works names
var newPageText = this.details[ 1 ].content;
// regex(/(.)(protect string)(.)/gi, protect_function);
mw.loader.using( [ 'ext.gadget.libGlobalReplace', 'ext.gadget.libWikiDOM' ], function () {
regex(/(.)(11\/22\/63)(.)/gi, protect_function);
newPageText = mw.libs.wikiDOM.nowikiEscaper( newPageText ).doCleanUp();
regex(/(.)(1\.1\.1994)(.)/gi, protect_function);
 
regex(/([\s\S])(2\.13\.61)([\s\S])/gi, protect_function);
AQD.showProgress();
// regex(/(.)(4th of জুলাই, Asbury)(.)/gi, protect_function); //protected above globally
AQD.prompt( [ {
regex(/(.)(26 অক্টোবর 1993)(.)/gi, protect_function);
message: '',
regex(/(\[\[|\'\')(জুন 1, 1974)(.)/gi, protect_function);
prefill: AQD.details[ 0 ].content,
regex(/(\[\[|\'\')(জুলাই 15, 1972)(.)/gi, protect_function);
returnvalue: 'discard',
regex(/(\[\[|\'\')(আগষ্ট 1914)(.)/gi, protect_function);
cleanUp: false,
ohc_regex(/(\[\[|\'\')(@fullmonth @dd@th? \((?:@yyyy |)film\)(?:\|@fullmonth @dd@th?|))([\s\S])/gi, protect_function);
noEmpty: false,
ohc_regex(/(\[\[|\'\')(@dd@th? @fullmonth \((?:@yyyy |)film\)(?:\|@dd@th? @fullmonth|))([\s\S])/gi, protect_function);
type: 'textarea',
// regex(/(Les Bains Douches 18)( ডিসেম্বর 1979)(.)/gi, protect_function);
enterToSubmit: false
regex(/(আগষ্ট)( 7, 4:15)(.)/gi, protect_function);
}, {
regex(/(In Concert, Zürich, অক্টোবর)( 28, 1979)(.)/gi, protect_function);
message: '',
regex(/(CBGB OMFUG Masters: Live জুন)( 29, 2001)(.)/gi, protect_function);
prefill: newPageText,
ohc_regex(/(Live at [\w ]*,? [1-3]\d)( @fullmonth)(.)/gi, protect_function);
returnvalue: 'newPageText',
ohc_regex(/(Live at [\w ]*,? @fullmonth)( @dd)(.)/gi, protect_function);
cleanUp: false,
ohc_regex(/(Bootmoon Series: [\w ]*[-–] @fullmonth)( @day, @YYYY)(.)/gi, protect_function);
noEmpty: false,
type: 'textarea',
enterToSubmit: false
}, {
message: AQD.i18n.useCORSForReplace,
prefill: !window.aqdCORSOptOut,
returnvalue: 'replaceUsingCORS',
// cleanUp: false,
noEmpty: false,
type: 'checkbox'
}
], AQD.i18n.mergeDescription, 800 );
 
AQD.destination = AQD.details[ 1 ].title;
AQD.reason = 'Exact or scaled-down duplicate: [[:' + AQD.destination + ']]';
} );
},
 
/**
* Correct the MIME-Type; Accepts only valid filenames (with extension)
* Either a filename is passed or the destination property is used
*/
correctMIME: function ( fn ) {
// If the current mime-type is available to the script, check it;
// MediaWiki sometimes allows uploading mismatching mimetypes but not moving
var f = fn || this.destination;
if ( this.mimeFileExtension ) {
f = f.replace( /\.\w{2,5}$/, '.' + this.mimeFileExtension );
}
 
if ( !fn ) {
this.destination = f;
return this.nextTask();
} else {
return f;
}
},
 
cleanFileName: function ( fn, ignoreMIME ) {
// Remove Namespace
fn = fn.replace( /^(?:Image|File):/i, '' )
// Convert extension to lower case
.replace( /(\.\w{2,5})+$/, function ( $e ) {
return $e.toLowerCase();
} )
// jpeg -> jpg
.replace( /\.jpe*g$/, '.jpg' )
// First cleanUp from Flinfo (FlinfoOut.php) by Flominator and Lupo
.replace( /~{3,}/g, '' ) // "signature"
.replace( /[\u00A0\u1680\u180E\u2000-\u200B\u2028\u2029\u202F\u205F\u3000]/, ' ' ) // remove NBSP and other unusual spaces
.replace( /\s+|_/g, ' ' ) // (multiple) whitespace
// eslint-disable-next-line no-control-regex
.replace( /[\x00-\x1f\x7f]/g, '' )
.replace( /%([0-9A-Fa-f]{2})/g, '% $1' ) // URL encoding stuff
.replace( /&(([A-Za-z0-9\x80-\xff]+|#[0-9]+|#x[0-9A-Fa-f]+);)/g, '& $1' ) // URL-params?
.replace( /''/g, '"' )
.replace( /[:/|#]/g, '-' )
.replace( /[\]}>]/g, ')' )
.replace( /[[{<]/g, '(' );
 
fn = this.checkFileExt( pageName, fn, ignoreMIME ) || fn;


// Capitalize the first letter and prefix the namespace
// expressions and grammatical strings including modal "মে"
return 'File:' + $.ucFirst( fn ); // own prototype
regex(/(\W)((?:\d{1,3}) মে)((?: have(?: \w+|)|) be)/g, protect_function);
},
regex(/(\W)((?:\d{3}|3[2-9]|[4-9]\d)\/\d ডিসেম্বর(?:l\.?|))(\W)/gi, protect_function);
regex(/(\W)((?:\d{2,3})\/\d ডিসেম্বর(?:l\.?|))( \(\d\d? overs)/gi, protect_function);
}


/**
/** ------------------------------------------------------------------------ **/
* @brief Compare mimetype
/// DATE PROTECTION FOR ALL REF SECTION
* @param [in] of old filename
* @param [in] fn new filename
* @param [in] boolean
* @return false if same, otherwise new file with old extension
*/
checkFileExt: function ( of, fn, ignoreMIME ) {
var currentExt = ( !ignoreMIME && this.mimeFileExtension ) ?
this.mimeFileExtension :
of.replace( /.*?\.(\w{2,5})$/, '$1' ).toLowerCase().replace( 'jpeg', 'jpg' ),


reCurrentExt = new RegExp( '\\.' + mw.util.escapeRegExp( currentExt ) + '$', 'i' ),
var linkmap = [];
reDestExt = new RegExp( '\\.' + mw.util.escapeRegExp( fn.replace( /.*?\.(\w{2,5})$/, '$1' ) ) + '$', 'i' );


// If new filename is without (same) extension, add the one from the old name
function ohc_protect_dates_ref()  
if ( !reCurrentExt.test( fn ) ) {
{
// First, try to replace the old extension
// protects dates within links, quotes, etc
fn = fn.replace( reDestExt, '.' + currentExt );
// the sensitive part is stored and replaced with a unique identifier,
if ( !reCurrentExt.test( fn ) ) {
// which is later replaced with the stored part.
// If this did not work, then simply append the old extension
fn += '.' + currentExt;
}
} else {
fn = false;
} // is equal


return fn;
var protect_function = function (s, begin, replace, end) {
},
linkmap.push(replace);
return begin + "⍌" + (linkmap.length - 1) + "⍍" + end;
};


cleanReason: function ( uncleanReason ) {
regex(/(<ref\s?(?:>|name=[^>]+))([^<]+)(<\/ref>)/gi, protect_function);
return uncleanReason
regex(/(<timeline>)([\s\S]*?)(<\/timeline>)/gi, protect_function);
.trim() // whitespace
regex(/(<math>)([\s\S]*?)(<\/math>)/gi, protect_function);
.replace( /(?:--||)? ?~{3,5} ?/, '' ) // remove signature
regex(/((?:{(?:Wikimedia |)Commons ?|C ?))(Cat(?:egory|))\|[^{}*](})/gi, protect_function);
.replace( /\|\s/g, '&#124; ' ); // pipes
regex(/((?:Category|Image|File):)([^|\]]*)([|\]])/gi, protect_function);
},
regex(/(\{(?:See ?also|Main))(\|[^}]*)(\})/gi, protect_function);
regex(/(\{\{(?:double ?|external ?|wide ?)image\s?\|)([^}]+)(\})/gi, protect_function);
regex(/(\{\{(?:harvnb|wikisource)\|)([^}]+)(\})/gi, protect_function);
regex(/(\[(?:https?:|ftp:))([^\]]*)(\])/gi, protect_function);
regex(/(>[ ]*(?:https?:|ftp:))([^< >\]]*)([ ]*<)/gi, protect_function);
//regex(/(https?:|ftp:)([^\s\]]*)([\s\]])/gi, protect_function);
regex(/(<blockquote>)([\s\S]*?)(<\/blockquote>)/gi, protect_function);
regex(/(\{[^\{]{0,6}(?:quot[^|]{1,7}\s?|sic)\|)([^}]+)(\})/gi, protect_function);
regex(/((?:image\d?|image_skyline|image[ _]location\d?|image[ _]name|image[ _]file|img|pic)\s*=)([^|}]*)([|}])/gi, protect_function);
regex(/([\|\{]\s*(?:file(?:name\d?|)|image\d?|image location\d?|img|pic|Cover|title|quote|chapter|journal|url|archiveurl|work|doi|club|at|volume|reporter)\s*=)([^|\}⍍]*)([|}])/gi, protect_function);
regex(/([\|\{]\s*(?:file(?:name\d?|)|image\d?|image location\d?|img|pic|Cover|title|quote|chapter|journal|url|archiveurl|work|doi|club|at|volume|reporter)\s*=)([^|\}⍍]*)([|}])/gi, protect_function);
regex(/([\|\{]\s*(?:season)\s*=)(\s*\[\[[^\]]*\]\]\s*)([|}])/gi, protect_function);
regex(/(\{\{navsource\|)([^}]+)(\})/gi, protect_function);
regex(/(\{\{singlechart\|)([^}]+)(\})/gi, protect_function);
regex(/(\{\{defaultsort:)([^}]+)(\})/gi, protect_function);
regex(/([\s\(>]")([^"\n]*)(")/gi, protect_function);
regex(/([\s\(>]“)([^”\n]*)(”)/gi, protect_function);
regex(/(.)(\(\{\{by\|[12]\d{3}\}\}[-–]\{\{by\|)([12]\d{3}[ ]*\}\}\))/gi, protect_function);
regex(/(.)(\(\{\{by\|[12]\d{3}\}\}(?:[-–]present|))(\))/gi, protect_function);


/**
//retraining redirects containing a date
* For display of progress messages.
regex(/(\[\[)(?:সেপ্টেম্বর 3 Society)(\]\]|\|)/gi, '$1Jiusan Society$2');
*/
regex(/(\[\[)(?:জুন 4th incident)(\]\]|\|)/gi, '$1Tiananmen Square protests of 1989$2');
showProgress: function ( message ) {
ohc_regex(/(\[\[)(?:5@th? অক্টোবর (?:\(Serbia\)|overthrow))(\]\]|\|)/gi, '$1Overthrow of Slobodan Milošević$2');
if ( !message ) {
ohc_regex(/(\[\[)(?:অক্টোবর 5@th?(?: \(Serbia\)| overthrow|, 2000))(\]\]|\|)/gi, '$1Overthrow of Slobodan Milošević$2');
if ( this.progressDialog ) {
this.progressDialog.remove();
}


this.progressDialog = 0;
//protect alternate meanings of 'মে' and 'মার্চ' (note: not case insensitive)
document.body.style.cursor = 'default';
ohc_regex(/([^\w])(@day,?\s{0,3}মে)([^\w][^\d])/g, protect_function);
return;
ohc_regex(/([^\w])(মার্চ\s@day)(\s(?:mile|kilomet|met))/g, protect_function);
}
if ( $( '#feedbackContainer' ).length ) {
$( '#feedbackContainer' ).html( message );
} else {
document.body.style.cursor = 'wait';


this.progressDialog = $( '<div>' ).html( '<div id="feedbackContainer">' + ( message || this.i18n.preparingToEdit ) + '</div>' ).dialog( {
//protect all links containing a date and some text
width: 450,
ohc_regex(/(\[\[)(\s*\w[^\]\|\n]+?@day[^\]\|\n]+?@fullmonth[^\]\|\n]*)(\]\]|\|)/gi, protect_function);
height: 'auto',
ohc_regex(/(\[\[)([^\]\|\n]*?@day[^\]\|\n]+?@fullmonth(?:,? @year|) \D[^\]\|\n]+\w\s*)(\]\]|\|)/gi, protect_function);
minHeight: 90,
ohc_regex(/(\[\[)(\s*\w[^\]\|\n]+?@fullmonth[^\]\|\n]+?@day[^\]\|\n]*)(\|)/gi, protect_function);
modal: true,
ohc_regex(/(\[\[)([^\]\|\n]*?@fullmonth[^\]\|\n]+?@day(?:, @year|) \D[^\]\|\n]+\w\s*)(\]\]|\|)/gi, protect_function);
resizable: false,
draggable: false,
closeOnEscape: false,
dialogClass: 'ajaxDeleteFeedback',
open: function () {
$( this ).parent().find( '.ui-dialog-titlebar' ).hide();
},
close: function () {
$( this ).dialog( 'destroy' ).remove();
}
} );
}


},
//protects certain dates
/**
regex(/(\[\[)(4AD)([\s\S])/gi, protect_function);
* Submit an edited page.
regex(/([\s\S])(মার্চ (?:8|14) Alliance)([\s\S])/gi, protect_function);
*/
regex(/([\s\S])(23rd মার্চ 1931: Shaheed)([\s\S])/gi, protect_function);
savePage: function ( page, summary, callback ) {
regex(/([\s\S])(Long মার্চ [1-7])([\s\S])/gi, protect_function);
if ( AQD.csrftoken ) {
regex(/([\s\S])(Bombay মার্চ 12)([\s\S])/gi, protect_function);
mw.user.tokens.set( 'csrfToken', AQD.csrftoken );
regex(/([\s\S])(movement 2 জুন)([\s\S])/gi, protect_function);
}
regex(/([\s\S])(6th\sof অক্টোবর City)([\s\S])/gi, protect_function);
 
regex(/([\s\S])(Party Workers' Liberation Front 30th of মে)([\s\S])/gi, protect_function);
$.extend( true, page, {
regex(/([\s\S])(4th\sof আগষ্ট regime)([\s\S])/gi, protect_function);
cb: function ( r ) {
regex(/([\s\S])(19th\sof এপ্রিল movement)([\s\S])/gi, protect_function);
AQD.secureCall( callback, r );
regex(/([\s\S])(জুন 4th incident)([\s\S])/gi, protect_function);
},
regex(/([\s\S])(The Battle Of Marston Moor \(জুলাই 2nd,? 1644\))([\s\S])/gi, protect_function);
// text, result, query
regex(/([\s\S])(Night of জানুয়ারি 16th)([\s\S])/gi, protect_function);
errCb: function ( t, r ) {
regex(/([\s\S])(Observance of 5th নভেম্বর Act)([\s\S])/gi, protect_function);
if ( AQD.uploadersToNotify ) {
regex(/(\[\[)(13 মে incident)(\|)/gi, protect_function);
// If user notify fails don't break next task (e.q. redirect to protected page, very rare)
regex(/(\'\'\')(22nd\sof মে)(\'\'\')/gi, protect_function);
AQD.secureCall( callback, r );
regex(/(\[\[)(22nd\sof মে \(film\))([|\]\'])/gi, protect_function);
}
regex(/(\[\[)(জুলাই 12, 2007, Baghdad airstrike)(\|)/gi, protect_function);
AQD.fail( t, r );
},
regex(/(\[\[)(নভেম্বর 1828)(\]\])/gi, protect_function);
summary: summary
regex(/(.)(4th\sof জুলাই)(.)/gi, protect_function);
} );
regex(/(\[\[)((?:2300|2000)\s?AD)(\]\])/gi, protect_function);
 
regex(/(\[\[)(29 ফেব্রুয়ারি)(\]\])/gi, protect_function);
mw.loader.using( [ 'ext.gadget.libAPI' ], function () {
regex(/(\[\[)(ফেব্রুয়ারি 29)(\]\])/gi, protect_function);
mw.libs.commons.api.editPage( page );
} );
},
 
movePage: function () {
mw.user.tokens.set( 'csrfToken', AQD.csrftoken );
// Some users don't get it: They want to move pages to themselves.
if ( pageName.replace( /_/g, ' ' ) === AQD.destination ) {
return AQD.nextTask();
}
 
mw.loader.using( [ 'ext.gadget.libAPI' ], function () {
var moveArgs = {
cb: function () {
AQD.nextTask();
},
// text, r-result, query
errCb: function ( t, r ) {
if ( r && r.error && /articleexists/.test( r.error.code ) ) {
AQD.disableReport = true;
}
 
AQD.fail( t, r );
},
from: pageName,
to: AQD.destination,
reason: AQD.reason,
movetalk: true,
watchlist: AQD.pageWasWatched ? 'watch' : 'preferences'
};
// Option to not leave a redirect behind, MediaWiki default does leave one behind
// Just like movetalk, an empty parameter sets it to true
if ( AQD.wpLeaveRedirect === false ) {
moveArgs.noredirect = true;
}
 
AQD.showProgress( AQD.i18n.movingFile );
mw.libs.commons.api.movePage( moveArgs );
} );
},
 
deletePage: function () {
mw.user.tokens.set( 'csrfToken', AQD.csrftoken );
mw.loader.using( [ 'ext.gadget.libAPI' ], function () {
AQD.showProgress( AQD.i18n.deletingFile );
mw.libs.commons.api.deletePage( {
cb: function () {
AQD.nextTask();
},
// text, result, query
errCb: function ( t, r ) {
AQD.fail( t, r );
},
title: pageName,
reason: AQD.reason
} );
} );
},
 
purge: function () {
// No need for checking success, showing progress, nor for waiting for task to complete
this.nextTask();
$.post( this.apiURL, {
format: 'json',
action: 'purge',
forcelinkupdate: 1,
titles: pageName
} );
},


/**
// works names
* Does a MediaWiki API request and passes the result to the supplied callback (method name).
//regex(/(.)(protect string)(.)/gi, protect_function);
*/
regex(/(.)(11\/22\/63)(.)/gi, protect_function);
queryAPI: function ( params, callback ) {
regex(/(.)(1\.1\.1994)(.)/gi, protect_function);
mw.loader.using( [ 'ext.gadget.libAPI' ], function () {
regex(/([\s\S])(2\.13\.61)([\s\S])/gi, protect_function);
params.action = params.action || 'query';
//regex(/(.)(4th of জুলাই, Asbury)(.)/gi, protect_function); //protected above globally
mw.libs.commons.api.query( params, {
regex(/(.)(26 অক্টোবর 1993)(.)/gi, protect_function);
method: 'GET',
regex(/(\[\[|\'\')(জুন 1, 1974)(.)/gi, protect_function);
cache: false,
regex(/(\[\[|\'\')(জুলাই 15, 1972)(.)/gi, protect_function);
cb: function ( r ) {
regex(/(\[\[|\'\')(আগষ্ট 1914)(.)/gi, protect_function);
AQD.secureCall( callback, r );
ohc_regex(/(\[\[|\'\')(@fullmonth @dd@th? \((?:@yyyy |)film\)(?:\|@fullmonth @dd@th?|))([\s\S])/gi, protect_function);
},
ohc_regex(/(\[\[|\'\')(@dd@th? @fullmonth \((?:@yyyy |)film\)(?:\|@dd@th? @fullmonth|))([\s\S])/gi, protect_function);
// text, result, query
//regex(/(Les Bains Douches 18)( ডিসেম্বর 1979)(.)/gi, protect_function);
errCb: function ( t, r ) {
regex(/(আগষ্ট)( 7, 4:15)(.)/gi, protect_function);
AQD.fail( t, r );
regex(/(In Concert, Zürich, অক্টোবর)( 28, 1979)(.)/gi, protect_function);
}
regex(/(CBGB OMFUG Masters: Live জুন)( 29, 2001)(.)/gi, protect_function);
} );
ohc_regex(/(Live at [\w ]*,? [1-3]\d)( @fullmonth)(.)/gi, protect_function);
} );
ohc_regex(/(Live at [\w ]*,? @fullmonth)( @dd)(.)/gi, protect_function);
},
ohc_regex(/(Bootmoon Series: [\w ]*[-–] @fullmonth)( @day, @YYYY)(.)/gi, protect_function);
 
/**
* Method to catch errors and report where they occurred
*/
secureCall: function ( fn, r ) {
var o = AQD;
try {
o.currentTask = arguments[ 0 ];
if ( typeof fn === 'function' ) {
// arguments is not of type array so we can't take .slice
return fn.apply( o, Array.prototype.slice.call( arguments, 1 ) );
} else if ( typeof fn === 'string' ) {
return o[ fn ].apply( o, Array.prototype.slice.call( arguments, 1 ) );
} else {
mw.log.warn( fn, this.tasks );
o.fail( 'This is not a function!' );
}
} catch ( ex ) {
o.fail( ex, r );
}
},
 
/**
* Simple task queue.  addTask() adds a new task to the queue, nextTask() executes
* the next scheduled task.  Tasks are specified as method names to call.
*/
tasks: [],
// list of pending tasks
currentTask: '',
// current task, for error reporting
addTask: function ( task ) {
this.tasks.push( task );
},
nextTask: function () {
this.secureCall( this.tasks.shift() );
},
retryTask: function () {
this.secureCall( this.currentTask );
},
 
/**
* Once we're all done, reload the page.
*/
reloadPage: function () {
this.showProgress();
if ( this.pageName && this.pageName.replace( / /g, '_' ) !== pageName ) {
return;
}
 
location.href = mw.util.getUrl( this.destination || pageName );
},
 
/**
* Error handler. Throws an alert at the user and give him
* the possibility to retry or autoreport the error-message.
*/
fail: function ( err, r ) {
var o = this,
msg,
dlgButtons = {};


if ( typeof err === 'object' ) {
regex(/(\W)((?:\d{3}|3[2-9]|[4-9]\d)\/\d ডিসেম্বর(?:l\.?|))(\W)/gi, protect_function);
msg = err.message + ' \n\n ' + err.name;
regex(/(\W)((?:\d{2,3})\/\d ডিসেম্বর(?:l\.?|))( \(\d\d? overs)/gi, protect_function);
if ( err.lineNumber ) {
}
msg += ' @line' + err.lineNumber;
}


err = msg;
}
// Mostly the same as err
if ( typeof r === 'object' ) {
if ( r.error && /tpt-target-page|readonly/.test( r.error.code ) ) {
this.disableReport = true;
}
}


// err += '\n' + JSON.stringify( r );
/** ------------------------------------------------------------------------ **/
/// DATE PROTECTION FOR SLASH modules


msg = this.i18n.taskFailure[ this.currentTask ] || this.i18n.genericFailure;
var linkmap = [];


// TODO: Needs cleanup
function ohc_protect_dates_slash()
if ( this.img_summary === 'Nominating for deletion' ) {
{
msg += ' ' + ( this.templateAdded ? this.i18n.completeRequestByHand : this.i18n.addTemplateByHand );
// protects dates within links, quotes, etc
}
// the sensitive part is stored and replaced with a unique identifier,
// which is later replaced with the stored part.


dlgButtons[ this.i18n.retryButtonLabel ] = function () {
var protect_function = function (s, begin, replace, end) {
$( this ).remove();
linkmap.push(replace);
o.retryTask();
return begin + "⍌" + (linkmap.length - 1) + "⍍" + end;
};
};


if ( [ 'movePage', 'deletePage', 'notifyUploaders' ].indexOf( o.currentTask ) !== -1 &&
regex(/(<ref\s?(?:>|name=[^>]+))([^<]+)(<\/ref>)/gi, protect_function);
( /code 50\d|missingtitle/.test( err ) ) ) {
regex(/(<timeline>)([\s\S]*?)(<\/timeline>)/gi, protect_function);
dlgButtons[ this.i18n.ignoreButtonLabel ] = function () {
regex(/(<math>)([\s\S]*?)(<\/math>)/gi, protect_function);
$( this ).remove();
regex(/((?:{(?:Wikimedia |)Commons ?|C ?))(Cat(?:egory|))\|[^{}*](})/gi, protect_function);
o.nextTask();
regex(/((?:Category|Image|File):)([^|\]]*)([|\]])/gi, protect_function);
};
regex(/(\{(?:See ?also|Main))(\|[^}]*)(\})/gi, protect_function);
}
regex(/(\{\{(?:double ?|external ?|wide ?)image\s?\|)([^}]+)(\})/gi, protect_function);
regex(/(\{\{(?:harvnb|wikisource)\|)([^}]+)(\})/gi, protect_function);
regex(/(\[(?:https?:|ftp:))([^\]]*)(\])/gi, protect_function);
regex(/(>[ ]*(?:https?:|ftp:))([^< >\]]*)([ ]*<)/gi, protect_function);
//regex(/(https?:|ftp:)([^\s\]]*)([\s\]])/gi, protect_function);
regex(/(<blockquote>)([\s\S]*?)(<\/blockquote>)/gi, protect_function);
regex(/(\{[^\{]{0,6}(?:quot[^|]{1,7}\s?|sic)\|)([^}]+)(\})/gi, protect_function);
regex(/((?:image\d?|image_skyline|image[ _]location\d?|image[ _]name|image[ _]file|img|pic)\s*=)([^|}]*)([|}])/gi, protect_function);
regex(/([\|\{]\s*(?:file(?:name\d?|)|image\d?|image location\d?|img|pic|Cover|title|quote|chapter|journal|url|archiveurl|work|doi|club|at|volume|reporter)\s*=)([^|\}⍍]*)([|}])/gi, protect_function);
regex(/([\|\{]\s*(?:file(?:name\d?|)|image\d?|image location\d?|img|pic|Cover|title|quote|chapter|journal|url|archiveurl|work|doi|club|at|volume|reporter)\s*=)([^|\}⍍]*)([|}])/gi, protect_function);
regex(/([\|\{]\s*(?:season)\s*=)(\s*\[\[[^\]]*\]\]\s*)([|}])/gi, protect_function);
regex(/(\{\{navsource\|)([^}]+)(\})/gi, protect_function);
regex(/(\{\{singlechart\|)([^}]+)(\})/gi, protect_function);
regex(/(\{\{defaultsort:)([^}]+)(\})/gi, protect_function);
regex(/([\s\(>]")([^"\n]*)(")/gi, protect_function);
regex(/([\s\(>]“)([^”\n]*)(”)/gi, protect_function);
regex(/(.)(\(\{\{by\|[12]\d{3}\}\}[-–]\{\{by\|)([12]\d{3}[ ]*\}\}\))/gi, protect_function);
regex(/(.)(\(\{\{by\|[12]\d{3}\}\}(?:[-–]present|))(\))/gi, protect_function);


if ( !this.disableReport ) {
}
dlgButtons[ this.i18n.reportButtonLabel ] = function () {
var randomId = Math.round( Math.random() * 1099511627776 ),
toSend = '\n== Autoreport by AjaxQuickDelete ' + randomId + ' ==\n' + err +
'\nAQD version: ' + o.version +
'\n++++\n:Task: ' + o.currentTask + '\n:NextTask: ' + o.tasks[ 0 ] + '\n:LastTask: ' + o.tasks[ o.tasks.length - 1 ] +
'\n:Page: {{Page|1=' + ( o.pageName || pageName ) + '}}\n:Skin: ' + mw.user.options.get( 'skin' ) +
'\n:[{{fullurl:Special:Contributions|target={{subst:urlencode:{{subst:REVISIONUSER}}}}&offset={{subst:REVISIONTIMESTAMP}}}} Contribs] ' +
'[{{fullurl:Special:Log|user={{subst:urlencode:{{subst:REVISIONUSER}}}}&offset={{subst:REVISIONTIMESTAMP}}}} Log] ' +
'before error [[User:{{subst:REVISIONUSER}}|]] ~~~~~\n\n';


$( '#feedbackContainer' ).contents().remove().end()
function ohc_unprotect_dates()  
.append( $( '<img>', { src: '//upload.wikimedia.org/wikipedia/commons/d/de/Ajax-loader.gif' } ) ).css( 'text-align', 'center' );
{
 
//unprotect all dates
$.post( o.apiURL, {
regex(/[♫]/g, '');
action: 'edit',
regex(/⍌([0-9]+)⍍/g, function (x, n) {
format: 'json',
var res = linkmap[n];
title: 'MediaWiki talk:Gadget-AjaxQuickDelete.js/auto-errors',
res = res.replace(/⍌([0-9]+)⍍/g, function (x, n) {
summary: '/*Autoreport by AjaxQuickDelete ' + randomId + '*/ error with random id',
var res = linkmap[n];
appendtext: toSend,
res = res.replace(/⍌([0-9]+)⍍/g, function (x, n) {
token: ( o.csrftoken || mw.user.tokens.get( 'csrfToken' ) )
var res = linkmap[n];
}, function () {
res = res.replace(/⍌([0-9]+)⍍/g, function (x, n) {
o.reloadPage();
return linkmap[n];
} );
});
};
return res;
}
});
dlgButtons[ this.i18n.abortButtonLabel ] = function () {
return res;
$( this ).remove();
});
};
return res;
});
}


this.disableReport = false;
function ohc_MOSNUM_edit_summary()  
this.showProgress();
{
this.progressDialog = $( '<div>' ).append( $( '<div>', {
//Add a tag to the summary box
id: 'feedbackContainer',
setoptions(minor = 'true');
html: ( msg + '<br>' + this.i18n.errorDetails + '<br>' + mw.html.escape( err ) + '<br>' +
setreason('date formats per [[MOS:DATEFORMAT]] by [[WP:MOSNUMscript|script]]', 'append');
( this.tag ? ( this.i18n.tagWas + this.tag ) : '' ) + '<br><a href="' + mw.util.getUrl( 'MediaWiki talk:AjaxQuickDelete.js' ) +
doaction('diff');
'" >' + this.i18n.errorReport.replace( /%BUTTON%/, '<tt>' + this.i18n.reportButtonLabel + '</tt>' ) + '</a>' )
}
} ) ).dialog( {
width: 550,
modal: true,
closeOnEscape: false,
title: this.i18n.errorDlgTitle,
dialogClass: 'ajaxDeleteError',
buttons: dlgButtons,
close: function () {
$( this ).dialog( 'destroy' ).remove();
}
} );
if ( mw.log.warn ) {
mw.log.warn( err );
}


},
function ohc_bigendien_edit_summary()
 
{
/**
//Add a tag to the summary box
* Very simple date formatter.  Replaces the substrings "YYYY", "MM" and "DD" in a
setoptions(minor = 'true');
* given string with the UTC year, month and day numbers respectively.
setreason('ymd ref dates', 'append');
* Also replaces "MON" with the English full month name and "DAY" with the unpadded day.
doaction('diff');
*/
}
formatDate: function ( fmt, date ) {
return mw.libs.commons.formatDate( fmt, date,
( mw.libs.commons.api && mw.libs.commons.api.getCurrentDate() || new Date() )
);
},
 
// Constants
// DR subpage prefix
requestPagePrefix: 'Commons:Deletion requests/',
// user talk page prefix
userTalkPrefix: conf.wgFormattedNamespaces[ 3 ] + ':',
// MediaWiki API script URL
apiURL: mw.util.wikiScript( 'api' ),
// Max number of errors that are allowed for silent retry
apiErrorThreshold: 10,


// Translatable strings
function ohc_expand_edit_summary()
i18n: {
{
toolboxLinkDelete: 'Nominate for deletion',
//Add a tag to the summary box
toolboxLinkDiscuss: 'Nominate category for discussion',
setoptions(minor = 'true');
setreason('expand month names', 'append');
doaction('diff');
}


// GUI reason prompt form
function ohc_slash_edit_summary()
reasonForDeletion: 'Why should this file be deleted?',
{
reasonForDiscussion: 'Why does this category need discussion?',
//Add a tag to the summary box
moreInformation: 'More information',
setoptions(minor = 'true');
loading: 'Loading…',
setreason('resolved slash dates', 'append');
doaction('diff');
}


keptAfterDR: 'This page was kept after a deletion request. Please contact the administrator who kept it before re-nominating.',
function ohc_abbrev_edit_summary()
hasTalkpage: 'There is a talk page. Consider reading it or adding your remarks.',
{
mentionedInDR: 'Consider reading the deletion debate –%PAGE%– that links to this page.',
//Add a tag to the summary box
mentionedInForum: 'On %PAGE%, this page is part of a discussion.',
setoptions(minor = 'true');
setreason('abbrev month names', 'append');
doaction('diff');
}


// Labels
/** ------------------------------------------------------------------------ **/
previewLabel: 'Preview:',
/// CUSTOMIZATION POINTS
submitButtonLabel: 'Proceed',
function ohc_customize_all_to_dmy() {
cancelButtonLabel: 'Cancel',
}
abortButtonLabel: 'Abort',
reportButtonLabel: 'Report automatically',
retryButtonLabel: 'Retry',
ignoreButtonLabel: 'Ignore and continue',
inverseButtonLabel: 'Inverse. Keep this delete other',
swapImagesButtonLabel: 'Swap to compare',
overlayButtonLabel: 'Overlay to compare',
expandToTextarea: 'Expand to textarea',
notifyUser: 'Notify users',


// GUI progress messages
function ohc_customize_all_to_mdy() {
preparingToEdit: 'Preparing to edit pages… ',
}
creatingNomination: 'Creating nomination page… ',
listingNomination: 'Adding nomination page to daily list… ',
addingAnyTemplate: 'Adding template to ' + conf.wgCanonicalNamespace.toLowerCase() + ' page… ',
notifyingUploader: 'Notifying %USER%… ',
listingMobile: 'Listing mobile upload',
updRedir: 'Updating redirects',


// Extended version
function ohc_customize_body_to_dmy() {
toolboxLinkSource: 'No source',
}
toolboxLinkLicense: 'No license',
toolboxLinkPermission: 'No permission',
toolboxLinkCopyvio: 'Report copyright violation',
reasonForCopyvio: 'Why is this file a copyright violation?',


// For moving files
function ohc_customize_body_to_mdy() {
notAllowed: 'You do not have the neccessary rights to move files',
}
reasonForMove: 'Why do you want to move this file?',
moveDestination: 'What should be the new filename?',
moveOtherDestination: 'The name you have specified exists. Choose a new name, please.',
checkFileExists: 'Checking whether file exists',
movingFile: 'Moving file',
replacingUsage: 'Ordering CommonsDelinker to replace all usage',
dropdownMove: 'Move & Replace',
leaveRedirect: 'Leave a redirect behind:',
moveAndReplace: 'Move file and replace all usage',
warnRename: 'File renaming was recently declined, be prudent!',


// For declining any request
function ohc_customize_ISO_to_dmy() {
removingTemplate: 'Removing template',
}
declineRequest: 'Why do you want to decline the request?',
anyDecline: 'Decline request',


// For Duplicates
function ohc_customize_ISO_to_mdy() {
useCORSForReplace: 'Try to replace usage immediately using your user account:',
}
deletingFile: 'Deleting file',
compareDetails: 'Please compare the images before merging the descriptions. The image with the bold text will be deleted.',
mergeDescription: 'Please now merge the file descriptions',
redirectingFile: 'Redirecting file',
savingDescription: 'Saving new details',
processDupes: 'Process Duplicates',


// Errors
/** ------------------------------------------------------------------------ **/
errorDlgTitle: 'Error',
function ohc_body_dates_to_dmy()  
genericFailure: 'An error occurred while trying to do the requested action. ',
{
taskFailure: {
ohc_use_dates_template('dmy');
listUploaders: 'An error occurred while determining the ' + ( nsNr === 6 ? ' uploader(s) of this file' : 'creator of this page' ) + '.',
loadPages: 'An error occurred while preparing to nominate this ' + conf.wgCanonicalNamespace.toLowerCase() + ' for deletion.',
prependDeletionTemplate: 'An error occurred while adding the {{delete}} template to this ' + conf.wgCanonicalNamespace.toLowerCase() + '.',
createRequestSubpage: 'An error occurred while creating the request subpage.',
listRequestSubpage: 'An error occurred while adding the deletion request to today’s log.',
notifyUploaders: 'An error occurred while notifying the ' + ( nsNr === 6 ? ' uploader(s) of this file' : 'creator of this page' ) + '.',
movePage: 'Error while moving the page.',
deletePage: 'Error deleting the page.'
},
addTemplateByHand: 'To nominate this ' + conf.wgCanonicalNamespace.toLowerCase() + ' for deletion, please edit the page to add the {{delete}} template and follow the instructions shown on it.',
completeRequestByHand: 'Please follow the instructions on the deletion notice to complete the request.',
errorDetails: 'A detailed description of the error is shown below:',
errorReport: 'Manually report the error here or click on %BUTTON% to send an automatic error-report.',
tagWas: 'The tag to be inserted into this page was ',


// Minor errors/warnings
ohc_fix_common_errors();
templateRegExp: 'The template does not expose a valid regular expression for {{X-To-DR}}. Go the the template and fix it there.',
ohc_fix_dts_template('dmy');
findTemplateAdderErr: 'Unable to find the person who added the template. This can occur if the template was already removed, the page is deleted or a redirect to the template is used. In this case you must add the redirect to the RegExp of the target template.',
ohc_fix_gr_template('dmy');
dupeParaErr: 'Error in the duplicate-template, check your language version!',
ohc_dates_to_dmy();
dupeExistErr: 'Retrieving information about %TITLE% failed. It is possible that it is deleted, the last revision is corrupt or the file is a redirect.',
ohc_remove_leading_zeroes();
noCreatorFound: 'The page you are attempting to add a tag to was deleted or moved. Unable to retrieve the content.',
ohc_fix_dmy_redundancies();
noPageFound: 'The page you are attempting to modify or move is corrupted, was deleted or moved: Unable to retrieve history and contents.'
}
};
 
AQD.preinstall();
 
if ( conf.wgUserLanguage !== 'en' ) {
$.when( mw.loader.getScript( mw.util.wikiScript() +
'?title=MediaWiki:Gadget-AjaxQuickDelete.js/' +
conf.wgUserLanguage + '.js&action=raw&ctype=text/javascript'
), $.ready ).always( function () { AQD.install(); } );
} else {
$( function () {
AQD.install();
} );
}
}


}() );
function ohc_body_dates_to_mdy()
// </nowiki>
{
 
ohc_use_dates_template('mdy');
// This script aligns dates into one of two formats allowed by [[WP:MOSNUM]].
ohc_fix_common_errors();
// PLEASE READ THE DOCUMENTATION at [[User:Ohconfucius/script/MOSNUM dates]] (click on the link above) before using.
ohc_fix_dts_template('mdy');
ohc_fix_gr_template('mdy');
ohc_dates_to_mdy();
ohc_remove_leading_zeroes();
ohc_fix_mdy_redundancies();
}
 
/** ------------------------------------------------------------------------ **/
function ohc_all_to_dmy_driver(e)
{
e.preventDefault();
ohc_delink_dates();
ohc_protect_dates();
ohc_fix_unambiguous_dates();
ohc_body_dates_to_dmy();
ohc_delink_ISO_to_dmy();
ohc_delink_year_in_X();
ohc_customize_all_to_dmy();
ohc_ISO_to_dmy_in_citations();
ohc_unprotect_dates();


// Feedback and constructive criticism are welcome
ohc_MOSNUM_edit_summary();
}


/**
function ohc_all_to_mdy_driver(e)
* TemplateScript adds configurable templates and scripts to the sidebar, and adds an example regex editor.
{
* @see https://meta.wikimedia.org/wiki/TemplateScript
e.preventDefault();
*/
ohc_delink_dates();
// <pre>
ohc_protect_dates();
if ($.inArray(mw.config.get('wgAction'), ['edit', 'submit']) !== -1) {
ohc_fix_unambiguous_dates();
$.ajax(
ohc_body_dates_to_mdy();
'//tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js',
ohc_delink_ISO_to_mdy();
{dataType: 'script', cache: true}
ohc_delink_year_in_X();
).done(function () {
ohc_customize_all_to_mdy();
$.when(
ohc_ISO_to_mdy_in_citations();
mw.loader.using(['mediawiki.util']),
ohc_unprotect_dates();
$.ajax('//en.wikipedia.org/w/index.php?title=User:Ohconfucius/script/MOSNUM_utils.js&action=raw&ctype=text/javascript',
 
{dataType: 'script', cache: true}),
ohc_MOSNUM_edit_summary();
$.ready
}
).done(function () {
var add = function() {
            return mw.util.addPortletLink.apply(mw.util, arguments);
};


$(add('p-tb', '#', 'DATES to dmy', 'dmy-unitfixer', 'Align all dates to dmy', '', '')).click(ohc_all_to_dmy_driver);
function ohc_dmy_publication_dates_driver(e)  
$(add('p-tb', '#', 'DATES to mdy', 'mdy-unitfixer', 'Align all dates to mdy', '', '')).click(ohc_all_to_mdy_driver);
{
// $(add('p-tb', '#', 'Expand ref dates', 't-expandref', 'Expand month names within refs', '', '')).click(ohc_expand_ref_dates_driver);
e.preventDefault();
// $(add('p-tb', '#', 'Expand all dates', 't-expandall', 'Expand month names throughout', '', '')).click(ohc_expand_all_dates_driver);
// ohc_delink_dates();
$( add('p-tb', '#', 'US-slash dates', 't-US', 'US-slash', '', '') ).click(ohc_US_slash_dates_driver);
ohc_protect_dates();
$( add('p-tb', '#', 'UK-slash dates', 't-UK', 'UK-slash', '', '') ).click(ohc_UK_slash_dates_driver);
ohc_body_dates_to_dmy();
});
ohc_customize_body_to_dmy();
});
ohc_dmy_publication_dates();
ohc_unprotect_dates();
 
ohc_MOSNUM_edit_summary();
}
}


function ohc_fix_unambiguous_dates()
function ohc_mdy_publication_dates_driver(e)  
{
{
// resolvable ambiguous date formats
e.preventDefault();
// UK style
// ohc_delink_dates();
ohc_regex(/([^-\w/:\.])@DD\.@MM\.@YYYY(?=[^-–/\w&])/gi, "$1@Day @Month @YYYY", function(d) {
ohc_protect_dates();
if (d.d == d.m) return true;
ohc_body_dates_to_mdy();
if (d.d > 12) return true;
ohc_customize_body_to_mdy();
return false;
ohc_mdy_publication_dates();
});
ohc_unprotect_dates();
ohc_regex(/([^-\w/:\.])@DD\/@MM\/@YYYY(?=[^-–/\w&])/gi, "$1@Day @Month @YYYY", function(d) {
 
if (d.d == d.m) return true;
ohc_MOSNUM_edit_summary();
if (d.d > 12) return true;
return false;
});


// US style
ohc_regex(/([^-\w/:\.])@MM\.@DD\.@YYYY(?=[^-–/\w&])/gi, "$1@Month @Day, @YYYY", function(d) {
if (d.d > 12) return true;
return false;
});
ohc_regex(/([^-\w/:\.])@MM\/@DD\/@YYYY(?=[^-–/\w&])/gi, "$1@Month @Day, @YYYY", function(d) {
if (d.d > 12) return true;
return false;
});
}
}


function ohc_US_slash_dates_to_mdy()
function ohc_body_to_dmy_driver(e)  
{
{
//ranges
e.preventDefault();
ohc_regex(/([^-\d/:\.])@MM\/@DD\/@YYNN(&nbsp;|\s)?(?:(?:[-–—]|&[mn]dash;)(?:&nbsp;|\s)?)@MM\/@DD\/@YYNN(?=[^-–/\w&])/gi, "$1@Mon1 @Day1, @Year1$2 – @Mon2 @Day2, @Year2");
// ohc_delink_dates();
ohc_regex(/([^-\d/:\.])@MM\.@DD\.@YYNN(&nbsp;|\s)?(?:(?:[-–—]|&[mn]dash;)(?:&nbsp;|\s)?)@MM\.@DD\.@YYNN(?=[^-–/\w&])/gi, "$1@Mon1 @Day1, @Year1$2 – @Mon2 @Day2, @Year2");
ohc_protect_dates_ref();
ohc_regex(/(\| ?)@MM\/@DD\/@YYNN(&nbsp;|\s)?(?:(?:[-–—]|&[mn]dash;)(?:&nbsp;|\s)?)@MM\/@DD\/@YYNN(?=\s*\|)/gi, "$1@Mon1 @Day1, @Year1$2 – @Mon2 @Day2, @Year2");
ohc_body_dates_to_dmy();
ohc_regex(/(\| ?)@MM\.@DD\.@YYNN(&nbsp;|\s)?(?:(?:[-–—]|&[mn]dash;)(?:&nbsp;|\s)?)@MM\.@DD\.@YYNN(?=\s*\|)/gi, "$1@Mon1 @Day1, @Year1$2 – @Mon @Day2, @Year2");
ohc_customize_body_to_dmy();
ohc_unprotect_dates();


// resolvable ambiguous date formats
ohc_MOSNUM_edit_summary();
ohc_regex(/([^-\d/:\.])@MM\/@DD\/@YYNN(?=[^-–/\w&])/gi, '$1@Month @Day, @YYYY');
ohc_regex(/([^-\d/:\.])@MM\.@DD\.@YYNN(?=[^-–/\w&])/gi, '$1@Month @Day, @YYYY');
ohc_regex(/([^-\d/:\.])@MM[-–]@DD[-–]@YYNN(?=[^-–/\w&])/gi, '$1@Month @Day, @YYYY');
ohc_regex(/(\| ?)@MM\/@DD\/@YYNN(?=\s*\|)/gi, '$1@Month @Day, @YYYY');
ohc_regex(/(\| ?)@MM\.@DD\.@YYNN(?=\s*\|)/gi, '$1@Month @Day, @YYYY');
// ohc_regex(/(\| ?)@MM[-–]@DD[-–]@YYNN(?=\s*\|)/gi, '$1@Month @Day, @YYYY');
}
}
 
function ohc_UK_slash_dates_to_dmy()
function ohc_body_to_mdy_driver(e)  
{
{
//ranges
e.preventDefault();
ohc_regex(/([^-\d/:\.])@DD\/@MM\/@YYNN(&nbsp;|\s)?(?:(?:[-–—]|&[mn]dash;)(?:&nbsp;|\s)?)@DD\/@MM\/@YYNN(?=[^-–/\w&])/gi, "$1@Day1 @Mon1 @Year1$2 – @Day2 @Mon2 @Year2");
// ohc_delink_dates();
ohc_regex(/([^-\d/:\.])@DD\.@MM\.@YYNN(&nbsp;|\s)?(?:(?:[-–—]|&[mn]dash;)(?:&nbsp;|\s)?)@DD\.@MM\.@YYNN(?=[^-–/\w&])/gi, "$1@Day1 @Mon1 @Year1$2 – @Day2 @Mon2 @Year2");
ohc_protect_dates_ref();
ohc_regex(/(\| ?)@DD\/@MM\/@YYNN(&nbsp;|\s)?(?:(?:[-–—]|&[mn]dash;)(?:&nbsp;|\s)?)@DD\/@MM\/@YYNN(?=\s*\|)/gi, "$1@Day1 @Mon1 @Year1$2 – @Day2 @Mon2 @Year2");
ohc_body_dates_to_mdy();
ohc_regex(/(\| ?)@DD\.@MM\.@YYNN(&nbsp;|\s)?(?:(?:[-–—]|&[mn]dash;)(?:&nbsp;|\s)?)@DD\.@MM\.@YYNN(?=\s*\|)/gi, "$1@Day1 @Mon1 @Year1$2 – @Day2 @Mon2 @Year2");
ohc_customize_body_to_mdy();
ohc_unprotect_dates();


// resolvable ambiguous date formats
ohc_MOSNUM_edit_summary();
ohc_regex(/([^-\d/:\.])@DD\/@MM\/@YYNN(?=[^-–/\w&])/gi, '$1@Day @Month @YYYY');
}
ohc_regex(/([^-\d/:\.])@DD\.@MM\.@YYNN(?=[^-–/\w&])/gi, '$1@Day @Month @YYYY');
 
ohc_regex(/([^-\d/:\.])@DD[-–]@MM[-–]@YYNN(?=[^-–/\w&])/gi, '$1@Day @Month @YYYY');
function ohc_ISO_to_dmy_driver(e)  
ohc_regex(/(\| ?)@DD\/@MM\/@YYNN(?=\s*\|)/gi, '$1@Day @Month @YYYY');
{
ohc_regex(/(\| ?)@DD\.@MM\.@YYNN(?=\s*\|)/gi, '$1@Day @Month @YYYY');
e.preventDefault();
// ohc_regex(/(\| ?)@DD[-–]@MM[-–]@YYNN(?=\s*\|)/gi, '$1@Day @Month @YYYY');
ohc_protect_dates();
ohc_delink_ISO_to_dmy();
ohc_customize_ISO_to_dmy();
ohc_unprotect_dates();
 
// ohc_MOSNUM_edit_summary();
}
}


function ohc_remove_leading_zeroes()
function ohc_ISO_to_mdy_driver(e) {
{
e.preventDefault();
ohc_regex(/(\D[^\w\/])@Month\s@ZD@th?,?\s@YYYY(?=\W\D)/gi, "$1@LMonth @Day, @LYear");
ohc_protect_dates();
ohc_regex(/(\D[^\w\/])@Month\s@ZD@th?(?=\W\D)/gi, "$1@LMonth @Day");
ohc_delink_ISO_to_mdy();
ohc_regex(/(\D[^\w\/])@ZD@th?\s@Month\s@YYYY(?=\W\D)/gi, "$1@Day @LMonth @LYear");
ohc_customize_ISO_to_mdy();
ohc_regex(/(\D[^\w\/])@ZD@th?\s@Month(?=\W\D)/gi, "$1@Day @LMonth");
ohc_unprotect_dates();
 
// ohc_MOSNUM_edit_summary();
}
}


function ohc_delink_dates()
function ohc_delink_year_in_X_driver(e)  
{
{
//add missing space between wikilinks
e.preventDefault();
regex(/(\]\])(\[\[)/gi, '$1 $2'); //remove (?!file:) to ensure a space between all links
ohc_delink_year_in_X();
}
// rem redundant quote marks and parentheses
regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)\'\'\'([^|}\[\]]*)\'\'\'(?=\s*[|}])/gi, "$1$2");
regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)\'\'([^|}\[\]]*)\'\'(?=\s*[|}])/gi, "$1$2");
regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)\"([^|}\[\]]*)\"(?=\s*[|}])/gi, "$1$2");
regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)\(([^|}\[\]]*)\)(?=\s*[|}])/gi, "$1$2");


//delink unpiped dates
function ohc_expand_ref_dates_driver(e) {
//delink full dates
e.preventDefault();
ohc_regex(/\[\[@Day[\s_](?:of[\s_])?@Month(?:\]\]\s?\[\[\| )@YYYY\]\]/gi, "@Day @LMonth @YYYY");
ohc_expand_ref_dates();
ohc_regex(/\[\[@Month (?:the\s)?@Day(?:\]\],? \[\[|, )@YYYY\]\]/gi, "@LMonth @Day, @YYYY");
ohc_protect_dates();
ohc_unprotect_dates();
ohc_expand_edit_summary();
}


//delink yyyy-mm-dd dates
function ohc_expand_all_dates_driver(e)  
ohc_regex(/\[\[@YYYY(?:\]\]-\[\[|-)@MM-@DD\]\]/gi, "@YYYY-@MM-@DD");
{
ohc_regex(/@YYYY-\[\[@MM-@DD\]\]/gi, "@YYYY-@MM-@DD");
e.preventDefault();
 
ohc_expand_ref_dates();
//underscore and nbsp in linked dates
ohc_protect_dates();
ohc_regex(/\[\[@DD@th?(?:\s|_|&nbsp;)@Month\]\]/gi, "@Day @LMonth");
ohc_expand_all_dates();
ohc_regex(/\[\[@Month(?:\s|_|&nbsp;)@DD@th?\]\]@th?/gi, "@LMonth @Day"); //consolidated regex with flexible removal of ordinal simple date
ohc_unprotect_dates();
ohc_regex(/\[\[@Day @Month\]\]/gi, "@Day @LMonth");
ohc_expand_edit_summary();
ohc_regex(/\[\[@Month @YYYY\]\]/gi, "@LMonth @YYYY");
}
ohc_regex(/\[\[@YYYY\]\]/gi, "@YYYY");


//remove leading zero and links from linked date
function ohc_abbrev_ref_dates_driver(e)
ohc_regex(/\[\[@Month(?:[ _]|&nbsp;)@ZD@th\]\]/gi, "@LMonth @Day");
{
ohc_regex(/\[\[@ZD@th(?:[ _]|&nbsp;)@Month\]\]/gi, "@Day @LMonth");
e.preventDefault();
ohc_protect_dates();
ohc_abbrev_ref_dates();
ohc_unprotect_dates();
ohc_slash_edit_summary();
}


// remove nowrap template from dm and md dates
function ohc_UK_slash_dates_driver(e)  
ohc_regex(/(date[ ]*=[ ]*)\{\{(?:j|no ?(?:break|wrap))\|(?:@DD(?:[ _]|&nbsp;)@Month)( @yyyy|)\}\}/gi, '$1@DD @LMonth$2');
{
ohc_regex(/(date[ ]*=[ ]*)\{\{(?:j|no ?(?:break|wrap))\|(?:@Month(?:[ _]|&nbsp;)@DD)( @yyyy|)\}\}/gi, '$1@LMonth @DD$2');
e.preventDefault();
ohc_expand_ref_dates();
//delink single dm or 'dth the m'
ohc_protect_dates_slash();
ohc_regex(/(?:the\s)?\[\[@Day@th?[\s_](?:of[\s_])?@Month\]\]/gi, "@Day @LMonth");
ohc_UK_slash_dates_to_dmy();
//delink single md or 'm the dth'
ohc_unprotect_dates();
ohc_regex(/\[\[@Month[\s_](?:the[\s_])?@Day@th?\]\](?=\W)/gi, "@LMonth @Day");
ohc_slash_edit_summary();
}


//month+day piped
function ohc_US_slash_dates_driver(e)
ohc_regex(/\[\[(?:@dd@th?[\s_](?:of[\s_])?@month|@month[\s_]@dd@th?)\|((?:@month |)@day)@th?\]\]/gi, "$1");
{
ohc_regex(/\[\[(?:@dd@th?[\s_](?:of[\s_])?@month|@month[\s_]@dd@th?)\|@Day@th?[\s_](@month|)\]\]/gi, "@Day $1");
e.preventDefault();
ohc_expand_ref_dates();
ohc_protect_dates_slash();
ohc_US_slash_dates_to_mdy();
ohc_unprotect_dates();
ohc_expand_edit_summary();
}


// ohc_regex(/\[\[@month @dd(?:#[^|]+|)\|([^|\]]+)@th?\]\]/gi, "$1");
// </pre>
// ohc_regex(/\[\[@dd @month(?:#[^|]+|)\|([^|\]]+)@th?\]\]/gi, "$1");
ohc_regex(/\[\[@month @yyyy(?:#[^|]+|)\|([^|\]]+)\]\]/gi, "$1");


//month+day+year pseudo-ISO dates
//সংশ্লিষ্ট পাতা ত্যাগ না করেই অন্য পাতা থেকে পুনর্নির্দেশ করা যাবে।
ohc_regex(/\[\[@Month @DD\|\d\d-\d\d\]\]-(?:\[\[)?(?:@yyyy[^|]*\|)?@YYYY(?:\]\])/gi, "@Day @LMonth @YYYY");
//<nowiki>
ohc_regex(/\[\[@DD\s@Month\|\d\d-\d\d\]\]-(?:\[\[)?(?:@yyyy[^|]*\|)?@YYYY(?:\]\])/gi, "@Day @LMonth @YYYY");
( function () {
var redir = $(mw.util.addPortletLink('p-tb','#','পুনর্নির্দেশক','পুনর্নির্দেশ তৈরিকারী','পুনর্নির্দেশ তৈরিকারী','','#pt-mytalk'));
$( redir ).click( function() {
var redirec = prompt("যে পাতা থেকে এই পাতায় পুনর্নির্দেশ করতে চান তার নাম লিখুন:", "");
  if (redirec === null || redirec === "") {
alert( 'আপনি কোনও নাম প্রবেশ করান নি। দয়া করে আবার চেষ্টা করুন।' );  
  } else  {
  var params = {
action: 'edit',
title: redirec ,
createonly: 1,
prependtext: '#পুনর্নির্দেশ [[' + mw.config.get("wgPageName") + ']]',
appendtext: " \n" + '{{একটি পুনর্নির্দেশ}}',
summary: '[[' + mw.config.get("wgPageName") + ']] পাতায় পুনর্নির্দেশ করা হল' ,
format: 'json'
};
api = new mw.Api();
api.postWithToken( 'csrf', params ).done( function ( data ) {
alert( 'সফলভাবে ' + redirec + ' পাতা থেকে একটি পুনর্নির্দেশ তৈরি করা হয়েছে!' );
});
  }
}
);
}() );
//</nowiki>


//'[[month day|xxXxx]]Xyyyy ' to 'month day, year'
//<nowiki>
ohc_regex(/\[\[@Month\s@Day\|@dd.@dd\]\].@YYYY/gi, "@LMonth @Day, @YYYY");
( function () {
//'[[day month|xxXxx]]Xyyyy' to 'day month year'
var talkp = $(mw.util.addPortletLink('p-tb','#','স্বাগত জানান','স্বাগত জানান','স্বাগত জানান','','#pt-mytalk'));
ohc_regex(/\[\[@Day\s@Month\|@dd.@dd\]\].@YYYY/gi, "@Day @LMonth @YYYY");
$( talkp ).click( function() {
 
var talk = prompt("কোন ধরনের স্বাগত বার্তা যুক্ত করতে চান এমন টেমপ্লেটটি লিখুন {{Subst:}} সাথে, অন্যথায় পূর্বনির্ধারিত {{Subst:স্বাগতম}} যুক্ত হবে:", "");
// century
  if (talk === null || talk === "") {
regex(/\[\[((?:first|second|third|(?:four|fif|six|seven|eigh|nin|ten|eleven|twelf|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twentie)th|twenty[\s\-]first[\s\-])centur(?:y|ies)(?:\s(?:AD|BC|CE|BCE))?)\]\]/gi, '$1');
    var params1 = {
regex(/\[\[(?:first|second|third|(?:four|fif|six|seven|eigh|nin|ten|eleven|twelf|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twentie)th|twenty[\s\-]first)[\s\-_]centur(?:y|ies)(?:\s(?:AD|BC|CE|BCE))?\|([^\]]{1,30})\]\]/gi, '$1');
action: 'edit',
regex(/\[\[(\d{1,2}(?:st|[nr]d|th))[\s\-_](centur(?:y|ies))(\s(?:AD|BC|CE|BCE)|)\]\]/gi, '$1 $2$3');
title: 'User talk:' + mw.config.get("wgRelevantUserName"),
ohc_regex(/\[\[\d{1,2}@th[\s\-_]centur(?:y|ies)(?:\s(?:AD|BC|CE|BCE)|)\|([^\]]{1,30})\]\]/gi, '$1');
prependtext: '{{Subst:স্বাগতম}}'
 
,
// months
summary: 'ভারতপিডিয়ায় স্বাগতম!',
ohc_regex(/\[\[@Month\]\]/gi, "@LMonth");
format: 'json'
ohc_regex(/\[\[@FullMonth\|([^\]]{1,30})\]\]/gi, "$1");
};
 
api = new mw.Api();
// decades and years
regex(/(\d{1,3}0)[‘`´’′]?s/g, '$1s');
api.postWithToken( 'csrf', params1 ).done( function ( data ) {
regex(/\[\[(\d{1,3}0)\'?s\]\]/g, '$1s');
alert( 'সফলভাবে স্বাগত জানানো হয়েছে!' );
regex(/\[\[\d{1,3}0\'?s?\|([^\]]{1,30})\]\]/g, '$1');
} );
regex(/\[\[(\d{1,3}0)\'?(s)?\s(AD|BC|CE|BCE)\]\]/gi, '$1$2 $3');
 
regex(/\[\[(\d{1,4}[\s_]?)(AD|BC|CE|BCE)\]\]/gi, '$1$2');
  } else {
regex(/\[\[(AD|BC|CE|BCE)([\s_]?)(\d{1,4})\]\]/gi, '$1$2$3');
  var params = {
ohc_regex(/([-–])\[\[\s?@yyyy\s?\|\s?(\d{2,4})\s?\]\]/gi, '$1$2'); //piped year
action: 'edit',
regex(/\[\[([12]\d{3}|[1-9]\d{0,2})\]\]/gi, '$1');
title: 'User talk:' + mw.config.get("wgRelevantUserName"),
regex(/\[\[\d{1,3}0\'?s?\s(?:AD|BC|CE|BCE)\|([^\]]{1,30})\]\]/gi, '$1');
prependtext: talk
regex(/\[\[\d{1,3}0\'?s?\s\(decade\)\|([^\]]{1,30})\]\]/gi, '$1');
,
 
summary: 'ভারতপিডিয়ায় স্বাগত!',
//month+year
format: 'json'
//Identify surprise or 'Easter egg' diversions linking month+years to year articles. Turn them into month+year links to be dealt with below
};
ohc_regex(/\[\[@yyyy in[^|\]]+\|@Day @Month @YYYY\]\]/gi, "@Day @LMonth @YYYY");
api = new mw.Api();
ohc_regex(/\[\[@yyyy in[^|\]]+\|@Month @Day,? @YYYY\]\]/gi, "@LMonth @Day, @YYYY");
ohc_regex(/\[\[@yyyy#[^|\]]+\|(@month\s|)(@yyyy)\]\]/gi, "$1$2");
api.postWithToken( 'csrf', params ).done( function ( data ) {
ohc_regex(/\[\[@yyyy#[^|\]]+\|(@month|@yyyy)\]\]/gi, "$1");
alert( 'সফলভাবে স্বাগত জানানো হয়েছে!' );
ohc_regex(/\[\[(@month\s@yyyy)\]\]/gi, "$1");
} );
ohc_regex(/\[\[@month\s@yyyy\|([^\]]{1,30})\]\]/gi, "$1");
  }
ohc_regex(/\[\[(?:List of |)Bollywood films of @yyyy\|@YYYY\]\](?= [^\[]{2}^B)/gi, "@YYYY");
}
 
);
ohc_regex(/(\[\[@yyyy[^|\]]+\|@yyyy)(\]\])( season)/gi, "$1$3$2");
}() );
 
//</nowiki>
//removed piped years when in full date (excepting disambiguated parentheses - updated 24/2/2012)
//<nowiki>
// ohc_regex(/\[\[[^|\]\(\)]{1,32}\|@YYYY\]\]/gi, '@Year');  // 23/6/2021 – disabled delinking "other" year-in articles
console.time('mobileUndo');
 
$.when(mw.loader.using(['mediawiki.util', 'mediawiki.api', 'oojs-ui-windows', 'oojs-ui-core', 'oojs-ui.styles.icons-editing-core'])).then(function() {
//Identify surprise or 'Easter egg' diversions linking months to year or "year in" articles.
    return new mw.Api().getMessages(['editundo', 'Undo-nochange']);
ohc_regex(/\[\[\d{1,4}#[^|\]]+\|@Month\]\]/gi, "@LMonth");
}).then(function(globalmessages) {
ohc_regex(/\[\[@yyyy \w[^|\]]{3,12}\|@Year\]\]/gi, '@Year');
    var mobileUndo, i18n_lang = mw.config.get('wgUserLanguage');
 
    var i18n = {
// month and day piped
        "en": {
ohc_regex(/\[\[@month[\s_]@day\|@MM-@DD\]\]/gi, "@MM-@DD");
            "mu-success": "Successful",
ohc_regex(/\[\[@month[\s_]@day\|([^\]]{1,30})\]\]/gi, "$1");
            "mu-fail": "Failed",
ohc_regex(/\[\[@day(?:\s|_|@th )(?:of[\s_]|)?@month\|([^\]]{1,30})\]\]/gi, "$1");
            "mu-loading": "Loading...",
 
            "editsummary-ad": "",
//years piped
            "mu-undo-successful": "Revert successful.... Reloading in a sec",
regex(/\[\[\d{1,4}\|([^\]]{1,30})\]\]/gi, '$1');
            "mu-empty-reponse-from-server": "An empty response was received from the server",
}
            "mu-edit-summary-prompt": "Add a reason to your edit summary !",
 
            "mu-edit-summary-prompt-placeholder": "Reason...",
function ohc_fix_common_errors()
            "mu-thank-success": "Thanked",
{
            "mu-thank-confirm": "Send public thanks ?",
ohc_regex(/(\d)<sup>@th<\/sup>/gi, '$1th');
            "mu-thank-loading": "Thanking...",
// remove dashbot comment from dates
            "mu-thank-successful": "You thanked $1.",
regex(/<!-- ?DASHBot ?-->/gi, '');
            "mu-thank-failed": "Failed to thank $1.",
ohc_regex(/(\|\s*(?:date|year)\s*=)\s*c(?:irca|a\.)?\s?((?:@day |)@month @year)(?=[\s\n]*[<|}])/gi, '$1c. $2'); //add space
            "mu-http-error":"HTTP error: "
//common cs1 errors
        },
regex(/(\|\s*(?:date|year)\s*=)\s*(1[7-9]\d|20[0-1])\?(?=[\s\n]*[<|}])/gi, '$1c. $20');
        "bn": {
regex(/(\|\s*(?:date|year)\s*=\s*(1[7-9])\d{2})[-](\d{2})(?=[\s\n]*[<|}])/gi, '$1–$2$3');
            "mu-success": "সফল",
// regex(/(\|\s*(?:date|year)\s*=\s*(20)[0-1]\d)[-–]([0-2]\d)(?=[\s\n]*[<|}])/gi, '$1–$2$3');  
            "mu-fail": "ব্যর্থ হয়েছে",
regex(/(\|\s*(?:date|year)\s*=\s*)@YYYY\s*[-–/]\s*@YYYY(?=[\s\n]*[<|}])/gi, '$1@YYYY1–@YYYY2'); //common cs1 error
            "mu-loading": "লোড করা হচ্ছে...",
regex(/(\|\s*(?:date)\s*=)\s*s(pring|ummer),?\s*((?:1[7-9]\d|20[0-1])\d)(?=[\s\n]*[<|}])/gi, '$1S$2 $3'); //common cs1 error
            "editsummary-ad": "",
regex(/(\|\s*(?:date)\s*=)\s*a(utumn),?\s*((?:1[7-9]\d|20[0-1])\d)(?=[\s\n]*[<|}])/gi, '$1A$2 $3'); //common cs1 error
            "mu-undo-successful": "পূর্বাবস্থায় ফেরত যাওয়া সফল হয়েছে.... পুনঃলোড করা হচ্ছে",
regex(/(\|\s*(?:date)\s*=)\s*f(all),?\s*((?:1[7-9]\d|20[0-1])\d)(?=[\s\n]*[<|}])/gi, '$1F$2 $3'); //common cs1 error
            "mu-empty-reponse-from-server": "সার্ভার থেকে একটি খালি প্রতিক্রিয়া পাওয়া গেছে।",
regex(/(\|\s*(?:date)\s*=)\s*w(inter),?\s*((?:1[7-9]\d|20[0-1])\d)(?=[\s\n]*[<|}])/gi, '$1W$2 $3'); //common cs1 error
            "mu-edit-summary-prompt": "সম্পাদনা সারাংশে কারণ উল্লেখ করুন!",
ohc_regex(/(\|\s*access-?date\s*=)\s*(@month @year)(?=[\s\n]*[<|}])/gi, '$11 $2'); //common cs1 error
            "mu-edit-summary-prompt-placeholder": "কারণ...",
// ohc_regex(/(\|\s*date\s*=\s*)@year\?(?=[\s\n]*[<|}])/gi, '$1@Year'); //common cs1 error
            "mu-thank-success": "ধন্যবাদ দিয়েছেন",
// ohc_regex(/(\|\s*(?:date|year)\s*=)\s*@year\?(?=[\s\n]*[<|}])/gi, '$1c. @Year'); //common cs1 error
            "mu-thank-confirm": "প্রকাশ্য ধন্যবাদ জানাবেন?",
// ohc_regex(/(\|\s*(?:date|year)\s*=)\s*(@month @year)\?(?=[\s\n]*[<|}])/gi, '$1c. $2'); //common cs1 error
            "mu-thank-loading": "ধন্যবাদ জানানো হচ্ছে...",
ohc_regex(/(\|\s*access-?date\s*=)\s*@month @day, (1[7-9]\d{2}|2000)(?=[\s\n]*[<|}])/gi, '$1'); //rem access date before Wikipedia (জানুয়ারি 2001)
            "mu-thank-successful": "আপনি $1 কে ধন্যবাদ জানিয়েছেন।",
ohc_regex(/(\|\s*access-?date\s*=)\s*@day @month.? (1[7-9]\d{2}|2000)(?=[\s\n]*[<|}])/gi, '$1'); //rem access date before Wikipedia (জানুয়ারি 2001)
            "mu-thank-failed": "$1 কে ধন্যবাদ জানানো ব্যর্থ হয়েছে।",
ohc_regex(/(\|\s*access-?date\s*=)\s*31( (?:এপ্রিল|জুন|সেপ্টেম্বর|নভেম্বর) @year)(?=[\s\n]*[<|}])/gi, '$130$2'); //rem nonsense access date (short months)
            "mu-http-error":"HTTP ত্রুটি: "
ohc_regex(/(\|\s*access-?date\s*=)\s*29( ফেব্রুয়ারি (?:200[1235679]|201[1345789]))(?=[\s\n]*[<|}])/gi, '$128$2'); //rem nonsense access date 29 ফেব্রুয়ারি (non-leap year)
        }
ohc_regex(/(\|\s*access-?date\s*=)\s*(?:3[01])( ফেব্রুয়ারি @yyyy)(?=[\s\n]*[<|}])/gi, '$128$2'); //rem nonsense access dates ফেব্রুয়ারি
    };
regex(/(\|\s*access-?date\s*=)\s*(\d{4})(?=[\s\n]*[<|}])/gi, ''); //common cs1 error
if(undefined === i18n[i18n_lang]){
i18n_lang = 'en';
//month+day+year pseudo-ISO dates
}
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*@dd)-@Mon-@YYYY/gi, "$1 @FullMonth @YYYY");
    if (mw.config.get('wgCanonicalSpecialPageName') === 'MobileDiff') {
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@YYYY-@DD-@Mon/gi, "$1 @DD @FullMonth @YYYY");
        mw.util.addCSS('#mw-mf-userinfo .mobileUndo-ui .mw-ui-icon.mw-ui-icon-before:before{display:none;}\n#mobileUndo > a > span.oo-ui-iconElement-icon.oo-ui-icon-editUndo.oo-ui-image-invert{display:inline-block; position:initial;}\n#mobileUndo > a{padding:0.57142857em 0.9375em;}'+
 
        '#mw-mf-userinfo > div > div.mobileUndo-ui > a > div{line-height:normal;}');
regex(/(\|\s*(?:date|year)\s*=)\s*(?:(?:date |)unknown|(?:not? |non-|un)date[ds])(?=[\s\n]*[<|}])/gi, '$1n.d.'); //common cs1 error
        if (mw.config.get('wgVisualEditor').pageLanguageDir === 'ltr') {
regex(/(\|\s*(?:date|year)\s*=)\s*n\.?d(?=[\s\n]*[<|}])/gi, '$1n.d.'); //common cs1 error
            $('#mw-mf-userinfo .post-content').append($('<div>').attr('class', 'mobileUndo-ui').css({
regex(/(\|\s*)year(\s*=\s*)(?=n\.?d\.)(?=[\s\n]*[<|}])/gi, '$1date$2'); //common cs1 error
                'display': 'inline-block',
 
                'float': 'right'
  // remove parasitic metadata -  days of the week/descriptives
            }));
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)(?:[^|}\d]*|)@Day\s+@Month\s+@YYYY((?:[a-z]\b|)\s?)[^|<}]*(?=[\s\n]*[<|}])/gi, "$1@Day @Month @YYYY$2"); //rem negate "<", "hyphens" "dashes" 26/6/2020
        } else {
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)[^|}]*@Month\s+@Day,\s+@YYYY((?:[a-z]\b|)\s?)[^|<}]*(?=[\s\n]*[<|}])/gi, "$1@Month @Day, @YYYY$2"); //rem negate "<", "hyphens" "dashes" 26/6/2020
            $('#mw-mf-userinfo .post-content').append($('<div>').attr('class', 'mobileUndo-ui').css({
// ohc_regex(/(\|\s*date\s*=\s*)(?:[^|}–<]*\D|)@Day\s+@Month\s+@YYYY ?– ?@Day\s+@Month\s+@YYYY[^|}–<]*(?=[\s\n]*[<|}])/gi, "$1@Day1 @Mon1 @Year1 – @Day2 @Mon2 @Year2");
                'display': 'inline-block',
// ohc_regex(/(\|\s*date\s*=\s*)[^|}–<]*@Month\s+@Day,\s+@YYYY ?– ?@Month @Day, @YYYY[^|}–<]*(?=[\s\n]*[<|}])/gi, "$1@Mon1 @Day1, @Year1 – @@Mon2 Day2, @Year2");
                'float': 'left'
// regex(/(\|\s*author\s*=\s*)(?:posted|published)(?: by\b| on\b|)[\s:](?=\w)/gi, "$1");
            }));
// regex(/(\|\s*(?:date|archive-?date|access-?date|author|year)\s*=\s*)(?:accessed|retrieved|entered|posted|published|(?:last |)updated?|©)(?: by\b| on\b|)[\s:]*(?=\w)/gi, "$1");
        }
regex(/(\|\s*(?:author|first|last)\s*=\s*)(?:by\b|on\b)[\s:]*(?=\w)/gi, "$1");
        $('.mobileUndo-ui').append($('.mw-mf-action-button').remove().css({
regex(/(\|\s*(?:date|archive-?date|access-?date|author|first|last)\s*=\s*)(?:(?:Mon|Tues|Wednes|Thurs|Fri|Satur|Sun)day,?)\s/gi, "$1");
            'clear': 'none'
regex(/(\|\s*(?:date|archive-?date|access-?date|author|first|last)\s*=\s*)(?:Mon|Tues?|Wed|Thur?|Fri|Sat)[\.,]?\s/gi, "$1"); //<!-- rem "Sun" - false positives -->
        }));
 
        if (!$('.warningbox').length && mw.config.get('wgRelevantPageIsProbablyEditable')) {
  // remove deprecated parameters (|day= and |month)
            mobileUndo = new OO.ui.ButtonWidget({
ohc_regex(/(\|\s*)day(?:\s*=\s*)@DD ?\| ?month(?:\s*=\s*)@Month ?\| ?year(?:\s*=\s*)@YYYY(?=[|}\s])/gi, '$1date=@Day @Month @Year');  
                label: (globalmessages.editundo).charAt(0).toUpperCase() + (globalmessages.editundo).slice(1),
ohc_regex(/(\|\s*)year(?:\s*=\s*)@YYYY ?\| ?month(?:\s*=\s*)@Month ?\| ?day(?:\s*=\s*)@DD(?=[|}\s])/gi, '$1date=@Month @Day, @Year');
                icon: 'editUndo',
                title: 'mobileUndo',
// typos
                flags: ['destructive', 'primary'],
ohc_regex(/(date *= *)@Day @Month ?@th/gi, '$1@Day @Month');
                id: 'mobileUndo'
ohc_regex(/(date *= *)@Day @Month\w(?= \d{3,4})/gi, '$1@Day @Month');
            });
 
            $('.mobileUndo-ui').append(mobileUndo.$element);
ohc_regex(/(date *= *(?:[12]?\d|30|31) )(জানুয়ারি|Febr)[\w ]?[aur]{3,4}\w{0,2}(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1$2uary');
            if (mw.config.get('wgVisualEditor').pageLanguageDir === 'ltr') {
ohc_regex(/(date *= *(?:[12]?\d|30|31) )J[anu]{3,5}r\w{0,2}(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1জানুয়ারি');
                $('#mobileUndo').css('margin-right', '0.3em');
ohc_regex(/(date *= *(?:[12]?\d) )Febua?r\w{0,2}(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1ফেব্রুয়ারি');
            } else {
ohc_regex(/(date *= *(?:[12]?\d|30|31) )M\w{2,3}ch(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1মার্চ');
                $('#mobileUndo').css('margin-left', '0.3em');
ohc_regex(/(date *= *(?:[12]?\d|30) )A[bpv\[]\w{2,3}l\w?(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1এপ্রিল');
            }
ohc_regex(/(date *= *(?:[12]?\d|30|31) )Ma[tui](?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1মে');
        }
ohc_regex(/(date *= *(?:[12]?\d|30) )J\wn\w(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1জুন');
        window.wgRelevantUser = function() {
ohc_regex(/(date *= *(?:[12]?\d|30) )J\w{1,2}e(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1জুন');
            var user;
ohc_regex(/(date *= *(?:[12]?\d|30|31) )জুলাই\w{1,2}(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1জুলাই');
            if ($('.mw-mf-user-link').text() !== '') {
ohc_regex(/(date *= *(?:[12]?\d|30|31) )A[oug]{2,3}\w{1,4}t(?:\w|us)?(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1আগষ্ট');
                user = $('.mw-mf-user-link').text();
ohc_regex(/(date *= *(?:[12]?\d|30|31) )(সেপ্টেম্বর|নভেম্বর|ডিসেম্বর)\w{2,4}b[er]{1,2}\w?(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1$2ember');
            } else {
ohc_regex(/(date *= *(?:[12]?\d|30) )S\w{0,2}p[ \[]?\w{2,5}[er]{2,3}\w?(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1সেপ্টেম্বর');
                user = $('#mw-mf-userinfo .post-content div:nth-child(2)').text();
ohc_regex(/(date *= *(?:[12]?\d|30|31) )O\w{0,2}t\w{1,3}[er]{2,3}\w?(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1অক্টোবর');
            }
ohc_regex(/(date *= *(?:[12]?\d|30) )[MN]\w{1,2}[bv] ?\w{1,3}b[er]{1,2}\w?(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1নভেম্বর');
            return user;
ohc_regex(/(date *= *(?:[12]?\d|30|31) )D[ie]?[cs] ?\w{1,4}b[er]{1,2}\w?(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1ডিসেম্বর');
        };
 
        window.wgRevId = ($('#mw-mf-diffarea > div.mw-mf-diff-info > h3 > a').attr('href')).split('&oldid=')[1];
ohc_regex(/(date *= *)@Month\w(?=(?: (?:[12]?\d|30|31),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1@Month'); //rem stray digit at the end of year string
        var revId = wgRevId;
        console.log(revId);
ohc_regex(/(date *= *)(জানুয়ারি|Febr)[\w ]?[aur]{3,4}\w{0,2}(?=(?: (?:[12]?\d|30|31),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1$2uary');
        var username = wgRelevantUser();
ohc_regex(/(date *= *)J[anu]{3,5}r\w{0,2}(?=(?: (?:[12]?\d|30|31),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1জানুয়ারি');
        $('#mw-mf-userinfo .post-content .mobileUndo-ui .mw-mf-action-button').click(function(e) {
ohc_regex(/(date *= *)Febua?r\w{0,2}(?=(?: (?:[12]?\d),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1ফেব্রুয়ারি');
            e.preventDefault();
ohc_regex(/(date *= *)M\w{2,3}ch(?=(?: (?:[12]?\d|30|31),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1মার্চ');
            OO.ui.confirm(i18n[i18n_lang]['mu-thank-confirm']).done(function(confirmed) {
ohc_regex(/(date *= *)A[bpv\[]\w{2,3}l\w?(?=(?: (?:[12]?\d|30),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1এপ্রিল');
                if (confirmed) {
ohc_regex(/(date *= *)Ma[tui](?=(?: (?:[12]?\d|30|31),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1মে');
                    $('.mw-mf-action-button').css('pointer-events', 'none').text(i18n[i18n_lang]['mu-thank-loading']);
ohc_regex(/(date *= *)J\wn\w(?=(?: (?:[12]?\d|30),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1জুন');
                    var api = new mw.Api();
ohc_regex(/(date *= *)J\w{1,2}e(?=(?: (?:[12]?\d|30),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1জুন');
                    api.postWithToken('csrf', {
ohc_regex(/(date *= *)জুলাই\w{1,2}(?=(?: (?:[12]?\d|30|31),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1জুলাই');
                        action: "thank",
ohc_regex(/(date *= *)A[oug]{2,3}\w{1,4}t(?:\w|us)?(?=(?: (?:[12]?\d|30|31),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1আগষ্ট');
                        rev: revId,
ohc_regex(/(date *= *)(সেপ্টেম্বর|নভেম্বর|ডিসেম্বর)\w{2,4}b[er]{1,2}\w?(?=(?: (?:[12]?\d|30|31),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1$2ember');
                    }).done(function(result) {
ohc_regex(/(date *= *)S\w{0,2}p[ \[]?\w{2,5}[er]{2,3}\w?(?=(?: (?:[12]?\d|30),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1সেপ্টেম্বর');
                        mw.notify((i18n[i18n_lang]['mu-thank-successful']).replace(/\$1/g, username));
ohc_regex(/(date *= *)O\w{0,2}t\w{1,3}[er]{2,3}\w?(?=(?: (?:[12]?\d|30|31),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1অক্টোবর');
                        $('.mw-mf-action-button').text(i18n[i18n_lang]['mu-thank-success']);
ohc_regex(/(date *= *)[MN]\w{1,2}[bv] ?\w{1,3}b[er]{1,2}\w?(?=(?: (?:[12]?\d|30),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1নভেম্বর');
                    }).fail(function() {
ohc_regex(/(date *= *)D[ie]?[cs] ?\w{1,4}b[er]{1,2}\w?(?=(?: (?:[12]?\d|30|31),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1ডিসেম্বর');
                        mw.notify((i18n[i18n_lang]['mu-thank-failed']).replace(/\$1/g, username));
 
                        $('.mw-mf-action-button').text(i18n[i18n_lang]['mu-failed']);
//insert comma to separate date from army unit
                    });
ohc_regex(/@FullMonth ((?:the |)\d\d*@th (?:Air(?:borne|)|Arm(?:ou?red|y)|Artillery|Battalion|Brigade|Co(?:mpan|)y|Division|Fleet|Group|Infantry|Land|Panzer|Regiment|Squadron|Sqn)\b)/g, "@Month, $1");
                }
 
            });
// remove parasitic metadata - time
        });
ohc_regex(/(\|\s*\w*date\s*=\s*@yyyy-@mm-@dd)\s?(?:T[0-2]\d:[0-5]\d:[0-5]\d(?:\s*|&nbsp;|)(?:GMT\s*|UTC\s*|[A-Z]{1,2}[DS]T\s*|Z))(?=\s*[|}])/g, "$1");
        console.timeEnd('mobileUndo');
ohc_regex(/(\|\s*\w*date\s*=\s*@month @day,? @yyyy)\s?(?:,? [0-2]?\d[\.:][0-5]\d(?:\s*|&nbsp;)(?:[apAP][mM]\s*|)(?:GMT\s*|UTC\s*|[A-Z]{1,2}[DS]T\s*|))(?=\|)/g, "$1");
        mobileUndo.on('click', function() {
ohc_regex(/(\|\s*\w*date\s*=\s*@day @month,? @yyyy)\s?(?:,? [0-2]?\d[\.:][0-5]\d(?:\s*|&nbsp;)(?:[apAP][mM]\s*|)(?:GMT\s*|UTC\s*|[A-Z]{1,2}[DS]T\s*|))(?=\|)/g, "$1");
            OO.ui.prompt(i18n[i18n_lang]['mu-edit-summary-prompt'], {
ohc_regex(/(\|\s*\w*date\s*=\s*\w[\w\s]+@month @day,? @yyyy)\s?(?:,? [0-2]?\d[\.:][0-5]\d(?:\s*|&nbsp;)(?:[apAP][mM]\s*|)(?:GMT\s*|UTC\s*|[A-Z]{1,2}[DS]T\s*|))(?=\|)/g, "$1");
                textInput: {
ohc_regex(/(\|\s*\w*date\s*=\s*\w[\w\s]+@day @month,? @yyyy)\s?(?:,? [0-2]?\d[\.:][0-5]\d(?:\s*|&nbsp;)(?:[apAP][mM]\s*|)(?:GMT\s*|UTC\s*|[A-Z]{1,2}[DS]T\s*|))(?=\|)/g, "$1");
                    placeholder: i18n[i18n_lang]['mu-edit-summary-prompt-placeholder']  
ohc_regex(/(\|\s*\w*date\s*=[^:|}]*)\s?(?:T?[0-2]\d:[0-5]\d:[0-5]\d(?:\s*|&nbsp;|)(?:GMT\s*|UTC\s*|[A-Z]{1,2}[DS]T\s*|Z))/g, "$1");
                }
 
            }).done(function(customEditSummary) {
//  add back spaces or comma or remove other single artefact after date string
                $.when(mw.loader.using('mediawiki.api')).then(function() {
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)(?:on |)@Day\s{,2}@Month\s{,2}@YYYY[^a-z{}]?(?=\s*[|}\n])/gi, "$1@Day @Month @YYYY$2");
                    return new mw.Api().getMessages(['undo-summary'], {
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)(?:on |)@Month\s{,2}@Day,?\s{,2}@YYYY[^a-z{}]?(?=\s*[|}\n])/gi, "$1@Month @Day, @YYYY$2");
                        amlang: mw.config.get('wgServerName').split('.wik')[0]
//long-hand palliative for observed failure to insert spaces
                    });
ohc_regex(/(\|\s*(?:archive|access|air)-?date\s*=\s*)(?:on |)([0-2]?\d|30|31)\s*(জানুয়ারি|ফেব্রুয়ারি|মার্চ|এপ্রিল|মে|জুন|জুলাই|আগষ্ট|সেপ্টেম্বর|অক্টোবর|নভেম্বর|ডিসেম্বর)\s*((?:19\d|20[0-1])\d\s?)[^|{}\s<>]*(?=\s*[|}])/gi, "$1$2 $3 $4");
                }).then(function(message) {
// ohc_regex(/(\|\s*(?:publication|)-?date\s*=\s*)(?:on |)@Day\s*@Month\s*@YYYY([a-z]\s?|\s?)\w*[^|{}<>]*(?=[|}])/gi, "$1@Day @Month @YYYY$2");
                    var editSummaryMessage = message['undo-summary'];
// ohc_regex(/(\|\s*(?:publication|)-?date\s*=\s*)(?:on |)@Month\s*@Day,\s*@YYYY([a-z]\s?|\s?)\w*[^|{}<>]*(?=[|}])/gi, "$1@Month @Day, @YYYY$2");
                    var editSummary = editSummaryMessage.replace(/\$1/g, revId);
 
                    editSummary = editSummary.replace(/\$2/g, username);
//remove extraneous bracket //from Batty
                    if (customEditSummary !== null) {
ohc_regex(/{{(\s*[Cc]it(?:e|ation))([^}]+)(\s*\|\s*(?:archive-?|access-?|publication-?)?date\s*=\s*)([\w\s-]+)\](?=\s*[\|}<])/gi, '{{$1$2$3$4'); 
                        mobileUndo.setDisabled(true);
 
                        editSummary = editSummary + ' ' + customEditSummary + (i18n[i18n_lang]['editsummary-ad']);
//fix bda template redirect
                        //call the API
// regex(/\{\{bda\|([^}]+)\}\}/gi, '{{birth date and age|$1}}');
                        var api = new mw.Api({
// regex(/\{\{dda\|([^}]+)\}\}/gi, '{{death date and age|$1}}');
                            ajax: {
 
                                headers: {
//zap redundant {{date}}, {{accessdate}} {{retrieved}}, {{monthname}} and {{#dateformat}}
                                    'Api-User-Agent': 'mobileUndo/2.0.2(https://en.wikipedia.org/wiki/User:FR30799386/undo.js)'
// regex(/({{(?:end|start)[-–]date)\|df=y(?:es|)/gi, "$1"); //rem deprecated parameter - disabled: doesn't work here, so ejected to the formatting script
                                }
ohc_regex(/{{#formatdate:@YYYY-@MM-@DD(?:[^\}]*)}}/gi, "@Day @Month @YYYY");
                            }
regex(/{{#formatdate:([^}]+)}}/gi, "$1");
                        });
regex(/\{\{#dateformat:([^}\|]+)(?:\|dmy|\|mdy)?\}\}/gi, '$1');
                        //Feedback UI
// ohc_regex(/(date[ ]*=[ ]*)\{\{(?:Start|End) ?date(?:\|df=y(?:es|)|)\|@YYYY\|@MM\|@DD(?:\|df=y(?:es|)|)\}\}/gi, '$1@Month @DD, @YYYY');  //stripping start/end template notes inside "|date=" parameter (line 72)
                        mobileUndo.setLabel(i18n[i18n_lang]['mu-loading']);
ohc_regex(/{{#formatdate:@YYYY-@MM-@DD(?:\|(?:[dmy]{3}|iso)|)}}/gi, "@Day @Month @YYYY");
                        api.postWithToken('csrf', {
ohc_regex(/\{\{date\|@YYYY-@MM-@DD\}\}/gi, "@Day @Month @YYYY");
                            action: "edit",
ohc_regex(/\{\{date\|(@DD[\-\s]@Mon|@Mon[\-\s]@DD)\}\}/gi, "@Day @Month");
                            title: mw.config.get('wgRelevantPageName'),
regex(/\{\{date\|([^}\|]+)(?:\|l?(?:[dmy]{3}|iso|none|link))?\}\}/gi, '$1');
                            summary: editSummary,
ohc_regex(/[ ]*\{\{accessdate\|@YYYY-@MM-@DD[ ]*\}\}/gi, " Retrieved @YYYY-@MM-@DD");
                            undo: revId,
ohc_regex(/[ ]*\{\{retrieved[ ]*\|[ ]accessdate=([\-\w, ]*)\}\}/gi, " Retrieved $1");
                        }).done(function(result) {
// ohc_regex(/(date[ ]*=[ ]*|\w{2,}[ ]*)\{\{(?:start|end).date[^|}]*(?:\|df=y(?:es|)|)\|@YYYY(?:\|df=y(?:es|)|)\}\}/gi, '$1@YYYY');  //stripping start/end template (disabling to placate Pigsonthewing)
                            if (result.edit.code === 'abusefilter-warning' || result.edit.code === 'abusefilter-disallowed') {
// ohc_regex(/\{\{(?:Start|End) date(?:\|df=y(?:es|)|)\|@YYYY\|@MM\}\}/gi, '@Month @YYYY')  //stripping start/end template notes
                                mobileUndo.setLabel(i18n[i18n_lang]['mu-fail']);
// ohc_regex(/<!--(?:Use)? \{\{(?:Start|End) date\|@YYYY\|@MM\|@DD\}\} -->/gi, '');  //stripping start/end template notes
                                OO.ui.alert($('<p>').html(result.edit.warning), {
ohc_regex(/(\{\{MONTHNAME\|@MM\}\})/gi, "@Month")
                                    title: result.edit.info
 
                                }).done(function() {});
//expand one and two-digit years in ranges
                                return;
regex(/(\()@Month @YYYY[-–]@Month @YYNN(\))/gi, '$1@Month1 @YYYY1 – @Month2 @YYYY2$2');
                            } else if (typeof result.edit.nochange !== 'undefined') {
regex(/(\(1[789])(\d)(1)[-–]([2-9]\))/gi, '$1$2$3–$2$4');
                                mobileUndo.setLabel(i18n[i18n_lang]['mu-fail']);
regex(/(\(1[789])(\d)(2)[-–]([3-9]\))/gi, '$1$2$3–$2$4');
                                OO.ui.alert($('<p>').html(globalmessages['Undo-nochange'])).done(function() {});
regex(/(\(1[789])(\d)(3)[-–]([4-9]\))/gi, '$1$2$3–$2$4');
                                return;
regex(/(\(1[789])(\d)(4)[-–]([5-9]\))/gi, '$1$2$3–$2$4');
                            }
regex(/(\(1[789])(\d)(5)[-–]([6-9]\))/gi, '$1$2$3–$2$4');
                            console.log(result);
regex(/(\(1[789])(\d)(6)[-–]([7-9]\))/gi, '$1$2$3–$2$4');
                            mobileUndo.setLabel(i18n[i18n_lang]['mu-success']);
regex(/(\(1[789])(\d)(7)[-–]([8-9]\))/gi, '$1$2$3–$2$4');
                            mw.notify(i18n[i18n_lang]['mu-undo-successful']);
regex(/(\(1[789])(\d)(8)[-–](9\))/gi, '$1$2$3–$2$4');
                            setTimeout(function() {
regex(/(\(20)([01])(1)[-–]([2-9]\))/gi, '$1$2$3–$2$4');
                                location.href = mw.util.getUrl('Special:MobileDiff/' + result.edit.newrevid);
regex(/(\(20)([01])(2)[-–]([3-9]\))/gi, '$1$2$3–$2$4');
                            }, 1500);
regex(/(\(20)([01])(3)[-–]([4-9]\))/gi, '$1$2$3–$2$4');
                        }).fail(function(code, jqxhr) {
regex(/(\(20)([01])(4)[-–]([5-9]\))/gi, '$1$2$3–$2$4');
                            mobileUndo.setLabel(i18n[i18n_lang]['mu-fail']);
regex(/(\(20)([01])(5)[-–]([6-9]\))/gi, '$1$2$3–$2$4');
                            var details;
regex(/(\(20)([01])(6)[-–]([7-9]\))/gi, '$1$2$3–$2$4');
                            if (code === 'http' && jqxhr.textStatus === 'error') {
regex(/(\(20)([01])(7)[-–]([8-9]\))/gi, '$1$2$3–$2$4');
                                details = i18n[i18n_lang]['mu-http-error'] + jqxhr.xhr.status;
regex(/(\(20)([01])(8)[-–](9\))/gi, '$1$2$3–$2$4');
                            } else if (code === 'http') {
 
                                details = i18n[i18n_lang]['mu-http-error'] + jqxhr.textStatus;
ohc_regex(/(\W)@DD@th?, @DD@th?((?:[ ]|&nbsp;)(?:and|&|to|or)(?:[ ]|&nbsp;))@DD@th?(?:\sof\s?)?([ ]|&nbsp;)@Month(?=\W)/gi, '$1@Day1, @Day2$2@Day3$3@LMonth');
                            } else if (code === 'ok-but-empty') {
ohc_regex(/(\W)@DD@th?((?:[ ]|&nbsp;)(?:and|&|to|or)(?:[ ]|&nbsp;))@DD@th?(?:\sof\s?|)([ ]|&nbsp;)@Month(?=\W)/gi, '$1@Day1$2@Day2$3@LMonth');
                                details = i18n[i18n_lang]['mu-empty response-from-server'];
ohc_regex(/(\W)the @DD@th(?:\sof|)\s@Month,? @YYYY(?=\W\D)/g, '$1@Day @LMonth @YYYY');
                            } else {
ohc_regex(/(\W)the @DD@th(?:\sof|)\s@Month(?=\W\D)/g, '$1@Day @LMonth');
                                details = jqxhr.error.info;
ohc_regex(/(\W)@Day@th?(?:\sof|)([ _]|&nbsp;|{{(?:break|nbsp)}})@Month(?=[^|\]\w])/gi, '$1@Day$2@LMonth');
                            }
ohc_regex(/(\W)@Month\s(?:the\s)?@DD@th?,(?:\sthe\s)?(?: |&nbsp;)@DD@th?(\s(?:and|&|to|or)(?:[ _]|&nbsp;))(?:the\s)?@DD@th?(?=[^|\]\w])/gi, '$1@LMonth @Day1, @Day2$2@Day3');
                            OO.ui.alert($('<p>').html(details)).done(function() {});
ohc_regex(/(\W)(@month)\s(@day)((?:,\s@day){0,6}),?(\/|\s?[-–]\s?|\s(?:and|&|to|or)\s+?)@Day@th?(?:,?(?:[ _]|&nbsp;)|\sof\s)?(\d{3,4}\W\D)/gi, '$1$2 $3$4$5@Day, $6');
                        });
ohc_regex(/(\W)(@month)\s(@day)((?:,\s@day){0,6}),?(\/|\s?[-–]\s?|\s(?:and|&|to|or)\s+?)@Day@th?(?=\W\D)/gi, '$1$2 $3$4$5@Day');
                    }
ohc_regex(/(\W)@Month([ _]|&nbsp;|{{(?:break|nbsp)}})(?:the\s)?@DD@th?,? @Year/gi, '$1@LMonth$2@Day, @Year');
                });
ohc_regex(/(\W)@Month @Day(?:\sof|,|)([ _]|&nbsp;|{{(?:break|nbsp)}})@Year(?=[^|\]\w])/gi, '$1@Month @Day,$2@Year');
            });
 
        });
// consolidating/amalgamating date fields
    }
ohc_regex(/(\|[ ]*date[ ]*=[ ]*@day)\s*\|[ ]*month=[ ]*(@month)\s*\|[ ]*year=[ ]*(@yyyy[ ]*)(?=[|}\s])/gi, "$1 $2 $3");
});
ohc_regex(/(\|[ ]*date[ ]*=[ ]*@day.?@month)\s*\|[ ]*year=[ ]*(@yyyy[ ]*)(?=[|}\s])/gi, "$1 $2");
//End of code
ohc_regex(/(\|[ ]*date[ ]*=[ ]*@month.?@day)\s*\|[ ]*year=[ ]*(@yyyy[ ]*)(?=[|}\s])/gi, "$1 $2");
//</nowiki>
 
window.wgRelevantUser = function() {
// eliminating dates and time placed in author parameter
    var user;
//removing artefacts from Indian news sites (TNN আগষ্ট 30, 2012, 05.46AM)
    if ($('.mw-mf-user-link').text() !== '') {
ohc_regex(/(\|\s*author\s*=\s*(?:[A-Z]{2,3}\b))(?:[^|}]*)\d{4}, [\d\.:]{4,5}(&nbsp;|)[AP]M IST(?=[ ]*\|)/g, '$1$2');
        user = $('.mw-mf-user-link').text();
// ohc_regex(/(\|\s*author=(?:[^\[\]|{}]*))(TNN|PTI) @day @month @yyyy, [\d\.:]{4,5}(&nbsp;|)[AP]M IST(?=[ ]*\|)/g, '$1$2');
    } else {
 
        user = $('#mw-mf-userinfo .post-content div:nth-child(2)').text();
ohc_regex(/(\|\s*author\s*=\s*)@month @day,? @yyyy\s?(?:,? [0-2]?\d[\.:][0-5]\d(?:\s*|&nbsp;)(?:[apAP][mM]\s*|)(?:GMT\s*|UTC\s*|[A-Z]{1,2}[DS]T\s*|)|)(?=\|)/g, "$1");
    }
ohc_regex(/(\|\s*author\s*=\s*)@day @month,? @yyyy\s?(?:,? [0-2]?\d[\.:][0-5]\d(?:\s*|&nbsp;)(?:[apAP][mM]\s*|)(?:GMT\s*|UTC\s*|[A-Z]{1,2}[DS]T\s*|)|)(?=\|)/g, "$1");
    return user;
ohc_regex(/(\|\s*author\s*=\s*\w[\w\s]+)@month @day,? @yyyy(?:[^\[\]|{}]*)(?=[|}])/g, "$1");
    };
ohc_regex(/(\|\s*author\s*=\s*\w[\w\s]+)@day @month,? @yyyy(?:[^\[\]|{}]*)(?=[|}])/g, "$1");
var href = ($('#mw-mf-diffarea > div.mw-mf-diff-info > h3 > a').attr('href')) || '';
ohc_regex(/(\|\s*author\s*=\s*(?:\w[\w\s]+)?)@dd-@mm-@yyyy/gi, "$1");
window.wgRevId = href.split('&oldid=')[1];
ohc_regex(/(\|\s*author\s*=\s*(?:\w[\w\s]+)?)@YYYY-@MM-@DD ?/gi, "$1");
if( $('#mw-mf-diffarea > ul > li.revision-history-next').length ) {
regex(/(\|\s*(?:date|archive-?date|access-?date|author)\s*=\s*(?:\w[\w\s]+)?)[0-2]\d:[0-5]\d(?:[ ]|&nbsp;)?(?:[ap]m|[ap]\.m\.|)(?: ?(?:[A-Z]{1,2}T|UTC)[\.,]?|)/gi, "$1");
$('#mw-mf-diffarea > div.mw-mf-diff-info > h3').append(
// ohc_regex(/(\|\s*author\s*=\s*(?:\w[\w\s]+)?)\s*[0-2]\d[\.:][0-5]\d(?:[\.:][0-5]\d|)/gi, "$1"); //let's see later if we need this
$('<a>').attr('id','mobileRestore').attr('href','javascript:void(0)').append(
 
$('<b>').text('(পুনরুদ্ধার)')
// eliminating mm-dd-yyyy dates
)
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@MM[-–\/\.=\s](1[3-9]|2\d|3[01])[-–\/\.=\s]@YYYY/gi, "$1@Month $2, @YYYY");
);
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Mon[-–\/\.=\s](1[3-9]|2\d|3[01])[-–\/\.=\s]@YYYY/gi, "$1@Month $2, @YYYY");
}
ohc_regex(/[ ](?:Accessed|Retrieved)(?:(?: online|) on|:?)[ ]@MM[-–\/\.=\s](1[3-9]|2\d|3[01])[-–\/\.=\s]@YYYY(?=\D)/gi, " Retrieved @Month $1, @YYYY");
$('#mobileRestore').click(function(e){
// ohc_regex(/[ ](?:Accessed|Retrieved)(?:(?: online|) on|:?)[ ]@YYYY,? @Month @DD(?=\D)/gi, " Retrieved @Day @Month @YYYY");
e.preventDefault();
 
$('#mobileRestore b').text('(লোড হচ্ছে....)');
ohc_regex(/([ =|])@Mon[-–](1[3-9]|2\d|3[01])[-–]@YYYY(?=[^-–\d/])/gi, "$1@Mon $2, @YYYY");
$('#mobileRestore').css('pointer-events','none');
ohc_regex(/([ =|])@Mon\/(1[3-9]|2\d|3[01])\/@YYYY(?=[^-–\d/])/gi, "$1@Mon $2, @YYYY");
var customEditSummary = prompt('পুনরুদ্ধারের কারণ (ঐচ্ছিক)');
ohc_regex(/([ =|])@Mon\.(1[3-9]|2\d|3[01])\.@YYYY(?=[^-–\d/])/gi, "$1@Mon $2, @YYYY");
if(customEditSummary === null) {
ohc_regex(/([ =|])@Mon (1[3-9]|2\d|3[01]) @YYYY(?=[^-–\d/])/gi, "$1@Mon $2, @YYYY");
$('#mobileRestore b').text('(পুনরুদ্ধার)');
ohc_regex(/([ =|])@MM[-–](1[3-9]|2\d|3[01])[-–]@YYYY(?=[^-–\d/])/gi, "$1@Mon $2, @YYYY");
$('#mobileRestore').css('pointer-events','auto');
ohc_regex(/([ =|])@MM\/(1[3-9]|2\d|3[01])\/@YYYY(?=[^-–\d/])/gi, "$1@Mon $2, @YYYY");
return;
ohc_regex(/([ =|])@MM\.(1[3-9]|2\d|3[01])\.@YYYY(?=[^-–\d/])/gi, "$1@Mon $2, @YYYY");
}
ohc_regex(/([ =|])@MM (1[3-9]|2\d|3[01]) @YYYY(?=[^-–\d/])/gi, "$1@Mon $2, @YYYY");
var username =wgRelevantUser();
 
var editSummary = '[[Special:Contributions/'+username+'|'+username+']] ([[User talk:'+username+'|আলাপ]])-এর করা ' +wgRevId+ 'নং সংস্করণ পুনরুদ্ধার করা হয়েছে';
// eliminating dd-mm-yyyy dates (assumed default)
editSummary = editSummary + customEditSummary + ' (পুনরুদ্ধারায়ন)';
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@DD[-–\/\.=\s]@MM[-–\/\.=\s]@YYYY/gi, "$1@Day @Month @YYYY");
$.when(mw.loader.load('mediawiki.api')).then(function(){
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@DD[-–\/\.=\s]@Mon[-–\/\.=\s]@YYYY/gi, "$1@Day @Month @YYYY");
var api = new mw.Api();
ohc_regex(/[ ](?:Accessed|Retrieved)(?:(?: online|) on|:?)[ ]@DD[-–\/\.=\s]@MM[-–\/\.=\s]@YYYY(?=\D)/gi, " Retrieved @Day @Month @YYYY");
api.get({
ohc_regex(/[ ](?:Accessed|Retrieved)(?:(?: online|) on|:?)[ ]@YYYY,? @Month @DD(?=\D)/gi, " Retrieved @Day @Month @YYYY");
'action':'query',
ohc_regex(/([ =|])@DD[-–]@Mon[-–]@YYYY(?=[^-–\d/])/gi, "$1@Day @Month @YYYY");
'prop':'revisions',
ohc_regex(/([ =|])@DD\/@Mon\/@YYYY(?=[^-–\d/])/gi, "$1@Day @Month @YYYY");
'titles':mw.config.get('wgRelevantPageName'),
ohc_regex(/([ =|])@DD\.@Mon\.@YYYY(?=[^-–\d/])/gi, "$1@Day @Month @YYYY");
'rvprop':'ids'
ohc_regex(/([ =|])@DD @Mon @YYYY(?=[^-–\d/])/gi, "$1@Day @Month @YYYY");
}).done(function(result){
ohc_regex(/([ =|])@DD[-–]@MM[-–]@YYYY(?=[^-–\d/])/gi, "$1@Day @Month @YYYY");
if(result.query.pages) {
ohc_regex(/([ =|])@DD\/@MM\/@YYYY(?=[^-–\d/])/gi, "$1@Day @Month @YYYY");
var StartRevId = result.query.pages[mw.config.get('wgRelevantArticleId')].revisions[0].revid;
ohc_regex(/([ =|])@DD\.@MM\.@YYYY(?=[^-–\d/])/gi, "$1@Day @Month @YYYY");
console.log(StartRevId);
ohc_regex(/([ =|])@DD @MM @YYYY(?=[^-–\d/])/gi, "$1@Day @Month @YYYY");
api.postWithToken('csrf', {
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@DD[-–\/\.=\s]@Month[-–\/\.=\s]@YYNN(?=\s*[|}\n])/gi, '$1@Day @Month @YYYY');
                    action: "edit",
 
                    title: mw.config.get('wgRelevantPageName'),
//convert yyyy-dd-mm to yyyy-mm-dd
                    summary: editSummary,
ohc_regex(/{{(\s*[Cc]it(?:e|ation))([^}]+)(\s*\|\s*(?:publication|archive|access|air|)-?date\s*=\s*(?:1[0-9]|20)\d{2})[-/\.=\s](1[3-9]|2\d|3[01])[-/\.=\s](0?\d|1[0-2])(\s*[\|}<])/gi, '{{$1$2$3-$5-$4$6'); //from Batty
                    undo:StartRevId,
 
undoafter:wgRevId,
// eliminating other errant formats
                }).done(function(result) {
ohc_regex(/(\|(?:[\w ]*)date\s*=\s*)([0-2]?\d|30|31) @Month \2,? @YYYY(?=\s*[|}])/gi, "$1$2 @Month @YYYY"); //repeated digits
                    if (typeof result.edit.nochange !== 'undefined') {
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Day ?@Month ?200([01]\d)[^\s|}]?(?=\s*[|}])/gi, "$1@Day @Month 20$2");
                    $('#mobileRestore b').text('(Failed)');
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month ?@Day,? ?200([01]\d)[^\s|}]?(?=\s*[|}])/gi, "$1@Month @Day, 20$2");
alert( 'No change occured');
 
                        return;
ohc_regex(/([ ]\()@DD-@MM-@YYYY(\)\W)/gi, '$1@Day @Month @YYYY$2');
                    }
ohc_regex(/([ ]\()@DD-@Month-@YYYY(\)\W)/gi, '$1@Day @Month @YYYY$2');
console.log(result);
ohc_regex(/(\|(?:[\w ]*)date\s*=\s*)@Month, @DD, @YYYY(?=\s*[|}])/gi, "$1@Day @Month @YYYY");
$('#mobileRestore b').text('(সফলভাবে হয়েছে)')
ohc_regex(/(\|(?:[\w ]*)date\s*=\s*)@DD[\.,] @Month,? @YYYY(?=\s*[|}])/gi, "$1@Day @Month @YYYY");
                    mw.notify('সংস্করণ পুনরুদ্ধার সফল হয়েছে.... পুনঃলোড করা হচ্ছে');
ohc_regex(/(\|(?:[\w ]*)date\s*=\s*)@YYYY,? @Month @DD(?=\s*[|}])/gi, "$1@Day @Month @YYYY");
setTimeout(function() {
ohc_regex(/(\|(?:[\w ]*)date\s*=\s*)@YYYY,? @DD @Month(?=\s*[|}])/gi, "$1@Day @Month @YYYY");
                      location.href = mw.util.getUrl('Special:MobileDiff/' + result.edit.newrevid);
ohc_regex(/[ ]\(@YYYY,? @Month @DD\)/gi, " (@Day @Month @YYYY)");
                    }, 1500);
ohc_regex(/[ ]\(@YYYY @MM @DD\)/gi, " (@Day @Month @YYYY)");
                }).fail(function(code, jqxhr) {
ohc_regex(/[ ]\(@YYYY, @DD @Month\)/gi, " (@Day @Month @YYYY)");
                $('#mobileRestore b').text('(পুনরুদ্ধার কার্য বাতিল করা হয়েছে)');
ohc_regex(/(\|(?:[\w ]*)date\s*=\s*)@YYYY,? @Month(?=\s*[|}])/gi, "$1@Month @YYYY");
                    var details;
ohc_regex(/[ ]\(@YYYY, @Month\)/gi, " (@Month @YYYY)");
                    if (code === 'http' && jqxhr.textStatus === 'error') {
ohc_regex(/[ ]\(@Mon@YYYY\)/gi, " (@Mon @YYYY)");
                        details = 'HTTP error: ' + jqxhr.xhr.status;
 
                    } else if (code === 'http') {
//CS1 errors ISO-like dates (too few or too many digits)
                        details = 'HTTP error: ' + jqxhr.textStatus;
ohc_regex(/(date\s*=\s*)(?:\[\[)?@YYYY(?:\]\][–—‐]\[\[|[–—‐])@MM[\-–—‐]@DD(?:\]\])?(?=\s*[|}])/gi, "$1@YYYY-@ZM-@ZD"); //ndashes and emdashes
                    } else if (code === 'ok-but-empty') {
ohc_regex(/(\|\s*access-?date\s*=)\s*@YYYY-0[–—]@DD(?=\s*[|}])/gi, ""); //rem nonsense access date
                        details = 'An empty response was given the server';
ohc_regex(/(\|(?:[\w ]*)date\s*=\s*)@YYYY[-–—]@MM[-–—]@DD(?=\s*[|}])/gi, "$1@YYYY-@ZM-@ZD"); //ndashes and emdashes
                    } else {
// ohc_regex(/(\|(?:[\w ]*)date\s*=\s*)@YYYY[\-–—‐]@MM(?=\s*[|}])/gi, "$1@Month @YYYY"); //transform "yyyy-mm" to "month year"
                        details = jqxhr.error.info;
ohc_regex(/(<ref[^>]*>[^<]+?)([\s\(])@YYYY[–—]@MM[–—]@DD([^-\w\/%,<][^<]*?<\/ref>)/gi, "$1$2@Day @Month @YYYY$3");
                    }
ohc_regex(/(<ref[^>]*>[^<]+?)([\s\(])@YYYY[-]@MM[-]([1-9])([^-\w\/%,<][^<]*?<\/ref>)/gi, "$1$2$3 @Month @YYYY$4");
                    alert( details );
                });
} else {
alert('Failed to retrieve page details');
}
});
});
});


// spaces and commas between month and year
//history
ohc_regex(/@Month(?:,?|\s+of|)(\s|&nbsp;)@YYYY(?=\D)/gi, "@LMonth$1@YYYY");
mw.loader.load('//bn.bharatpedia.org/index.php?title=ব্যবহারকারী:রবি/মোবাইল পার্থক্য ইতিহাস.js&action=raw&ctype=text/javascript');


// fix month names (capitalize, remove dots)
//my common.js
ohc_regex(/(\W)@DD\s@FullMonth(\s+|\s*,)/gi, "$1@Day @FullMonth$2");
$.when(mw.loader.using(['mediawiki.util'], $.ready)).done( function() {
ohc_regex(/(\W)@DD\s@Mon(\s+|\s*,)/gi, "$1@Day @Mon$2");
mw.util.addPortletLink("p-tb", mw.config.get('wgArticlePath').replace('$1', "ব্যবহারকারী:রবি/common.js"), "common.js", "tb-awbscript", "Personal common.js");
ohc_regex(/(\W)@FullMonth\s@DD(\s+|\s*,)/gi, "$1@FullMonth @Day$2");
});
ohc_regex(/(\W)@Mon\s@DD(\s+|\s*,)/gi, "$1@Mon @Day$2");
regex(/(\d(?:st|nd|rd|th) )C(entur(?:ies|y))(?=[ ]*(=|BC|AD|CE))/g, '$1c$2');
// regex(/(\d(?:st|nd|rd|th) )C(entur(?:ies|y))(?![ \-][A-Z]\w*|''|")/g, '$1c$2');
 
//spaces and commas - in date formats
ohc_regex(/(\D\W\[?\[?@dd)[ ]+(@month)(\]\])?[ ]*,[ ]*(\[?\[?@yyyy(\sAD|\sBC|\sCE|\sBCE|)\]?\]?\W\D)/gi, "$1 $2$3 $4");
ohc_regex(/(\D\W\[?\[?)(@month)[ ]+(@dd)(\]?\]?)(?:[ ]*,[ ]*)(\[?\[?@yyyy(\sAD|\sBC|\sCE|\sBCE|)\]?\]?\W\D)/gi, "$1$2 $3$4, $5");
ohc_regex(/(\D\W\[?\[?)(@month)[ ]+(@dd)(\]?\]?)[ ]+(\[?\[?@yyyy(\sAD|\sBC|\sCE|\sBCE|)\]?\]?\W\D)/gi, "$1$2 $3$4, $5");
 
ohc_regex(/(@month)(?:, | of )(@yyyy\w)/gi, "$1 $2"); //repeat after delinking
 
// spaces and commas - md-md and dm-dm date ranges
ohc_regex(/(\D\W)@Month\s@DD(&nbsp;|\s)(?:[-–—]|&[mn]dash;)(?:&nbsp;|\s)?@Month\s@DD(?=\W\D)/gi, "$1@LMonth1 @Day1$2– @LMonth2 @Day2");
ohc_regex(/(\D\W)@Month\s@DD(?:[-–—]|&[mn]dash;)(?:&nbsp;|\s)?@Month\s@DD(?=\W\D)/gi, "$1@LMonth1 @Day1 – @LMonth2 @Day2");
ohc_regex(/(\D\W)@DD\s@Month(&nbsp;|\s)(?:[-–—]|&[mn]dash;)(?:&nbsp;|\s)?@DD\s@Month(?=\W\D)/gi, "$1@Day1 @LMonth1$2– @Day2 @LMonth2");
ohc_regex(/(\D\W)@DD\s@Month(?:[-–—]|&[mn]dash;)(?:&nbsp;|\s)?@DD\s@Month(?=\W\D)/gi, "$1@Day1 @LMonth1 – @Day2 @LMonth2");
 
// spaces and commas - d-dm and md-d date ranges
ohc_regex(/(\D\W)@Month(\s|&nbsp;)@DD@th?(?:(?:\s*|&nbsp;|)[-–](?:\s*|&nbsp;|))@DD@th?(?=\W\D)/gi, "$1@LMonth1$2@Day1–@Day2");
ohc_regex(/(\D\W)@DD@th?(?:(?:\s*|&nbsp;|)[-–](?:\s*|&nbsp;|))@DD@th?(\s|&nbsp;)@Month(?=\W\D)/gi, "$1@Day1–@Day2$2@LMonth1");
 
// spaces and commas between month and year (again)
ohc_regex(/@Month(?:,\s+|\s+of\s+)@YYYY(\w)/gi, "@LMonth @YYYY$1");
}
 
/** ------------------------------------------------------------------------- */
/// ISO to long format
 
function ohc_ISO_to_dmy_in_citations()
{
//ISO dates within single citation
ohc_regex(/(\|\s*(?:publication|archive|access|air|designation\d?_|)-?date\s*=\s*)@YYYY[-–]@MM[-–]@DD(?=\W\D)/gi, "$1@Day @Month @YYYY");
}
 
function ohc_ISO_to_mdy_in_citations()
{
//ISO dates within single citation
ohc_regex(/(\|\s*(?:publication|archive|access|air|designation\d?_|)-?date\s*=\s*)@YYYY[-–]@MM[-–]@DD(?=\W\D)/gi,  "$1@Month @Day, @YYYY");
}
 
function ohc_ISO_to_dmy_in_references()
{
//multiple calls for multiple dates within single citation
ohc_regex(/(<ref[^>]*>[^<]+?)([\s\(])@YYYY[-–]@MM[-–]@DD([^-\w\/%,<][^<]*?<\/ref>)/gi, "$1$2@Day @Month @YYYY$3");
ohc_regex(/(<ref[^>]*>[^<]+?)([\s\(])@YYYY[-–]@MM[-–]@DD(<\/ref>)/gi, "$1$2@Day @Month @YYYY$3");
}
 
function ohc_ISO_to_mdy_in_references()
{
//multiple calls for multiple dates within single citation
ohc_regex(/(<ref[^>]*>[^<]+?)([\s\(])@YYYY[-–]@MM[-–]@DD([^-\w\/%,<][^<]*?<\/ref>)/gi, "$1$2@Month @Day, @YYYY$3");
ohc_regex(/(<ref[^>]*>[^<]+?)([\s\(])@YYYY[-–]@MM[-–]@DD(<\/ref>)/gi, "$1$2@Month @Day, @YYYY$3");
}
 
// currently unused
function ohc_ISO_to_dmy_anywhere()
{
//multiple calls for multiple dates within single citation
ohc_regex(/([^-\w/])@YYYY[-–]@MM[-–]@DD([^-\w/])/gi, '$1@Day @Month @YYYY$2');
ohc_regex(/([^-\w/])@YYYY[-–]@MM[-–]@DD([^-\w/])/gi, '$1@Day @Month @YYYY$2');
ohc_regex(/([^-\w/])@YYYY[-–]@MM[-–]@DD([^-\w/])/gi, '$1@Day @Month @YYYY$2');
}
 
// currently unused
function ohc_ISO_to_mdy_anywhere()
{
//multiple calls for multiple dates within single citation
ohc_regex(/([^-\w/])@YYYY[-–]@MM[-–]@DD([^-\w/])/gi, '$1@Month @Day, @YYYY$2');
ohc_regex(/([^-\w/])@YYYY[-–]@MM[-–]@DD([^-\w/])/gi, '$1@Month @Day, @YYYY$2');
ohc_regex(/([^-\w/])@YYYY[-–]@MM[-–]@DD([^-\w/])/gi, '$1@Month @Day, @YYYY$2');
}
 
function ohc_delink_ISO_to_dmy()
{
ohc_ISO_to_dmy_in_citations();
ohc_ISO_to_dmy_in_references();
regex(/([^\w\/\-%,])@YYYY-@MM-@DD(<\s?\/ref.*?>)/g, '$1@Day @Month @Year$2');
ohc_regex(/(\|\|[ ]*)@YYYY[-–]@MM[-–]@DD([ ]*\|\|)/gi, '$1{{dts|format=dmy|@YYYY|@MM|@DD}}$2');  //dts template for sortable tables
ohc_regex(/(\{\{dts\|format=)mdy\|/gi, '$1dmy|');  //flip dts template formats
}
 
function ohc_delink_ISO_to_mdy()
{
ohc_ISO_to_mdy_in_citations();
ohc_ISO_to_mdy_in_references();
regex(/([^\w\/\-%,])@YYYY-@MM-@DD(<\s?\/ref.*?>)/g, '$1@Month @Day, @Year$2');
ohc_regex(/(\|\|[ ]*)@YYYY[-–]@MM[-–]@DD([ ]*\|\|)/gi, '$1{{dts|@YYYY|@MM|@DD}}$2');  //dts template for sortable tables (mdy is default)
ohc_regex(/(\{\{dts\|)format=(?:mdy|dmy|) ?\|/gi, '$1');  //flip dts template formats
}
 
function ohc_delink_year_in_X()
{
// ohc_regex(/\{\{(?:avyear|by|baseball\syear|fy|ly|mlby|mlb\syear|scy|sdy)\|(@year)\}\}/gi, "$1"); //disabled 3/5/21 discussion at https://en.wikipedia.org/w/index.php?title=Wikipedia_talk:WikiProject_Baseball&oldid=1021203365#Links_to_baseball_year_articles_in_infobox?
// ohc_regex(/\{\{(?:avyear|by|baseball\syear|fy|ly|mlby|mlb\syear|scy|sdy)\|@year\|(@year)\}\}/gi, "$1");
ohc_regex(/\[\[@yyyy\sin\s[^|\]]+\|((?:(?:@day |)@month |)@yyyy)\]\]/gi, '$1');
regex(/\[\[(?:\d{4}[-–]\d{2} in English football)\|((?:(?:@Day |)@Month |)@YYYY)\]\]/gi, '$1');
 
regex(/\[\[\d{4} Major League Baseball season\|(\d{4})(\sseason)?\]\]/gi, '$1$2');
}
 
 
// format parameter must be 'dmy' or 'mdy'
function ohc_fix_dts_template(format)
{
// dts - format=dmy in this case (per D12000)
// per {{dts}} doc, remove the obsolete link=off param
regex(/(\{\{dts[^}]*)(?:\|link=off)/gi, '$1');
ohc_regex(/(\{\{dts\s*\|\s*@year\s*\|\s*@month\s*\|\s*@day\s*\|\s*format=)(?:dmy|mdy)(\}\})/gi, '$1'+format+'$2');
ohc_regex(/(\{\{dts\s*\|\s*format=)(?:dmy|mdy)(\s*\|\s*@year\s*\|\s*@month\s*\|\s*@day\s*\}\})/gi, '$1'+format+'$2');
ohc_regex(/(\{\{dts\s*\|\s*@year\s*\|\s*@month\s*\|\s*@day\s*)(\}\})/gi, '$1|format='+format+'$2');
 
  // stripping – {{dts}} serves no purpose inside date parameters
ohc_regex(/(\|(?:[\w ]*)date\s*=\s*)\{\{dts\s*\|\s*format=(?:dmy|mdy)\s*\|\s*([|}]*)\}\}(?=\s*[|}])/gi, "$1$2");
ohc_regex(/(\|(?:[\w ]*)date\s*=\s*)\{\{dts\s*\|\s*([|}]*)(?:\|\s*format=(?:dmy|mdy)\s*|)\}\}(?=\s*[|}])/gi, "$1$2");
ohc_regex(/(\|(?:[\w ]*)date\s*=\s*)\{\{dts\s*\|\s*format=(?:dmy|mdy)\s*\|\s*@YYYY(\s*\|\s*|-)@MM(\s*\|\s*|-)@DD\s*\}\}(?=\s*[|}])/gi, "$1@YYYY-@MM-@DD ");
ohc_regex(/(\|(?:[\w ]*)date\s*=\s*)\{\{dts\s*\|\s*@YYYY(\s*\|\s*|-)@MM(\s*\|\s*|-)@DD\s*\|\s*format=(?:dmy|mdy)\s*\}\}(?=\s*[|}])/gi, "$1@YYYY-@MM-@DD ");
}
 
// format parameter must be 'dmy' or 'mdy'
function ohc_fix_gr_template(format)
{
// GR - date formatting parameter
// per {GR} doc, insert date formatting param
regex(/(\{\{GR\|\d\d?)(?!\|date)/gi, '$1|dateform=' + format);
}
 
function ohc_dates_to_dmy()
{
regex(/\|df=[mdy]{3}(?:-all|)(?=\s*[|}])/gi, '');
regex(/\|format=mdy/gi, '|format=dmy');
//change start and end templates; vgrelease new v=2 or mdy is default
regex(/(\{\{(?:start date|end date)[^|}]*\|)df=ye?s?\|([^}]*df=ye?s?)/gi, '$1$2');
regex(/(\{\{vgrelease new[^|}]*\|)(?:v=1\||)([A-Z]{2,3}\|)/g, '$1v=2|$2');
ohc_regex(/(\|\s*(?:begin|end|first|last)\s*=\s*)@YYYY[-–]@MM[-–]@DD(?=\W\D)/gi, "$1@Day @Month @YYYY"); //spotted at [[Template:Infobox recurring event]]
//change birth and death templates
regex(/(\{\{(?:(?:Birth|Death) date(?: and age|)|launch|release|start)[^}]*\|)m(f=ye?s?)/gi, '$1d$2'); // substitute df for mf
regex(/(\{\{(?:(?:Birth|Death) date(?: and age|)|launch|release|start|film ?date|Wayback)[\|\d]+)(\}\})/gi, '$1|df=y$2'); //insert df parameter
regex(/(\{\{(?:(?:Birth|Death) date(?: and age|)|launch|release|start|film ?date|Wayback)[\|\d]+\|)df=ye?s?\|([^}]*df=ye?s?)/gi, '$1$2'); //put date format parameter at the end
regex(/(\{\{(?:start date|end date)\|)df=ye?s?\|((?:1[789]|20)\d{2}\}\})/gi, '$1$2');  //date format parameter not needed – year only
 
//convert date ranges (md,d,d-dy to d,d,d-dmy; md,d,d-d to d,d,d-dm; md,d,d to d,d,dm)
ohc_regex(/(\D\W)@Month((?:\s@day?,?){1,6}),?(\/|\s?(?:[-–]|&ndash;)\s?|(?:[ _]|&nbsp;)(?:and|&|to|or)(?:[ _]|&nbsp;)+?)@Day,?\s(?:of\s)?(@yyyy\W\D)/gi, "$1$2$3@Day @LMonth $4");
ohc_regex(/(\D\W)@Month((?:\s@day?,?){1,6}),?(\/|\s?(?:[-–]|&ndash;)\s?|(?:[ _]|&nbsp;)(?:and|&|to|or)(?:[ _]|&nbsp;)+?)@Day(?=\W\D)/gi, "$1$2$3@Day @LMonth");
 
// ohc_regex(/(\D\W)@Month((?:\s@day?,?){1,6}) @Day(?=\W\D)/gi, "$1$2 @Day @LMonth"); //disabling as unlikely and ungrammatical constructions causing false positives
 
//'md, md,' to 'dm, dm,'
ohc_regex(/(\D\W)@Month @Day, @Month @Day(?=[,\.]\W\D)/gi, "$1@Day1 @LMonth1, @Day2 @LMonth2");
 
//convert simple mdy dates to dmy
ohc_regex(/(p(?:g?\.?|age) ?\d+|p(?:p\.?|ages) ?\d+[-–]\d+), @Month((?:\s@day?,?){1,6}) @Day(?=\W\D)/gi, "$1. $2 @Day @LMonth");
ohc_regex(/(\D\W)@Month\s@Day,?\s@Year(\s?(?:AD|BC|CE|BCE)\W\D)/gi, "$1@Day @LMonth @Year$2");
ohc_regex(/(\|\s*term_(?:end|start)\d\s*=\s*|\D\W)@Month\s@Day,?\s@YYYY(?=\W\D)/gi, "$1@Day @LMonth @Year");
ohc_regex(/(\|\s*term_(?:end|start)\d\s*=\s*|\D\W)@Month\s@Day(?=\W\D)/gi, "$1@Day @LMonth");
 
//Month+day_number " 7th মার্চ" -> "7 মার্চ"
ohc_regex(/(\D\W)@Day\s@Month\s@YYYY(?=\W\D)/gi, "$1@Day @LMonth @Year");
ohc_regex(/(\D\W)@Day\s@Month(?=\W\D)/gi, "$1@Day @LMonth");
ohc_regex(/(\D\W)@Month\s@Day,?\s@Year(?=\W\D)/gi, "$1@Day @LMonth @Year");
 
//dates with embedded nbsp
ohc_regex(/(\D\W)@Month([ _]|&nbsp;)(\d{1,2},(?: |&nbsp;)\d{1,2}(?:\s(?:and|&|to|or)(?:[ _]|&nbsp;))\d{1,2})(?=[^|\]\w])/gi, '$1$3$2@LMonth ');
ohc_regex(/(\D\W)@Month([ _]|&nbsp;|{{(?:break|nbsp)}})@Day,([ _]|&nbsp;|{{(?:break|nbsp)}})@YYYY(?=[^|\]\w])/gi, '$1@Day$2@Month$3@Year');
 
//remove comma
ohc_regex(/(\D\W)@Day\s@Month,\s?@Year(?=\W\D)/gi, "$1@Day @LMonth @Year");
 
// remove "the" from "on the dd month"
ohc_regex(/(on |by )the @Day\s@Month(?=[ ,\)\.])/gi, "$1@Day @LMonth");
 
//remove space from date range conversion
ohc_regex(/(\D ) @Day(\/|\s?(?:[-–]|&ndash;)\s?|(?:[ _]|&nbsp;)(?:and|&|to|or)(?:[ _]|&nbsp;)+?)/gi, "$1@Day$2");
}
 
function ohc_dates_to_mdy()
{
//change birth and death templates – mf=y is the default; vgrelease new v=2 or mdy is default
regex(/\|df=[mdy]{3}(?:-all|)(?=\s*[|}])/gi, '');
regex(/\|df=y(?:es|)(?=[|}\s])/gi, '');
regex(/(mf=y(?:es|)\|[^}]*\|)(?:mf=y(?:es|)\|)/gi, '$1');
regex(/(\{\{vgrelease new[^|}]*\|)(?:v=2\||)([A-Z]{2,3}\|)/g, '$1$2');
ohc_regex(/(\|\s*(?:begin|end|first|last)\s*=\s*)@YYYY[-–]@MM[-–]@DD(?=\W\D)/gi, "$1@Month @Day, @YYYY");
 
//convert date ranges (d,d,d-dmy to md,d,d-dy; d,d,d-dm to md,d,d-d; dm,d,d to md,d,d)
ohc_regex(/(\D\W)@Day((?:, @day){0,5})(\/|\s?(?:[-–]|&ndash;)\s?|\s(?:and|&|to|or)\s+?)@Day\s@Month,? @YYYY(?=\W\D)/gi, "$1@LMonth @Day1$2$3@Day2, @YYYY");
ohc_regex(/(\D\W)@Day((?:, @day){0,5})(\/|\s?(?:[-–]|&ndash;)\s?|\s(?:and|&|to|or)\s+?)@Day\s@Month(?=\W\D)/gi, "$1@LMonth @Day1$2$3@Day2");
// ohc_regex(/(\D\W)@Day((?:, @day){0,5})\s@Month,? @YYYY(?=\W\D)/gi, "$1@LMonth @Day1$2, @YYYY"); //disabling as unlikely and ungrammatical constructions causing false positives
// ohc_regex(/(\D\W)@Day((?:, @day){0,5})\s@Month(?=\W\D)/gi, "$1@LMonth @Day1$2"); //disabling as unlikely and ungrammatical constructions causing false positives
 
//'dm, dm,' to 'md, md,'
ohc_regex(/(\D\W)@Day @Month, @Day @Month(?=[,\.]?\W\D)/gi, "$1@LMonth1 @Day1, @LMonth2 @Day2");
 
//convert simple dmy dates to mdy
ohc_regex(/(p(?:g?\.?|age) ?\d+|p(?:p\.?|ages) ?\d+[-–]\d+), @Month((?:\s@day?,?){1,6}) @Day(?=\W\D)/gi, "$1. @LMonth $2 @Day");
ohc_regex(/(\D\W)@Day(\s|&nbsp;)@Month,?(\s|&nbsp;)@Year(?=\W\D)/gi, "$1@LMonth$2@Day,$3@Year");
ohc_regex(/(\|\s*term_(?:end|start)\d\s*=\s*|\D\W)@Day[ ]+@Month,?\s@YYYY(?=\W\D)/gi, "$1@LMonth @Day, @Year");
ohc_regex(/(\|\s*term_(?:end|start)\d\s*=\s*|\D\W)@Day[ ]+@Month(?=\W\D)/gi, "$1@LMonth @Day");
 
//Month+day_number "মার্চ 7th" -> "মার্চ 7"
ohc_regex(/(\D\W)@Month\s@Day@th?,?\s@YYYY(?=\W\D)/gi, "$1@LMonth @Day, @YYYY");
ohc_regex(/(\D\W)@Day@th?(\s|&nbsp;)@Month(\s|&nbsp;)@YYYY(?=\W\D)/gi, "$1@LMonth$2@Day,$3@YYYY");
ohc_regex(/(\D\W)@Month(\s|&nbsp;)@Day(?=\W\D)/gi, "$1@LMonth$2@Day");
ohc_regex(/(\D\W)@Day@th?(\s|&nbsp;)@Month([,\.])(?=\W\D)/gi, "$1@LMonth$2@Day$3");
 
//add comma where missing
ohc_regex(/(\D\W)@Month\s@Day,?\s@YYYY,?(?=\s\w)/gi, "$1@LMonth @Day, @YYYY,");
//rem superfluous comma where applicable
ohc_regex(/(\D[^\w\/])@Month\s@ZD,,(?=\W\D|\b)/gi, "$1@LMonth @Day,");
}
 
function ohc_fix_dmy_redundancies()
{
//month-range redundancies (repeating month names)
ohc_regex(/([\D]@dd)@th? @Month[ ]{1,2}((?:to|and|-|–)[ ]{1,2}@dd)@th? @Month/, "$1 $2 @LMonth", function(d1, d2) {
if (d1.m == d2.m) return true;
return false;
});
}
//not currently used
function ohc_fix_mdy_redundancies()
{
//month-range redundancies (repeating month names)
ohc_regex(/(@Month[ ]{1,2}@dd)@th? (to|and|-|–)[ ]{1,2}@Month[ ]{1,2}@DD@th?/, "$1 $2 @LDay", function(d1, d2) {
if (d1.m == d2.m) return true;
return false;
});
}
 
function ohc_expand_ref_dates()
{
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month @YYYY(?=\s*[|}])/gi, "$1@FullMonth @YYYY");
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Day @Month @YYYY(?=\s*[|}])/gi, "$1@Day @FullMonth @YYYY");
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month @Day, @YYYY(?=\s*[|}])/gi, "$1@FullMonth @Day, @YYYY");
 
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)((?:[01-2]?\d|30|31) |)@Month @YYYY ?(?:-|–|&ndash;) ?((?:[01-3]?\d|30|31) |)@Month @YYYY(?=\s*[|}])/gi, "$1$2 @FullMonth1 @YYYY1 – $3@FullMonth2 @YYYY2");
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month @Day(, (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month @Day, @YYYY(?=\s*[|}])/gi, "$1@FullMonth1 @Day1$2 – @FullMonth2 @Day2, @YYYY");
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Day @Month,?( (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Day @Month @YYYY(?=\s*[|}])/gi, "$1@Day1 @FullMonth1$2 – @Day2 @FullMonth2 @YYYY");
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month,?( (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month,? @YYYY(?=\s*[|}])/gi, "$1@FullMonth1$2 – @FullMonth2 @YYYY");
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)((?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month @YYYY(?=\s*[|}])/gi, "$1@$2 – @FullMonth @YYYY");
 
ohc_regex(/(<ref[^>]*>(?:[^<]+?[\s\(]|))((?:[01-2]?\d|30|31) |)@Month @YYYY ?(?:-|–|&ndash;) ?((?:[01-3]?\d|30|31) |)@Month @YYYY(?=(?:[^-\w\/%,<][^<]*?|)<\/ref>)/gi, "$1$2@FullMonth1 @YYYY1 – $3@FullMonth2 @YYYY2");
ohc_regex(/(<ref[^>]*>(?:[^<]+?[\s\(]|))@Month @Day(, (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month @Day, @YYYY(?=(?:[^-\w\/%,<][^<]*?|)<\/ref>)/gi, "$1@FullMonth1 @Day1$2 – @FullMonth2 @Day2, @YYYY");
ohc_regex(/(<ref[^>]*>(?:[^<]+?[\s\(]|))@Day @Month,?( (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Day @Month @YYYY(?=(?:[^-\w\/%,<][^<]*?|)<\/ref>)/gi, "$1@Day1 @FullMonth1$2 – @Day2 @FullMonth2 @YYYY");
ohc_regex(/(<ref[^>]*>(?:[^<]+?[\s\(]|))@Month,?( (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month,? @YYYY(?=(?:[^-\w\/%,<][^<]*?|)<\/ref>)/gi, "$1@FullMonth1$2 – @FullMonth2 @YYYY");
ohc_regex(/(<ref[^>]*>(?:[^<]+?[\s\(]|))((?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month @YYYY(?=(?:[^-\w\/%,<][^<]*?|)<\/ref>)/gi, "$1$2 – @FullMonth @YYYY");
}
 
function ohc_expand_all_dates()
{
ohc_regex(/([^-\w/])@Month @YYYY(?=[^-\w/])/gi, '$1@FullMonth @YYYY');
ohc_regex(/([^-\w/])@Day @Month @YYYY(?=[^-\w/])/gi, '$1@Day @FullMonth @YYYY');
ohc_regex(/([^-\w/])@Month @Day, @YYYY(?=[^-\w/])/gi, '$1@FullMonth @Day, @YYYY');
 
ohc_regex(/([^-\w/])((?:[01-2]?\d|30|31) |)@Month @YYYY ?(?:-|–|&ndash;) ?((?:[01-3]?\d|30|31) |)@Month @YYYY(?=[^-\w/])/gi, "$1$2@FullMonth1 @YYYY1 – $3@FullMonth2 @YYYY2");
ohc_regex(/([^-\w/])@Month @Day(, (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month @Day, @YYYY(?=[^-\w/])/gi, "$1@FullMonth1 @Day1$2 – @FullMonth2 @Day2, @YYYY");
ohc_regex(/([^-\w/])@Day @Month,?( (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Day @Month @YYYY(?=[^-\w/])/gi, "$1@Day1 @FullMonth1$2 – @Day2 @FullMonth2 @YYYY");
ohc_regex(/([^-\w/])@Month,?( (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month,? @YYYY(?=[^-\w/])/gi, "$1@FullMonth1$2 – @FullMonth2 @YYYY");
ohc_regex(/([^-\w/])((?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month @YYYY(?=[^-\w/])/gi, "$1$2 – @FullMonth @YYYY");
 
ohc_regex(/([ ]\(|\|\s*)@Day @Month @YYYY(?=\)\W|\s*[|\n])/gi, "$1@Day @FullMonth @YYYY");
ohc_regex(/([ ]\(|\|\s*)@Month @Day,? @YYYY(?=\)\W|\s*[|\n])/gi, "$1@FullMonth @Day, @YYYY");
ohc_regex(/([ ]\((?:c\. |))@Month @YYYY ?(?:-|–|&nbsp;) ?@Day @Month @YYYY(?=\)\W)/gi, "$1@FullMonth1 @YYYY1 – @Day @FullMonth2 @YYYY2");
ohc_regex(/([ ]\((?:c\. |))@Month @YYYY ?(?:-|–|&nbsp;) ?@Month @YYYY(?=\)\W)/gi, "$1@FullMonth1 @YYYY1 – @FullMonth2 @YYYY2");
ohc_regex(/([ ]\((?:c\. |))@YYYY ?(?:-|–|&nbsp;) ?@Month @YYYY(?=\)\W)/gi, "$1@YYYY1 – @FullMonth @YYYY2");
ohc_regex(/([ ]\((?:c\. |))@Month ?(?:-|–|&nbsp;) ?@Month @YYYY(?=\)\W)/gi, "$1@FullMonth1 – @FullMonth2 @YYYY");
ohc_regex(/([ ]\((?:c\. |))@Month @YYYY(?=\)\W)/gi, "$1@FullMonth @YYYY");
}
 
function ohc_abbrev_ref_dates()
{
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Day @Month @YYYY(?=\s*[|}])/gi, "$1@Day @Mon @YYYY");
ohc_regex(/(<ref[^>]*>(?:[^<]+?[\s\(]|))([12]?\d|30|31) (জানুয়ারি|ফেব্রুয়ারি|মার্চ|এপ্রিল|মে|জুন|জুলাই|আগষ্ট|অক্টোবর|Oct|নভেম্বর|ডিসেম্বর)(?:r?uary|ch|il|[ey]|ust|(?:t?em|o)ber)( (?:19\d|20[01])\d)(?=(?:[^-\w\/%,<][^<]*?|)<\/ref>)/gi, "$1$2 $3$4");
ohc_regex(/([ ]\()@Day @Month @YYYY([^-\w\/])/gi, "$1@Day @Mon @YYYY$2");
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month @Day, @YYYY(?=\s*[|}])/gi, "$1@Mon @Day, @YYYY");
ohc_regex(/(<ref[^>]*>(?:[^<]+?[\s\(]|))(জানুয়ারি|ফেব্রুয়ারি|মার্চ|এপ্রিল|মে|জুন|জুলাই|আগষ্ট|অক্টোবর|Oct|নভেম্বর|ডিসেম্বর)(?:r?uary|ch|il|[ey]|ust|(?:t?em|o)ber) ([12]?\d|30|31),( (?:19\d|20[01])\d)(?=(?:[^-\w\/%,<][^<]*?|)<\/ref>)/gi, "$1$2 $3,$4");
ohc_regex(/([^-\w\/])@Month @Day, @YYYY([^-\w\/])/gi, '$1@Mon @Day, @YYYY$2');
}
//not currently used
function ohc_abbrev_all_dates()
{
ohc_regex(/([^-\w/])@Day @Month @YYYY(?=[^-\w/])/gi, '$1@Day @Mon @YYYY');
ohc_regex(/([^-\w/])@Month @Day, @YYYY(?=[^-\w/])/gi, '$1@Mon @Day, @YYYY');
}
 
//not currently used
function ohc_dmy_publication_dates()
{
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month @Day,? @YYYY/gi, "$1@Day @Month @YYYY"); // conversion of dates in references outside of the protection loop (eg for quotations etc.)
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)(?:\[\[)?@YYYY(?:\]\][-–]\[\[|[-–])@MM[-–]@DD(?:\]\])?(?=\s*[|}])/gi, "$1@Day @Month @YYYY");
//replace ISO dates (within parentheses) only within refs
ohc_regex(/(<ref[^>]*>[^<]+?)([ ]\()@YYYY-@MM-@DD(\))(\W[^<]*?<\/ref>)/gi, "$1$2@Day @Month @YYYY$3$4");
}
 
function ohc_mdy_publication_dates()
{
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Day @Month @YYYY/gi, "$1@Month @Day, @YYYY"); // conversion of dates in references outside of the protection loop (eg for quotations etc.)
ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)(?:\[\[)?@YYYY(?:\]\][-–]\[\[|[-–])@MM[-–]@DD(?:\]\])?(?=\s*[|}])/gi, "$1@Month @Day, @YYYY");
//replace ISO dates (within parentheses) only within refs
ohc_regex(/(<ref[^>]*>[^<]+?)([ ]\()@YYYY-@MM-@DD(\))(\W[^<]*?<\/ref>)/gi, "$1$2@Month @Day, @YYYY$3$4");
}
 
function ohc_Bigendian_ref_dates() {
// Add a tag to the summary box
regex(/(\{\{use (?:mdy|dmy) dates)(?:\|cs1-dates=\w{1,2}|)(\|[^\}\|]+\}\})/gi, '$1|cs1-dates=y$2');
}
 
/** ------------------------------------------------------------------------ **/
/// EDIT SUMMARIES & USE DMY TEMPLATE
// this function modified 2019-03-27 from [[Special:Permalink/846525463]]
// format parameter must be 'dmy' or 'mdy'
function ohc_use_dates_template(format)
{
var txt = document.editform.wpTextbox1;
// current month-year
var currentDate = new Date();
var currmonth = currentDate.getMonth();
var curryear = currentDate.getFullYear();
var myMonths = ["জানুয়ারি", "ফেব্রুয়ারি", "মার্চ", "এপ্রিল", "মে", "জুন", "জুলাই", "আগষ্ট", "সেপ্টেম্বর", "অক্টোবর", "নভেম্বর", "ডিসেম্বর"];
var curryyyymm = myMonths[currmonth] + ' ' + curryear;
 
// step 1: normalize redirect template names to canonical template names 'Use dmy dates' or 'Use mdy dates' according to 'format' argument
// rename redirects 'dmy', 'mdy', 'usedmydates', 'usemdydates' ('usedmydates' and 'usemdydates' are not currently listed as redirects but might be encountered?)
regex(/\{\{ *(?:use(?:dmy|mdy)dates|dmy|mdy) *([\|\}])/gi, '{{Use ' + format + ' dates$1');
// rename redirects 'usedmy', 'usemdy', 'use dmy', 'use mdy' to canonical form
regex(/\{\{ *use *(?:dmy|mdy) *([\|\}])/gi, '{{Use ' + format + ' dates$1');
// strip leading / trailing whitespace from 'use xxx dates'
regex(/\{\{ *use (?:dmy|mdy) dates *([\|\}])/gi, '{{Use ' + format + ' dates$1');
 
// step 2: look for a canonical template name (the above might not have had anthing to work on) ; if found continue, write new template else
var rxpdd = new RegExp("{{Use " + format + " dates", "gi"); // here we search for canonical form {{use xxx dates}} that has current date
var dflagfound = txt.value.search(rxpdd);
if (dflagfound === -1) {
txt.value = '{{Use ' + format + ' dates|date=' + curryyyymm + '}}\r\n' + txt.value; // not found so insert new template at top of wikitext
return; // and done
}
 
// step 3: rewrite existing canonical templates; add or refresh |date= to current month year; preserve |cs1-dates= as is
regex(/(\{\{use (?:dmy|mdy) dates)\| *date *=[^\|]*\| *cs1\-dates *= *([^\|\}]*?) *\}\}/gi, '$1|date=' + curryyyymm + '|cs1-dates=$2}}'); // with |date= followed by |cs1-dates=
regex(/(\{\{use (?:dmy|mdy) dates)\| *cs1\-dates *= *([^\|\}]*?) *\| *date *=[^\}]*\}\}/gi, '$1|date=' + curryyyymm + '|cs1-dates=$2}}'); // with |cs1-dates= followed by |date=
regex(/(\{\{use (?:dmy|mdy) dates)\| *date *=[^\|\}]*\}\}/gi, '$1|date=' + curryyyymm + '}}'); // with |date=
regex(/(\{\{use (?:dmy|mdy) dates)\| *cs1\-dates *= *([^\|\}]*?) \}\}/gi, '$1|date=' + curryyyymm + '|cs1-dates=$2}}'); // with |cs1-dates
regex(/(\{\{use (?:dmy|mdy) dates)\}\}/gi, '$1|date=' + curryyyymm + '}}'); // no parameters so add |date=curryyyymm
regex(/(\{\{[\t_ ]*use[\t_ ]+(?:dmy|mdy)[\t_ ]+dates[^{}]*\}\})([\r\n\t ]*)(\{\{[\t ]*short description[^{}]*\}\})/gi, '$3$2$1'); // repositioning "short description" template at the top
}
 
 
 
/** ------------------------------------------------------------------------ **/
/// DATE PROTECTION
 
var linkmap = [];
 
function ohc_protect_dates()
{
// protects dates within links, quotes, etc
// the sensitive part is stored and replaced with a unique identifier,
// which is later replaced with the stored part.
var protect_function = function(s, begin, replace, end) {
linkmap.push(replace);
return begin + "⍌"+(linkmap.length-1)+"⍍" + end;
};
//\|x=
regex(/(<timeline>)([\s\S]*?)(<\/timeline>)/gi, protect_function);
regex(/(<!--)([^<\{\}]*?)(-->)/gi, protect_function);
regex(/(<math>)([\s\S]*?)(<\/math>)/gi, protect_function);
regex(/((?:{(?:Wikimedia |)Commons ?|C ?))(Cat(?:egory|))\|[^{}*](})/gi, protect_function);
regex(/(<ref)([^>]+)(>)/gi, protect_function);
regex(/((?:Category|Image|File):)([^|\]]*)([|\]])/gi, protect_function);
regex(/(\{(?:See ?also|Main))(\|[^}]*)(\})/gi, protect_function);
regex(/(\{\{(?:double ?|external ?|wide ?)image\s?\|)([^}]+)(\})/gi, protect_function);
regex(/(\{\{(?:harvnb|r|wikisource)\|)([^}]+)(\})/gi, protect_function);
regex(/(\{\{(?:Canadian federal by-election))([^}]+)(\}\})/gi, protect_function);
regex(/(\[(?:https?:|ftp:))([^\]]*)(\])/gi, protect_function);
regex(/(>[ ]*(?:https?:|ftp:))([^< >\]]*)([ ]*<)/gi, protect_function);
// regex(/(https?:|ftp:)([^\s\]]*)([\s\]])/gi, protect_function);
regex(/(<blockquote>)([\s\S]*?)(<\/blockquote>)/gi, protect_function);
regex(/(<noinclude>)([\s\S]*?)(<\/noinclude>)/gi, protect_function);
regex(/(<gallery)([\s\S]*?)(<\/gallery>)/gi, protect_function);
regex(/(<poem>)([\s\S]*?)(<\/poem>)/gi, protect_function);
regex(/(\{[^\{]{0,6}(?:quot[^|]{1,7}\s?|sic)\|)([^}]+)(\})/gi, protect_function);
regex(/((?:image\d?|image_skyline|image[ _]location\d?|image[ _]name|image[ _]file|img|map\d|pic)\s*=)([^|}]*)([|}])/gi, protect_function);
regex(/([\|\{]\s*(?:file(?:name\d?|)|image\d?|image location\d?|img|pic|Cover|(?:trans-?|)title|quote|chapter|journal|url|archiveurl|work|doi|club|at|volume|reporter)\s*=)([^|\}⍍]*)([|}])/gi, protect_function);
regex(/([\|\{]\s*(?:file(?:name\d?|)|image\d?|image location\d?|img|pic|Cover|(?:trans-?|)title|quote|chapter|journal|url|archiveurl|work|doi|club|at|volume|reporter)\s*=)([^|\}⍍]*)([|}])/gi, protect_function);
regex(/([\|\{]\s*(?:season)\s*=)(\s*\[\[[^\]]*\]\]\s*)([|}])/gi, protect_function);
regex(/([\|\{]\s*(?:[xy])\s*=)(\s*[^\|]+\s*)(\|)/gi, protect_function);
regex(/(\{\{navsource\|)([^}]+)(\})/gi, protect_function);
regex(/(\{\{(?:singlechart)\|)([^}]+)(\})/gi, protect_function);
regex(/(\{\{(?:defaultsort|graph):)([^}]+)(\})/gi, protect_function);
regex(/(["“])([^"”\n]*)(["”])/gi, protect_function);
regex(/(.)(\(\{\{by\|[12]\d{3}\}\}[-–]\{\{by\|)([12]\d{3}[ ]*\}\}\))/gi, protect_function);
regex(/(.)(\(\{\{by\|[12]\d{3}\}\}(?:[-–]present|))(\))/gi, protect_function);
regex(/(\[\[)(4AD)(\]\]|\|)/gi, protect_function);
 
//retraining redirects containing a date
regex(/(\[\[)(?:সেপ্টেম্বর 3 Society)(\]\]|\|)/gi, '$1Jiusan Society$2');
regex(/(\[\[)(?:জুন 4th incident)(\]\]|\|)/gi, '$1Tiananmen Square protests of 1989$2');
regex(/(\[\[)(?:5@th? অক্টোবর (?:\(Serbia\)|overthrow))(\]\]|\|)/gi, '$1Overthrow of Slobodan Milošević$2');
regex(/(\[\[)(?:অক্টোবর 5@th?(?: \(Serbia\)| overthrow|, 2000))(\]\]|\|)/gi, '$1Overthrow of Slobodan Milošević$2');
 
//protect alternate meanings of 'মে' and 'মার্চ' (note: not case insensitive)
// ohc_regex(/([^\w])(@day,?\s{0,3}মে)([^\w][^\d])/g, protect_function);  //disabled 26 মে – not case senstitve: false negatives in converting dates in মে
ohc_regex(/([^\w])(মার্চ\s@day)(\s(?:mile|kilomet|met))/g, protect_function);
 
//protect all links containing a date and some text
ohc_regex(/(\[\[)(\s*\w[^\]\|\n]+?@day[^\]\|\n]+?@fullmonth[^\]\|\n]*)(\]\]|\|)/gi, protect_function);
ohc_regex(/(\[\[)([^\]\|\n]*?@day[^\]\|\n]+?@fullmonth(?:,? @year|) \D[^\]\|\n]+\w\s*)(\]\]|\|)/gi, protect_function);
ohc_regex(/(\[\[)(\s*\w[^\]\|\n]+?@fullmonth[^\]\|\n]+?@day[^\]\|\n]*)(\|)/gi, protect_function);
ohc_regex(/(\[\[)([^\]\|\n]*?@fullmonth[^\]\|\n]+?@day(?:, @year|) \D[^\]\|\n]+\w\s*)(\]\]|\|)/gi, protect_function);
 
//protects certain dates
regex(/(\[\[)(4AD)([\s\S])/gi, protect_function);
regex(/([\s\S])(মার্চ (?:8|14) Alliance)([\s\S])/gi, protect_function);
regex(/([\s\S])(23rd মার্চ 1931: Shaheed)([\s\S])/gi, protect_function);
regex(/([\s\S])(Long মার্চ [1-7])([\s\S])/gi, protect_function);
regex(/([\s\S])(National সেপ্টেম্বর 11 Memorial & Museum)([\s\S])/gi, protect_function);
regex(/([\s\S])(Queen Elizabeth II সেপ্টেম্বর 11th Garden)([\s\S])/gi, protect_function);
regex(/([\s\S])(Bombay মার্চ 12)([\s\S])/gi, protect_function);
regex(/([\s\S])(movement 2 জুন)([\s\S])/gi, protect_function);
regex(/([\s\S])(6th\sof অক্টোবর City)([\s\S])/gi, protect_function);
regex(/([\s\S])(Party Workers' Liberation Front 30th of মে)([\s\S])/gi, protect_function);
regex(/([\s\S])(4th\sof আগষ্ট regime)([\s\S])/gi, protect_function);
regex(/([\s\S])(19th\sof এপ্রিল movement)([\s\S])/gi, protect_function);
regex(/([\s\S])(জুন 4th (?:incident|museum))([\s\S])/gi, protect_function);
regex(/([\s\S])(The Battle Of Marston Moor \(জুলাই 2nd,? 1644\))([\s\S])/gi, protect_function);
regex(/([\s\S])(Night of জানুয়ারি 16th)([\s\S])/gi, protect_function);
regex(/([\s\S])(Observance of 5th নভেম্বর Act)([\s\S])/gi, protect_function);
regex(/(\[\[)(13 মে incident)(\|)/gi, protect_function);
regex(/(\'\'\')(22nd\sof মে)(\'\'\')/gi, protect_function);
regex(/(\[\[)(22nd\sof মে \(film\))([|\]\'])/gi, protect_function);
regex(/(\[\[)(জুলাই 12, 2007, Baghdad airstrike)(\|)/gi, protect_function);
regex(/(\[\[)(নভেম্বর 1828)(\]\])/gi, protect_function);
regex(/(.)(4th\sof জুলাই)(.)/gi, protect_function);
regex(/(\[\[)((?:2300|2000)\s?AD)(\]\])/gi, protect_function);
regex(/(\[\[)(29 ফেব্রুয়ারি)(\]\])/gi, protect_function);
regex(/(\[\[)(ফেব্রুয়ারি 29)(\]\])/gi, protect_function);
 
// works names
// regex(/(.)(protect string)(.)/gi, protect_function);
regex(/(.)(11\/22\/63)(.)/gi, protect_function);
regex(/(.)(1\.1\.1994)(.)/gi, protect_function);
regex(/([\s\S])(2\.13\.61)([\s\S])/gi, protect_function);
// regex(/(.)(4th of জুলাই, Asbury)(.)/gi, protect_function); //protected above globally
regex(/(.)(26 অক্টোবর 1993)(.)/gi, protect_function);
regex(/(\[\[|\'\')(জুন 1, 1974)(.)/gi, protect_function);
regex(/(\[\[|\'\')(জুলাই 15, 1972)(.)/gi, protect_function);
regex(/(\[\[|\'\')(আগষ্ট 1914)(.)/gi, protect_function);
ohc_regex(/(\[\[|\'\')(@fullmonth @dd@th? \((?:@yyyy |)film\)(?:\|@fullmonth @dd@th?|))([\s\S])/gi, protect_function);
ohc_regex(/(\[\[|\'\')(@dd@th? @fullmonth \((?:@yyyy |)film\)(?:\|@dd@th? @fullmonth|))([\s\S])/gi, protect_function);
// regex(/(Les Bains Douches 18)( ডিসেম্বর 1979)(.)/gi, protect_function);
regex(/(আগষ্ট)( 7, 4:15)(.)/gi, protect_function);
regex(/(In Concert, Zürich, অক্টোবর)( 28, 1979)(.)/gi, protect_function);
regex(/(CBGB OMFUG Masters: Live জুন)( 29, 2001)(.)/gi, protect_function);
ohc_regex(/(Live at [\w ]*,? [1-3]\d)( @fullmonth)(.)/gi, protect_function);
ohc_regex(/(Live at [\w ]*,? @fullmonth)( @dd)(.)/gi, protect_function);
ohc_regex(/(Bootmoon Series: [\w ]*[-–] @fullmonth)( @day, @YYYY)(.)/gi, protect_function);
 
// expressions and grammatical strings including modal "মে"
regex(/(\W)((?:\d{1,3}) মে)((?: have(?: \w+|)|) be)/g, protect_function);
regex(/(\W)((?:\d{3}|3[2-9]|[4-9]\d)\/\d ডিসেম্বর(?:l\.?|))(\W)/gi, protect_function);
regex(/(\W)((?:\d{2,3})\/\d ডিসেম্বর(?:l\.?|))( \(\d\d? overs)/gi, protect_function);
}
 
/** ------------------------------------------------------------------------ **/
/// DATE PROTECTION FOR ALL REF SECTION
 
var linkmap = [];
 
function ohc_protect_dates_ref()
{
// protects dates within links, quotes, etc
// the sensitive part is stored and replaced with a unique identifier,
// which is later replaced with the stored part.
 
var protect_function = function (s, begin, replace, end) {
linkmap.push(replace);
return begin + "⍌" + (linkmap.length - 1) + "⍍" + end;
};
 
regex(/(<ref\s?(?:>|name=[^>]+))([^<]+)(<\/ref>)/gi, protect_function);
regex(/(<timeline>)([\s\S]*?)(<\/timeline>)/gi, protect_function);
regex(/(<math>)([\s\S]*?)(<\/math>)/gi, protect_function);
regex(/((?:{(?:Wikimedia |)Commons ?|C ?))(Cat(?:egory|))\|[^{}*](})/gi, protect_function);
regex(/((?:Category|Image|File):)([^|\]]*)([|\]])/gi, protect_function);
regex(/(\{(?:See ?also|Main))(\|[^}]*)(\})/gi, protect_function);
regex(/(\{\{(?:double ?|external ?|wide ?)image\s?\|)([^}]+)(\})/gi, protect_function);
regex(/(\{\{(?:harvnb|wikisource)\|)([^}]+)(\})/gi, protect_function);
regex(/(\[(?:https?:|ftp:))([^\]]*)(\])/gi, protect_function);
regex(/(>[ ]*(?:https?:|ftp:))([^< >\]]*)([ ]*<)/gi, protect_function);
//regex(/(https?:|ftp:)([^\s\]]*)([\s\]])/gi, protect_function);
regex(/(<blockquote>)([\s\S]*?)(<\/blockquote>)/gi, protect_function);
regex(/(\{[^\{]{0,6}(?:quot[^|]{1,7}\s?|sic)\|)([^}]+)(\})/gi, protect_function);
regex(/((?:image\d?|image_skyline|image[ _]location\d?|image[ _]name|image[ _]file|img|pic)\s*=)([^|}]*)([|}])/gi, protect_function);
regex(/([\|\{]\s*(?:file(?:name\d?|)|image\d?|image location\d?|img|pic|Cover|title|quote|chapter|journal|url|archiveurl|work|doi|club|at|volume|reporter)\s*=)([^|\}⍍]*)([|}])/gi, protect_function);
regex(/([\|\{]\s*(?:file(?:name\d?|)|image\d?|image location\d?|img|pic|Cover|title|quote|chapter|journal|url|archiveurl|work|doi|club|at|volume|reporter)\s*=)([^|\}⍍]*)([|}])/gi, protect_function);
regex(/([\|\{]\s*(?:season)\s*=)(\s*\[\[[^\]]*\]\]\s*)([|}])/gi, protect_function);
regex(/(\{\{navsource\|)([^}]+)(\})/gi, protect_function);
regex(/(\{\{singlechart\|)([^}]+)(\})/gi, protect_function);
regex(/(\{\{defaultsort:)([^}]+)(\})/gi, protect_function);
regex(/([\s\(>]")([^"\n]*)(")/gi, protect_function);
regex(/([\s\(>]“)([^”\n]*)(”)/gi, protect_function);
regex(/(.)(\(\{\{by\|[12]\d{3}\}\}[-–]\{\{by\|)([12]\d{3}[ ]*\}\}\))/gi, protect_function);
regex(/(.)(\(\{\{by\|[12]\d{3}\}\}(?:[-–]present|))(\))/gi, protect_function);
 
//retraining redirects containing a date
regex(/(\[\[)(?:সেপ্টেম্বর 3 Society)(\]\]|\|)/gi, '$1Jiusan Society$2');
regex(/(\[\[)(?:জুন 4th incident)(\]\]|\|)/gi, '$1Tiananmen Square protests of 1989$2');
ohc_regex(/(\[\[)(?:5@th? অক্টোবর (?:\(Serbia\)|overthrow))(\]\]|\|)/gi, '$1Overthrow of Slobodan Milošević$2');
ohc_regex(/(\[\[)(?:অক্টোবর 5@th?(?: \(Serbia\)| overthrow|, 2000))(\]\]|\|)/gi, '$1Overthrow of Slobodan Milošević$2');
 
//protect alternate meanings of 'মে' and 'মার্চ' (note: not case insensitive)
ohc_regex(/([^\w])(@day,?\s{0,3}মে)([^\w][^\d])/g, protect_function);
ohc_regex(/([^\w])(মার্চ\s@day)(\s(?:mile|kilomet|met))/g, protect_function);
 
//protect all links containing a date and some text
ohc_regex(/(\[\[)(\s*\w[^\]\|\n]+?@day[^\]\|\n]+?@fullmonth[^\]\|\n]*)(\]\]|\|)/gi, protect_function);
ohc_regex(/(\[\[)([^\]\|\n]*?@day[^\]\|\n]+?@fullmonth(?:,? @year|) \D[^\]\|\n]+\w\s*)(\]\]|\|)/gi, protect_function);
ohc_regex(/(\[\[)(\s*\w[^\]\|\n]+?@fullmonth[^\]\|\n]+?@day[^\]\|\n]*)(\|)/gi, protect_function);
ohc_regex(/(\[\[)([^\]\|\n]*?@fullmonth[^\]\|\n]+?@day(?:, @year|) \D[^\]\|\n]+\w\s*)(\]\]|\|)/gi, protect_function);
 
//protects certain dates
regex(/(\[\[)(4AD)([\s\S])/gi, protect_function);
regex(/([\s\S])(মার্চ (?:8|14) Alliance)([\s\S])/gi, protect_function);
regex(/([\s\S])(23rd মার্চ 1931: Shaheed)([\s\S])/gi, protect_function);
regex(/([\s\S])(Long মার্চ [1-7])([\s\S])/gi, protect_function);
regex(/([\s\S])(Bombay মার্চ 12)([\s\S])/gi, protect_function);
regex(/([\s\S])(movement 2 জুন)([\s\S])/gi, protect_function);
regex(/([\s\S])(6th\sof অক্টোবর City)([\s\S])/gi, protect_function);
regex(/([\s\S])(Party Workers' Liberation Front 30th of মে)([\s\S])/gi, protect_function);
regex(/([\s\S])(4th\sof আগষ্ট regime)([\s\S])/gi, protect_function);
regex(/([\s\S])(19th\sof এপ্রিল movement)([\s\S])/gi, protect_function);
regex(/([\s\S])(জুন 4th incident)([\s\S])/gi, protect_function);
regex(/([\s\S])(The Battle Of Marston Moor \(জুলাই 2nd,? 1644\))([\s\S])/gi, protect_function);
regex(/([\s\S])(Night of জানুয়ারি 16th)([\s\S])/gi, protect_function);
regex(/([\s\S])(Observance of 5th নভেম্বর Act)([\s\S])/gi, protect_function);
regex(/(\[\[)(13 মে incident)(\|)/gi, protect_function);
regex(/(\'\'\')(22nd\sof মে)(\'\'\')/gi, protect_function);
regex(/(\[\[)(22nd\sof মে \(film\))([|\]\'])/gi, protect_function);
regex(/(\[\[)(জুলাই 12, 2007, Baghdad airstrike)(\|)/gi, protect_function);
regex(/(\[\[)(নভেম্বর 1828)(\]\])/gi, protect_function);
regex(/(.)(4th\sof জুলাই)(.)/gi, protect_function);
regex(/(\[\[)((?:2300|2000)\s?AD)(\]\])/gi, protect_function);
regex(/(\[\[)(29 ফেব্রুয়ারি)(\]\])/gi, protect_function);
regex(/(\[\[)(ফেব্রুয়ারি 29)(\]\])/gi, protect_function);
 
// works names
//regex(/(.)(protect string)(.)/gi, protect_function);
regex(/(.)(11\/22\/63)(.)/gi, protect_function);
regex(/(.)(1\.1\.1994)(.)/gi, protect_function);
regex(/([\s\S])(2\.13\.61)([\s\S])/gi, protect_function);
//regex(/(.)(4th of জুলাই, Asbury)(.)/gi, protect_function); //protected above globally
regex(/(.)(26 অক্টোবর 1993)(.)/gi, protect_function);
regex(/(\[\[|\'\')(জুন 1, 1974)(.)/gi, protect_function);
regex(/(\[\[|\'\')(জুলাই 15, 1972)(.)/gi, protect_function);
regex(/(\[\[|\'\')(আগষ্ট 1914)(.)/gi, protect_function);
ohc_regex(/(\[\[|\'\')(@fullmonth @dd@th? \((?:@yyyy |)film\)(?:\|@fullmonth @dd@th?|))([\s\S])/gi, protect_function);
ohc_regex(/(\[\[|\'\')(@dd@th? @fullmonth \((?:@yyyy |)film\)(?:\|@dd@th? @fullmonth|))([\s\S])/gi, protect_function);
//regex(/(Les Bains Douches 18)( ডিসেম্বর 1979)(.)/gi, protect_function);
regex(/(আগষ্ট)( 7, 4:15)(.)/gi, protect_function);
regex(/(In Concert, Zürich, অক্টোবর)( 28, 1979)(.)/gi, protect_function);
regex(/(CBGB OMFUG Masters: Live জুন)( 29, 2001)(.)/gi, protect_function);
ohc_regex(/(Live at [\w ]*,? [1-3]\d)( @fullmonth)(.)/gi, protect_function);
ohc_regex(/(Live at [\w ]*,? @fullmonth)( @dd)(.)/gi, protect_function);
ohc_regex(/(Bootmoon Series: [\w ]*[-–] @fullmonth)( @day, @YYYY)(.)/gi, protect_function);
 
regex(/(\W)((?:\d{3}|3[2-9]|[4-9]\d)\/\d ডিসেম্বর(?:l\.?|))(\W)/gi, protect_function);
regex(/(\W)((?:\d{2,3})\/\d ডিসেম্বর(?:l\.?|))( \(\d\d? overs)/gi, protect_function);
}
 
 
/** ------------------------------------------------------------------------ **/
/// DATE PROTECTION FOR SLASH modules
 
var linkmap = [];
 
function ohc_protect_dates_slash()
{
// protects dates within links, quotes, etc
// the sensitive part is stored and replaced with a unique identifier,
// which is later replaced with the stored part.
 
var protect_function = function (s, begin, replace, end) {
linkmap.push(replace);
return begin + "⍌" + (linkmap.length - 1) + "⍍" + end;
};
 
regex(/(<ref\s?(?:>|name=[^>]+))([^<]+)(<\/ref>)/gi, protect_function);
regex(/(<timeline>)([\s\S]*?)(<\/timeline>)/gi, protect_function);
regex(/(<math>)([\s\S]*?)(<\/math>)/gi, protect_function);
regex(/((?:{(?:Wikimedia |)Commons ?|C ?))(Cat(?:egory|))\|[^{}*](})/gi, protect_function);
regex(/((?:Category|Image|File):)([^|\]]*)([|\]])/gi, protect_function);
regex(/(\{(?:See ?also|Main))(\|[^}]*)(\})/gi, protect_function);
regex(/(\{\{(?:double ?|external ?|wide ?)image\s?\|)([^}]+)(\})/gi, protect_function);
regex(/(\{\{(?:harvnb|wikisource)\|)([^}]+)(\})/gi, protect_function);
regex(/(\[(?:https?:|ftp:))([^\]]*)(\])/gi, protect_function);
regex(/(>[ ]*(?:https?:|ftp:))([^< >\]]*)([ ]*<)/gi, protect_function);
//regex(/(https?:|ftp:)([^\s\]]*)([\s\]])/gi, protect_function);
regex(/(<blockquote>)([\s\S]*?)(<\/blockquote>)/gi, protect_function);
regex(/(\{[^\{]{0,6}(?:quot[^|]{1,7}\s?|sic)\|)([^}]+)(\})/gi, protect_function);
regex(/((?:image\d?|image_skyline|image[ _]location\d?|image[ _]name|image[ _]file|img|pic)\s*=)([^|}]*)([|}])/gi, protect_function);
regex(/([\|\{]\s*(?:file(?:name\d?|)|image\d?|image location\d?|img|pic|Cover|title|quote|chapter|journal|url|archiveurl|work|doi|club|at|volume|reporter)\s*=)([^|\}⍍]*)([|}])/gi, protect_function);
regex(/([\|\{]\s*(?:file(?:name\d?|)|image\d?|image location\d?|img|pic|Cover|title|quote|chapter|journal|url|archiveurl|work|doi|club|at|volume|reporter)\s*=)([^|\}⍍]*)([|}])/gi, protect_function);
regex(/([\|\{]\s*(?:season)\s*=)(\s*\[\[[^\]]*\]\]\s*)([|}])/gi, protect_function);
regex(/(\{\{navsource\|)([^}]+)(\})/gi, protect_function);
regex(/(\{\{singlechart\|)([^}]+)(\})/gi, protect_function);
regex(/(\{\{defaultsort:)([^}]+)(\})/gi, protect_function);
regex(/([\s\(>]")([^"\n]*)(")/gi, protect_function);
regex(/([\s\(>]“)([^”\n]*)(”)/gi, protect_function);
regex(/(.)(\(\{\{by\|[12]\d{3}\}\}[-–]\{\{by\|)([12]\d{3}[ ]*\}\}\))/gi, protect_function);
regex(/(.)(\(\{\{by\|[12]\d{3}\}\}(?:[-–]present|))(\))/gi, protect_function);
 
}
 
function ohc_unprotect_dates()
{
//unprotect all dates
regex(/[♫]/g, '');
regex(/⍌([0-9]+)⍍/g, function (x, n) {
var res = linkmap[n];
res = res.replace(/⍌([0-9]+)⍍/g, function (x, n) {
var res = linkmap[n];
res = res.replace(/⍌([0-9]+)⍍/g, function (x, n) {
var res = linkmap[n];
res = res.replace(/⍌([0-9]+)⍍/g, function (x, n) {
return linkmap[n];
});
return res;
});
return res;
});
return res;
});
}
 
function ohc_MOSNUM_edit_summary()
{
//Add a tag to the summary box
setoptions(minor = 'true');
setreason('date formats per [[MOS:DATEFORMAT]] by [[WP:MOSNUMscript|script]]', 'append');
doaction('diff');
}
 
function ohc_bigendien_edit_summary()
{
//Add a tag to the summary box
setoptions(minor = 'true');
setreason('ymd ref dates', 'append');
doaction('diff');
}
 
function ohc_expand_edit_summary()
{
//Add a tag to the summary box
setoptions(minor = 'true');
setreason('expand month names', 'append');
doaction('diff');
}
 
function ohc_slash_edit_summary()
{
//Add a tag to the summary box
setoptions(minor = 'true');
setreason('resolved slash dates', 'append');
doaction('diff');
}
 
function ohc_abbrev_edit_summary()
{
//Add a tag to the summary box
setoptions(minor = 'true');
setreason('abbrev month names', 'append');
doaction('diff');
}
 
/** ------------------------------------------------------------------------ **/
/// CUSTOMIZATION POINTS
function ohc_customize_all_to_dmy() {
}
 
function ohc_customize_all_to_mdy() {
}
 
function ohc_customize_body_to_dmy() {
}
 
function ohc_customize_body_to_mdy() {
}
 
function ohc_customize_ISO_to_dmy() {
}
 
function ohc_customize_ISO_to_mdy() {
}
 
/** ------------------------------------------------------------------------ **/
function ohc_body_dates_to_dmy()
{
ohc_use_dates_template('dmy');
 
ohc_fix_common_errors();
ohc_fix_dts_template('dmy');
ohc_fix_gr_template('dmy');
ohc_dates_to_dmy();
ohc_remove_leading_zeroes();
ohc_fix_dmy_redundancies();
}
 
function ohc_body_dates_to_mdy()
{
ohc_use_dates_template('mdy');
ohc_fix_common_errors();
ohc_fix_dts_template('mdy');
ohc_fix_gr_template('mdy');
ohc_dates_to_mdy();
ohc_remove_leading_zeroes();
ohc_fix_mdy_redundancies();
}
 
/** ------------------------------------------------------------------------ **/
function ohc_all_to_dmy_driver(e)
{
e.preventDefault();
ohc_delink_dates();
ohc_protect_dates();
ohc_fix_unambiguous_dates();
ohc_body_dates_to_dmy();
ohc_delink_ISO_to_dmy();
ohc_delink_year_in_X();
ohc_customize_all_to_dmy();
ohc_ISO_to_dmy_in_citations();
ohc_unprotect_dates();
 
ohc_MOSNUM_edit_summary();
}
 
function ohc_all_to_mdy_driver(e)
{
e.preventDefault();
ohc_delink_dates();
ohc_protect_dates();
ohc_fix_unambiguous_dates();
ohc_body_dates_to_mdy();
ohc_delink_ISO_to_mdy();
ohc_delink_year_in_X();
ohc_customize_all_to_mdy();
ohc_ISO_to_mdy_in_citations();
ohc_unprotect_dates();
 
ohc_MOSNUM_edit_summary();
}
 
function ohc_dmy_publication_dates_driver(e)
{
e.preventDefault();
// ohc_delink_dates();
ohc_protect_dates();
ohc_body_dates_to_dmy();
ohc_customize_body_to_dmy();
ohc_dmy_publication_dates();
ohc_unprotect_dates();
 
ohc_MOSNUM_edit_summary();
}
 
function ohc_mdy_publication_dates_driver(e)
{
e.preventDefault();
// ohc_delink_dates();
ohc_protect_dates();
ohc_body_dates_to_mdy();
ohc_customize_body_to_mdy();
ohc_mdy_publication_dates();
ohc_unprotect_dates();
 
ohc_MOSNUM_edit_summary();
 
}
 
function ohc_body_to_dmy_driver(e)
{
e.preventDefault();
// ohc_delink_dates();
ohc_protect_dates_ref();
ohc_body_dates_to_dmy();
ohc_customize_body_to_dmy();
ohc_unprotect_dates();
 
ohc_MOSNUM_edit_summary();
}
 
function ohc_body_to_mdy_driver(e)
{
e.preventDefault();
// ohc_delink_dates();
ohc_protect_dates_ref();
ohc_body_dates_to_mdy();
ohc_customize_body_to_mdy();
ohc_unprotect_dates();
 
ohc_MOSNUM_edit_summary();
}
 
function ohc_ISO_to_dmy_driver(e)
{
e.preventDefault();
ohc_protect_dates();
ohc_delink_ISO_to_dmy();
ohc_customize_ISO_to_dmy();
ohc_unprotect_dates();
 
// ohc_MOSNUM_edit_summary();
}
 
function ohc_ISO_to_mdy_driver(e) {
e.preventDefault();
ohc_protect_dates();
ohc_delink_ISO_to_mdy();
ohc_customize_ISO_to_mdy();
ohc_unprotect_dates();
 
// ohc_MOSNUM_edit_summary();
}
 
function ohc_delink_year_in_X_driver(e)
{
e.preventDefault();
ohc_delink_year_in_X();
}
 
function ohc_expand_ref_dates_driver(e) {
e.preventDefault();
ohc_expand_ref_dates();
ohc_protect_dates();
ohc_unprotect_dates();
ohc_expand_edit_summary();
}
 
function ohc_expand_all_dates_driver(e)
{
e.preventDefault();
ohc_expand_ref_dates();
ohc_protect_dates();
ohc_expand_all_dates();
ohc_unprotect_dates();
ohc_expand_edit_summary();
}
 
function ohc_abbrev_ref_dates_driver(e)
{
e.preventDefault();
ohc_protect_dates();
ohc_abbrev_ref_dates();
ohc_unprotect_dates();
ohc_slash_edit_summary();
}
 
function ohc_UK_slash_dates_driver(e)
{
e.preventDefault();
ohc_expand_ref_dates();
ohc_protect_dates_slash();
ohc_UK_slash_dates_to_dmy();
ohc_unprotect_dates();
ohc_slash_edit_summary();
}
 
function ohc_US_slash_dates_driver(e)
{
e.preventDefault();
ohc_expand_ref_dates();
ohc_protect_dates_slash();
ohc_US_slash_dates_to_mdy();
ohc_unprotect_dates();
ohc_expand_edit_summary();
}
 
// </pre>
 
//সংশ্লিষ্ট পাতা ত্যাগ না করেই অন্য পাতা থেকে পুনর্নির্দেশ করা যাবে।
//<nowiki>
( function () {
var redir = $(mw.util.addPortletLink('p-tb','#','পুনর্নির্দেশক','পুনর্নির্দেশ তৈরিকারী','পুনর্নির্দেশ তৈরিকারী','','#pt-mytalk'));
$( redir ).click( function() {
var redirec = prompt("যে পাতা থেকে এই পাতায় পুনর্নির্দেশ করতে চান তার নাম লিখুন:", "");
  if (redirec === null || redirec === "") {
alert( 'আপনি কোনও নাম প্রবেশ করান নি। দয়া করে আবার চেষ্টা করুন।' );  
  } else  {
  var params = {
action: 'edit',
title: redirec ,
createonly: 1,
prependtext: '#পুনর্নির্দেশ [[' + mw.config.get("wgPageName") + ']]',
appendtext: " \n" + '{{একটি পুনর্নির্দেশ}}',
summary: '[[' + mw.config.get("wgPageName") + ']] পাতায় পুনর্নির্দেশ করা হল' ,
format: 'json'
};
api = new mw.Api();
api.postWithToken( 'csrf', params ).done( function ( data ) {
alert( 'সফলভাবে ' + redirec + ' পাতা থেকে একটি পুনর্নির্দেশ তৈরি করা হয়েছে!' );
});
  }
}
);
}() );
//</nowiki>
 
//<nowiki>
( function () {
var talkp = $(mw.util.addPortletLink('p-tb','#','স্বাগত জানান','স্বাগত জানান','স্বাগত জানান','','#pt-mytalk'));
$( talkp ).click( function() {
var talk = prompt("কোন ধরনের স্বাগত বার্তা যুক্ত করতে চান এমন টেমপ্লেটটি লিখুন {{Subst:}} সাথে, অন্যথায় পূর্বনির্ধারিত {{Subst:স্বাগতম}} যুক্ত হবে:", "");
  if (talk === null || talk === "") {
    var params1 = {
action: 'edit',
title: 'User talk:' + mw.config.get("wgRelevantUserName"),
prependtext: '{{Subst:স্বাগতম}}'
,
summary: 'ভারতপিডিয়ায় স্বাগতম!',
format: 'json'
};
api = new mw.Api();
api.postWithToken( 'csrf', params1 ).done( function ( data ) {
alert( 'সফলভাবে স্বাগত জানানো হয়েছে!' );
} );
 
  } else {
  var params = {
action: 'edit',
title: 'User talk:' + mw.config.get("wgRelevantUserName"),
prependtext: talk
,
summary: 'ভারতপিডিয়ায় স্বাগত!',
format: 'json'
};
api = new mw.Api();
api.postWithToken( 'csrf', params ).done( function ( data ) {
alert( 'সফলভাবে স্বাগত জানানো হয়েছে!' );
} );
  }
}
);
}() );
//</nowiki>
//<nowiki>
console.time('mobileUndo');
$.when(mw.loader.using(['mediawiki.util', 'mediawiki.api', 'oojs-ui-windows', 'oojs-ui-core', 'oojs-ui.styles.icons-editing-core'])).then(function() {
    return new mw.Api().getMessages(['editundo', 'Undo-nochange']);
}).then(function(globalmessages) {
    var mobileUndo, i18n_lang = mw.config.get('wgUserLanguage');
    var i18n = {
        "en": {
            "mu-success": "Successful",
            "mu-fail": "Failed",
            "mu-loading": "Loading...",
            "editsummary-ad": "",
            "mu-undo-successful": "Revert successful.... Reloading in a sec",
            "mu-empty-reponse-from-server": "An empty response was received from the server",
            "mu-edit-summary-prompt": "Add a reason to your edit summary !",
            "mu-edit-summary-prompt-placeholder": "Reason...",
            "mu-thank-success": "Thanked",
            "mu-thank-confirm": "Send public thanks ?",
            "mu-thank-loading": "Thanking...",
            "mu-thank-successful": "You thanked $1.",
            "mu-thank-failed": "Failed to thank $1.",
            "mu-http-error":"HTTP error: "
        },
        "bn": {
            "mu-success": "সফল",
            "mu-fail": "ব্যর্থ হয়েছে",
            "mu-loading": "লোড করা হচ্ছে...",
            "editsummary-ad": "",
            "mu-undo-successful": "পূর্বাবস্থায় ফেরত যাওয়া সফল হয়েছে.... পুনঃলোড করা হচ্ছে",
            "mu-empty-reponse-from-server": "সার্ভার থেকে একটি খালি প্রতিক্রিয়া পাওয়া গেছে।",
            "mu-edit-summary-prompt": "সম্পাদনা সারাংশে কারণ উল্লেখ করুন!",
            "mu-edit-summary-prompt-placeholder": "কারণ...",
            "mu-thank-success": "ধন্যবাদ দিয়েছেন",
            "mu-thank-confirm": "প্রকাশ্য ধন্যবাদ জানাবেন?",
            "mu-thank-loading": "ধন্যবাদ জানানো হচ্ছে...",
            "mu-thank-successful": "আপনি $1 কে ধন্যবাদ জানিয়েছেন।",
            "mu-thank-failed": "$1 কে ধন্যবাদ জানানো ব্যর্থ হয়েছে।",
            "mu-http-error":"HTTP ত্রুটি: "
        }
    };
if(undefined === i18n[i18n_lang]){
i18n_lang = 'en';
}
    if (mw.config.get('wgCanonicalSpecialPageName') === 'MobileDiff') {
        mw.util.addCSS('#mw-mf-userinfo .mobileUndo-ui .mw-ui-icon.mw-ui-icon-before:before{display:none;}\n#mobileUndo > a > span.oo-ui-iconElement-icon.oo-ui-icon-editUndo.oo-ui-image-invert{display:inline-block; position:initial;}\n#mobileUndo > a{padding:0.57142857em 0.9375em;}'+
        '#mw-mf-userinfo > div > div.mobileUndo-ui > a > div{line-height:normal;}');
        if (mw.config.get('wgVisualEditor').pageLanguageDir === 'ltr') {
            $('#mw-mf-userinfo .post-content').append($('<div>').attr('class', 'mobileUndo-ui').css({
                'display': 'inline-block',
                'float': 'right'
            }));
        } else {
            $('#mw-mf-userinfo .post-content').append($('<div>').attr('class', 'mobileUndo-ui').css({
                'display': 'inline-block',
                'float': 'left'
            }));
        }
        $('.mobileUndo-ui').append($('.mw-mf-action-button').remove().css({
            'clear': 'none'
        }));
        if (!$('.warningbox').length && mw.config.get('wgRelevantPageIsProbablyEditable')) {
            mobileUndo = new OO.ui.ButtonWidget({
                label: (globalmessages.editundo).charAt(0).toUpperCase() + (globalmessages.editundo).slice(1),
                icon: 'editUndo',
                title: 'mobileUndo',
                flags: ['destructive', 'primary'],
                id: 'mobileUndo'
            });
            $('.mobileUndo-ui').append(mobileUndo.$element);
            if (mw.config.get('wgVisualEditor').pageLanguageDir === 'ltr') {
                $('#mobileUndo').css('margin-right', '0.3em');
            } else {
                $('#mobileUndo').css('margin-left', '0.3em');
            }
        }
        window.wgRelevantUser = function() {
            var user;
            if ($('.mw-mf-user-link').text() !== '') {
                user = $('.mw-mf-user-link').text();
            } else {
                user = $('#mw-mf-userinfo .post-content div:nth-child(2)').text();
            }
            return user;
        };
        window.wgRevId = ($('#mw-mf-diffarea > div.mw-mf-diff-info > h3 > a').attr('href')).split('&oldid=')[1];
        var revId = wgRevId;
        console.log(revId);
        var username = wgRelevantUser();
        $('#mw-mf-userinfo .post-content .mobileUndo-ui .mw-mf-action-button').click(function(e) {
            e.preventDefault();
            OO.ui.confirm(i18n[i18n_lang]['mu-thank-confirm']).done(function(confirmed) {
                if (confirmed) {
                    $('.mw-mf-action-button').css('pointer-events', 'none').text(i18n[i18n_lang]['mu-thank-loading']);
                    var api = new mw.Api();
                    api.postWithToken('csrf', {
                        action: "thank",
                        rev: revId,
                    }).done(function(result) {
                        mw.notify((i18n[i18n_lang]['mu-thank-successful']).replace(/\$1/g, username));
                        $('.mw-mf-action-button').text(i18n[i18n_lang]['mu-thank-success']);
                    }).fail(function() {
                        mw.notify((i18n[i18n_lang]['mu-thank-failed']).replace(/\$1/g, username));
                        $('.mw-mf-action-button').text(i18n[i18n_lang]['mu-failed']);
                    });
                }
            });
        });
        console.timeEnd('mobileUndo');
        mobileUndo.on('click', function() {
            OO.ui.prompt(i18n[i18n_lang]['mu-edit-summary-prompt'], {
                textInput: {
                    placeholder: i18n[i18n_lang]['mu-edit-summary-prompt-placeholder']
                }
            }).done(function(customEditSummary) {
                $.when(mw.loader.using('mediawiki.api')).then(function() {
                    return new mw.Api().getMessages(['undo-summary'], {
                        amlang: mw.config.get('wgServerName').split('.wik')[0]
                    });
                }).then(function(message) {
                    var editSummaryMessage = message['undo-summary'];
                    var editSummary = editSummaryMessage.replace(/\$1/g, revId);
                    editSummary = editSummary.replace(/\$2/g, username);
                    if (customEditSummary !== null) {
                        mobileUndo.setDisabled(true);
                        editSummary = editSummary + ' ' + customEditSummary + (i18n[i18n_lang]['editsummary-ad']);
                        //call the API
                        var api = new mw.Api({
                            ajax: {
                                headers: {
                                    'Api-User-Agent': 'mobileUndo/2.0.2(https://en.wikipedia.org/wiki/User:FR30799386/undo.js)'
                                }
                            }
                        });
                        //Feedback UI
                        mobileUndo.setLabel(i18n[i18n_lang]['mu-loading']);
                        api.postWithToken('csrf', {
                            action: "edit",
                            title: mw.config.get('wgRelevantPageName'),
                            summary: editSummary,
                            undo: revId,
                        }).done(function(result) {
                            if (result.edit.code === 'abusefilter-warning' || result.edit.code === 'abusefilter-disallowed') {
                                mobileUndo.setLabel(i18n[i18n_lang]['mu-fail']);
                                OO.ui.alert($('<p>').html(result.edit.warning), {
                                    title: result.edit.info
                                }).done(function() {});
                                return;
                            } else if (typeof result.edit.nochange !== 'undefined') {
                                mobileUndo.setLabel(i18n[i18n_lang]['mu-fail']);
                                OO.ui.alert($('<p>').html(globalmessages['Undo-nochange'])).done(function() {});
                                return;
                            }
                            console.log(result);
                            mobileUndo.setLabel(i18n[i18n_lang]['mu-success']);
                            mw.notify(i18n[i18n_lang]['mu-undo-successful']);
                            setTimeout(function() {
                                location.href = mw.util.getUrl('Special:MobileDiff/' + result.edit.newrevid);
                            }, 1500);
                        }).fail(function(code, jqxhr) {
                            mobileUndo.setLabel(i18n[i18n_lang]['mu-fail']);
                            var details;
                            if (code === 'http' && jqxhr.textStatus === 'error') {
                                details = i18n[i18n_lang]['mu-http-error'] + jqxhr.xhr.status;
                            } else if (code === 'http') {
                                details = i18n[i18n_lang]['mu-http-error'] + jqxhr.textStatus;
                            } else if (code === 'ok-but-empty') {
                                details = i18n[i18n_lang]['mu-empty response-from-server'];
                            } else {
                                details = jqxhr.error.info;
                            }
                            OO.ui.alert($('<p>').html(details)).done(function() {});
                        });
                    }
                });
            });
        });
    }
});
//End of code
//</nowiki>
window.wgRelevantUser = function() {
    var user;
    if ($('.mw-mf-user-link').text() !== '') {
        user = $('.mw-mf-user-link').text();
    } else {
        user = $('#mw-mf-userinfo .post-content div:nth-child(2)').text();
    }
    return user;
    };
var href = ($('#mw-mf-diffarea > div.mw-mf-diff-info > h3 > a').attr('href')) || '';
window.wgRevId = href.split('&oldid=')[1];
if( $('#mw-mf-diffarea > ul > li.revision-history-next').length ) {
$('#mw-mf-diffarea > div.mw-mf-diff-info > h3').append(
$('<a>').attr('id','mobileRestore').attr('href','javascript:void(0)').append(
$('<b>').text('(পুনরুদ্ধার)')
)
);
}
$('#mobileRestore').click(function(e){
e.preventDefault();
$('#mobileRestore b').text('(লোড হচ্ছে....)');
$('#mobileRestore').css('pointer-events','none');
var customEditSummary = prompt('পুনরুদ্ধারের কারণ (ঐচ্ছিক)');
if(customEditSummary === null) {
$('#mobileRestore b').text('(পুনরুদ্ধার)');
$('#mobileRestore').css('pointer-events','auto');
return;
}
var username =wgRelevantUser();
var editSummary = '[[Special:Contributions/'+username+'|'+username+']] ([[User talk:'+username+'|আলাপ]])-এর করা ' +wgRevId+ 'নং সংস্করণ পুনরুদ্ধার করা হয়েছে';
editSummary = editSummary + customEditSummary + ' (পুনরুদ্ধারায়ন)';
$.when(mw.loader.load('mediawiki.api')).then(function(){
var api = new mw.Api();
api.get({
'action':'query',
'prop':'revisions',
'titles':mw.config.get('wgRelevantPageName'),
'rvprop':'ids'
}).done(function(result){
if(result.query.pages) {
var StartRevId = result.query.pages[mw.config.get('wgRelevantArticleId')].revisions[0].revid;
console.log(StartRevId);
api.postWithToken('csrf', {
                    action: "edit",
                    title: mw.config.get('wgRelevantPageName'),
                    summary: editSummary,
                    undo:StartRevId,
undoafter:wgRevId,
                }).done(function(result) {
                    if (typeof result.edit.nochange !== 'undefined') {
                    $('#mobileRestore b').text('(Failed)');
alert( 'No change occured');
                        return;
                    }
console.log(result);
$('#mobileRestore b').text('(সফলভাবে হয়েছে)')
                    mw.notify('সংস্করণ পুনরুদ্ধার সফল হয়েছে.... পুনঃলোড করা হচ্ছে');
setTimeout(function() {
                      location.href = mw.util.getUrl('Special:MobileDiff/' + result.edit.newrevid);
                    }, 1500);
                }).fail(function(code, jqxhr) {
                $('#mobileRestore b').text('(পুনরুদ্ধার কার্য বাতিল করা হয়েছে)');
                    var details;
                    if (code === 'http' && jqxhr.textStatus === 'error') {
                        details = 'HTTP error: ' + jqxhr.xhr.status;
                    } else if (code === 'http') {
                        details = 'HTTP error: ' + jqxhr.textStatus;
                    } else if (code === 'ok-but-empty') {
                        details = 'An empty response was given the server';
                    } else {
                        details = jqxhr.error.info;
                    }
                    alert( details );
                });
} else {
alert('Failed to retrieve page details');
}
});
});
});
if(mw.config.get('wgCanonicalSpecialPageName') === 'MobileDiff') {
mw.loader.using('mediawiki.util', function() {
var ele_a = document.createElement('a');
ele_a.setAttribute('href', mw.util.getUrl(mw.config.get('wgRelevantPageName'), {action: 'history'}));
ele_a.innerHTML = '(ইতিহাস)';
document.getElementsByTagName('h2')[0].appendChild(ele_a);
});
}
 
//my common.js
$.when(mw.loader.using(['mediawiki.util'], $.ready)).done( function() {
mw.util.addPortletLink("p-tb", mw.config.get('wgArticlePath').replace('$1', "ব্যবহারকারী:রবি/common.js"), "common.js", "tb-awbscript", "Personal common.js");
});
 
if (mw.config.get('wgCanonicalNamespace')+':'+mw.config.get('wgTitle') === 'ব্যবহারকারী:রবি/common.js' && mw.config.get('wgAction') == 'view');
 
//শীর্ষক
(function($, mw) {
var scrollDownButtonId = 'scrollDownButton',
scrollUpButtonId = 'scrollUpButton';
if (mw.config.get('wgServerName').match(/wikimirror\.org$/)) {
scrollDownButtonId += '-zhwiki';
scrollUpButtonId += '-zhwiki'
}
 
var scrollButtonIcon = '//upload.wikimedia.org/wikipedia/commons/7/7f/Font_Awesome_5_regular_arrow-circle-up_green.svg';
if (!document.implementation.hasFeature('http://www.w3.org/TR/SVG11/feature#Image', '1.1'))
scrollButtonIcon = '//upload.wikimedia.org/wikipedia/commons/thumb/7/7f/Font_Awesome_5_regular_arrow-circle-up_green.svg/32px-Font_Awesome_5_regular_arrow-circle-up_green.svg.png';
 
$scrollDownButton = $('<img>', {
src: scrollButtonIcon,
id: scrollDownButtonId
}).css({
cursor: 'pointer',
opacity: 0.7,
position: 'fixed',
display: 'none',
right: '18px',
transform: 'rotate(180deg)',
'-webkit-transform': 'rotate(180deg)',
'-moz-transform': 'rotate(180deg)',
'-o-transform': 'rotate(180deg)',
'-ms-transform': 'rotate(180deg)'
}).on('click', function() {
$('html, body').animate({
scrollTop: $(document).height() - $(window).height()
}, 660)
}).on('mouseenter mouseleave', function(e) {
this.style.opacity = e.type === 'mouseenter' ? 1 : 0.7
}).appendTo('body');
 
$scrollUpButton = $('<img>', {
src: scrollButtonIcon,
id: scrollUpButtonId
}).css({
cursor: 'pointer',
opacity: 0.7,
position: 'fixed',
display: 'none',
right: '18px'
}).on('click', function() {
$('html, body').animate({
scrollTop: 0
}, 660)
}).on('mouseenter mouseleave', function(e) {
this.style.opacity = e.type === 'mouseenter' ? 1 : 0.7
}).appendTo('body');
 
var scrollButtonTimer;
$(window).on('scroll', function() {
var dingHeight = $('#bluedeck_ding>div').height() ? $('#bluedeck_ding>div').height() : 0;
$('#mw-ge-help-panel-cta-button').length > 0 ? $scrollDownButton.css('bottom', dingHeight + 75 + 'px') && $scrollUpButton.css('bottom', dingHeight + 116 + 'px') : $scrollDownButton.css('bottom', dingHeight + 24 + 'px') && $scrollUpButton.css('bottom', dingHeight + 65 + 'px');
$('#cat_a_lot').length > 0 || $('#proveit').length > 0 || $('.wordcount').length > 0 ? $scrollDownButton.css('left', '10px') && $scrollUpButton.css('left', '10px') : $scrollDownButton.css('left', 'unset') && $scrollUpButton.css('left', 'unset');
$(this).scrollTop() > 60 ? $scrollDownButton.fadeIn('slow') && $scrollUpButton.fadeIn('slow') : $scrollDownButton.fadeOut('slow') && $scrollUpButton.fadeOut('slow');
this.clearTimeout(scrollButtonTimer);
scrollButtonTimer = this.setTimeout(function() {
$scrollDownButton.fadeOut('slow');
$scrollUpButton.fadeOut('slow')
}, 2000)
});
$scrollDownButton.on('mouseenter', function() {
window.clearTimeout(scrollButtonTimer)
});
$scrollUpButton.on('mouseenter', function() {
window.clearTimeout(scrollButtonTimer)
})
})(jQuery, mw);
 
/**
* Add "Purge" content action link.
*
* Dependencies: mediawiki.util, mediawiki.api
*
* @source https://www.mediawiki.org/wiki/Snippets/Purge_action
* @revision 2016-05-22
*/
$( function () {
if ( $( '#ca-purge' ).length || !mw.config.get( 'wgIsArticle' ) ) return;
var node = mw.util.addPortletLink(
'p-cactions',
mw.util.getUrl( null, { action: 'purge' } ),
mw.config.get( 'skin' ) === 'vector' ? 'শোধন' : 'শোধন',
'ca-purge',
'এই পাতার সার্ভার ক্যাশে পরিস্কার করুন',
'শোধন'
);
$(node).on( 'click', function (e) {
new mw.Api().post( { action: 'purge', titles: mw.config.get( 'wgPageName' ) } ).then(function () {
location.reload();
}, function () {
mw.notify( 'শোধন ব্যর্থ হয়েছে', { type: 'error' } );
});
e.preventDefault();
});
});
 
//rollback confirmation
//<nowiki>
(function() {
if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
$(".mw-rollback-link").on('click', function(e) {
var linkText = $(e.target).text(),
count = linkText.match(/\d/) ? linkText.match(/\d+/)[0] : null,
message = 'রোলব্যাক ' + 'করছেন ' + mw.util.getParamValue('from',e.target.href) + ' কতৃক সম্পাদিত ' + (count ? count + ' edits' : 'সম্পাদনা') + '?';
if(!confirm(message)) return e.preventDefault();
});
}
}());
//</nowiki>
 
/** Quick Edit **/
 
// Edit sections of a page without leaving the article
// [[en:w:User:BrandonXLF/QuickEdit]]
// By [[en:w:User:BrandonXLF]]
 
(function() {
var mobile = mw.config.get('skin') === 'minerva',
apiSingleton,
titleRegexp = new RegExp(
mw.config.get('wgArticlePath').replace(/[.*+?^${}()|[\]\\]/g, '\\$&').replace(/\\\$1/, '([^?]+)') +
'|[?&]title=([^&#]*)'
);
 
function api(func, params) {
if (!apiSingleton) apiSingleton = new mw.Api();
 
$.extend(params, {
errorformat: 'html',
errorlang: mw.config.get('wgUserLanguage'),
errorsuselocal: true
});
 
return apiSingleton[func](params).fail(function(_, data) {
mw.notify(apiSingleton.getErrorMessage(data), {
type: 'error',
tag: 'quickedit'
});
});
}
 
function getPageInfo(title, sectionID) {
return api('get', {
action: 'query',
curtimestamp: 1,
prop: 'revisions',
indexpageids: 1,
titles: title,
rvprop: ['timestamp', 'content'],
rvslots: 'main',
rvsection: sectionID
}).then(function(res) {
var rev = res.query.pages[res.query.pageids[0]].revisions[0];
 
return {
start: res.curtimestamp,
base: rev.timestamp,
full: rev.slots.main['*']
};
});
}
 
function getPreviewCallback(editor) {
editor.children('.preview').remove();
 
new OO.ui.ProgressBarWidget().$element.css({
maxWidth: '100%',
borderRadius: '0',
boxShadow: 'none',
margin: '8px 0'
}).addClass('preview').appendTo(editor);
 
return function(html) {
editor.children('.preview').remove();
 
$('<div>').html(html).css({
margin: '8px 0',
border: '1px solid #a2a9b1',
padding: '8px',
overflowX: 'hidden'
}).addClass('preview').appendTo(editor);
};
}
 
function showCompare(editor, title, from, to) {
mw.loader.load('mediawiki.diff.styles');
 
api('post', {
action: 'compare',
fromslots: 'main',
'fromtext-main': from,
fromtitle: title,
frompst: 'true',
toslots: 'main',
'totext-main': to,
totitle: title,
topst: 'true'
}).then(function(r) {
return r.compare['*'] ? $('<table>').addClass('diff').append(
$('<colgroup>').append(
$('<col>').addClass('diff-marker'),
$('<col>').addClass('diff-content'),
$('<col>').addClass('diff-marker'),
$('<col>').addClass('diff-content')
)
).append(r.compare['*']) : 'কোন পার্থক্য নেই';
}).then(getPreviewCallback(editor));
}
 
// Parts taken from EditPage::extractSectionTitle and Parser::stripSectionName
function getSectionSummary(text) {
var match = text.match(/^(=+)(.+)\1\s*(\n|$)/);
 
return !match ? '' : '/* ' + match[2].trim()
// Strip internal link markup
.replace(/\[\[:?([^[|]+)\|([^[]+)\]\]/g, '$2')
.replace(/\[\[:?([^[]+)\|?\]\]/g, '$1')
// Strip external link markup
.replace(new RegExp('\\[(?:' + mw.config.get('wgUrlProtocols') + ')([^ ]+?) ([^\\[]+)\\]', 'ig'), '$2')
// Remove wikitext quotes
.replace(/(''|'''|''''')(?!')/g, '')
// Strip HTML tags
.replace(/<[^>]+?>/g, '') + ' */ ';
}
 
function showEditor(el) {
var progress = new OO.ui.ProgressBarWidget(),
heading = el.closest(':header'),
matcher = heading.nextUntil.bind(heading),
inserter = heading.after.bind(heading),
targetEl = el.siblings('.quickedit-target').last(),
titleMatch = targetEl.attr('href').match(titleRegexp),
title = decodeURIComponent(titleMatch[1] || titleMatch[2]),
sectionID = /[?&]v?e?section=T?-?(\d*)/.exec(targetEl.attr('href'))[1];
 
if (!heading.closest('.mw-parser-output').length) {
var articleContent = $('#mw-content-text .mw-parser-output');
 
matcher = function(selector) {
var child = articleContent.children(selector).first();
 
if (child.length) return child.prevAll();
return articleContent.children();
};
inserter = articleContent.prepend.bind(articleContent);
}
 
inserter(progress.$element.css({
maxWidth: '100%',
borderRadius: '0',
boxShadow: 'none'
}));
 
el.addClass('quickedit-loading');
$('.quickedit-hide').removeClass('quickedit-hide');
$('.quickedit-heading').removeClass('quickedit-heading');
$('#quickedit-editor').remove();
 
getPageInfo(title, sectionID).then(function(r) {
var start = r.start,
base = r.base,
full = r.full,
saving = false,
expanded = false,
remainderStart = full.match(/\n=+.+=+(?:\n|$)/),
part =  remainderStart ? full.substring(0, remainderStart.index) : full,
remainder = remainderStart ? full.substring(remainderStart.index) : '',
level = 0,
editor;
 
full.replace(/^(=+).+?(=+)(?:\n|$)/, function(m, a, b) {
level = Math.min(a.length, b.length);
return m;
});
 
var levelMatch = 'h1';
for (var i = 2; i <= level; i++) levelMatch += ',h' + i + ':has(*)';
 
var partSection = matcher(':header:has(*)'),
fullSection = matcher(levelMatch),
textarea = new OO.ui.MultilineTextInputWidget({
rows: 1,
maxRows: 20,
autosize: true,
value: part
}),
summary = new OO.ui.TextInputWidget({
value: getSectionSummary(part)
}),
minor = new OO.ui.CheckboxInputWidget(),
save = new OO.ui.ButtonInputWidget({
label: 'পরিবর্তন প্রকাশ করুন',
title: 'Save your changes',
flags: ['primary', 'progressive']
}),
preview = new OO.ui.ButtonInputWidget({
label: 'প্রাকদর্শন',
title: 'Preview the new wikitext'
}),
compare = new OO.ui.ButtonInputWidget({
label: 'পরিবর্তনসমূহ',
title: 'View the difference between the current revision and your revision'
}),
cancel = new OO.ui.ButtonInputWidget({
useInputTag: true,
label: 'বাতিল',
title: 'Close the edit form and discard changes',
flags: ['secondary', 'destructive']
}),
more = new OO.ui.ButtonInputWidget({
label: '+',
title: 'Edit the entire section (including subsections)'
}),
buttons = new OO.ui.HorizontalLayout({
items: [save, preview, compare, cancel]
});
 
if (part != full) {
buttons.addItems([more], 3);
}


partSection.addClass('quickedit-hide');
if (mw.config.get('wgCanonicalNamespace')+':'+mw.config.get('wgTitle') === 'ব্যবহারকারী:রবি/common.js' && mw.config.get('wgAction') == 'view');
heading.addClass('quickedit-heading');
el.removeClass('quickedit-loading');
progress.$element.remove();
textarea.$input.css({
borderRadius: '0'
});


summary.on('enter', function() {
//শীর্ষক
save.emit('click');
mw.loader.load('//bn.bharatpedia.org/index.php?title=ব্যবহারকারী:রবি/উপর নীচ.js&action=raw&ctype=text/javascript');
});


save.on('click', function() {
//Purge
if (saving) return;
mw.loader.load('//bn.bharatpedia.org/index.php?title=ব্যবহারকারী:রবি/পুনঃসতেজ.js&action=raw&ctype=text/javascript');


var fullText = textarea.getValue() + (expanded ? '' : remainder);
/** Quick Edit **/
saving = true;
mw.loader.load('//bn.bharatpedia.org/index.php?title=ব্যবহারকারী:রবি/দ্রুত সম্পাদনা.js&action=raw&ctype=text/javascript');
save.setLabel('সংরক্ষণ করা হচ্ছে...');
compare.setDisabled(true);
preview.setDisabled(true);
cancel.setDisabled(true);
more.setDisabled(true);
 
api('postWithEditToken', {
action: 'edit',
title: title,
section: sectionID,
summary: summary.getValue(),
text: fullText,
minor: minor.isSelected() ? true : undefined,
notminor: minor.isSelected() ? undefined : true,
starttimestamp: start,
basetimestamp: base
}).then(function() {
api('get', {
action: 'parse',
page: mw.config.get('wgPageName'),
prop: ['text', 'categorieshtml']
}).then(function(r) {
var contentText = $('#mw-content-text'),
catLinks = $('#catlinks');
 
contentText.find('.mw-parser-output').replaceWith(r.parse.text['*']);
mw.hook('wikipage.content').fire(contentText);
 
catLinks.replaceWith(r.parse.categorieshtml['*']);
mw.hook('wikipage.categories').fire(catLinks);
 
saving = false;
});
}, function(code) {
if (code == 'editconflict') {
showEditConflict(editor, title, sectionID, fullText).then(function(r) {
start = r.start;
base = r.base;
textarea = r.textarea;
expanded = true;
});
}
 
compare.setDisabled(false);
preview.setDisabled(false);
cancel.setDisabled(false);
more.setDisabled(expanded);
saving = false;
save.setLabel('Save');
});
});
 
preview.on('click', function() {
api('post', {
action: 'parse',
title: title,
prop: 'text',
pst: 'true',
disablelimitreport: 'true',
disableeditsection: 'true',
sectionpreview: 'true',
disabletoc: 'true',
text: textarea.getValue()
}).then(function(r) {
return r.parse.text['*'] + '<div style="clear:both;"></div>';
}).then(getPreviewCallback(editor));
});
 
compare.on('click', function() {
showCompare(editor, title, part + (expanded ? remainder : ''), textarea.getValue());
});
 
cancel.on('click', function() {
editor.remove();
heading.removeClass('quickedit-heading');
fullSection.removeClass('quickedit-hide');
});
 
more.on('click', function() {
expanded = true;
textarea.setValue(textarea.getValue() + remainder);
fullSection.addClass('quickedit-hide');
more.setDisabled(true);
});
 
editor = $('<div id="quickedit-editor">').css({
overflowX: 'hidden'
}).append(
$('<div>').css({
backgroundColor: '#eaecf0',
borderBottom: '1px solid #a2a9b1',
marginBottom: '8px'
}).append(
textarea.$element.css({
width: '100%',
maxWidth: '100%',
fontFamily: 'monospace, monospace'
}).addClass('quickedit-textarea'),
$('<div>').css({
border: '1px solid #a2a9b1',
borderWidth: '0 1px'
}).append(
$('<div>').css({
padding: '8px 4px 8px 8px',
display: 'table-cell',
verticalAlign: 'middle'
}).html('সারাংশ:'),
summary.$element.css({
width: '100%',
maxWidth: '100%',
padding: '8px 0px',
display: 'table-cell',
verticalAlign: 'middle'
}),
new OO.ui.FieldLayout(minor, {
label: new OO.ui.HtmlSnippet('🤏?'),
align: 'inline'
}).$element.css({
padding: '8px 8px 8px 4px',
display: 'table-cell',
verticalAlign: 'middle'
})
),
buttons.$element.css({
border: '1px solid #a2a9b1',
borderWidth: '0 1px',
padding: '0px 8px 0'
}),
title !== mw.config.get('wgPageName') ? $('<div>').css({
border: '1px solid #a2a9b1',
borderWidth: '0 1px',
padding: '0px 8px 8px'
}).append(
'Editing page: ',
$('<a>').attr('href', mw.config.get('wgArticlePath').replace('$1', title)).css({
fontWeight: 'bold'
}).text(title.replace(/_/g, ' '))
) : undefined
)
);
 
inserter(editor);
}, function() {
el.removeClass('quickedit-loading');
progress.$element.remove();
});
}
 
function showEditConflict(editor, title, sectionID, text) {
return getPageInfo(title, sectionID).then(function(r) {
var textarea = new OO.ui.MultilineTextInputWidget({
rows: 1,
maxRows: 20,
autosize: true,
value: r.full
}),
textarea2 = new OO.ui.MultilineTextInputWidget({
rows: 1,
maxRows: 20,
autosize: true,
value: text,
});
 
function syncSize() {
textarea.styleHeight = -1;
textarea.adjustSize(true);
 
textarea2.styleHeight = -1;
textarea2.adjustSize(true);
 
var height = Math.max(textarea.$input.height(), textarea2.$input.height());
textarea.$input.height(height);
textarea2.$input.height(height);
}
 
textarea.$input.css({
borderRadius: '0'
});
editor.find('> :first-child > :first-child').remove();
 
$('<table>').css({
width: '100%',
border: '1px solid #a2a9b1',
borderBottom: 'none',
borderSpacing: '0',
margin: '0 !important'
}).append(
$('<tr>').append(
$('<th>').css({
width: '50%',
paddingTop: '4px'
}).text('Their version (to be saved)'),
$('<th>').css({
width: '50%',
paddingTop: '4px'
}).text('Your version')
),
$('<tr>').append(
$('<td>').css({
width: '50%',
padding: '4px 4px 0 8px'
}).append(
textarea.$element.css({
width: '100%',
maxWidth: '100%',
fontFamily: 'monospace, monospace'
})
),
$('<td>').css({
width: '50%',
padding: '4px 8px 0 4px'
}).append(
textarea2.$element.css({
width: '100%',
maxWidth: '100%',
fontFamily: 'monospace, monospace'
})
)
)
).prependTo(editor.find('> :first-child'));
 
textarea.on('change', syncSize);
textarea2.on('change', syncSize);
syncSize();
showCompare(editor, title, text, r.full);
 
r.textarea = textarea;
return r;
});
}
 
function clickHandler(e) {
var el = $(e.target);
 
if (!el.hasClass('quickedit-editlink') || el.hasClass('quickedit-loading')) return;
 
e.preventDefault();
 
showEditor(el);
}
 
function addLinksToChildren(element) {
element.find('#quickedit-editor, .quickedit-section').remove();
element.find('.mw-editsection').each(function() {
$('[href*="section="]', this).last().after(
mobile ? '' : '<span class="quickedit-section"> | </span>',
$('<a>').html(mobile ? '&nbsp;💨' : 'দ্রুত সম্পাদনা').addClass('quickedit-section quickedit-editlink')
).addClass('quickedit-target');
});
}
 
$.when(mw.loader.using('oojs-ui-core'), $.ready).done(function() {
var body = $(document.body);
 
body.on('click', clickHandler);
addLinksToChildren(body);
mw.hook('wikipage.content').add(addLinksToChildren);
});
 
mw.loader.addStyleTag(
'.skin-minerva .mw-editsection { white-space: nowrap; }' +
'.skin-minerva .content .collapsible-heading .quickedit-section { visibility: hidden; }' +
'.skin-minerva .content .collapsible-heading.open-block .quickedit-section { visibility: visible; }' +
'.quickedit-hide { display: none !important; }' +
'.quickedit-loading, .quickedit-heading { color: #777; }'
);
})();
 
//খেলাঘর
$( document ).ready( function() {
  mw.util.addPortletLink(
    'p-personal',
    mw.util.getUrl( 'Special:MyPage/খেলাঘর' ), //No need for a variable.
    'খেলাঘর',
    'pt-sandbox2',
    'খেলাঘর',
    null,
    '#pt-sandbox'
  );
});


//article creation
//page creation
mw.loader.load('//bn.bharatpedia.org/index.php?title=ব্যবহারকারী:রবি/পাতা সৃষ্টিকারক.js&action=raw&ctype=text/javascript');


//redirect fix
$(function() { $('#mw-content-text .mw-redirect').after(function() { return this.href.indexOf('action=edit') !== -1 || this.href.indexOf('action=') !== -1  || this.href.indexOf('diff=') !== -1 ? '' : '<a href="' + this.href + (this.href.includes('?') ? '&' : '?') + 'action=edit" title="' + (this.title || this.href) + ' (edit redirect)"><sup>(→)</sup></a>'; }); });


(function() {
//cleanup
$(document).ready(function() {
mw.loader.load('//bn.bharatpedia.org/index.php?title=ব্যবহারকারী:রবি/পরিষ্কারকরণ.js&action=raw&ctype=text/javascript');
mw.loader.using( ['mediawiki.util'], function() {
{
var L=mw.util.addPortletLink("p-navigation", "#", "নতুন পাতা তৈরি");L.addEventListener("click", create);
return;
}
});
});
}());
function create() {
var art = prompt ("যে নিবন্ধটি তৈরি করতে চান তার নাম লিখুন:");
switch (art) {
case null:
case undefined:
case '':
//Do nothing
break;
default:
{
window.open('/index.php?preload=Special:New_page&editintro=&title=' + art + '&create=Create+page#/editor/all', '_blank');
}
}
 
 
}

১৫:৪৭, ১৩ মে ২০২২ তারিখে সম্পাদিত সর্বশেষ সংস্করণ

mw.loader.load('//bn.bharatpedia.org/index.php?title=ব্যবহারকারী:রবি/রোলব্যাক নিশ্চিতকারক.js&action=raw&ctype=text/javascript');
mw.loader.load('//commons.m.wikimedia.org/w/index.php?title=MediaWiki:Gadget-HotCat.js&action=raw&ctype=text/javascript');

$(document).ready(function() {

 function customAlert(msg,duration){
 var pageId = mw.config.get('wgArticleId');
 var div = document.createElement('div');
 div.style ='position: fixed; right:500px; top:100px;height:51px;padding-top:13px;width:300px;font-size:25px; display:block;border: solid 1px black;background-color:white';
 div.innerHTML = "<center><img src='https://upload.wikimedia.org/wikipedia/commons/thumb/a/a1/Chulito_verde.jpg/21px-Chulito_verde.jpg'>"+"   "+msg+"</center>";
 setTimeout(function() {
 div.parentNode.removeChild(div);
 },duration);
 document.body.appendChild(div);};
 var bnSpellChecker = function() {
$('#wpTextbox1').wikiEditor('addToToolbar', {
            'section': 'main',
            'group': 'insert',
            'tools': {
                'bnSpellChecker': {
                   label: 'বানান শুদ্ধি করুন',
                   type: 'button',
        	   icon: '//upload.wikimedia.org/wikipedia/commons/thumb/0/01/Lachit_SpellChecker.png/25px-Lachit_SpellChecker.png',
                   action: {
                        type: 'callback',
                        execute: function() {
                        
   getText = $('#wpTextbox1').val();
   x = getText.replace(/  +/g, " ");

   //wiki special
   x = x.replace(/\u09DF/g, 'য়');
   x = x.replace(/{{ /g, '{{');
//   x = x.replace(/ডঃ/g, 'ড°');
   x = x.replace(/ঐতিয্য/g, 'ঐতিহ্য');
   x = x.replace(/নিম্নপ্রদত্ব/g, 'নিম্নপ্রদত্ত');
   x = x.replace(/কাহানি/g, 'কাহিনী');
   x = x.replace(/মনোনিত/g, 'মনোনীত');

   // From Dibya Dutta's Pratishapan
   x = x.replace(/৷/g, "।");
   x = x.replace(/ ।/g, "।");
   x = x.replace(/ ৷/g, "।");
   x = x.replace(/ \?/g, "?");
   x = x.replace(/ ॥/g, "॥");
   x = x.replace(/ !/g, "!");
   x = x.replace(/ ;/g, ";");
   x = x.replace(/ ,/g, ',');
   x = x.replace(/।।/g, '॥');
   x = x.replace(/৷৷/g, "॥");
   x = x.replace(/াে/g, "ো");
   x = x.replace(/ো/g, "ো");
   x = x.replace(/অাা/g, 'আ');
   x = x.replace(/অা/g, 'আ');
   x = x.replace(/আা/g, 'আ');

   //Lachit Spellchecker
    x = x.replace(/য়/g, 'য়');
 //   x = x.replace(/ন্ট/g, 'ণ্ট');
    x = x.replace(/থ্থ/g, 'ত্থ');
    x = x.replace(/ট্ন/g, 'ত্ন');
    x = x.replace(/ধ্ধ/g, 'দ্ধ');
    x = x.replace(/ন্ঠ/g, 'ণ্ঠ');
  //  x = x.replace(/ন্ড/g, 'ণ্ড');
    x = x.replace(/ণ্দ/g, 'ন্দ');
    x = x.replace(/ণ্ধ/g, 'ন্ধ');
    x = x.replace(/ন্ঢ/g, 'ণ্ঢ');
    x = x.replace(/ণ্ত/g, 'ন্ত');
    x = x.replace(/ণ্জ/g, 'ঞ্জ');
    x = x.replace(/ন্জ/g, 'ঞ্জ');
    x = x.replace(/ন্চ/g, 'ঞ্চ');
    x = x.replace(/ন্ছ/g, 'ঞ্ছ');
    x = x.replace(/ণ্চ/g, 'ঞ্চ');
    x = x.replace(/ণ্ছ/g, 'ঞ্ছ');
    x = x.replace(/ণ্স/g, 'ন্স');
    x = x.replace(/ষ্ন/g, 'ষ্ণ');
 //   x = x.replace(/স্ট/g, 'ষ্ট'); (প্রতিবর্ণীতে ভুল ফলাফল দিচ্ছে)
    x = x.replace(/স্হ/g, 'স্থ');
    x = x.replace(/ষ্হ/g, 'স্থ');
    x = x.replace(/ন্হ/g, 'ন্থ');
    x = x.replace(/স্ঠ/g, 'ষ্ঠ'); 
    x = x.replace(/ঙঁ/g, 'ঙ');
    x = x.replace(/ঞঁ/g, 'ঞ');
    x = x.replace(/নঁ/g, 'ন');
    x = x.replace(/ণঁ/g, 'ণ');
    x = x.replace(/মঁ/g, 'ম');
    x = x.replace(/অা/g, 'আ');
    x = x.replace(/অাা/g, 'আ');
    x = x.replace(/অাা/g, 'আ');



    //crucial part starts 
    // do not fiddle here 
    //removes multiple question marks, exclamation

    x = x.replace(/\?\?\?/g, '?'); //removes triple question marks with spaces
    x = x.replace(/\?\?/g, '?'); //removed double question marks with spaces
    // x = x.replace(/!!!/g, '!'); //removes triple exclamation with spaces NOT FOR WIKI
    // x = x.replace(/!!/g, '!'); //removes double exclamation with spaces NOT FOR WIKI

    // crucial part ends

    // brings the question marks, exclamation, full stop before inverted comma
    // new in Version 3.0
//    x = x.replace(/"। /g, '।" ');  // ” = RIGHT DOUBLE QUOTATION MARK “ = LEFT DOUBLE QUOTATION MARK
    x = x.replace(/"\?/g, '?"');  // ” = RIGHT DOUBLE QUOTATION MARK “ = LEFT DOUBLE QUOTATION MARK
    x = x.replace(/"! /g, '!" ');  // ” = RIGHT DOUBLE QUOTATION MARK “ = LEFT DOUBLE QUOTATION MARK


    //corrects commonly mistaken words

  x = x.replace(/অংক/g, 'অঙ্ক');
  x = x.replace(/অংকন/g, 'অঙ্কন');
  x = x.replace(/অংকুর/g, 'অঙ্কুর');
  x = x.replace(/অংগ /g, 'অঙ্গ ');
  x = x.replace(/অংগন/g, 'অঙ্গন');
  x = x.replace(/অংগাংগী/g, 'অঙ্গাঙ্গি');
  x = x.replace(/অকল্যান/g, 'অকল্যাণ');
  x = x.replace(/অকারন/g, 'অকারণ');
  x = x.replace(/অগ্রগন্য/g, 'অগ্রগণ্য');
  x = x.replace(/অগ্রহায়ন/g, 'অগ্রহায়ণ');
  x = x.replace(/অচিন্ত/g, 'অচিন্ত্য');
  x = x.replace(/অচিন্ত্যনীয়/g, 'অচিন্তনীয়');
  x = x.replace(/অঞ্জলী/g, 'অঞ্জলি');
  x = x.replace(/অণ্বেষণ/g, 'অন্বেষণ');
  x = x.replace(/অতিথী/g, 'অতিথি');
  x = x.replace(/অতিব /g, 'অতীব ');
  x = x.replace(/অতিষ্ট/g, 'অতিষ্ঠ');
  x = x.replace(/অত্যাধিক/g, 'অত্যধিক');
  x = x.replace(/অত্যান্ত/g, 'অত্যন্ত');
  x = x.replace(/অদ্ভূত/g, 'অদ্ভুত');
  x = x.replace(/অদ্যপি/g, 'অদ্যাপি');
  x = x.replace(/অদ্যবদি/g, 'অদ্যাবধি');
  x = x.replace(/অধঃস্তন/g, 'অধস্তন');
  x = x.replace(/অধিকরন/g, 'অধিকরণ');
  x = x.replace(/অধীনস্ত/g, 'অধীনস্থ');
  x = x.replace(/অধ্যাবসায়/g, 'অধ্যবসায়');
  x = x.replace(/অধ্যায়ণ/g, 'অধ্যয়ন');
  x = x.replace(/অধ্যূষিত/g, 'অধ্যুষিত');
  x = x.replace(/অনিন্দসুন্দর/g, 'অনিন্দ্যসুন্দর');
  x = x.replace(/অনিষ্ঠ/g, 'অনিষ্ট');
  x = x.replace(/অনু /g, 'অণু ');
  x = x.replace(/অনুকুল/g, 'অনুকূল');
  x = x.replace(/অনুর্ধ্ব/g, 'অনূর্ধ্ব');
  x = x.replace(/অনুসঙ্গ/g, 'অনুষঙ্গ');
  x = x.replace(/অন্তঃসত্তা/g, 'অন্তসত্ত্বা');
  x = x.replace(/অন্তকরণ/g, 'অন্তঃকরণ');
  x = x.replace(/অন্তর্ভূক্ত/g, 'অন্তর্ভুক্ত');
  x = x.replace(/অন্তর্মুখি/g, 'অন্তর্মুখী');
  x = x.replace(/অন্যমনষ্ক/g, 'অন্যমনস্ক');
  x = x.replace(/অপসৃয়মান/g, 'অপসৃয়মাণ');
  x = x.replace(/অপাংক্তেয়/g, 'অপাঙ্‌ক্তেয়');
  x = x.replace(/অপেক্ষমান/g, 'অপেক্ষমাণ');
  x = x.replace(/অভিভুত/g, 'অভিভূত');
  x = x.replace(/অভিমুখি /g, 'অভিমুখী ');
  x = x.replace(/অভ্যন্তরিক/g, 'আভ্যন্তরিক');
  x = x.replace(/অভ্যস্থ/g, 'অভ্যস্ত');
  x = x.replace(/অমানুসিক/g, 'অমানুষিক');
  x = x.replace(/অমাবশ্যা/g, 'অমাবস্যা');
  x = x.replace(/অমিতাক্ষর/g, 'অমিত্রাক্ষর');
  x = x.replace(/অর্ধ্ব/g, 'অর্ধ');
  x = x.replace(/অর্পণা/g, 'অপর্ণা');
  x = x.replace(/অলংঘ/g, 'অলঙ্ঘ্য');
  x = x.replace(/অশিরিরী/g, 'অশরীরী');
  x = x.replace(/অসুয়া/g, 'অসূয়া');
  x = x.replace(/অস্তমান/g, 'অস্তায়মান');
  x = x.replace(/অহঃরহ/g, 'অহরহ');
  x = x.replace(/আঁড়াআড়ি/g, 'আড়াআড়ি');
  x = x.replace(/আঁড়িপাতা/g, 'আড়িপাতা');
  x = x.replace(/আকষ্কিক/g, 'আকস্মিক');
  x = x.replace(/আকাংখা/g, 'আকাঙ্ক্ষা');
  x = x.replace(/আকাবাকা/g, 'আঁকাবাঁকা');
  x = x.replace(/আকুতি/g, 'আকূতি');
  x = x.replace(/আকূল/g, 'আকুল');
  x = x.replace(/আক্রমন/g, 'আক্রমণ');
  x = x.replace(/আটপৌড়ে/g, 'আটপৌরে');
  x = x.replace(/আড়ষ্ঠ/g, 'আড়ষ্ট');
  x = x.replace(/আড়ৎ/g, 'আড়ত');
  x = x.replace(/আতংক/g, 'আতঙ্ক');
  x = x.replace(/আত্মস্যাৎ/g, 'আত্মসাৎ');
  x = x.replace(/আদ্যান্ত/g, 'আদ্যন্ত');
  x = x.replace(/আদ্র/g, 'আর্দ্র');
  x = x.replace(/আনবিক/g, 'আণবিক');
  x = x.replace(/আনুষাঙ্গিক/g, 'আনুষঙ্গিক');
  x = x.replace(/আপাতঃদৃষ্টে/g, 'আপাতদৃষ্টে');
  x = x.replace(/আপাততঃ/g, 'আপাতত');
  x = x.replace(/আপোষ/g, 'আপোস');
  x = x.replace(/আভ্যন্তরীণ/g, 'অভ্যন্তরীণ');
  x = x.replace(/আয়ত্ব/g, 'আয়ত্ত');
  x = x.replace(/আয়ত্বাধীন/g, 'আয়ত্তাধীন');
  x = x.replace(/আরাম্ভ/g, 'আরম্ভ');
  x = x.replace(/আলিংগন/g, 'আলিঙ্গন');
  x = x.replace(/আলোচ্যমান/g, 'আলোচ্য');
  x = x.replace(/আশংকা/g, 'আশঙ্কা');
  x = x.replace(/আশক্তি/g, 'আসক্তি');
  x = x.replace(/আশ্বস্থ/g, 'আশ্বস্ত');
  x = x.replace(/আস্তাকুঁড়/g, 'আঁস্তাকুড়');
  x = x.replace(/ইংগিত/g, 'ইঙ্গিত');
  x = x.replace(/ইতঃস্তত/g, 'ইতস্তত');
  x = x.replace(/ইতিপূর্বে/g, 'ইতঃপূর্বে');
  x = x.replace(/ইতিমধ্যে/g, 'ইতোমধ্যে');
  x = x.replace(/ইদানিং/g, 'ইদানীং');
  x = x.replace(/ইয়ত্বা/g, 'ইয়ত্তা');
  x = x.replace(/ইষ্ঠ/g, 'ইষ্ট');
  x = x.replace(/ইষৎ/g, 'ঈষৎ');
  x = x.replace(/ঈস্পিত/g, 'ঈপ্সিত');
  x = x.replace(/উচিৎ/g, 'উচিত');
  x = x.replace(/উচ্চৈস্বরে/g, 'উচ্চৈঃস্বরে');
  x = x.replace(/উচ্ছ্বল/g, 'উচ্ছল');
  x = x.replace(/উজ্বল/g, 'উজ্জ্বল');
  x = x.replace(/উত্তরন/g, 'উত্তরণ');
  x = x.replace(/উত্তরসুরী/g, 'উত্তরসূরি');
  x = x.replace(/উত্তলন/g, 'উত্তোলন');
  x = x.replace(/উত্যক্ত/g, 'উত্ত্যক্ত');
  x = x.replace(/উদীচি/g, 'উদীচী');
  x = x.replace(/উদ্দান/g, 'উদ্যান');
  x = x.replace(/উদ্দ্যোগ/g, 'উদ্যোগ');
  x = x.replace(/উদ্ধত্য/g, 'ঔদ্ধত্য');
  x = x.replace(/উদ্বিঘ্ন/g, 'উদ্বিগ্ন');
  x = x.replace(/উদ্ভিজ/g, 'উদ্ভিজ্জ');
  x = x.replace(/উদ্ভুত/g, 'উদ্ভূত');
  x = x.replace(/উনবিংশ/g, 'ঊনবিংশ');
  x = x.replace(/উপকুল/g, 'উপকূল');
  x = x.replace(/উপচার্য/g, 'উপাচার্য');
  x = x.replace(/উপরোক্ত/g, 'উপরিউক্ত');
  x = x.replace(/উপলক্ষ্য/g, 'উপলক্ষ');
  x = x.replace(/উভয়চর/g, 'উভচর');
  x = x.replace(/উর্ধ্ব/g, 'ঊর্ধ্ব');
  x = x.replace(/উর্মি/g, 'ঊর্মি');
  x = x.replace(/উশৃঙ্খল/g, 'উচ্ছৃঙ্খল');
  x = x.replace(/উষর/g, 'ঊষর');
  x = x.replace(/উহ্য/g, 'ঊহ্য');
  x = x.replace(/উৎকর্ষতা/g, 'উৎকর্ষ');
  x = x.replace(/ঊনিশ/g, 'উনিশ');
  x = x.replace(/এককৃত/g, 'একীকৃত');
  x = x.replace(/একনিষ্ট/g, 'একনিষ্ঠ');
  x = x.replace(/একভূত/g, 'একীভূত');
  x = x.replace(/একাধিক্রমে/g, 'একাদিক্রমে');
  x = x.replace(/এক্ষুণি/g, 'এক্ষুনি');
  x = x.replace(/এতদ্‌সঙ্গে/g, 'এতৎসঙ্গে');
  x = x.replace(/এতদ্‌সত্ত্বেও/g, 'এতৎসত্ত্বেও');
  x = x.replace(/এশিয় /g, 'এশীয় ');
  x = x.replace(/ঐকবদ্ধ/g, 'ঐক্যবদ্ধ');
  x = x.replace(/ঐক্যতা/g, 'একতা');
  x = x.replace(/ঐক্যতান/g, 'ঐকতান');
  x = x.replace(/ঐক্যমত/g, 'ঐকমত্য');
  x = x.replace(/ওতঃপ্রোত/g, 'ওতপ্রোত');
  x = x.replace(/ঔচিত্ত/g, 'ঔচিত্য');
  x = x.replace(/কংকণ/g, 'কঙ্কণ');
  x = x.replace(/কংকাল/g, 'কঙ্কাল');
  x = x.replace(/কচিৎ/g, 'ক্বচিৎ');
  x = x.replace(/কটুক্তি/g, 'কটূক্তি');
  x = x.replace(/কতৃক/g, 'কর্তৃক');
  x = x.replace(/কতৃত্ত্ব/g, 'কর্তৃত্ব');
  x = x.replace(/কতৃপক্ষ/g, 'কর্তৃপক্ষ');
  x = x.replace(/কথপোকথন/g, 'কথোপকথন');
  x = x.replace(/কদাচিত/g, 'কদাচিৎ');
  x = x.replace(/ কনা/g, ' কণা');
  x = x.replace(/কনিষ্ট/g, 'কনিষ্ঠ');
  x = x.replace(/কন্ঠশিল্পী/g, 'কণ্ঠশিল্পী');
  x = x.replace(/কন্ঠস্ত/g, 'কণ্ঠস্থ');
  x = x.replace(/কয়েদী/g, 'কয়েদি');
  x = x.replace(/করনিক/g, 'করণিক');
  x = x.replace(/কর্তী/g, 'কর্ত্রী');
  x = x.replace(/কর্মচারি/g, 'কর্মচারী');
  x = x.replace(/কলংক/g, 'কলঙ্ক');
  x = x.replace(/কলসী/g, 'কলসি');
  x = x.replace(/কল্যান/g, 'কল্যাণ');
  x = x.replace(/কল্যানীয়াষু/g, 'কল্যাণীয়াসু');
  x = x.replace(/কল্যানীয়েসু/g, 'কল্যাণীয়েষু');
  x = x.replace(/কষ্ঠি/g, 'কষ্টি');
  x = x.replace(/কাঁচ/g, 'কাচ');
  x = x.replace(/কাঁছাকাছি/g, 'কাছাকাছি');
  x = x.replace(/কাংখিত/g, 'কাঙ্খিত');
  x = x.replace(/কাকলী/g, 'কাকলি');
  x = x.replace(/কাচা/g, 'কাঁচা');
  x = x.replace(/কাতলা/g, 'কাৎলা');
  x = x.replace(/কার্যতঃ/g, 'কার্যত');
  x = x.replace(/কিংবদন্তী/g, 'কিংবদন্তি');
  x = x.replace(/কিম্বা/g, 'কিংবা');
  x = x.replace(/কুটনীতি/g, 'কূটনীতি');
  x = x.replace(/কুৎসিৎ/g, 'কুৎসিত');
  x = x.replace(/কূটিল/g, 'কুটিল');
  x = x.replace(/কৃচ্ছতা/g, 'কৃচ্ছ্রতা');
  x = x.replace(/কৃচ্ছসাধন/g, 'কৃচ্ছ্রসাধন');
  x = x.replace(/কৃষিজীবি/g, 'কৃষিজীবী');
  x = x.replace(/কৃষ্টিবান/g, 'কৃষ্টিমান');
  x = x.replace(/কেন্দ্রিয়/g, 'কেন্দ্রীয়');
  x = x.replace(/কেরাণী/g, 'কেরানি');
  x = x.replace(/কোণাকুণি/g, 'কোনাকুনি');
  x = x.replace(/কৌতুহল/g, 'কৌতূহল');
  x = x.replace(/কৌতূক/g, 'কৌতুক');
  x = x.replace(/ক্রুর/g, 'ক্রূর');
  x = x.replace(/ক্ষীয়মান/g, 'ক্ষীয়মাণ');
  x = x.replace(/ক্ষুন্ন/g, 'ক্ষুণ্ণ');
  x = x.replace(/ক্ষুব্দ/g, 'ক্ষুব্ধ');
  x = x.replace(/ক্ষেপন/g, 'ক্ষেপণ');
  x = x.replace(/ক্ষেপনাস্ত্র/g, 'ক্ষেপণাস্ত্র');
  x = x.replace(/খঞ্জনী/g, 'খঞ্জনি');
  x = x.replace(/খুটিনাটি/g, 'খুঁটিনাটি');
  x = x.replace(/খুড়ী/g, 'খুড়ি');
  x = x.replace(/খুশী/g, 'খুশি');
  x = x.replace(/খেতমজুর/g, 'ক্ষেতমজু');
  x = x.replace(/খেলাধূলা/g, 'খেলাধুলা');
  x = x.replace(/খেলোয়ার/g, 'খেলোয়াড়');
  x = x.replace(/খোজ/g, 'খোঁজ');
  x = x.replace(/খোলাখোলি/g, 'খোলাখুলি');
  x = x.replace(/গংগা/g, 'গঙ্গা');
  x = x.replace(/গগণ/g, 'গগন');
  x = x.replace(/গড্ডালিকা/g, 'গড্ডলিকা');
  x = x.replace(/গত্যান্তর/g, 'গত্যন্তর');
  x = x.replace(/ গন /g, ' গণ ');
  x = x.replace(/গননা/g, 'গণনা');
  x = x.replace(/গনিত/g, 'গণিত');
  x = x.replace(/গন্য /g, 'গণ্য ');
  x = x.replace(/গন্‌জ/g, 'গঞ্জ');
  x = x.replace(/গবেষনা/g, 'গবেষণা');
  x = x.replace(/গরীব/g, 'গরিব');
  x = x.replace(/গর্ধব/g, 'গর্ধভ');
  x = x.replace(/গাড়ী/g, 'গাড়ি');
  x = x.replace(/গার্হস্থ /g, 'গার্হস্থ্য ');
  x = x.replace(/গীর্জা/g, 'গির্জা');
  x = x.replace(/গুড়া/g, 'গুঁড়া');
  x = x.replace(/গুড়ো/g, 'গুঁড়ো');
  x = x.replace(/গুণে গুণে/g, 'গুনে গুনে');
  x = x.replace(/গৃহস্ত/g, 'গৃহস্থ');
  x = x.replace(/গৃহিত/g, 'গৃহীত');
  x = x.replace(/গোধুলি/g, 'গোধূলি');
  x = x.replace(/গোষ্ঠি/g, 'গোষ্ঠী');
  x = x.replace(/গোস্পদ/g, 'গোষ্পদ');
  x = x.replace(/গ্রন্থী/g, 'গ্রন্থি');
  x = x.replace(/গ্রহন/g, 'গ্রহণ');
  x = x.replace(/গ্রহিতা/g, 'গ্রহীতা');
  x = x.replace(/গ্রামীন/g, 'গ্রামীণ');
  x = x.replace(/গ্রীক/g, 'গ্রিক');
  x = x.replace(/গ্রীস/g, 'গ্রিস');
  x = x.replace(/ঘনিষ্ট/g, 'ঘনিষ্ঠ');
  x = x.replace(/ঘরণী/g, 'ঘরনি');
  x = x.replace(/ ঘাটি/g, ' ঘাঁটি');
  x = x.replace(/ঘুরাঘুরি/g, 'ঘোরাঘুরি');
  x = x.replace(/ঘুর্ণীয়মান/g, 'ঘূর্ণায়মান');
  x = x.replace(/ঘুর্নি/g, 'ঘূর্ণি');
  x = x.replace(/ঘুসখোর/g, 'ঘুষখোর');
  x = x.replace(/ঘূণ/g, 'ঘুণ');
  x = x.replace(/ঘোষনা/g, 'ঘোষণা');
  x = x.replace(/ঘ্রান/g, 'ঘ্রাণ');
  x = x.replace(/চত্তর/g, 'চত্বর');
  x = x.replace(/চরক/g, 'চড়ক');
  x = x.replace(/চাকরানী/g, 'চাকরানি');
  x = x.replace(/চাকরী/g, 'চাকরি');
  x = x.replace(/চাকুরী/g, 'চাকুরী');
  x = x.replace(/চাতুর্যতা/g, 'চাতুর্য');
  x = x.replace(/চীৎকার/g, 'চিৎকার');
  x = x.replace(/চুড়মার/g, 'চুরমার');
  x = x.replace(/চুড়ান্ত/g, 'চূড়ান্ত');
  x = x.replace(/চূষ্য/g, 'চোষ্য');
  x = x.replace(/চৌচিড়/g, 'চৌচির');
  x = x.replace(/ছাকনি/g, 'ছাঁকনি');
  x = x.replace(/ ছাকা/g, ' ছাঁকা');
  x = x.replace(/ছাত্রীবাস/g, 'ছাত্রীনিবাস');
  x = x.replace(/ছোওয়া/g, 'ছোঁয়া');
  x = x.replace(/ছোকড়া/g, 'ছোকরা');
  x = x.replace(/ছোটখাট /g, 'ছোটোখাটো ');
  x = x.replace(/ছোটাছোটি/g, 'ছোটাছুটি');
  x = x.replace(/জংগল/g, 'জঙ্গল');
  x = x.replace(/জগত/g, 'জগৎ');
  x = x.replace(/জঘণ্য/g, 'জঘন্য');
  x = x.replace(/জটীল/g, 'জটিল');
  x = x.replace(/জবানবন্দী/g, 'জবানবন্দি');
  x = x.replace(/জরুরী/g, 'জরুরি');
  x = x.replace(/জাগরুক/g, 'জাগরূক');
  x = x.replace(/জাতিয়/g, 'জাতীয়');
  x = x.replace(/জাতী /g, 'জাতি ');
  x = x.replace(/জাতীয়করন/g, 'জাতীয়করণ');
  x = x.replace(/জানুয়ারী/g, 'জানুয়ারি');
  x = x.replace(/জিনিষ/g, 'জিনিস');
  x = x.replace(/জীবীকা/g, 'জীবিকা');
  x = x.replace(/জেষ্ঠ্য/g, 'জ্যেষ্ঠ');
  x = x.replace(/জৈষ্ঠ্য/g, 'জ্যৈষ্ঠ');
  x = x.replace(/জ্বরাজীর্ণ/g, 'জরাজীর্ণ');
  x = x.replace(/টাকশাল/g, 'টাঁকশাল');
  x = x.replace(/টেঁকসই/g, 'টেকসই');
  x = x.replace(/ডাইনী/g, 'ডাইনি');
  x = x.replace(/তক্ষুণি/g, 'তক্ষুনি');
  x = x.replace(/তছরূপ/g, 'তছরুপ');
  x = x.replace(/তড়িত/g, 'তড়িৎ');
  x = x.replace(/ততক্ষণাৎ/g, 'তৎক্ষণাৎ');
  x = x.replace(/ততধিক/g, 'ততোধিক');
  x = x.replace(/তত্তজ্ঞান/g, 'তত্ত্বজ্ঞান');
  x = x.replace(/তত্তাবদায়ক/g, 'তত্ত্বাবধায়ক');
  x = x.replace(/তত্তাবধান/g, 'তত্ত্বাবধান');
  x = x.replace(/তদসংক্রান্ত/g, 'তৎসংক্রান্ত');
  x = x.replace(/তদানুসারে/g, 'তদনুসারে');
  x = x.replace(/তদ্রুপ/g, 'তদ্রূপ');
  x = x.replace(/তফাত/g, 'তফাৎ');
  x = x.replace(/তরংগ/g, 'তরঙ্গ');
  x = x.replace(/তরান্বিত/g, 'ত্বরান্বিত');
  x = x.replace(/তর্জনি/g, 'তর্জনী');
  x = x.replace(/তষ্কর/g, 'তস্কর');
  x = x.replace(/তাঁতী/g, 'তাঁতি');
  x = x.replace(/তাবত/g, 'তাবৎ');
  x = x.replace(/তিতীক্ষা/g, 'তিতিক্ষা');
  x = x.replace(/তিরষ্কার/g, 'তিরস্কার');
  x = x.replace(/ত্বরিৎ/g, 'ত্বরিত');
  x = x.replace(/ত্যজ্য/g, 'ত্যাজ্য');
  x = x.replace(/ত্রান/g, 'ত্রাণ');
  x = x.replace(/ত্রিভূজ/g, 'ত্রিভুজ');
  x = x.replace(/তৎবিষয়ক/g, 'তদ্বিষয়ক');
  x = x.replace(/থুত্থুরে/g, 'থুত্থুড়ে');
  x = x.replace(/দক্ষিন/g, 'দক্ষিণ');
  x = x.replace(/দণ্ডবত/g, 'দণ্ডবৎ');
  x = x.replace(/দরকারী/g, 'দরকারি');
  x = x.replace(/দরুণ/g, 'দরুন');
  x = x.replace(/দারিদ্রতা/g, 'দরিদ্রতা, দারিদ্র');
  x = x.replace(/দারুন/g, 'দারুণ');
  x = x.replace(/দিকভ্রান্ত/g, 'দিগভ্রান্ত');
  x = x.replace(/দিক্ষা/g, 'দীক্ষা');
  x = x.replace(/দিঘী/g, 'দিঘি');
  x = x.replace(/দীর্ঘসূত্রিতা/g, 'দীর্ঘসূত্রতা');
  x = x.replace(/দুতাবাস/g, 'দূতাবাস');
  x = x.replace(/দুরবীক্ষন/g, 'দূরবীক্ষণ');
  x = x.replace(/দুরাবস্থা/g, 'দুরবস্থা');
  x = x.replace(/দুষ /g, 'দোষ ');
  x = x.replace(/দুষ্কৃতীকারী/g, 'দুষ্কৃতকারী');
  x = x.replace(/দূরবীক্ষন/g, 'দূরবীক্ষণ');
  x = x.replace(/দূরবীণ/g, 'দূরবীন');
  x = x.replace(/দূরারোগ্য/g, 'দুরারোগ্য');
  x = x.replace(/দূরুহ/g, 'দুরূহ');
  x = x.replace(/দূর্গ/g, 'দুর্গ');
  x = x.replace(/দৃঢ়করণ/g, 'দৃঢ়ীকরণ');
  x = x.replace(/দৃষ্টিকোন/g, 'দৃষ্টিকোণ');
  x = x.replace(/দৃষ্ঠিভঙ্গি/g, 'দৃষ্টিভঙ্গি');
  x = x.replace(/দেদীপ্যমাণ/g, 'দেদীপ্যমান');
  x = x.replace(/দেরী/g, 'দেরি');
  x = x.replace(/দৈনতা/g, 'দীনতা, দৈন্য');
  x = x.replace(/দোষনীয়/g, 'দূষণীয়');
  x = x.replace(/দৌরাত্ম/g, 'দৌরাত্ম্য');
  x = x.replace(/দ্বন্দ/g, 'দ্বন্দ্ব');
  x = x.replace(/দ্বিতীয়তঃ/g, 'দ্বিতীয়ত');
  x = x.replace(/ধজা/g, 'ধ্বজা');
  x = x.replace(/ধরণ/g, 'ধরন');
  x = x.replace(/ধাধা/g, 'ধাঁধা');
  x = x.replace(/ধারন/g, 'ধারণ');
  x = x.replace(/ধারনা/g, 'ধারণা');
  x = x.replace(/ধুমপান/g, 'ধূমপান');
  x = x.replace(/ধুর্ত/g, 'ধূর্ত');
  x = x.replace(/ধুলি/g, 'ধূলি');
  x = x.replace(/ধুসর/g, 'ধূসর');
  x = x.replace(/ধূলা/g, 'ধুলা');
  x = x.replace(/ধ্বনী/g, 'ধ্বনি');
  x = x.replace(/ধ্বস/g, 'ধ্স');
  x = x.replace(/ধ্বস্তাধ্বস্তি/g, 'ধ্স্তাধস্তি');
  x = x.replace(/নচেত/g, 'নচেৎ');
  x = x.replace(/নচ্ছাড়/g, 'নচ্ছাড়');
  x = x.replace(/নবীণ/g, 'নবীন');
  x = x.replace(/নমষ্কার/g, 'নমস্কার');
  x = x.replace(/নিক্কন/g, 'নিক্বণ');
  x = x.replace(/নিন্দ্যনীয়/g, 'নিন্দনীয়');
  x = x.replace(/নিরব/g, 'নীরব');
  x = x.replace(/নিরস /g, 'নীরস ');
  x = x.replace(/নিরুপন/g, 'নিরূপণ');
  x = x.replace(/নিরোগ/g, 'নীরোগ');
  x = x.replace(/নির্দোষী/g, 'নির্দোষ');
  x = x.replace(/নির্ধনী/g, 'নির্ধন');
  x = x.replace(/নির্নয়/g, 'নির্ণয়');
  x = x.replace(/নিস্কাশন/g, 'নিষ্কাশন');
  x = x.replace(/নিস্প্রভ/g, 'নিষ্প্রভ');
  x = x.replace(/নিস্প্রয়োজন/g, 'নিষ্প্রয়োজন');
  x = x.replace(/নিহারীকা/g, 'নীহারিকা');
  x = x.replace(/নীচে/g, 'নিচে');
  x = x.replace(/নীজ/g, 'নিজ');
  x = x.replace(/নীরলস/g, 'নিরলস');
  x = x.replace(/নূন্যতম/g, 'ন্যূনতম');
  x = x.replace(/নৃসংশ/g, 'নৃশংস');
  x = x.replace(/নৈশব্দ্য/g, 'নৈঃশব্দ্য');
  x = x.replace(/ন্যয়/g, 'ন্যায়');
  x = x.replace(/ন্যয্য/g, 'ন্যায্য');
  x = x.replace(/পংক/g, 'পঙ্ক');
  x = x.replace(/পংক্তি/g, 'পঙক্তি');
  x = x.replace(/পক্ক/g, 'পক্ব');
  x = x.replace(/পড়শী/g, 'পড়শি');
  x = x.replace(/পড়াশুনা/g, 'পড়াশোনা');
  x = x.replace(/পথমধ্যে/g, 'পথিমধ্যে');
  x = x.replace(/পথিকৃত/g, 'পথিকৃৎ');
  x = x.replace(/পন্য /g, 'পণ্য ');
  x = x.replace(/পরবর্তীতে /g, 'পরবর্তীকালে ');
  x = x.replace(/পরমানু/g, 'পরমাণু');
  x = x.replace(/পরষ্পর/g, 'পরস্পর');
  x = x.replace(/পরাস্থ/g, 'পরাস্ত');
  x = x.replace(/পরিনাম/g, 'পরিণাম');
  x = x.replace(/পরিবহণ/g, 'পরিবহন');
  x = x.replace(/পরিমান/g, 'পরিমাণ');
  x = x.replace(/পরিষ্ফুট/g, 'পরিস্ফুট');
  x = x.replace(/পরিস্কার/g, 'পরিষ্কার');
  x = x.replace(/পশ্চাদপট/g, 'পশ্চাৎপট');
  x = x.replace(/পশ্চাদপদ/g, 'পশ্চাৎপদ');
  x = x.replace(/পশ্চাৎগামী/g, 'পশ্চাদগামী');
  x = x.replace(/পশ্চাৎভূমি/g, 'পশ্চাদভূমি');
  x = x.replace(/পারদর্শীতা/g, 'পারদর্শিতা');
  x = x.replace(/পারমানবিক/g, 'পারমাণবিক');
  x = x.replace(/পার্বন/g, 'পার্বণ');
  x = x.replace(/পালংক/g, 'পালঙ্ক');
  x = x.replace(/পাষান/g, 'পাষাণ');
  x = x.replace(/পিচাশ/g, 'পিশাচ');
  x = x.replace(/পিঠস্থান/g, 'পীঠস্থান');
  x = x.replace(/পিপিলিকা/g, 'পিপীলিকা');
  x = x.replace(/পুংখানুপুংখ/g, 'পুঙ্খানুপুঙ্খ');
  x = x.replace(/পুজা/g, 'পূজা');
  x = x.replace(/পুণবিবেচনা/g, 'পুনর্বিবেচনা');
  x = x.replace(/পুন্য/g, 'পুণ্য');
  x = x.replace(/পুরষ্কার/g, 'পুরস্কার');
  x = x.replace(/পুর্ন/g, 'পূর্ণ');
  x = x.replace(/পুস্করিনী/g, 'পুষ্করিণী');
  x = x.replace(/পূজো/g, 'পুজো');
  x = x.replace(/পূবালী/g, 'পুবালি');
  x = x.replace(/পূর্ণগঠন/g, 'পুনর্গঠন');
  x = x.replace(/পৈত্রিক/g, 'পৈতৃক');
  x = x.replace(/পোষাক/g, 'পোশাক');
  x = x.replace(/পৌনঃপৌনিক/g, 'পৌনঃপুনিক');
  x = x.replace(/পৌরহিত্য/g, 'পৌরোহিত্য');
  x = x.replace(/প্রজ্জলন/g, 'প্রজ্বলন');
  x = x.replace(/প্রজ্জলিত/g, 'প্রজ্বলিত');
  x = x.replace(/প্রণয়ণ/g, 'প্রণয়ন');
  x = x.replace(/প্রতিকুল/g, 'প্রতিকূল');
  x = x.replace(/প্রতিযোগীতা/g, 'প্রতিযোগিতা');
  x = x.replace(/প্রত্যয়ণ/g, 'প্রত্যায়ন');
  x = x.replace(/প্রথমতঃ/g, 'প্রথমত');
  x = x.replace(/প্রধানতঃ/g, 'প্রধানত');
  x = x.replace(/প্রনালী/g, 'প্রণালী');
  x = x.replace(/প্রনিধান/g, 'প্রণিধান');
  x = x.replace(/প্রবাহমাণ/g, 'প্রবাহমান');
  x = x.replace(/প্রবীন/g, 'প্রবীণ');
  x = x.replace(/প্রভুত/g, 'প্রভূত');
  x = x.replace(/প্রয়ান/g, 'প্রয়াণ');
  x = x.replace(/প্রশস্থ/g, 'প্রশস্ত');
  x = x.replace(/প্রসংগ/g, 'প্রসঙ্গ');
  x = x.replace(/প্রসংশা/g, 'প্রশংসা');
  x = x.replace(/প্রাংগন/g, 'প্রাঙ্গণ');
  x = x.replace(/প্রাণপন/g, 'প্রাণপণ');
  x = x.replace(/প্রানীজগৎ/g, 'প্রাণীজগৎ');
  x = x.replace(/প্রানীবিদ্যা/g, 'প্রাণীবিদ্যা');
  x = x.replace(/ফলতঃ/g, 'ফলত');
  x = x.replace(/ফলপ্রসু/g, 'ফলপ্রসূ');
  x = x.replace(/ফাল্গুণ/g, 'ফাল্গুন');
  x = x.replace(/ফেব্রুয়ারী/g, 'ফেব্রুয়ারি');
  x = x.replace(/বংগ/g, 'বঙ্গ');
  x = x.replace(/বনষ্পতি/g, 'বনস্পতি');
  x = x.replace(/বনিক/g, 'বণিক');
  x = x.replace(/বন্টন/g, 'বণ্টন');
  x = x.replace(/বন্দোপাধ্যায়/g, 'বন্দ্যোপাধ্যায়');
  x = x.replace(/বয়ষ্ক/g, 'বয়স্ক');
  x = x.replace(/বয়োকনিষ্ট/g, 'বয়ঃকনিষ্ঠ');
  x = x.replace(/বর্ণালী/g, 'বর্ণালি');
  x = x.replace(/বর্ত্তমান/g, 'বর্তমান');
  x = x.replace(/বর্ষন/g, 'বর্ষণ');
  x = x.replace(/বাঁশী/g, 'বাঁশি');
  x = x.replace(/বাকদত্তা/g, 'বাগদত্তা');
  x = x.replace(/বাঞ্চনীয়/g, 'বাঞ্ছনীয়');
  x = x.replace(/বাঞ্চা/g, 'বাঞ্ছা');
  x = x.replace(/ বাড়ী/g, ' বাড়ি');
  x = x.replace(/বাদুর/g, 'বাদুড়');
  x = x.replace(/বানিজ্য/g, 'বাণিজ্য');
  x = x.replace(/বিদ্যান/g, 'বিদ্বান');
  x = x.replace(/বিপদগ্রস্থ/g, 'বিপদগ্রস্ত');
  x = x.replace(/বিপদজনক/g, 'বিপজ্জনক');
  x = x.replace(/বিপনন/g, 'বিপণন');
  x = x.replace(/বিপনী/g, 'বিপণী');
  x = x.replace(/বিশ্বস্থ/g, 'বিশ্বস্ত');
  x = x.replace(/বিষ্ফোরণ/g, 'বিস্ফোরণ');
  x = x.replace(/বীভৎস্য/g, 'বীভৎস');
  x = x.replace(/বুদ্ধিজীবি/g, 'বুদ্ধজীবী');
//  x = x.replace(/বেশী/g, 'বেশি'); দ্ব্যর্থক শব্দ, দুটো ভিন্ন অর্থ প্রকাশ করে
  x = x.replace(/ব্যকরণ/g, 'ব্যাকরণ');
  x = x.replace(/ব্যপক/g, 'ব্যাপক');
  x = x.replace(/ব্যহত/g, 'ব্যাহত');
  x = x.replace(/ব্যাতিক্রম/g, 'ব্যতিক্রম');
  x = x.replace(/ব্যাথা/g, 'ব্যথা');
  x = x.replace(/ব্যাপি/g, 'ব্যাপী');
  x = x.replace(/ব্যাবধান/g, 'ব্যবধান');
  x = x.replace(/ব্যাবহার/g, 'ব্যবহার');
  x = x.replace(/ব্যাভিচার/g, 'ব্যভিচার');
  x = x.replace(/ব্যায় /g, 'ব্যয় ');
  x = x.replace(/ব্যার্থ/g, 'ব্যর্থ');
  x = x.replace(/ব্যুৎপত্তি/g, 'বুৎপত্তি');
  x = x.replace(/ব্রাক্ষণ/g, 'ব্রাহ্মণ');
  x = x.replace(/ভংগ/g, 'ভঙ্গ');
  x = x.replace(/ভংগী/g, 'ভঙ্গি');
  x = x.replace(/ভংগুর/g, 'ভঙ্গুর');
  x = x.replace(/ভনিতা/g, 'ভণিতা');
  x = x.replace(/ভবিষ্যৎবাণী/g, 'ভবিষ্যদ্বাণী');
  x = x.replace(/ভরনপোষণ/g, 'ভরণপোষণ');
  x = x.replace(/ভষ্ম/g, 'ভস্ম');
  x = x.replace(/ভাষ্কর/g, 'ভাস্কর');
  x = x.replace(/ভিখারী/g, 'ভিখারি');
  x = x.replace(/ভিরু/g, 'ভীরু');
  x = x.replace(/ভীড়/g, 'ভিড়');
  x = x.replace(/ভুড়ি/g, 'ভুঁড়ি');
  x = x.replace(/ভুতপূর্ব/g, 'ভূতপূর্ব');
  x = x.replace(/ভুমিষ্ট/g, 'ভূমিষ্ঠ');
  x = x.replace(/ভুয়সী/g, 'ভূয়সী');
  x = x.replace(/ভুরিভোজন/g, 'ভূরিভোজন');
  x = x.replace(/ভূবন/g, 'ভুবন');
  x = x.replace(/ভূয়া/g, 'ভুয়া');
  x = x.replace(/ভূল/g, 'ভুল');
  x = x.replace(/ভৌগলিক/g, 'ভৌগোলিক');
  x = x.replace(/ভ্রমন/g, 'ভ্রমণ');
  x = x.replace(/ভ্রাম্যমান/g, 'ভ্রাম্যমাণ');
  x = x.replace(/ভ্রুক্ষেপ/g, 'ভ্রূক্ষেপ');
  x = x.replace(/মজুরী/g, 'মজুরি');
  x = x.replace(/মণিষা/g, 'মনীষা');
  x = x.replace(/মনমালিন্য/g, 'মনোমালিন্য');
  x = x.replace(/মনিষী/g, 'মনীষী');
  x = x.replace(/মন্ত্রনালয়/g, 'মন্ত্রণালয়');
  x = x.replace(/ময়ুর/g, 'ময়ূর');
  x = x.replace(/মরুদ্যান/g, 'মরূদ্যান');
  x = x.replace(/মশারী/g, 'মশারি');
  x = x.replace(/মস্তিস্ক/g, 'মস্তিষ্ক');
  x = x.replace(/মহত্ত/g, 'মহত্ত্ব');
  x = x.replace(/মহামতী/g, 'মহামতি');
  x = x.replace(/মহামারি/g, 'মহামারী');
  x = x.replace(/মহিয়সী/g, 'মহীয়সী');
  x = x.replace(/ মাংশ /g, ' মাংস ');
  x = x.replace(/মানিক্য/g, 'মানিক');
  x = x.replace(/মাসী/g, 'মাসি');
  x = x.replace(/মাহাত্ম/g, 'মাহাত্ম্য');
  x = x.replace(/মিতালী/g, 'মিতালি');
  x = x.replace(/মিমাংসা/g, 'মীমাংসা');
  x = x.replace(/মিরিচিকা/g, 'মরীচিকা');
  x = x.replace(/মুখস্ত/g, 'মুখস্থ');
  x = x.replace(/মুঢ়/g, 'মূঢ়');
  x = x.replace(/মুত্র/g, 'মূত্র');
  x = x.replace(/মুদ্রন/g, 'মুদ্রণ');
  x = x.replace(/মুমুর্ষ/g, 'মুমূর্ষু');
  x = x.replace(/মুর্খ/g, 'মূর্খ');
  x = x.replace(/মুর্তি/g, 'মূর্তি');
  x = x.replace(/মুর্ধন্য/g, 'মূর্ধন্য');
  x = x.replace(/মুষ্ঠি/g, 'মুষ্টি');
  x = x.replace(/মুহুর্ত/g, 'মুহূর্ত');
  x = x.replace(/মুহূর্মুহু/g, 'মুহুর্মুহু');
  x = x.replace(/মুহ্যবান/g, 'মোহ্যমান/মুহ্যমান');
  x = x.replace(/মূখ্য/g, 'মুখ্য');
  x = x.replace(/মূল্যায়ণ/g, 'মূল্যায়ন');
  x = x.replace(/মৃয়মান/g, 'ম্রিয়মাণ');
  x = x.replace(/মোটামোটি/g, 'মোটামুটি');
  x = x.replace(/মৌনতা/g, 'মৌন');
  x = x.replace(/যক্ষা/g, 'যক্ষ্মা');
  x = x.replace(/যথেষ্ঠ/g, 'যথেষ্ট');
  x = x.replace(/যদ্যাপি/g, 'যদ্যপি');
  x = x.replace(/যন্ত্রনা/g, 'যন্ত্রণা');
  x = x.replace(/যাদুঘর/g, 'জাদুঘর');
  x = x.replace(/রংগ/g, 'রঙ্গ');
  x = x.replace(/রঙিণ/g, 'রঙিন');
  x = x.replace(/রঙ্গিণ/g, 'রঙ্গিন');
  x = x.replace(/রথি/g, 'রথী');
  x = x.replace(/রসায়ণ/g, 'রসায়ন');
  x = x.replace(/রাংগামাটি/g, 'রাঙ্গামাটি');
  x = x.replace(/রামায়ন/g, 'রামায়ণ');
  x = x.replace(/রাষ্ট্রিয়/g, 'রাষ্ট্রীয়');
  x = x.replace(/রূপায়ন/g, 'রূপায়ণ');
  x = x.replace(/রোপন/g, 'রোপণ');
  x = x.replace(/লংকা/g, 'লঙ্কা');
  x = x.replace(/লংঘন/g, 'লঙ্ঘন');
  x = x.replace(/লক্ষী/g, 'লক্ষ্মী');
  x = x.replace(/লক্ষ্যণীয়/g, 'লক্ষণীয়');
  x = x.replace(/লঘুকরণ/g, 'লঘূকরণ');
  x = x.replace(/লজ্জাষ্কর/g, 'লজ্জাকর');
  x = x.replace(/লবন/g, 'লবণ');
  x = x.replace(/লাইব্রেরী/g, 'লাইব্রেরি');
  x = x.replace(/লাবন্য/g, 'লাবণ্য');
  x = x.replace(/শংকর/g, 'শঙ্কর');
  x = x.replace(/শংকা/g, 'শঙ্কা');
  x = x.replace(/শংকিত/g, 'শঙ্কিত');
  x = x.replace(/শরীক/g, 'শরিক');
  x = x.replace(/শশাংক/g, 'শশাঙ্ক');
  x = x.replace(/শশুর/g, 'শ্বশুর');
  x = x.replace(/শশ্মান/g, 'শ্মশান');
  x = x.replace(/শাড়ী/g, 'শাড়ি');
  x = x.replace(/শাষণ/g, 'শাসন');
  x = x.replace(/শারীরীক/g, 'শারীরিক');
  x = x.replace(/শাশুড়ী/g, 'শাশুড়ি');
  x = x.replace(/শিক্ষাঙ্গন/g, 'শিক্ষাঙ্গণ');
  x = x.replace(/শিরচ্ছেদ/g, 'শিরশ্ছেদ');
  x = x.replace(/শিরধার্য/g, 'শিরোধার্য');
  x = x.replace(/শিরনাম/g, 'শিরোনাম');
  x = x.replace(/শিরমণি/g, 'শিরোমণি');
  x = x.replace(/শুভাকাংখী/g, 'শুভাকাঙ্খী');
  x = x.replace(/শুশ্রুষা/g, 'শুশ্রূষা');
  x = x.replace(/শূণ্য/g, 'শুন্য');
  x = x.replace(/শৃংখলা/g, 'শৃঙ্খলা');
  x = x.replace(/শ্বাশত/g, 'শাশ্বত');
  x = x.replace(/শ্রদ্ধাঞ্জলী/g, 'শ্রদ্ধাঞ্জলি');
  x = x.replace(/শ্রদ্ধাভাজনীয়/g, 'শ্রদ্ধাভাজন');
  x = x.replace(/শ্রদ্ধাষ্পদ/g, 'শ্রদ্ধাস্পদ');
  x = x.replace(/শ্রমজীবি/g, 'শ্রমজীবী');
  x = x.replace(/শ্রাবন/g, 'শ্রাবণ');
  x = x.replace(/শ্রীমতি/g, 'শ্রীমতী');
  x = x.replace(/শ্রেষ্ট/g, 'শ্রেষ্ঠ');
  x = x.replace(/ষষ্ট/g, 'ষষ্ঠ');
  x = x.replace(/ষষ্ঠদশ/g, 'ষোড়শ');
  x = x.replace(/সংগা/g, 'সংজ্ঞা');
  x = x.replace(/সংগী/g, 'সঙ্গী');
  x = x.replace(/সখ/g, 'শখ');
  x = x.replace(/সতীন/g, 'সতিন');
  x = x.replace(/সত্বেও/g, 'সত্ত্বেও');
  x = x.replace(/সত্যয়িত/g, 'সত্যায়িত');
  x = x.replace(/সদ্যজাত/g, 'সদ্যোজাত');
  x = x.replace(/সদ্যস্নাত/g, 'সদ্যঃস্নাত');
  x = x.replace(/সনাক্ত/g, 'শনাক্ত');
  x = x.replace(/সন্মান/g, 'সম্মান');
  x = x.replace(/সন্মানীত/g, 'সম্মানীত');
  x = x.replace(/সন্মুখ/g, 'সম্মুখ');
  x = x.replace(/সন্মেলন/g, 'সম্মেলন');
  x = x.replace(/সমীচিন/g, 'সমীচীন');
  x = x.replace(/সম্বরণ/g, 'সংবরণ');
  x = x.replace(/সম্বর্ধনা/g, 'সংবর্ধনা');
  x = x.replace(/সম্বলিত/g, 'সংবলিত');
  x = x.replace(/সরকারী/g, 'সরকারি');
  x = x.replace(/সরণী/g, 'সরণি');
  x = x.replace(/সরনী/g, 'সরণি');
  x = x.replace(/সর্বাঙ্গীন/g, 'সর্বাঙ্গীণ');
  x = x.replace(/সলজ্জিত/g, 'সলজ্জ');
  x = x.replace(/সশংকিত/g, 'সশঙ্ক');
  x = x.replace(/সহকারি/g, 'সহকারী');
  x = x.replace(/সাংগ/g, 'সাঙ্গ');
  x = x.replace(/সাক্ষাতকার/g, 'সাক্ষাৎকার');
  x = x.replace(/সাড়াশী/g, 'সাঁড়াশি');
  x = x.replace(/সাধারন/g, 'সাধারণ');
  x = x.replace(/সান্তনা/g, 'সান্ত্বনা');
  x = x.replace(/সামগ্রীক/g, 'সামগ্রিক');
  x = x.replace(/সৌখিন/g, 'শৌখিন');
  x = x.replace(/স্বচ্ছল/g, 'সচ্ছল');
  x = x.replace(/স্বরস্বতী/g, 'সরস্বতী');
  x = x.replace(/স্বস্ত্রীক/g, 'সস্ত্রীক');
  x = x.replace(/স্বাতন্ত্র/g, 'স্বাতন্ত্র্য');
  x = x.replace(/স্বাধীকার/g, 'স্বাধিকার');
  x = x.replace(/স্বায়ত্ত্বশাসন/g, 'স্বায়ত্তশাসন');
  x = x.replace(/স্মরন/g, 'স্মরণ');
  x = x.replace(/স্রোতঃস্বতী/g, 'স্রোতস্বতী');
  x = x.replace(/হীনমন্যতা/g, 'হীনম্মন্যতা');
  x = x.replace(/হৃদপিণ্ড/g, 'হৃৎপিণ্ড');
  x = x.replace(/হৃদস্পন্দন/g, 'হৃৎস্পন্দন');
  x = x.replace(/হৃৎরোগ/g, 'হৃদরোগ');

//added by YAHYA
    x = x.replace(/আঘাট/g, 'আঘাত');
    x = x.replace(/সাংঘাটিক/g, 'সাংঘাতিক');
    x = x.replace(/আবিস্কার/g, 'আবিষ্কার');
    x = x.replace(/আনুসংগিক/g, 'আনুষঙ্গিক');
    x = x.replace(/শীততাপ/g, 'শীতাতপ');
    x = x.replace(/অতীষ্ঠ/g, 'অতিষ্ঠ');
    x = x.replace(/আষ্ফালন/g, 'আস্ফালন');
    x = x.replace(/আয়ত্ব/g, 'আয়ত্ত');
    x = x.replace(/ঐশ্চর্য/g, 'ঐশ্বর্য');
    x = x.replace(/ক্রুটি/g, 'ত্রুটি');
    x = x.replace(/অংকণ/g, 'অঙ্কন');
    x = x.replace(/কোরাণ/g, 'কোরান');
    x = x.replace(/খরছ/g, 'খরচ');
    x = x.replace(/আরো /g, 'আরও ');
    x = x.replace(/বাহ্যিক লিঙ্ক/g, 'বহিঃসংযোগ');
     x = x.replace(/বাহ্যিক লিংক/g, 'বহিঃসংযোগ');

//নতুন শব্দ এই লাইনের উপরে যোগ হবে।

    // wiki formatting
   x = x.replace(/। </g, '।<');
   x = x.replace(/! -/g, '!-');
   x = x.replace(/“।/g, '।”');
   x = x.replace(/। ”/g, '।”');
   x = x.replace(/! \|/g, '!|');
   x = x.replace(/! }/g, '!}');
   x = x.replace(/! !/g, '!!');
   x = x.replace(/। "/g, '।" ');
   x = x.replace(/! "/g, '!" ');

	// some more formatting for bnwiki
   x = x.replace(/ <ref>/g, '<ref>');
   x = x.replace(/ <ref /g, '<ref ');
   x = x.replace(/{{reflist/g, '{{সূত্র তালিকা');
   x = x.replace(/{{Reflist/g, '{{সূত্র তালিকা');
   x = x.replace(/<\/references>/g, '{{সূত্র তালিকা}}');

   // fixing error

     x = x.replace(/বৈচিত্র/g, 'বৈচিত্র্য');
     x = x.replace(/বৈচিত্র্য্য/g, 'বৈচিত্র্য');
     x = x.replace(/তামুল/g, 'তামোল');
     x = x.replace(/ফূর্তি/g, 'স্ফূর্তি');
     x = x.replace(/স্ফুর্তি/g, 'স্ফূর্তি');
     x = x.replace(/স্স্স্ফূর্তি/g, 'স্ফূর্তি');
     x = x.replace(/স্স্ফূর্তি/g, 'স্ফূর্তি');
     x = x.replace(/নৈশব্দ/g, 'নৈঃশব্দ্য');
     x = x.replace(/নৈঃশব্দ/g, 'নৈঃশব্দ্য');
     x = x.replace(/নৈঃশব্দ্য্য্য/g, 'নৈঃশব্দ্য');
     x = x.replace(/নৈঃশব্দ্য্য/g, 'নৈঃশব্দ্য');
     x = x.replace(/নৈঃশব্দ্যতা/g, 'নৈঃশব্দ্য');
     x = x.replace(/বৈশিষ্ট্য্য/g, 'বৈশিষ্ট্য');
     x = x.replace(/নিরালস্য্য/g, 'নিরালস্য');
     x = x.replace(/দৈর্ঘ্য্য/g, 'দৈর্ঘ্য');
     x = x.replace(/কেচাঁ/g, 'কেঁচা');
     x = x.replace(/কেঁচাঁ/g, 'কেঁচা');
     x = x.replace(/অন্তঃসত্বা/g, 'অন্তঃসত্ত্বা');
     x = x.replace(/অন্তসত্তা/g, 'অন্তঃসত্ত্বা');
     x = x.replace(/অন্তঃসত্তা/g, 'অন্তঃসত্ত্বা');
     x = x.replace(/ন্দ্ব্ব/g, 'ন্দ্ব');
     x = x.replace(/ধ্ব্ব/g, 'ধ্ব');
     x = x.replace(/ত্ব্ব/g, 'ত্ব');
     x = x.replace(/ঁঁ/g, 'ঁ');
     x = x.replace(/মাননি\u09DF/g, 'মাননী\u09DF');
     x = x.replace(/মাননিয়/g, 'মাননীয়');
     x = x.replace(/বিদূষী/g, 'বিদুষী');
     x = x.replace(/বয়সীয়াল/g, 'বয়সিয়াল');
     x = x.replace(/রিস্কা/g, 'রিক্সা');
     //x = x.replace(/অনসুয়া/g, 'অনসূয়া');
     x = x.replace(/অনুসূয়া/g, 'অনসুয়া');
     x = x.replace(/মুমূর্ষুু/g, 'মুমূর্ষু');
     x = x.replace(/নিরবিচ্ছিন্ন/g, 'নিরবচ্ছিন্ন');
     x = x.replace(/ণ্ধ/g, 'ন্ধ');

    // removes double space between anything
    x = x.replace(/  /g, ' '); // makes double space into one
    x = x.replace(/   /g, ' '); //makes triple space into one

    x = x.replace(/য়/g, '\u09DF');

   $('#wpTextbox1').val(x);
     customAlert('বানান শুদ্ধি সম্পন্ন!','3000');
                        }
                    }
                }
            }
        });

    };
    
/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar … */
    if ($.inArray(mw.config.get('wgAction'), ['edit', 'submit']) !== -1) {
        $.when(mw.loader.using('ext.wikiEditor'), $.ready)
            .then(bnSpellChecker);
    }
});


// This script aligns dates into one of two formats allowed by [[WP:MOSNUM]].
// PLEASE READ THE DOCUMENTATION at [[User:Ohconfucius/script/MOSNUM dates]] (click on the link above) before using.

// Feedback and constructive criticism are welcome

/**
 * TemplateScript adds configurable templates and scripts to the sidebar, and adds an example regex editor.
 * @see https://meta.wikimedia.org/wiki/TemplateScript
 */
// <pre>
if ($.inArray(mw.config.get('wgAction'), ['edit', 'submit']) !== -1) {
	$.ajax(
		'//tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js',
		{dataType: 'script', cache: true}
	).done(function () {
		$.when(
			mw.loader.using(['mediawiki.util']),
			$.ajax('//en.wikipedia.org/w/index.php?title=User:Ohconfucius/script/MOSNUM_utils.js&action=raw&ctype=text/javascript',
				{dataType: 'script', cache: true}),
			$.ready
		).done(function () {
			var add = function() {
            return mw.util.addPortletLink.apply(mw.util, arguments);
			};

			$(add('p-tb', '#', 'DATES to dmy', 'dmy-unitfixer', 'Align all dates to dmy', '', '')).click(ohc_all_to_dmy_driver);
			$(add('p-tb', '#', 'DATES to mdy', 'mdy-unitfixer', 'Align all dates to mdy', '', '')).click(ohc_all_to_mdy_driver);
//			$(add('p-tb', '#', 'Expand ref dates', 't-expandref', 'Expand month names within refs', '', '')).click(ohc_expand_ref_dates_driver);
//			$(add('p-tb', '#', 'Expand all dates', 't-expandall', 'Expand month names throughout', '', '')).click(ohc_expand_all_dates_driver);
			$( add('p-tb', '#', 'US-slash dates', 't-US', 'US-slash', '', '') ).click(ohc_US_slash_dates_driver);
			$( add('p-tb', '#', 'UK-slash dates', 't-UK', 'UK-slash', '', '') ).click(ohc_UK_slash_dates_driver);
		});
	});
}

function ohc_fix_unambiguous_dates()
{
	// resolvable ambiguous date formats
	// UK style
	ohc_regex(/([^-\w/:\.])@DD\.@MM\.@YYYY(?=[^-–/\w&])/gi, "$1@Day @Month @YYYY", function(d) {
		if (d.d == d.m) return true;
		if (d.d > 12) return true;
		return false;
		});
	ohc_regex(/([^-\w/:\.])@DD\/@MM\/@YYYY(?=[^-–/\w&])/gi, "$1@Day @Month @YYYY", function(d) {
		if (d.d == d.m) return true;
		if (d.d > 12) return true;
		return false;
		});

	// US style
	ohc_regex(/([^-\w/:\.])@MM\.@DD\.@YYYY(?=[^-–/\w&])/gi, "$1@Month @Day, @YYYY", function(d) {
		if (d.d > 12) return true;
		return false;
		});
	ohc_regex(/([^-\w/:\.])@MM\/@DD\/@YYYY(?=[^-–/\w&])/gi, "$1@Month @Day, @YYYY", function(d) {
		if (d.d > 12) return true;
		return false;
		});
}

function ohc_US_slash_dates_to_mdy()
{
//ranges
	ohc_regex(/([^-\d/:\.])@MM\/@DD\/@YYNN(&nbsp;|\s)?(?:(?:[-–—]|&[mn]dash;)(?:&nbsp;|\s)?)@MM\/@DD\/@YYNN(?=[^-–/\w&])/gi, "$1@Mon1 @Day1, @Year1$2 – @Mon2 @Day2, @Year2");
	ohc_regex(/([^-\d/:\.])@MM\.@DD\.@YYNN(&nbsp;|\s)?(?:(?:[-–—]|&[mn]dash;)(?:&nbsp;|\s)?)@MM\.@DD\.@YYNN(?=[^-–/\w&])/gi, "$1@Mon1 @Day1, @Year1$2 – @Mon2 @Day2, @Year2");
	ohc_regex(/(\| ?)@MM\/@DD\/@YYNN(&nbsp;|\s)?(?:(?:[-–—]|&[mn]dash;)(?:&nbsp;|\s)?)@MM\/@DD\/@YYNN(?=\s*\|)/gi, "$1@Mon1 @Day1, @Year1$2 – @Mon2 @Day2, @Year2");
	ohc_regex(/(\| ?)@MM\.@DD\.@YYNN(&nbsp;|\s)?(?:(?:[-–—]|&[mn]dash;)(?:&nbsp;|\s)?)@MM\.@DD\.@YYNN(?=\s*\|)/gi, "$1@Mon1 @Day1, @Year1$2 – @Mon @Day2, @Year2");

// resolvable ambiguous date formats
	ohc_regex(/([^-\d/:\.])@MM\/@DD\/@YYNN(?=[^-–/\w&])/gi, '$1@Month @Day, @YYYY');
	ohc_regex(/([^-\d/:\.])@MM\.@DD\.@YYNN(?=[^-–/\w&])/gi, '$1@Month @Day, @YYYY');
	ohc_regex(/([^-\d/:\.])@MM[-–]@DD[-–]@YYNN(?=[^-–/\w&])/gi, '$1@Month @Day, @YYYY');
	ohc_regex(/(\| ?)@MM\/@DD\/@YYNN(?=\s*\|)/gi, '$1@Month @Day, @YYYY');
	ohc_regex(/(\| ?)@MM\.@DD\.@YYNN(?=\s*\|)/gi, '$1@Month @Day, @YYYY');
//	ohc_regex(/(\| ?)@MM[-–]@DD[-–]@YYNN(?=\s*\|)/gi, '$1@Month @Day, @YYYY');
}
 
function ohc_UK_slash_dates_to_dmy()
{
//ranges
	ohc_regex(/([^-\d/:\.])@DD\/@MM\/@YYNN(&nbsp;|\s)?(?:(?:[-–—]|&[mn]dash;)(?:&nbsp;|\s)?)@DD\/@MM\/@YYNN(?=[^-–/\w&])/gi, "$1@Day1 @Mon1 @Year1$2 – @Day2 @Mon2 @Year2");
	ohc_regex(/([^-\d/:\.])@DD\.@MM\.@YYNN(&nbsp;|\s)?(?:(?:[-–—]|&[mn]dash;)(?:&nbsp;|\s)?)@DD\.@MM\.@YYNN(?=[^-–/\w&])/gi, "$1@Day1 @Mon1 @Year1$2 – @Day2 @Mon2 @Year2");
	ohc_regex(/(\| ?)@DD\/@MM\/@YYNN(&nbsp;|\s)?(?:(?:[-–—]|&[mn]dash;)(?:&nbsp;|\s)?)@DD\/@MM\/@YYNN(?=\s*\|)/gi, "$1@Day1 @Mon1 @Year1$2 – @Day2 @Mon2 @Year2");
	ohc_regex(/(\| ?)@DD\.@MM\.@YYNN(&nbsp;|\s)?(?:(?:[-–—]|&[mn]dash;)(?:&nbsp;|\s)?)@DD\.@MM\.@YYNN(?=\s*\|)/gi, "$1@Day1 @Mon1 @Year1$2 – @Day2 @Mon2 @Year2");

// resolvable ambiguous date formats
	ohc_regex(/([^-\d/:\.])@DD\/@MM\/@YYNN(?=[^-–/\w&])/gi, '$1@Day @Month @YYYY');
	ohc_regex(/([^-\d/:\.])@DD\.@MM\.@YYNN(?=[^-–/\w&])/gi, '$1@Day @Month @YYYY');
	ohc_regex(/([^-\d/:\.])@DD[-–]@MM[-–]@YYNN(?=[^-–/\w&])/gi, '$1@Day @Month @YYYY');
	ohc_regex(/(\| ?)@DD\/@MM\/@YYNN(?=\s*\|)/gi, '$1@Day @Month @YYYY');
	ohc_regex(/(\| ?)@DD\.@MM\.@YYNN(?=\s*\|)/gi, '$1@Day @Month @YYYY');
//	ohc_regex(/(\| ?)@DD[-–]@MM[-–]@YYNN(?=\s*\|)/gi, '$1@Day @Month @YYYY');
}

function ohc_remove_leading_zeroes()
{
	ohc_regex(/(\D[^\w\/])@Month\s@ZD@th?,?\s@YYYY(?=\W\D)/gi, "$1@LMonth @Day, @LYear");
	ohc_regex(/(\D[^\w\/])@Month\s@ZD@th?(?=\W\D)/gi, "$1@LMonth @Day");
	ohc_regex(/(\D[^\w\/])@ZD@th?\s@Month\s@YYYY(?=\W\D)/gi, "$1@Day @LMonth @LYear");
	ohc_regex(/(\D[^\w\/])@ZD@th?\s@Month(?=\W\D)/gi, "$1@Day @LMonth");
}

function ohc_delink_dates()
{
	//add missing space between wikilinks
	regex(/(\]\])(\[\[)/gi, '$1 $2');  //remove (?!file:) to ensure a space between all links
 
	 // rem redundant quote marks and parentheses
	regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)\'\'\'([^|}\[\]]*)\'\'\'(?=\s*[|}])/gi, "$1$2");
	regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)\'\'([^|}\[\]]*)\'\'(?=\s*[|}])/gi, "$1$2");
	regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)\"([^|}\[\]]*)\"(?=\s*[|}])/gi, "$1$2");
	regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)\(([^|}\[\]]*)\)(?=\s*[|}])/gi, "$1$2");

//delink unpiped dates
	//delink full dates
	ohc_regex(/\[\[@Day[\s_](?:of[\s_])?@Month(?:\]\]\s?\[\[\| )@YYYY\]\]/gi, "@Day @LMonth @YYYY");
	ohc_regex(/\[\[@Month (?:the\s)?@Day(?:\]\],? \[\[|, )@YYYY\]\]/gi, "@LMonth @Day, @YYYY");

	//delink yyyy-mm-dd dates
	ohc_regex(/\[\[@YYYY(?:\]\]-\[\[|-)@MM-@DD\]\]/gi, "@YYYY-@MM-@DD");
	ohc_regex(/@YYYY-\[\[@MM-@DD\]\]/gi, "@YYYY-@MM-@DD");

	//underscore and nbsp in linked dates
	ohc_regex(/\[\[@DD@th?(?:\s|_|&nbsp;)@Month\]\]/gi, "@Day @LMonth");
	ohc_regex(/\[\[@Month(?:\s|_|&nbsp;)@DD@th?\]\]@th?/gi, "@LMonth @Day"); //consolidated regex with flexible removal of ordinal simple date
	ohc_regex(/\[\[@Day @Month\]\]/gi, "@Day @LMonth");
	ohc_regex(/\[\[@Month @YYYY\]\]/gi, "@LMonth @YYYY");
	ohc_regex(/\[\[@YYYY\]\]/gi, "@YYYY");

	//remove leading zero and links from linked date
	ohc_regex(/\[\[@Month(?:[ _]|&nbsp;)@ZD@th\]\]/gi, "@LMonth @Day");
	ohc_regex(/\[\[@ZD@th(?:[ _]|&nbsp;)@Month\]\]/gi, "@Day @LMonth");

	// remove nowrap template from dm and md dates
	ohc_regex(/(date[ ]*=[ ]*)\{\{(?:j|no ?(?:break|wrap))\|(?:@DD(?:[ _]|&nbsp;)@Month)( @yyyy|)\}\}/gi, '$1@DD @LMonth$2');
	ohc_regex(/(date[ ]*=[ ]*)\{\{(?:j|no ?(?:break|wrap))\|(?:@Month(?:[ _]|&nbsp;)@DD)( @yyyy|)\}\}/gi, '$1@LMonth @DD$2');
	
	//delink single dm or 'dth the m'
	ohc_regex(/(?:the\s)?\[\[@Day@th?[\s_](?:of[\s_])?@Month\]\]/gi, "@Day @LMonth");
	//delink single md or 'm the dth'
	ohc_regex(/\[\[@Month[\s_](?:the[\s_])?@Day@th?\]\](?=\W)/gi, "@LMonth @Day");

//month+day piped
	ohc_regex(/\[\[(?:@dd@th?[\s_](?:of[\s_])?@month|@month[\s_]@dd@th?)\|((?:@month |)@day)@th?\]\]/gi, "$1");
	ohc_regex(/\[\[(?:@dd@th?[\s_](?:of[\s_])?@month|@month[\s_]@dd@th?)\|@Day@th?[\s_](@month|)\]\]/gi, "@Day $1");

//	ohc_regex(/\[\[@month @dd(?:#[^|]+|)\|([^|\]]+)@th?\]\]/gi, "$1");
//	ohc_regex(/\[\[@dd @month(?:#[^|]+|)\|([^|\]]+)@th?\]\]/gi, "$1");
	ohc_regex(/\[\[@month @yyyy(?:#[^|]+|)\|([^|\]]+)\]\]/gi, "$1");

	//month+day+year pseudo-ISO dates
	ohc_regex(/\[\[@Month @DD\|\d\d-\d\d\]\]-(?:\[\[)?(?:@yyyy[^|]*\|)?@YYYY(?:\]\])/gi, "@Day @LMonth @YYYY");
	ohc_regex(/\[\[@DD\s@Month\|\d\d-\d\d\]\]-(?:\[\[)?(?:@yyyy[^|]*\|)?@YYYY(?:\]\])/gi, "@Day @LMonth @YYYY");

	//'[[month day|xxXxx]]Xyyyy ' to 'month day, year'
	ohc_regex(/\[\[@Month\s@Day\|@dd.@dd\]\].@YYYY/gi, "@LMonth @Day, @YYYY");
	 //'[[day month|xxXxx]]Xyyyy' to 'day month year'
	ohc_regex(/\[\[@Day\s@Month\|@dd.@dd\]\].@YYYY/gi, "@Day @LMonth @YYYY");

// century
	regex(/\[\[((?:first|second|third|(?:four|fif|six|seven|eigh|nin|ten|eleven|twelf|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twentie)th|twenty[\s\-]first[\s\-])centur(?:y|ies)(?:\s(?:AD|BC|CE|BCE))?)\]\]/gi, '$1');
	regex(/\[\[(?:first|second|third|(?:four|fif|six|seven|eigh|nin|ten|eleven|twelf|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twentie)th|twenty[\s\-]first)[\s\-_]centur(?:y|ies)(?:\s(?:AD|BC|CE|BCE))?\|([^\]]{1,30})\]\]/gi, '$1');
	regex(/\[\[(\d{1,2}(?:st|[nr]d|th))[\s\-_](centur(?:y|ies))(\s(?:AD|BC|CE|BCE)|)\]\]/gi, '$1 $2$3');
	ohc_regex(/\[\[\d{1,2}@th[\s\-_]centur(?:y|ies)(?:\s(?:AD|BC|CE|BCE)|)\|([^\]]{1,30})\]\]/gi, '$1');

	// months
	ohc_regex(/\[\[@Month\]\]/gi, "@LMonth");
	ohc_regex(/\[\[@FullMonth\|([^\]]{1,30})\]\]/gi, "$1");

	// decades and years
	regex(/(\d{1,3}0)[‘`´’′]?s/g, '$1s');
	regex(/\[\[(\d{1,3}0)\'?s\]\]/g, '$1s');
	regex(/\[\[\d{1,3}0\'?s?\|([^\]]{1,30})\]\]/g, '$1');
	regex(/\[\[(\d{1,3}0)\'?(s)?\s(AD|BC|CE|BCE)\]\]/gi, '$1$2 $3');
	regex(/\[\[(\d{1,4}[\s_]?)(AD|BC|CE|BCE)\]\]/gi, '$1$2');
	regex(/\[\[(AD|BC|CE|BCE)([\s_]?)(\d{1,4})\]\]/gi, '$1$2$3');
	ohc_regex(/([-–])\[\[\s?@yyyy\s?\|\s?(\d{2,4})\s?\]\]/gi, '$1$2'); //piped year
	regex(/\[\[([12]\d{3}|[1-9]\d{0,2})\]\]/gi, '$1');
	regex(/\[\[\d{1,3}0\'?s?\s(?:AD|BC|CE|BCE)\|([^\]]{1,30})\]\]/gi, '$1');
	regex(/\[\[\d{1,3}0\'?s?\s\(decade\)\|([^\]]{1,30})\]\]/gi, '$1');

	//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
	ohc_regex(/\[\[@yyyy in[^|\]]+\|@Day @Month @YYYY\]\]/gi, "@Day @LMonth @YYYY");
	ohc_regex(/\[\[@yyyy in[^|\]]+\|@Month @Day,? @YYYY\]\]/gi, "@LMonth @Day, @YYYY");
	ohc_regex(/\[\[@yyyy#[^|\]]+\|(@month\s|)(@yyyy)\]\]/gi, "$1$2");
	ohc_regex(/\[\[@yyyy#[^|\]]+\|(@month|@yyyy)\]\]/gi, "$1");
	ohc_regex(/\[\[(@month\s@yyyy)\]\]/gi, "$1");
	ohc_regex(/\[\[@month\s@yyyy\|([^\]]{1,30})\]\]/gi, "$1");
	ohc_regex(/\[\[(?:List of |)Bollywood films of @yyyy\|@YYYY\]\](?= [^\[]{2}^B)/gi, "@YYYY");

	ohc_regex(/(\[\[@yyyy[^|\]]+\|@yyyy)(\]\])( season)/gi, "$1$3$2");

	//removed piped years when in full date (excepting disambiguated parentheses - updated 24/2/2012)
//	ohc_regex(/\[\[[^|\]\(\)]{1,32}\|@YYYY\]\]/gi, '@Year');  // 23/6/2021 – disabled delinking "other" year-in articles

	//Identify surprise or 'Easter egg' diversions linking months to year or "year in" articles.
	ohc_regex(/\[\[\d{1,4}#[^|\]]+\|@Month\]\]/gi, "@LMonth");
	ohc_regex(/\[\[@yyyy \w[^|\]]{3,12}\|@Year\]\]/gi, '@Year');

	// month and day piped
	ohc_regex(/\[\[@month[\s_]@day\|@MM-@DD\]\]/gi, "@MM-@DD");
	ohc_regex(/\[\[@month[\s_]@day\|([^\]]{1,30})\]\]/gi, "$1");
	ohc_regex(/\[\[@day(?:\s|_|@th )(?:of[\s_]|)?@month\|([^\]]{1,30})\]\]/gi, "$1");

	//years piped
	regex(/\[\[\d{1,4}\|([^\]]{1,30})\]\]/gi, '$1');
}

function ohc_fix_common_errors()
{
	ohc_regex(/(\d)<sup>@th<\/sup>/gi, '$1th');
	// remove dashbot comment from dates
	regex(/<!-- ?DASHBot ?-->/gi, '');
	ohc_regex(/(\|\s*(?:date|year)\s*=)\s*c(?:irca|a\.)?\s?((?:@day |)@month @year)(?=[\s\n]*[<|}])/gi, '$1c. $2'); //add space
//common cs1 errors
	regex(/(\|\s*(?:date|year)\s*=)\s*(1[7-9]\d|20[0-1])\?(?=[\s\n]*[<|}])/gi, '$1c. $20'); 
	regex(/(\|\s*(?:date|year)\s*=\s*(1[7-9])\d{2})[-–](\d{2})(?=[\s\n]*[<|}])/gi, '$1–$2$3'); 
//	regex(/(\|\s*(?:date|year)\s*=\s*(20)[0-1]\d)[-–]([0-2]\d)(?=[\s\n]*[<|}])/gi, '$1–$2$3'); 
	regex(/(\|\s*(?:date|year)\s*=\s*)@YYYY\s*[-–/]\s*@YYYY(?=[\s\n]*[<|}])/gi, '$1@YYYY1–@YYYY2'); //common cs1 error
	regex(/(\|\s*(?:date)\s*=)\s*s(pring|ummer),?\s*((?:1[7-9]\d|20[0-1])\d)(?=[\s\n]*[<|}])/gi, '$1S$2 $3'); //common cs1 error
	regex(/(\|\s*(?:date)\s*=)\s*a(utumn),?\s*((?:1[7-9]\d|20[0-1])\d)(?=[\s\n]*[<|}])/gi, '$1A$2 $3'); //common cs1 error
	regex(/(\|\s*(?:date)\s*=)\s*f(all),?\s*((?:1[7-9]\d|20[0-1])\d)(?=[\s\n]*[<|}])/gi, '$1F$2 $3'); //common cs1 error
	regex(/(\|\s*(?:date)\s*=)\s*w(inter),?\s*((?:1[7-9]\d|20[0-1])\d)(?=[\s\n]*[<|}])/gi, '$1W$2 $3'); //common cs1 error
	ohc_regex(/(\|\s*access-?date\s*=)\s*(@month @year)(?=[\s\n]*[<|}])/gi, '$11 $2'); //common cs1 error
//	ohc_regex(/(\|\s*date\s*=\s*)@year\?(?=[\s\n]*[<|}])/gi, '$1@Year'); //common cs1 error
//	ohc_regex(/(\|\s*(?:date|year)\s*=)\s*@year\?(?=[\s\n]*[<|}])/gi, '$1c. @Year'); //common cs1 error
//	ohc_regex(/(\|\s*(?:date|year)\s*=)\s*(@month @year)\?(?=[\s\n]*[<|}])/gi, '$1c. $2'); //common cs1 error
	ohc_regex(/(\|\s*access-?date\s*=)\s*@month @day, (1[7-9]\d{2}|2000)(?=[\s\n]*[<|}])/gi, '$1'); //rem access date before Wikipedia (জানুয়ারি 2001)
	ohc_regex(/(\|\s*access-?date\s*=)\s*@day @month.? (1[7-9]\d{2}|2000)(?=[\s\n]*[<|}])/gi, '$1'); //rem access date before Wikipedia (জানুয়ারি 2001)
	ohc_regex(/(\|\s*access-?date\s*=)\s*31( (?:এপ্রিল|জুন|সেপ্টেম্বর|নভেম্বর) @year)(?=[\s\n]*[<|}])/gi, '$130$2'); //rem nonsense access date (short months)
	ohc_regex(/(\|\s*access-?date\s*=)\s*29( ফেব্রুয়ারি (?:200[1235679]|201[1345789]))(?=[\s\n]*[<|}])/gi, '$128$2'); //rem nonsense access date 29 ফেব্রুয়ারি (non-leap year)
	ohc_regex(/(\|\s*access-?date\s*=)\s*(?:3[01])( ফেব্রুয়ারি @yyyy)(?=[\s\n]*[<|}])/gi, '$128$2'); //rem nonsense access dates ফেব্রুয়ারি
	regex(/(\|\s*access-?date\s*=)\s*(\d{4})(?=[\s\n]*[<|}])/gi, ''); //common cs1 error
	
	//month+day+year pseudo-ISO dates
	ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*@dd)-@Mon-@YYYY/gi, "$1 @FullMonth @YYYY");
	ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@YYYY-@DD-@Mon/gi, "$1 @DD @FullMonth @YYYY");

	regex(/(\|\s*(?:date|year)\s*=)\s*(?:(?:date |)unknown|(?:not? |non-|un)date[ds])(?=[\s\n]*[<|}])/gi, '$1n.d.'); //common cs1 error
	regex(/(\|\s*(?:date|year)\s*=)\s*n\.?d(?=[\s\n]*[<|}])/gi, '$1n.d.'); //common cs1 error
	regex(/(\|\s*)year(\s*=\s*)(?=n\.?d\.)(?=[\s\n]*[<|}])/gi, '$1date$2'); //common cs1 error

   // remove parasitic metadata -  days of the week/descriptives
	ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)(?:[^|}\d]*|)@Day\s+@Month\s+@YYYY((?:[a-z]\b|)\s?)[^|<}]*(?=[\s\n]*[<|}])/gi, "$1@Day @Month @YYYY$2"); //rem negate "<", "hyphens" "dashes" 26/6/2020
	ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)[^|}]*@Month\s+@Day,\s+@YYYY((?:[a-z]\b|)\s?)[^|<}]*(?=[\s\n]*[<|}])/gi, "$1@Month @Day, @YYYY$2"); //rem negate "<", "hyphens" "dashes" 26/6/2020
//	ohc_regex(/(\|\s*date\s*=\s*)(?:[^|}–<]*\D|)@Day\s+@Month\s+@YYYY ?– ?@Day\s+@Month\s+@YYYY[^|}–<]*(?=[\s\n]*[<|}])/gi, "$1@Day1 @Mon1 @Year1 – @Day2 @Mon2 @Year2");
//	ohc_regex(/(\|\s*date\s*=\s*)[^|}–<]*@Month\s+@Day,\s+@YYYY ?– ?@Month @Day, @YYYY[^|}–<]*(?=[\s\n]*[<|}])/gi, "$1@Mon1 @Day1, @Year1 – @@Mon2 Day2, @Year2");
//	regex(/(\|\s*author\s*=\s*)(?:posted|published)(?: by\b| on\b|)[\s:](?=\w)/gi, "$1");
//	regex(/(\|\s*(?:date|archive-?date|access-?date|author|year)\s*=\s*)(?:accessed|retrieved|entered|posted|published|(?:last |)updated?|©)(?: by\b| on\b|)[\s:]*(?=\w)/gi, "$1");
	regex(/(\|\s*(?:author|first|last)\s*=\s*)(?:by\b|on\b)[\s:]*(?=\w)/gi, "$1");
	regex(/(\|\s*(?:date|archive-?date|access-?date|author|first|last)\s*=\s*)(?:(?:Mon|Tues|Wednes|Thurs|Fri|Satur|Sun)day,?)\s/gi, "$1");
	regex(/(\|\s*(?:date|archive-?date|access-?date|author|first|last)\s*=\s*)(?:Mon|Tues?|Wed|Thur?|Fri|Sat)[\.,]?\s/gi, "$1"); //<!-- rem "Sun" - false positives -->

   // remove deprecated parameters (|day= and |month)
 	ohc_regex(/(\|\s*)day(?:\s*=\s*)@DD ?\| ?month(?:\s*=\s*)@Month ?\| ?year(?:\s*=\s*)@YYYY(?=[|}\s])/gi, '$1date=@Day @Month @Year'); 
 	ohc_regex(/(\|\s*)year(?:\s*=\s*)@YYYY ?\| ?month(?:\s*=\s*)@Month ?\| ?day(?:\s*=\s*)@DD(?=[|}\s])/gi, '$1date=@Month @Day, @Year'); 
 	
// typos
	ohc_regex(/(date *= *)@Day @Month ?@th/gi, '$1@Day @Month'); 
	ohc_regex(/(date *= *)@Day @Month\w(?= \d{3,4})/gi, '$1@Day @Month'); 

	ohc_regex(/(date *= *(?:[12]?\d|30|31) )(জানুয়ারি|Febr)[\w ]?[aur]{3,4}\w{0,2}(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1$2uary'); 
	ohc_regex(/(date *= *(?:[12]?\d|30|31) )J[anu]{3,5}r\w{0,2}(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1জানুয়ারি');
	ohc_regex(/(date *= *(?:[12]?\d) )Febua?r\w{0,2}(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1ফেব্রুয়ারি');
	ohc_regex(/(date *= *(?:[12]?\d|30|31) )M\w{2,3}ch(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1মার্চ'); 
	ohc_regex(/(date *= *(?:[12]?\d|30) )A[bpv\[]\w{2,3}l\w?(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1এপ্রিল');
	ohc_regex(/(date *= *(?:[12]?\d|30|31) )Ma[tui](?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1মে'); 
	ohc_regex(/(date *= *(?:[12]?\d|30) )J\wn\w(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1জুন'); 
	ohc_regex(/(date *= *(?:[12]?\d|30) )J\w{1,2}e(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1জুন'); 
	ohc_regex(/(date *= *(?:[12]?\d|30|31) )জুলাই\w{1,2}(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1জুলাই'); 
	ohc_regex(/(date *= *(?:[12]?\d|30|31) )A[oug]{2,3}\w{1,4}t(?:\w|us)?(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1আগষ্ট'); 
	ohc_regex(/(date *= *(?:[12]?\d|30|31) )(সেপ্টেম্বর|নভেম্বর|ডিসেম্বর)\w{2,4}b[er]{1,2}\w?(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1$2ember'); 
	ohc_regex(/(date *= *(?:[12]?\d|30) )S\w{0,2}p[ \[]?\w{2,5}[er]{2,3}\w?(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1সেপ্টেম্বর'); 
	ohc_regex(/(date *= *(?:[12]?\d|30|31) )O\w{0,2}t\w{1,3}[er]{2,3}\w?(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1অক্টোবর'); 
	ohc_regex(/(date *= *(?:[12]?\d|30) )[MN]\w{1,2}[bv] ?\w{1,3}b[er]{1,2}\w?(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1নভেম্বর'); 
	ohc_regex(/(date *= *(?:[12]?\d|30|31) )D[ie]?[cs] ?\w{1,4}b[er]{1,2}\w?(?= (?:1[6-9]\d|20[01])\d\b)/gi, '$1ডিসেম্বর'); 

	ohc_regex(/(date *= *)@Month\w(?=(?: (?:[12]?\d|30|31),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1@Month'); //rem stray digit at the end of year string
 
	ohc_regex(/(date *= *)(জানুয়ারি|Febr)[\w ]?[aur]{3,4}\w{0,2}(?=(?: (?:[12]?\d|30|31),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1$2uary'); 
	ohc_regex(/(date *= *)J[anu]{3,5}r\w{0,2}(?=(?: (?:[12]?\d|30|31),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1জানুয়ারি');
	ohc_regex(/(date *= *)Febua?r\w{0,2}(?=(?: (?:[12]?\d),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1ফেব্রুয়ারি');
	ohc_regex(/(date *= *)M\w{2,3}ch(?=(?: (?:[12]?\d|30|31),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1মার্চ'); 
	ohc_regex(/(date *= *)A[bpv\[]\w{2,3}l\w?(?=(?: (?:[12]?\d|30),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1এপ্রিল');
	ohc_regex(/(date *= *)Ma[tui](?=(?: (?:[12]?\d|30|31),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1মে'); 
	ohc_regex(/(date *= *)J\wn\w(?=(?: (?:[12]?\d|30),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1জুন'); 
	ohc_regex(/(date *= *)J\w{1,2}e(?=(?: (?:[12]?\d|30),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1জুন'); 
	ohc_regex(/(date *= *)জুলাই\w{1,2}(?=(?: (?:[12]?\d|30|31),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1জুলাই'); 
	ohc_regex(/(date *= *)A[oug]{2,3}\w{1,4}t(?:\w|us)?(?=(?: (?:[12]?\d|30|31),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1আগষ্ট'); 
	ohc_regex(/(date *= *)(সেপ্টেম্বর|নভেম্বর|ডিসেম্বর)\w{2,4}b[er]{1,2}\w?(?=(?: (?:[12]?\d|30|31),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1$2ember'); 
	ohc_regex(/(date *= *)S\w{0,2}p[ \[]?\w{2,5}[er]{2,3}\w?(?=(?: (?:[12]?\d|30),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1সেপ্টেম্বর'); 
	ohc_regex(/(date *= *)O\w{0,2}t\w{1,3}[er]{2,3}\w?(?=(?: (?:[12]?\d|30|31),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1অক্টোবর'); 
	ohc_regex(/(date *= *)[MN]\w{1,2}[bv] ?\w{1,3}b[er]{1,2}\w?(?=(?: (?:[12]?\d|30),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1নভেম্বর'); 
	ohc_regex(/(date *= *)D[ie]?[cs] ?\w{1,4}b[er]{1,2}\w?(?=(?: (?:[12]?\d|30|31),?|) (?:1[6-9]\d|20[01])\d\b)/gi, '$1ডিসেম্বর'); 

//insert comma to separate date from army unit
	ohc_regex(/@FullMonth ((?:the |)\d\d*@th (?:Air(?:borne|)|Arm(?:ou?red|y)|Artillery|Battalion|Brigade|Co(?:mpan|)y|Division|Fleet|Group|Infantry|Land|Panzer|Regiment|Squadron|Sqn)\b)/g, "@Month, $1");

	// remove parasitic metadata - time
	ohc_regex(/(\|\s*\w*date\s*=\s*@yyyy-@mm-@dd)\s?(?:T[0-2]\d:[0-5]\d:[0-5]\d(?:\s*|&nbsp;|)(?:GMT\s*|UTC\s*|[A-Z]{1,2}[DS]T\s*|Z))(?=\s*[|}])/g, "$1");
	ohc_regex(/(\|\s*\w*date\s*=\s*@month @day,? @yyyy)\s?(?:,? [0-2]?\d[\.:][0-5]\d(?:\s*|&nbsp;)(?:[apAP][mM]\s*|)(?:GMT\s*|UTC\s*|[A-Z]{1,2}[DS]T\s*|))(?=\|)/g, "$1");
	ohc_regex(/(\|\s*\w*date\s*=\s*@day @month,? @yyyy)\s?(?:,? [0-2]?\d[\.:][0-5]\d(?:\s*|&nbsp;)(?:[apAP][mM]\s*|)(?:GMT\s*|UTC\s*|[A-Z]{1,2}[DS]T\s*|))(?=\|)/g, "$1");
	ohc_regex(/(\|\s*\w*date\s*=\s*\w[\w\s]+@month @day,? @yyyy)\s?(?:,? [0-2]?\d[\.:][0-5]\d(?:\s*|&nbsp;)(?:[apAP][mM]\s*|)(?:GMT\s*|UTC\s*|[A-Z]{1,2}[DS]T\s*|))(?=\|)/g, "$1");
	ohc_regex(/(\|\s*\w*date\s*=\s*\w[\w\s]+@day @month,? @yyyy)\s?(?:,? [0-2]?\d[\.:][0-5]\d(?:\s*|&nbsp;)(?:[apAP][mM]\s*|)(?:GMT\s*|UTC\s*|[A-Z]{1,2}[DS]T\s*|))(?=\|)/g, "$1");
	ohc_regex(/(\|\s*\w*date\s*=[^:|}]*)\s?(?:T?[0-2]\d:[0-5]\d:[0-5]\d(?:\s*|&nbsp;|)(?:GMT\s*|UTC\s*|[A-Z]{1,2}[DS]T\s*|Z))/g, "$1");

//  add back spaces or comma or remove other single artefact after date string	
	ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)(?:on |)@Day\s{,2}@Month\s{,2}@YYYY[^a-z{}]?(?=\s*[|}\n])/gi, "$1@Day @Month @YYYY$2");
	ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)(?:on |)@Month\s{,2}@Day,?\s{,2}@YYYY[^a-z{}]?(?=\s*[|}\n])/gi, "$1@Month @Day, @YYYY$2");
	//long-hand palliative for observed failure to insert spaces
	ohc_regex(/(\|\s*(?:archive|access|air)-?date\s*=\s*)(?:on |)([0-2]?\d|30|31)\s*(জানুয়ারি|ফেব্রুয়ারি|মার্চ|এপ্রিল|মে|জুন|জুলাই|আগষ্ট|সেপ্টেম্বর|অক্টোবর|নভেম্বর|ডিসেম্বর)\s*((?:19\d|20[0-1])\d\s?)[^|{}\s<>]*(?=\s*[|}])/gi, "$1$2 $3 $4");
//	ohc_regex(/(\|\s*(?:publication|)-?date\s*=\s*)(?:on |)@Day\s*@Month\s*@YYYY([a-z]\s?|\s?)\w*[^|{}<>]*(?=[|}])/gi, "$1@Day @Month @YYYY$2");
//	ohc_regex(/(\|\s*(?:publication|)-?date\s*=\s*)(?:on |)@Month\s*@Day,\s*@YYYY([a-z]\s?|\s?)\w*[^|{}<>]*(?=[|}])/gi, "$1@Month @Day, @YYYY$2");

//remove extraneous bracket //from Batty
	ohc_regex(/{{(\s*[Cc]it(?:e|ation))([^}]+)(\s*\|\s*(?:archive-?|access-?|publication-?)?date\s*=\s*)([\w\s-]+)\](?=\s*[\|}<])/gi, '{{$1$2$3$4');  

	//fix bda template redirect
//	regex(/\{\{bda\|([^}]+)\}\}/gi, '{{birth date and age|$1}}');
//	regex(/\{\{dda\|([^}]+)\}\}/gi, '{{death date and age|$1}}');

	//zap redundant {{date}}, {{accessdate}} {{retrieved}}, {{monthname}} and {{#dateformat}}
//	regex(/({{(?:end|start)[-–]date)\|df=y(?:es|)/gi, "$1"); //rem deprecated parameter - disabled: doesn't work here, so ejected to the formatting script
	ohc_regex(/{{#formatdate:@YYYY-@MM-@DD(?:[^\}]*)}}/gi, "@Day @Month @YYYY");
	regex(/{{#formatdate:([^}]+)}}/gi, "$1");
	regex(/\{\{#dateformat:([^}\|]+)(?:\|dmy|\|mdy)?\}\}/gi, '$1');
//	ohc_regex(/(date[ ]*=[ ]*)\{\{(?:Start|End) ?date(?:\|df=y(?:es|)|)\|@YYYY\|@MM\|@DD(?:\|df=y(?:es|)|)\}\}/gi, '$1@Month @DD, @YYYY');  //stripping start/end template notes inside "|date=" parameter (line 72)
	ohc_regex(/{{#formatdate:@YYYY-@MM-@DD(?:\|(?:[dmy]{3}|iso)|)}}/gi, "@Day @Month @YYYY");
	ohc_regex(/\{\{date\|@YYYY-@MM-@DD\}\}/gi, "@Day @Month @YYYY");
	ohc_regex(/\{\{date\|(@DD[\-\s]@Mon|@Mon[\-\s]@DD)\}\}/gi, "@Day @Month");
	regex(/\{\{date\|([^}\|]+)(?:\|l?(?:[dmy]{3}|iso|none|link))?\}\}/gi, '$1');
	ohc_regex(/[ ]*\{\{accessdate\|@YYYY-@MM-@DD[ ]*\}\}/gi, " Retrieved @YYYY-@MM-@DD");
	ohc_regex(/[ ]*\{\{retrieved[ ]*\|[ ]accessdate=([\-\w, ]*)\}\}/gi, " Retrieved $1");
//	ohc_regex(/(date[ ]*=[ ]*|\w{2,}[ ]*)\{\{(?:start|end).date[^|}]*(?:\|df=y(?:es|)|)\|@YYYY(?:\|df=y(?:es|)|)\}\}/gi, '$1@YYYY');  //stripping start/end template (disabling to placate Pigsonthewing)
//	ohc_regex(/\{\{(?:Start|End) date(?:\|df=y(?:es|)|)\|@YYYY\|@MM\}\}/gi, '@Month @YYYY')  //stripping start/end template notes
//	ohc_regex(/<!--(?:Use)? \{\{(?:Start|End) date\|@YYYY\|@MM\|@DD\}\} -->/gi, '');  //stripping start/end template notes
	ohc_regex(/(\{\{MONTHNAME\|@MM\}\})/gi, "@Month")

//expand one and two-digit years in ranges
	regex(/(\()@Month @YYYY[-–]@Month @YYNN(\))/gi, '$1@Month1 @YYYY1 – @Month2 @YYYY2$2');
	regex(/(\(1[789])(\d)(1)[-–]([2-9]\))/gi, '$1$2$3–$2$4');
	regex(/(\(1[789])(\d)(2)[-–]([3-9]\))/gi, '$1$2$3–$2$4');
	regex(/(\(1[789])(\d)(3)[-–]([4-9]\))/gi, '$1$2$3–$2$4');
	regex(/(\(1[789])(\d)(4)[-–]([5-9]\))/gi, '$1$2$3–$2$4');
	regex(/(\(1[789])(\d)(5)[-–]([6-9]\))/gi, '$1$2$3–$2$4');
	regex(/(\(1[789])(\d)(6)[-–]([7-9]\))/gi, '$1$2$3–$2$4');
	regex(/(\(1[789])(\d)(7)[-–]([8-9]\))/gi, '$1$2$3–$2$4');
	regex(/(\(1[789])(\d)(8)[-–](9\))/gi, '$1$2$3–$2$4');
	regex(/(\(20)([01])(1)[-–]([2-9]\))/gi, '$1$2$3–$2$4');
	regex(/(\(20)([01])(2)[-–]([3-9]\))/gi, '$1$2$3–$2$4');
	regex(/(\(20)([01])(3)[-–]([4-9]\))/gi, '$1$2$3–$2$4');
	regex(/(\(20)([01])(4)[-–]([5-9]\))/gi, '$1$2$3–$2$4');
	regex(/(\(20)([01])(5)[-–]([6-9]\))/gi, '$1$2$3–$2$4');
	regex(/(\(20)([01])(6)[-–]([7-9]\))/gi, '$1$2$3–$2$4');
	regex(/(\(20)([01])(7)[-–]([8-9]\))/gi, '$1$2$3–$2$4');
	regex(/(\(20)([01])(8)[-–](9\))/gi, '$1$2$3–$2$4');

	ohc_regex(/(\W)@DD@th?, @DD@th?((?:[ ]|&nbsp;)(?:and|&|to|or)(?:[ ]|&nbsp;))@DD@th?(?:\sof\s?)?([ ]|&nbsp;)@Month(?=\W)/gi, '$1@Day1, @Day2$2@Day3$3@LMonth');
	ohc_regex(/(\W)@DD@th?((?:[ ]|&nbsp;)(?:and|&|to|or)(?:[ ]|&nbsp;))@DD@th?(?:\sof\s?|)([ ]|&nbsp;)@Month(?=\W)/gi, '$1@Day1$2@Day2$3@LMonth');
	ohc_regex(/(\W)the @DD@th(?:\sof|)\s@Month,? @YYYY(?=\W\D)/g, '$1@Day @LMonth @YYYY');
	ohc_regex(/(\W)the @DD@th(?:\sof|)\s@Month(?=\W\D)/g, '$1@Day @LMonth');
	ohc_regex(/(\W)@Day@th?(?:\sof|)([ _]|&nbsp;|{{(?:break|nbsp)}})@Month(?=[^|\]\w])/gi, '$1@Day$2@LMonth');
	ohc_regex(/(\W)@Month\s(?:the\s)?@DD@th?,(?:\sthe\s)?(?: |&nbsp;)@DD@th?(\s(?:and|&|to|or)(?:[ _]|&nbsp;))(?:the\s)?@DD@th?(?=[^|\]\w])/gi, '$1@LMonth @Day1, @Day2$2@Day3');
	ohc_regex(/(\W)(@month)\s(@day)((?:,\s@day){0,6}),?(\/|\s?[-–]\s?|\s(?:and|&|to|or)\s+?)@Day@th?(?:,?(?:[ _]|&nbsp;)|\sof\s)?(\d{3,4}\W\D)/gi, '$1$2 $3$4$5@Day, $6');
	ohc_regex(/(\W)(@month)\s(@day)((?:,\s@day){0,6}),?(\/|\s?[-–]\s?|\s(?:and|&|to|or)\s+?)@Day@th?(?=\W\D)/gi, '$1$2 $3$4$5@Day');
	ohc_regex(/(\W)@Month([ _]|&nbsp;|{{(?:break|nbsp)}})(?:the\s)?@DD@th?,? @Year/gi, '$1@LMonth$2@Day, @Year');
	ohc_regex(/(\W)@Month @Day(?:\sof|,|)([ _]|&nbsp;|{{(?:break|nbsp)}})@Year(?=[^|\]\w])/gi, '$1@Month @Day,$2@Year');

	// consolidating/amalgamating date fields
	ohc_regex(/(\|[ ]*date[ ]*=[ ]*@day)\s*\|[ ]*month=[ ]*(@month)\s*\|[ ]*year=[ ]*(@yyyy[ ]*)(?=[|}\s])/gi, "$1 $2 $3");
	ohc_regex(/(\|[ ]*date[ ]*=[ ]*@day.?@month)\s*\|[ ]*year=[ ]*(@yyyy[ ]*)(?=[|}\s])/gi, "$1 $2");
	ohc_regex(/(\|[ ]*date[ ]*=[ ]*@month.?@day)\s*\|[ ]*year=[ ]*(@yyyy[ ]*)(?=[|}\s])/gi, "$1 $2");

	// eliminating dates and time placed in author parameter
	//removing artefacts from Indian news sites (TNN আগষ্ট 30, 2012, 05.46AM)
	ohc_regex(/(\|\s*author\s*=\s*(?:[A-Z]{2,3}\b))(?:[^|}]*)\d{4}, [\d\.:]{4,5}(&nbsp;|)[AP]M IST(?=[ ]*\|)/g, '$1$2');
//	ohc_regex(/(\|\s*author=(?:[^\[\]|{}]*))(TNN|PTI) @day @month @yyyy, [\d\.:]{4,5}(&nbsp;|)[AP]M IST(?=[ ]*\|)/g, '$1$2');

	ohc_regex(/(\|\s*author\s*=\s*)@month @day,? @yyyy\s?(?:,? [0-2]?\d[\.:][0-5]\d(?:\s*|&nbsp;)(?:[apAP][mM]\s*|)(?:GMT\s*|UTC\s*|[A-Z]{1,2}[DS]T\s*|)|)(?=\|)/g, "$1");
	ohc_regex(/(\|\s*author\s*=\s*)@day @month,? @yyyy\s?(?:,? [0-2]?\d[\.:][0-5]\d(?:\s*|&nbsp;)(?:[apAP][mM]\s*|)(?:GMT\s*|UTC\s*|[A-Z]{1,2}[DS]T\s*|)|)(?=\|)/g, "$1");
	ohc_regex(/(\|\s*author\s*=\s*\w[\w\s]+)@month @day,? @yyyy(?:[^\[\]|{}]*)(?=[|}])/g, "$1");
	ohc_regex(/(\|\s*author\s*=\s*\w[\w\s]+)@day @month,? @yyyy(?:[^\[\]|{}]*)(?=[|}])/g, "$1");
	ohc_regex(/(\|\s*author\s*=\s*(?:\w[\w\s]+)?)@dd-@mm-@yyyy/gi, "$1");
	ohc_regex(/(\|\s*author\s*=\s*(?:\w[\w\s]+)?)@YYYY-@MM-@DD ?/gi, "$1");
	regex(/(\|\s*(?:date|archive-?date|access-?date|author)\s*=\s*(?:\w[\w\s]+)?)[0-2]\d:[0-5]\d(?:[ ]|&nbsp;)?(?:[ap]m|[ap]\.m\.|)(?: ?(?:[A-Z]{1,2}T|UTC)[\.,]?|)/gi, "$1");
//	ohc_regex(/(\|\s*author\s*=\s*(?:\w[\w\s]+)?)\s*[0-2]\d[\.:][0-5]\d(?:[\.:][0-5]\d|)/gi, "$1"); //let's see later if we need this

	// eliminating mm-dd-yyyy dates
	ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@MM[-–\/\.=\s](1[3-9]|2\d|3[01])[-–\/\.=\s]@YYYY/gi, "$1@Month $2, @YYYY");
	ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Mon[-–\/\.=\s](1[3-9]|2\d|3[01])[-–\/\.=\s]@YYYY/gi, "$1@Month $2, @YYYY");
	ohc_regex(/[ ](?:Accessed|Retrieved)(?:(?: online|) on|:?)[ ]@MM[-–\/\.=\s](1[3-9]|2\d|3[01])[-–\/\.=\s]@YYYY(?=\D)/gi, " Retrieved @Month $1, @YYYY");
//	ohc_regex(/[ ](?:Accessed|Retrieved)(?:(?: online|) on|:?)[ ]@YYYY,? @Month @DD(?=\D)/gi, " Retrieved @Day @Month @YYYY");

	ohc_regex(/([ =|])@Mon[-–](1[3-9]|2\d|3[01])[-–]@YYYY(?=[^-–\d/])/gi, "$1@Mon $2, @YYYY"); 
	ohc_regex(/([ =|])@Mon\/(1[3-9]|2\d|3[01])\/@YYYY(?=[^-–\d/])/gi, "$1@Mon $2, @YYYY"); 
	ohc_regex(/([ =|])@Mon\.(1[3-9]|2\d|3[01])\.@YYYY(?=[^-–\d/])/gi, "$1@Mon $2, @YYYY"); 
	ohc_regex(/([ =|])@Mon (1[3-9]|2\d|3[01]) @YYYY(?=[^-–\d/])/gi, "$1@Mon $2, @YYYY"); 
	ohc_regex(/([ =|])@MM[-–](1[3-9]|2\d|3[01])[-–]@YYYY(?=[^-–\d/])/gi, "$1@Mon $2, @YYYY"); 
	ohc_regex(/([ =|])@MM\/(1[3-9]|2\d|3[01])\/@YYYY(?=[^-–\d/])/gi, "$1@Mon $2, @YYYY"); 
	ohc_regex(/([ =|])@MM\.(1[3-9]|2\d|3[01])\.@YYYY(?=[^-–\d/])/gi, "$1@Mon $2, @YYYY"); 
	ohc_regex(/([ =|])@MM (1[3-9]|2\d|3[01]) @YYYY(?=[^-–\d/])/gi, "$1@Mon $2, @YYYY"); 

	// eliminating dd-mm-yyyy dates (assumed default)
	ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@DD[-–\/\.=\s]@MM[-–\/\.=\s]@YYYY/gi, "$1@Day @Month @YYYY");
	ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@DD[-–\/\.=\s]@Mon[-–\/\.=\s]@YYYY/gi, "$1@Day @Month @YYYY");
	ohc_regex(/[ ](?:Accessed|Retrieved)(?:(?: online|) on|:?)[ ]@DD[-–\/\.=\s]@MM[-–\/\.=\s]@YYYY(?=\D)/gi, " Retrieved @Day @Month @YYYY");
	ohc_regex(/[ ](?:Accessed|Retrieved)(?:(?: online|) on|:?)[ ]@YYYY,? @Month @DD(?=\D)/gi, " Retrieved @Day @Month @YYYY");
	ohc_regex(/([ =|])@DD[-–]@Mon[-–]@YYYY(?=[^-–\d/])/gi, "$1@Day @Month @YYYY"); 
	ohc_regex(/([ =|])@DD\/@Mon\/@YYYY(?=[^-–\d/])/gi, "$1@Day @Month @YYYY"); 
	ohc_regex(/([ =|])@DD\.@Mon\.@YYYY(?=[^-–\d/])/gi, "$1@Day @Month @YYYY");
	ohc_regex(/([ =|])@DD @Mon @YYYY(?=[^-–\d/])/gi, "$1@Day @Month @YYYY"); 
	ohc_regex(/([ =|])@DD[-–]@MM[-–]@YYYY(?=[^-–\d/])/gi, "$1@Day @Month @YYYY"); 
	ohc_regex(/([ =|])@DD\/@MM\/@YYYY(?=[^-–\d/])/gi, "$1@Day @Month @YYYY"); 
	ohc_regex(/([ =|])@DD\.@MM\.@YYYY(?=[^-–\d/])/gi, "$1@Day @Month @YYYY");
	ohc_regex(/([ =|])@DD @MM @YYYY(?=[^-–\d/])/gi, "$1@Day @Month @YYYY"); 
	ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@DD[-–\/\.=\s]@Month[-–\/\.=\s]@YYNN(?=\s*[|}\n])/gi, '$1@Day @Month @YYYY');

//convert yyyy-dd-mm to yyyy-mm-dd
	ohc_regex(/{{(\s*[Cc]it(?:e|ation))([^}]+)(\s*\|\s*(?:publication|archive|access|air|)-?date\s*=\s*(?:1[0-9]|20)\d{2})[-/\.=\s](1[3-9]|2\d|3[01])[-/\.=\s](0?\d|1[0-2])(\s*[\|}<])/gi, '{{$1$2$3-$5-$4$6'); //from Batty

// eliminating other errant formats
	ohc_regex(/(\|(?:[\w ]*)date\s*=\s*)([0-2]?\d|30|31) @Month \2,? @YYYY(?=\s*[|}])/gi, "$1$2 @Month @YYYY"); //repeated digits
	ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Day ?@Month ?200([01]\d)[^\s|}]?(?=\s*[|}])/gi, "$1@Day @Month 20$2");
	ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month ?@Day,? ?200([01]\d)[^\s|}]?(?=\s*[|}])/gi, "$1@Month @Day, 20$2");

	ohc_regex(/([ ]\()@DD-@MM-@YYYY(\)\W)/gi, '$1@Day @Month @YYYY$2');
	ohc_regex(/([ ]\()@DD-@Month-@YYYY(\)\W)/gi, '$1@Day @Month @YYYY$2');
	ohc_regex(/(\|(?:[\w ]*)date\s*=\s*)@Month, @DD, @YYYY(?=\s*[|}])/gi, "$1@Day @Month @YYYY");
	ohc_regex(/(\|(?:[\w ]*)date\s*=\s*)@DD[\.,] @Month,? @YYYY(?=\s*[|}])/gi, "$1@Day @Month @YYYY");
	ohc_regex(/(\|(?:[\w ]*)date\s*=\s*)@YYYY,? @Month @DD(?=\s*[|}])/gi, "$1@Day @Month @YYYY");
	ohc_regex(/(\|(?:[\w ]*)date\s*=\s*)@YYYY,? @DD @Month(?=\s*[|}])/gi, "$1@Day @Month @YYYY");
	ohc_regex(/[ ]\(@YYYY,? @Month @DD\)/gi, " (@Day @Month @YYYY)");
	ohc_regex(/[ ]\(@YYYY @MM @DD\)/gi, " (@Day @Month @YYYY)");
	ohc_regex(/[ ]\(@YYYY, @DD @Month\)/gi, " (@Day @Month @YYYY)");
	ohc_regex(/(\|(?:[\w ]*)date\s*=\s*)@YYYY,? @Month(?=\s*[|}])/gi, "$1@Month @YYYY");
	ohc_regex(/[ ]\(@YYYY, @Month\)/gi, " (@Month @YYYY)");
	ohc_regex(/[ ]\(@Mon@YYYY\)/gi, " (@Mon @YYYY)");

	//CS1 errors ISO-like dates (too few or too many digits)
	ohc_regex(/(date\s*=\s*)(?:\[\[)?@YYYY(?:\]\][–—‐]\[\[|[–—‐])@MM[\-–—‐]@DD(?:\]\])?(?=\s*[|}])/gi, "$1@YYYY-@ZM-@ZD"); //ndashes and emdashes
	ohc_regex(/(\|\s*access-?date\s*=)\s*@YYYY-0[–—]@DD(?=\s*[|}])/gi, ""); //rem nonsense access date
	ohc_regex(/(\|(?:[\w ]*)date\s*=\s*)@YYYY[-–—]@MM[-–—]@DD(?=\s*[|}])/gi, "$1@YYYY-@ZM-@ZD"); //ndashes and emdashes
//	ohc_regex(/(\|(?:[\w ]*)date\s*=\s*)@YYYY[\-–—‐]@MM(?=\s*[|}])/gi, "$1@Month @YYYY"); //transform "yyyy-mm" to "month year"
	ohc_regex(/(<ref[^>]*>[^<]+?)([\s\(])@YYYY[–—]@MM[–—]@DD([^-\w\/%,<][^<]*?<\/ref>)/gi, "$1$2@Day @Month @YYYY$3");
	ohc_regex(/(<ref[^>]*>[^<]+?)([\s\(])@YYYY[-]@MM[-]([1-9])([^-\w\/%,<][^<]*?<\/ref>)/gi, "$1$2$3 @Month @YYYY$4");  

	// spaces and commas between month and year
	ohc_regex(/@Month(?:,?|\s+of|)(\s|&nbsp;)@YYYY(?=\D)/gi, "@LMonth$1@YYYY");

// fix month names (capitalize, remove dots)
	ohc_regex(/(\W)@DD\s@FullMonth(\s+|\s*,)/gi, "$1@Day @FullMonth$2");
	ohc_regex(/(\W)@DD\s@Mon(\s+|\s*,)/gi, "$1@Day @Mon$2");
	ohc_regex(/(\W)@FullMonth\s@DD(\s+|\s*,)/gi, "$1@FullMonth @Day$2");
	ohc_regex(/(\W)@Mon\s@DD(\s+|\s*,)/gi, "$1@Mon @Day$2");
	regex(/(\d(?:st|nd|rd|th) )C(entur(?:ies|y))(?=[ ]*(=|BC|AD|CE))/g, '$1c$2');
//	regex(/(\d(?:st|nd|rd|th) )C(entur(?:ies|y))(?![ \-][A-Z]\w*|''|")/g, '$1c$2');

	//spaces and commas - in date formats
	ohc_regex(/(\D\W\[?\[?@dd)[ ]+(@month)(\]\])?[ ]*,[ ]*(\[?\[?@yyyy(\sAD|\sBC|\sCE|\sBCE|)\]?\]?\W\D)/gi, "$1 $2$3 $4");
	ohc_regex(/(\D\W\[?\[?)(@month)[ ]+(@dd)(\]?\]?)(?:[ ]*,[ ]*)(\[?\[?@yyyy(\sAD|\sBC|\sCE|\sBCE|)\]?\]?\W\D)/gi, "$1$2 $3$4, $5");
	ohc_regex(/(\D\W\[?\[?)(@month)[ ]+(@dd)(\]?\]?)[ ]+(\[?\[?@yyyy(\sAD|\sBC|\sCE|\sBCE|)\]?\]?\W\D)/gi, "$1$2 $3$4, $5");

	ohc_regex(/(@month)(?:, | of )(@yyyy\w)/gi, "$1 $2"); //repeat after delinking

	// spaces and commas - md-md and dm-dm date ranges
	ohc_regex(/(\D\W)@Month\s@DD(&nbsp;|\s)(?:[-–—]|&[mn]dash;)(?:&nbsp;|\s)?@Month\s@DD(?=\W\D)/gi, "$1@LMonth1 @Day1$2– @LMonth2 @Day2");
	ohc_regex(/(\D\W)@Month\s@DD(?:[-–—]|&[mn]dash;)(?:&nbsp;|\s)?@Month\s@DD(?=\W\D)/gi, "$1@LMonth1 @Day1 – @LMonth2 @Day2");
	ohc_regex(/(\D\W)@DD\s@Month(&nbsp;|\s)(?:[-–—]|&[mn]dash;)(?:&nbsp;|\s)?@DD\s@Month(?=\W\D)/gi, "$1@Day1 @LMonth1$2– @Day2 @LMonth2");
	ohc_regex(/(\D\W)@DD\s@Month(?:[-–—]|&[mn]dash;)(?:&nbsp;|\s)?@DD\s@Month(?=\W\D)/gi, "$1@Day1 @LMonth1 – @Day2 @LMonth2");

	// spaces and commas - d-dm and md-d date ranges
	ohc_regex(/(\D\W)@Month(\s|&nbsp;)@DD@th?(?:(?:\s*|&nbsp;|)[-–](?:\s*|&nbsp;|))@DD@th?(?=\W\D)/gi, "$1@LMonth1$2@Day1–@Day2");
	ohc_regex(/(\D\W)@DD@th?(?:(?:\s*|&nbsp;|)[-–](?:\s*|&nbsp;|))@DD@th?(\s|&nbsp;)@Month(?=\W\D)/gi, "$1@Day1–@Day2$2@LMonth1");

	// spaces and commas between month and year (again)
	ohc_regex(/@Month(?:,\s+|\s+of\s+)@YYYY(\w)/gi, "@LMonth @YYYY$1");
}

/** ------------------------------------------------------------------------- */
/// ISO to long format

function ohc_ISO_to_dmy_in_citations()
{
	//ISO dates within single citation
	ohc_regex(/(\|\s*(?:publication|archive|access|air|designation\d?_|)-?date\s*=\s*)@YYYY[-–]@MM[-–]@DD(?=\W\D)/gi, "$1@Day @Month @YYYY");
}

function ohc_ISO_to_mdy_in_citations()
{
	//ISO dates within single citation
	ohc_regex(/(\|\s*(?:publication|archive|access|air|designation\d?_|)-?date\s*=\s*)@YYYY[-–]@MM[-–]@DD(?=\W\D)/gi,  "$1@Month @Day, @YYYY");
}

function ohc_ISO_to_dmy_in_references()
{
	//multiple calls for multiple dates within single citation
	ohc_regex(/(<ref[^>]*>[^<]+?)([\s\(])@YYYY[-–]@MM[-–]@DD([^-\w\/%,<][^<]*?<\/ref>)/gi, "$1$2@Day @Month @YYYY$3");
	ohc_regex(/(<ref[^>]*>[^<]+?)([\s\(])@YYYY[-–]@MM[-–]@DD(<\/ref>)/gi, "$1$2@Day @Month @YYYY$3");
}

function ohc_ISO_to_mdy_in_references()
{
	//multiple calls for multiple dates within single citation
	ohc_regex(/(<ref[^>]*>[^<]+?)([\s\(])@YYYY[-–]@MM[-–]@DD([^-\w\/%,<][^<]*?<\/ref>)/gi, "$1$2@Month @Day, @YYYY$3");
	ohc_regex(/(<ref[^>]*>[^<]+?)([\s\(])@YYYY[-–]@MM[-–]@DD(<\/ref>)/gi, "$1$2@Month @Day, @YYYY$3");
}

// currently unused
function ohc_ISO_to_dmy_anywhere()
{
	//multiple calls for multiple dates within single citation
	ohc_regex(/([^-\w/])@YYYY[-–]@MM[-–]@DD([^-\w/])/gi, '$1@Day @Month @YYYY$2');
	ohc_regex(/([^-\w/])@YYYY[-–]@MM[-–]@DD([^-\w/])/gi, '$1@Day @Month @YYYY$2');
	ohc_regex(/([^-\w/])@YYYY[-–]@MM[-–]@DD([^-\w/])/gi, '$1@Day @Month @YYYY$2');
}

// currently unused
function ohc_ISO_to_mdy_anywhere()
{
	//multiple calls for multiple dates within single citation
	ohc_regex(/([^-\w/])@YYYY[-–]@MM[-–]@DD([^-\w/])/gi, '$1@Month @Day, @YYYY$2');
	ohc_regex(/([^-\w/])@YYYY[-–]@MM[-–]@DD([^-\w/])/gi, '$1@Month @Day, @YYYY$2');
	ohc_regex(/([^-\w/])@YYYY[-–]@MM[-–]@DD([^-\w/])/gi, '$1@Month @Day, @YYYY$2');
}

function ohc_delink_ISO_to_dmy()
{
	ohc_ISO_to_dmy_in_citations();
	ohc_ISO_to_dmy_in_references();
	regex(/([^\w\/\-%,])@YYYY-@MM-@DD(<\s?\/ref.*?>)/g, '$1@Day @Month @Year$2');
	ohc_regex(/(\|\|[ ]*)@YYYY[-–]@MM[-–]@DD([ ]*\|\|)/gi, '$1{{dts|format=dmy|@YYYY|@MM|@DD}}$2');  //dts template for sortable tables
	ohc_regex(/(\{\{dts\|format=)mdy\|/gi, '$1dmy|');  //flip dts template formats
}

function ohc_delink_ISO_to_mdy()
{
	ohc_ISO_to_mdy_in_citations();
	ohc_ISO_to_mdy_in_references();
	regex(/([^\w\/\-%,])@YYYY-@MM-@DD(<\s?\/ref.*?>)/g, '$1@Month @Day, @Year$2');
	ohc_regex(/(\|\|[ ]*)@YYYY[-–]@MM[-–]@DD([ ]*\|\|)/gi, '$1{{dts|@YYYY|@MM|@DD}}$2');  //dts template for sortable tables (mdy is default)
	ohc_regex(/(\{\{dts\|)format=(?:mdy|dmy|) ?\|/gi, '$1');  //flip dts template formats
}

function ohc_delink_year_in_X()
{
//	ohc_regex(/\{\{(?:avyear|by|baseball\syear|fy|ly|mlby|mlb\syear|scy|sdy)\|(@year)\}\}/gi, "$1"); //disabled 3/5/21 discussion at https://en.wikipedia.org/w/index.php?title=Wikipedia_talk:WikiProject_Baseball&oldid=1021203365#Links_to_baseball_year_articles_in_infobox?
//	ohc_regex(/\{\{(?:avyear|by|baseball\syear|fy|ly|mlby|mlb\syear|scy|sdy)\|@year\|(@year)\}\}/gi, "$1");
	ohc_regex(/\[\[@yyyy\sin\s[^|\]]+\|((?:(?:@day |)@month |)@yyyy)\]\]/gi, '$1');
	regex(/\[\[(?:\d{4}[-–]\d{2} in English football)\|((?:(?:@Day |)@Month |)@YYYY)\]\]/gi, '$1'); 

	regex(/\[\[\d{4} Major League Baseball season\|(\d{4})(\sseason)?\]\]/gi, '$1$2');
}


// format parameter must be 'dmy' or 'mdy'
function ohc_fix_dts_template(format)
{
	// dts - format=dmy in this case (per D12000)
	// per {{dts}} doc, remove the obsolete link=off param
	regex(/(\{\{dts[^}]*)(?:\|link=off)/gi, '$1');
	ohc_regex(/(\{\{dts\s*\|\s*@year\s*\|\s*@month\s*\|\s*@day\s*\|\s*format=)(?:dmy|mdy)(\}\})/gi, '$1'+format+'$2');
	ohc_regex(/(\{\{dts\s*\|\s*format=)(?:dmy|mdy)(\s*\|\s*@year\s*\|\s*@month\s*\|\s*@day\s*\}\})/gi, '$1'+format+'$2');
	ohc_regex(/(\{\{dts\s*\|\s*@year\s*\|\s*@month\s*\|\s*@day\s*)(\}\})/gi, '$1|format='+format+'$2');

   // stripping – {{dts}} serves no purpose inside date parameters
	ohc_regex(/(\|(?:[\w ]*)date\s*=\s*)\{\{dts\s*\|\s*format=(?:dmy|mdy)\s*\|\s*([|}]*)\}\}(?=\s*[|}])/gi, "$1$2");
	ohc_regex(/(\|(?:[\w ]*)date\s*=\s*)\{\{dts\s*\|\s*([|}]*)(?:\|\s*format=(?:dmy|mdy)\s*|)\}\}(?=\s*[|}])/gi, "$1$2");
	ohc_regex(/(\|(?:[\w ]*)date\s*=\s*)\{\{dts\s*\|\s*format=(?:dmy|mdy)\s*\|\s*@YYYY(\s*\|\s*|-)@MM(\s*\|\s*|-)@DD\s*\}\}(?=\s*[|}])/gi, "$1@YYYY-@MM-@DD ");
	ohc_regex(/(\|(?:[\w ]*)date\s*=\s*)\{\{dts\s*\|\s*@YYYY(\s*\|\s*|-)@MM(\s*\|\s*|-)@DD\s*\|\s*format=(?:dmy|mdy)\s*\}\}(?=\s*[|}])/gi, "$1@YYYY-@MM-@DD ");
}

// format parameter must be 'dmy' or 'mdy'
function ohc_fix_gr_template(format)
{
	// GR - date formatting parameter
	// per {GR} doc, insert date formatting param
	regex(/(\{\{GR\|\d\d?)(?!\|date)/gi, '$1|dateform=' + format);
}

function ohc_dates_to_dmy()
{
	regex(/\|df=[mdy]{3}(?:-all|)(?=\s*[|}])/gi, '');
	regex(/\|format=mdy/gi, '|format=dmy');
	//change start and end templates; vgrelease new v=2 or mdy is default
	regex(/(\{\{(?:start date|end date)[^|}]*\|)df=ye?s?\|([^}]*df=ye?s?)/gi, '$1$2');
	regex(/(\{\{vgrelease new[^|}]*\|)(?:v=1\||)([A-Z]{2,3}\|)/g, '$1v=2|$2');
	ohc_regex(/(\|\s*(?:begin|end|first|last)\s*=\s*)@YYYY[-–]@MM[-–]@DD(?=\W\D)/gi, "$1@Day @Month @YYYY"); //spotted at [[Template:Infobox recurring event]]
 
	//change birth and death templates
	regex(/(\{\{(?:(?:Birth|Death) date(?: and age|)|launch|release|start)[^}]*\|)m(f=ye?s?)/gi, '$1d$2'); // substitute df for mf 
	regex(/(\{\{(?:(?:Birth|Death) date(?: and age|)|launch|release|start|film ?date|Wayback)[\|\d]+)(\}\})/gi, '$1|df=y$2'); //insert df parameter
	regex(/(\{\{(?:(?:Birth|Death) date(?: and age|)|launch|release|start|film ?date|Wayback)[\|\d]+\|)df=ye?s?\|([^}]*df=ye?s?)/gi, '$1$2'); //put date format parameter at the end
	regex(/(\{\{(?:start date|end date)\|)df=ye?s?\|((?:1[789]|20)\d{2}\}\})/gi, '$1$2');  //date format parameter not needed – year only

	//convert date ranges (md,d,d-dy to d,d,d-dmy; md,d,d-d to d,d,d-dm; md,d,d to d,d,dm)
	ohc_regex(/(\D\W)@Month((?:\s@day?,?){1,6}),?(\/|\s?(?:[-–]|&ndash;)\s?|(?:[ _]|&nbsp;)(?:and|&|to|or)(?:[ _]|&nbsp;)+?)@Day,?\s(?:of\s)?(@yyyy\W\D)/gi, "$1$2$3@Day @LMonth $4");
	ohc_regex(/(\D\W)@Month((?:\s@day?,?){1,6}),?(\/|\s?(?:[-–]|&ndash;)\s?|(?:[ _]|&nbsp;)(?:and|&|to|or)(?:[ _]|&nbsp;)+?)@Day(?=\W\D)/gi, "$1$2$3@Day @LMonth");

//	ohc_regex(/(\D\W)@Month((?:\s@day?,?){1,6}) @Day(?=\W\D)/gi, "$1$2 @Day @LMonth"); //disabling as unlikely and ungrammatical constructions causing false positives

	//'md, md,' to 'dm, dm,'
	ohc_regex(/(\D\W)@Month @Day, @Month @Day(?=[,\.]\W\D)/gi, "$1@Day1 @LMonth1, @Day2 @LMonth2");

	//convert simple mdy dates to dmy
	ohc_regex(/(p(?:g?\.?|age) ?\d+|p(?:p\.?|ages) ?\d+[-–]\d+), @Month((?:\s@day?,?){1,6}) @Day(?=\W\D)/gi, "$1. $2 @Day @LMonth");
	ohc_regex(/(\D\W)@Month\s@Day,?\s@Year(\s?(?:AD|BC|CE|BCE)\W\D)/gi, "$1@Day @LMonth @Year$2");
	ohc_regex(/(\|\s*term_(?:end|start)\d\s*=\s*|\D\W)@Month\s@Day,?\s@YYYY(?=\W\D)/gi, "$1@Day @LMonth @Year");
	ohc_regex(/(\|\s*term_(?:end|start)\d\s*=\s*|\D\W)@Month\s@Day(?=\W\D)/gi, "$1@Day @LMonth");

	//Month+day_number " 7th মার্চ" -> "7 মার্চ"
	ohc_regex(/(\D\W)@Day\s@Month\s@YYYY(?=\W\D)/gi, "$1@Day @LMonth @Year");
	ohc_regex(/(\D\W)@Day\s@Month(?=\W\D)/gi, "$1@Day @LMonth");
	ohc_regex(/(\D\W)@Month\s@Day,?\s@Year(?=\W\D)/gi, "$1@Day @LMonth @Year");

	//dates with embedded nbsp
	ohc_regex(/(\D\W)@Month([ _]|&nbsp;)(\d{1,2},(?: |&nbsp;)\d{1,2}(?:\s(?:and|&|to|or)(?:[ _]|&nbsp;))\d{1,2})(?=[^|\]\w])/gi, '$1$3$2@LMonth ');
	ohc_regex(/(\D\W)@Month([ _]|&nbsp;|{{(?:break|nbsp)}})@Day,([ _]|&nbsp;|{{(?:break|nbsp)}})@YYYY(?=[^|\]\w])/gi, '$1@Day$2@Month$3@Year');

	//remove comma
	ohc_regex(/(\D\W)@Day\s@Month,\s?@Year(?=\W\D)/gi, "$1@Day @LMonth @Year");

	//	remove "the" from "on the dd month"
	ohc_regex(/(on |by )the @Day\s@Month(?=[ ,\)\.])/gi, "$1@Day @LMonth");

	//remove space from date range conversion
	ohc_regex(/(\D ) @Day(\/|\s?(?:[-–]|&ndash;)\s?|(?:[ _]|&nbsp;)(?:and|&|to|or)(?:[ _]|&nbsp;)+?)/gi, "$1@Day$2");
}

function ohc_dates_to_mdy()
{
	//change birth and death templates – mf=y is the default; vgrelease new v=2 or mdy is default
	regex(/\|df=[mdy]{3}(?:-all|)(?=\s*[|}])/gi, '');
	regex(/\|df=y(?:es|)(?=[|}\s])/gi, '');
	regex(/(mf=y(?:es|)\|[^}]*\|)(?:mf=y(?:es|)\|)/gi, '$1');
	regex(/(\{\{vgrelease new[^|}]*\|)(?:v=2\||)([A-Z]{2,3}\|)/g, '$1$2');
	ohc_regex(/(\|\s*(?:begin|end|first|last)\s*=\s*)@YYYY[-–]@MM[-–]@DD(?=\W\D)/gi, "$1@Month @Day, @YYYY");

	//convert date ranges (d,d,d-dmy to md,d,d-dy; d,d,d-dm to md,d,d-d; dm,d,d to md,d,d)
	ohc_regex(/(\D\W)@Day((?:, @day){0,5})(\/|\s?(?:[-–]|&ndash;)\s?|\s(?:and|&|to|or)\s+?)@Day\s@Month,? @YYYY(?=\W\D)/gi, "$1@LMonth @Day1$2$3@Day2, @YYYY");
	ohc_regex(/(\D\W)@Day((?:, @day){0,5})(\/|\s?(?:[-–]|&ndash;)\s?|\s(?:and|&|to|or)\s+?)@Day\s@Month(?=\W\D)/gi, "$1@LMonth @Day1$2$3@Day2");
//	ohc_regex(/(\D\W)@Day((?:, @day){0,5})\s@Month,? @YYYY(?=\W\D)/gi, "$1@LMonth @Day1$2, @YYYY"); //disabling as unlikely and ungrammatical constructions causing false positives
//	ohc_regex(/(\D\W)@Day((?:, @day){0,5})\s@Month(?=\W\D)/gi, "$1@LMonth @Day1$2"); //disabling as unlikely and ungrammatical constructions causing false positives

	//'dm, dm,' to 'md, md,'
	ohc_regex(/(\D\W)@Day @Month, @Day @Month(?=[,\.]?\W\D)/gi, "$1@LMonth1 @Day1, @LMonth2 @Day2");

	//convert simple dmy dates to mdy
	ohc_regex(/(p(?:g?\.?|age) ?\d+|p(?:p\.?|ages) ?\d+[-–]\d+), @Month((?:\s@day?,?){1,6}) @Day(?=\W\D)/gi, "$1. @LMonth $2 @Day");
	ohc_regex(/(\D\W)@Day(\s|&nbsp;)@Month,?(\s|&nbsp;)@Year(?=\W\D)/gi, "$1@LMonth$2@Day,$3@Year");
	ohc_regex(/(\|\s*term_(?:end|start)\d\s*=\s*|\D\W)@Day[ ]+@Month,?\s@YYYY(?=\W\D)/gi, "$1@LMonth @Day, @Year");
	ohc_regex(/(\|\s*term_(?:end|start)\d\s*=\s*|\D\W)@Day[ ]+@Month(?=\W\D)/gi, "$1@LMonth @Day");

	//Month+day_number "মার্চ 7th" -> "মার্চ 7"
	ohc_regex(/(\D\W)@Month\s@Day@th?,?\s@YYYY(?=\W\D)/gi, "$1@LMonth @Day, @YYYY");
	ohc_regex(/(\D\W)@Day@th?(\s|&nbsp;)@Month(\s|&nbsp;)@YYYY(?=\W\D)/gi, "$1@LMonth$2@Day,$3@YYYY");
	ohc_regex(/(\D\W)@Month(\s|&nbsp;)@Day(?=\W\D)/gi, "$1@LMonth$2@Day");
	ohc_regex(/(\D\W)@Day@th?(\s|&nbsp;)@Month([,\.])(?=\W\D)/gi, "$1@LMonth$2@Day$3");

	//add comma where missing
	ohc_regex(/(\D\W)@Month\s@Day,?\s@YYYY,?(?=\s\w)/gi, "$1@LMonth @Day, @YYYY,");
	//rem superfluous comma where applicable
	ohc_regex(/(\D[^\w\/])@Month\s@ZD,,(?=\W\D|\b)/gi, "$1@LMonth @Day,");
}

function ohc_fix_dmy_redundancies()
{
	//month-range redundancies (repeating month names)
	ohc_regex(/([\D]@dd)@th? @Month[ ]{1,2}((?:to|and|-|–)[ ]{1,2}@dd)@th? @Month/, "$1 $2 @LMonth", function(d1, d2) {
		if (d1.m == d2.m) return true;
		return false;
	});
}
//not currently used
function ohc_fix_mdy_redundancies()
{
	//month-range redundancies (repeating month names)
	ohc_regex(/(@Month[ ]{1,2}@dd)@th? (to|and|-|–)[ ]{1,2}@Month[ ]{1,2}@DD@th?/, "$1 $2 @LDay", function(d1, d2) {
		if (d1.m == d2.m) return true;
		return false;
	});
}

function ohc_expand_ref_dates()
{
	ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month @YYYY(?=\s*[|}])/gi, "$1@FullMonth @YYYY");
	ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Day @Month @YYYY(?=\s*[|}])/gi, "$1@Day @FullMonth @YYYY");
	ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month @Day, @YYYY(?=\s*[|}])/gi, "$1@FullMonth @Day, @YYYY");

	ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)((?:[01-2]?\d|30|31) |)@Month @YYYY ?(?:-|–|&ndash;) ?((?:[01-3]?\d|30|31) |)@Month @YYYY(?=\s*[|}])/gi, "$1$2 @FullMonth1 @YYYY1 – $3@FullMonth2 @YYYY2");
	ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month @Day(, (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month @Day, @YYYY(?=\s*[|}])/gi, "$1@FullMonth1 @Day1$2 – @FullMonth2 @Day2, @YYYY");
	ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Day @Month,?( (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Day @Month @YYYY(?=\s*[|}])/gi, "$1@Day1 @FullMonth1$2 – @Day2 @FullMonth2 @YYYY");
	ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month,?( (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month,? @YYYY(?=\s*[|}])/gi, "$1@FullMonth1$2 – @FullMonth2 @YYYY");
	ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)((?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month @YYYY(?=\s*[|}])/gi, "$1@$2 – @FullMonth @YYYY");

	ohc_regex(/(<ref[^>]*>(?:[^<]+?[\s\(]|))((?:[01-2]?\d|30|31) |)@Month @YYYY ?(?:-|–|&ndash;) ?((?:[01-3]?\d|30|31) |)@Month @YYYY(?=(?:[^-\w\/%,<][^<]*?|)<\/ref>)/gi, "$1$2@FullMonth1 @YYYY1 – $3@FullMonth2 @YYYY2");
	ohc_regex(/(<ref[^>]*>(?:[^<]+?[\s\(]|))@Month @Day(, (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month @Day, @YYYY(?=(?:[^-\w\/%,<][^<]*?|)<\/ref>)/gi, "$1@FullMonth1 @Day1$2 – @FullMonth2 @Day2, @YYYY");
	ohc_regex(/(<ref[^>]*>(?:[^<]+?[\s\(]|))@Day @Month,?( (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Day @Month @YYYY(?=(?:[^-\w\/%,<][^<]*?|)<\/ref>)/gi, "$1@Day1 @FullMonth1$2 – @Day2 @FullMonth2 @YYYY");
	ohc_regex(/(<ref[^>]*>(?:[^<]+?[\s\(]|))@Month,?( (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month,? @YYYY(?=(?:[^-\w\/%,<][^<]*?|)<\/ref>)/gi, "$1@FullMonth1$2 – @FullMonth2 @YYYY");
	ohc_regex(/(<ref[^>]*>(?:[^<]+?[\s\(]|))((?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month @YYYY(?=(?:[^-\w\/%,<][^<]*?|)<\/ref>)/gi, "$1$2 – @FullMonth @YYYY");
}

function ohc_expand_all_dates()
{
	ohc_regex(/([^-\w/])@Month @YYYY(?=[^-\w/])/gi, '$1@FullMonth @YYYY');
	ohc_regex(/([^-\w/])@Day @Month @YYYY(?=[^-\w/])/gi, '$1@Day @FullMonth @YYYY');
	ohc_regex(/([^-\w/])@Month @Day, @YYYY(?=[^-\w/])/gi, '$1@FullMonth @Day, @YYYY');

	ohc_regex(/([^-\w/])((?:[01-2]?\d|30|31) |)@Month @YYYY ?(?:-|–|&ndash;) ?((?:[01-3]?\d|30|31) |)@Month @YYYY(?=[^-\w/])/gi, "$1$2@FullMonth1 @YYYY1 – $3@FullMonth2 @YYYY2");
	ohc_regex(/([^-\w/])@Month @Day(, (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month @Day, @YYYY(?=[^-\w/])/gi, "$1@FullMonth1 @Day1$2 – @FullMonth2 @Day2, @YYYY");
	ohc_regex(/([^-\w/])@Day @Month,?( (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Day @Month @YYYY(?=[^-\w/])/gi, "$1@Day1 @FullMonth1$2 – @Day2 @FullMonth2 @YYYY");
	ohc_regex(/([^-\w/])@Month,?( (?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month,? @YYYY(?=[^-\w/])/gi, "$1@FullMonth1$2 – @FullMonth2 @YYYY");
	ohc_regex(/([^-\w/])((?:19|20)\d\d) ?(?:-|–|&ndash;) ?@Month @YYYY(?=[^-\w/])/gi, "$1$2 – @FullMonth @YYYY");

	ohc_regex(/([ ]\(|\|\s*)@Day @Month @YYYY(?=\)\W|\s*[|\n])/gi, "$1@Day @FullMonth @YYYY");
	ohc_regex(/([ ]\(|\|\s*)@Month @Day,? @YYYY(?=\)\W|\s*[|\n])/gi, "$1@FullMonth @Day, @YYYY");
	ohc_regex(/([ ]\((?:c\. |))@Month @YYYY ?(?:-|–|&nbsp;) ?@Day @Month @YYYY(?=\)\W)/gi, "$1@FullMonth1 @YYYY1 – @Day @FullMonth2 @YYYY2");
	ohc_regex(/([ ]\((?:c\. |))@Month @YYYY ?(?:-|–|&nbsp;) ?@Month @YYYY(?=\)\W)/gi, "$1@FullMonth1 @YYYY1 – @FullMonth2 @YYYY2");
	ohc_regex(/([ ]\((?:c\. |))@YYYY ?(?:-|–|&nbsp;) ?@Month @YYYY(?=\)\W)/gi, "$1@YYYY1 – @FullMonth @YYYY2");
	ohc_regex(/([ ]\((?:c\. |))@Month ?(?:-|–|&nbsp;) ?@Month @YYYY(?=\)\W)/gi, "$1@FullMonth1 – @FullMonth2 @YYYY");
	ohc_regex(/([ ]\((?:c\. |))@Month @YYYY(?=\)\W)/gi, "$1@FullMonth @YYYY");
}

function ohc_abbrev_ref_dates()
{
	ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Day @Month @YYYY(?=\s*[|}])/gi, "$1@Day @Mon @YYYY");
	ohc_regex(/(<ref[^>]*>(?:[^<]+?[\s\(]|))([12]?\d|30|31) (জানুয়ারি|ফেব্রুয়ারি|মার্চ|এপ্রিল|মে|জুন|জুলাই|আগষ্ট|অক্টোবর|Oct|নভেম্বর|ডিসেম্বর)(?:r?uary|ch|il|[ey]|ust|(?:t?em|o)ber)( (?:19\d|20[01])\d)(?=(?:[^-\w\/%,<][^<]*?|)<\/ref>)/gi, "$1$2 $3$4");
	ohc_regex(/([ ]\()@Day @Month @YYYY([^-\w\/])/gi, "$1@Day @Mon @YYYY$2");
 
	ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month @Day, @YYYY(?=\s*[|}])/gi, "$1@Mon @Day, @YYYY");
	ohc_regex(/(<ref[^>]*>(?:[^<]+?[\s\(]|))(জানুয়ারি|ফেব্রুয়ারি|মার্চ|এপ্রিল|মে|জুন|জুলাই|আগষ্ট|অক্টোবর|Oct|নভেম্বর|ডিসেম্বর)(?:r?uary|ch|il|[ey]|ust|(?:t?em|o)ber) ([12]?\d|30|31),( (?:19\d|20[01])\d)(?=(?:[^-\w\/%,<][^<]*?|)<\/ref>)/gi, "$1$2 $3,$4");
	ohc_regex(/([^-\w\/])@Month @Day, @YYYY([^-\w\/])/gi, '$1@Mon @Day, @YYYY$2');
}
 
//not currently used
function ohc_abbrev_all_dates()
{
	ohc_regex(/([^-\w/])@Day @Month @YYYY(?=[^-\w/])/gi, '$1@Day @Mon @YYYY');
	ohc_regex(/([^-\w/])@Month @Day, @YYYY(?=[^-\w/])/gi, '$1@Mon @Day, @YYYY');
}

//not currently used
function ohc_dmy_publication_dates()
{
	ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Month @Day,? @YYYY/gi, "$1@Day @Month @YYYY"); // conversion of dates in references outside of the protection loop (eg for quotations etc.)
	ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)(?:\[\[)?@YYYY(?:\]\][-–]\[\[|[-–])@MM[-–]@DD(?:\]\])?(?=\s*[|}])/gi, "$1@Day @Month @YYYY");
	//replace ISO dates (within parentheses) only within refs
	ohc_regex(/(<ref[^>]*>[^<]+?)([ ]\()@YYYY-@MM-@DD(\))(\W[^<]*?<\/ref>)/gi, "$1$2@Day @Month @YYYY$3$4");
}

function ohc_mdy_publication_dates()
{
	ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)@Day @Month @YYYY/gi, "$1@Month @Day, @YYYY"); // conversion of dates in references outside of the protection loop (eg for quotations etc.)
	ohc_regex(/(\|\s*(?:publication|archive|access|air|)-?date\s*=\s*)(?:\[\[)?@YYYY(?:\]\][-–]\[\[|[-–])@MM[-–]@DD(?:\]\])?(?=\s*[|}])/gi, "$1@Month @Day, @YYYY"); 
	//replace ISO dates (within parentheses) only within refs
	ohc_regex(/(<ref[^>]*>[^<]+?)([ ]\()@YYYY-@MM-@DD(\))(\W[^<]*?<\/ref>)/gi, "$1$2@Month @Day, @YYYY$3$4");
}

function ohc_Bigendian_ref_dates() {
	// Add a tag to the summary box
	regex(/(\{\{use (?:mdy|dmy) dates)(?:\|cs1-dates=\w{1,2}|)(\|[^\}\|]+\}\})/gi, '$1|cs1-dates=y$2');
}

/** ------------------------------------------------------------------------ **/
/// EDIT SUMMARIES & USE DMY TEMPLATE
// this function modified 2019-03-27 from [[Special:Permalink/846525463]]
// format parameter must be 'dmy' or 'mdy'
function ohc_use_dates_template(format) 
{
	var txt = document.editform.wpTextbox1;
	// current month-year
	var currentDate = new Date();
	var currmonth = currentDate.getMonth();
	var curryear = currentDate.getFullYear();
	var myMonths = ["জানুয়ারি", "ফেব্রুয়ারি", "মার্চ", "এপ্রিল", "মে", "জুন", "জুলাই", "আগষ্ট", "সেপ্টেম্বর", "অক্টোবর", "নভেম্বর", "ডিসেম্বর"];
	var curryyyymm = myMonths[currmonth] + ' ' + curryear;

// step 1: normalize redirect template names to canonical template names 'Use dmy dates' or 'Use mdy dates' according to 'format' argument 
// rename redirects 'dmy', 'mdy', 'usedmydates', 'usemdydates' ('usedmydates' and 'usemdydates' are not currently listed as redirects but might be encountered?)
	regex(/\{\{ *(?:use(?:dmy|mdy)dates|dmy|mdy) *([\|\}])/gi, '{{Use ' + format + ' dates$1');
// rename redirects 'usedmy', 'usemdy', 'use dmy', 'use mdy' to canonical form
	regex(/\{\{ *use *(?:dmy|mdy) *([\|\}])/gi, '{{Use ' + format + ' dates$1');
// strip leading / trailing whitespace from 'use xxx dates'
	regex(/\{\{ *use (?:dmy|mdy) dates *([\|\}])/gi, '{{Use ' + format + ' dates$1');

// step 2: look for a canonical template name (the above might not have had anthing to work on) ; if found continue, write new template else
	var rxpdd = new RegExp("{{Use " + format + " dates", "gi");	// here we search for canonical form {{use xxx dates}} that has current date
	var dflagfound = txt.value.search(rxpdd);
	if (dflagfound === -1) {
		txt.value = '{{Use ' + format + ' dates|date=' + curryyyymm + '}}\r\n' + txt.value;	// not found so insert new template at top of wikitext
		return;																	// and done
	}

// step 3: rewrite existing canonical templates; add or refresh |date= to current month year; preserve |cs1-dates= as is
	regex(/(\{\{use (?:dmy|mdy) dates)\| *date *=[^\|]*\| *cs1\-dates *= *([^\|\}]*?) *\}\}/gi, '$1|date=' + curryyyymm + '|cs1-dates=$2}}');	// with |date= followed by |cs1-dates=
	regex(/(\{\{use (?:dmy|mdy) dates)\| *cs1\-dates *= *([^\|\}]*?) *\| *date *=[^\}]*\}\}/gi, '$1|date=' + curryyyymm + '|cs1-dates=$2}}');	// with |cs1-dates= followed by |date=
	regex(/(\{\{use (?:dmy|mdy) dates)\| *date *=[^\|\}]*\}\}/gi, '$1|date=' + curryyyymm + '}}');												// with |date=
	regex(/(\{\{use (?:dmy|mdy) dates)\| *cs1\-dates *= *([^\|\}]*?) \}\}/gi, '$1|date=' + curryyyymm + '|cs1-dates=$2}}');						// with |cs1-dates
	regex(/(\{\{use (?:dmy|mdy) dates)\}\}/gi, '$1|date=' + curryyyymm + '}}');																	// no parameters so add |date=curryyyymm 
	regex(/(\{\{[\t_ ]*use[\t_ ]+(?:dmy|mdy)[\t_ ]+dates[^{}]*\}\})([\r\n\t ]*)(\{\{[\t ]*short description[^{}]*\}\})/gi, '$3$2$1');			// repositioning "short description" template at the top
}



/** ------------------------------------------------------------------------ **/
/// DATE PROTECTION

var linkmap = [];

function ohc_protect_dates()
{
	// protects dates within links, quotes, etc
	// the sensitive part is stored and replaced with a unique identifier,
	// which is later replaced with the stored part.
 
	var protect_function = function(s, begin, replace, end) {
		linkmap.push(replace);
		return begin + "⍌"+(linkmap.length-1)+"⍍" + end;
	};
//\|x=
	regex(/(<timeline>)([\s\S]*?)(<\/timeline>)/gi, protect_function);
	regex(/(<!--)([^<\{\}]*?)(-->)/gi, protect_function);
	regex(/(<math>)([\s\S]*?)(<\/math>)/gi, protect_function);
	regex(/((?:{(?:Wikimedia |)Commons ?|C ?))(Cat(?:egory|))\|[^{}*](})/gi, protect_function);
	regex(/(<ref)([^>]+)(>)/gi, protect_function);
	regex(/((?:Category|Image|File):)([^|\]]*)([|\]])/gi, protect_function);
	regex(/(\{(?:See ?also|Main))(\|[^}]*)(\})/gi, protect_function);
	regex(/(\{\{(?:double ?|external ?|wide ?)image\s?\|)([^}]+)(\})/gi, protect_function);
	regex(/(\{\{(?:harvnb|r|wikisource)\|)([^}]+)(\})/gi, protect_function);
	regex(/(\{\{(?:Canadian federal by-election))([^}]+)(\}\})/gi, protect_function);
	
	regex(/(\[(?:https?:|ftp:))([^\]]*)(\])/gi, protect_function);
	regex(/(>[ ]*(?:https?:|ftp:))([^< >\]]*)([ ]*<)/gi, protect_function);
//	regex(/(https?:|ftp:)([^\s\]]*)([\s\]])/gi, protect_function);
	regex(/(<blockquote>)([\s\S]*?)(<\/blockquote>)/gi, protect_function);
	regex(/(<noinclude>)([\s\S]*?)(<\/noinclude>)/gi, protect_function);
	regex(/(<gallery)([\s\S]*?)(<\/gallery>)/gi, protect_function);
	regex(/(<poem>)([\s\S]*?)(<\/poem>)/gi, protect_function);
	regex(/(\{[^\{]{0,6}(?:quot[^|]{1,7}\s?|sic)\|)([^}]+)(\})/gi, protect_function);
	regex(/((?:image\d?|image_skyline|image[ _]location\d?|image[ _]name|image[ _]file|img|map\d|pic)\s*=)([^|}]*)([|}])/gi, protect_function);
	regex(/([\|\{]\s*(?:file(?:name\d?|)|image\d?|image location\d?|img|pic|Cover|(?:trans-?|)title|quote|chapter|journal|url|archiveurl|work|doi|club|at|volume|reporter)\s*=)([^|\}⍍]*)([|}])/gi, protect_function);
	regex(/([\|\{]\s*(?:file(?:name\d?|)|image\d?|image location\d?|img|pic|Cover|(?:trans-?|)title|quote|chapter|journal|url|archiveurl|work|doi|club|at|volume|reporter)\s*=)([^|\}⍍]*)([|}])/gi, protect_function);
	regex(/([\|\{]\s*(?:season)\s*=)(\s*\[\[[^\]]*\]\]\s*)([|}])/gi, protect_function);
	regex(/([\|\{]\s*(?:[xy])\s*=)(\s*[^\|]+\s*)(\|)/gi, protect_function);
	regex(/(\{\{navsource\|)([^}]+)(\})/gi, protect_function);
	regex(/(\{\{(?:singlechart)\|)([^}]+)(\})/gi, protect_function);
	regex(/(\{\{(?:defaultsort|graph):)([^}]+)(\})/gi, protect_function);
	regex(/(["“])([^"”\n]*)(["”])/gi, protect_function);
	regex(/(.)(\(\{\{by\|[12]\d{3}\}\}[-–]\{\{by\|)([12]\d{3}[ ]*\}\}\))/gi, protect_function);
	regex(/(.)(\(\{\{by\|[12]\d{3}\}\}(?:[-–]present|))(\))/gi, protect_function);
	regex(/(\[\[)(4AD)(\]\]|\|)/gi, protect_function);

	//retraining redirects containing a date
	regex(/(\[\[)(?:সেপ্টেম্বর 3 Society)(\]\]|\|)/gi, '$1Jiusan Society$2');
	regex(/(\[\[)(?:জুন 4th incident)(\]\]|\|)/gi, '$1Tiananmen Square protests of 1989$2');
	regex(/(\[\[)(?:5@th? অক্টোবর (?:\(Serbia\)|overthrow))(\]\]|\|)/gi, '$1Overthrow of Slobodan Milošević$2');
	regex(/(\[\[)(?:অক্টোবর 5@th?(?: \(Serbia\)| overthrow|, 2000))(\]\]|\|)/gi, '$1Overthrow of Slobodan Milošević$2');

	//protect alternate meanings of 'মে' and 'মার্চ' (note: not case insensitive)
//	ohc_regex(/([^\w])(@day,?\s{0,3}মে)([^\w][^\d])/g, protect_function);  //disabled 26 মে – not case senstitve: false negatives in converting dates in মে
	ohc_regex(/([^\w])(মার্চ\s@day)(\s(?:mile|kilomet|met))/g, protect_function);

	//protect all links containing a date and some text
	ohc_regex(/(\[\[)(\s*\w[^\]\|\n]+?@day[^\]\|\n]+?@fullmonth[^\]\|\n]*)(\]\]|\|)/gi, protect_function);
	ohc_regex(/(\[\[)([^\]\|\n]*?@day[^\]\|\n]+?@fullmonth(?:,? @year|) \D[^\]\|\n]+\w\s*)(\]\]|\|)/gi, protect_function);
	ohc_regex(/(\[\[)(\s*\w[^\]\|\n]+?@fullmonth[^\]\|\n]+?@day[^\]\|\n]*)(\|)/gi, protect_function);
	ohc_regex(/(\[\[)([^\]\|\n]*?@fullmonth[^\]\|\n]+?@day(?:, @year|) \D[^\]\|\n]+\w\s*)(\]\]|\|)/gi, protect_function);

	//protects certain dates
	regex(/(\[\[)(4AD)([\s\S])/gi, protect_function);
	regex(/([\s\S])(মার্চ (?:8|14) Alliance)([\s\S])/gi, protect_function);
	regex(/([\s\S])(23rd মার্চ 1931: Shaheed)([\s\S])/gi, protect_function);
	regex(/([\s\S])(Long মার্চ [1-7])([\s\S])/gi, protect_function);
	regex(/([\s\S])(National সেপ্টেম্বর 11 Memorial & Museum)([\s\S])/gi, protect_function);
	regex(/([\s\S])(Queen Elizabeth II সেপ্টেম্বর 11th Garden)([\s\S])/gi, protect_function);
	regex(/([\s\S])(Bombay মার্চ 12)([\s\S])/gi, protect_function);
	regex(/([\s\S])(movement 2 জুন)([\s\S])/gi, protect_function);
	regex(/([\s\S])(6th\sof অক্টোবর City)([\s\S])/gi, protect_function);
	regex(/([\s\S])(Party Workers' Liberation Front 30th of মে)([\s\S])/gi, protect_function);
	regex(/([\s\S])(4th\sof আগষ্ট regime)([\s\S])/gi, protect_function);
	regex(/([\s\S])(19th\sof এপ্রিল movement)([\s\S])/gi, protect_function);
	regex(/([\s\S])(জুন 4th (?:incident|museum))([\s\S])/gi, protect_function);
	regex(/([\s\S])(The Battle Of Marston Moor \(জুলাই 2nd,? 1644\))([\s\S])/gi, protect_function);
	regex(/([\s\S])(Night of জানুয়ারি 16th)([\s\S])/gi, protect_function);
	regex(/([\s\S])(Observance of 5th নভেম্বর Act)([\s\S])/gi, protect_function);
	regex(/(\[\[)(13 মে incident)(\|)/gi, protect_function);
	regex(/(\'\'\')(22nd\sof মে)(\'\'\')/gi, protect_function);
	regex(/(\[\[)(22nd\sof মে \(film\))([|\]\'])/gi, protect_function);
	regex(/(\[\[)(জুলাই 12, 2007, Baghdad airstrike)(\|)/gi, protect_function);
	
	regex(/(\[\[)(নভেম্বর 1828)(\]\])/gi, protect_function);
	regex(/(.)(4th\sof জুলাই)(.)/gi, protect_function);
	regex(/(\[\[)((?:2300|2000)\s?AD)(\]\])/gi, protect_function);
	regex(/(\[\[)(29 ফেব্রুয়ারি)(\]\])/gi, protect_function);
	regex(/(\[\[)(ফেব্রুয়ারি 29)(\]\])/gi, protect_function);

	// works names
//	regex(/(.)(protect string)(.)/gi, protect_function);
	regex(/(.)(11\/22\/63)(.)/gi, protect_function);
	regex(/(.)(1\.1\.1994)(.)/gi, protect_function);
	regex(/([\s\S])(2\.13\.61)([\s\S])/gi, protect_function);
//	regex(/(.)(4th of জুলাই, Asbury)(.)/gi, protect_function); //protected above globally
	regex(/(.)(26 অক্টোবর 1993)(.)/gi, protect_function);
	regex(/(\[\[|\'\')(জুন 1, 1974)(.)/gi, protect_function);
	regex(/(\[\[|\'\')(জুলাই 15, 1972)(.)/gi, protect_function);
	regex(/(\[\[|\'\')(আগষ্ট 1914)(.)/gi, protect_function);
	ohc_regex(/(\[\[|\'\')(@fullmonth @dd@th? \((?:@yyyy |)film\)(?:\|@fullmonth @dd@th?|))([\s\S])/gi, protect_function);
	ohc_regex(/(\[\[|\'\')(@dd@th? @fullmonth \((?:@yyyy |)film\)(?:\|@dd@th? @fullmonth|))([\s\S])/gi, protect_function);
//	regex(/(Les Bains Douches 18)( ডিসেম্বর 1979)(.)/gi, protect_function);
	regex(/(আগষ্ট)( 7, 4:15)(.)/gi, protect_function);
	regex(/(In Concert, Zürich, অক্টোবর)( 28, 1979)(.)/gi, protect_function);
	regex(/(CBGB OMFUG Masters: Live জুন)( 29, 2001)(.)/gi, protect_function);
	ohc_regex(/(Live at [\w ]*,? [1-3]\d)( @fullmonth)(.)/gi, protect_function);
	ohc_regex(/(Live at [\w ]*,? @fullmonth)( @dd)(.)/gi, protect_function);
	ohc_regex(/(Bootmoon Series: [\w ]*[-–] @fullmonth)( @day, @YYYY)(.)/gi, protect_function);

// expressions and grammatical strings including modal "মে"
	regex(/(\W)((?:\d{1,3}) মে)((?: have(?: \w+|)|) be)/g, protect_function);
	regex(/(\W)((?:\d{3}|3[2-9]|[4-9]\d)\/\d ডিসেম্বর(?:l\.?|))(\W)/gi, protect_function);
	regex(/(\W)((?:\d{2,3})\/\d ডিসেম্বর(?:l\.?|))( \(\d\d? overs)/gi, protect_function);
}

/** ------------------------------------------------------------------------ **/
/// DATE PROTECTION FOR ALL REF SECTION

var linkmap = [];

function ohc_protect_dates_ref() 
{
	// protects dates within links, quotes, etc
	// the sensitive part is stored and replaced with a unique identifier,
	// which is later replaced with the stored part.

	var protect_function = function (s, begin, replace, end) {
		linkmap.push(replace);
		return begin + "⍌" + (linkmap.length - 1) + "⍍" + end;
	};

	regex(/(<ref\s?(?:>|name=[^>]+))([^<]+)(<\/ref>)/gi, protect_function);
	regex(/(<timeline>)([\s\S]*?)(<\/timeline>)/gi, protect_function);
	regex(/(<math>)([\s\S]*?)(<\/math>)/gi, protect_function);
	regex(/((?:{(?:Wikimedia |)Commons ?|C ?))(Cat(?:egory|))\|[^{}*](})/gi, protect_function);
	regex(/((?:Category|Image|File):)([^|\]]*)([|\]])/gi, protect_function);
	regex(/(\{(?:See ?also|Main))(\|[^}]*)(\})/gi, protect_function);
	regex(/(\{\{(?:double ?|external ?|wide ?)image\s?\|)([^}]+)(\})/gi, protect_function);
	regex(/(\{\{(?:harvnb|wikisource)\|)([^}]+)(\})/gi, protect_function);
	regex(/(\[(?:https?:|ftp:))([^\]]*)(\])/gi, protect_function);
	regex(/(>[ ]*(?:https?:|ftp:))([^< >\]]*)([ ]*<)/gi, protect_function);
	//regex(/(https?:|ftp:)([^\s\]]*)([\s\]])/gi, protect_function);
	regex(/(<blockquote>)([\s\S]*?)(<\/blockquote>)/gi, protect_function);
	regex(/(\{[^\{]{0,6}(?:quot[^|]{1,7}\s?|sic)\|)([^}]+)(\})/gi, protect_function);
	regex(/((?:image\d?|image_skyline|image[ _]location\d?|image[ _]name|image[ _]file|img|pic)\s*=)([^|}]*)([|}])/gi, protect_function);
	regex(/([\|\{]\s*(?:file(?:name\d?|)|image\d?|image location\d?|img|pic|Cover|title|quote|chapter|journal|url|archiveurl|work|doi|club|at|volume|reporter)\s*=)([^|\}⍍]*)([|}])/gi, protect_function);
	regex(/([\|\{]\s*(?:file(?:name\d?|)|image\d?|image location\d?|img|pic|Cover|title|quote|chapter|journal|url|archiveurl|work|doi|club|at|volume|reporter)\s*=)([^|\}⍍]*)([|}])/gi, protect_function);
	regex(/([\|\{]\s*(?:season)\s*=)(\s*\[\[[^\]]*\]\]\s*)([|}])/gi, protect_function);
	regex(/(\{\{navsource\|)([^}]+)(\})/gi, protect_function);
	regex(/(\{\{singlechart\|)([^}]+)(\})/gi, protect_function);
	regex(/(\{\{defaultsort:)([^}]+)(\})/gi, protect_function);
	regex(/([\s\(>]")([^"\n]*)(")/gi, protect_function);
	regex(/([\s\(>]“)([^”\n]*)(”)/gi, protect_function);
	regex(/(.)(\(\{\{by\|[12]\d{3}\}\}[-–]\{\{by\|)([12]\d{3}[ ]*\}\}\))/gi, protect_function);
	regex(/(.)(\(\{\{by\|[12]\d{3}\}\}(?:[-–]present|))(\))/gi, protect_function);

	//retraining redirects containing a date
	regex(/(\[\[)(?:সেপ্টেম্বর 3 Society)(\]\]|\|)/gi, '$1Jiusan Society$2');
	regex(/(\[\[)(?:জুন 4th incident)(\]\]|\|)/gi, '$1Tiananmen Square protests of 1989$2');
	ohc_regex(/(\[\[)(?:5@th? অক্টোবর (?:\(Serbia\)|overthrow))(\]\]|\|)/gi, '$1Overthrow of Slobodan Milošević$2');
	ohc_regex(/(\[\[)(?:অক্টোবর 5@th?(?: \(Serbia\)| overthrow|, 2000))(\]\]|\|)/gi, '$1Overthrow of Slobodan Milošević$2');

	//protect alternate meanings of 'মে' and 'মার্চ' (note: not case insensitive)
	ohc_regex(/([^\w])(@day,?\s{0,3}মে)([^\w][^\d])/g, protect_function);
	ohc_regex(/([^\w])(মার্চ\s@day)(\s(?:mile|kilomet|met))/g, protect_function);

	//protect all links containing a date and some text
	ohc_regex(/(\[\[)(\s*\w[^\]\|\n]+?@day[^\]\|\n]+?@fullmonth[^\]\|\n]*)(\]\]|\|)/gi, protect_function);
	ohc_regex(/(\[\[)([^\]\|\n]*?@day[^\]\|\n]+?@fullmonth(?:,? @year|) \D[^\]\|\n]+\w\s*)(\]\]|\|)/gi, protect_function);
	ohc_regex(/(\[\[)(\s*\w[^\]\|\n]+?@fullmonth[^\]\|\n]+?@day[^\]\|\n]*)(\|)/gi, protect_function);
	ohc_regex(/(\[\[)([^\]\|\n]*?@fullmonth[^\]\|\n]+?@day(?:, @year|) \D[^\]\|\n]+\w\s*)(\]\]|\|)/gi, protect_function);

	//protects certain dates
	regex(/(\[\[)(4AD)([\s\S])/gi, protect_function);
	regex(/([\s\S])(মার্চ (?:8|14) Alliance)([\s\S])/gi, protect_function);
	regex(/([\s\S])(23rd মার্চ 1931: Shaheed)([\s\S])/gi, protect_function);
	regex(/([\s\S])(Long মার্চ [1-7])([\s\S])/gi, protect_function);
	regex(/([\s\S])(Bombay মার্চ 12)([\s\S])/gi, protect_function);
	regex(/([\s\S])(movement 2 জুন)([\s\S])/gi, protect_function);
	regex(/([\s\S])(6th\sof অক্টোবর City)([\s\S])/gi, protect_function);
	regex(/([\s\S])(Party Workers' Liberation Front 30th of মে)([\s\S])/gi, protect_function);
	regex(/([\s\S])(4th\sof আগষ্ট regime)([\s\S])/gi, protect_function);
	regex(/([\s\S])(19th\sof এপ্রিল movement)([\s\S])/gi, protect_function);
	regex(/([\s\S])(জুন 4th incident)([\s\S])/gi, protect_function);
	regex(/([\s\S])(The Battle Of Marston Moor \(জুলাই 2nd,? 1644\))([\s\S])/gi, protect_function);
	regex(/([\s\S])(Night of জানুয়ারি 16th)([\s\S])/gi, protect_function);
	regex(/([\s\S])(Observance of 5th নভেম্বর Act)([\s\S])/gi, protect_function);
	regex(/(\[\[)(13 মে incident)(\|)/gi, protect_function);
	regex(/(\'\'\')(22nd\sof মে)(\'\'\')/gi, protect_function);
	regex(/(\[\[)(22nd\sof মে \(film\))([|\]\'])/gi, protect_function);
	regex(/(\[\[)(জুলাই 12, 2007, Baghdad airstrike)(\|)/gi, protect_function);
	
	regex(/(\[\[)(নভেম্বর 1828)(\]\])/gi, protect_function);
	regex(/(.)(4th\sof জুলাই)(.)/gi, protect_function);
	regex(/(\[\[)((?:2300|2000)\s?AD)(\]\])/gi, protect_function);
	regex(/(\[\[)(29 ফেব্রুয়ারি)(\]\])/gi, protect_function);
	regex(/(\[\[)(ফেব্রুয়ারি 29)(\]\])/gi, protect_function);

	// works names
	//regex(/(.)(protect string)(.)/gi, protect_function);
	regex(/(.)(11\/22\/63)(.)/gi, protect_function);
	regex(/(.)(1\.1\.1994)(.)/gi, protect_function);
	regex(/([\s\S])(2\.13\.61)([\s\S])/gi, protect_function);
	//regex(/(.)(4th of জুলাই, Asbury)(.)/gi, protect_function); //protected above globally
	regex(/(.)(26 অক্টোবর 1993)(.)/gi, protect_function);
	regex(/(\[\[|\'\')(জুন 1, 1974)(.)/gi, protect_function);
	regex(/(\[\[|\'\')(জুলাই 15, 1972)(.)/gi, protect_function);
	regex(/(\[\[|\'\')(আগষ্ট 1914)(.)/gi, protect_function);
	ohc_regex(/(\[\[|\'\')(@fullmonth @dd@th? \((?:@yyyy |)film\)(?:\|@fullmonth @dd@th?|))([\s\S])/gi, protect_function);
	ohc_regex(/(\[\[|\'\')(@dd@th? @fullmonth \((?:@yyyy |)film\)(?:\|@dd@th? @fullmonth|))([\s\S])/gi, protect_function);
	//regex(/(Les Bains Douches 18)( ডিসেম্বর 1979)(.)/gi, protect_function);
	regex(/(আগষ্ট)( 7, 4:15)(.)/gi, protect_function);
	regex(/(In Concert, Zürich, অক্টোবর)( 28, 1979)(.)/gi, protect_function);
	regex(/(CBGB OMFUG Masters: Live জুন)( 29, 2001)(.)/gi, protect_function);
	ohc_regex(/(Live at [\w ]*,? [1-3]\d)( @fullmonth)(.)/gi, protect_function);
	ohc_regex(/(Live at [\w ]*,? @fullmonth)( @dd)(.)/gi, protect_function);
	ohc_regex(/(Bootmoon Series: [\w ]*[-–] @fullmonth)( @day, @YYYY)(.)/gi, protect_function);

	regex(/(\W)((?:\d{3}|3[2-9]|[4-9]\d)\/\d ডিসেম্বর(?:l\.?|))(\W)/gi, protect_function);
	regex(/(\W)((?:\d{2,3})\/\d ডিসেম্বর(?:l\.?|))( \(\d\d? overs)/gi, protect_function);
}


/** ------------------------------------------------------------------------ **/
/// DATE PROTECTION FOR SLASH modules

var linkmap = [];

function ohc_protect_dates_slash() 
{
	// protects dates within links, quotes, etc
	// the sensitive part is stored and replaced with a unique identifier,
	// which is later replaced with the stored part.

	var protect_function = function (s, begin, replace, end) {
		linkmap.push(replace);
		return begin + "⍌" + (linkmap.length - 1) + "⍍" + end;
	};

	regex(/(<ref\s?(?:>|name=[^>]+))([^<]+)(<\/ref>)/gi, protect_function);
	regex(/(<timeline>)([\s\S]*?)(<\/timeline>)/gi, protect_function);
	regex(/(<math>)([\s\S]*?)(<\/math>)/gi, protect_function);
	regex(/((?:{(?:Wikimedia |)Commons ?|C ?))(Cat(?:egory|))\|[^{}*](})/gi, protect_function);
	regex(/((?:Category|Image|File):)([^|\]]*)([|\]])/gi, protect_function);
	regex(/(\{(?:See ?also|Main))(\|[^}]*)(\})/gi, protect_function);
	regex(/(\{\{(?:double ?|external ?|wide ?)image\s?\|)([^}]+)(\})/gi, protect_function);
	regex(/(\{\{(?:harvnb|wikisource)\|)([^}]+)(\})/gi, protect_function);
	regex(/(\[(?:https?:|ftp:))([^\]]*)(\])/gi, protect_function);
	regex(/(>[ ]*(?:https?:|ftp:))([^< >\]]*)([ ]*<)/gi, protect_function);
	//regex(/(https?:|ftp:)([^\s\]]*)([\s\]])/gi, protect_function);
	regex(/(<blockquote>)([\s\S]*?)(<\/blockquote>)/gi, protect_function);
	regex(/(\{[^\{]{0,6}(?:quot[^|]{1,7}\s?|sic)\|)([^}]+)(\})/gi, protect_function);
	regex(/((?:image\d?|image_skyline|image[ _]location\d?|image[ _]name|image[ _]file|img|pic)\s*=)([^|}]*)([|}])/gi, protect_function);
	regex(/([\|\{]\s*(?:file(?:name\d?|)|image\d?|image location\d?|img|pic|Cover|title|quote|chapter|journal|url|archiveurl|work|doi|club|at|volume|reporter)\s*=)([^|\}⍍]*)([|}])/gi, protect_function);
	regex(/([\|\{]\s*(?:file(?:name\d?|)|image\d?|image location\d?|img|pic|Cover|title|quote|chapter|journal|url|archiveurl|work|doi|club|at|volume|reporter)\s*=)([^|\}⍍]*)([|}])/gi, protect_function);
	regex(/([\|\{]\s*(?:season)\s*=)(\s*\[\[[^\]]*\]\]\s*)([|}])/gi, protect_function);
	regex(/(\{\{navsource\|)([^}]+)(\})/gi, protect_function);
	regex(/(\{\{singlechart\|)([^}]+)(\})/gi, protect_function);
	regex(/(\{\{defaultsort:)([^}]+)(\})/gi, protect_function);
	regex(/([\s\(>]")([^"\n]*)(")/gi, protect_function);
	regex(/([\s\(>]“)([^”\n]*)(”)/gi, protect_function);
	regex(/(.)(\(\{\{by\|[12]\d{3}\}\}[-–]\{\{by\|)([12]\d{3}[ ]*\}\}\))/gi, protect_function);
	regex(/(.)(\(\{\{by\|[12]\d{3}\}\}(?:[-–]present|))(\))/gi, protect_function);

}

function ohc_unprotect_dates() 
{
	//unprotect all dates
	regex(/[♫]/g, '');
	regex(/⍌([0-9]+)⍍/g, function (x, n) {
		var res = linkmap[n];
		res = res.replace(/⍌([0-9]+)⍍/g, function (x, n) {
			var res = linkmap[n];
			res = res.replace(/⍌([0-9]+)⍍/g, function (x, n) {
				var res = linkmap[n];
				res = res.replace(/⍌([0-9]+)⍍/g, function (x, n) {
					return linkmap[n];
				});
				return res;
			});
			return res;
		});
		return res;
	});
}

function ohc_MOSNUM_edit_summary() 
{
	//Add a tag to the summary box
	setoptions(minor = 'true');
	setreason('date formats per [[MOS:DATEFORMAT]] by [[WP:MOSNUMscript|script]]', 'append');
	doaction('diff');
}

function ohc_bigendien_edit_summary() 
{
	//Add a tag to the summary box
	setoptions(minor = 'true');
	setreason('ymd ref dates', 'append');
	doaction('diff');
}

function ohc_expand_edit_summary() 
{
	//Add a tag to the summary box
	setoptions(minor = 'true');
	setreason('expand month names', 'append');
	doaction('diff');
}

function ohc_slash_edit_summary() 
{
	//Add a tag to the summary box
	setoptions(minor = 'true');
	setreason('resolved slash dates', 'append');
	doaction('diff');
}

function ohc_abbrev_edit_summary() 
{
	//Add a tag to the summary box
	setoptions(minor = 'true');
	setreason('abbrev month names', 'append');
	doaction('diff');
}

/** ------------------------------------------------------------------------ **/
/// CUSTOMIZATION POINTS
function ohc_customize_all_to_dmy() {
}

function ohc_customize_all_to_mdy() {
}

function ohc_customize_body_to_dmy() {
}

function ohc_customize_body_to_mdy() {
}

function ohc_customize_ISO_to_dmy() {
}

function ohc_customize_ISO_to_mdy() {
}

/** ------------------------------------------------------------------------ **/
function ohc_body_dates_to_dmy() 
{
	ohc_use_dates_template('dmy');

	ohc_fix_common_errors();
	ohc_fix_dts_template('dmy');
	ohc_fix_gr_template('dmy');
	ohc_dates_to_dmy();
	ohc_remove_leading_zeroes();
	ohc_fix_dmy_redundancies();
}

function ohc_body_dates_to_mdy() 
{
	ohc_use_dates_template('mdy');
	ohc_fix_common_errors();
	ohc_fix_dts_template('mdy');
	ohc_fix_gr_template('mdy');
	ohc_dates_to_mdy();
	ohc_remove_leading_zeroes();
	ohc_fix_mdy_redundancies();
}

/** ------------------------------------------------------------------------ **/
function ohc_all_to_dmy_driver(e) 
{
	e.preventDefault();
	ohc_delink_dates();
	ohc_protect_dates();
	ohc_fix_unambiguous_dates();
	ohc_body_dates_to_dmy();
	ohc_delink_ISO_to_dmy();
	ohc_delink_year_in_X();
	ohc_customize_all_to_dmy();
	ohc_ISO_to_dmy_in_citations();
	ohc_unprotect_dates();

	ohc_MOSNUM_edit_summary();
}

function ohc_all_to_mdy_driver(e) 
{
	e.preventDefault();
	ohc_delink_dates();
	ohc_protect_dates();
	ohc_fix_unambiguous_dates();
	ohc_body_dates_to_mdy();
	ohc_delink_ISO_to_mdy();
	ohc_delink_year_in_X();
	ohc_customize_all_to_mdy();
	ohc_ISO_to_mdy_in_citations();
	ohc_unprotect_dates();

	ohc_MOSNUM_edit_summary();
}

function ohc_dmy_publication_dates_driver(e) 
{
	e.preventDefault();
//	ohc_delink_dates();
	ohc_protect_dates();
	ohc_body_dates_to_dmy();
	ohc_customize_body_to_dmy();
	ohc_dmy_publication_dates();
	ohc_unprotect_dates();

	ohc_MOSNUM_edit_summary();
}

function ohc_mdy_publication_dates_driver(e) 
{
	e.preventDefault();
//	ohc_delink_dates();
	ohc_protect_dates();
	ohc_body_dates_to_mdy();
	ohc_customize_body_to_mdy();
	ohc_mdy_publication_dates();
	ohc_unprotect_dates();

	ohc_MOSNUM_edit_summary();

}

function ohc_body_to_dmy_driver(e) 
{
	e.preventDefault();
//	ohc_delink_dates();
	ohc_protect_dates_ref();
	ohc_body_dates_to_dmy();
	ohc_customize_body_to_dmy();
	ohc_unprotect_dates();

	ohc_MOSNUM_edit_summary();
}

function ohc_body_to_mdy_driver(e) 
{
	e.preventDefault();
//	ohc_delink_dates();
	ohc_protect_dates_ref();
	ohc_body_dates_to_mdy();
	ohc_customize_body_to_mdy();
	ohc_unprotect_dates();

	ohc_MOSNUM_edit_summary();
}

function ohc_ISO_to_dmy_driver(e) 
{
	e.preventDefault();
	ohc_protect_dates();
	ohc_delink_ISO_to_dmy();
	ohc_customize_ISO_to_dmy();
	ohc_unprotect_dates();

//	ohc_MOSNUM_edit_summary();
}

function ohc_ISO_to_mdy_driver(e) {
	e.preventDefault();
	ohc_protect_dates();
	ohc_delink_ISO_to_mdy();
	ohc_customize_ISO_to_mdy();
	ohc_unprotect_dates();

//	ohc_MOSNUM_edit_summary();
}

function ohc_delink_year_in_X_driver(e) 
{
	e.preventDefault();
	ohc_delink_year_in_X();
}

function ohc_expand_ref_dates_driver(e) {
	e.preventDefault();
	ohc_expand_ref_dates();
	ohc_protect_dates();
	ohc_unprotect_dates();
	ohc_expand_edit_summary();
}

function ohc_expand_all_dates_driver(e) 
{
	e.preventDefault();
	ohc_expand_ref_dates();
	ohc_protect_dates();
	ohc_expand_all_dates();
	ohc_unprotect_dates();
	ohc_expand_edit_summary();
}

function ohc_abbrev_ref_dates_driver(e) 
{
	e.preventDefault();
	ohc_protect_dates();
	ohc_abbrev_ref_dates();
	ohc_unprotect_dates();
	ohc_slash_edit_summary();
}

function ohc_UK_slash_dates_driver(e) 
{
	e.preventDefault();
	ohc_expand_ref_dates();
	ohc_protect_dates_slash();
		ohc_UK_slash_dates_to_dmy();
	ohc_unprotect_dates();
	ohc_slash_edit_summary();
}

function ohc_US_slash_dates_driver(e) 
{
	e.preventDefault();
	ohc_expand_ref_dates();
	ohc_protect_dates_slash();
		ohc_US_slash_dates_to_mdy();
	ohc_unprotect_dates();
	ohc_expand_edit_summary();
}

// </pre>

//সংশ্লিষ্ট পাতা ত্যাগ না করেই অন্য পাতা থেকে পুনর্নির্দেশ করা যাবে।
//<nowiki>
( function () {
	var redir = $(mw.util.addPortletLink('p-tb','#','পুনর্নির্দেশক','পুনর্নির্দেশ তৈরিকারী','পুনর্নির্দেশ তৈরিকারী','','#pt-mytalk'));
	$( redir ).click( function() {
			var redirec = prompt("যে পাতা থেকে এই পাতায় পুনর্নির্দেশ করতে চান তার নাম লিখুন:", "");
		  if (redirec === null || redirec === "") {
				alert( 'আপনি কোনও নাম প্রবেশ করান নি। দয়া করে আবার চেষ্টা করুন।' );	  
		  } else  {
			   var params = {
					action: 'edit',
					title: redirec ,
					createonly: 1,
					prependtext: '#পুনর্নির্দেশ [[' + mw.config.get("wgPageName") + ']]',
					appendtext: " \n" + '{{একটি পুনর্নির্দেশ}}',
					summary: '[[' + mw.config.get("wgPageName") + ']] পাতায় পুনর্নির্দেশ করা হল' ,
					format: 'json'
				};
				api = new mw.Api();
			api.postWithToken( 'csrf', params ).done( function ( data ) {
				alert( 'সফলভাবে ' + redirec + ' পাতা থেকে একটি পুনর্নির্দেশ তৈরি করা হয়েছে!' );
			});
		  }
			}
	);
}() );
//</nowiki>

//<nowiki>
( function () {
	var talkp = $(mw.util.addPortletLink('p-tb','#','স্বাগত জানান','স্বাগত জানান','স্বাগত জানান','','#pt-mytalk'));
	$( talkp ).click( function() {
			var talk = prompt("কোন ধরনের স্বাগত বার্তা যুক্ত করতে চান এমন টেমপ্লেটটি লিখুন {{Subst:}} সাথে, অন্যথায় পূর্বনির্ধারিত {{Subst:স্বাগতম}} যুক্ত হবে:", "");
		  if (talk === null || talk === "") {
		    var params1 = {
					action: 'edit',
					title: 'User talk:' + mw.config.get("wgRelevantUserName"),
					prependtext: '{{Subst:স্বাগতম}}'
					,
					summary: 'ভারতপিডিয়ায় স্বাগতম!',
					format: 'json'
				};
				api = new mw.Api();
			
			api.postWithToken( 'csrf', params1 ).done( function ( data ) {
				alert( 'সফলভাবে স্বাগত জানানো হয়েছে!' );
			} );
		  
		  } else {
			   var params = {
					action: 'edit',
					title: 'User talk:' + mw.config.get("wgRelevantUserName"),
					prependtext: talk
					,
					summary: 'ভারতপিডিয়ায় স্বাগত!',
					format: 'json'
				};
				api = new mw.Api();
			
			api.postWithToken( 'csrf', params ).done( function ( data ) {
				alert( 'সফলভাবে স্বাগত জানানো হয়েছে!' );
			} );
		  }
			}
	);
}() );
//</nowiki>
//<nowiki>
console.time('mobileUndo');
$.when(mw.loader.using(['mediawiki.util', 'mediawiki.api', 'oojs-ui-windows', 'oojs-ui-core', 'oojs-ui.styles.icons-editing-core'])).then(function() {
    return new mw.Api().getMessages(['editundo', 'Undo-nochange']);
}).then(function(globalmessages) {
    var mobileUndo, i18n_lang = mw.config.get('wgUserLanguage');
    var i18n = {
        "en": {
            "mu-success": "Successful",
            "mu-fail": "Failed",
            "mu-loading": "Loading...",
            "editsummary-ad": "",
            "mu-undo-successful": "Revert successful.... Reloading in a sec",
            "mu-empty-reponse-from-server": "An empty response was received from the server",
            "mu-edit-summary-prompt": "Add a reason to your edit summary !",
            "mu-edit-summary-prompt-placeholder": "Reason...",
            "mu-thank-success": "Thanked",
            "mu-thank-confirm": "Send public thanks ?",
            "mu-thank-loading": "Thanking...",
            "mu-thank-successful": "You thanked $1.",
            "mu-thank-failed": "Failed to thank $1.",
            "mu-http-error":"HTTP error: "
        },
        "bn": {
            "mu-success": "সফল",
            "mu-fail": "ব্যর্থ হয়েছে",
            "mu-loading": "লোড করা হচ্ছে...",
            "editsummary-ad": "",
            "mu-undo-successful": "পূর্বাবস্থায় ফেরত যাওয়া সফল হয়েছে.... পুনঃলোড করা হচ্ছে",
            "mu-empty-reponse-from-server": "সার্ভার থেকে একটি খালি প্রতিক্রিয়া পাওয়া গেছে।",
            "mu-edit-summary-prompt": "সম্পাদনা সারাংশে কারণ উল্লেখ করুন!",
            "mu-edit-summary-prompt-placeholder": "কারণ...",
            "mu-thank-success": "ধন্যবাদ দিয়েছেন",
            "mu-thank-confirm": "প্রকাশ্য ধন্যবাদ জানাবেন?",
            "mu-thank-loading": "ধন্যবাদ জানানো হচ্ছে...",
            "mu-thank-successful": "আপনি $1 কে ধন্যবাদ জানিয়েছেন।",
            "mu-thank-failed": "$1 কে ধন্যবাদ জানানো ব্যর্থ হয়েছে।",
            "mu-http-error":"HTTP ত্রুটি: "
        }
    };
	if(undefined === i18n[i18n_lang]){
		i18n_lang = 'en';
	}
    if (mw.config.get('wgCanonicalSpecialPageName') === 'MobileDiff') {
        mw.util.addCSS('#mw-mf-userinfo .mobileUndo-ui .mw-ui-icon.mw-ui-icon-before:before{display:none;}\n#mobileUndo > a > span.oo-ui-iconElement-icon.oo-ui-icon-editUndo.oo-ui-image-invert{display:inline-block; position:initial;}\n#mobileUndo > a{padding:0.57142857em 0.9375em;}'+
        '#mw-mf-userinfo > div > div.mobileUndo-ui > a > div{line-height:normal;}');
        if (mw.config.get('wgVisualEditor').pageLanguageDir === 'ltr') {
            $('#mw-mf-userinfo .post-content').append($('<div>').attr('class', 'mobileUndo-ui').css({
                'display': 'inline-block',
                'float': 'right'
            }));
        } else {
            $('#mw-mf-userinfo .post-content').append($('<div>').attr('class', 'mobileUndo-ui').css({
                'display': 'inline-block',
                'float': 'left'
            }));
        }
        $('.mobileUndo-ui').append($('.mw-mf-action-button').remove().css({
            'clear': 'none'
        }));
        if (!$('.warningbox').length && mw.config.get('wgRelevantPageIsProbablyEditable')) {
            mobileUndo = new OO.ui.ButtonWidget({
                label: (globalmessages.editundo).charAt(0).toUpperCase() + (globalmessages.editundo).slice(1),
                icon: 'editUndo',
                title: 'mobileUndo',
                flags: ['destructive', 'primary'],
                id: 'mobileUndo'
            });
            $('.mobileUndo-ui').append(mobileUndo.$element);
            if (mw.config.get('wgVisualEditor').pageLanguageDir === 'ltr') {
                $('#mobileUndo').css('margin-right', '0.3em');
            } else {
                $('#mobileUndo').css('margin-left', '0.3em');
            }
        }
        window.wgRelevantUser = function() {
            var user;
            if ($('.mw-mf-user-link').text() !== '') {
                user = $('.mw-mf-user-link').text();
            } else {
                user = $('#mw-mf-userinfo .post-content div:nth-child(2)').text();
            }
            return user;
        };
        window.wgRevId = ($('#mw-mf-diffarea > div.mw-mf-diff-info > h3 > a').attr('href')).split('&oldid=')[1];
        var revId = wgRevId;
        console.log(revId);
        var username = wgRelevantUser();
        $('#mw-mf-userinfo .post-content .mobileUndo-ui .mw-mf-action-button').click(function(e) {
            e.preventDefault();
            OO.ui.confirm(i18n[i18n_lang]['mu-thank-confirm']).done(function(confirmed) {
                if (confirmed) {
                    $('.mw-mf-action-button').css('pointer-events', 'none').text(i18n[i18n_lang]['mu-thank-loading']);
                    var api = new mw.Api();
                    api.postWithToken('csrf', {
                        action: "thank",
                        rev: revId,
                    }).done(function(result) {
                        mw.notify((i18n[i18n_lang]['mu-thank-successful']).replace(/\$1/g, username));
                        $('.mw-mf-action-button').text(i18n[i18n_lang]['mu-thank-success']);
                    }).fail(function() {
                        mw.notify((i18n[i18n_lang]['mu-thank-failed']).replace(/\$1/g, username));
                        $('.mw-mf-action-button').text(i18n[i18n_lang]['mu-failed']);
                    });
                }
            });
        });
        console.timeEnd('mobileUndo');
        mobileUndo.on('click', function() {
            OO.ui.prompt(i18n[i18n_lang]['mu-edit-summary-prompt'], {
                textInput: {
                    placeholder: i18n[i18n_lang]['mu-edit-summary-prompt-placeholder'] 
                }
            }).done(function(customEditSummary) {
                $.when(mw.loader.using('mediawiki.api')).then(function() {
                    return new mw.Api().getMessages(['undo-summary'], {
                        amlang: mw.config.get('wgServerName').split('.wik')[0]
                    });
                }).then(function(message) {
                    var editSummaryMessage = message['undo-summary'];
                    var editSummary = editSummaryMessage.replace(/\$1/g, revId);
                    editSummary = editSummary.replace(/\$2/g, username);
                    if (customEditSummary !== null) {
                        mobileUndo.setDisabled(true);
                        editSummary = editSummary + ' ' + customEditSummary + (i18n[i18n_lang]['editsummary-ad']);
                        //call the API
                        var api = new mw.Api({
                            ajax: {
                                headers: {
                                    'Api-User-Agent': 'mobileUndo/2.0.2(https://en.wikipedia.org/wiki/User:FR30799386/undo.js)'
                                }
                            }
                        });
                        //Feedback UI
                        mobileUndo.setLabel(i18n[i18n_lang]['mu-loading']);
                        api.postWithToken('csrf', {
                            action: "edit",
                            title: mw.config.get('wgRelevantPageName'),
                            summary: editSummary,
                            undo: revId,
                        }).done(function(result) {
                            if (result.edit.code === 'abusefilter-warning' || result.edit.code === 'abusefilter-disallowed') {
                                mobileUndo.setLabel(i18n[i18n_lang]['mu-fail']);
                                OO.ui.alert($('<p>').html(result.edit.warning), {
                                    title: result.edit.info
                                }).done(function() {});
                                return;
                            } else if (typeof result.edit.nochange !== 'undefined') {
                                mobileUndo.setLabel(i18n[i18n_lang]['mu-fail']);
                                OO.ui.alert($('<p>').html(globalmessages['Undo-nochange'])).done(function() {});
                                return;
                            }
                            console.log(result);
                            mobileUndo.setLabel(i18n[i18n_lang]['mu-success']);
                            mw.notify(i18n[i18n_lang]['mu-undo-successful']);
                            setTimeout(function() {
                                location.href = mw.util.getUrl('Special:MobileDiff/' + result.edit.newrevid);
                            }, 1500);
                        }).fail(function(code, jqxhr) {
                            mobileUndo.setLabel(i18n[i18n_lang]['mu-fail']);
                            var details;
                            if (code === 'http' && jqxhr.textStatus === 'error') {
                                details = i18n[i18n_lang]['mu-http-error'] + jqxhr.xhr.status;
                            } else if (code === 'http') {
                                details = i18n[i18n_lang]['mu-http-error'] + jqxhr.textStatus;
                            } else if (code === 'ok-but-empty') {
                                details = i18n[i18n_lang]['mu-empty response-from-server'];
                            } else {
                                details = jqxhr.error.info;
                            }
                            OO.ui.alert($('<p>').html(details)).done(function() {});
                        });
                    }
                });
            });
        });
    }
});
//End of code
//</nowiki>
window.wgRelevantUser = function() {
    var user;
    	if ($('.mw-mf-user-link').text() !== '') {
        	user = $('.mw-mf-user-link').text();
    	} else {
        	user = $('#mw-mf-userinfo .post-content div:nth-child(2)').text();
    	}
    return user;
    };
var href = ($('#mw-mf-diffarea > div.mw-mf-diff-info > h3 > a').attr('href')) || '';
window.wgRevId = href.split('&oldid=')[1];
if( $('#mw-mf-diffarea > ul > li.revision-history-next').length ) {
	$('#mw-mf-diffarea > div.mw-mf-diff-info > h3').append(
		$('<a>').attr('id','mobileRestore').attr('href','javascript:void(0)').append(
			$('<b>').text('(পুনরুদ্ধার)')
		)
	);
}
$('#mobileRestore').click(function(e){
	e.preventDefault();
	$('#mobileRestore b').text('(লোড হচ্ছে....)');
	$('#mobileRestore').css('pointer-events','none');
	var customEditSummary = prompt('পুনরুদ্ধারের কারণ (ঐচ্ছিক)');
	if(customEditSummary === null) {
		$('#mobileRestore b').text('(পুনরুদ্ধার)');
		$('#mobileRestore').css('pointer-events','auto');
		return;
	}
	var username =wgRelevantUser();
	var editSummary = '[[Special:Contributions/'+username+'|'+username+']] ([[User talk:'+username+'|আলাপ]])-এর করা ' +wgRevId+ 'নং সংস্করণ পুনরুদ্ধার করা হয়েছে';
	editSummary = editSummary + customEditSummary + ' (পুনরুদ্ধারায়ন)';
	$.when(mw.loader.load('mediawiki.api')).then(function(){
		var api = new mw.Api();
		api.get({
			'action':'query',
			'prop':'revisions',
			'titles':mw.config.get('wgRelevantPageName'),
			'rvprop':'ids'
		}).done(function(result){
			if(result.query.pages) {
				var StartRevId = result.query.pages[mw.config.get('wgRelevantArticleId')].revisions[0].revid;
				console.log(StartRevId);
				api.postWithToken('csrf', {
                    action: "edit",
                    title: mw.config.get('wgRelevantPageName'),
                    summary: editSummary,
                    undo:StartRevId,
					undoafter:wgRevId,
                }).done(function(result) {
                    if (typeof result.edit.nochange !== 'undefined') {
                    	$('#mobileRestore b').text('(Failed)');
						alert( 'No change occured');
                        return;
                    }
					console.log(result);
					$('#mobileRestore b').text('(সফলভাবে হয়েছে)')
                    mw.notify('সংস্করণ পুনরুদ্ধার সফল হয়েছে.... পুনঃলোড করা হচ্ছে');
					setTimeout(function() {
                      location.href = mw.util.getUrl('Special:MobileDiff/' + result.edit.newrevid);
                    }, 1500);
                }).fail(function(code, jqxhr) {
                	$('#mobileRestore b').text('(পুনরুদ্ধার কার্য বাতিল করা হয়েছে)');
                    var details;
                    if (code === 'http' && jqxhr.textStatus === 'error') {
                        details = 'HTTP error: ' + jqxhr.xhr.status;
                    } else if (code === 'http') {
                        details = 'HTTP error: ' + jqxhr.textStatus;
                    } else if (code === 'ok-but-empty') {
                        details = 'An empty response was given the server';
                    } else {
                        details = jqxhr.error.info;
                    }
                    alert( details );
                });
			} else {
				alert('Failed to retrieve page details');
			}
		});
	});
});

//history
mw.loader.load('//bn.bharatpedia.org/index.php?title=ব্যবহারকারী:রবি/মোবাইল পার্থক্য ইতিহাস.js&action=raw&ctype=text/javascript');

//my common.js
$.when(mw.loader.using(['mediawiki.util'], $.ready)).done( function() {
	mw.util.addPortletLink("p-tb", mw.config.get('wgArticlePath').replace('$1', "ব্যবহারকারী:রবি/common.js"), "common.js", "tb-awbscript", "Personal common.js");
});

if (mw.config.get('wgCanonicalNamespace')+':'+mw.config.get('wgTitle') === 'ব্যবহারকারী:রবি/common.js' && mw.config.get('wgAction') == 'view');

//শীর্ষক
mw.loader.load('//bn.bharatpedia.org/index.php?title=ব্যবহারকারী:রবি/উপর নীচ.js&action=raw&ctype=text/javascript');

//Purge
mw.loader.load('//bn.bharatpedia.org/index.php?title=ব্যবহারকারী:রবি/পুনঃসতেজ.js&action=raw&ctype=text/javascript');

/** Quick Edit **/
mw.loader.load('//bn.bharatpedia.org/index.php?title=ব্যবহারকারী:রবি/দ্রুত সম্পাদনা.js&action=raw&ctype=text/javascript');

//page creation
mw.loader.load('//bn.bharatpedia.org/index.php?title=ব্যবহারকারী:রবি/পাতা সৃষ্টিকারক.js&action=raw&ctype=text/javascript');

//redirect fix
$(function() { 	$('#mw-content-text .mw-redirect').after(function() { 		return this.href.indexOf('action=edit') !== -1 || this.href.indexOf('action=') !== -1  || this.href.indexOf('diff=') !== -1 ? '' 			: '<a href="' + 			this.href + 			(this.href.includes('?') ? '&' : '?') + 			'action=edit" title="' + 			(this.title || this.href) + 			' (edit redirect)"><sup>(→)</sup></a>'; 	}); });

//cleanup
mw.loader.load('//bn.bharatpedia.org/index.php?title=ব্যবহারকারী:রবি/পরিষ্কারকরণ.js&action=raw&ctype=text/javascript');