mirror of
https://github.com/overte-org/overte.git
synced 2025-04-16 16:26:17 +02:00
remove autosave, disable save button until change
This commit is contained in:
parent
5166a33370
commit
477ed88284
2 changed files with 34 additions and 12 deletions
|
@ -67,9 +67,9 @@
|
|||
<label for="property-user-data">User data</label>
|
||||
<br>
|
||||
<div class="row">
|
||||
<input type="button" class="red" id="userdata-clear" value="Clear User Data">
|
||||
<input type="button" class="red" id="userdata-clear" value="Clear User Data">
|
||||
<input type="button" class="blue" id="userdata-new-editor" value="Edit as JSON">
|
||||
<input type="button" class="black" id="userdata-save" value="Save User Data">
|
||||
<input disabled type="button" class="black" id="userdata-save" value="Save User Data">
|
||||
<span id="userdata-saved">Saved!</span>
|
||||
</div>
|
||||
<div id="static-userdata"></div>
|
||||
|
|
|
@ -348,8 +348,11 @@ function setTextareaScrolling(element) {
|
|||
element.setAttribute("scrolling", isScrolling ? "true" : "false");
|
||||
};
|
||||
|
||||
|
||||
|
||||
var editor = null;
|
||||
var editorTimeout = null;
|
||||
var lastJSONString=null;
|
||||
|
||||
function createJSONEditor() {
|
||||
var container = document.getElementById("userdata-editor");
|
||||
|
@ -365,13 +368,15 @@ function createJSONEditor() {
|
|||
alert('JSON editor:' + e)
|
||||
},
|
||||
onChange: function() {
|
||||
if (editorTimeout !== null) {
|
||||
clearTimeout(editorTimeout);
|
||||
console.log('changed')
|
||||
if(currentJSONString==='{"":""}'){
|
||||
console.log('its empty')
|
||||
return;
|
||||
}
|
||||
editorTimeout = setTimeout(function() {
|
||||
saveJSONUserData();
|
||||
}, EDITOR_TIMEOUT_DURATION)
|
||||
//saveJSONUserData();
|
||||
$('#userdata-save').attr('disabled',false)
|
||||
var currentJSONString = editor.getText();
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
editor = new JSONEditor(container, options);
|
||||
|
@ -448,9 +453,18 @@ function saveJSONUserData() {
|
|||
}
|
||||
savedJSONTimer = setTimeout(function() {
|
||||
$('#userdata-saved').hide();
|
||||
$('#userdata-save').attr('disabled',true)
|
||||
}, 1500)
|
||||
}
|
||||
|
||||
function bindAllNonJSONEditorElements(){
|
||||
var inputs = $('input');
|
||||
var i;
|
||||
for(i=0;i<inputs.length;i++){
|
||||
var input = inputs[i];
|
||||
}
|
||||
}
|
||||
|
||||
function loaded() {
|
||||
openEventBridge(function() {
|
||||
var allSections = [];
|
||||
|
@ -773,7 +787,7 @@ function loaded() {
|
|||
FIXME: See FIXME for property-script-url.
|
||||
elScriptTimestamp.value = properties.scriptTimestamp;
|
||||
*/
|
||||
deleteJSONEditor();
|
||||
//deleteJSONEditor();
|
||||
hideUserDataTextArea();
|
||||
var json = null;
|
||||
try {
|
||||
|
@ -782,8 +796,12 @@ function loaded() {
|
|||
if (Object.keys(json).length === 0 && json.constructor === Object) {
|
||||
//it's an empty object
|
||||
}
|
||||
createJSONEditor();
|
||||
setEditorJSON(json)
|
||||
if (editor === null) {
|
||||
createJSONEditor();
|
||||
console.log('CREATING NEW EDITOR')
|
||||
}
|
||||
|
||||
setEditorJSON(json);
|
||||
showSaveUserDataButton();
|
||||
hideNewJSONEditorButton();
|
||||
|
||||
|
@ -956,6 +974,7 @@ function loaded() {
|
|||
elLocked.removeAttribute('disabled');
|
||||
} else {
|
||||
enableProperties();
|
||||
elSaveUserData.disabled=true;
|
||||
}
|
||||
|
||||
var activeElement = document.activeElement;
|
||||
|
@ -1096,7 +1115,9 @@ function loaded() {
|
|||
});
|
||||
|
||||
elUserData.addEventListener('change', createEmitTextPropertyUpdateFunction('userData'));
|
||||
|
||||
// elJSONEditor.addEventListener('mouseleave',function(){
|
||||
// saveJSONUserData();
|
||||
// });
|
||||
elNewJSONEditor.addEventListener('click', function() {
|
||||
deleteJSONEditor();
|
||||
createJSONEditor();
|
||||
|
@ -1366,6 +1387,7 @@ function loaded() {
|
|||
clicked = true;
|
||||
};
|
||||
}
|
||||
bindMouseLeaveForJSONEditor();
|
||||
});
|
||||
|
||||
// Collapsible sections
|
||||
|
|
Loading…
Reference in a new issue