Skip to content

Instantly share code, notes, and snippets.

@williammalo
williammalo / README.md
Last active October 5, 2015 14:27 — forked from 140bytes/LICENSE.txt
jQuery .html() clone

jQuery .html() clone

A (Hopefully) perfect clone of the jQuery .html() method

If it has an argument, it will set the innerhtml of the element to the value of the argument.

If it has no argument, it returns the innerHTML of the element.

It is also chainable! yay!

@williammalo
williammalo / README.md
Last active October 5, 2015 17:48 — forked from 140bytes/LICENSE.txt
element methods on nodelists

This function allows element methods to be used on nodelists, kinda like what jQuery does.

@williammalo
williammalo / README.md
Last active October 5, 2015 17:48 — forked from 140bytes/LICENSE.txt
element coercion

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

@williammalo
williammalo / README.md
Last active October 5, 2015 19:07 — forked from 140bytes/LICENSE.txt
blockifyIndents

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:

@williammalo
williammalo / Description.md
Created June 19, 2012 19:22
Javascript Rss Reader

#Javascript Rss Reader#

Takes a rss feed and prints html (defined by a template) for every post.

@williammalo
williammalo / README.md
Last active October 6, 2015 09:58 — forked from 140bytes/LICENSE.txt
set element properties on nodelists

a neat function that allows this:

document.getElementsByTagName('i').innerHTML="pie";

and it will change the innerHTML of all tags AUTOMATICALLY!!!!

incredible!

demo: http://jsfiddle.net/Vw54L/

@williammalo
williammalo / calendar.js
Created June 25, 2012 23:10
Javascript Calendar Maker
//function
calendar = function(year,month,template,rowStart,rowEnd,cellStart,cellEnd){
var tmpl=function(a,b){return a.replace(/\{\{([^{}]+)}}/g,function(c,d){return typeof b[d]=="function"?b[d]():b[d]})}
return tmpl(template,{
monthName:"January,February,March,April,May,June,July,August,September,October,November,December".split(",")[month],
year:year,
days:function(f,txt,i){
@williammalo
williammalo / README.md
Last active October 6, 2015 14:18 — forked from 140bytes/LICENSE.txt
get offset of element

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

@williammalo
williammalo / README.md
Last active March 1, 2019 17:39 — forked from 140bytes/LICENSE.txt
Responsive image loading in 199bytes (minification help needed)

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:

@williammalo
williammalo / README.md
Last active October 7, 2015 01:48 — forked from 140bytes/LICENSE.txt
masonry under 140bytes

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.