Created
February 9, 2011 22:05
-
-
Save pjhoberman/819410 to your computer and use it in GitHub Desktop.
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
// ajax to html what what | |
$.extend( { | |
updateBlock: function(url, options, callback){ | |
var defaults = { | |
round:false | |
}; // defaults | |
options = $.extend({}, defaults, options || {}); | |
$.getJSON(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( 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] = '--'; | |
if( options.round ) | |
round( $( '#' + key ).text( r[key] ), 1 ); | |
else | |
$( '#' + key ).text( r[key] ); | |
} // else | |
} // if | |
} // for | |
if( typeof callback == 'function' ) | |
callback.call(this, data); | |
}); // get | |
}, | |
completelyDifferentFunction: function( other, options, entirely){ | |
} | |
}); // extend |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment