20,22d19 < var text=""; < < // Fish~`~taylor,300;barramundi,400;perch,100;mullet,234 25c22 < var fruits = [ --- > const fruits = [ 37,42c34 < function mysimpleCallback(qty) { < //alert(qty); < return qty > tippingpoint ? "ok" : "low"; < } < < function addone(knownname, knownquantity) { --- > function addone() { 44,52d35 < //alert(knownname); < //alert(knownquantity); < if (('' + knownname) != 'undefined' && ('' + knownquantity) != 'undefined') { < fruits.push({name:knownname, quantity:knownquantity}); < m.set(knownname, knownquantity); < } else if (('' + knownname) != 'undefined') { < fruits.push({name:knownname, quantity:0}); < m.set(knownname, 0); < } else { 55d37 < } 82,83d63 < var kk=0; < 85,86d64 < text="These " + document.getElementById('topic').innerHTML.toLowerCase() + "s are Ok:
"; < try { 89a68 > let text ="These fruits are Ok:
"; 93c72 < text += "" + x.name + " " + x.quantity + "
"; --- > text += x.name + " " + x.quantity + "
"; 100c79 < text += "
These " + document.getElementById('topic').innerHTML.toLowerCase() + "s are low:
"; --- > text += "
These fruits are low:
"; 104c83 < text += "" + x.name + " " + x.quantity + "
"; --- > text += x.name + " " + x.quantity + "
"; 110d88 < console.log(result.get("ok")); 112,140d89 < } catch(overebad) { < text="These " + document.getElementById('topic').innerHTML.toLowerCase() + "s are Ok:
"; < for (kk=0; kk= '0' && ('' + fruits[kk].quantity).replace('-','').substring(0,1) <= '9') { < if (mysimpleCallback(fruits[kk].quantity) == 'ok') { < //alert(fruits[kk].name); < text += "" + fruits[kk].name + " " + fruits[kk].quantity + "
"; < //alert('2:' + fruits[kk].name); < if (!m.has(fruits[kk].name)) { < //alert('3:' + fruits[kk].name); < m.set(fruits[kk].name, fruits[kk].quantity); < //alert('4:' + fruits[kk].name); < } < } < } < } < text += "
These " + document.getElementById('topic').innerHTML.toLowerCase() + "s are low:
"; < for (kk=0; kk= '0' && ('' + fruits[kk].quantity).replace('-','').substring(0,1) <= '9') { < if (mysimpleCallback(fruits[kk].quantity) == 'low') { < text += "" + fruits[kk].name + " " + fruits[kk].quantity + "
"; < if (!m.has(fruits[kk].name)) { < m.set(fruits[kk].name, fruits[kk].quantity); < } < } < } < } < < } 142a92 > console.log(result.get("ok")); 169d118 < document.getElementById("mysup").title='Add an editable ' + document.getElementById('topic').innerHTML.toLowerCase(); 180,244d128 < function askall() { < var delall=false; < var enterall=prompt('Optionally copy all your CSV (comma separated values) data to apply here (where ; or | can be record delimiters). Optionally prefix this CSV data with your topic followed by ~`~' + String.fromCharCode(10) + String.fromCharCode(10) + 'Example ...' + String.fromCharCode(10) + 'Fish~`~taylor,300;barramundi,400;perch,100;mullet,234', ''); < if (enterall == null) { enterall=''; } < if (enterall.indexOf('~`~') != -1) { document.getElementById('topic').innerHTML=enterall.split('~`~')[0]; enterall=enterall.replace(enterall.split('~`~')[0] + '~`~', ''); } < if (enterall.indexOf(',') != -1) { < var elines=[]; < if (enterall.indexOf(String.fromCharCode(10)) != -1) { < elines=enterall.split(String.fromCharCode(10)); < } else if (enterall.indexOf(';') != -1) { < elines=enterall.split(';'); < } else if (enterall.indexOf('|') != -1) { < elines=enterall.split('|'); < } < for (var ie=0; ie= '0' && elines[ie].substring(1).replace('-','').substring(0,1) <= '9') { < addone(elines[ie].split('","')[1].split('"')[0], elines[ie].substring(1).split('"')[0]); < } else { < addone(elines[ie].substring(1).split('"')[0], elines[ie].split('","')[1].split('"')[0]); < } < } else if (elines[ie].indexOf('",') != -1 && elines[ie].indexOf('",') < elines[ie].indexOf(',')) { < if (!delall) { < delall=true; < fruits=[]; < m = new Map(); < } < if (elines[ie].substring(1).replace('-','').substring(0,1) >= '0' && elines[ie].substring(1).replace('-','').substring(0,1) <= '9') { < addone(elines[ie].split('",')[1].split(',')[0], elines[ie].substring(1).split('"')[0]); < } else { < addone(elines[ie].substring(1).split('"')[0], elines[ie].split('",')[1].split(',')[0]); < } < } else if (elines[ie].indexOf(',"') != -1 && elines[ie].indexOf(',"') == elines[ie].indexOf(',')) { < if (!delall) { < delall=true; < fruits=[]; < m = new Map(); < } < if (elines[ie].substring(0).replace('-','').substring(0,1) >= '0' && elines[ie].substring(0).replace('-','').substring(0,1) <= '9') { < addone(elines[ie].split(',"')[1].split('"')[0], elines[ie].substring(0).split(',')[0]); < } else { < addone(elines[ie].substring(0).split(',')[0], elines[ie].split(',"')[1].split('"')[0]); < } < } else if (elines[ie].indexOf(',') != -1) { < if (!delall) { < delall=true; < fruits=[]; < m = new Map(); < } < if (elines[ie].substring(0).replace('-','').substring(0,1) >= '0' && elines[ie].substring(0).replace('-','').substring(0,1) <= '9') { < addone(elines[ie].substring(0).split(',')[1], elines[ie].substring(0).split(',')[0]); < } else { < addone(elines[ie].substring(0).split(',')[0], elines[ie].substring(0).split(',')[1]); < } < } < } < beadjustable(); < } < } < 254c138 < Fruit Report ++ --- > Fruit Report ++