diff --git a/FloatingSpace/CodeEditor.js b/FloatingSpace/CodeEditor.js index 1ed862964..62fcffdae 100644 --- a/FloatingSpace/CodeEditor.js +++ b/FloatingSpace/CodeEditor.js @@ -71,6 +71,13 @@ function newCodeEditor () { let textArea = document.getElementById('textArea') textArea.style.display = 'none' thisObject.payload.node.code = textArea.value + if (thisObject.payload.node.type !== 'Code' && thisObject.payload.node.type !== 'Formula') { + try { + let code = JSON.parse(thisObject.payload.node.code) + } catch (err) { + thisObject.payload.uiObject.setErrorMessage(err.message, 10) + } + } } } @@ -80,6 +87,7 @@ function newCodeEditor () { thisObject.rawRadius = 8 thisObject.targetRadius = thisObject.container.frame.radius thisObject.currentRadius = 0 + thisObject.payload.uiObject.setErrorMessage('', 0) let textArea = document.getElementById('textArea') textArea.value = payload.node.code diff --git a/FloatingSpace/UiObject.js b/FloatingSpace/UiObject.js index 55506b4c0..f702b5e60 100644 --- a/FloatingSpace/UiObject.js +++ b/FloatingSpace/UiObject.js @@ -835,11 +835,12 @@ function newUiObject () { highlightCounter = 30 } - function setErrorMessage (message) { + function setErrorMessage (message, duration) { if (message !== undefined) { errorMessage = message hasError = true - errorMessageCounter = 100 + if (duration === undefined) { duration = 1 } + errorMessageCounter = 100 * duration } }