/gist:e0f3fa72828134c83f69 Secret
Created
December 14, 2010 23:45
-
-
Save tbeseda/e0f3fa72828134c83f69 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 it yo! | |
$.extend( { | |
updateBlock = { | |
defaults: { | |
round: false | |
}, | |
init: function(url, options, callback){ | |
options = $.extend({}, $.updateBlock.defaults, options || {}); | |
$.get(url, function(data, these_options){ | |
var r = data.output; // r for record | |
for (var key in r) { | |
if (r.hasOwnProperty(key)) { | |
if( typeof r[key] == 'object' ) { // units and values | |
if( $.updateBlock.options.round ) | |
round($( '#' + key ).text( quantity(r[key])),1); | |
else | |
$( '#' + key ).text( quantity(r[key])); | |
} // if | |
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, data); | |
}); // get | |
} | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment