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
// for detailed comments and demo, see my SO answer here http://stackoverflow.com/questions/8853396/logical-operator-in-a-handlebars-js-if-conditional/21915381#21915381 | |
/* a helper to execute an IF statement with any expression | |
USAGE: | |
-- Yes you NEED to properly escape the string literals, or just alternate single and double quotes | |
-- to access any global function or property you should use window.functionName() instead of just functionName() | |
-- this example assumes you passed this context to your handlebars template( {name: 'Sam', age: '20' } ), notice age is a string, just for so I can demo parseInt later | |
<p> | |
{{#xif " name == 'Sam' && age === '12' " }} | |
BOOM |
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 () { | |
WebSocket.prototype._send = WebSocket.prototype.send; | |
WebSocket.prototype.send = function (data) { | |
this._send(data); | |
this.addEventListener('message', function (msg) { | |
console.log('>> ' + msg.data); | |
}, false); | |
this.send = function (data) { | |
this._send(data); | |
console.log("<< " + data); |