Увага: Після публікування слід очистити кеш браузера, щоб побачити зміни.

  • Firefox / Safari: тримайте Shift, коли натискаєте Оновити, або натисніть Ctrl-F5 чи Ctrl-Shift-R (⌘-R на Apple Mac)
  • Google Chrome: натисніть Ctrl-Shift-R (⌘-Shift-R на Apple Mac)
  • Internet Explorer / Edge: тримайте Ctrl, коли натискаєте Оновити, або натисніть Ctrl-F5
  • Opera: натисніть Ctrl-F5
$(function () {
	if( mw.config.get( 'wgNamespaceNumber' ) !== 250 ) {
		return;
	}

    if ($('#editform').length) {
        $('#wpTextbox1').on( 'wikiEditor-toolbar-doneInitialSections', function() {

			$('#wpTextbox1' ).wikiEditor( 'addToToolbar', {
                section: 'main',
                groups: {
                    user: {
                        label: 'User`s'
                        }
                    }
                });

            $('#wpTextbox1').wikiEditor('addToToolbar', {
				section: 'characters',
				pages: {
					diacritic: {
						layout: 'characters',
						label: 'Diacritics',
						characters: [ '\u0301', '\u0300', '\u0302', '\u0317', '\u031C'  ]
						}
					}
			});


			var buttons = new Array (
	['id', replaceMain, 'Заміна', '6/67/OOjs_UI_icon_book-ltr-progressive.svg'],
	['id0', replacePoem, 'Поезія', '3/3d/OOjs_UI_icon_citeArticle-ltr-progressive.svg'],
	['id1', replacePoem1, '--', 'b/bc/Header_and_footer_toolbar_button.svg'],
	['id2', replacePoem2, 'F', 'b/b9/OOjs_UI_icon_table-insert-row-after-progressive.svg'],
	['id3', replacePoem3, 'H', '8/8a/OOjs_UI_icon_table-insert-row-before-progressive.svg'],
	['id4', replacePoem4, 'HF', 'b/b2/OOjs_UI_icon_alignCenter-progressive.svg'],
	['id5', replacePoem5, 'Чистка колонтитулів', 'd/d0/OOjs_UI_icon_clear-progressive.svg'],
	['id_zh', replace4zheleh, 'Жел.', 'c/cc/OOjs_UI_icon_bold-cyrl-zhe-progressive.svg'],
	['id_t', replaceLat2Cyr, 'Лат->Кир', 'e/e0/OOjs_UI_icon_language-ltr-progressive.svg'],
	['id_ya', yaryzhka, 'Ярижка', 'thumb/9/98/Cirila-ъ-minuskla.svg/48px-Cirila-ъ-minuskla.svg.png'],
	['id_cyr_lat', replaceCyr2Lat, 'Кир->Лат', 'e/e0/OOjs_UI_icon_language-ltr-progressive.svg'],
	['id_lat_cyr', replaceLat2CyrMarked, 'Лат->Кир (marked)', 'e/e0/OOjs_UI_icon_language-ltr-progressive.svg'],
	['id_mx', maxim, 'Максимовичка', 'thumb/c/cc/Circumflex_accent.svg/16px-Circumflex_accent.svg.png'],
	['id_up', upperCase, 'UpperCase', '8/85/OOjs_UI_icon_bigger-ltr-progressive.svg'],
	['id_down', lowerCase, 'LowerCase', 'd/df/OOjs_UI_icon_smaller-ltr-progressive.svg'],
	['id_del_blnk', deleteBlank, 'DleteBlank', '7/75/OOjs_UI_icon_cancel-progressive.svg'],
	['id_par', paragraph, 'Абзац', '1/10/OOjs_UI_icon_stripeFlow-ltr-progressive.svg']
        		);

        	var items = {};
        	var url = '//upload.wikimedia.org/wikipedia/commons/';
        	
        	for ( var i = 0; i < buttons.length; i++ ) {
				items[buttons[i][0]] = {
                    		type: 'button',
	                    	label: buttons[i][2],
	                    	icon: url+buttons[i][3],
							action: {
								type: 'callback',
								execute: buttons[i][1]
								}
							};
			} // end for

            $('#wpTextbox1').wikiEditor('addToToolbar', {
                section: 'main',
                group: 'user', 
                tools: items
            });

        });
    }
});


