cloudstack 3.0 UI - fix a JS error "str.replace is undefined".

This commit is contained in:
Jessica Wang 2012-03-14 14:36:44 -07:00
parent 4b4cba10c7
commit c4c68e2995
3 changed files with 20 additions and 6 deletions

View File

@ -1645,7 +1645,7 @@
var jsonObj = args.context.instances[0]; var jsonObj = args.context.instances[0];
args.response.success({ args.response.success({
data: { data: {
totalCPU: _s(jsonObj.cpunumber) + " x " + cloudStack.converters.convertHz(jsonObj.cpuspeed), totalCPU: jsonObj.cpunumber + " x " + cloudStack.converters.convertHz(jsonObj.cpuspeed),
cpuused: jsonObj.cpuused, cpuused: jsonObj.cpuused,
networkkbsread: (jsonObj.networkkbsread == null || jsonObj.networkkbsread == 0)? "N/A": cloudStack.converters.convertBytes(jsonObj.networkkbsread * 1024), networkkbsread: (jsonObj.networkkbsread == null || jsonObj.networkkbsread == 0)? "N/A": cloudStack.converters.convertBytes(jsonObj.networkkbsread * 1024),
networkkbswrite: (jsonObj.networkkbswrite == null || jsonObj.networkkbswrite == 0)? "N/A": cloudStack.converters.convertBytes(jsonObj.networkkbswrite * 1024) networkkbswrite: (jsonObj.networkkbswrite == null || jsonObj.networkkbswrite == 0)? "N/A": cloudStack.converters.convertBytes(jsonObj.networkkbswrite * 1024)

View File

@ -5695,7 +5695,7 @@
var jsonObj = args.context.hosts[0]; var jsonObj = args.context.hosts[0];
args.response.success({ args.response.success({
data: { data: {
totalCPU: _s(jsonObj.cpunumber) + " x " + cloudStack.converters.convertHz(jsonObj.cpuspeed), totalCPU: jsonObj.cpunumber + " x " + cloudStack.converters.convertHz(jsonObj.cpuspeed),
cpuused: jsonObj.cpuused, cpuused: jsonObj.cpuused,
cpuallocated: (jsonObj.cpuallocated == null || jsonObj.cpuallocated == 0)? "N/A": jsonObj.cpuallocated, cpuallocated: (jsonObj.cpuallocated == null || jsonObj.cpuallocated == 0)? "N/A": jsonObj.cpuallocated,
memorytotal: (jsonObj.memorytotal == null || jsonObj.memorytotal == 0)? "N/A": cloudStack.converters.convertBytes(jsonObj.memorytotal * 1024), memorytotal: (jsonObj.memorytotal == null || jsonObj.memorytotal == 0)? "N/A": cloudStack.converters.convertBytes(jsonObj.memorytotal * 1024),

View File

@ -60,10 +60,24 @@
* *
* Strip unwanted characters from user-based input * Strip unwanted characters from user-based input
*/ */
cloudStack.sanitize = window._s = function(str) { cloudStack.sanitize = window._s = function(value) {
if (!str) return ''; if(typeof(value) == "number") {
//alert("number does not need to be sanitized. Only string needs to be sanitized.");
var sanitized = str return value;
}
else if(typeof(value) == "boolean") {
//alert("boolean does not need to be sanitized. Only string needs to be sanitized.");
return value;
}
else if(typeof(value) == "object") {
//alert("object cant not be sanitized. Only string can be sanitized.");
return value;
}
else if(typeof(value) == null || typeof(value) == "undefined") {
return '';
}
var sanitized = value
.replace(/&/g, "&") .replace(/&/g, "&")
.replace(/</g, "&lt;") .replace(/</g, "&lt;")
.replace(/>/g, "&gt;"); .replace(/>/g, "&gt;");