Skip to content

Instantly share code, notes, and snippets.

@hasegawayosuke
Created December 24, 2009 03:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hasegawayosuke/262987 to your computer and use it in GitHub Desktop.
Save hasegawayosuke/262987 to your computer and use it in GitHub Desktop.
// Running JSDeferred on WSH
var _util = { cat : function(f){return (new ActiveXObject("Scripting.FileSystemObject")).OpenTextFile(f,1,false).ReadAll();} };
// fake window, fake document, and other global object
(function(){
if( typeof( document ) == "undefined" ){
document = new ActiveXObject( "htmlfile" );
document.write("<html></html>");
}
if( typeof( window ) == "undefined" ) window = document.parentWindow;
if( typeof( alert ) == "undefined" ) //alert = window.alert;
alert = function(s){ return window.alert( s )};
if( typeof( confirm ) == "undefined" ) confirm = function(s){ return window.confirm(s) };
if( typeof( location ) == "undefined" ) location = window.location;
if( typeof( navigator ) == "undefined" ) navigator = window.navigator;
if( typeof( clearInterval ) == "undefined" ) clearInterval = function(id){
return window.clearInterval( id );
};
if( typeof( clearTimeout ) == "undefined" ) clearTimeout = function(id){
return window.clearTimeout(id);
};
if( typeof( setInterval ) == "undefined" ) setInterval = function(code, interval){
return window.setInterval(code, interval);
}
if( typeof( setTimeout ) == "undefined" ) setTimeout = function(code, delay){
return window.setTimeout(code, delay);
}
})();
// loading JSDeferred
eval( _util.cat( "jsdeferred.js" ) );
// loading jQuery
eval( _util.cat( "jquery-1.3.2.js" ) );
(function(){
var complete = false;
Deferred.parallel([
func1,
func2
]).next( function(){ complete = true; } );
while( !complete ) WScript.Sleep( 10 );
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment