-
Notifications
You must be signed in to change notification settings - Fork 512
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0dbb4d5
commit 513f9b0
Showing
10 changed files
with
236 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /> | ||
<title>Add MooTools when page is already ready</title> | ||
</head> | ||
<body> | ||
|
||
<script> | ||
function callback(){ | ||
window.callbackFired = true; | ||
} | ||
|
||
function addScript(path){ | ||
var script = document.createElement('script'); | ||
script.type = 'text/javascript'; | ||
script.src = path; | ||
document.getElementsByTagName('head')[0].appendChild(script); | ||
} | ||
|
||
window.callbackFired = false; | ||
window.onload = function(){ | ||
addScript('mootoolsPath.js'); | ||
} | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /> | ||
<title>Flushed page scenario</title> | ||
<script src="mootoolsPath.js" type="text/javascript"></script> | ||
<script> | ||
window.moments = []; | ||
moments.push(document.readyState); | ||
|
||
function callback(){ | ||
window.callbackFired = true; | ||
moments.push(document.readyState); | ||
} | ||
window.callbackFired = false; | ||
window.addEvent("domready", callback); | ||
</script> | ||
</head> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<body> | ||
<div>body added...</div> | ||
<script> | ||
moments.push(document.readyState); | ||
</script> | ||
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /> | ||
<title>Normal DOMReady scenario</title> | ||
|
||
<script src="mootoolsPath.js" type="text/javascript"></script> | ||
</head> | ||
<body> | ||
|
||
<script> | ||
function callback(){ | ||
window.callbackFired = true; | ||
} | ||
|
||
window.callbackFired = false; | ||
window.addEvent('domready', callback); | ||
</script> | ||
</body> | ||
</html> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /> | ||
<title>DOMReady added when page is already loaded</title> | ||
|
||
<script src="mootoolsPath.js" type="text/javascript"></script> | ||
</head> | ||
<body> | ||
|
||
<script> | ||
function callback(){ | ||
window.callbackFired = true; | ||
} | ||
|
||
window.callbackFired = false; | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
"use strict"; | ||
|
||
var fs = require('fs'); | ||
var path = require('path'); | ||
var http = require('http'); | ||
|
||
module.exports = function(build){ | ||
|
||
var getFileContent = function(url, callback){ | ||
fs.readFile(url, 'utf-8', function (err, content) { | ||
if (err) return console.log(err); | ||
content = content.replace('mootoolsPath', '/base/mootools-' + build); | ||
callback(content); | ||
}); | ||
} | ||
|
||
http.createServer(function(req, res){ | ||
if (req.url.indexOf('~') != -1){ // multiple files to send as chunks | ||
var partials = req.url.split('~'); | ||
partials.push(null); // res.end() | ||
res.writeHead(200, {'Content-Type': 'text/html'}); | ||
partials.forEach(function(file, i){ | ||
setTimeout(function(){ | ||
if (!file) res.end('</html>'); | ||
else getFileContent(path.join(__dirname, '/DOMReady/', file), function(data){ | ||
res.write(data); | ||
}); | ||
}, 2000 * i + 1); | ||
}) | ||
} else { // single files | ||
getFileContent(path.join(__dirname, '/DOMReady/', req.url), function(data){ | ||
res.end(data); | ||
}); | ||
} | ||
}).listen(9000); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters