Guest User

Untitled

a guest
Oct 13th, 2019
81
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function(a, b) {
  2. typeof define === "function" && define.amd ? define([], function() {
  3. return b()
  4. }) : typeof exports === "object" ? module.exports = b() : a.whatInput = b()
  5. }
  6. )(this, function() {
  7. function a(a) {
  8. clearTimeout(p);
  9. c(a);
  10. i = !0;
  11. p = setTimeout(function() {
  12. i = !1
  13. }, 1E3)
  14. }
  15. function b(a) {
  16. i || c(a)
  17. }
  18. function c(a) {
  19. var c = a.keyCode ? a.keyCode : a.which
  20. , b = a.target || a.srcElement
  21. , d = l[a.type];
  22. d === "pointer" && (d = typeof a.pointerType === "number" ? q[a.pointerType] : a.pointerType);
  23. if (h !== d && (k || !h || !(d === "keyboard" && o[c] !== "tab" && j.indexOf(b.nodeName.toLowerCase()) >= 0)))
  24. h = d,
  25. f.setAttribute("data-whatinput", h),
  26. m.indexOf(h) === -1 && m.push(h);
  27. d === "keyboard" && g.indexOf(o[c]) === -1 && o[c] && g.push(o[c])
  28. }
  29. function d(a) {
  30. a = g.indexOf(o[a.keyCode ? a.keyCode : a.which]);
  31. a !== -1 && g.splice(a, 1)
  32. }
  33. var g = [], f = document.body, i = !1, h = null, j = ["input", "select", "textarea"], k = f.hasAttribute("data-whatinput-formtyping"), l = {
  34. keydown: "keyboard",
  35. mousedown: "mouse",
  36. mouseenter: "mouse",
  37. touchstart: "touch",
  38. pointerdown: "pointer",
  39. MSPointerDown: "pointer"
  40. }, m = [], o = {
  41. 9: "tab",
  42. 13: "enter",
  43. 16: "shift",
  44. 27: "esc",
  45. 32: "space",
  46. 37: "left",
  47. 38: "up",
  48. 39: "right",
  49. 40: "down"
  50. }, q = {
  51. 2: "touch",
  52. 3: "touch",
  53. 4: "mouse"
  54. }, p;
  55. (function() {
  56. var c = "mousedown";
  57. window.PointerEvent ? c = "pointerdown" : window.MSPointerEvent && (c = "MSPointerDown");
  58. f.addEventListener ? (f.addEventListener(c, b),
  59. f.addEventListener("mouseenter", b),
  60. "ontouchstart"in document.documentElement && f.addEventListener("touchstart", a),
  61. f.addEventListener("keydown", b),
  62. f.addEventListener("keyup", d)) : (f.attachEvent(c, b),
  63. f.attachEvent("mouseenter", b),
  64. "ontouchstart"in document.documentElement && f.attachEvent("touchstart", a),
  65. f.attachEvent("keydown", b),
  66. f.attachEvent("keyup", d))
  67. }
  68. )();
  69. return {
  70. ask: function() {
  71. return h
  72. },
  73. keys: function() {
  74. return g
  75. },
  76. types: function() {
  77. return m
  78. },
  79. set: c
  80. }
  81. });
RAW Paste Data