forked from iamnoah/writeCapture
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
4 changed files
with
105 additions
and
3 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,42 @@ | ||
(function(global,wc) { | ||
function wcEvil(code) { | ||
wc.replaceWith(global.CJS.curScript,'<script>'+code+'</script>'); | ||
} | ||
|
||
function wcExt(src,cb) { | ||
// copied from control.js. be sure we support callbacks properly | ||
var fonload = ( function(ponload) { | ||
switch ( typeof(ponload) ) { | ||
case "string": | ||
ponload = new Function(ponload); | ||
break; | ||
case "function": | ||
// ponload is already a function | ||
break; | ||
default: | ||
ponload = new Function(); | ||
} | ||
return ponload; | ||
})(cb); | ||
wc.replaceWith(global.CJS.curScript,'<script src="'+src+'"> </script>',fonload); | ||
} | ||
|
||
global.__writeCapture_cjsSupport_setup = function() { | ||
// 2. replace CJS's eval and exec with our eval and exec | ||
global.CJS.eval = wcEvil; | ||
global.CJS.execScript = wcExt; | ||
}; | ||
|
||
// 1. add an inline CJS script to the top that calls setup | ||
// this should be the first script CJS evals | ||
var dummy = document.createElement('script'); | ||
var sib = document.getElementsByTagName('script')[0]; | ||
sib.parentNode.insertBefore(dummy, sib); | ||
wc.replaceWith(dummy,'<script type="text/cjs">__writeCapture_cjsSupport_setup();</script>'); | ||
|
||
if(global.writeCapture_cjsSrc) { | ||
var se = document.createElement('script'); | ||
se.src = global.writeCapture_cjsSrc; | ||
sib.parentNode.insertBefore(se, sib); | ||
} | ||
})(this,this.writeCapture); |
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,25 @@ | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" | ||
dir="ltr" id="html"> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | ||
<title>CJS Plugin Tests</title> | ||
<!-- | ||
<script type="text/javascript" src="../support/nolib-support.js"></script> | ||
<script src="../writeCapture.js" type="text/javascript" charset="utf-8"></script> | ||
<script src="../cjs.writeCapture.js" type="text/javascript" charset="utf-8"></script> | ||
--> | ||
</head> | ||
<body> | ||
|
||
<script type="text/cjs">function writeTimes() {}</script> | ||
<script type="text/cjs" data-cjssrc="http://stevesouders.com/controljs/examples/docwrite.js?sleep=2&jsdelay=2&t=1293390195"></script> | ||
<script>(function() { | ||
window.writeCapture_cjsSrc = 'http://controljs.googlecode.com/svn-history/trunk/control.js'; | ||
var script = document.createElement('script'); | ||
script.src = "../writeCapture-1.0.5-forCjs-min.js"; | ||
var sib = document.getElementsByTagName('script')[0]; | ||
sib.parentNode.insertBefore(script, sib); | ||
})();</script> | ||
</body> | ||
</html> |