பயனர்:Shrikarsan/விக்சனரி 3.js
குறிப்பு - சேமித்த பின்னர், நீங்கள் செய்த மாற்றங்களைக் காண்பதற்கு உங்கள் உலவியின் இடைமாற்று அகற்றப்பட வேண்டும்.
- மொஸில்லா பயர்பாக்ஸ் / சபாரி: Shift+Reload, அல்லது Ctrl-F5 அல்லது Ctrl-R (⌘-R Mac ல்)
- கூகிள் குரோம் Ctrl-Shift-R அழுத்தவும். (⌘-Shift-R Mac ல்) ;
- இண்டர்நெட் எக்ஸ்ப்ளோரர்: Ctrl-Refresh அல்லது Ctrl-F5 ஐ அழுத்தவும்.
- ஒபேரா: Tools → Preferences இல் இடைமாற்றை அகற்றவும்;
customizeToolbar30shri = function () {//<<--- Please do not use this name
$('#wpTextbox1').wikiEditor('addToToolbar', {
'sections' : {
'Wikt3Shrikarsan' : {//<<--- Please do not use this name
'type' : 'toolbar',
'label' : 'விக்சனரி 3',
'groups' : {
'Wikt3insert' : {
'label': 'கருவிகள்:',
'tools' : {
'addWikiBracketsToWords' : {
label : 'சொற்களுக்கு அடைப்புக் குறியிடுக',
type : 'button',
icon : '//upload.wikimedia.org/wikipedia/commons/d/dc/Template_green_icon.png',
action : {
type : 'callback',
execute : function (context) {
addRemoveBrackets($('#wpTextbox1').val().indexOf("{{"));
wikt3EditSummary(txt);
}
}
},
'formatTamilLexiconText' : {
label : 'தமிழ்ப் பேரகரமுதலியிலிருந்து விக்சனரிப்படுத்தல்',
type : 'button',
icon : '//upload.wikimedia.org/wikipedia/commons/7/73/Edit-clear_mirrored.svg',
action : {
type : 'callback',
execute : function (context) {
formatTamilLexiconText(txt);
wikt3EditSummary(txt);
}
}
},
'formatTamilLexiconTextbot' : {
label : 'தமிழ்ப் பேரகரமுதலியிலிருந்து விக்சனரிப்படுத்தல் (தானியங்கிப் பதிவேற்றம்)',
type : 'button',
icon : '//upload.wikimedia.org/wikipedia/commons/e/e0/Accessories-text-editor.svg',
action : {
type : 'callback',
execute : function (context) {
formatTamilLexiconTextbot(txt);
wikt3EditSummary(txt);
}
}
},
}
}
}
}
}
});
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'Wikt3Shrikarsan',
'groups': {
'Wikt3help': {
'label': 'உதவி:'
}
}
} );
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'Wikt3Shrikarsan',
'group': 'Wikt3help',
'tools': {
'Wikt3helper' : {
label : 'இக்கருவி பற்றி மேலும் அறிய',
type : 'button',
icon : '//upload.wikimedia.org/wikipedia/commons/c/c6/Emblem-question_red.png',
action : {
type : 'callback',
execute : function (context) {
window.open("//ta.wiktionary.org/wiki/பயனர்:Shrikarsan/விக்சனரி_3","_blank");
}
}
}
}
});
var addRemoveBrackets = function (addOrRemove) {//addOrRemove == -1 add else remove
var txtBxVal = $('#wpTextbox1').val().trim();
var arrayOfLines = txtBxVal.match(/[^\r\n]+/g);
var patt = new RegExp("[\u0B80-\u0BFF]");
var arrayLength = arrayOfLines.length;
for (var i = 0; i < arrayLength; i++) {
if( patt.test(arrayOfLines[i]) ){
arrayOfLines[i] = arrayOfLines[i].replace(/[^\u0B80-\u0BFF \-\.\,\{\}]/g, ""); //replace everything elseexcept -,.,,, {,} and tamil letters
}
}
txtBxVal = arrayOfLines.join('\r\n');
if(addOrRemove != -1 ){//remove
txtBxVal = txtBxVal.replace(/\}\}/gim, "");
txtBxVal = txtBxVal.replace(/\#\s*/gim, "");
txtBxVal = txtBxVal.replace(/\{\{/gim, "");
}
txtBxVal = txtBxVal.replace(/[ ]{2,}/gm, " ");
txtBxVal = txtBxVal.replace(/\s*\,/g, ".");
txtBxVal = txtBxVal.replace(/\s*\./g, ".");
txtBxVal = txtBxVal.replace(/[/,]/gm, ".");
txtBxVal = txtBxVal.replace(/[/,]{2,}/gm, ".");
txtBxVal = txtBxVal.replace(/[/.]{2,}/gm, ".");
txtBxVal = txtBxVal.replace(/\s*\,/g, ".");
txtBxVal = txtBxVal.replace(/\s*\./g, ".");
txtBxVal = txtBxVal.replace(/([\u0B80-\u0BFF]+)([\.]+)([\u0B80-\u0BFF]+)/g, "$1$2 $3");
txtBxVal = txtBxVal.replace(/([\u0B80-\u0BFF]+)([\.]+)([\u0B80-\u0BFF]+)/g, "$1$2 $3");
if(addOrRemove == -1 ){//add
txtBxVal = txtBxVal.replace(/^(\s*)(.*)$/gim, "#{{$2");//trim left and add bracket
txtBxVal = txtBxVal.replace(/\s+($)/gm, "$1");//trim right
txtBxVal = txtBxVal.replace(/($)/gm, "}}$1");// add bracket
}
$('#wpTextbox1').val(txtBxVal);
};
function formatTamilLexiconText(inputText) {
var txtBxVal = cleanText(inputText);
txtBxVal = txtBxVal.replace(/^(\s*)([\u0B80-\u0BFF]+)(.*)$/gim, "{{User:Shrikarsan/noun-ta|$2$3}}");
txtBxVal = txtBxVal.replace(/\s+($)/gm, "$1");
txtBxVal = txtBxVal.replace(/($)/gm, "$1");
txtBxVal = txtBxVal.replace(/([\{\{]+)([\U\s\e\r]+)/g, "$1subst:$2");
txtBxVal = txtBxVal.replace(/([\;]+)([\s*]+)([\u0B80-\u0BFF]+)/g, "\r\n|$2$3");
txtBxVal = txtBxVal.replace(/[;]\s*/gm, ';\r\n');
txtBxVal = txtBxVal.replace(/\;*\s*$/gm, "");
txtBxVal = txtBxVal.replace(/^(.+)\s*(\d\d\. )/gm, '$1\r\n#');
txtBxVal = txtBxVal.replace(/^(.+)\s*(\d\. )/gm, '$1\r\n#');
txtBxVal = txtBxVal.replace(/^(.+)\s+(\([a-z]+\) )/gm, '$1\r\n$2');
txtBxVal = txtBxVal.replace(/\.\*\*\*/g, "\r\n#");
txtBxVal = txtBxVal.replace(/\*\*\*/g, "");
txtBxVal = txtBxVal.replace(/\a\|.*($)/gm, "a|");
txtBxVal = txtBxVal.replace(/^(\s*)(.*)$/gim, "$2");
txtBxVal = txtBxVal.replace(/\s+($)/gm, "$1");
inputText.val(txtBxVal);
}
function wikt3EditSummary(inputText) {
var txt = document.forms.editform.wpSummary;
var tag;
if( typeof wikt3Tag === 'undefined' ) {
tag = '[[பயனர்:Shrikarsan|ஸ்ரீகர்சனின்]] [[பயனர்:Shrikarsan/விக்சனரி 3|விக்சனரி 3]] கருவியின் மூலம் தொகுக்கப்பட்டது';
} else {
tag = wikt3Tag;
}
if( tag.match(/[^\s]/) ) {
if( txt.value.indexOf(tag) == -1 ) {
if( txt.value.match(/[^\*\/\s][^\/\s]?\s*$/) ) {
txt.value += ' | ';
}
txt.value += tag;
}
}
}
function formatTamilLexiconTextbot(inputText) {
var txtBxVal = cleanText(inputText);
txtBxVal = txtBxVal.replace(/^(\s*)(.*)$/gim, "{{noun-ta|$2");
txtBxVal = txtBxVal.replace(/\s+($)/gm, "$1");
txtBxVal = txtBxVal.replace(/($)/gm, "}}$1");
txtBxVal = txtBxVal.replace(/([\{\{]+)/g, "$1subst:");
txtBxVal = txtBxVal.replace(/([\;]+)([\s*]+)([\u0B80-\u0BFF]+)/g, "|$2$3");
txtBxVal = txtBxVal.replace(/[;]\s*/gm, ';');
txtBxVal = txtBxVal.replace(/\;*\s*$/gm, "");
txtBxVal = txtBxVal.replace(/\a\|.*1\./gm, "a|");
txtBxVal = txtBxVal.replace(/\d\d\./g, '#');
txtBxVal = txtBxVal.replace(/\d\./g, '#');
txtBxVal = txtBxVal.replace(/^(.+)\s+(\([a-z]+\) )/gm, '$1$2');
txtBxVal = txtBxVal.replace(/\.\*\*\*/g, " #");
txtBxVal = txtBxVal.replace(/\*\*\*/g, "");
txtBxVal = txtBxVal.replace(/\;/g, "");
txtBxVal = txtBxVal.replace(/^(\s*)(.*)$/gim, "$2");
txtBxVal = txtBxVal.replace(/\s+($)/gm, "$1");
inputText.val(txtBxVal);
}
};
/* 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) {
mw.loader.using('user.options', function () {
if (mw.user.options.get('usebetatoolbar')) {
mw.loader.using('ext.wikiEditor', function () {
$(document).ready(customizeToolbar30shri);
});
}
});
}