2 // http://www.webcheatsheet.com/PHP/get_current_page_url.php
3 function getCurrentURL(){
4 $pageURL = 'http' . (!empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on" ?
's' : '');
5 $pageURL .= "://" . $_SERVER["SERVER_NAME"];
6 if ($_SERVER["SERVER_PORT"] != "80") $pageURL .= ":".$_SERVER["SERVER_PORT"];
8 return $pageURL.$_SERVER["REQUEST_URI"];
11 // http://forum.jquery.com/topic/implementation-of-domcontentloaded-failing-when-no-assets
12 // by andrea.giammarchi on 13-Jul-2008 10:21 PM
13 function flushPause($pause = 0){
17 usleep($pause * 1000000);
21 ob_implicit_flush(false);
29 var testElement
= document
.createElement('div'),
30 hasOperationAborted
= (
31 testElement
.innerHTML
= '<!--[if lt IE 8]>1<![endif]-->', !!+testElement
.innerText
34 var MESSAGES
= document
.createElement('div')
35 , thingsThatHappened
= {}
37 function somethingHappened(id
, result
){
38 if (window
.ONLOAD
) document
.body
.insertBefore(MESSAGES
, document
.body
.firstChild
)
40 if (typeof result
== 'function') result
= result()
41 if (result
== null) result
= ''
42 if (result
=== true) result
= 'PASS'
43 if (result
=== false) result
= 'FAIL'
45 if (thingsThatHappened
[id
] === result
) return
46 thingsThatHappened
[id
] = result
48 log((+
new Date
- START_TIME
) +
' '+ id +
' ' + result
)
51 +
= '<p id="' + id +
'" class="' + result +
'">'
52 +
'<b>' +
(+
new Date
- START_TIME
) +
'ms </b>'
58 var START_TIME
= +
new Date
59 function isNotLoaded(){ return !!(window
.PARSED
&& !window
.ONLOAD
) }
61 if (false <?php
if (isset($_GET['iframe'])) echo '|| true'; ?
>){
63 document
.domain
= 'localhost'
64 somethingHappened("document.domain = 'localhost'", true)
67 somethingHappened("document.domain = 'localhost'; " + e
, false)
73 function log(message
){
75 console
.log('' + message
)
80 var domreadyCallbacks
= []
81 function DomReady(fn
){
82 domreadyCallbacks
.push(fn
)
84 <?php
if (!isset($_GET['plain'])):
85 $core = dirname(__FILE__
) . '/../../../';
86 require $core . 'Packager/packager.php';
88 $pkg = new Packager(array($core));
89 echo $pkg->build(array('DOMReady'), array(), array(), array());
91 document
.write('<scr'+
'ipt src="./DOMReady.js?' +
(new Date
) +
'"><'+
'/script>');
92 document
.write('<scr'+
'ipt src="../../../Source/Utilities/DOMReady.js?' +
(new Date
) +
'"><'+
'/script>');
97 var loadScript
= function(type
){
99 new Element('script', {
100 src
: '../../Configuration.js?' + type +
(new Date
),
103 log('>> ' + type +
': JavaSript Loaded, load called: ' +
(++count
));
106 }).inject(document
.body
);
107 log('>> ' + type +
': Loading JavaScript');
110 window
.addEvent('load', function(){
114 somethingHappened('<i>MooTools load</i>', function(){
115 return !!window
.READY
118 window
.addEvent('domready', function(){
119 loadScript('domready');
121 window
.READY
= +
new Date
122 somethingHappened('<i>MooTools domready</i>', isNotLoaded
)
125 window
.READY
= +
new Date
126 somethingHappened('<i>MooTools domready</i>', isNotLoaded
)
129 <meta http
-equiv
=Content
-type content
="text/html; charset=utf-8">
130 <title
>DomReady Test
</title
>
154 font
: 11px
"Lucida Grande", "Trebuchet MS", Verdana
, sans
-serif
;
163 .PASS
{background
:#0f0;}
164 .FAIL
{background
:#f00;}
166 .Yes
{background
:#cfc;}
167 .No
{background
:#fcc;}
175 if (document
.addEventListener
) document
.addEventListener('DOMContentLoaded', function(){ window
.READY
= +
new Date
; somethingHappened('DOMContentLoaded (addEventListener)', isNotLoaded
) }, false)
176 if (document
.attachEvent
) document
.attachEvent('onDOMContentLoaded', function(){ window
.READY
= +
new Date
; somethingHappened('DOMContentLoaded (attachEvent)', isNotLoaded
) }, false)
178 if (document
.addEventListener
) document
.addEventListener('readyStateChange', function(){ somethingHappened('readyStateChange (addEventListener)', document
.readyState
) }, false)
179 if (document
.attachEvent
) document
.attachEvent('onReadyStateChange', function(){ somethingHappened('onReadyStateChange (attachEvent)', document
.readyState
) }, false)
180 if (document
.attachEvent
) document
.attachEvent('onreadystatechange', function(){ somethingHappened('onreadystatechange (attachEvent)', document
.readyState
) }, false)
183 var TEST_ELEMENT
= document
.createElement('div')
184 function pollDoScroll(){
185 if (!TEST_ELEMENT
.doScroll
) return
189 TEST_ELEMENT
.doScroll('left')
196 window
.CANSCROLL
= PASS
197 somethingHappened('TEST_ELEMENT.doScroll()', PASS
)
199 if (!PASS
) setTimeout(pollDoScroll
, 10)
202 function pollDoScroll_body(){
203 if (!document
.body
.doScroll
) return
207 document
.body
.doScroll('left')
214 somethingHappened('document.body.doScroll()', PASS
)
216 if (!PASS
) setTimeout(pollDoScroll_body
, 10)
220 function pollReadyState(){
221 var readyState
= document
.readyState
222 if (!readyState
) return
223 if (readyState
== lastReadyState
) return
224 somethingHappened('poll document.readyState', readyState
)
225 if (readyState
!= 'complete' && readyState
!= 'loaded') setTimeout(pollReadyState
, 10)
226 lastReadyState
= readyState
229 function pollBodyExists(){
233 document
.body
.lastChild
239 somethingHappened('body Exists?', PASS?
'YES':'NO')
240 if (!window
.ONLOAD
) setTimeout(pollBodyExists
, 10)
243 function pollAugmentBody(){
245 , body
= document
.body
246 , root
= body
.parentNode
247 , sibling
= body
.nextSibling
250 body
.appendChild(document
.createTextNode( new Date
- START_TIME +
'ms:Body ') )
256 somethingHappened('can Augment Body?', PASS?
'YES':'NO')
257 if (!window
.ONLOAD
) setTimeout(pollAugmentBody
, 10)
260 // // // // // // // // // // // // // // // // // // // // //
263 "document.readyState ==": function(){return document
.readyState
}
265 ,'document.body exists?': function(){return document
.body ?
'Yes':'No'}
267 ,"All page content loaded and parsed?": function(){return window
.PARSED ?
'Yes':'No'}
268 ,"cached IMG onload fired?": function(){return window
.IMG_ONLOAD ?
'Yes':'No'}
269 ,"uncached IMG onload fired?": function(){return window
.IMG_ONLOAD_UNCACHED ?
'Yes':'No'}
270 ,"document ready?": function(){return !!window
.READY ?
'Yes':'No'}
271 ,"onload fired?": function(){return !!window
.ONLOAD ?
'Yes':'No'}
273 ,"el.doScroll()": function(){
275 TEST_ELEMENT
.doScroll()
283 ,"body.doScroll('left')": function(){
285 document
.body
.doScroll('left')
293 ,'isFramed?': function(){
294 return isFramed() ?
'Yes':'No'
297 ,'Is top frame?': function(){
298 return window
.window
=== window
.top ?
'Yes':'No'
302 if (!hasOperationAborted
) readyTests
['Can augment body?'] = function(){
304 document
.body
.appendChild(
305 document
.createTextNode('Augmented the body! ' +
(+
new Date
- START_TIME
))
307 document
.body
.removeChild(document
.body
.lastChild
)
315 var readyTestResults
= []
319 , lastResults
= readyTestResults
[readyTestResults
.length
- 1] ||
{}
320 , hasDifferentResults
= 0
322 results
.ms
= new Date
- START_TIME
324 for (var id in readyTests
){
325 results
[id
] = readyTests
[id
]()
326 if (results
[id
] == lastResults
[id
]) continue
328 ++ hasDifferentResults
329 somethingHappened(id
, results
[id
])
334 if (window
.CANSCROLL
&& !isFramed()) shouldBeReady
= true
335 if ({loaded
:1,complete
:1}[document
.readyState
]) shouldBeReady
= true
336 if (window
.LOADED
) shouldBeReady
= true
337 if (window
.IMG_ONLOAD_UNCACHED
) shouldBeReady
= true
340 somethingHappened('Should be Ready!', function(){
341 return !!window
.READY ?
true:'Not yet...'
344 if (hasDifferentResults
) readyTestResults
.push(results
)
345 if (!window
.ONLOAD
) setTimeout(poll
, 10)
351 return window
.frameElement
!= null
359 var EL
= document
.createElement('div')
360 , HTML
= '<table class=results>'
362 for (var i
= 0; i
< readyTestResults
.length
; ++i
){
364 HTML +
= '<thead><tr>'
365 for (var key in readyTestResults
[i
]){
370 HTML +
= '</tr></thead>'
374 for (var key in readyTestResults
[i
]){
376 HTML +
= readyTestResults
[i
][key
]
383 document
.body
.insertBefore(EL
, document
.body
.firstChild
)
391 onload
="window.ONLOAD = +new Date; somethingHappened('body[onload] ' + (window.READY ? (window.ONLOAD - window.READY) + 'ms after Ready' : ''), function(){return !!window.READY})"
392 onDOMContentLoaded
="window.READY = +new Date; somethingHappened('DOMContentLoaded body[onDOMContentLoaded]', isNotLoaded)"
393 onReadyStateChange
="somethingHappened('body[onReadyStateChange]')"
398 <div id
=thingsthathappened
></div
>
402 <script
> somethingHappened('<i>Before serverSide flush/sleep</i> <hr>') </script
>
403 <?php
flushPause(1.0); ?
>
404 <script
> somethingHappened('<i>After serverSide flush/sleep</i> <hr>') </script
>
407 <p
>Lorem ipsum dolor sit amet
, consectetur adipisicing elit
, sed
do eiusmod tempor incididunt ut labore et dolore magna aliqua
. Ut enim ad minim veniam
, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat
. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur
. Excepteur sint occaecat cupidatat non proident
, sunt in culpa qui officia deserunt mollit anim id est laborum
.</p
>
408 <p
>Lorem ipsum dolor sit amet
, consectetur adipisicing elit
, sed
do eiusmod tempor incididunt ut labore et dolore magna aliqua
. Ut enim ad minim veniam
, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat
. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur
. Excepteur sint occaecat cupidatat non proident
, sunt in culpa qui officia deserunt mollit anim id est laborum
.</p
>
409 <p
>Lorem ipsum dolor sit amet
, consectetur adipisicing elit
, sed
do eiusmod tempor incididunt ut labore et dolore magna aliqua
. Ut enim ad minim veniam
, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat
. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur
. Excepteur sint occaecat cupidatat non proident
, sunt in culpa qui officia deserunt mollit anim id est laborum
.</p
>
413 <p
>Lorem ipsum dolor sit amet
, consectetur adipisicing elit
, sed
do eiusmod tempor incididunt ut labore et dolore magna aliqua
. Ut enim ad minim veniam
, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat
. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur
. Excepteur sint occaecat cupidatat non proident
, sunt in culpa qui officia deserunt mollit anim id est laborum
.</p
>
414 <p
>Lorem ipsum dolor sit amet
, consectetur adipisicing elit
, sed
do eiusmod tempor incididunt ut labore et dolore magna aliqua
. Ut enim ad minim veniam
, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat
. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur
. Excepteur sint occaecat cupidatat non proident
, sunt in culpa qui officia deserunt mollit anim id est laborum
.</p
>
415 <p
>Lorem ipsum dolor sit amet
, consectetur adipisicing elit
, sed
do eiusmod tempor incididunt ut labore et dolore magna aliqua
. Ut enim ad minim veniam
, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat
. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur
. Excepteur sint occaecat cupidatat non proident
, sunt in culpa qui officia deserunt mollit anim id est laborum
.</p
>
418 <img height
=16 width
=16 onload
="window.IMG_ONLOAD = true; somethingHappened('img[onload][src=about:blank]')" src
="about:blank">
419 <img height
=16 width
=16 onload
="window.IMG_ONLOAD = true; somethingHappened('img[onload][src=' + this.src + ']')" src
="http://projects.subtlegradient.com/domready/big_image.jpg">
420 <script
>document
.write("<img height=16 width=16 onload=\"window.IMG_ONLOAD = true; window.IMG_ONLOAD_UNCACHED = true; somethingHappened('img[onload][src=' + this.src + ']')\" src=\"http://projects.subtlegradient.com/domready/big_image.jpg?_=" + +
new Date +
"\">")</script
>
423 onload
="window.SCRIPT_ONLOAD = true; somethingHappened('script[onload][src=about:blank]')"
424 onreadystatechange
="somethingHappened('script[src=about:blank][onreadystatechange]', this.readyState)"
425 onerror
="somethingHappened('script[src=about:blank][onerror]')"
426 src
="about:blank"></script
> -->
428 onload
="window.SCRIPT_ONLOAD = true; somethingHappened('script[onload]')"
429 onreadystatechange
="somethingHappened('script[onreadystatechange]', this.readyState)"
430 src
="http://projects.subtlegradient.com/domready/blank.js"></script
>
432 onload
="window.SCRIPT_ONLOAD = true; somethingHappened('script[onload][defer]')"
433 onreadystatechange
="somethingHappened('script[defer][onreadystatechange]', this.readyState)"
434 defer src
="http://projects.subtlegradient.com/domready/blank.js?123"></script
>
438 <script
>if (window
!= top
) {somethingHappened('This is a frame!'); document
.getElementsByTagName('html')[0].className +
= ' framed'} </script
>
440 if (!isset($_GET['iframe'])){
441 $url = getCurrentURL();
442 $url .= (strpos($url, '?') !== false ?
'&' : '?') . 'iframe';
443 echo '<iframe src="' . $url . '"></iframe>';
447 somethingHappened('<i>All page content loaded and parsed! (Last <SCRIPT> on page)</i> <hr>')
453 <?php
flushPause(); ?
>