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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>LABjs Demo</title> | |
<script src="/js/queue.LAB.js"></script> | |
<script> | |
// adding `false` in the queue will signifiy an empty .wait() in the $LAB chain | |
$LAB.queue("http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js", false); | |
$LAB.queue("http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/jquery-ui.min.js", false); |
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
// stripped down version just detecting IE | |
(function(global){ | |
global._isIE = false; | |
try { | |
var div = document.createElement("div"); | |
div.innerHTML = "<!--[if IE]><i></i><![endif]-->"; | |
global._isIE = (div.getElementsByTagName("i").length > 0); | |
} catch(err) { } | |
})(window); |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>LABjs Demo</title> | |
</head> | |
<body> | |
<!-- some stuff --> | |
<script src="/js/LAB.js"></script> |
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
/*! LAB.js v1.0.3 (c) Kyle Simpson MIT License */ | |
/* INCLUDE THE MINIFIED LAB.js CODE HERE */ | |
$LAB | |
.script('https:'==document.location.protocol?'https://ssl':'http://www')+'.google-analytics.com/ga.js') | |
.wait(function(){ | |
var scripts = document.getElementsByTagName("script"), | |
src, i, len, | |
acct = "UA-XXXXX-X", |
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
//SUMMARY: | |
// a() @ b() ==> execute a(). if a() flags an async deferral inside it, | |
// then wait to continue execution of the expression until that promise is | |
// fulfilled, then continue execution *AT* b(). | |
// | |
// more generally: X @ Y ==> evaluate X expression. if it was a function call | |
// call that deferred with a promise, wait until fulfilled then continue at | |
// Y. otherwise, assume that X had an implicit immediately fulfilled promise, | |
// and continue evaluating at Y. | |
// ------ |
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
In "Safari 5.0.1" on Win7: | |
> console.log(navigator.userAgent); | |
Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.18.1 (KHTML, like Gecko) Version/5.0.1 Safari/533.17.8 | |
In "Webkit Nightly r74232" on Win7: | |
> console.log(navigator.userAgent); |
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
v8::HandleScope handle_scope; | |
v8::Context::Scope scope(my_context); | |
v8::Handle<v8::Function> func1; | |
{ | |
v8::TryCatch try_catch; | |
v8::Handle<v8::Script> func1_script = v8::Script::Compile(v8::String::New("func1"), v8::String::New("inline::code")); | |
v8::Handle<v8::Value> func1_res = func1_script->Run(); | |
func1 = v8::Handle<v8::Function>::Cast(func1_res); | |
} |
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 A() {} | |
var a = new A(); | |
function B() { | |
function F(){} | |
F.prototype = a; | |
return new F(); | |
} | |
var b = new B(); // `b` now inherits from `a` (*not* `A`) |
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 foo() { | |
// ... | |
nonExistent(); | |
// | |
} | |
function bar() { | |
try { | |
foo(); | |
} |
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
var function_sandbox = (function(global) { | |
function SubFunc(func) { | |
func.__proto__ = funcPlugin; | |
return func; | |
} | |
var funcPlugin, __Function = global.Function; | |
// make prototype values conform to ECMA spec and inherit from regular natives | |
(SubFunc.prototype = new __Function('')).__proto__ = __Function.prototype; |