Created
December 8, 2010 23:33
-
-
Save pjhoberman/734111 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
$.extend( { | |
updateBlock: function(url, options, callback){ | |
// this stuff isn't needed right now, but it's for adding options | |
$.updateBlock.defaults = { | |
//formatDate: [] // expects an array of ids to format | |
}; // defaults | |
$.updateBlock.options = $.extend({}, $.updateBlock.defaults, options || {}); | |
$.get(url, function(data){ | |
var r = data.output; // r for record | |
for (var key in r) { | |
if (r.hasOwnProperty(key)) { | |
if( typeof r[key] == 'object' ) // units and values | |
$( '#' + key ).text( quantity(r[key])); | |
else | |
{ | |
if( r[key] == '' && typeof r[key] == 'string' ) // for blank strings | |
r[key] = '--'; | |
$( '#' + key ).text( r[key] ); | |
} // else | |
} // if | |
} // for | |
if( typeof callback == 'function' ) | |
callback.call(this); | |
}); // get | |
} | |
}); // extend |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
check out my fork https://gist.github.com/e0f3fa72828134c83f69