Minor sanity check fixes in functions - don't attempt to deep clone an object that might not exist, check for the existance of a native Array.swap before implementing our own, and properly check for jQuery support when displaying changes (ideally this'll be moved out anyway)

This commit is contained in:
Veno Server 2009-10-02 02:16:49 -05:00
parent f865073ea8
commit 30e385c55f

View file

@ -6,11 +6,13 @@
/* Define some basic prototypes that we'll require later.. */ /* Define some basic prototypes that we'll require later.. */
Array.prototype.swap = function(a, b) { if(!Array.prototype.swap) {
Array.prototype.swap = function(a, b) {
var tmp = this[a]; var tmp = this[a];
this[a] = this[b]; this[a] = this[b];
this[b] = tmp; this[b] = tmp;
return true; /* For the sake of being complete */ return true; /* For the sake of being complete */
}
} }
/* allows numeric sorting for built in js sort */ /* allows numeric sorting for built in js sort */
@ -42,6 +44,7 @@ var franz = {
}, },
clone: function(obj) { clone: function(obj) {
if(typeof obj !== "undefined") {
/* Recursively iterate through objects and clone them (Don't even try to put this on the Object prototype (recursion fail)) */ /* Recursively iterate through objects and clone them (Don't even try to put this on the Object prototype (recursion fail)) */
var returnObj = (obj instanceof Array) ? [] : {}; var returnObj = (obj instanceof Array) ? [] : {};
@ -55,6 +58,7 @@ var franz = {
} }
return returnObj; return returnObj;
}
}, },
loadImg: function(img_src) { loadImg: function(img_src) {
@ -169,7 +173,7 @@ var franz = {
} }
document.getElementById("log_colors").innerHTML = docStr; document.getElementById("log_colors").innerHTML = docStr;
if(typeof jQuery != "undefined") { if(typeof jQuery !== "undefined") {
$("#container_bottom").fadeIn("fast"); $("#container_bottom").fadeIn("fast");
setTimeout(function() { $("#testLayout").fadeIn("slow"); }, 500); setTimeout(function() { $("#testLayout").fadeIn("slow"); }, 500);
} }