Skip to content

Instantly share code, notes, and snippets.

@dkordik
dkordik / autosave.js
Created June 28, 2011 20:52
Automatically save and repopulate input values across the current session using sessionStorage
(function ($) {
var $inputs = $("input"); //left as generic 'input' to acct for html5y types.
$inputs.each(function () {
if (this.value == '') {
this.value = sessionStorage["autosave-"+this.id];
}
})
$.fn.autosave = function () {
@dkordik
dkordik / .vimrc
Created June 14, 2011 21:00 — forked from roykolak/gist:1025131
VIM config
syntax on
set tabstop=2 softtabstop=2 shiftwidth=2 expandtab smarttab
set number
set nofoldenable
set showmatch
set hlsearch
set vb
set smartindent
set nocompatible
set backspace=indent,eol,start
@dkordik
dkordik / gist:843229
Created February 25, 2011 01:00
From an iframe, use the parent document's jQuery
/*
Lets hope you never have to do this, but if you're in an iframe that needs to use jQuery,
and you don't want to load the file a separate time in the iframe, this will let you use
the parent page's copy of jQuery, while also giving you the correct scope for selectors
to work as expected.
This version is SOL if you want to still be able to set a sub-scope from the iframe.
*/
javascript:document.getElementById('ctl00_contentBody_btnVote').addEventListener('click', function(e) { document.cookie = 'Lots2Give_Votes=; expires=Thu, 01-Jan-70 00:00:01 GMT;'; if(window.voteCount==undefined){ window.voteCount=1; document.getElementById('info').getElementsByTagName("p")[2].getElementsByTagName("span")[0].innerHTML="Vote <i>unlimited</i> times per day!<br><span id='superCount' style='font-weight: bold; font-size: 12px; color:blue;'>You have voted 1 time.</span>"; } else { window.voteCount++;} document.getElementById('ctl00_contentBody_lblVoteMessage').innerHTML="Voting...";document.getElementById('superCount').innerHTML="You have voted "+window.voteCount+" times. Nice!";}, false)