From 477ed8828476f19c6a9687a9460b949316f8409b Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Tue, 23 Aug 2016 14:34:28 -0700 Subject: [PATCH] remove autosave, disable save button until change --- scripts/system/html/entityProperties.html | 4 +-- scripts/system/html/js/entityProperties.js | 42 ++++++++++++++++------ 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/scripts/system/html/entityProperties.html b/scripts/system/html/entityProperties.html index 0eeb817640..dfa87f86ad 100644 --- a/scripts/system/html/entityProperties.html +++ b/scripts/system/html/entityProperties.html @@ -67,9 +67,9 @@
- + - + Saved!
diff --git a/scripts/system/html/js/entityProperties.js b/scripts/system/html/js/entityProperties.js index 9f58fbe04d..b9135a1048 100644 --- a/scripts/system/html/js/entityProperties.js +++ b/scripts/system/html/js/entityProperties.js @@ -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