Advertisement
majudhu

vaguthu dhivehi key translation

May 12th, 2020
1,220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var c;
  2. (c = jQuery).fn.thaana = function (t) {
  3. var e = {
  4. keyboard: 'phonetic'
  5. };
  6. return this.each(function () {
  7. t && c.extend(e, t);
  8. var n = {
  9.   phonetic: {
  10.     33: '!',
  11.     34: '"',
  12.     35: '#',
  13.     36: '$',
  14.     37: '%',
  15.     38: '&',
  16.     39: '\'',
  17.     40: ')',
  18.     41: '(',
  19.     42: '*',
  20.     43: '+',
  21.     44: '،',
  22.     45: '-',
  23.     46: '.',
  24.     47: '/',
  25.     58: ':',
  26.     59: '؛',
  27.     60: '>',
  28.     61: '=',
  29.     62: '<',
  30.     63: '؟',
  31.     64: '@',
  32.     65: 'ާ',
  33.     66: 'ޞ',
  34.     67: 'ޝ',
  35.     68: 'ޑ',
  36.     69: 'ޭ',
  37.     70: 'ﷲ',
  38.     71: 'ޣ',
  39.     72: 'ޙ',
  40.     73: 'ީ',
  41.     74: 'ޛ',
  42.     75: 'ޚ',
  43.     76: 'ޅ',
  44.     77: 'ޟ',
  45.     78: 'ޏ',
  46.     79: 'ޯ',
  47.     80: '÷',
  48.     81: 'ޤ',
  49.     82: 'ޜ',
  50.     83: 'ށ',
  51.     84: 'ޓ',
  52.     85: 'ޫ',
  53.     86: 'ޥ',
  54.     87: 'ޢ',
  55.     88: 'ޘ',
  56.     89: 'ޠ',
  57.     90: 'ޡ',
  58.     91: ']',
  59.     92: '\\',
  60.     93: '[',
  61.     94: '^',
  62.     95: '_',
  63.     96: '`',
  64.     97: 'ަ',
  65.     98: 'ބ',
  66.     99: 'ޗ',
  67.     100: 'ދ',
  68.     101: 'ެ',
  69.     102: 'ފ',
  70.     103: 'ގ',
  71.     104: 'ހ',
  72.     105: 'ި',
  73.     106: 'ޖ',
  74.     107: 'ކ',
  75.     108: 'ލ',
  76.     109: 'މ',
  77.     110: 'ނ',
  78.     111: 'ޮ',
  79.     112: 'ޕ',
  80.     113: 'ް',
  81.     114: 'ރ',
  82.     115: 'ސ',
  83.     116: 'ތ',
  84.     117: 'ު',
  85.     118: 'ވ',
  86.     119: 'އ',
  87.     120: '×',
  88.     121: 'ޔ',
  89.     122: 'ޒ',
  90.     123: '}',
  91.     124: '|',
  92.     125: '{',
  93.     126: '~'
  94.   },
  95.   typewriter: {
  96.     33: '!',
  97.     34: '؛',
  98.     35: '#',
  99.     36: '$',
  100.     37: '%',
  101.     38: '&',
  102.     39: 'ﷲ',
  103.     40: ')',
  104.     41: '(',
  105.     42: '*',
  106.     43: '+',
  107.     44: 'ށ',
  108.     45: '-',
  109.     46: 'ޓ',
  110.     47: 'ޯ',
  111.     58: 'ޡ',
  112.     59: 'ފ',
  113.     60: '\\',
  114.     61: '=',
  115.     62: 'ޞ',
  116.     63: '؟',
  117.     64: '@',
  118.     65: '<',
  119.     66: 'ޟ',
  120.     67: 'ޏ',
  121.     68: '.',
  122.     69: '“',
  123.     70: '،',
  124.     71: '"',
  125.     72: 'ޥ',
  126.     73: 'ޣ',
  127.     74: 'ޢ',
  128.     75: 'ޘ',
  129.     76: 'ޚ',
  130.     77: 'ޝ',
  131.     78: 'ޛ',
  132.     79: 'ޠ',
  133.     80: 'ޙ',
  134.     81: '×',
  135.     82: '/',
  136.     83: '>',
  137.     84: ':',
  138.     85: 'ޜ',
  139.     86: 'ޗ',
  140.     87: '’',
  141.     88: 'ޕ',
  142.     89: 'ޤ',
  143.     90: 'ޖ',
  144.     91: 'ލ',
  145.     92: ']',
  146.     93: '[',
  147.     94: '^',
  148.     95: '_',
  149.     96: '`',
  150.     97: 'ި',
  151.     98: 'ޅ',
  152.     99: 'ސ',
  153.     100: 'ް',
  154.     101: 'ާ',
  155.     102: 'ަ',
  156.     103: 'ެ',
  157.     104: 'ވ',
  158.     105: 'މ',
  159.     106: 'އ',
  160.     107: 'ނ',
  161.     108: 'ކ',
  162.     109: 'ބ',
  163.     110: 'ދ',
  164.     111: 'ތ',
  165.     112: 'ހ',
  166.     113: 'ޫ',
  167.     114: 'ީ',
  168.     115: 'ު',
  169.     116: 'ޭ',
  170.     117: 'ރ',
  171.     118: 'ޔ',
  172.     119: 'ޮ',
  173.     120: 'ޑ',
  174.     121: 'ގ',
  175.     122: 'ޒ',
  176.     123: '÷',
  177.     124: '}',
  178.     125: '{',
  179.     126: '~'
  180.   }
  181. },
  182. i = function () {
  183.   var t,
  184.   i = c(this).val(),
  185.   r = !1,
  186.   o = 0;
  187.   this.selectionEnd < i.length && this.selectionEnd > 0 ? (r = !0, o = this.selectionEnd, t = i.substring(this.selectionEnd - 1, this.selectionEnd))  : t = i.substring(i.length - 1);
  188.   var s = t.charCodeAt(0),
  189.   a = c(this).attr('data-length') ? c(this).attr('data-length')  : 0,
  190.   l = i.length - a;
  191.   void 0 !== n[e.keyboard][s] && (1 == l || i.length < a) && (1 == r ? current = c(this).val().substr(0, this.selectionStart - 1) + n[e.keyboard][s] + c(this).val().substr(this.selectionStart)  : (current = c(this).val().substr(0, i.length - 1), current += n[e.keyboard][s]), c(this).val(current), r && (this.selectionStart = o, this.selectionEnd = o), c(this).trigger('change'))
  192. };
  193. c(this).on('keydown', function (t) {
  194.   t.ctrlKey || t.metaKey || 8 == t.which || 46 == t.which ? c(this).off('input')  : void 0 === c._data(this, 'events').input && c(this).on('input', i),
  195.   c(this).attr('data-length', c(this).val().length)
  196. }).on('keyup', function (t) {
  197.   c(this).attr('data-length', c(this).val().length)
  198. })
  199. })
  200. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement