User:দিব্য দত্ত/Script/Pratisthapon.js

From Meta, a Wikimedia project coordination wiki

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/*
    @Author [[User:দিব্য দত্ত]]
*/

$(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 Pratisthapon = function() {
        $('#wpTextbox1').wikiEditor('addToToolbar', {
            'section': 'main',
            'group': 'insert',
            'tools': {
                'Pratisthapon': {
                    label: 'অসমীয়া লিখোতে হোৱা কেইটামান সাধাৰণ ভুল প্ৰতিস্থাপন কৰক',
                    type: 'button',
                    icon: '//upload.wikimedia.org/wikipedia/commons/thumb/1/1e/Pratisthapon.png/25px-Pratisthapon.png',
                    action: {
                        type: 'callback',
                        execute: function() {
getText = $('#wpTextbox1').val();
newText = getText.replace(/  +/g, " ");
 // old proti code //
newText = newText.replace(/।।/g, '॥');
newText = newText.replace(/।।/g, "॥");
newText = newText.replace(/৷৷/g, "॥");
newText = newText.replace(/র/g, "ৰ");
newText = newText.replace(/অাা/g, "আ");
newText = newText.replace(/অা/g, "আ");
newText = newText.replace(/আা/g, "আ");
newText = newText.replace(/ ।/g, "।");
newText = newText.replace(/ ৷/g, "।");
newText = newText.replace(/ \?/g, "?");
newText = newText.replace(/ ॥/g, "॥");
newText = newText.replace(/ !/g, "!");
newText = newText.replace(/ ;/g, ";");
newText = newText.replace(/াে/g, "ো");
newText = newText.replace(/ো/g, "ো");
newText = newText.replace(/^ +| +$/gm, "");
$('#wpTextbox1').val(newText);
customAlert('বৰ্ণাশুদ্ধি নিবাৰণ কৰা হ’ল।','3000');
$('#wpSummary').val("ৰ-প্ৰতিস্থাপন সঁজুলি ব্যৱহাৰ কৰি ‘বঙালী ৰ’ প্ৰতিস্থাপন কৰা হ’ল।");
                        }
                    }
                }
            }
        });

    };
    
/* 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(Pratisthapon);
    }
});