Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function dumpDictionary(data, keyval, valueval) {
- /// <summary>
- /// Renders a json dictionary and/or key value array into a ul list
- /// </summary>
- /// <param name="data" type="PlainObject">
- /// Object that contains the array of values to dump
- /// </param>
- /// <param name="keyval" type="PlainObject">
- /// Object that contains a function or the an item's property name
- /// </param>
- /// <param name="valueval" type="PlainObject">
- /// Object that contains a function or the an item's property name
- /// </param>
- /// <returns type="string" >
- /// The html list of provieded json data
- /// </returns>
- var items = [];
- items.push("<ul>");
- for (var i = 0; i < data.length; i++) {
- var item = data[i];
- var key,value;
- if (keyval != null) {
- if (typeof (keyval) === "function")
- key = keyval(item, i);
- else
- key = item[keyval];
- }
- if (valueval != null) {
- if (typeof (valueval) === "function")
- value = valueval(item,i);
- else
- value = item[valueval];
- }
- items.push('<li>' + key + " = " + value + '</li>');
- }
- items.push("</ul>");
- var html = items.join('');
- return html;
- }
- function dumpList(data, valueval) {
- /// <summary>
- /// Renders a json value array into a ul list
- /// </summary>
- /// <param name="data" type="PlainObject">
- /// Object that contains the array of values to dump
- /// </param>
- /// <param name="valueval" type="PlainObject">
- /// Object that contains a function or the an item's property name
- /// </param>
- /// <returns type="string" >
- /// The html list of provieded json data
- /// </returns>
- var items = [];
- items.push("<ul>");
- for (var i = 0; i < data.length; i++) {
- var item = data[i];
- var value;
- if (valueval != null) {
- if (typeof (valueval) === "function")
- value = valueval(item,i);
- else
- value = item[valueval];
- }
- items.push('<li>' + value + '</li>');
- }
- items.push("</ul>");
- var html = items.join('');
- return html;
- }
Add Comment
Please, Sign In to add comment