This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getQueryString(key) | |
{ | |
var url = window.location.href, | |
pairs = url.slice(url.indexOf('?') + 1).split('&'), | |
qs = window.location.qs || {}, | |
kv; | |
if (! qs.cached){ | |
for (var i=0, l=pairs.length; i<l; i++){ | |
kv = pairs[i].split('='); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getFixed(mixed, precision) | |
{ | |
mixed = '' + mixed; | |
precision = precision || 2; | |
var matches = mixed.match(/\d+\.?\d+/), | |
amount = (matches && matches[0]) || null, | |
fixed = parseFloat(amount).toFixed(precision); | |
return parseFloat(fixed); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Number.prototype.asDollar = function() | |
{ | |
return "$" + this.toFixed(2); | |
} | |
Number.prototype.asDollarWithCommas = function() | |
{ | |
var as_str = this.toFixed(2), | |
matches = as_str.match(/\.\d+$/), | |
cents = (matches && matches[0]), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function obj2URL(obj, url) | |
{ | |
url = url || ''; | |
var parts = [], | |
push = function(key, val){ | |
parts.push(encodeURIComponent(key) + '=' + encodeURIComponent(val)); | |
}, | |
qs; | |
for (var key in obj) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function cursorToPosition(el, ndx) | |
{ | |
if (typeof el === 'string') { el = document.getElementById(el); } // DOM el or id | |
ndx = isNaN(ndx) ? el.value.length : parseInt(ndx); // end by default | |
if (el.setSelectionRange) { | |
el.focus(); | |
el.setSelectionRange(ndx, ndx); | |
} | |
else if (el.createTextRange) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery.fn.getListeners = function(typ) | |
{ | |
var $els = this, | |
cache = jQuery.cache, | |
aListeners = []; | |
function _handlersArray(typ, handlers) | |
{ | |
var arr = []; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* ns('foo.bar'); | |
* => window.foo = {bar: {} }; | |
* ns('some.arbitrary.depth.string'); | |
* => window.some = {arbitrary: {depth: {string: {} } }; | |
* ns('some.other.ns'); | |
* => window.some is already created, so window.some.other = {ns: {}}; | |
*/ | |
function ns( str, root ) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery.extend({ | |
obj2URL: function(obj, url) | |
{ | |
url = url || ''; | |
var qs = (/\?/.test(url) ? '&' : '?') + $.obj2kvs(obj); | |
return url + qs; | |
}, | |
obj2kvs: function(obj) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// jquery invert plugin | |
// by paul irish | |
// some (bad) code from this css color inverter | |
// http://plugins.jquery.com/project/invert-color | |
// some better code via Opera to inverse images via canvas | |
// http://dev.opera.com/articles/view/html-5-canvas-the-basics/#insertingimages | |
// and some imagesLoaded stuff from me | |
// http://gist.github.com/268257 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright (c) 2010 Tobias Schneider | |
* This script is freely distributable under the terms of the MIT license. | |
*/ | |
(function(){ | |
var UPC_SET = { | |
"3211": '0', | |
"2221": '1', | |
"2122": '2', |
OlderNewer