This file contains hidden or 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
// Simple JavaScript Templating | |
// John Resig - http://ejohn.org/ - MIT Licensed | |
(function(){ | |
var cache = {}; | |
this.tmpl = function tmpl(str, data){ | |
// Figure out if we're getting a template, or if we need to | |
// load the template - and be sure to cache the result. | |
var fn = !/\W/.test(str) ? | |
cache[str] = cache[str] || |
This file contains hidden or 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
//register a *simple* html renderer | |
app.register( '.html', { | |
compile: function( str, options ){ | |
return function( locals ){ | |
return str; | |
} | |
} | |
}); |
This file contains hidden or 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
//deps | |
var mongoose = require( 'mongoose' ); | |
var Schema = mongoose.Schema; | |
var ObjectId = mongoose.Schema.ObjectId; | |
//config | |
var mongo = require( './../conf.js' ).mongo ; | |
mongo.database = 'learn'; | |
//connect to mongo |
This file contains hidden or 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 newDefered = function(){ | |
var state = 0 ; // 0 - unresolved, 1 - resolved, 2 - rejected | |
var resolveCallbacks = [] ; | |
var resolveArgs = [] ; | |
var rejectCallbacks = [] ; | |
var rejectArgs = [] ; | |
var execute = function( callbacks, args ){ | |
while( callbacks.length !== 0 ){ | |
callbacks.shift().call( {}, args ) ; |
This file contains hidden or 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
// js barrier, waits for all events to be fired before executing the callback | |
// dependencies: | |
// 1. jquery 1.4.2+ - jquery.com | |
// 2. ben alman's tiny jquery pub/sub - https://gist.github.com/661855 | |
(function($){ | |
$.barrier = function( evs , callback ){ | |
var events = evs.split(' ') ; | |
var flags = {} ; | |
var collector = {} ; | |
$.each( events , function( i, ev ){ |
This file contains hidden or 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> | |
<title> host </title> | |
<meta charset="utf-8"> | |
<div id="container">host.html</div> | |
<script src="jquery-1.6.1.js"></script> | |
<script src="jquery.tinypubsub.js"></script> | |
<script src="postmessage.js"></script> | |
<script src="xPubSub.js"></script> | |
<script> | |
NewerOlder