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 gesture = { | |
delta: { | |
X: 0, | |
Y: 0, | |
T: 0 | |
}, | |
start: { | |
X: 0, | |
Y: 0, | |
T: 0, |
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
Exiting the dark ages of strongly coupled templating. | |
Remember "Classic ASP" or "Java Beans"? they never really understood the concept of the DOM. | |
They chose to ignore it and just stub in some placeholders like <%=myVariable%> for server | |
generated content then just rewrite the file. | |
These days, not much has changed, there are lots of templating engines. I think choosing a | |
templating engine with JS these days is like choosing between a fast car and a fast car. IMHO, | |
the most important thing to look at is the concept, not the performance. Sure you could go to | |
JSPerf and test how many milliseconds of difference there is between their compile times. But |
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
<html> | |
<head> | |
<style> | |
#products { | |
display: -webkit-box; | |
-webkit-box-orient: horizontal; | |
} | |
#products p { | |
display: -moz-inline-box; | |
-moz-box-orient: vertical; |
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 issues = (function() { | |
var o = { | |
"Array.prototype": "forEach map reduce reduceRight filter every some indexOf lastIndexOf", | |
"Array": "isArray", | |
"Object": "keys preventExtensions isExtensible getOwnPropertyDescriptor defineProperty getOwnPropertyNames create seal isSealed freeze isFrozen" | |
}; | |
for(var l in o) { | |
o[l] = o[l].split(" "); | |
for(var f=0; f<o[l].length; f++) { |
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
if (!Array.prototype.indexOf) { | |
Array.prototype.indexOf = function(s) { | |
var len = this.length; | |
while(len--) { | |
if (this[len] === s) { | |
return len; | |
} | |
} | |
return -1; |
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 router = SS.router({ | |
'foo/?([a-zA-Z0-9_\-]+)?': { // if the route 'foo/whatever' is matched... | |
'1': { // the first capture group | |
'bar': { // a potential value | |
on: ["barFunc"], // list of methods to fire on match | |
once: ["barOnce"], // optional, once only this route | |
state: { "someNumber": 100 } // optional, some data | |
} |
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
Array.diff = function(left, right) | |
{ | |
var o = left; | |
var n = right; | |
var ns = {}; | |
var os = {}; | |
for (var i = 0; i < n.length; i++) { | |
if (ns[n[i]] == null) |
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 uA=navigator.userAgent.toLowerCase(); | |
var version=((uA.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[])[1]||"").split("."); |
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 d = { foo: [{ /* ... */ }], bla: 123123 }; | |
{ | |
".name[foo]": { "foo": "bla" }, | |
".foo": "/foo.html", | |
".bazz": { | |
data: d.foo, | |
map: function(node, data) { | |
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
$(".content").weld( | |
{ | |
some : "data", | |
user : "tmpvar" | |
}, | |
{ | |
map : function(key, value) { | |
$(this).attr("foo", value); // key is null if it is an array. | |
}, | |
method : "append" // defines what action the insert method should do. |