Skip to content

Instantly share code, notes, and snippets.

@pjhoberman
Created December 7, 2010 20:39
Show Gist options
  • Save pjhoberman/732366 to your computer and use it in GitHub Desktop.
Save pjhoberman/732366 to your computer and use it in GitHub Desktop.
$.extend( {
updateBlock: function(url, options, callback){
$.updateBlock.defaults = {
formatDate: false
}; // defaults
$.updateBlock.options = $.extend({}, $.updateBlock.defaults, options || {});
console.log( $.updateBlock.options );
$.get(url, function(data){
var r = data.output; // r for record
for (var key in r) {
if (r.hasOwnProperty(key)) {
//console.log( key + ' - ' + typeof r[key] + ' - ' + r[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
@tbeseda
Copy link

tbeseda commented Dec 7, 2010

very nice. glad you're using "egyptian brackets" :P

@pjhoberman
Copy link
Author

And semicolons!;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment