-
-
Save mattn/263077 to your computer and use it in GitHub Desktop.
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
// Running JSDeferred on WSH | |
var _util = { | |
cat : function(f){ | |
if(f.match(/^http:/)) { | |
var xhr = new ActiveXObject("Microsoft.XMLHTTP"); | |
xhr.open("GET", f, false); | |
xhr.send(); | |
return xhr.responseText; | |
} | |
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( "http://github.com/cho45/jsdeferred/raw/master/jsdeferred.js" ) ); | |
// loading jQuery | |
eval( _util.cat( "http://code.jquery.com/jquery-latest.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