-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.php
254 lines (199 loc) · 5.32 KB
/
demo.php
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
242
243
244
245
246
247
248
249
250
251
252
253
254
<?php
/**
* Demo page for lateLoad.
*
* TO USE:
* demo.php?
* jquery=[1] Whether to load jQuery.
*
* @author jls
*
* @version 1.0 2012-05-04
*/
class g
{
static $isJQuery = false;
}
g::$isJQuery = !empty($_GET['jquery']);
print "
<html>
<head>
<style>
H3 {
margin-bottom: 4px;
font-family: Verdana, Arial;
font-size: 15px;
}
.test-container {
border: 1px solid #aaaaaa;
width: 300px;
height: 40px;
}
#loadsInline {
border-color: pink;
}
#loadsOnDocumentReady {
border-color: lightblue;
}
#loadsOnLoad {
border-color: yellow;
}
#loadsOnButton {
border-color: lightgreen;
}
#logWindow {
margin-top: 8px;
border: 1px solid blue;
height: 300px;
width: 450px;
font-family: Verdana, Arial;
font-size: 13px;
overflow: auto;
}
.log-entry {
padding: 2px 4px;
border-bottom: 1px solid #eeeeee;
}
.time {
display: inline-block;
margin-right: 8px;
width: 60px;
font-family: Courier, monospace;
text-align: right;
vertical-align: top;
}
.descr {
display: inline-block;
width: 360px;
text-align: left;
}
</style>
<script>
g = {};
g.dtStart = new Date();
</script>
";
if (g::$isJQuery)
{
print "
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.js'></script>
";
}
print "
<script type='text/javascript' src='/projects/lateload/lateload.beta.1.js'></script>
<script>
";
if (g::$isJQuery)
{
print "
$(document).ready(function(){
g.logEvent ('$(document).ready in <HEAD>');
});
";
}
print <<< xxxxx
g.onLoad = function ()
{
g.logEvent ('onload');
}
g.loadManual = function ()
{
g.logEvent ('Calling lateLoad.now("MyTest")...');
lateLoad.now ('MyTest');
g.logEvent ('...lateLoad.now returned');
}
g.logEvent = function (p_msg)
{
var dtNow, msecs, secs, domLogEntry;
dtNow = new Date();
msecs = dtNow.getTime() - g.dtStart.getTime();
secs = (msecs / 1000).toFixed(3);
domLogEntry = document.createElement('DIV');
domLogEntry.className = "log-entry";
domLogEntry.innerHTML = "<div class='time'>" + secs + "</div><div class='descr'>" + p_msg + "</div>";
g.domLog.appendChild (domLogEntry);
}
</script>
</head>
<body onload='g.onLoad()'>
xxxxx;
if (g::$isJQuery)
{
print "
<script>
$(document).ready(function(){
g.logEvent ('$(document).ready at start of <BODY>');
});
</script>
";
}
print "
<div id='logWindow'>
</div>
<script>
g.domLog = document.getElementById('logWindow');
</script>
<p>It is interesting to contemplate an entangled bank, clothed with many plants of many kinds, with birds singing on the bushes, with various insects flitting about, and with worms crawling through the damp earth, and to reflect that these elaborately constructed forms, so different from each other, and dependent on each other in so complex a manner, have all been produced by laws acting around us.
<h3>This script is loaded inline, so it blocks the text below it.</h3>
<div id='loadsInline' class='test-container'>
</div>
<script type='text/javascript' src='demoscript.php?into=loadsInline'></script>
<p>These laws, taken in the largest sense, being Growth with Reproduction; inheritance which is almost implied by reproduction; Variability from the indirect and direct action of the external conditions of life, and from use and disuse; a Ratio of Increase so high as to lead to a Struggle for Life, and as a consequence to Natural Selection, entailing Divergence of Character and the Extinction of less-improved forms.
";
if (g::$isJQuery)
{
print "
<h3>This script won't load until $(document).ready</h3>
<div id='loadsOnDocumentReady' class='test-container'>
</div>
<script>
lateLoad.later ('demoscript.php?into=loadsOnDocumentReady', {when:'onDocumentReady', where:'#loadsOnDocumentReady'});
</script>
";
}
print "
<p>Thus, from the war of nature, from famine and death, the most exalted object which we are capable of conceiving, namely, the production of the higher animals, directly follows.
<h3>This script won't load until window.onload</h3>
<div id='loadsOnLoad' class='test-container'>
</div>
<script>
lateLoad.later ('demoscript.php?into=loadsOnLoad', {when:'onLoad', where:'#loadsOnLoad'});
</script>
<p>There is grandeur in this view of life, with its several powers, having been originally breathed into a few forms or into one; and that, whilst this planet has gone cycling on according to the fixed law of gravity, from so simple a beginning endless forms most beautiful and most wonderful have been, and are being, evolved.
<h3>This script won't load until you press this button:</h3>
<input type='button' value='Load MyTest widget' onclick='g.loadManual()'>
<div id='loadsOnButton' class='test-container'>
</div>
<script>
lateLoad.later ('demoscript.php?into=loadsOnButton', {when:'MyTest', where:'#loadsOnButton'});
</script>
";
if (g::$isJQuery)
{
print <<< xxxxx
<script>
$(document).ready(function(){
g.logEvent ('$(document).ready at end of <BODY>');
});
</script>
xxxxx;
}
print "
</body>
";
if (g::$isJQuery)
{
print "
<script>
$(document).ready(function(){
g.logEvent ('$(document).ready after </BODY>');
});
</script>
";
}
print "
<script>
g.logEvent ('Parsing end of document');
</script>
</html>
";