பயனர்:சிவசுப்பிரமணியன்/wikt.js
குறிப்பு - சேமித்த பின்னர், நீங்கள் செய்த மாற்றங்களைக் காண்பதற்கு உங்கள் உலவியின் இடைமாற்று அகற்றப்பட வேண்டும்.
- மொஸில்லா பயர்பாக்ஸ் / சபாரி: Shift+Reload, அல்லது Ctrl-F5 அல்லது Ctrl-R (⌘-R Mac ல்)
- கூகிள் குரோம் Ctrl-Shift-R அழுத்தவும். (⌘-Shift-R Mac ல்) ;
- இண்டர்நெட் எக்ஸ்ப்ளோரர்: Ctrl-Refresh அல்லது Ctrl-F5 ஐ அழுத்தவும்.
- ஒபேரா: Tools → Preferences இல் இடைமாற்றை அகற்றவும்;
var customToolbarSiva = function () {//<<---- Please do not use this name
$('#wpTextbox1').wikiEditor('addToToolbar', {
'sections' : {
'interWikiLinkerSiva' : {//<<---- Please do not use this name
'type' : 'toolbar',
'label' : 'விக்சனரி ',
'groups' : {
'insert2' : {
'tools' : {
'gapFilter' : {
labelMsg: 'எடுத்து காட்டு குறியீடு',
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/2/2a/Button_gap.png',
action:{
type: 'callback',
execute : function (context){
replaceDotAfterHash();
}
}
},
'addTemplateToWords' : {
labelMsg : 'சொற்களுக்கு வார்ப்புரு இணைப்பு குறியிடுக',
type : 'button',
icon : '//upload.wikimedia.org/wikipedia/commons/2/20/Button_subst.png',
action : {
type : 'callback',
execute : function (context) {
addRemoveTemplates($('#wpTextbox1').val().indexOf("{{-start-}}'''"));
}
}
}
}
}
}
}
}
});
var replaceDotAfterHash = function (){
var inputTxtBxVal = $('#wpTextbox1').val().trim();
var hash_char=inputTxtBxVal.indexOf('#');
var change_string = '';
if(inputTxtBxVal.indexOf("#:{{எ. கா.}}") == -1){
var splitHash = inputTxtBxVal.split("#");
var indices = [];
for(var i = 0; i< inputTxtBxVal.length; i++){
if (inputTxtBxVal[i] === '#') {
indices.push(i);
}
}
for(var j =0; j< splitHash.length;j++){
if(splitHash[j].trim().length >=1)
change_string += "#"+ splitHash[j].replace(splitHash[j].charAt(splitHash[j].indexOf('.')),'#:{{எ. கா.}}');
}
}else {
var find = '#:{{எ. கா.}}';
var re = new RegExp(find, 'g');
change_string = inputTxtBxVal.replace(re ,'.');
}
$('#wpTextbox1').val(change_string);
};
var addRemoveTemplates = 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 else except tamil letters
}
}
txtBxVal = arrayOfLines.join('\r\n');
if(addOrRemove != -1 ){//remove
txtBxVal = txtBxVal.replace("'''{{subst:noun-ta|", "");
txtBxVal = txtBxVal.replace(/\#\s*/gim, "");
txtBxVal = txtBxVal.replace("{{-start-}}'''", "");
}
txtBxVal = txtBxVal.replace(/\d/gm, "");// remove digits
txtBxVal = txtBxVal.replace(/[ ]{2,}/gm, " ");// replace multiple space to single space
txtBxVal = txtBxVal.replace(/>|\.|,|:|;|</gm, "");//remove some special chars
txtBxVal = txtBxVal.replace(/\-*\s*$/gm, "");//remove hyphen at end
txtBxVal = txtBxVal.replace(/\s*\-\s*/g, "-");//space before and after hyphen
txtBxVal = txtBxVal.replace(/([\u0B80-\u0BFF]+)-([\u0B80-\u0BFF]+)/g, "$1$2");//hyphen between tamil words removed
txtBxVal = txtBxVal.replace(/[\(|\)]/gm, "");//remove simple brackets
txtBxVal = txtBxVal.replace(/\[.*\]/gm, "");//remove square brackets and its content
txtBxVal = txtBxVal.replace(/^(\s*)(.*)$/gim, "$2");//trim left
txtBxVal = txtBxVal.replace(/\s+($)/gm, "$1");//trim right
if(addOrRemove == -1 ){//add
txtBxVal = txtBxVal.replace(/^(\s*)(.*)$/gim, "{{-start-}}'''$2");//trim left and add {{-start-}}'''
txtBxVal = txtBxVal.replace(/\s+($)/gm, "$1");//trim right
txtBxVal = txtBxVal.replace(/($)/gm, "'''{{subst:noun-ta|$1");// add '''{{subst:noun-ta
}
$('#wpTextbox1').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(customToolbarSiva);
});
}
});
}