میدیاویکی:Gadget-ArabicLetterConvertor.js
تێبینی: دوای پاشەکەوتکردن، پێویستە کاشی وێبگەڕەکەت پاک بکەیتەوە تا گۆڕانکارییەکان ببینیت. بۆ گووگڵ کڕۆم، فایەرفۆکس، مایکرۆسۆفت ئێج و سافاری: پەنجە لەسەر دوگمەی ⇧ Shift ڕاگرە و کرتە لەسەر Reload بکە. بۆ وردەکاری و ڕێنمایییەکان لەسەر وێبگەڕەکانی تر، بڕوانە ئێرە.
/**
* Below code given from: https://dotnettipsrepository.svn.codeplex.com/svn/Trunk/ASP.NET/YeKe/jquery.yeke.js
* The dotnettipsrepository codes released under MIT License per: http://dotnettipsrepository.codeplex.com/license
* we modified it a bit for using here ;)
*/
function substituteCharInFireFox(charCode, e) {
var keyEvt = document.createEvent("KeyboardEvent");
keyEvt.initKeyEvent("keypress", true, true, null, false, false, false, false, 0, charCode);
e.target.dispatchEvent(keyEvt);
e.preventDefault();
}
function substituteCharInChrome(charCode, e) {
//it does not work yet! /*$.browser.webkit*/
//https://bugs.webkit.org/show_bug.cgi?id=16735
var keyEvt = document.createEvent("KeyboardEvent");
keyEvt.initKeyboardEvent("keypress", true, true, null, false, false, false, false, 0, charCode);
e.target.dispatchEvent(keyEvt);
e.preventDefault();
}
function insertAtCaret(myValue, e) {
var obj = e.target;
var startPos = obj.selectionStart;
var endPos = obj.selectionEnd;
var scrollTop = obj.scrollTop;
obj.value = obj.value.substring(0, startPos) + myValue + obj.value.substring(endPos, obj.value.length);
obj.focus();
obj.selectionStart = startPos + myValue.length;
obj.selectionEnd = startPos + myValue.length;
obj.scrollTop = scrollTop;
e.preventDefault();
}
$(document).ready(function () {
var arabicYeCharCode = 1610;
var arabicAlefMaghsooreCharCode = 1609;
var kurdishYeCharCode = 1740;
var arabicKeCharCode = 1603;
var kurdishKeCharCode = 1705;
$(document).keypress(function (e) {
var keyCode = e.keyCode ? e.keyCode : e.which;
if ($.browser.msie) {
switch (keyCode) {
case arabicYeCharCode:
event.keyCode = kurdishYeCharCode;
showCharWarning();
break;
case arabicAlefMaghsooreCharCode:
event.keyCode = kurdishYeCharCode;
showCharWarning();
break;
case arabicKeCharCode:
event.keyCode = kurdishKeCharCode;
showCharWarning();
break;
}
}
else if ($.browser.mozilla) {
switch (keyCode) {
case arabicYeCharCode:
substituteCharInFireFox(kurdishYeCharCode, e);
showCharWarning();
break;
case arabicAlefMaghsooreCharCode:
substituteCharInFireFox(kurdishYeCharCode, e);
showCharWarning();
break;
case arabicKeCharCode:
substituteCharInFireFox(kurdishKeCharCode, e);
showCharWarning();
break;
}
}
else {
switch (keyCode) {
case arabicYeCharCode:
insertAtCaret(String.fromCharCode(kurdishYeCharCode), e);
showCharWarning();
break;
case arabicAlefMaghsooreCharCode:
insertAtCaret(String.fromCharCode(kurdishYeCharCode), e);
showCharWarning();
break;
case arabicKeCharCode:
insertAtCaret(String.fromCharCode(kurdishKeCharCode), e);
showCharWarning();
break;
}
}
});
});
function showCharWarning(){
return; //
if ($("#ArabicLetterConvertor").length === 0){
$('body').append("");
mw.loader.using( 'jquery.ui', function() {
$("#ArabicLetterConvertor").dialog();
});
}
}