User:ZxxZxxZ/faTranslit.js

/* */ function faTranslit{ var faLetters = "ءاأآئؤبپتثجچحخدذرزژسشصضطظعغفقکگلمنوهیةًٌٍَُِّْٔ" var c = document.getElementById('wpTextbox1').value; c = c.replace(/‌/g, '-'); // ZWNJ c = c.replace(/ـ/g, ''); c = c.replace(/اً/g, 'an'); c = c.replace(/ٌ/g, 'on'); c = c.replace(/^ا/g, 'a/e/o'); c = c.replace(new RegExp('([^' + faLetters + '\\w])ا', 'g'), '$1a/e/o'); c = c.replace(/ا/g, 'â'); c = c.replace(/آ/g, 'â'); c = c.replace(/[ءئؤأع]/g, "'"); c = c.replace(/ب/g, 'b'); c = c.replace(/پ/g, 'p'); c = c.replace(/[تطة]/g, 't'); c = c.replace(/[ثسص]/g, 's'); c = c.replace(/ج/g, 'j'); c = c.replace(/چ/g, 'č'); c = c.replace(/هٔ/g, 'e-ye'); c = c.replace(/ه$/g, 'e'); c = c.replace(new RegExp('ه([^' + faLetters + '\\w])', 'g'), 'e$1'); c = c.replace(/[حه]/g, 'h'); c = c.replace(/خ/g, 'x'); c = c.replace(/د/g, 'd'); c = c.replace(/[ذزظض]/g, 'z'); c = c.replace(/ر/g, 'r'); c = c.replace(/ژ/g, 'ž'); c = c.replace(/ش/g, 'š'); c = c.replace(/غ/g, 'ğ'); c = c.replace(/ف/g, 'f'); c = c.replace(/ق/g, 'q'); c = c.replace(/ک/g, 'k'); c = c.replace(/گ/g, 'g'); c = c.replace(/ل/g, 'l'); c = c.replace(/م/g, 'm'); c = c.replace(/ن/g, 'n'); c = c.replace(/و/g, 'v/u'); c = c.replace(/ی/g, 'y/i'); c = c.replace(/ﻻ/g, 'lâ'); c = c.replace(/[،٬]/g, ','); c = c.replace(/؛/g, ';'); c = c.replace(/«/g, '“'); c = c.replace(/»/g, '”'); c = c.replace(/؟/g, '?'); c = c.replace(/٫/g, '.'); c = c.replace(/٪/g, '%'); nums = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹']; for (var i = 0; i < 10; i++) { c = c.replace(new RegExp(nums[i], 'g'), i); }   alert(c); } $(function {   var cp = document.getElementById('editpage-copywarn');    var wpSave = document.getElementById('wpSave');    if (!cp || !wpSave) return    var ins = ' faTranslit';    cp.innerHTML += ins;    var warningDone = false; }) /* */