1

i am converting English to My local language in ckeditor by using phonetic characters but it is not working properly in google chrome and safari This is my code

( function() {

   var codes= new Array();
   codes['a']=0x0627;
   ..................
   codes['z']=0x0632;

   codes['A']=0x0622;
   ..................
   codes['Z']=0x0630;

   codes['>']=0x0650;
   ..................
   codes[':']=58;

   codes['[']=0x201C;
   ..................
   codes['´']=0x0657;

   codes['0']=0x30;
   ..................
   codes['9']=0x39;

   isUrdu=true;
   var urdueditor_lang = 1;        // 1: Urdu, 0: English
   //var isiri2901_nativelang = 0;  // 1: Urdu, 0: English


    function DenIE_OnKeyDown( e )
    {
        var charCode = e.keyCode;
        if (e.ctrlKey && (charCode==32))
        {
            if (urdueditor_lang == 0)
              urdueditor_lang = 1;
            else
              urdueditor_lang = 0;
            try {
              e.preventDefault();
            } catch (err) {
            }
            return false;
        }
    }

    function DenIE_OnKeyPress( e )
    {
        if(urdueditor_lang!=1) return true;
        var charCode = e.keyCode;
        var whichASC = charCode ;
        var whichChar = String.fromCharCode(whichASC); // key's character
        e.keyCode= codes[whichChar];
    }

    var DenGecko_OnKeyDown = function(e) {
        var charCode = (e.charCode) ? e.charCode :
                            ((e.keyCode) ? e.keyCode :
                           ((e.which) ? e.which : 0));
        if (e.ctrlKey && (charCode==32))
        {
            if (urdueditor_lang == 0)
              urdueditor_lang = 1;
            else
              urdueditor_lang = 0;
            try {

              e.preventDefault();
            } catch (err) {
            }
            return false;
        }
    };

    var DenGecko_OnKeyPress = function(e) {
        if(urdueditor_lang!=1) return true;
        var charCode = e.charCode;
        var whichASC = charCode ;
        var whichChar = String.fromCharCode(whichASC); // key's character
        if((charCode==13) || (charCode==8)|| (charCode==37) || (charCode==39) ||  (charCode==38)|| (charCode==40)|| (charCode==33) || (charCode==34) || (charCode==50)  ) return;
        if (e.bubbles==false)
        return true;

        console.log("whichASC", whichASC);
        if (whichASC >= 0x00FF) {
            isUrdu=true;
        }
        else
        {
            isUrdu=false;
        }

        if (whichASC < 0x0020 || whichASC >= 0x007F || e.ctrlKey || e.altKey || e.metaKey)
            return true;
        var newkey;
        newkey = codes[whichChar];
        if (newkey == whichASC)
            return true;
        txt=String.fromCharCode(codes[whichChar]);
          e.preventDefault();
          var editor = CKEDITOR.instances.urduContent;

          editor.insertText(txt);
        }


   CKEDITOR.plugins.add( 'urdu',
   {
      init : function( editor )
      {
         editor.on( 'contentDom', function( e ) {
            var doc = this.document.$;
            if ( CKEDITOR.env.ie ) {        // If Internet Explorer.
               doc.attachEvent("onkeydown", DenIE_OnKeyDown ) ;
               doc.attachEvent("onkeypress", DenIE_OnKeyPress ) ;
            } else {                // If Gecko.
               doc.addEventListener( 'keydown', DenGecko_OnKeyDown, true ) ;
               doc.addEventListener( 'keypress', DenGecko_OnKeyPress, true ) ;
            }
         });

      } //Init
   } );

})();

But its working in Firefox, i can read text in all browser in chrome, safari characters is not bind to make words.

Hassan Shafique
  • 147
  • 2
  • 14
  • 1
    Post the code you are trying, we can't reproduce if you do not post what you have tried so far. – svelandiag Feb 06 '17 at 17:14
  • @SsouLlesS sorry i was busy its late but i have update my code please review it ... – Hassan Shafique Feb 11 '17 at 07:20
  • It has been a little over 4 years since I published that code http://ckeditor.com/forums/Plugins/Urdu-input stating that it doesn't work in Chrome, so what have you really tried? Why have you added jQuery tag? – AlfonsoML Feb 11 '17 at 15:27
  • after adding Jquery now it is working in Chrome but does not bind characters to make words its just showing me character before changing it was event does not show me characters as well – Hassan Shafique Feb 12 '17 at 12:22
  • can you guide me why its not working properly in chrome ? – Hassan Shafique Feb 12 '17 at 13:41

0 Answers0