0001-Feature-622-Improved-template-representation-in-Suns.patch

Hector Sanjuan, 05/11/2011 03:37 PM

Download (2.68 KB)

View differences:

src/sunstone/public/css/application.css
384 384
	font-weight:bold;
385 385
}
386 386

  
387
.info_table td.key_td:after{
388
	content:":";
389
}
390

  
391 387
.info_table td.value_td{
392 388
	text-align:left;
393 389
}
src/sunstone/public/js/sunstone-util.js
189 189

  
190 190
// Returns an HTML string with the json keys and values in the form
191 191
// key: value<br />
192
// It recursively explores objects, and flattens their contents in
193
// the result.
194
function prettyPrintJSON(template_json){
195
	var str = ""
196
	for (field in template_json) {
197
		if (typeof template_json[field] == 'object'){
198
			str += prettyPrintJSON(template_json[field]) + '<tr><td></td><td></td></tr>';
199
		} else {
200
			str += '<tr><td class="key_td">'+field+'</td><td class="value_td">'+template_json[field]+'</td></tr>';
201
		};
202
	};
203
	return str;
192
// It recursively explores objects
193
function prettyPrintJSON(template_json,padding,weight, border_bottom){
194
    var str = ""
195
    if (!padding) {padding=0};
196
    if (!weight) {weight="bold";}
197
    if (!border_bottom) {border_bottom = "1px solid #CCCCCC";}
198

  
199
    for (field in template_json) {
200
        if (typeof template_json[field] == 'object'){
201
            str += '<tr><td class="key_td" style="padding-left:'+padding+'px;font-weight:'+weight+';border-bottom:'+border_bottom+'">'+field+'</td><td class="value_td" style="border-bottom:'+border_bottom+'"></td></tr>';
202
            str += prettyPrintJSON(template_json[field],padding+25,"normal","0") + '<tr><td class="key_td" style="padding-left:'+(padding+10)+'px"></td><td class="value_td"></td></tr>';
203
        } else {
204
            str += '<tr><td class="key_td" style="padding-left:'+padding+'px;font-weight:'+weight+';border-bottom:'+border_bottom+'">'+field+'</td><td class="value_td" style="border-bottom:'+border_bottom+'">'+template_json[field]+'</td></tr>';
205
        };
206
    };
207
    return str;
204 208
}
205 209

  
206 210
//Add a listener to the check-all box of a datatable, enabling it to
207
-