பயனர்:ச.பிரபாகரன்/whitespaceTamil99.js

கட்டற்ற பன்மொழி அகரமுதலியான விக்சனரியில் இருந்து.

குறிப்பு - சேமித்த பின்னர், நீங்கள் செய்த மாற்றங்களைக் காண்பதற்கு உங்கள் உலவியின் இடைமாற்று அகற்றப்பட வேண்டும்.

  • மொஸில்லா பயர்பாக்ஸ் / சபாரி: Shift+Reload, அல்லது Ctrl-F5 அல்லது Ctrl-R (⌘-R Mac ல்)
  • கூகிள் குரோம் Ctrl-Shift-R அழுத்தவும். (⌘-Shift-R Mac ல்) ;
  • இண்டர்நெட் எக்ஸ்ப்ளோரர்: Ctrl-Refresh அல்லது Ctrl-F5 ஐ அழுத்தவும்.
  • ஒபேரா: Tools → Preferences இல் இடைமாற்றை அகற்றவும்;
var txt;
var customizeToolbar = function () {
	txt = $('#wpTextbox1');
	txt.wikiEditor('addToToolbar', {
		'sections' : {
			'interWikiLinker' : {
				'type' : 'toolbar',
				'label' : 'விக்கிமீடியா',
				'groups' : {
					'insert2' : {
						'tools' : {
							'cleanInputText' : {
								labelMsg : 'தேவையில்லாத இடைவெளிகளை நீக்கவும்',
								type : 'button',
								icon : '//upload.wikimedia.org/wikipedia/commons/8/81/Toolbaricon_justify-left.png',
								action : {
									type : 'callback',
									execute : function (context) {
										cleanInputText(txt);
									}
								}
							}
						}
					}
				}
			}
		}
	});
};

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

function cleanInputText(inputText) {
	var txtBxVal = cleanText(inputText);

	inputText.val(txtBxVal);
}

function cleanText(inputText) {
	var txtBxVal = inputText.val().trim();

	txtBxVal = txtBxVal.replace(/[ ]{2,}/gm, ' ');// replace multiple space to single space
	txtBxVal = txtBxVal.replace(/[ ]{1,}([\u0B95-\u0BBD][\u0BCD])/gm, '$1');//delete the extra space generated before Tamil consonant in Tamil99 keyboard layout
	txtBxVal = txtBxVal.replace(/(\[)(\s*)(\[)(.*)(\])(\s*)(\])/gm, '$1$3$4$5$7');// delete unnecessary space
	txtBxVal = txtBxVal.replace(/(\{)(\s*)(\{)(.*)(\})(\s*)(\})/gm, '$1$3$4$5$7');// delete unnecessary space

	var arrayOfLines = txtBxVal.replace(/\r\n|\n\r|\n|\r/g,'\n').split('\n');
	for (var i = 0; i < arrayOfLines.length; i++) {
		arrayOfLines[i] = arrayOfLines[i].trim();
	}
	txtBxVal = arrayOfLines.join('\r\n');

	return txtBxVal;
}