Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…912cdd6b-5c7d-d5a7-a2ba-d0f0cdb91641
  • Loading branch information
thexerteproject committed Jul 26, 2013
1 parent 8a44458 commit 2992982
Showing 1 changed file with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1318,17 +1318,25 @@ function x_getSWFRef(swfID) {
function x_sortInitObject(initObj) {
var initObject;
if (initObj != undefined && initObj != "") {
if (initObj.substring(0,1) == "{") { // object - just doing eval or parseJSON won't work
var temp = initObj.replace("{", "").replace("}", "").split(","),
initObject = new Object();
for (var i=0, len=temp.length; i<len; i++) {
initObject[$.trim(temp[i].split(":")[0])] = eval($.trim(temp[i].split(":")[1]));
if (initObj.substring(0,1) == "{") { // object - just doing eval or parseJSON won't work.


//add try ... ...catch to try the JSON parser first, which will work with valid JSON strings, else fallback to Fay's method if an error occurs.
try {
initObject = $.parseJSON(initObj);
}
} else {
initObject = initObj;
}
catch(e){
var temp = initObj.replace("{", "").replace("}", "").split(","),
initObject = new Object();
for (var i=0; i<temp.length; i++) {
initObject[$.trim(temp[i].split(":")[0])] = eval($.trim(temp[i].split(":")[1]));
}
}

} else {

initObject = undefined;

}
return initObject;
}
Expand Down

0 comments on commit 2992982

Please sign in to comment.