Skip to content
Browse files

upd: added more event types

  • Loading branch information...
1 parent 714a606 commit ceeaebc0dc87fcd54981c35fc9ad3231bfac0c4c 0mg committed Apr 1, 2012
Showing with 142 additions and 22 deletions.
  1. +142 −22 tools/event/index.html
View
164 tools/event/index.html
@@ -23,14 +23,20 @@
border-left: solid;
}
/*]]>*/</style>
-</head>
-<body>
-<div class="main" id="event-properties"></div>
-<div class="side" id="event-type-log"></div>
<script>//<![CDATA[
-window.addEventListener = window.addEventListener || function() {
- document.attachEvent("on" + arguments[0], arguments[1]);
-};
+if (!window.addEventListener) {
+ window.addEventListener = function(type, f) {
+ document.attachEvent("on" + type, f);
+ };
+}
+if (!Array.prototype.indexOf) {
+ Array.prototype.indexOf = function(v) {
+ for (var i = 0; i < this.length; ++i) {
+ if (this[i] === v) return i;
+ }
+ return -1;
+ };
+}
//]]></script>
<script>//<![CDATA[
var eventlog = [];
@@ -55,24 +61,138 @@
while (logBox.hasChildNodes()) logBox.removeChild(logBox.lastChild);
logBox.appendChild(document.createTextNode(eventlog.join(" ")));
}
-
-var eventList =
- ["mousemove",
- "mousedown",
- "mouseup",
- "click",
- "dblclick",
- "mouseout",
- "mouseover",
- "mousewheel",
- "keydown",
- "keyup",
- "keypress",
- "resize",
- "scroll"];
+var eventTypes = {
+ dom3: [
+ "abort",
+ "blur",
+ "click",
+ "compositionstart",
+ "compositionupdate",
+ "compositionend",
+ "dblclick",
+ "DOMActivate",
+ "DOMAttributeNameChanged",
+ "DOMAttrModified",
+ "DOMCharacterDataModified",
+ "DOMElementNameChanged",
+ "DOMFocusIn",
+ "DOMFocusOut",
+ //"DOMNodeInserted",
+ "DOMNodeInsertedIntoDocument",
+ //"DOMNodeRemoved",
+ "DOMNodeRemovedFromDocument",
+ //"DOMSubtreeModified",
+ "error",
+ "focus",
+ "focusin",
+ "focusout",
+ "keydown",
+ "keypress",
+ "keyup",
+ "load",
+ "mousedown",
+ "mouseenter",
+ "mouseleave",
+ "mousemove",
+ "mouseout",
+ "mouseover",
+ "mouseup",
+ "resize",
+ "scroll",
+ "select",
+ "textinput",
+ "unload",
+ "wheel"
+ ],
+ html5: [
+ "abort",
+ "canplay",
+ "canplaythrough",
+ "change",
+ "click",
+ "contextmenu",
+ "cuechange",
+ "dblclick",
+ "drag",
+ "dragend",
+ "dragenter",
+ "dragleave",
+ "dragover",
+ "dragstart",
+ "drop",
+ "durationchange",
+ "emptied",
+ "ended",
+ "input",
+ "invalid",
+ "keydown",
+ "keypress",
+ "keyup",
+ "loadeddata",
+ "loadedmetadata",
+ "loadstart",
+ "mousedown",
+ "mousemove",
+ "mouseout",
+ "mouseover",
+ "mouseup",
+ "mousewheel",
+ "pause",
+ "play",
+ "playing",
+ "progress",
+ "ratechange",
+ "reset",
+ "seeked",
+ "seeking",
+ "select",
+ "show",
+ "stalled",
+ "submit",
+ "suspend",
+ "timeupdate",
+ "volumechange",
+ "waiting",
+ "blur",
+ "error",
+ "focus",
+ "load",
+ "scroll",
+ "afterprint",
+ "beforeprint",
+ "beforeunload",
+ "blur",
+ "error",
+ "focus",
+ "hashchange",
+ "load",
+ "message",
+ "offline",
+ "online",
+ "pagehide",
+ "pageshow",
+ "popstate",
+ "resize",
+ "scroll",
+ "storage",
+ "unload",
+ "readystatechange"
+ ]
+};
+var eventList = [];
+for (var i in eventTypes) {
+ var types = eventTypes[i], lim = types.length;
+ for (var j = 0; j < lim; ++j) {
+ if (eventList.indexOf(types[j]) === -1) eventList.push(types[j]);
+ }
+}
for (var i = 0; i < eventList.length; ++i) {
window.addEventListener(eventList[i], onEvent, false);
}
//]]></script>
+</head>
+<body>
+<div class="main" id="event-properties"></div>
+<div class="side" id="event-type-log"></div>
</body>
</html>

0 comments on commit ceeaebc

Please sign in to comment.
Something went wrong with that request. Please try again.