block by shawnbot bb167c3c33b36c52b162

bb167c3c33b36c52b162

Full Screen

Stateful Checkboxes

This quick little hack creates a global function named checkboxes() that uses [localStorage] to remember the state of checkboxes on the host page. Usage:

var boxes = checkboxes({
    // the checkbox selector (always prefixed with 'input[type=checkbox]')
    selector:   '.stateful',
    // the storage engine (only 'localStorage' is supported here)
    storage:    'localStorage',
    // the prefix for all storage keys
    namespace:  'stateful.checkboxes:' + location.pathname,
    // elements matching this selector will clear the checkboxes when clicked
    clear:      'button.stateful-clear'
});

index.html

checkboxes.js