mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 08:56:25 +02:00
handle some more cases
This commit is contained in:
parent
8d5a896ccf
commit
9be073cc12
2 changed files with 37 additions and 17 deletions
|
@ -1369,7 +1369,12 @@ var PropertiesTool = function (opts) {
|
||||||
});
|
});
|
||||||
|
|
||||||
webView.webEventReceived.connect(function (data) {
|
webView.webEventReceived.connect(function (data) {
|
||||||
data = JSON.parse(data);
|
try{
|
||||||
|
data = JSON.parse(data);
|
||||||
|
}
|
||||||
|
catch(e){
|
||||||
|
return;
|
||||||
|
}
|
||||||
var i, properties, dY, diff, newPosition;
|
var i, properties, dY, diff, newPosition;
|
||||||
if (data.type === "print") {
|
if (data.type === "print") {
|
||||||
if (data.message) {
|
if (data.message) {
|
||||||
|
@ -1418,7 +1423,8 @@ var PropertiesTool = function (opts) {
|
||||||
pushCommandForSelections();
|
pushCommandForSelections();
|
||||||
selectionManager._update();
|
selectionManager._update();
|
||||||
} else if(data.type === 'saveUserData'){
|
} 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") {
|
} else if (data.type === "showMarketplace") {
|
||||||
showMarketplace();
|
showMarketplace();
|
||||||
} else if (data.type === "action") {
|
} else if (data.type === "action") {
|
||||||
|
|
|
@ -333,7 +333,13 @@ function userDataChanger(groupName, keyName, checkBoxElement, userDataElement, d
|
||||||
var properties = {};
|
var properties = {};
|
||||||
var parsedData = {};
|
var parsedData = {};
|
||||||
try {
|
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) {}
|
} catch (e) {}
|
||||||
|
|
||||||
if (!(groupName in parsedData)) {
|
if (!(groupName in parsedData)) {
|
||||||
|
@ -441,7 +447,11 @@ function hideUserDataTextArea() {
|
||||||
function showStaticUserData() {
|
function showStaticUserData() {
|
||||||
$('#static-userdata').show();
|
$('#static-userdata').show();
|
||||||
$('#static-userdata').css('height', $('#userdata-editor').height())
|
$('#static-userdata').css('height', $('#userdata-editor').height())
|
||||||
$('#static-userdata').text(editor.getText());
|
if (editor !== null) {
|
||||||
|
$('#static-userdata').text(editor.getText());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function removeStaticUserData() {
|
function removeStaticUserData() {
|
||||||
|
@ -450,7 +460,10 @@ function removeStaticUserData() {
|
||||||
|
|
||||||
function setEditorJSON(json) {
|
function setEditorJSON(json) {
|
||||||
editor.set(json)
|
editor.set(json)
|
||||||
editor.expandAll();
|
if (editor.hasOwnProperty('expandAll')) {
|
||||||
|
editor.expandAll();
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function getEditorJSON() {
|
function getEditorJSON() {
|
||||||
|
@ -745,11 +758,11 @@ function loaded() {
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
properties = data.selections[0].properties;
|
properties = data.selections[0].properties;
|
||||||
if (lastEntityID !== properties.id && lastEntityID !== null && editor !== null) {
|
if (lastEntityID !== '"' + properties.id + '"' && lastEntityID !== null && editor !== null) {
|
||||||
saveJSONUserData(true);
|
saveJSONUserData(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
lastEntityID = properties.id;
|
lastEntityID = '"' + properties.id + '"';
|
||||||
elID.innerHTML = properties.id;
|
elID.innerHTML = properties.id;
|
||||||
|
|
||||||
elType.innerHTML = properties.type;
|
elType.innerHTML = properties.type;
|
||||||
|
@ -840,26 +853,27 @@ function loaded() {
|
||||||
FIXME: See FIXME for property-script-url.
|
FIXME: See FIXME for property-script-url.
|
||||||
elScriptTimestamp.value = properties.scriptTimestamp;
|
elScriptTimestamp.value = properties.scriptTimestamp;
|
||||||
*/
|
*/
|
||||||
hideUserDataTextArea();
|
|
||||||
var json = null;
|
var json = null;
|
||||||
try {
|
try {
|
||||||
json = JSON.parse(properties.userData);
|
json = JSON.parse(properties.userData);
|
||||||
|
} catch (e) {
|
||||||
|
//normal text
|
||||||
|
deleteJSONEditor();
|
||||||
|
elUserData.value = properties.userData;
|
||||||
|
showUserDataTextArea();
|
||||||
|
showNewJSONEditorButton();
|
||||||
|
hideSaveUserDataButton();
|
||||||
|
}
|
||||||
|
if (json !== null) {
|
||||||
if (editor === null) {
|
if (editor === null) {
|
||||||
createJSONEditor();
|
createJSONEditor();
|
||||||
}
|
}
|
||||||
|
|
||||||
setEditorJSON(json);
|
setEditorJSON(json);
|
||||||
showSaveUserDataButton();
|
showSaveUserDataButton();
|
||||||
|
hideUserDataTextArea();
|
||||||
hideNewJSONEditorButton();
|
hideNewJSONEditorButton();
|
||||||
|
|
||||||
} catch (e) {
|
|
||||||
//normal text
|
|
||||||
|
|
||||||
elUserData.value = properties.userData;
|
|
||||||
showUserDataTextArea();
|
|
||||||
showNewJSONEditorButton();
|
|
||||||
hideSaveUserDataButton();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
elHyperlinkHref.value = properties.href;
|
elHyperlinkHref.value = properties.href;
|
||||||
|
|
Loading…
Reference in a new issue