-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdom.html
154 lines (131 loc) · 2.42 KB
/
dom.html
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
<!DOCTYPE html>
<html>
<head>
<title>5 minutes for 50 states</title>
<style>
#st {
background-color: #C2C2D6;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius:6px;
}
body {
color: #1B4027;
font-family: Rockwell;
background: #C2C2D6;
text-align: center;
height: 100%;
width: 100%;
}
#rest {
margin-top: 20px;
}
#instructions{
font-size: 40px;
margin-top: 60px;
}
#stat {
margin-top: 30px;
font-size: 40px;
color: #990000;
}
.bor {
width: 300px;
height: 40px;
border: 1px solid #3366FF;
border-left: 4px solid #3366FF;
font-size: 35px;
}
tr {
text-align: left;
}
font.finish {
margin-top: 500px;
margin-left: 500px;
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type='text/javascript'>
function bodyClicked(event){
var x = event.clientX;
var y = event.clientY;
goObj(x, y)
}
function goObj(x, y) {
var arr = document.getElementsByTagName("*");
var numNodes = arr.length;
var tot = [];
for (var i = 0; i < numNodes; i++) {
var elem = arr[i];
var area = elem.offsetHeight * elem.offsetWidth;
tot.push([area, elem]);
}
tot.sort();
var best;
once = false;
for (var i = 0; i < numNodes; i++) {
over = tot[i];
elem = over[1];
area = over[0];
r = elem.getBoundingClientRect()
l = r.left;
t = r.top;
r = l + elem.offsetWidth;
b = t + elem.offsetHeight;
if (((l < x ) && (x < r) && (t < y) && (y < b)) && (once == false)) {
best = over;
once = true;
}
else if (((l < x ) && (x < r) && (t < y) && (y < b)) && (area < best[0])) {
best = over;
}
}
ob = best[1]
function objProps(myObj) {
var idx, out = "";
for (idx in myObj) {
var tn = typeof(myObj[idx]);
if (tn=="function") continue;
if (!myObj[idx]) continue;
out += (!out ? "" : ",\n");
out += idx + ": " + myObj[idx];
}
return out;
}
console.log(objProps(ob));
}
</script>
</head>
<body onclick="bodyClicked(event)">
<div id="stat">
Try to name all 50 states under five minutes!
</div>
<div id="instructions">
</div>
<div id="rest">
<div id="countLeft">
</div>
<div id="enter">
<input type="text" id="myTextId"class="bor">
</div>
<table id="tab1" align="left">
<tr>
<td>
<a>link</a>
</td>
</tr>
<tr>
<td>HI</td>
</tr>
<tr>
<td>BYE</td>
</tr>
</table>
<button type="button" id="st">button</button>
<br>
<br>
<br>
<br>
</div>
</body>
</html>