1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- var orden = new Map();
- var menu = new Map();
- menu.set('Pasta',[
- "Gardenia",
- "Primavera",
- "Carbonara",
- "Carnivorum",
- "Primavera con pollo",
- "Chicken carbonara",
- "Al pesto",
- "Pollo marsala",
- "Chicken and shrimp"
- ]);
- menu.set('Pizzeta', [
- "Simply Cheese",
- "Carbonara",
- "Al pesto",
- "Beef & Onion",
- "Pepperoni",
- "Bacon & Mushroom",
- "Churrasco Hollandaise",
- "Mr Wedge",
- "BBQ Meatlovers"
- ]);
-
- function add_item(item, category, num){
- var val = parseInt(document.getElementsByName(category + 'qty' + num)[0].value);
- var selection = category + " " + item;
- if (!orden.get(selection)){
- orden.set(selection, val);
- }
-
- else{
- orden.set(selection, orden.get(selection) + val);
- }
- localStorage.orden_local = JSON.stringify(Array.from(orden.entries()));
- console.log(orden);
- }
-
- function item_display(category){
- var cat_list = menu.get(category);
- var page = document.getElementById(category + "Div");
- var card_collection = "";
- for(var i = 0; i < cat_list.length; i++){
- card_collection += `<div class="card" style="width: 18rem;">
- <img class="card-img-top" src="img/` + category + `.png" alt="Image of ` + category + `">
- <div class="card-body">
- <h5 class="card-title">` + cat_list[i] + `</h5>
- <div style = "width: 100px; display: table; margin: 4px; padding: 1px;">
- <div style = "display: table-cell; width: 100%;">
- <input style = "width: 100%; margin: 1px;" type = "number" min = "1" value = "1" name = "`+ category + `qty` + i + `">
- </div>
- <div style = "padding: 5px">
- <button class="btn btn-primary btn-sm" onclick = "add_item('` + cat_list[i] + `', '` + category + `', `+ i + `)">Add</buton>
- </div>
- </div>
- </div>
- </div>`;
- }
- card_collection += "<br>";
- page.innerHTML = card_collection;
- }
-
- function order_summary(){
- try{
- orden = new Map(JSON.parse(localStorage.orden_local));
- }
- catch(err){
- alert("ERROR: Orden invalida")
- window.location.href = "index.html";
- }
- localStorage.orden_local = []
- var page = document.getElementById("rows");
- var orden_table = "";
- for(let [key,value] of orden){
- orden_table += `<tr>
- <td>` + key + `</td>
- <td>` + value + `</td>
- </tr>`
- }
- page.innerHTML = orden_table;
- }
|