Skip to content

Instantly share code, notes, and snippets.

View radius's full-sized avatar

darius daftary radius

View GitHub Profile
@radius
radius / urlparams.js
Created July 30, 2012 16:08
Get URL Query String Parameters with Javascript
var urlParams = (function () {
var _params={},
e,
a = /\+/g, // Regex for replacing addition symbol with a space
r = /([^&=]+)=?([^&]*)/g,
d = function (s) { return decodeURIComponent(s.replace(a, " ")); },
q = window.location.search.substring(1);
while (e = r.exec(q)) {
_params[d(e[1])] = d(e[2]);
@radius
radius / inputPlaceholder.jquery.js
Created May 16, 2012 15:30
Input Placeholder jQuery Plugin
$.fn.inputPlaceholder = function(options){
return $(this).each(function() {
var options = jQuery.extend({
text: $(this).attr('placeholder')
},options);
if($(this).val() == '') {
$(this).val(options.text);
}
$(this)
@radius
radius / Logger.js
Created February 10, 2012 02:08
Little JS logger class
var Logger = (function() {
return {
active: true,
post: false,
log: function(obj, type) {
if(Logger.active) {
console.log(obj);
}
if(Logger.post) {
$.post(Logger.post, {