Graph update and little noe ui tweaks

This commit is contained in:
Max
2023-07-23 23:13:28 +00:00
parent d3acd62688
commit c61f0c0198
12 changed files with 1341 additions and 356 deletions

View File

@@ -172,15 +172,16 @@ const SquireButtonFunctions = {
//Fetch the container
let container = document.getElementById('squire-id')
this.$router.go(-1)
Array.from( container.getElementsByClassName('active') ).forEach(item => {
item.classList.remove('active');
})
setTimeout(()=>{
//Close menu if user is on mobile, then sort list
if(this.$store.getters.getIsUserOnMobile){
this.$router.go(-1)
}
Array.from( container.getElementsByClassName('active') ).forEach(item => {
item.classList.remove('active');
})
},600)
},
deleteCompletedListItems(){
//
@@ -190,53 +191,57 @@ const SquireButtonFunctions = {
//Fetch the container
let container = document.getElementById('squire-id')
//Go through each item, on first level, look for Unordered Lists
container.childNodes.forEach( (node) => {
if(node.nodeName == 'UL'){
//Close menu if user is on mobile, then sort list
this.$router.go(-1)
//Create two categories, done and not done list items
let undoneElements = document.createDocumentFragment()
setTimeout(()=>{
//Go through each item in each list we found
node.childNodes.forEach( (checkListItem, index) => {
//Go through each item, on first level, look for Unordered Lists
container.childNodes.forEach( (node) => {
if(node.nodeName == 'UL'){
//Skip Embedded lists, they are handled with the list item above them. Keep lists with intented items together
if(checkListItem.nodeName == 'UL'){
return
}
//Create two categories, done and not done list items
let undoneElements = document.createDocumentFragment()
//Check if list item has active class
const checkedItem = checkListItem.classList.contains('active')
//Go through each item in each list we found
node.childNodes.forEach( (checkListItem, index) => {
//Check if the next item is a list, Keep lists with intented items together
let sublist = null
if(node.childNodes[index+1] && node.childNodes[index+1].nodeName == 'UL'){
sublist = node.childNodes[index+1]
}
//Push checked items and their sub lists to the done set
if(!checkedItem){
undoneElements.appendChild( checkListItem.cloneNode(true) )
if(sublist){
undoneElements.appendChild( sublist.cloneNode(true) )
//Skip Embedded lists, they are handled with the list item above them. Keep lists with intented items together
if(checkListItem.nodeName == 'UL'){
return
}
}
//Check if list item has active class
const checkedItem = checkListItem.classList.contains('active')
})
//Check if the next item is a list, Keep lists with intented items together
let sublist = null
if(node.childNodes[index+1] && node.childNodes[index+1].nodeName == 'UL'){
sublist = node.childNodes[index+1]
}
//Remove all HTML from node, push unfinished items, then finished below them
node.innerHTML = null
node.appendChild(undoneElements)
}
})
//Push checked items and their sub lists to the done set
if(!checkedItem){
//Close menu if user is on mobile, then sort list
if(this.$store.getters.getIsUserOnMobile){
this.$router.go(-1)
}
undoneElements.appendChild( checkListItem.cloneNode(true) )
if(sublist){
undoneElements.appendChild( sublist.cloneNode(true) )
}
}
})
//Remove all HTML from node, push unfinished items, then finished below them
node.innerHTML = null
node.appendChild(undoneElements)
}
})
}, 600)
},
sortList(){
//
@@ -246,61 +251,65 @@ const SquireButtonFunctions = {
//Fetch the container
let container = document.getElementById('squire-id')
//Go through each item, on first level, look for Unordered Lists
container.childNodes.forEach( (node) => {
if(node.nodeName == 'UL'){
//Close menu if user is on mobile
this.$router.go(-1)
//Create two categories, done and not done list items
let doneElements = document.createDocumentFragment()
let undoneElements = document.createDocumentFragment()
setTimeout(()=>{
//Go through each item in each list we found
node.childNodes.forEach( (checkListItem, index) => {
//Go through each item, on first level, look for Unordered Lists
container.childNodes.forEach( (node) => {
if(node.nodeName == 'UL'){
//Skip Embedded lists, they are handled with the list item above them. Keep lists with intented items together
if(checkListItem.nodeName == 'UL'){
return
}
//Create two categories, done and not done list items
let doneElements = document.createDocumentFragment()
let undoneElements = document.createDocumentFragment()
//Check if list item has active class
const checkedItem = checkListItem.classList.contains('active')
//Go through each item in each list we found
node.childNodes.forEach( (checkListItem, index) => {
//Check if the next item is a list, Keep lists with intented items together
let sublist = null
if(node.childNodes[index+1] && node.childNodes[index+1].nodeName == 'UL'){
sublist = node.childNodes[index+1]
}
//Push checked items and their sub lists to the done set
if(checkedItem){
doneElements.appendChild( checkListItem.cloneNode(true) )
if(sublist){
doneElements.appendChild( sublist.cloneNode(true) )
//Skip Embedded lists, they are handled with the list item above them. Keep lists with intented items together
if(checkListItem.nodeName == 'UL'){
return
}
} else {
//Check if list item has active class
const checkedItem = checkListItem.classList.contains('active')
undoneElements.appendChild( checkListItem.cloneNode(true) )
if(sublist){
undoneElements.appendChild( sublist.cloneNode(true) )
//Check if the next item is a list, Keep lists with intented items together
let sublist = null
if(node.childNodes[index+1] && node.childNodes[index+1].nodeName == 'UL'){
sublist = node.childNodes[index+1]
}
}
})
//Push checked items and their sub lists to the done set
if(checkedItem){
//Remove all HTML from node, push unfinished items, then finished below them
node.innerHTML = null
node.appendChild(undoneElements)
node.appendChild(doneElements)
}
})
doneElements.appendChild( checkListItem.cloneNode(true) )
if(sublist){
doneElements.appendChild( sublist.cloneNode(true) )
}
//Close menu if user is on mobile
if(this.$store.getters.getIsUserOnMobile){
this.$router.go(-1)
}
} else {
undoneElements.appendChild( checkListItem.cloneNode(true) )
if(sublist){
undoneElements.appendChild( sublist.cloneNode(true) )
}
}
})
//Remove all HTML from node, push unfinished items, then finished below them
node.innerHTML = null
node.appendChild(undoneElements)
node.appendChild(doneElements)
}
})
},600)
},
calculateMath(){
//
@@ -310,6 +319,9 @@ const SquireButtonFunctions = {
//Fetch the container
let container = document.getElementById('squire-id')
//Close menu if user is on mobile, then sort list
this.$router.go(-1)
// simple function that trys to evaluate javascript
const shittyMath = (string) => {
//Remove all chars but math chars
@@ -322,38 +334,39 @@ const SquireButtonFunctions = {
}
}
//Go through each item, on first level, look for Unordered Lists
container.childNodes.forEach( (node) => {
setTimeout(()=>{
const line = node.innerText.trim()
//Go through each item, on first level, look for Unordered Lists
container.childNodes.forEach( (node) => {
// = sign exists and its the last character in the string
if(line.indexOf('=') != -1 && (line.length-1) == line.indexOf('=')){
const line = node.innerText.trim()
//Pull out everything before the formula and try to evaluate it
const formula = line.split('=').shift()
const output = shittyMath(formula)
// = sign exists and its the last character in the string
if(line.indexOf('=') != -1 && (line.length-1) == line.indexOf('=')){
//If its a number and didn't throw an error, update the line
if(!isNaN(output) && output != null){
//Pull out everything before the formula and try to evaluate it
const formula = line.split('=').shift()
const output = shittyMath(formula)
//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()
//If its a number and didn't throw an error, update the line
if(!isNaN(output) && output != null){
//Slam in that new HTML with the output
node.innerHTML = newLine
//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()
//Slam in that new HTML with the output
node.innerHTML = newLine
}
}
}
})
})
},600)
//Close menu if user is on mobile, then sort list
if(this.$store.getters.getIsUserOnMobile){
this.$router.go(-1)
}
},
setText(inText){