1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
|
var isEventSupported = (function(undef) {
var TAGNAMES = {
'select':'input',
'change':'input',
'submit':'form',
'reset':'form',
'error':'img',
'load':'img',
'abort':'img'
};
function isEventSupported(eventName, element) {
element = element || document.createElement(TAGNAMES[eventName] || 'div');
eventName = 'on' + eventName;
var isSupported = (eventName in element);
if (!isSupported) {
// if it has no `setAttribute` (i.e. doesn't implement Node interface), try generic element
if (!element.setAttribute) {
element = document.createElement('div');
}
if (element.setAttribute && element.removeAttribute) {
element.setAttribute(eventName, '');
isSupported = typeof element[eventName] == 'function';
// if property was created, "remove it" (by setting value to `undefined`)
if (typeof element[eventName] != 'undefined') {
element[eventName] = undef;
}
element.removeAttribute(eventName);
}
}
element = null;
return isSupported;
}
return isEventSupported;
})();
function divResult(category, name, element, div) {
div.innerHTML = div.innerHTML + category + " " + name + ": ";
div.innerHTML = div.innerHTML + (
isEventSupported(name, element)
? '<span style="background-color:green;color:white;">true</span></td>'
: '<span style="background-color:red;color:white;">false</span></td>'
);
div.innerHTML = div.innerHTML + "<br>";
}
var counter = 1;
function log(title, detail) {
var logDiv = document.getElementById("log");
idString = "'id" + counter + "'";
var newlink = document.createElement('a');
newlink.setAttribute('href', "javascript:toggle_visibility(" + idString + ")");
newlink.innerHTML = counter + ". " + title;
var br1 = document.createElement('br');
logDiv.appendChild(newlink);
logDiv.appendChild(br1);
var childDiv = document.createElement('div');
childDiv.setAttribute("id", idString.replace("'", "").replace("'", ""));
childDiv.setAttribute("style", 'display: none; margin-left : 5px;');
childDiv.innerHTML = detail;
var br2 = document.createElement('br');
logDiv.appendChild(childDiv);
counter = counter + 1;
}
function inspect(obj) {
if (typeof obj === "undefined") {
return "undefined";
}
var _props = [];
for (var i in obj) {
_props.push(i + " : " + obj[i]);
}
return " {" + _props.join(",<br>") + "} ";
}
function click(e) {
if (document.getElementById("clickID").checked) {
var box = document.getElementById("box");
log(e.type, inspect(e));
if (e.preventDefault) e.preventDefault();
}
return false;
}
function dblclick(e) {
if (document.getElementById("dblclickID").checked) {
var box = document.getElementById("box");
log(e.type, inspect(e));
if (e.preventDefault) e.preventDefault();
}
return false;
}
function mousedown(e) {
if (document.getElementById("mousedownID").checked) {
var box = document.getElementById("box");
log(e.type, inspect(e));
if (e.preventDefault) e.preventDefault();
}
return false;
}
function mouseup(e) {
if (document.getElementById("mouseupID").checked) {
var box = document.getElementById("box");
log(e.type, inspect(e));
if (e.preventDefault) e.preventDefault();
}
return false;
}
function mouseover(e) {
if (document.getElementById("mouseoverID").checked) {
var box = document.getElementById("box");
log(e.type, inspect(e));
if (e.preventDefault) e.preventDefault();
}
return false;
}
function mousemove(e) {
if (document.getElementById("mousemoveID").checked) {
var box = document.getElementById("box");
log(e.type, inspect(e));
if (e.preventDefault) e.preventDefault();
}
return false;
}
function mouseout(e) {
if (document.getElementById("mouseoutID").checked) {
var box = document.getElementById("box");
log(e.type, inspect(e));
if (e.preventDefault) e.preventDefault();
}
return false;
}
function touchstart(e) {
if (document.getElementById("touchstartID").checked) {
var box = document.getElementById("box");
var result = inspect(e);
for (var i = 0; i < e.touches.length; i++) {
result = result + "<br> Touches nr." + i + " <br>" + inspect(e.touches[i]);
}
log(e.type, result);
if (e.preventDefault) e.preventDefault();
}
return false;
}
function touchend(e) {
if (document.getElementById("touchendID").checked) {
var box = document.getElementById("box");
var result = inspect(e);
for (var i = 0; i < e.touches.length; i++) {
result = result + "<br> Touches nr." + i + " <br>" + inspect(e.touches[i]);
}
log(e.type, result);
if (e.preventDefault) e.preventDefault();
}
return false;
}
function touchmove(e) {
if (document.getElementById("touchmoveID").checked) {
var targetEvent = e.touches.item(0);
var box = document.getElementById("box");
box.style.left = targetEvent.clientX + "px";
box.style.top = targetEvent.clientY + "px";
var result = inspect(e);
for (var i = 0; i < e.touches.length; i++) {
result = result + "<br> Touches nr." + i + " <br>" + inspect(e.touches[i]);
}
log(e.type, result);
if (e.preventDefault) e.preventDefault();
}
return false;
}
function touchcancel(e) {
if (document.getElementById("touchcancelID").checked) {
var box = document.getElementById("box");
var result = inspect(e);
for (var i = 0; i < e.touches.length; i++) {
result = result + "<br> Touches nr." + i + " <br>" + inspect(e.touches[i]);
}
log(e.type, result);
if (e.preventDefault) e.preventDefault();
}
return false;
}
function gesturestart(e) {
if (document.getElementById("gesturestartID").checked) {
var box = document.getElementById("box");
log(e.type, inspect(e));
if (e.preventDefault) e.preventDefault();
}
return false;
}
function gesturechange(e) {
if (document.getElementById("gesturechangeID").checked) {
var box = document.getElementById("box");
log(e.type, inspect(e));
if (e.preventDefault) e.preventDefault();
}
return false;
}
function gestureend(e) {
if (document.getElementById("gestureendID").checked) {
var box = document.getElementById("box");
log(e.type, inspect(e));
if (e.preventDefault) e.preventDefault();
}
return false;
}
function toggle_visibility(id) {
var e = document.getElementById(id);
if (e.style.display == 'block') {
e.style.display = 'none';
} else {
e.style.display = 'block';
}
}
|