From e6d05a673dfde48f3f574a421c0e1c008068bfa7 Mon Sep 17 00:00:00 2001 From: jvalkeal Date: Sat, 31 Dec 2011 16:43:07 +0000 Subject: [PATCH] Array mods in layout structure. #47 --- dojo-release-1.5.0-src/hyperic/util/Util.js | 7 +++++++ dojo-release-1.5.0-src/hyperic/wallmount/Player.js | 13 ++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/dojo-release-1.5.0-src/hyperic/util/Util.js b/dojo-release-1.5.0-src/hyperic/util/Util.js index 6f543e1..78fe10a 100755 --- a/dojo-release-1.5.0-src/hyperic/util/Util.js +++ b/dojo-release-1.5.0-src/hyperic/util/Util.js @@ -36,3 +36,10 @@ hyperic.util.Util.zeroMinInsets = function(/*Object*/obj){ right: Math.max(obj.right,0) }; }; + +hyperic.util.Util.toArray = function(t){ + // summary: + // Converts object to array of size 1. If it's + // already an array, return it unmodified. + return dojo.isArray(t) ? t : [t]; +}; diff --git a/dojo-release-1.5.0-src/hyperic/wallmount/Player.js b/dojo-release-1.5.0-src/hyperic/wallmount/Player.js index dafad06..8cfc143 100755 --- a/dojo-release-1.5.0-src/hyperic/wallmount/Player.js +++ b/dojo-release-1.5.0-src/hyperic/wallmount/Player.js @@ -27,6 +27,7 @@ dojo.provide("hyperic.wallmount.Player"); dojo.require("hyperic.wallmount.WindowUtil"); +dojo.require("hyperic.util.Util"); dojo.require("hyperic.data.MetricStore"); hyperic.wallmount.Player.loadLayout = function(/*String*/url, /*Boolean*/ sendAnim, /*String*/node) { @@ -84,7 +85,11 @@ hyperic.wallmount.Player.createLayout = function(/*jsondata*/data, /*String*/nod dojo.style(wallmountPane,'width',data.w||9999); dojo.style(wallmountPane,'height',data.h||9999); - var items = data.items; + // items should be a list (items:[{},{}...] + // if it's an object, we assume list with one object + // -> make conversion + var items = hyperic.util.Util.toArray(data.items); + for(var i=0; i