props.html 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <html>
  2. <head>
  3. </head>
  4. <body>
  5. <script>(function(){
  6. var props = {};
  7. function addObject(obj) {
  8. if (obj == null) return;
  9. try {
  10. Object.getOwnPropertyNames(obj).forEach(add);
  11. } catch(ex) {}
  12. if (obj.prototype) {
  13. Object.getOwnPropertyNames(obj.prototype).forEach(add);
  14. }
  15. if (typeof obj == "function") {
  16. try {
  17. Object.getOwnPropertyNames(new obj).forEach(add);
  18. } catch(ex) {}
  19. }
  20. }
  21. function add(name) {
  22. if (/^[a-z_$][a-z0-9_$]*$/i.test(name)) {
  23. props[name] = true;
  24. }
  25. }
  26. Object.getOwnPropertyNames(window).forEach(function(thing){
  27. addObject(window[thing]);
  28. });
  29. try {
  30. addObject(new Event("click"));
  31. addObject(new Event("contextmenu"));
  32. addObject(new Event("mouseup"));
  33. addObject(new Event("mousedown"));
  34. addObject(new Event("keydown"));
  35. addObject(new Event("keypress"));
  36. addObject(new Event("keyup"));
  37. addObject(new Event("input"));
  38. addObject(new Event("touchstart"));
  39. addObject(new Event("touchmove"));
  40. addObject(new Event("touchend"));
  41. addObject(new Event("touchcancel"));
  42. addObject(new Event("pointerdown"));
  43. addObject(new Event("pointermove"));
  44. addObject(new Event("pointerup"));
  45. addObject(new Event("pointercancel"));
  46. addObject(new Event("pointerenter"));
  47. addObject(new Event("pointerleave"));
  48. } catch(ex) {}
  49. var ta = document.createElement("textarea");
  50. ta.style.width = "100%";
  51. ta.style.height = "20em";
  52. ta.style.boxSizing = "border-box";
  53. ta.value = 'export var domprops = ' + JSON.stringify(Object.keys(props).sort(cmp), null, 4);
  54. document.body.appendChild(ta);
  55. function cmp(a, b) {
  56. a = a.toLowerCase();
  57. b = b.toLowerCase();
  58. return a < b ? -1 : a > b ? 1 : 0;
  59. }
  60. })();</script>
  61. </body>
  62. </html>