This function allows element methods to be used on nodelists, kinda like what jQuery does.
Why?
Because why the hell not?
Allows you to use nodelist methods on strings!
It's kinda useless on it's own, but with https://gist.github.com/2847249 it's pretty fun =D
Turns indentation into {curly brackets} Great for a yml to json converter or something. Credit to @maettig for writing all* the code.
Turn this:
if(3==3)
alert("obviously!")
alert("lol!")
Into:
a neat function that allows this:
document.getElementsByTagName('i').innerHTML="pie";
and it will change the innerHTML of all tags AUTOMATICALLY!!!!
incredible!
recursively checks every parent of the element to get the ABSOLUTE offset of the element.
call it like this:
getOff(element).x
getOff(element).y
This function loops through all images on the page, and serves the appropriately sized image file from a list in a data attribute.
example link: http://total.maloweb.com/responsive
example html:
<img src="default.png" data-widths="400,600,800,1023" data-srcsuffix="-foo.png">
example javascript:
A minimalist masonry function
mason(containerElement,brickElement,brickWidth,brickHeight)
Only works with one size of brick.
The only advantage of using this over using inline-block elements is that you can use css transitions.
converts canvas image data to a 2d array of booleans
array=img2array(imagedata,width,height)
array[x][y] //gives true or false
very useful for games where you need pixel perfect collision.
Reading an image every time you check for collision is slow. Using a 2d array makes it much faster, and has a very simple syntax (array[x][y]) .
##Object Merger
Recurcively merges two objects.
merge(
{foo:"foo"},
{bar:{lol:"lol"}}
);