jquery.sendkeys.js

jquery.sendkeys.js is a javascript bililiteRange plugin (see https://greatest.deepsurf.us/en/scripts/24818-bililiterange/code and https://github.com/dwachss/bililiteRange )

بۇ قوليازمىنى بىۋاسىتە قاچىلاشقا بولمايدۇ. بۇ باشقا قوليازمىلارنىڭ ئىشلىتىشى ئۈچۈن تەمىنلەنگەن ئامبار بولۇپ، ئىشلىتىش ئۈچۈن مېتا كۆرسەتمىسىگە قىستۇرىدىغان كود: // @require https://update.greatest.deepsurf.us/scripts/374554/646475/jquerysendkeysjs.js

  1. // insert characters in a textarea or text input field
  2. // special characters are enclosed in {}; use {{} for the { character itself
  3. // documentation: http://bililite.com/blog/2008/08/20/the-fnsendkeys-plugin/
  4. // Version: 4
  5. // Copyright (c) 2013 Daniel Wachsstock
  6. // MIT license:
  7. // Permission is hereby granted, free of charge, to any person
  8. // obtaining a copy of this software and associated documentation
  9. // files (the "Software"), to deal in the Software without
  10. // restriction, including without limitation the rights to use,
  11. // copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. // copies of the Software, and to permit persons to whom the
  13. // Software is furnished to do so, subject to the following
  14. // conditions:
  15.  
  16. // The above copyright notice and this permission notice shall be
  17. // included in all copies or substantial portions of the Software.
  18.  
  19. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  21. // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  23. // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  24. // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  25. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  26. // OTHER DEALINGS IN THE SOFTWARE.
  27.  
  28. (function($){
  29.  
  30. $.fn.sendkeys = function (x){
  31. x = x.replace(/([^{])\n/g, '$1{enter}'); // turn line feeds into explicit break insertions, but not if escaped
  32. return this.each( function(){
  33. bililiteRange(this).bounds('selection').sendkeys(x).select();
  34. this.focus();
  35. });
  36. }; // sendkeys
  37.  
  38. // add a default handler for keydowns so that we can send keystrokes, even though code-generated events
  39. // are untrusted (http://www.w3.org/TR/DOM-Level-3-Events/#trusted-events)
  40. // documentation of special event handlers is at http://learn.jquery.com/events/event-extensions/
  41. $.event.special.keydown = $.event.special.keydown || {};
  42. $.event.special.keydown._default = function (evt){
  43. if (evt.isTrusted) return false;
  44. if (evt.ctrlKey || evt.altKey || evt.metaKey) return false; // only deal with printable characters. This may be a false assumption
  45. if (evt.key == null) return false; // nothing to print. Use the keymap plugin to set this
  46. var target = evt.target;
  47. if (target.isContentEditable || target.nodeName == 'INPUT' || target.nodeName == 'TEXTAREA') {
  48. // only insert into editable elements
  49. var key = evt.key;
  50. if (key.length > 1 && key.charAt(0) != '{') key = '{'+key+'}'; // sendkeys notation
  51. $(target).sendkeys(key);
  52. return true;
  53. }
  54. return false;
  55. }
  56. })(jQuery)