function replaceMain() 
{ 
    var text = $('#wpTextbox1').val();

	var nbsp = String.fromCharCode(160);
	var unvis = String.fromCharCode(8291);
	var dash1, dash2;
	dash1 = nbsp.concat("—");
	dash2 = nbsp.concat("— ");
	
    var item, temp;

	var arr = [
    [/―/g, "—"],
    [/([0-9])\)\s/g, "$1)"+nbsp],
    [/\s([а-яґєїa-z])\)\s/g, " $1)"+nbsp],
    [/\s([\.\!\?\:\;\,\)…])/g, '$1'],
    [/([0-9])\)\?/g, "$1)"+nbsp+'?'],
    [/\{\{\-\-\}\}/g, dash2],
    [/\s*\{\{—\}\}\s*/g, dash2],
    [/\-\-/g, dash2],
    [/\.\.\./g, "…"],
    [/…\./g, "...."],
    [/\s"/g, ' „'],
    [/"(?=[\.\s\,\!\?\:\;\)…<])/g, '“'],
    [/¬\n/g, ''],
    [/\­/g, ''],
    [/ \n/g, '\n'],
	[/[’‘]/g, "'"],
    [/([A-Za-zА-ЯЇҐЄіа-яїґєі\.\!\?\:\;\,\)…„»«“”\"])—/g, '$1'+dash2],
    [/—([A-Za-zА-ЯЇҐЄіа-яїґєі„»«“”\"])/g, '— $1'],
    [/\x20—|&#32;—/g, dash1],
    [/\t/g, " "],
    [/^{{[-—]+}}/mg, "— "],
    [/\s*\|\|\s*/g, '||'],
    [/\|\s/g, '|'],
    [/([0-9])\s([гр]\.)/g, '$1'+nbsp+'$2'],
    [/([IVX])\s(в\.)/g, '$1'+nbsp+'$2'],
    [/([IVX])\s(ст\.)/g, '$1'+nbsp+'$2'],
    [/№\s/g, "№"+nbsp],
    [/\sт\. ([пдєиі]\.)/g, " т."+nbsp+"$1"],
    [/(і [тм]\.) ([іи]н\.)/g, "$1"+nbsp+"$2"],
    [/т\. (з[нв]\.)/g, "т."+nbsp+"$1"],
    [/п\. з\./g, "п."+nbsp+"з."],
    [/іцб/g, "що"+'\u0301'],
    [/([Щщ])б([\.\!\?\:\;\,\s\-…])/g, "$1о"+'\u0301'+"$2"],
    [/\sіцо([\s\-])/g, " що"+"$1"],
    [/\sіце\s/g, " ще "],
    [/\x20»/g, " "+unvis+"»"],
    [/«\x20|«&#32;/g, "«"+unvis+" "],
    [/\x20{2,}/g, " "]
    ];

//    [/([A-ZА-ЯЇҐЄѲ]\.)\s([A-ZА-ЯЇҐЄѲ])/g, '$1'+nbsp+'$2'],

	for (item of arr) {
		temp = text;
		if(temp.search(item[0]) > -1){
//			setTimeout(() => console.log(text), 200);
			text = temp.replace(item[0], item[1]);
			
//			alert(item);
//			alert(text);
		}
	}

    text = text.replace(/“ \/\>/g, '" />');
	text = text.replace(/align:top“/g, 'align:top"');
	text = text.replace(/wikitable“/g, 'wikitable"');
	text = text.replace(/- „ -/g, '–"–');

/*	text = text.replace(/([\.\!\?\…\:])\s\n/g, "$1\n");*/
    
    $('#wpTextbox1').val(text);

}

function replace4zheleh() 
{ 
//    var text = $('#wpTextbox1').val();

    // ся
//    text = text.replace(/([а-яїґєі])ся([\s\.\!\?\:\;\,\)…»«“”\"])/g, '$1 ся$2'); 

	// ї
//    text = text.replace(/([ТДЦСЗЛНтдцсзлн])і/g, '$1ї');
	var nbsp = String.fromCharCode(160);
	var len, last, head, foot, body, startPos, endPos, link;
	
    tb = document.getElementById("wpTextbox1");

    startPos = tb.selectionStart;
    endPos = tb.selectionEnd;

    head = tb.value.substring(0, startPos);
    foot = tb.value.substring(endPos);

    body = tb.value.substring(startPos, endPos);
	len = body.length-1;
	last = body[len];
	if (last === ' ' || last === nbsp) {
		body = body.slice(0,len);
	} else {
		last = '';
	}
	
	link = body.replace(/́/g, "");
	link = link.toLowerCase();
    body = '[[Словарь української мови (1924)/'+link+'|'+body+']]'+last; 

    tb.value = head + body + foot;

    var textScroll = tb.scrollTop;
	tb.selectionStart = endPos;
	tb.selectionEnd = tb.selectionStart;
	tb.scrollTop = textScroll;

//    $('#wpTextbox1').val(text);

}

function replacePoem() 
{ 
    var text = $('#wpTextbox1').val();
	text = text.replace(/<br\/>/g, "");
	text = text.replace(/<br \/>/g, "");
	text = text.replace(/<br>/g, "");
    $('#wpTextbox1').val(text);
}

function replacePoem1() 
{ 
    var text = $('#wpTextbox1').val();
    text = '{{block center|<poem>' + text + '</poem>}}';
    $('#wpTextbox1').val(text);
}

function replacePoem2() 
{ 
    var text = $('#wpTextbox1').val();
    text = '{{block center/s}}<poem>' + text + '</poem>';
    $('#wpTextbox1').val(text);

    text = $('#wpFooterTextbox').val();
    text = '{{block center/e}}';
    $('#wpFooterTextbox').val(text);
}

function replacePoem3() 
{ 
    var text = $('#wpTextbox1').val();
    text = '<poem>' + text + '</poem>{{block center/e}}';
    $('#wpTextbox1').val(text);

    text = $('#wpHeaderTextbox').val();
    text = '{{block center/s}}';
    $('#wpHeaderTextbox').val(text);
}

function replacePoem4() 
{ 
    var text = $('#wpTextbox1').val();
    text = '<poem>' + text + '</poem>';
    $('#wpTextbox1').val(text);

    text = $('#wpHeaderTextbox').val();
    text = '{{block center/s}}';
    $('#wpHeaderTextbox').val(text);

    text = $('#wpFooterTextbox').val();
    text = '{{block center/e}}';
    $('#wpFooterTextbox').val(text);
}

function replacePoem5() 
{ 
    text = $('#wpHeaderTextbox').val();
    text = '';
    $('#wpHeaderTextbox').val(text);

    text = $('#wpFooterTextbox').val();
    text = '';
    $('#wpFooterTextbox').val(text);
}

function replaceLat2Cyr() 
{ 
    var text = $('#wpTextbox1').val();
    var item;
	var arr = [
    [/ô/g, 'о̂'],
    [/Ô/g, 'О̂'],
	[/j/g, 'ј'],
	[/ó/g, 'о́'],
	[/r/g, 'г'],
	[/e/g, 'е'],
	[/y/g, 'у'],
	[/i/g, 'і'],
	[/o/g, 'о'],
	[/p/g, 'р'],
	[/a/g, 'а'],
	[/x/g, 'х'],
	[/c/g, 'с'],
	[/C/g, 'С'],
	[/H/g, 'Н'],
	[/K/g, 'К'],
	[/B/g, 'В'],
	[/A/g, 'А'],
	[/E/g, 'Е'],
	[/I/g, 'І'],
	[/T/g, 'Т'],
	[/O/g, 'О'],
	[/P/g, 'Р'],
	[/M/g, 'М'],
	[/X/g, 'Х'],
	[/€/g, 'є'],
	[/é/g, 'е́'],
	[/ө/g, 'е'],
	[/k/g, 'к'],
	[/Ң/g, 'Н'],
	[/ң/g, 'н'],
	[/Қ/g, 'К'],
	[/қ/g, 'к'],
	[/Ү/g, 'У'],
	[/ү/g, 'у'],
	[/ï/g, 'ї'],
	[/геf>/g, 'ref>'],
	[/nор}/g, 'nop}'],
	[/{{с\|/g, '{{c|'],
];
	for (item of arr) {
		text = text.replace(item[0], item[1]);
	}

    $('#wpTextbox1').val(text);
}

function replaceCyr2Lat() 
{ 
    var item;
    var arr;
    
	tb = document.getElementById("wpTextbox1");

    startPos = tb.selectionStart;
    endPos = tb.selectionEnd;

    head = tb.value.substring(0, startPos);
    foot = tb.value.substring(endPos);
    body = tb.value.substring(startPos, endPos);

	arr = [
	[/о́/g, 'ó'],
	[/е́/g, 'é'],
	[/ј/g, 'j'],
	[/г/g, 'r'],
	[/е/g, 'e'],
	[/і/g, 'i'],
	[/о/g, 'o'],
	[/к/g, 'k'],
	[/р/g, 'p'],
	[/а/g, 'a'],
	[/х/g, 'x'],
	[/у/g, 'y'],
	[/с/g, 'c'],
	[/С/g, 'C'],
	[/Н/g, 'H'],
	[/К/g, 'K'],
	[/В/g, 'B'],
	[/А/g, 'A'],
	[/Е/g, 'E'],
	[/І/g, 'I'],
	[/Т/g, 'T'],
	[/О/g, 'O'],
	[/Р/g, 'P'],
	[/М/g, 'M'],
	[/Х/g, 'X'],
	[/ї/g, 'ï']
];

	for (item of arr) {
		body = body.replace(item[0], item[1]);
	}
    
    tb.value = head + body + foot;

    var textScroll = tb.scrollTop;
	tb.selectionStart = endPos;
	tb.selectionEnd = tb.selectionStart;
	tb.scrollTop = textScroll;

}

function replaceLat2CyrMarked() 
{ 
    var item;
    var arr;
    
	tb = document.getElementById("wpTextbox1");

    startPos = tb.selectionStart;
    endPos = tb.selectionEnd;

    head = tb.value.substring(0, startPos);
    foot = tb.value.substring(endPos);
    body = tb.value.substring(startPos, endPos);

	arr = [
    [/ô/g, 'о̂'],
    [/Ô/g, 'О̂'],
	[/j/g, 'ј'],
	[/ó/g, 'о́'],
	[/r/g, 'г'],
	[/e/g, 'е'],
	[/y/g, 'у'],
	[/i/g, 'і'],
	[/o/g, 'о'],
	[/p/g, 'р'],
	[/a/g, 'а'],
	[/x/g, 'х'],
	[/c/g, 'с'],
	[/C/g, 'С'],
	[/H/g, 'Н'],
	[/K/g, 'К'],
	[/B/g, 'В'],
	[/A/g, 'А'],
	[/E/g, 'Е'],
	[/I/g, 'І'],
	[/T/g, 'Т'],
	[/O/g, 'О'],
	[/P/g, 'Р'],
	[/M/g, 'М'],
	[/X/g, 'Х'],
	[/€/g, 'є'],
	[/é/g, 'е́'],
	[/ө/g, 'е'],
	[/k/g, 'к'],
	[/Ң/g, 'Н'],
	[/ң/g, 'н'],
	[/Қ/g, 'К'],
	[/қ/g, 'к'],
	[/Ү/g, 'У'],
	[/ү/g, 'у'],
	[/ï/g, 'ї']
];

	for (item of arr) {
		body = body.replace(item[0], item[1]);
	}
    
    tb.value = head + body + foot;

    var textScroll = tb.scrollTop;
	tb.selectionStart = endPos;
	tb.selectionEnd = tb.selectionStart;
	tb.scrollTop = textScroll;
}

function yaryzhka() 
{ 
    var text = $('#wpTextbox1').val();
    var item;
	var arr = [
    [/\'ь([\s\.\!\?\:\;\,\)…»«“”\"])/g, 'ъ$1'],
    [/\'і[\.\,»\)\>]([\s\.\!\?\:\;\,\)…»«“”\"])/g, 'ъ$1'],
    [/і[\.\,»\)\>]([\s\.\!\?\:\;\,\)…»«“”\"])/g, 'ъ$1'],
    [/і[\.\,»\)\>]/g, 'ь'],
    [/ііі/g, 'ш'],
    [/іо/g, 'ю'],
    [/ьі/g, 'ы'],
    [/\.і/g, 'л'],
    [/іюна/g, 'вона'],
    [/меп([еи])/g, 'мен$1'],
    [/тъся/g, 'ться'],
    [/\sіц([ое])\s/g, ' щ$1 '],
    [/\sзь\s/g, ' зъ '],
    [/!\./g, 'ь'],
    [/\sпаче\s/g, ' наче '],
    [/“/g, '”'],
    [/\nЯва\s/g, '\n{{sp|Ява}} '],
    [/\nОфіцер\s/g, '\n\n{{sp|Офіцер}} '],
    [/\nОфіцер\./g, '\n\n{{sp-l|Офіцер}}.'],
    [/ь[ії]/g, "ы"],
    [/smaller/g, "fine block"]
];

	arr = [
    [/\(/g, "{{fine|("],
    [/\)/g, ")}}"],
    [/\nКармелюк\s/g, '\n\n{{sp|Кармелюк}} '],
    [/\nКармелюк\./g, '\n\n{{sp-l|Кармелюк}}.'],
    [/\nГайдамака\s/g, '\n\n{{sp|Гайдамака}} '],
    [/\nГайдамака\./g, '\n\n{{sp-l|Гайдамака}}.'],
    [/\nБатько\s/g, '\n\n{{sp|Батько}} '],
    [/\nБатько\./g, '\n\n{{sp-l|Батько}}.'],
    [/\nГості\s/g, '\n\n{{sp|Гості}} '],
    [/\nГості\./g, '\n\n{{sp-l|Гості}}.'],
    [/\nГості\:/g, '\n\n{{sp-l|Гості}}:'],
    [/\nМати\s/g, '\n\n{{sp|Мати}} '],
    [/\nМати\./g, '\n\n{{sp-l|Мати}}.'],
    [/\nЧоловік\s/g, '\n\n{{sp|Чоловік}} '],
    [/\nЧоловік\./g, '\n\n{{sp-l|Чоловік}}.'],
    [/\nЖінка\s/g, '\n\n{{sp|Жінка}} '],
    [/\nЖінка\./g, '\n\n{{sp-l|Жінка}}.'],
    [/\nШинкар\s/g, '\n\n{{sp|Шинкар}} '],
    [/\nШинкар\./g, '\n\n{{sp-l|Шинкар}}.'],
    [/\nКушнірук\s/g, '\n\n{{sp|Кушнірук}} '],
    [/\nКушнірук\./g, '\n\n{{sp-l|Кушнірук}}.'],
    [/\nМошко\s/g, '\n\n{{sp|Мошко}} '],
    [/\nМошко\./g, '\n\n{{sp-l|Мошко}}.'],
    [/\nО. Шуляк\s/g, '\n\nО. {{sp|Шуляк}} '],
    [/\nО. Шуляк\./g, '\n\nО. {{sp-l|Шуляк}}.'],
    [/\nГолос\s/g, '\n\n{{sp|Голос}} '],
    [/\nГолос\./g, '\n\n{{sp-l|Голос}}.'],
    [/\nБурлака\s/g, '\n\n{{sp|Бурлака}} '],
    [/\nБурлака\./g, '\n\n{{sp-l|Бурлака}}.'],
    [/\nПані Люба\s/g, '\n\n{{sp|Пані Люба}} '],
    [/\nПані Люба\./g, '\n\n{{sp-l|Пані Люба}}.'],
    [/\nСтась\s/g, '\n\n{{sp|Стась}} '],
    [/\nСтась\./g, '\n\n{{sp-l|Стась}}.'],
    [/\nПан Душечка\s/g, '\n\n{{sp|Пан Душечка}} '],
    [/\nПан Душечка\./g, '\n\n{{sp-l|Пан Душечка}}.'],
    [/\nДушечка\s/g, '\n\n{{sp|Душечка}} '],
    [/\nДушечка\./g, '\n\n{{sp-l|Душечка}}.'],
    [/\nЕконом\s/g, '\n\n{{sp|Економ}} '],
    [/\nЕконом\./g, '\n\n{{sp-l|Економ}}.'],
    [/\nУсі\s/g, '\n\n{{sp|Усі}} '],
    [/\nУсі\./g, '\n\n{{sp-l|Усі}}.'],
    [/\nНезнакомий\s/g, '\n\n{{sp|Незнакомий}} '],
    [/\nНезнакомий\./g, '\n\n{{sp-l|Незнакомий}}.'],
    [/\nОлізар\s/g, '\n\n{{sp|Олізар}} '],
    [/\nОлізар\./g, '\n\n{{sp-l|Олізар}}.'],
    [/\nДівчина\s/g, '\n\n{{sp|Дівчина}} '],
    [/\nДівчина\./g, '\n\n{{sp-l|Дівчина}}.'],
    [/\nПанна Ромця\s/g, '\n\n{{sp|Панна Ромця}} '],
    [/\nПанна Ромця\./g, '\n\n{{sp-l|Панна Ромця}}.'],
    [/\nПерша дівчина\s/g, '\n\n{{sp|Перша дівчина}} '],
    [/\nПерша дівчина\./g, '\n\n{{sp-l|Перша дівчина}}.'],
    [/\nДруга дівчина\s/g, '\n\n{{sp|Друга дівчина}} '],
    [/\nДруга дівчина\./g, '\n\n{{sp-l|Друга дівчина}}.'],
    [/\nХурщик\s/g, '\n\n{{sp|Хурщик}} '],
    [/\nХурщик\./g, '\n\n{{sp-l|Хурщик}}.'],
    [/\nВсі\s/g, '\n\n{{sp|Всі}} '],
    [/\nВсі\./g, '\n\n{{sp-l|Всі}}.'],
    [/\nВ 1-му гурті\s/g, '\n\n{{sp|В 1-му гурті}} '],
    [/\nВ 1-му гурті\./g, '\n\n{{sp-l|В 1-му гурті}}.'],
    [/\nГолоси\s/g, '\n\n{{sp|Голоси}} '],
    [/\nГолоси\./g, '\n\n{{sp-l|Голоси}}.'],
    [/\nГолоси\:/g, '\n\n{{sp-l|Голоси}}:'],
    [/\nВ 2-му гурті\s/g, '\n\n{{sp|В 2-му гурті}} '],
    [/\nВ 2-му гурті\./g, '\n\n{{sp-l|В 2-му гурті}}.'],
    [/\nВ 2-му гурті\:/g, '\n\n{{sp-l|В 2-му гурті}}:'],
    [/\nСтарий пан\s/g, '\n\n{{sp|Старий пан}} '],
    [/\nСтарий пан\./g, '\n\n{{sp-l|Старий пан}}.'],
    [/\nЛюди\s/g, '\n\n{{sp|Люди}} '],
    [/\nЛюди\:/g, '\n\n{{sp-l|Люди}}:'],
    [/\nПани\s/g, '\n\n{{sp|Пани}} '],
    [/\nПани\:/g, '\n\n{{sp-l|Пани}}:'],
    [/\nЧиновник\s/g, '\n\n{{sp|Чиновник}} '],
    [/\nЧиновник\./g, '\n\n{{sp-l|Чиновник}}.'],
    [/\nПані\s/g, '\n\n{{sp|Пані}} '],
    [/\nПані\./g, '\n\n{{sp-l|Пані}}.'],
    [/\nПанна\s/g, '\n\n{{sp|Панна}} '],
    [/\nПанна\./g, '\n\n{{sp-l|Панна}}.'],
    [/\nПан\s/g, '\n\n{{sp|Пан}} '],
    [/\nПан\./g, '\n\n{{sp-l|Пан}}.'],
    [/\nГолос\s/g, '\n\n{{sp|Голос}} '],
    [/\nГолос\./g, '\n\n{{sp-l|Голос}}.']
		];

/**
	for (item of arr) {
		text = text.replace(item[0], item[1]);
	}

    $('#wpTextbox1').val(text);

    text = $('#wpHeaderTextbox').val();
    text = '<div class="max">'+text;
    $('#wpHeaderTextbox').val(text);

    text = $('#wpFooterTextbox').val();
    text = text + '</div>';
    $('#wpFooterTextbox').val(text);
*/

    text = $('#wpTextbox1').val();
    text = text.replace(/<br\/\>/g, '');
    text = text.replace(/:*\d+\.\s'''/g, "<li>'''");
    $('#wpTextbox1').val(text);

    text = $('#wpHeaderTextbox').val();
    text = '<ol start= class="o">';
    $('#wpHeaderTextbox').val(text);

    text = $('#wpFooterTextbox').val();
    text = '</ol>';
    $('#wpFooterTextbox').val(text);


}

function maxim() 
{ 
    var text = $('#wpTextbox1').val();
    var item;
	var arr = [
    [/([БВГҐДЖЗКЛМНПРСТФХЦЧШЩбвгґджзклмнпрстфхцчшщ])б([бвгґджзйклмнпрстфхцчшщ])/g, '$1о̂$2'],
    [/\sб([дкн])/g, ' о̂$1'],
    [/\sб.ъ/g, ' о̂нъ'],
    [/\sзо̂л/g, ' збл'],
    [/([бвгґджзклмнпрстфхцчшщ])й([\s\.\!\?\:\;\,\)…»«“”\"])/g, '$1и̂$2'],
    [/\s[ѳебв][ивн]([\s\.\!\?\:\;\,\)…»«“”\"])/g, ' єи$1'],
    [/ѳ/g, 'є'],
    [/\s[пнв]\s/g, ' и '],
    [/\sея\s/g, ' ся '],
    [/\sесть([\s\.\!\?\:\;\,\)…»«“”\"])/g, ' єсть$1'],
    [/\s([Пп])од([ьъ])\s/g, ' $1о̂дъ '],
    [/\sокрик/g, ' скрик'],
    [/\s([Чч])елов/g, ' $1олов'],
    [/навѣтъ/g, 'навѣть'],
    [/\sесли([\s\.\!\?\:\;\,\)…»«“”\"])/g, ' єсли$1'],
    [/\s([мд])([ао])е([\s\.\!\?\:\;\,\)…»«“”\"])/g, ' $1$2є$3'],
    [/\s[евб]му([\s\.\!\?\:\;\,\)…»«“”\"])/g, ' єму$1'],
    [/\s[евб]го([\s\.\!\?\:\;\,\)…»«“”\"])/g, ' єго$1'],
    [/\s([тс])воей([\s\.\!\?\:\;\,\)…»«“”\"])/g, ' $1воєи$2'],
    [/\sмоей([\s\.\!\?\:\;\,\)…»«“”\"])/g, ' моєи$1'],
    [/([уаѣюяіоы])е/g, '$1є'],
    [/\sОдтакъ\s/g, ' О̂дтакъ '],
    [/\s([Оо])нъ\s/g, ' $1̂нъ '],
    [/\s([Зз])б\s/g, ' $1о̂ '],
    [/ó/g, 'о̂'],
    [/ò/g, 'о̂'],
    [/\sнадо\s/g, ' надо̂ '],
    [/([Щщ])6/g, '$1о́'],
    [/\s([Мм])огъ([\s\.\!\?\:\;\,\)…»«“”\"])/g, ' $1о̂гъ$2'],
    [/\sпаче\s/g, ' наче '],
    [/\sвол([ио])\s/g, ' кол$1 '],
    [/\sвотр/g, ' котр'],
    [/\s([Яя]).ъ/g, ' $1къ'],
    [/\s([Тт])й\s/g, ' $1и̂ '],
    [/\sсваз/g, ' сказ'],
    [/\s([Чч])н\s/g, ' $1и '],
    [/\о̂д.овѣ/g, 'о̂дповѣ'],
    [/\s([Вв])ко̂вци\s/g, ' $1ко̂нци '],
    [/\sесть([\s\.\!\?\:\;\,\)…»«“”\"])/g, ' єсть$1'],
    [/\sпавѣ([\s\.\!\?\:\;\,\)…»«“”\"])/g, ' панѣ$1'],
];
	for (item of arr) {
		text = text.replace(item[0], item[1]);
	}

    $('#wpTextbox1').val(text);
}

function deleteBlank() 
{
    tb = document.getElementById("wpTextbox1");

    startPos = tb.selectionStart;
    endPos = tb.selectionEnd;

    head = tb.value.substring(0, startPos);
    foot = tb.value.substring(endPos);
    body = tb.value.substring(startPos, endPos);

    body = body.replace(/\s/g,'');

    tb.value = head + body + foot;

    var textScroll = tb.scrollTop;
	tb.selectionStart = endPos;
	tb.selectionEnd = tb.selectionStart;
	tb.scrollTop = textScroll;
    
}

function paragraph() 
{
    tb = document.getElementById("wpTextbox1");

    startPos = tb.selectionStart;
    endPos = tb.selectionEnd;

    head = tb.value.substring(0, startPos);
    foot = tb.value.substring(endPos);
    body = tb.value.substring(startPos, endPos);

    body = body.replace(/-\n/g,'');
    body = body.replace(/\s\n/g,' ');
    body = body.replace(/\n/g,' ');

    tb.value = head + body + foot;

    var textScroll = tb.scrollTop;
	tb.selectionStart = endPos;
	tb.selectionEnd = tb.selectionStart;
	tb.scrollTop = textScroll;
}

function upperCase() 
{ 
    tb = document.getElementById("wpTextbox1");

    startPos = tb.selectionStart;
    endPos = tb.selectionEnd;

    head = tb.value.substring(0, startPos);
    foot = tb.value.substring(endPos);
    body = tb.value.substring(startPos, endPos);
    body = body.toUpperCase(); 

    tb.value = head + body + foot;

    var textScroll = tb.scrollTop;
	tb.selectionStart = endPos;
	tb.selectionEnd = tb.selectionStart;
	tb.scrollTop = textScroll;
}

function lowerCase() 
{ 
    tb = document.getElementById("wpTextbox1");

    startPos = tb.selectionStart;
    endPos = tb.selectionEnd;

    head = tb.value.substring(0, startPos);
    foot = tb.value.substring(endPos);
    body = tb.value.substring(startPos, endPos);
    body = body.toLowerCase(); 

    tb.value = head + body + foot;

    var textScroll = tb.scrollTop;
	tb.selectionStart = endPos;
	tb.selectionEnd = tb.selectionStart;
	tb.scrollTop = textScroll;
  
}

function create_page4word() 
{
	var inputWord, submitBut, fieldset, form4word;
	
	inputWord = new OO.ui.TextInputWidget( { 
		value: 'слово'
	} );
 	
 	submitBut = new OO.ui.ButtonInputWidget( { 
		label: 'Створити',
	} );
 
	fieldset = new OO.ui.FieldsetLayout( { 
		label: 'Створення статті для слова',
		classes: [ 'container' ]
	} );
 
	fieldset.addItems( [ 
		new OO.ui.FieldLayout( inputWord, {
			label: 'Слово',
			align: 'top'
		} ),
		new OO.ui.FieldLayout( submitBut )
	] );
 
	form4word = new OO.ui.FormLayout(  {
		items: [ fieldset ],
		action: 'test',
		method: 'get'
	} );
	$( document.body ).append( form4word.$element );
	
}