* Fixed a bunch of little bugs
* Added more options to attachment page and filters * Much better rendering and updating on attachment page * Math bug is fixed with better string parsing fixes #14 * Icons are limited to 4 per note * If an image is visible on note preview it will not appear in images preview * Touched up text algorithm to better display note titles
This commit is contained in:
@@ -582,8 +582,10 @@
|
||||
|
||||
// simple function that trys to evaluate javascript
|
||||
const shittyMath = (string) => {
|
||||
//Remove all chars but math chars
|
||||
const cleanString = String(string).replace(/[a-zA-Z\s]*/g,'')
|
||||
try {
|
||||
return Function('"use strict"; return (' + string + ')')();
|
||||
return Function('"use strict"; return (' + cleanString + ')')();
|
||||
} catch (error) {
|
||||
console.log('Math Error: ', string)
|
||||
return null
|
||||
@@ -596,8 +598,7 @@
|
||||
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 ){
|
||||
if(line.indexOf('=') != -1 && (line.length-1) == line.indexOf('=')){
|
||||
|
||||
//Pull out everything before the formula and try to evaluate it
|
||||
const formula = line.split('=').shift()
|
||||
@@ -607,6 +608,7 @@
|
||||
if(!isNaN(output) && output != null){
|
||||
|
||||
//Since there is HTML in the line, splice in the number after the = sign
|
||||
let equalLocation = node.innerHTML.indexOf('=')
|
||||
let newLine = node.innerHTML.slice(0, equalLocation+1).trim()
|
||||
newLine += ` ${output}`
|
||||
newLine += node.innerHTML.slice(equalLocation+1).trim()
|
||||
|
Reference in New Issue
Block a user