handle some more cases

This commit is contained in:
James B. Pollack 2016-08-25 16:03:12 -07:00
parent 8d5a896ccf
commit 9be073cc12
2 changed files with 37 additions and 17 deletions

View file

@ -1369,7 +1369,12 @@ var PropertiesTool = function (opts) {
});
webView.webEventReceived.connect(function (data) {
data = JSON.parse(data);
try{
data = JSON.parse(data);
}
catch(e){
return;
}
var i, properties, dY, diff, newPosition;
if (data.type === "print") {
if (data.message) {
@ -1418,7 +1423,8 @@ var PropertiesTool = function (opts) {
pushCommandForSelections();
selectionManager._update();
} else if(data.type === 'saveUserData'){
Entities.editEntity(data.id, data.properties)
var actualID = data.id.split('"')[1]
var success = Entities.editEntity(actualID, data.properties)
} else if (data.type === "showMarketplace") {
showMarketplace();
} else if (data.type === "action") {

View file

@ -333,7 +333,13 @@ function userDataChanger(groupName, keyName, checkBoxElement, userDataElement, d
var properties = {};
var parsedData = {};
try {
parsedData = JSON.parse(userDataElement.value);
if ($('#userdata-editor').css('height') !== "0px") {
//if there is an expanded, we want to use its json.
parsedData = getEditorJSON();
} else {
parsedData = JSON.parse(userDataElement.value);
}
} catch (e) {}
if (!(groupName in parsedData)) {
@ -441,7 +447,11 @@ function hideUserDataTextArea() {
function showStaticUserData() {
$('#static-userdata').show();
$('#static-userdata').css('height', $('#userdata-editor').height())
$('#static-userdata').text(editor.getText());
if (editor !== null) {
$('#static-userdata').text(editor.getText());
}
};
function removeStaticUserData() {
@ -450,7 +460,10 @@ function removeStaticUserData() {
function setEditorJSON(json) {
editor.set(json)
editor.expandAll();
if (editor.hasOwnProperty('expandAll')) {
editor.expandAll();
}
};
function getEditorJSON() {
@ -745,11 +758,11 @@ function loaded() {
} else {
properties = data.selections[0].properties;
if (lastEntityID !== properties.id && lastEntityID !== null && editor !== null) {
if (lastEntityID !== '"' + properties.id + '"' && lastEntityID !== null && editor !== null) {
saveJSONUserData(true);
}
lastEntityID = properties.id;
lastEntityID = '"' + properties.id + '"';
elID.innerHTML = properties.id;
elType.innerHTML = properties.type;
@ -840,26 +853,27 @@ function loaded() {
FIXME: See FIXME for property-script-url.
elScriptTimestamp.value = properties.scriptTimestamp;
*/
hideUserDataTextArea();
var json = null;
try {
json = JSON.parse(properties.userData);
} catch (e) {
//normal text
deleteJSONEditor();
elUserData.value = properties.userData;
showUserDataTextArea();
showNewJSONEditorButton();
hideSaveUserDataButton();
}
if (json !== null) {
if (editor === null) {
createJSONEditor();
}
setEditorJSON(json);
showSaveUserDataButton();
hideUserDataTextArea();
hideNewJSONEditorButton();
} catch (e) {
//normal text
elUserData.value = properties.userData;
showUserDataTextArea();
showNewJSONEditorButton();
hideSaveUserDataButton();
}
elHyperlinkHref.value = properties.href;