From 5aa70deae776d0b71ff026bfdc509a98638d0374 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Tue, 7 Sep 2010 11:24:46 -0700 Subject: [PATCH] new UI - add a shared function fromdb() --- ui/new/scripts/cloud.core.account.js | 4 ++-- ui/new/scripts/cloud.core.event.js | 6 +++--- ui/new/scripts/cloud.core.instance.js | 16 ++++++++-------- ui/new/scripts/cloud.core.js | 14 +++++++++++--- ui/new/scripts/cloud.core.snapshot.js | 8 ++++---- ui/new/scripts/cloud.core.volume.js | 10 +++++----- 6 files changed, 33 insertions(+), 25 deletions(-) diff --git a/ui/new/scripts/cloud.core.account.js b/ui/new/scripts/cloud.core.account.js index ed4475d3af1..6438c247731 100644 --- a/ui/new/scripts/cloud.core.account.js +++ b/ui/new/scripts/cloud.core.account.js @@ -2,8 +2,8 @@ function loadAccountToRigntPanelFn($rightPanelContent) { var jsonObj = $rightPanelContent.data("jsonObj"); var $rightPanelContent = $("#right_panel_content"); $rightPanelContent.find("#role").text(toRole(jsonObj.accounttype)); - $rightPanelContent.find("#account").text(jsonObj.name); - $rightPanelContent.find("#domain").text(jsonObj.domain); + $rightPanelContent.find("#account").text(fromdb(jsonObj.name)); + $rightPanelContent.find("#domain").text(fromdb(jsonObj.domain)); $rightPanelContent.find("#vm_total").text(jsonObj.vmtotal); $rightPanelContent.find("#ip_total").text(jsonObj.iptotal); $rightPanelContent.find("#bytes_received").text(jsonObj.receivedbytes); diff --git a/ui/new/scripts/cloud.core.event.js b/ui/new/scripts/cloud.core.event.js index ca70c3b3096..72c54960e9c 100644 --- a/ui/new/scripts/cloud.core.event.js +++ b/ui/new/scripts/cloud.core.event.js @@ -1,11 +1,11 @@ function loadEventToRigntPanelFn($rightPanelContent) { var jsonObj = $rightPanelContent.data("jsonObj"); var $rightPanelContent = $("#right_panel_content"); - $rightPanelContent.find("#username").text(jsonObj.username); - $rightPanelContent.find("#account").text(jsonObj.account); + $rightPanelContent.find("#username").text(fromdb(jsonObj.username)); + $rightPanelContent.find("#account").text(fromdb(jsonObj.account)); $rightPanelContent.find("#type").text(jsonObj.type); $rightPanelContent.find("#level").text(jsonObj.level); - $rightPanelContent.find("#description").text(jsonObj.description); + $rightPanelContent.find("#description").text(fromdb(jsonObj.description)); $rightPanelContent.find("#state").text(jsonObj.state); setDateField(jsonObj.created, $rightPanelContent.find("#created")); } \ No newline at end of file diff --git a/ui/new/scripts/cloud.core.instance.js b/ui/new/scripts/cloud.core.instance.js index 78ce2d97683..d44eb6bf51d 100755 --- a/ui/new/scripts/cloud.core.instance.js +++ b/ui/new/scripts/cloud.core.instance.js @@ -384,21 +384,21 @@ function clickInstanceGroupHeader($arrowIcon) { var jsonObj = $t.data("jsonObj"); var vmName = getVmName(jsonObj.name, jsonObj.displayname); - $rightPanelHeader.find("#vm_name").text(vmName); + $rightPanelHeader.find("#vm_name").text(fromdb(vmName)); updateVirtualMachineStateInRightPanel(jsonObj.state); $rightPanelContent.find("#ipAddress").text(jsonObj.ipaddress); - $rightPanelContent.find("#zoneName").text(jsonObj.zonename); - $rightPanelContent.find("#templateName").text(jsonObj.templatename); - $rightPanelContent.find("#serviceOfferingName").text(jsonObj.serviceofferingname); + $rightPanelContent.find("#zoneName").text(fromdb(jsonObj.zonename)); + $rightPanelContent.find("#templateName").text(fromdb(jsonObj.templatename)); + $rightPanelContent.find("#serviceOfferingName").text(fromdb(jsonObj.serviceofferingname)); if(jsonObj.haenable == "true") $rightPanelContent.find("#ha").removeClass("cross_icon").addClass("tick_icon").show(); else $rightPanelContent.find("#ha").removeClass("tick_icon").addClass("cross_icon").show(); $rightPanelContent.find("#created").text(jsonObj.created); - $rightPanelContent.find("#account").text(jsonObj.account); - $rightPanelContent.find("#domain").text(jsonObj.domain); - $rightPanelContent.find("#hostName").text(jsonObj.hostname); - $rightPanelContent.find("#group").text(jsonObj.group); + $rightPanelContent.find("#account").text(fromdb(jsonObj.account)); + $rightPanelContent.find("#domain").text(fromdb(jsonObj.domain)); + $rightPanelContent.find("#hostName").text(fromdb(jsonObj.hostname)); + $rightPanelContent.find("#group").text(fromdb(jsonObj.group)); if(jsonObj.isoid != null && jsonObj.isoid.length > 0) $rightPanelContent.find("#iso").removeClass("cross_icon").addClass("tick_icon").show(); else diff --git a/ui/new/scripts/cloud.core.js b/ui/new/scripts/cloud.core.js index d65d01b054a..c563805529c 100755 --- a/ui/new/scripts/cloud.core.js +++ b/ui/new/scripts/cloud.core.js @@ -165,6 +165,14 @@ function createURL(url) { return url +"&response=json&sessionkey=" + g_sessionKey; } +function fromdb(val) { + return sanitizeXSS(unescape(noNull(val))); +} + +function todb(val) { + return encodeURIComponent(escape(display)); +} + @@ -790,16 +798,16 @@ function sanitizeXSS(val) { function getVmName(p_vmName, p_vmDisplayname) { if(p_vmDisplayname == null) - return sanitizeXSS(p_vmName); + return sanitizeXSS(unescape(p_vmName)); var vmName = null; if (isAdmin()) { if (p_vmDisplayname != p_vmName) { - vmName = p_vmName + "(" + sanitizeXSS(p_vmDisplayname) + ")"; + vmName = p_vmName + "(" + sanitizeXSS(unescape(p_vmDisplayname)) + ")"; } else { vmName = p_vmName; } } else { - vmName = sanitizeXSS(p_vmDisplayname); + vmName = sanitizeXSS(unescape(p_vmDisplayname)); } return vmName; } diff --git a/ui/new/scripts/cloud.core.snapshot.js b/ui/new/scripts/cloud.core.snapshot.js index 279d38b0d95..c54a63d3b53 100644 --- a/ui/new/scripts/cloud.core.snapshot.js +++ b/ui/new/scripts/cloud.core.snapshot.js @@ -4,11 +4,11 @@ function loadSnapshotToRigntPanelFn($rightPanelContent) { var $rightPanelContent = $("#right_panel_content"); $rightPanelContent.find("#id").text(jsonObj.id); - $rightPanelContent.find("#name").text(jsonObj.name); - $rightPanelContent.find("#volume_name").text(jsonObj.volumename); + $rightPanelContent.find("#name").text(fromdb(jsonObj.name)); + $rightPanelContent.find("#volume_name").text(fromdb(jsonObj.volumename)); $rightPanelContent.find("#interval_type").text(jsonObj.intervaltype); - $rightPanelContent.find("#account").text(jsonObj.account); - $rightPanelContent.find("#domain").text(jsonObj.domain); + $rightPanelContent.find("#account").text(fromdb(jsonObj.account)); + $rightPanelContent.find("#domain").text(fromdb(jsonObj.domain)); setDateField(jsonObj.created, $rightPanelContent.find("#created")); } \ No newline at end of file diff --git a/ui/new/scripts/cloud.core.volume.js b/ui/new/scripts/cloud.core.volume.js index 1a5493427af..7324d6d3d04 100644 --- a/ui/new/scripts/cloud.core.volume.js +++ b/ui/new/scripts/cloud.core.volume.js @@ -4,14 +4,14 @@ function loadVolumeToRigntPanelFn($rightPanelContent) { var $rightPanelContent = $("#right_panel_content"); $rightPanelContent.find("#id").text(jsonObj.id); - $rightPanelContent.find("#name").text(jsonObj.name); - $rightPanelContent.find("#zonename").text(jsonObj.zonename); + $rightPanelContent.find("#name").text(fromdb(jsonObj.name)); + $rightPanelContent.find("#zonename").text(fromdb(jsonObj.zonename)); $rightPanelContent.find("#device_id").text(jsonObj.deviceid); $rightPanelContent.find("#state").text(jsonObj.state); - $rightPanelContent.find("#storage").text(jsonObj.storage); - $rightPanelContent.find("#account").text(jsonObj.account); + $rightPanelContent.find("#storage").text(fromdb(jsonObj.storage)); + $rightPanelContent.find("#account").text(fromdb(jsonObj.account)); - $rightPanelContent.find("#type").text(noNull(jsonObj.type) + " (" + noNull(jsonObj.storagetype) + " storage)"); + $rightPanelContent.find("#type").text(jsonObj.type + " (" + jsonObj.storagetype + " storage)"); $rightPanelContent.find("#size").text((jsonObj.size == "0") ? "" : convertBytes(jsonObj.size)); if (jsonObj.virtualmachineid == null)