From f5ebc510f2e5be2d1a16464f19ba6230bf7f4e5f Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Mon, 16 May 2011 14:01:07 +0200 Subject: [PATCH] Bug #645: Iterate on arrays with vanilla loops. For...in loops on Arrays were changed in to for(i = 0, i' - } - colored_log += line + "\n"; + if (line.match(/\[E\]/)){ + line = ''+line+''; } + colored_log += line + "\n"; } + var log_tab = { title: "VM log", content: '
'+colored_log+'
' diff --git a/src/sunstone/public/js/plugins/vnets-tab.js b/src/sunstone/public/js/plugins/vnets-tab.js index 927461c1e1..e5a66e37c6 100644 --- a/src/sunstone/public/js/plugins/vnets-tab.js +++ b/src/sunstone/public/js/plugins/vnets-tab.js @@ -381,7 +381,7 @@ function updateVNetworkInfo(request,vn){ \ Leases information\ '+ - prettyPrintJSON(vn_info.LEASES)+ + prettyPrintJSON(vn_info.LEASES.LEASE)+ ''; } diff --git a/src/sunstone/public/js/sunstone-util.js b/src/sunstone/public/js/sunstone-util.js index 5e2ba6d22b..44f51a0c99 100644 --- a/src/sunstone/public/js/sunstone-util.js +++ b/src/sunstone/public/js/sunstone-util.js @@ -198,59 +198,75 @@ function notifyMessage(msg){ // It recursively explores objects function prettyPrintJSON(template_json,padding,weight, border_bottom,padding_top_bottom){ var str = "" + if (!template_json){ return "Not defined";} if (!padding) {padding=0}; if (!weight) {weight="bold";} if (!border_bottom) {border_bottom = "1px solid #CCCCCC";} if (!padding_top_bottom) {padding_top_bottom=6;} + var field = null; - for (field in template_json) { - if (typeof template_json[field] == 'object'){ - //name of field row - str += '\ - ' - +field+ - '\ - \ - \ - '; - //attributes rows - //empty row - prettyprint - empty row - str += '\ - \ - \ - ' + - prettyPrintJSON(template_json[field],padding+25,"normal","0",1) + - '\ - \ - \ - '; - } else { - str += '\ - '+ - field+ - '\ - '+ - template_json[field]+ - '\ + if (template_json.constructor == Array){ + for (field = 0; field < template_json.length; ++field){ + str += prettyPrintRowJSON(field,template_json[field],padding,weight, border_bottom,padding_top_bottom); + } + } else { + for (field in template_json) { + str += prettyPrintRowJSON(field,template_json[field],padding,weight, border_bottom,padding_top_bottom); + } + } + return str; +} + +function prettyPrintRowJSON(field,value,padding,weight, border_bottom,padding_top_bottom){ + var str=""; + + if (typeof value == 'object'){ + //name of field row + str += '\ + ' + +field+ + '\ + \ + \ '; - }; + //attributes rows + //empty row - prettyprint - empty row + str += '\ + \ + \ + ' + + prettyPrintJSON(value,padding+25,"normal","0",1) + + '\ + \ + \ + '; + } else { + str += '\ + '+ + field+ + '\ + '+ + value+ + '\ + '; }; + return str; } @@ -336,7 +352,7 @@ function onError(request,error_json) { var value; rows = ["method","action","object","id","reason"]; message = ""; - for (i in rows){ + for (i = 0; i