class shoppingFunc { processItems(itemArr, itemLabel) { let tempAr = this.BuildList(this.updateShopIt(itemArr, itemLabel), ","); return "[" + tempAr + "]" } updateShopIt(itemArr, itemLabel) { let tempAr = itemArr; let num = 0; for (let i = 0; i < tempAr.length; i++) { let amount = tempAr[i].split(" ")[0] + " "; let radicale = tempAr[i].replace(tempAr[i].split(" ")[0] + " " + tempAr[i].split(" ")[1], ""); switch(itemLabel) { case !Boolean(itemLabel): amount = amount + num.toString() break; default: if (radicale.contains(itemLabel)) { amount = amount + (parseFloat(tempAr[i].split(" ")[1]) + 1).toString() } break; } tempAr[i] = "\"" + amount + radicale + "\"" } return tempAr } BuildList(arg1, construct) { let TempS = "" for (let i = 0; i < arg1.length; i++) { if (Boolean(arg1[i])) { if (TempS == "") { TempS = arg1[i] } else { TempS = TempS + construct + arg1[i] } } } return TempS } resetList(args) { const { that, app, dv, theme, listOfIt, } = args; // const { update } = app.plugins.plugins["metaedit"].api const { createButton } = app.plugins.plugins["buttons"] // var myButton = document.createElement("button"); const updateSct = listOfIt //this.getSctName(theme) //await dv.suggester(["groceries", "health", "household"], ["groceries", "health", "household"]); //"Groceries" // const btnStr = this.getBtnName(theme, updateSct) // const itemAr = this.getPoint(dv.page("01.02 Home/@Shopping list.md"), updateSct); // const updateStr = this.processItems(itemAr, false); // myButton.innerHTML = "\"" + this.getBtnName(theme, updateSct) + "\"" // myButton.addEventListener ("click", function() {this.updateList(updateSct, updateStr, dv.page("01.02 Home/@Shopping list.md").file.path)}); //return (async () => { dv.el('div', createButton({ app, el: that.container, args: { name: btnStr, color: 'blue' }, clickOverride: { click: this.getEditApi() /*await update*/, params: [updateSct, this.processItems(this.getPoint(dv.page("01.02 Home/@Shopping list.md"), updateSct), false), dv.page("01.02 Home/@Shopping list.md").file.path]} }), ) // })(); // dv.container.appendElement(myButton) } async getEditApi() { const { update } = app.plugins.plugins["metaedit"].api return await update } getBtnName(arg1, arg2) { let tempresult = "Test"; switch(arg1) { case 'to0': tempresult = "Reset " + arg2 + " list" break; case 'add': tempresult = "Add a " + arg2 + " item" break; } return tempresult } getPoint(p, datapoint) { let result = null switch(datapoint) { case 'Groceries': result = p.Groceries break; case 'Health': result = p.Health break; case 'Household': result = p.Household break; case 'type': result = p.DocType break; case 'createddate': result = p.Date break; case 'tag': result = p.Tag break; case 'hierarchy': result = p.Hierarchy break; case 'alias': result = p.Alias break; case 'location': result = p.location break; } return result } }