diff --git a/client/src/components/NoteInputPanel.vue b/client/src/components/NoteInputPanel.vue index 7a1b21b..6c73e11 100644 --- a/client/src/components/NoteInputPanel.vue +++ b/client/src/components/NoteInputPanel.vue @@ -158,12 +158,18 @@ Uncheck all Checked items -
+
Undo last change
+
+
+ + Simple Math +
+
{ + try { + return Function('"use strict"; return (' + string + ')')(); + } catch (error) { + console.log('Math Error: ', string) + return null + } + } + + //Go through each item, on first level, look for Unordered Lists + container.childNodes.forEach( (node) => { + + const line = node.innerText.trim() + + // = sign exists and its the last character in the string + let equalLocation = line.indexOf('=') + if(equalLocation != -1 && (line.length-1) == equalLocation ){ + + //Pull out everything before the formula and try to evaluate it + const formula = line.split('=').shift() + const output = shittyMath(formula) + + //If its a number and didn't throw an error, update the line + if(!isNaN(output) && output != null){ + + //Since there is HTML in the line, splice in the number after the = sign + let newLine = node.innerHTML.slice(0, equalLocation+1).trim() + newLine += ` ${output}` + newLine += node.innerHTML.slice(equalLocation+1).trim() + + //Slam in that new HTML with the output + node.innerHTML = newLine + } + } + + }) + }, setText(inText){ this.editor.setHTML(inText)