cleanup and handle a bug when changing from normal text userdata to another field

This commit is contained in:
James B. Pollack 2016-08-24 14:49:41 -07:00
parent 45e3f926a1
commit 384c3dd543

View file

@ -333,11 +333,7 @@ function userDataChanger(groupName, keyName, checkBoxElement, userDataElement, d
var properties = {};
var parsedData = {};
try {
if ($('#userdata-editor').css('height') === "0px") {
parsedData = editor.getJSON();
} else {
parsedData = JSON.parse(userDataElement.value);
}
} catch (e) {}
if (!(groupName in parsedData)) {
@ -493,7 +489,10 @@ function bindAllNonJSONEditorElements() {
if (e.target.id === "userdata-new-editor" || e.target.id === "userdata-clear") {
return;
} else {
if ($('#userdata-editor').css('height') !== "0px") {
saveJSONUserData(true);
}
}
})
}
@ -843,11 +842,8 @@ function loaded() {
hideUserDataTextArea();
var json = null;
try {
json = JSON.parse(properties.userData)
//its json
if (Object.keys(json).length === 0 && json.constructor === Object) {
//it's an empty object
}
json = JSON.parse(properties.userData);
if (editor === null) {
createJSONEditor();
}