Last active
August 29, 2015 14:25
-
-
Save gffcoutinho/44646872a54c07506bfe to your computer and use it in GitHub Desktop.
Javascript Cookbook
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
(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 = 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);} | |
})(); | |
(function() { | |
console = { | |
log: function(s) { | |
WScript.StdOut.Write(s); | |
} | |
} | |
}()); | |
var n1 = 10; | |
var n2 = 16; | |
var id1 = setInterval(function() {if(n1--) WScript.Echo('interval ----'); else clearInterval(id1);}, 500); | |
var id2 = setInterval(function() {if(n2--) console.log('interval --\n'); else clearInterval(id2);}, 1000); | |
clearInterval(id1); | |
clearInterval(id2); | |
var st_id01 = setTimeout(function() {console.log('timeout --\n');}, 3000); | |
while(n1 || n2){ | |
WScript.Sleep(100); | |
} |
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
WScript.StdOut.Write('\e[1;31m'+'teste da estrela'+String.fromCharCode(27)+'[0m\n'); | |
WScript.StdOut.Write(String.fromCharCode(27)+'[1;32m'+'teste da estrela'+String.fromCharCode(27)+'[0m\n'); | |
WScript.StdOut.Write(String.fromCharCode(27)+'[1;33m'+'teste da estrela'+String.fromCharCode(27)+'[0m\n'); | |
WScript.StdOut.Write(String.fromCharCode(27)+'[1;37m'+'teste da estrela'+String.fromCharCode(27)+'[0m\n'); | |
var time = 125; | |
while(true) { | |
WScript.StdOut.Write('\b-'); | |
WScript.Sleep(time); | |
WScript.StdOut.Write('\b\\'); | |
WScript.Sleep(time); | |
WScript.StdOut.Write('\b|'); | |
WScript.Sleep(time); | |
WScript.StdOut.Write('\b/'); | |
WScript.Sleep(time); | |
WScript.StdOut.Write('\b-'); | |
WScript.Sleep(time); | |
WScript.StdOut.Write('\b\\'); | |
WScript.Sleep(time); | |
WScript.StdOut.Write('\b|'); | |
WScript.Sleep(time); | |
WScript.StdOut.Write('\b/'); | |
WScript.Sleep(time); | |
// break; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment