Skip to content

Instantly share code, notes, and snippets.

@fetimo
fetimo / endangered-species.json
Last active December 31, 2015 11:19
A JSON representation of endangered species in the UK. Includes common name, Latin name, description (usually location), IUCN conservation status code, and kingdom (although this isn't scientifically accurate).
{
"records": [
{
"common_name": "Bottlenose dolphin",
"latin_name": "Tursiops truncatus",
"description": "warm and temperate seas worldwide",
"conservation_status": "LC",
"kingdom": "mammal"
},
{
@fetimo
fetimo / Class Manipulation
Last active December 11, 2015 05:58
A simple collection of functions to add classes, remove classes, and toggle classes on elements.
var Class = (function() {
'use strict';
function addClass(el, className) {
/**
* Adds a string to the class name.
*
* @param {Node} el Any element
* @param {String} className The new class name to add
@fetimo
fetimo / localstorage-and-progress-meter.js
Created February 18, 2012 17:54
A quick way to attach a progress meter to checked inputs and store them locally
(function() {
var inputs = document.getElementsByTagName('input'),
j = inputs.length,
checkedBoxes = 0;
//adds click event listener to each input
for (var i = 0; i < j; i += 1) {
inputs[i].addEventListener("click", function(){changeState(this);});
if (inputs[i].checked == true) checkedBoxes += 1;
}