Skip to content

Instantly share code, notes, and snippets.

@lgedeon
lgedeon / pure js only toggle
Created May 7, 2014 14:23
toggle class by id on div without any other classes (maximum compatibility limited use case)
function namespace_divname_toggle(){
this.className=("active"==this.className.substr(0, 6))?"":"active";
}
document.querySelector('#divname').addEventListener('click', namespace_divname_toggle )
@lgedeon
lgedeon / time-range
Created July 27, 2013 02:37
partial time range solution
/**
* Returns a compact date range like March 27-29, 1977 from two unix time stamps. If $end is empty
* or less than start returns start only.
*
* @param int $start Unix timestamp
* @param int $end Unix timestamp
* @param string $round Least unit of time to include - supported values: day, hour, minute
* @param string $include Largest unit of time to include - supported values: year, month, hour
*
* Samples: