You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
762 B

const {globalFunc} = customJS;
let {items} = input;
let ing = [];
let j = 0;
if (!Boolean(items)) {
return "⚠️ <b>Warning</b>\nYou have not specified shopping items!\n<b>The shopping list cannot be printed.</b>"
}
for (let i = 0; i < items.length; i++) {
let name = items[i].replace(items[i].split(" ")[0] + " " + items[i].split(" ")[1]+ " " + items[i].split(" ")[2], "");
let unit = items[i].split(" ")[2];
if (unit.contains('whole')) {unit = ""}
let amount = items[i].split(" ")[1];
let emoji = items[i].split(" ")[0];
if (amount > 0) {
ing[j] = emoji + " " + amount + " " + unit + " <b>" + name + "</b>"
j++
}
}
if (ing.length == 0) {
return dv.el('p', "✌️ No shopping item to display")
}
dv.el('p', globalFunc.BuildList(ing, "\n"))