PageSourceSearch

https://avongrill.co.uk/js/orderFunctions2.js?v=13

js avongrill.co.uk collected 2026-09-24 11:08:04 UTC 109,619 bytes, 3,097 lines download raw bytes

1"use strict";
2
3 
4
5var campaignText="no",saladNames = [], sauceNames = [], DipNames = [], CanNames = [], KidsNames = [], ElistNames = [],ElistxNames = [],BottleNames = [], toppingNames = [], classes=[], etoppings1 = [], etoppings2= [], etoppings3= [] , maxSauces=2;
6var toppingPrices = [], stuffedPrices = [],stuffedPrices2 = [], maximumToppings = [], PizzaNames = [], KebabNames = [],SidesNames = [], etoppings1Prices = [], etoppings3Prices = [], cheeseprice = 0, bcheeseprice = 0, bases = [], boxt = [], extraAll =[], arx=[],extraTypes =[],mmNames=["Chips"], swaptop=0,makeMeal=0,catNames=[];
7 
8var OtherNames=["Ham Burger","Cheese Burger","Bacon Burger","Teriyaki Chicken Burger","Cajun Chicken Burger","Buttermilk Chicken Burger","Bacon Cheese Burger","Philly Cheese Steak","Chicken Teriyaki","Bacon 3 Cheese Steak","Chicken Buffalo","Chicken Philly","Veggie Delight","Chicken California"], OtherxNames=["Fudge Cake","Carrot Cake","Waffle"];
9
10function headerx(infox){
11  return tableFiller(infox.name);
12}
13function headerc(infox){
14  return finishTable();
15}
16
17//formModal += finishTable();
18//formModal += tableFiller("Customize");
19
20 
21function entryx(infox,iterate,differ){
22  return createCheckBox55("radio", infox.name,infox.class, iterate,infox.price,infox.class+differ,"");
23}
24
25function entryy(infox,iterate,differ){
26    return createCheckBox55("radio", infox.name ,infox.class, iterate,infox.price,infox.class+differ,"notavailable ");
27  }
28
29function selecty(infox, iterate, differ) {
30    return createSelectBox55(
31        infox.name,
32        infox.class,
33        iterate,
34        infox.price,
35        infox.class + differ
36    );
37}
38 
39function createCheckBox55(typeBox, itemName, className, iterator,pricesx,type,xclass) {
40 
41    var checkbox = '';
42    checkbox += '<tr><td>';
43    checkbox += '<div class="funkyradio">';
44    checkbox += '<div class="funkyradio-default">';
45    checkbox += '<div class="funkyradio-success">';
46    checkbox += '<input type="' + typeBox + '" name="'+type+'"  class="'+xclass+'typexyz ' + className + '" id="' + type + iterator + '" value="' + itemName + '" data-checked="false" data-price="'+pricesx+'"/>';
47    checkbox += '<label for="' + type + iterator + '"> <span class="label-box"></span><span class="label-text">' + itemName + '</span> </label>';
48    checkbox += '</div> </div></div></td></tr>';
49    return checkbox;
50}
51
52function createSelectBox55(itemName, className, iterator, pricesx, type) {
53
54    var parts = (itemName || "").split("::");
55
56    var heading = "";
57    var optionsText = itemName || "";
58    var required = false;
59
60    if (parts.length > 1) {
61
62        heading = parts[0].trim();
63        optionsText = parts.slice(1).join("::");
64
65        required = heading.endsWith("*");
66
67        if (required) {
68            heading = heading.slice(0, -1).trim();
69        }
70    }
71
72    var options = optionsText.split("|");
73
74
75    var optionPriceDefinitions = String(pricesx || "0").split(";");
76
77    var html = "";
78
79    if (heading) {
80        html += "<tr><td>";
81        html += '<strong class="modifierHeading">' + heading + "</strong>";
82        html += "</td></tr>";
83    }
84
85    html += "<tr><td>";
86
87    html += "<select ";
88    html += 'name="' + type + '" ';
89    html += 'class="form-control modifierSelect typexyz ' + className + '" ';
90    html += 'id="' + type + iterator + '" ';
91    html += 'data-required="' + (required ? "true" : "false") + '">';
92
93    if (required) {
94        html += '<option value="" selected disabled>Please Choose...</option>';
95    } else {
96        html += '<option value="" selected data-price="0">No Change</option>';
97    }
98
99    for (var i = 0; i < options.length; i++) {
100
101        var optionName = options[i].trim();
102
103        if (!optionName) {
104            continue;
105        }
106
107        /*
108          Get this option's own price definition.
109
110          If there is only one price definition, use it for every option
111          so your old shared-price setup remains compatible.
112        */
113        var optionPriceInfo;
114
115        if (optionPriceDefinitions.length === 1) {
116            optionPriceInfo = optionPriceDefinitions[0].trim();
117        } else {
118            optionPriceInfo = (
119                optionPriceDefinitions[i] !== undefined
120                    ? optionPriceDefinitions[i]
121                    : "0"
122            ).trim();
123        }
124
125        if (!optionPriceInfo) {
126            optionPriceInfo = "0";
127        }
128
129        var unavailableSizes = "";
130        var actualPrices = optionPriceInfo;
131
132        /*
133          Example:
134
135          notavailable:10,12|2.80,3.20,4.20,5.20
136        */
137        if (optionPriceInfo.indexOf("notavailable:") === 0) {
138
139            var availabilityParts = optionPriceInfo.split("|");
140
141            unavailableSizes = availabilityParts[0]
142                .replace("notavailable:", "")
143                .trim();
144
145            actualPrices = availabilityParts.slice(1).join("|").trim();
146
147            if (!actualPrices) {
148                actualPrices = "0";
149            }
150        }
151
152    var prices = actualPrices.split(",");
153
154var numericPrices = [];
155
156for (var p = 0; p < prices.length; p++) {
157
158    var price = parseFloat(prices[p]);
159
160    if (!isNaN(price)) {
161        numericPrices.push(price);
162    }
163}
164
165var optionLabel = optionName;
166
167if (numericPrices.length > 0) {
168
169    var minPrice = Math.min.apply(null, numericPrices);
170    var maxPrice = Math.max.apply(null, numericPrices);
171
172    if (maxPrice > 0) {
173
174        if (minPrice === maxPrice) {
175            optionLabel += " (+£" + minPrice.toFixed(2) + ")";
176        } else {
177            optionLabel +=
178                " (+£" +
179                minPrice.toFixed(2) +
180                " - £" +
181                maxPrice.toFixed(2) +
182                ")";
183        }
184    }
185}
186
187        html += "<option ";
188        html += 'value="' + optionName + '" ';
189        html += 'data-price="' + optionPriceInfo + '" ';
190        html += 'data-prices="' + actualPrices + '" ';
191        html += 'data-notavailable="' + unavailableSizes + '">';
192        html += optionLabel;
193        html += "</option>";
194    }
195
196    html += "</select>";
197    html += "</td></tr>";
198
199    return html;
200}
201  
202
203function branchInformation() {
204 
205    var shopResponse = window.BRANCH_INFO || {};
206 
207    try {
208        toppingNames = JSON.parse(shopResponse.toppings || "[]");
209
210        var a = 0, b = 0, c = 0;
211        var yx = Math.floor(toppingNames.length / 3);
212        var tlen = toppingNames.length - 3 * yx;
213
214        if (tlen === 2) {
215            a = yx + 1;
216            b = a + yx + 1;
217            c = b + yx;
218        } else if (tlen === 1) {
219            a = yx + 1;
220            b = a + yx;
221            c = b + yx;
222        } else {
223            a = yx;
224            b = a + yx;
225            c = b + yx;
226        }
227        arx.push(a, b, c);
228    } catch (e) {
229        // If toppings JSON is bad, just skip splitting; no crash.
230        console.log("branchInformation toppings parse error", e);
231    }
232 
233
234    console.log("shopresponse",shopResponse);
235    saladNames   = (shopResponse.salads   || "").split(",");
236    sauceNames   = (shopResponse.sauces   || "").split(",");
237    DipNames     = (shopResponse.dips     || "").split(",");
238    CanNames     = (shopResponse.cans     || "").split(",");
239    BottleNames  = (shopResponse.bottles  || "").split(",");
240    toppingPrices = (shopResponse.toppingPrices || "").split(",");
241
242   
243    var newstuffed = (shopResponse.stuffed || "").split("|");
244    stuffedPrices  = (newstuffed[0] || "").split(",");
245    try { stuffedPrices2 = (newstuffed[1] || "").split(","); } catch (e) { stuffedPrices2 = "no"; }
246
247 
248    try { KidsNames   = (shopResponse.kids   || "").split(","); }   catch (e) {}
249    try { ElistNames  = (shopResponse.elist  || "").split(","); }   catch (e) {}
250
251    try { ElistxNames = (shopResponse.elistx || "").split(","); }   catch (e) {}
252
253    PizzaNames       = (shopResponse.pizzaNames       || "").split(",");
254    maximumToppings  = (shopResponse.maximumToppings  || "").split(",");
255    KebabNames       = (shopResponse.kebabNames       || "").split(",");
256    SidesNames       = (shopResponse.sides            || "").split(",");
257
258    try { makeMeal    = shopResponse.makeMeal; }       catch (e) {}
259    try { etoppings1  = (shopResponse.etoppings1  || "").split(","); } catch (e) {}
260    try { campaignText = shopResponse.campaignText; }  catch (e) {}
261    try { etoppings2  = (shopResponse.etoppings2  || "").split(","); } catch (e) {}
262    try { mmNames     = (shopResponse.mmList      || "").split(","); } catch (e) { mmNames = ["Chips"]; }
263    try { etoppings3  = (shopResponse.etoppings3  || "").split(","); } catch (e) {}
264    try { etoppings1Prices = (shopResponse.etoppings1Prices || "").split(","); } catch (e) {}
265    try { etoppings3Prices = (shopResponse.etoppings3Prices || "").split(","); } catch (e) {}
266    try { catNames = (shopResponse.printcat || "").split(","); } catch (e) {}
267
268    try { extraAll   = shopResponse.extraAll   ? JSON.parse(shopResponse.extraAll)   : extraAll; }   catch (e) {}
269    try { extraTypes = shopResponse.extraTypes ? JSON.parse(shopResponse.extraTypes) : extraTypes; } catch (e) {}
270
271    try { bases = (shopResponse.bases || "").split(","); } catch (e) {}
272    try { boxt  = (shopResponse.boxt  || "").split(","); } catch (e) {}
273
274    maxSauces    = (shopResponse.maxSauces !== undefined && shopResponse.maxSauces !== null)? shopResponse.maxSauces: 2;
275    cheeseprice  = (shopResponse.cheesePrice  !== undefined) ? shopResponse.cheesePrice  : cheeseprice;
276    bcheeseprice = (shopResponse.bcheesePrice !== undefined) ? shopResponse.bcheesePrice : bcheeseprice;
277
278    try { swaptop = (shopResponse.swaptop !== undefined ? shopResponse.swaptop : 0); } catch (e) { swaptop = 0; }
279
280 
281    if (shopResponse.situation === "Closed") {
282        var closing;
283        try {
284            closing = (shopResponse.closeddays || "").split(",");
285            if (!closing || closing.length !== 7) {
286                closing = ["23:00","23:00","23:00","23:00","23:00","23:00","23:00"];
287            }
288        } catch (e) {
289            closing = ["23:00","23:00","23:00","23:00","23:00","23:00","23:00"];
290        }
291
292        var days  = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Frid
292ay","Saturday"];
293        var days2 = [];
294        try {
295            days2 = (shopResponse.opendays || "").split(",");
296        } catch (e) {}
297
298        // normalise length
299        if (!days2 || days2.length !== 7) {
300            days2 = ["Closed","Closed","Closed","Closed","Closed","Closed","Closed"];
301        }
302
303        var tabls = '<table class="alerts1x" style="margin-bottom:16px;"><thead><tr style="border-bottom:2px solid #333 !important;"><th>Day</th><th>Opening</th><th>Closing</th></tr></thead><tbody>';
304        for (var i = 0; i < days.length; ++i) {
305            tabls += '<tr style="border-bottom:1px solid #e3e3e3;"><td>' + days[i] + '</td>';
306            tabls += '<td>' + days2[i] + '</td>';
307            if (days2[i] === "Closed") {
308                tabls += '<td>' + days2[i] + '</td></tr>';
309            } else {
310                tabls += '<td>' + closing[i] + '</td></tr>';
311            }
312        }
313        tabls += '</tbody></table>';
314
315        var reason = shopResponse.closeReason;
316        if (!reason || reason === "Closed") {
317            reason = "Out of Delivery and Collection Hours";
318        }
319
320        alertUser(
321            "<h1 class='alertmessage'>Sorry it seems like shop is closed at the moment <br> Reason: " +
322            reason +
323            "</h1> <h1 class='openingxx'>Our Opening Times are :</h1> " +
324            tabls
325        );
326    }
327
328    // --- HEADER LINKS (menu categories) ---
329    var headernames        = shopResponse.headerNames    || "";
330    var headerAvailability = shopResponse.headerAvailable || "";
331
332    var body  = "";
333    var array = headernames.split(",");
334    var array2 = headerAvailability.split(",");
335
336    for (var j = 0; j < array.length; ++j) {
337          if (array[j] && array[j].trim().toLowerCase() === 'custom') {
338            continue;
339        }
340        if (array2[j] != 0) {
341            var header = array[j].split(" ").join("");
342            body += '<a href="#menus" data-filter="' + header + '" class="hheads">' + array[j] + '</a>';
343        }
344    }
345
346    try { document.getElementById("menuHeaders").innerHTML = body; } catch (e) {}
347 
348    try { branchItems(); } catch (e) {}
349}
350
351 
352 
353function addToCart() {
354    var currentLength = localStorage.length + 1; while (localStorage.getItem(currentLength) != null) { ++currentLength; }
355    var pizzaSize = 0, countMe = 0, attiributes = {};
356    var tempBody = "", tempName = "";
357    var xy1 = document.getElementById("invokeMyModal");
358    var salads = xy1.getElementsByClassName("salad");
359    var sauces = xy1.getElementsByClassName("sauce");
360    var portions = xy1.getElementsByClassName("portion");
361    var toppings = xy1.getElementsByClassName("toppings");
362    var extraToppings = xy1.getElementsByClassName("extratoppings");
363    var etoppings12 = xy1.getElementsByClassName("etoppings1");
364    var etoppings13 = xy1.getElementsByClassName("etoppings2");
365    var etoppings14 = xy1.getElementsByClassName("etoppings3");
366    var pbases = xy1.getElementsByClassName("bases33");
367    var featureBody = "", customizedBody = "", featureBody2="";
368    var offeredItems = xy1.getElementsByClassName("itemOffers");
369    var optionNames = xy1.getElementsByClassName("optionHeaders");
370    var optionChoices = xy1.getElementsByClassName("optionsChoices");
371    var comboChoices = xy1.getElementsByClassName("comboItems");
372    var extrasxx = xy1.getElementsByClassName("extrasxx");
373    var features = xy1.getElementsByClassName("typexyz");
374    var makeMealOptions = xy1.getElementsByClassName("mealItemsm");
375 
376    var name = document.getElementById("forwho").value;
377    if(name!="nonex"){
378        featureBody += '<p class="itemOptions" >For:' + name + '</p>';
379    }
380
381    try { var menuHeader = document.getElementById("menuHeader1").value;} catch (e) { }
382    try { var extraCheese = document.getElementById("cheese33").checked; } catch (e) { }
383    try { var chipsCheese = document.getElementById("cheese334").checked; } catch (e) { }
384    try { var nocheeseCheck = document.getElementById("nocheese33").
384checked; } catch (e) { }
385    try { var extraBurgerCheese = document.getElementById("cheese44").checked; } catch (e) { }
386    try { var stuffedCheck = document.getElementById("stuffedCrust24").checked; } catch (e) { }
387    try { var stuffedCheck2 = document.getElementById("stuffedCrust25").checked; } catch (e) { }
388    try { var makeMealSelect = document.getElementById("makeMealSelect").checked; } catch (e) { }
389    try { var salt = document.getElementById("salt33").checked; } catch (e) {}
390    try { var vinegar = document.getElementById("vinegar33").checked; } catch (e) {} 
391    try { var amounts = document.getElementById("amountItem").value; } catch (e) {}
392    try { var specialoffer = document.getElementById("mealtt0").value; } catch (e) {}
393
394    if (amounts <= 0) { alertUser("You need to specify an amount bigger than 0"); return; }
395    var itemInfo = $('#foodInfo').data("json");
396 
397
398    for (var i = 0; i < portions.length; ++i) {
399        if (portions[i].checked == true) {
400            var itemPrice = $('#' + portions[i].id).data("price");
401            var portionNames = $('#' + portions[i].id).data("name");
402            pizzaSize = i;
403        }
404    }
405    itemInfo.portion = portionNames;
406    itemInfo.basePrice = parseFloat(itemPrice) * parseInt(amounts);
407    itemInfo.fullPrice = parseFloat(itemPrice) * parseInt(amounts);
408
409    try{
410        var pricez=0;
411        //  for (var i = 0; i < extrasxx.length; ++i) {
412        //      if (extrasxx[i].checked == true) {
413        //          pricez=$(extrasxx[i]).attr('data-price');
414        //          featureBody += '<p class="itemOptions">' + extrasxx[i].value + '</p>';
415        //          featureBody2 +=  extrasxx[i].value +' £'+ pricez +',';
416        //          itemInfo.fullPrice += parseFloat(amounts) * parseFloat(pricez);
417        //          tempBody +=', '+extrasxx[i].value
418        //      }
419        //  }
420
421for (var i = 0; i < extrasxx.length; ++i) {
422
423    var element = extrasxx[i];
424
425    var isCheckedInput = element.checked == true;
426
427    var isSelectedBox =
428        element.tagName == "SELECT" &&
429        element.value != "";
430
431    if (isCheckedInput || isSelectedBox) {
432
433        var rawPrice = 0;
434
435        if (isSelectedBox) {
436
437            rawPrice =
438                $(element)
439                    .find("option:selected")
440                    .attr("data-price") || 0;
441
442        } else {
443
444            rawPrice =
445                $(element).attr("data-price") || 0;
446        }
447
448        pricez = parseFloat(rawPrice);
449
450        if (isNaN(pricez)) {
451            pricez = 0;
452        }
453
454        var priceText =
455            isSelectedBox && pricez > 0
456                ? ' (£' + pricez.toFixed(2) + ')'
457                : '';
458
459        featureBody +=
460            '<p class="itemOptions">' +
461            element.value +
462            priceText +
463            '</p>';
464
465        featureBody2 +=
466            element.value +
467            (isSelectedBox && pricez > 0
468                ? ' £' + pricez.toFixed(2)
469                : '') +
470            ',';
471
472        itemInfo.fullPrice +=
473            parseFloat(amounts) * pricez;
474
475        tempBody += ', ' + element.value;
476    }
477}
478     }catch(e){}
479         attiributes.etoppings += tempBody;
480         attiributes.etoppings = tempBody;
481 
482    var salad1='', tempBody='';
483    if (salads.length > 0) {
484        for (var i = 0; i < salads.length; ++i) {
485            tempName = salads[i].value;
486            if (salads[i].checked == true) {
487                ++countMe;
488                tempBody += ', ' + tempName;
489            }
490            else{
491                salad1=tempName;
492            }
493        }
494        tempBody = tempBody.slice(2);
495        if (countMe == saladNames.length) { tempBody = "All Salads"; }
496        if( countMe==salads.length-1){tempBody = "All Salads <br> No "+salad1;}
497        attiributes.salads = tempBody;
498        if (countMe > 0) {  featureBody += '<p class="itemOptions"><strong>Salads: </strong>' + tempBody + '</p>';}
499    }
500    if (sauces.length > 0) {
501        tempBody = ""; countMe = 0; tempName = "";
502        for (var i = 0; i < sauces.length; ++i) {
503            tempName = sauces[i].value;
504            if (sauces[i].checked == true) {
505                ++countMe;
506                tempBody += ', ' + tempName;
507            }
508        }
509        tempBody = tempBody.slice(2);
510        attiributes.sauces = tempBody;
511        if (countMe > 0) { featureBody += '<p class="itemOptions"><strong>Sauces: </strong> ' + tempBody + '</p>'; }
512    }
513    if (extraCheese == true) {
514        customizedBody += '<p class="itemOptions">Extra Cheese (&#163;' + cheeseprice + ')</p>';
515        attiributes.extraCheese = "yes";
516        itemInfo.fullPrice += parseFloat(amounts) * parseFloat(cheeseprice);
517    }
518    if (specialoffer) {
519        if (specialoffer.length>3) {
520        customizedBody += '<p class="itemOptions">Promotion:'+specialoffer+'</p>';
521        }
522    }
523    if (makeMealSelect == true) {
524        customizedBody += '<p class="itemOptions">Make it Meal (&#163;' + makeMeal + ')</p>';
525        attiributes.makeMeal = "yes";
526        var extraPrices=0;
527        for (var y=0; y<makeMealOptions.length; ++y){
528            customizedBody +='<p class="itemOptions">'+makeMealOptions[y].value+'</p>';
529            if((makeMealOptions[y].value).includes("+")){
530                const match = makeMealOptions[y].value.match(/\+([\d\.]+)/);
531                if (match && match[1]) {
532                    pricex = parseFloat(match[1]);  // Converts the matched price to a float
533                    extraPrices +=pricex;
534                }
535            }
536        }
537        //customizedBody +='<p class="itemOptions">'+$('#mealx1').val()+'</p>';
538        itemInfo.fullPrice += parseFloat(amounts) * (parseFloat(makeMeal)+parseFloat(extraPrices));
539    }
540    if (chipsCheese == true) {
541        customizedBody += '<p class="itemOptions">Cheese on Chips (&#163;' + cheeseprice + ')</p>';
542        attiributes.chipsCheese = "yes";
543        itemInfo.fullPrice += parseFloat(amounts) * parseFloat(cheeseprice);
544    }
545    if (extraBurgerCheese == true) {
546        customizedBody += '<p class="itemOptions">Add Burger Cheese (&#163;' + bcheeseprice + ')</p>';
547        attiributes.extraBurgerCheese = "yes";
548        itemInfo.fullPrice += parseFloat(amounts) * parseFloat(bcheeseprice);
549    }
550    if (nocheeseCheck == true) { featureBody += '<p class="itemOptions">No Cheese</p>';  attiributes.noCheese = "yes";}
551
552    tempBody = ""; attiributes.etoppings = "";
553    for (var i = 0; i < etoppings14.length; ++i) {
554        if (etoppings14[i].checked == true) {
555            featureBody += '<p class="itemOptions">' + etoppings14[i].value + '</p>';
556            itemInfo.fullPrice += parseFloat(amounts) * parseFloat(etoppings3Prices[i]);
557            tempBody +=', '+etoppings14[i].value
558        }
559    }
560    attiributes.etoppings = tempBody;
561
562    tempBody = "<strong>Salad: </strong>";  var tmpcounter=0;
563    for (var i = 0; i < etoppings13.length; ++i) {
564        if (etoppings13[i].checked == true) {
565            tempBody +=etoppings13[i].value +', ';
566            ++tmpcounter;
567        }
568    }
569if(tmpcounter){   featureBody += '<p class="itemOptions"> ' + tempBody.slice(0,-2) + '</p>';}
570   tempBody = ""
571    for (var i = 0; i < etoppings12.length; ++i) {
572        if (etoppings12[i].checked == true) {
573            featureBody += '<p class="itemOptions">' + etoppings12[i].value + '</p>';
574            itemInfo.fullPrice += parseFloat(amounts) * parseFloat(etoppings1Prices[i]);
575            tempBody +=', '+etoppings12[i].value
576        }
577    }
578tempBody = tempBody.slice(2);
579attiributes.etoppings += tempBody;
580tempBody = ""
581
582
583
584for (var i = 0; i < features.length; ++i) {
585
586    var feature = features[i];
587    var isSelect = feature.tagName === "SELECT";
588
589    var isSelected = isSelect
590        ? feature.value !== ""
591        : feature.checked === true;
592
593    if (!isSelected) {
594        continue;
595    }
596
597    var rawPrice;
598
599    if (isSelect) {
600        rawPrice =
601            $(feature).find("option:selected").attr("data-price") || "0";
602    } else {
603        rawPrice = $(feature).data("price") || "0";
604    }
605
606    var pricex = ((rawPrice + "").split("|").pop()).split(",");
607
608    var selectedPrice = parseFloat(pricex[pizzaSize]);
609
610    if (isNaN(selectedPrice)) {
611        selectedPrice = 0;
612    }
613
614    var amountNumber = parseInt(amounts);
615
616    if (isNaN(amountNumber)) {
617        amountNumber = 1;
618    }
619
620    var t1 = (selectedPrice * amountNumber).toFixed(2);
621    var te1 = " ( £" + t1 + ")";
622
623    if (parseFloat(t1) === 0) {
624        t1 = 0;
625        te1 = "";
626    }
627
628    itemInfo.fullPrice += parseFloat(t1);
629
630    customizedBody +=
631        '<p class="itemOptions"><strong class="blacks">' +
632        feature.value +
633        te1 +
634        '</strong></p>';
635
636    tempBody += ", " + feature.value;
637}
638attiributes.extraxyz=tempBody.slice(2);
639
640    if (extraToppings.length > 0) {
641        tempBody = ""; countMe = 0; tempName = "";
642        for (var i = 0; i < toppings.length; ++i) {
643            if (toppings[i].checked == false) {
644                tempBody += 'No ' + toppings[i].value + ', ';
645                ++countMe;
646            }
647        }
648        if (countMe > 0) { 
649            featureBody += '<p class="itemOptions">' + tempBody.slice(0, -2) + '</p>';   attiributes.toppings = tempBody.slice(0, -2);
650        }
651
652        for (var i = 0; i < pbases.length; ++i) {
653            if (pbases[i].checked == true) {
654                customizedBody += '<p class="itemOptions"><strong class="blacks">' + pbases[i].value + '</strong></p>';
655                tempBody +=', '+pbases[i].value;
656            }
657        }
658        tempBody = tempBody.slice(2);
659         attiributes.bases = tempBody;
660        
661        if (stuffedCheck == true) {
662            var stuffedPrice = stuffedPrices[pizzaSize];
663            stuffedPrice = ((Math.round(stuffedPrice * 100) / 100) * parseInt(amounts)).toFixed(2);
664            itemInfo.fullPrice += parseFloat(stuffedPrice);
665            customizedBody += '<p class="itemOptions"><strong>Stuffed Crust (&#163;' + stuffedPrice + ')</strong></p>';
666            attiributes.stuffed = "yes";
667        }
668        
669        if (stuffedCheck2 == true) {
670            var stuffedPrice = stuffedPrices2[pizzaSize];
671            stuffedPrice = ((Math.round(stuffedPrice * 100) / 100) * parseInt(amounts)).toFixed(2);
672            itemInfo.fullPrice += parseFloat(stuffedPrice);
673            customizedBody += '<p class="itemOptions"><strong>Hot Dog Crust (&#163;' + stuffedPrice + ')</strong></p>';
674            attiributes.stuffed = "yes";
675        }
676        tempBody = ""; var countMe2 = 0; tempName = "";
677        for (var i = 0; i < toppingNames.length; ++i) {
678            if (extraToppings[i].checked == true) {
679                tempBody += extraToppings[i].value + ', ';
680                ++countMe2;
681            }
682        }
683        if (countMe2 > 0) {
684            if(swaptop!=1){
685            countMe2 = (parseInt(countMe2) -parseInt(countMe));
686            if(countMe2<0){countMe2=0;}
687        }
688            var extraToppingPrice = parseFloat(toppingPrices[pizzaSize] * countMe2 * parseFloat(amounts));
689            extraToppingPrice = (Math.round(extraToppingPrice * 100) / 100).toFixed(2);
690            if (itemInfo.type.includes("freechoice")) {
691               try{ maximumToppings = parseInt(itemInfo.type.slice(-1)); } catch(e){maximumToppings=4;}
692                if (countMe2 > maximumToppings) {
693                    var top = countMe2 - maximumToppings;
694                    extraToppingPrice = parseFloat(toppingPrices[pizzaSize] * top * parseFloat(amounts));
695                    extraToppingPrice = (Math.round(extraToppingPrice * 100) / 100).toFixed(2);
696                }
697                else {
698                    extraToppingPrice = parseFloat(0).toFixed(2);
699                }
700            }
701            itemInfo.fullPrice += parseFloat(extraToppingPrice);
702            customizedBody += '<p class="itemOptions"><strong>Extra:</strong>' + tempBody.slice(0, -2) + ' (&#163;' + extraToppingPrice + ')</p>';
703            attiributes.extraToppings = tempBody.slice(0, -2);
704        }
705    }
706    if (salt == true) { featureBody += '<p class="itemOptions"><strong>Salt</strong></p>';}
707    if (vinegar == true) { featureBody += '<p class="itemOptions"><strong>Vinegar</strong></p>';} 
708    if (itemInfo.type == "offer") {
709        for (var i = 0; i < offeredItems.length; ++i) {
710            featureBody += '<p class="itemOptions"><strong>Choice : </strong>' + offeredItems[i].value + '</p>';
711        }
712        for (var i = 0; i < optionNames.length; ++i) {
713            featureBody += '<p class="itemOptions"><strong>' + optionNames[i].innerHTML + '</strong></p>';
714            if (optionChoices[i]) {
715                featureBody += optionChoices[i].innerHTML;
716            }
717        }
718    }
719    attiributes.combos="";
720    for (var i = 0; i < comboChoices.length; ++i) {
721        if(comboChoices[i].value=="Click to Choose"){
722            alertUser("Please choose the options required");
723             invokeItem("foodItem"+itemInfo.id);
724             $('.comboItems').css("border","2px solid red");
725             $('body').find('.modal-backdrop').removeClass('modal-backdrop'); 
726            return;
727        }
728        featureBody += '<p class="itemOptions" style="font-weight:700;">' + comboChoices[i].value + '</p>';
729        attiributes.combos +=comboChoices[i].value+', ';
730    }
731    itemInfo.fullPrice = parseFloat(itemInfo.fullPrice);
732    itemInfo.basePrice = parseFloat(itemInfo.basePrice);
733    itemInfo.amount = amounts;
734    itemInfo.pizza = itemInfo.pizza;
735    attiributes.features = featureBody;
736    attiributes.features2=featureBody2;
737    attiributes.additions = customizedBody; 
738    itemInfo.customization = attiributes;
739    itemInfo.menuHeader=menuHeader;
740     
741    var flyFrom = $('#foodItem' + itemInfo.id).closest('div').find('img.menuImage');
742    flyToElement(flyFrom);
743    itemInfo = JSON.stringify(itemInfo);
744   localStorage.setItem(currentLength, itemInfo);
745loadPopUp();
746    sendNumber();
747}
748 
749 
750
751function sendNumber() {
752  const count = getCartKeys().length; // only numeric cart items
753  try { window.webkit.messageHandlers["scriptHandler"].postMessage(String(count)); } catch (e) {}
754}
755
756
757// $(document).on('hide.bs.modal', '#invokeMyModal', function () {
758//     $('body').css('position', '');
759// });
760
761function addOffer(idItem) {
762    var bodyModal = '';
763    var myData = $("#" + idItem).data("json");
764    var tempData = {};
765    try{ myData.portions=myData.portions.split(',');
766    myData.prices=myData.prices.split(',');
767    myData.toppings=myData.toppings.split(',');
768    myData.offers=myData.offers.split(',');
769    myData.offerSizes=myData.offerSizes.split(',');}catch(e){}
770   
771    totalSteps = myData.offers.length;
772    //$('body').css('position', 'fixed');
773    bodyModal += '<div class="modal fade flex3Modal" id="invokeMyModal" role="dialog"><div class="modal-dialog  modal-md">';
774    bodyModal += '<div class="modal-content" style="background:#222020;"><div class="modal-header">';
775    bodyModal += ' <button type="button" class="close_new2x" data-dismiss="modal" aria-label="Close" style="top:10px;">×</button>';
776    bodyModal += '<input type="text"  style="display:none;" id="menuHeader1" value="'+myData.menuHeader+'">';
777
778  
779    var jsons = {}; jsons.itemPrice = myData.prices[0]; jsons.image = myData.image; jsons.name = myData.itemName; jsons.id = idItem.slice(8); jsons.offers = myData.offers; jsons.offerSizes = myData.offerSizes; jsons.cat = myData.cat; jsons.printers=myData.printers; jsons.printers2=myData.printers2; jsons.countz=myData.countz; jsons.conly=myData.conly;  jsons.dable=myData.dable;
780    jsons = JSON.stringify(jsons);
781    bodyModal += '<h4 class="modal-title foodName2" id="foodInformation"  data-json=\'' + jsons + '\' >' + myData.itemName + '</h4>  </div><div class="modal-body">';
782    for (var i = 0; i < myData.offers.length; ++i) {
783        //tempData = $("#foodItem" + myData.offers[i]).data("json");
784
785        if (i == 0) {
786            bodyModal += '<div class="row " style="margin-right:15px; margin-left:9px;  margin-top:10px; align-items:center;" id="mainStep">';
787        }
788        if(myData.offers[i].includes("|")){
789            bodyModal += createPricedItem(myData.offers[i], myData.offerSizes[i], (i + 1));
790        }
791        else{
792            
793            bodyModal += createItem(myData.offers[i], myData.offerSizes[i], (i + 1),myData.itemName);
794        }
795    }
796 
797    for (var i = 1; i <= myData.offers.length; ++i) {
798        bodyModal += '<div class="row stepOptions mealStepHidden" id="stepOption' + i + '" style="display:none;" data-xxx="'+myData.offerSizes[i-1]+'"> This Item Has no Customization</div>';
799    }
800    bodyModal += '</div>';
801    bodyModal += '</div>';
802    /* Modal Body Ends Here*/ /*Modal Footer Starts Here*/
803    bodyModal += '<div class="modal-footer" style="margin-top:5px;">';
804    bodyModal += '<div class="align_prev_next" style=" float:left; margin-left:20px; display:block;" onclick="firstStep();"> <button class="finishedButton" onclick="firstStep()"><svg class="finishedIcon"viewBox="0 0 24 24"aria-hidden="true"><circle cx="12" cy="12" r="9" fill="none" stroke="currentColor" stroke-width="2"/> <path d="M8 12.2l2.6 2.6L16.5 9" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"/></svg><span>FINISHED HERE</span></button>';
805    bodyModal += '</div>';
806    bodyModal += '<button type="text" class="btn btn-default addtobutton"  onclick="offersCart();"   style="padding: 11px 21px;  " id="addOfferButton" >Add to Cart <i class="fa fa-icon-add2x icon-classes-general2"></i></button>';
807    bodyModal += '</div>';
808    /*Footer ends here*/
809    bodyModal += '</div>';
810    bodyModal += '</div>';
811    bodyModal += '</div>';
812    /*End of fade, dialog, content*/
813    $('#modalArea').html(bodyModal);
814    $('#invokeMyModal').modal('show');
815    $('.align_prev_next').hide();
816    //centerInvokeModal();
817}
818
819var currentStep = 1;
820var totalSteps = 0;
821
822 
823
824function prepareItem(itemIds, itemPortion, orders) {
825    var formModal = '';
826    var myData = $("#foodItem" + itemIds).data("json");
827    try{ myData.portions=myData.portions.split(',');
828    myData.prices=myData.prices.split(',');
829    myData.toppings=myData.toppings.split(',');
830    myData.offers=myData.offers.split(',');
831    myData.offerSizes=myData.offerSizes.split(',');}catch(e){}
832    var portionLoc = 0;
833    try { formModal += '<h1 class="headersOffer">
833' + myData.itemName + '</h1>'; } catch (e) { }
834  
835
836    if (myData.pizza != "no") {
837        for (var i = 0; i < myData.portions.length; ++i) {
838
839            if (myData.portions[i].replace('"','') == itemPortion) {
840                portionLoc = i;
841            }
842        }
843
844        var setted = 0;
845        formModal += '<div class="row" style="margin-right: 3px;  margin-left: 3px; display:flex;">';
846        formModal += tableFiller("Toppings");
847        for (var i = 0; i < myData.toppings.length; ++i) {
848            if (myData.toppings.length > 3 && myData.toppings.length / 2 <= i && i != 0 && setted == 0) {
849                formModal += finishTable();
850                formModal += tableFiller("Toppings");
851                ++setted;
852            }
853            formModal += createPizzaToppings("checkbox", myData.toppings[i], "toppings" + orders, i);
854        }
855        formModal += finishTable();
856
857        if(stuffedPrices[0]!="no"){
858            formModal += tableFiller("Customize");
859            if (stuffedPrices[0] != "no") { formModal += createCheckBox("checkbox", "Stuffed Crust", "stuffedCrust" + orders, orders); }
860            if (stuffedPrices2[0] != "no") { formModal += createCheckBox("checkbox", "HotDog Crust", "stuffedCrust2x" + orders, orders); }
861    
862            try{
863                if(bases[0].length>0){
864            for (var i = 0; i < bases.length; ++i) {
865                formModal += createCheckBox4(boxt[i], bases[i], "bases" + orders, i);
866            }
867            }} catch(e){}
868            formModal += finishTable();
869        }
870
871        else{
872            for (var i=0; i<extraTypes.length; ++i){
873                var x= window[extraTypes[i].type];
874                formModal += x(extraTypes[i],i,orders);
875            }
876        }
877       
878
879        // formModal += tableFiller("Customize");
880        // if (stuffedPrices[0] != "no") { formModal += createCheckBox("checkbox", "Stuffed Crust", "stuffedCrust" + orders, orders); }
881        // if (stuffedPrices2[0] != "no") { formModal += createCheckBox("checkbox", "HotDog Crust", "stuffedCrust2x" + orders, orders); }
882
883        // try{
884        //     if(bases[0].length>0){
885        // for (var i = 0; i < bases.length; ++i) {
886        //     formModal += createCheckBox4(boxt[i], bases[i], "bases" + orders, i);
887        // }
888        // }} catch(e){}
889        // formModal += finishTable();
890
891        formModal += '</div>';
892        if(toppingNames.length>10){
893            formModal +='<div class="wrapb"><button type="button" class="btn btn-default footerButtons addtobutton xxenable" id="xyx' + orders + '" onclick="enableExtras(this.id);"  style="text-align: center;width: 100%;">Extra Toppings</button></div>';
894        formModal += ' <div class="row pizzaRow"  style="margin-right: 3px;  margin-left: 5px; display:none;" id="pizzaDivxyx' + orders + '"><input type="text" value="' + portionLoc + '" id="portionLoc' + orders + '" style="display:none;"> <input type="text" value="' + myData.type + '" id="typeLoc' + orders + '" style="display:none;">';
895        }
896        else{
897            formModal += ' <div class="row pizzaRow"  style="margin-right: 3px;  margin-left: 5px;" id="pizzaDivxyx' + orders + '"><input type="text" value="' + portionLoc + '" id="portionLoc' + orders + '" style="display:none;"> <input type="text" value="' + myData.type + '" id="typeLoc' + orders + '" style="display:none;">';
898        }
899
900        var jx=0;
901        for (var i=0; i<arx.length; ++i){
902            formModal += tableFiller("Extra Topping");
903            for (jx; jx<arx[i]; ++jx){
904                formModal += createExtraToppings("checkbox", toppingNames[jx], "extratoppings" + orders, jx);
905            }
906            jx=arx[i];
907            formModal += finishTable();
908        }
909    }
910
911    if (myData.salads == "yes") {
912        // formModal += createSalad("salad"+orders);
913        // for (var i = 0; i < saladNames.length; ++i) {
914        //     formModal += createCheckBox("checkbox", saladNames[i], "salad" + orders, i);
915        // }
916        // formModal += finishTable();
917
918          formModal += createSaladSection(saladNames, orders);
919    }
920    if (myData.etoppings1 == "yes") {
921        formModal += tableFiller("Customize");
922        for (var i = 0; i < etoppings1.length; ++i) {
923            formModal += createCheckBox("checkbox", etoppings1[i], "etoppings1"+orders, i);
924        }
925        formModal += finishTable();
926    }
927    if (myData.etoppings2 == "yes") {
928        formModal += tableFiller("Customize");
929        for (var i = 0; i < etoppings2.length; ++i) {
930            formModal += createCheckBox("checkbox", etoppings2[i], "etoppings2"+orders, i);
931        }
932        formModal += finishTable();
933    }
934  
935    if (myData.sauces == "yes"){
936        if (myData.itemName == "Pot of Sauce" || myData.itemName == "Dips") {
937            formModal += tableFiller("Dip Sauces");
938            for (var i = 0; i < DipNames.length-1; ++i) {
939                formModal += createCheckBox("radio", DipNames[i], "sauce" + orders, i);
940            }
941            formModal += finishTable();
942        }
943        else {
944            formModal += tableFiller("Sauces");
945            for (var i = 0; i < sauceNames.length; ++i) {
946                formModal += createCheckBox5("checkbox", sauceNames[i], "sauce" + orders, i);
947            }
948            formModal += finishTable();
949        }
950        formModal += '</div>';
951    }
952 
953    if (myData.pizza == "no") {
954        var otherCounter = 0;
955        var otherBody = "";
956        if (myData.extraCheese == "yes") {
957            otherBody += createCheckBox("checkbox", "Extra Cheese", "cheese" + orders, "");
958            ++otherCounter;
959        }
960        if (myData.chipsCheese == "yes") {
961            otherBody += createCheckBox("checkbox", "Ex.Cheese (Chips)", "ccheese" + orders, "");
962            ++otherCounter;
963        }
964        if (myData.extraBurgerCheese == "yes") {
965            otherBody += createCheckBox("checkbox", "with Cheese", "excheese" + orders, "");
966            ++otherCounter;
967        }
968        if (myData.saltvinegar == "yes") {
969            otherBody += createCheckBox("checkbox", "Salt", "salt" + orders, "");
970            otherBody += createCheckBox("checkbox", "Vinegar", "vinegar" + orders, "");
971            ++otherCounter;
972        }
973        if (myData.noCheese == "yes") {
974            otherBody += createCheckBox("checkbox", "No Cheese", "nocheese" + orders, "");
975            ++otherCounter;
976        }
977
978        if (myData.etoppings1 == "yes") {
979            for (var i = 0; i < etoppings1.length; ++i) {
980                otherBody += createCheckBox("checkbox", etoppings1[i] + ("(" + etoppings1Prices[i] + ")"), "etoppings1"+orders, i);
981            }
982            ++otherCounter;
983        }
984        if (myData.etoppings3 == "yes") {
985            for (var i = 0; i < etoppings3.length; ++i) {
986                if(etoppings3Prices[i]=="0"){
987                    otherBody += createCheckBox("checkbox", etoppings3[i], "etoppings3"+orders, i);
988
989                }
990                else{
991                    otherBody += createCheckBox("checkbox", etoppings3[i] + ("(" + etoppings3Prices[i] + ")"), "etoppings3"+orders, i);
992                }
993            }
994            ++otherCounter;
995        }
996
997        if (myData.etoppings5 != "no" && myData.etoppings5) {
998 
999        var toppingz = (myData.etoppings5).split(',');
1000
1001for (var i = 0; i < toppingz.length; ++i) {
1002
1003    let tops = extraAll.find(({ id }) => id == toppingz[i]);
1004
1005    if (!tops) {
1006        continue;
1007    }
1008
1009    var topType = String(tops.type || "").trim();
1010
1011    if (topType == "selectBox") {
1012
1013        otherBody += createSelectBox(
1014            tops.extra,
1015            "extrasxx" + orders,
1016            i,
1017            tops.price,
1018            topType
1019        );
1020
1021    } else if (tops.price == "0") {
1022
1023        otherBody += createCheckBox3(
1024            "checkbox",
1025            tops.extra,
1026            "extrasxx" + orders,
1027            i,
1028            tops.price,
1029            topType
1030        );
1031
1032    } else {
1033
1034        otherBody += createCheckBox3(
1035            "checkbox",
1036            tops.extra + " (" + tops.price + ")",
1037            "extrasxx" + orders,
1038            i,
1039            tops.price,
1040            topType
1041        );
1042    }
1043}
1044            ++otherCounter;
1045        } 
1046 
1047        if (otherCounter > 0) {
1048            formModal += tableFiller("Other");
1049            formModal += otherBody;
1050            formModal += finishTable();
1051        }
1052    }
1053    formModal += '</div>';
1054    return formModal;
1055}
1056 
1057function bringSelected(stepNumber, portionItem,itemid) {
1058
1059    
1060    var stepThumbs = "itemOptionsStep" + stepNumber;
1061    $('#' + stepThumbs).show();
1062    $('#offerName' + stepNumber).css('border', 'none');
1063    var selectedOne = $('#offerName' + stepNumber).val();
1064    var testy = $(".itemNames[listname='" + selectedOne + "']");
1065    var itemIds = $(testy).attr('itemid');
1066
1067    if(itemid!="no"){
1068        itemIds=itemid;
1069    }
1070    try { var myModal = prepareItem(itemIds, portionItem, stepNumber); } catch (e) { }
1071    //$('#stepOption' + stepNumber).html(myModal);
1072
1073    $('#stepOption' + stepNumber)
1074    .html(myModal)
1075    .attr('data-loaded', 'true');
1076}
1077
1078// function revealStep(stepNumber) {
1079//     $('.align_prev_next').show();
1080//     if(!$('#offerName'+stepNumber).val()){
1081//         alertUser("Please choose an item and press customize");
1082//         $('#offerName'+stepNumber).css('border', '3px solid red');
1083//         return;
1084//     }
1085//     var showStep = "stepOption" + stepNumber;
1086//     $('.steps').hide();
1087//     $('.stepOptions').hide();
1088//     $('#addOfferButton').hide();
1089//     $('#' + showStep).css('display', 'block');
1090//     $('.mmealdiv').hide();
1091//     //$('.stepOptions').removeClass('activeOption');
1092//     //$('#' + showStep).addClass('activeOption');
1093// }
1094
1095function revealStep(stepNumber, itemPortion, itemid) {
1096    $('.align_prev_next').show();
1097
1098    if (!$('#offerName' + stepNumber).val()) {
1099        alertUser(
1100            "Please choose an item and press customize"
1101        );
1102
1103        $('#offerName' + stepNumber).css(
1104            'border',
1105            '3px solid red'
1106        );
1107
1108        return;
1109    }
1110
1111    var showStep = "stepOption" + stepNumber;
1112
1113    /*
1114     * Load the customisation content only when required.
1115     */
1116    if ($('#' + showStep).attr('data-loaded') != 'true') {
1117        bringSelected(
1118            stepNumber,
1119            itemPortion,
1120            itemid
1121        );
1122
1123        $('#' + showStep).attr(
1124            'data-loaded',
1125            'true'
1126        );
1127    }
1128
1129    /*
1130     * Hide only the six main selection rows.
1131     * Do not hide #mainStep because stepOptions are inside it.
1132     */
1133    $('.offer-step-row').addClass(
1134        'offer-step-hidden'
1135    );
1136
1137    $('.stepOptions').hide();
1138
1139    $('#' + showStep).css(
1140        'display',
1141        'block'
1142    );
1143
1144    $('#addOfferButton').hide();
1145    $('.mmealdiv').hide();
1146}
1147
1148function firstStep() {
1149    /*
1150     * Restore the six Meal Deal rows.
1151     */
1152    $('.offer-step-row').removeClass(
1153        'offer-step-hidden'
1154    );
1155
1156    $('.stepOptions').hide();
1157
1158    $('#mainStep').show();
1159    $('#addOfferButton').show();
1160
1161    $('.align_prev_next').hide();
1162}
1163
1164 
1165
1166 function createItem(itemIds, itemPortion, orders, itemName) {
1167    currentStep = 1;
1168
1169    var formModal = "";
1170    var itemid = "no";
1171    var itemIdsText = String(itemIds);
1172
1173    if (parseInt(itemIds)) {
1174        itemid = itemIds;
1175    }
1176
1177    var isItemGroup =
1178        itemIdsText == "Pizza" ||
1179        itemIdsText == "Kebab" ||
1180        itemIdsText == "Sides" ||
1181        itemIdsText == "Bottle" ||
1182        itemIdsText == "Can" ||
1183        itemIdsText == "Dip" ||
1184        itemIdsText == "Kids" ||
1185        itemIdsText == "Other" ||
1186        itemIdsText == "Otherx" ||
1187        itemIdsText.includes("Eextra") ||
1188        itemIdsText.includes("Elist");
1189
1190    /*
1191     * Keep the "steps" class because firstStep() and revealStep()
1192     * use it. The new offer-step-row class controls the layout.
1193     */
1194    formModal +=
1195        '<div class="steps offer-step-row" id="step' +
1196        orders +
1197        '">';
1198
1199    formModal +=
1200        '<input id="itemPortionz' +
1201        orders +
1202        '" value="' +
1203        itemPortion +
1204        '" style="display:none;">';
1205
1206    /*
1207     * Step number
1208     */
1209    formModal +=
1210        '<div class="offer-step-number stepNumbers">' +
1211        orders +
1212        ".</div>";
1213
1214    /*
1215     * Category/group choice:
1216     * Pizza, Kebab, Sides, Can, etc.
1217     */
1218    if (isItemGroup) {
1219        var items = window[itemIdsText + "Names"] || [];
1220
1221        formModal += '<div class="offer-step-select">';
1222
1223        formModal +=
1224            '<select class="form-control itemOffers" ' +
1225            'id="offerName' +
1226            orders +
1227            '" ' +
1228            'onchange="bringSelected(\'' +
1229            orders +
1230            "','" +
1231            itemPortion +
1232            "','" +
1233            itemid +
1234            "');\">";
1235
1236        formModal +=
1237            '<option value="" disabled selected hidden>' +
1238            "Please Choose..." +
1239            "</option>";
1240
1241        for (var i = 0; i < items.length; ++i) {
1242            formModal +=
1243                '<option value="' +
1244                items[i] +
1245                '">' +
1246                items[i] +
1247                "</option>";
1248        }
1249
1250        formModal += "</select>";
1251        formModal += "</div>";
1252
1253        /*
1254         * Customize button
1255         */
1256        formModal += '<div class="offer-step-customize">';
1257
1258    formModal +=
1259    '<button type="button" class="offer-customize-button" ' +
1260    "onclick=\"revealStep('" +
1261    orders +
1262    "','" +
1263    itemPortion +
1264    "','" +
1265    itemid +
1266    "')\">" +
1267    "Customize" +
1268    "</button>";
1269
1270        formModal += "</div>";
1271    }
1272
1273    /*
1274     * Fixed individual item
1275     */
1276    else {
1277        var myData = $("#foodItem" + itemIds).data("json");
1278
1279        if (!myData || !myData.itemName) {
1280            sendSystemLog(
1281                "Offer item unavailable | ID: " +
1282                itemIds +
1283                " | Portion: " +
1284                itemPortion +
1285                " | Step: " +
1286                orders +
1287                " | ItemName: " +
1288                itemName,
1289                itemName
1290            );
1291
1292            return "";
1293        }
1294
1295        formModal += '<div class="offer-step-select">';
1296
1297        formModal +=
1298            '<select class="form-control itemOffers" ' +
1299            'id="offerName' +
1300            orders +
1301            '" ' +
1302            'onchange="bringSelected(\'' +
1303            orders +
1304            "','" +
1305            itemPortion +
1306            "','" +
1307            itemid +
1308            "');\">" +
1309            '<option value="' +
1310            myData.itemName +
1311            '" selected>' +
1312            myData.itemName +
1313            "</option>" +
1314            "</select>";
1315
1316        formModal += "</div>";
1317
1318        /*
1319         * Customize button
1320         */
1321        formModal += '<div class="offer-step-customize">';
1322
1323        formModal +=
1324            '<button type="button" class="offer-customize-button" ' +
1325            "onclick=\"revealStep('" +
1326            orders +
1327            "','" +
1328            itemPortion +
1329            "','" +
1330            itemid +
1331            "')\">" +
1332            "Customize" +
1333            "</button>";
1334
1335        formModal += "</div>";
1336    }
1337
1338    /*
1339     * Completed/customised status icon
1340     */
1341    formModal += '<div class="offer-step-status">';
1342
1343    formModal +=
1344        '<div id="itemOptionsStep' +
1345        orders +
1346        '" style="display:none;">' +
1347        '<i class="fa fa-icon-steps icon-basket-general"></i>' +
1348        "</div>";
1349
1350    formModal += "</div>";
1351
1352    formModal += "</div>";
1353
1354    return formModal;
1355}
1356
1357function sendSystemLog(message,itemName) {
1358
1359    var sendData={};
1360    sendData.message=message;
1361    sendData.itemName=itemName;
1362
1363    try {
1364        $.ajax({
1365            url: "/client-log",
1366            type: "POST",
1367            contentType: "application/json",
1368            data: JSON.stringify({
1369                message: sendData
1370            }),
1371            timeout: 3000
1372        });
1373    } catch (e) {}
1374}
1375
1376function createPricedItem(itemIds, itemPortion, orders) {
1377    currentStep = 1;
1378    var formModal = '', newItem=itemIds;
1379    
1380 
1381    formModal += '<div class="row steps" style="margin-right:3px; margin-left:-14px;   align-items:center;" id="step' + orders + '">';
1382    formModal += '<input id="itemPortionz' + orders + '" value="' + itemPortion + '" style="display:none;">';
1383var itemid="no";
1384 
1385try{
1386if(itemIds.includes("|")){
1387    newItem=itemIds;
1388    itemIds=itemIds.replace("|","");
1389}
1390
1391
1392}catch(e){}
1393if(parseInt(itemIds)){
1394    itemid=itemIds;
1395}
1396    if (itemIds == "Pizza" || itemIds == "Kebab" || itemIds == "Sides" || itemIds == "Bottle" || itemIds == "Can" || itemIds == "Dip" || itemIds == "Kids" || itemIds == "Other" || itemIds == "Otherx" || itemIds.includes("Eextra") || itemIds.includes("Elist")) {
1397        var items = window[itemIds + 'Names'];
1398        formModal += '<div class="col-xs-1 stepNumbers">' + orders + '. </div> <div class="col-xs-6 modalMenuDetails"><select class="form-control itemOffers" style="padding:6px; min-width:134px;" id="offerName' + orders + '" onchange="bringSelected(\'' + orders + '\',\'' + itemPortion + '\',\'' + itemid + '\');">';
1399        formModal += '<option value="" disabled selected hidden>Please Choose...</option>';
1400
1401        if(newItem.includes('|')){
1402            for (var i = 0; i < items.length; ++i) {
1403                var pricex=0;
1404                try {pricex=getPriceByNameAndPortion(items[i],itemPortion);}catch(e){pricex=0;}
1405                formModal += '<option value="'+items[i]+'" data-price="'+pricex+'">' + items[i] + ' ('+pricex+')</option>';
1406            }
1407        }
1408        else{
1409            for (var i = 0; i < items.length; ++i) {
1410                formModal += '<option value="'+items[i]+'" >' + items[i] + '</option>';
1411            }
1412        }
1413        
1414        formModal += ' </select></div>';
1415        formModal += '<div class="col-xs-3 modalMenuDetails"><h4 class="sub-header cxheader"    onclick="revealStep(' + orders + ')">Customize</h4></div>';
1416        formModal += '<div class="col-xs-2 modalMenuDetails"><div id="itemOptionsStep' + orders + '" style="display:none;"><i class="fa fa-icon-steps icon-basket-general"  ></i></div> ';
1417        formModal += '</div>';
1418    }
1419    else {
1420        var myData = $("#foodItem" + itemIds).data("json");
1421        formModal += '<div class="col-xs-1 stepNumbers">' + orders + '. </div> <div class="col-xs-6 modalMenuDetails"><select class="form-control itemOffers" style="padding:6px; min-width:134px;" id="offerName' + orders + '" onchange="bringSelected(\'' + orders + '\',\'' + itemPortion + '\',\'' + itemid + '\');">';
1422        formModal += '<option value="" disabled selected hidden>Please Choose...</option>';
1423        formModal += '<option value="'+myData.itemName+'">' + myData.itemName + '</option>';
1424        formModal += ' </select></div>';
1425        formModal += '<div class="col-xs-3 modalMenuDetails"><h4 class="sub-header cxheader"   onclick="revealStep(' + orders + ')">Customize</h4></div>';
1426        formModal += '<div class="col-xs-2 modalMenuDetails"><div id="itemOptionsStep' + orders + '" style="display:none;"><i class="fa fa-icon-steps icon-basket-general"  ></i></div> ';
1427        formModal += '</div>';
1428    }
1429    formModal += '</div>';
1430    return formModal;
1431}
1432
1433function getPriceByNameAndPortion(itemName, portion) {
1434    // Find the element that matches the item name
1435    const itemEl = document.querySelector(
1436      `.wrapItems[data-json*='"itemName":"${itemName}"']`
1437    );
1438    if (!itemEl) return null;
1439  
1440    // Parse the JSON in data-json
1441    const json = JSON.parse(itemEl.getAttribute("data-json").replace(/&quot;/g, '"'));
1442  
1443    // Split portions and prices into arrays
1444    const portions = json.portions.split(",");
1445    const prices = json.prices.split(",");
1446  
1447    // Find index of the requested portion
1448    const idx = portions.indexOf(String(portion));
1449    if (idx === -1) return null;
1450  
1451    return prices[idx];
1452  }
1453
1454
1455  //offerprice
1456function offersCart() {
1457    var currentLength = localStorage.length + 1; while (localStorage.getItem(currentLength) != null) { ++currentLength; }
1458    var pizzaSize = 0, countMe = 0, itemtype = "regular",tempBody = "", tempName = "", offerText="", offerProp="";
1459    var itemInfo = $("#foodInformation").data("json");
1460    itemInfo.typex="no";
1461    itemInfo.divider=0;
1462    var totalPrice = 0, basePrice = 0;
1463    totalPrice = parseFloat(itemInfo.itemPrice);
1464    basePrice = parseFloat(itemInfo.itemPrice);
1465    var featureBody = "", customizedBody = "";
1466 
1467   try{ var name = document.getElementById("forwho").value;
1468
1469    if(name!="nonex"){
1470        featureBody += '<p class="itemOptions" >
1470For:' + name + '</p>';
1471    }}catch(e){}
1472
1473    let offerDetails = []; // store all offer subtotals
1474 
1475    for (var j = 0; j < itemInfo.offers.length; ++j) {
1476
1477       
1478        var extraCheese = false;
1479        var chipsCheese = false;
1480        var nocheeseCheck = false;
1481        var extraBurgerCheese = false;
1482        var stuffedCheck = false;
1483        var stuffedCheck2 = false;
1484        var salt = false;
1485        var vinegar = false;
1486        var itemName = "";
1487        var idget = "offerName" + (j + 1);
1488        var nota = (j + 1).toString();
1489
1490        var xy1 = document.getElementById("stepOption" + nota);
1491        try { itemName = document.getElementById(idget).value; } catch (e) { }
1492        if (itemName == "") {
1493            $('#' + idget).css('border', '3px solid red');
1494            alertUser("You Must Select All Items");
1495            return;
1496        }
1497    
1498        // get inner text (like "Margherita")
1499        let selectEl = document.getElementById(idget);
1500        let optionEl = selectEl.options[selectEl.selectedIndex];
1501    
1502        // Option value (if you set value="")
1503        let itemValue = optionEl.value;
1504    
1505        // Any custom attribute, like data-price
1506        let price = optionEl.getAttribute("data-price");
1507        let price2 = optionEl.dataset.price;
1508    
1509        let basePrice = parseFloat(price2 || 0);
1510        let itemSubtotal = basePrice;
1511 
1512        if (itemName == undefined) { itemName = document.getElementById(idget).innerHTML; }
1513        var salads = xy1.getElementsByClassName("salad" + nota);
1514        var sauces = xy1.getElementsByClassName("sauce" + nota);
1515        var toppings = xy1.getElementsByClassName("toppings" + nota);
1516        var extraToppings = xy1.getElementsByClassName("extratoppings" + nota);
1517        var pbases = xy1.getElementsByClassName("bases" + nota);
1518        var etoppings12 = xy1.getElementsByClassName("etoppings1" + nota);
1519        var etoppings13 = xy1.getElementsByClassName("etoppings2" + nota);
1520        var etoppings14 = xy1.getElementsByClassName("etoppings3" + nota);
1521        var extrasxx = xy1.getElementsByClassName("extrasxx" + nota);
1522        var allextras = xy1.getElementsByClassName("typexyz");
1523    
1524        pizzaSize = $('#portionLoc' + nota).val();
1525        itemtype = $('#typeLoc' + nota).val();
1526        pizzaSize = pizzaSize ? pizzaSize : 0;
1527    
1528        featureBody += '<div class="wrapOfferItems" style="margin-bottom:2px;" ><h6 class="cartItemNames" >' + itemName + ' ' + itemInfo.offerSizes[j] + '</h6>';
1529        offerText += itemName + ' ' + itemInfo.offerSizes[j] + ',';
1530        try { extraCheese = (xy1.getElementsByClassName("cheese" + nota))[0].checked; } catch (e) { }
1531        try { chipsCheese = (xy1.getElementsByClassName("ccheese" + nota))[0].checked; } catch (e) { }
1532        try { nocheeseCheck = (xy1.getElementsByClassName("nocheese" + nota))[0].checked; } catch (e) { }
1533        try { extraBurgerCheese = (xy1.getElementsByClassName("excheese" + nota))[0].checked; } catch (e) { }
1534        try { stuffedCheck = (xy1.getElementsByClassName("stuffedCrust" + nota))[0].checked; } catch (e) { }
1535        try { stuffedCheck2 = (xy1.getElementsByClassName("stuffedCrust2x" + nota))[0].checked; } catch (e) { }
1536        try { salt = (xy1.getElementsByClassName("salt" + nota))[0].checked; } catch (e) { }
1537        try { vinegar = (xy1.getElementsByClassName("vinegar" + nota))[0].checked; } catch (e) { }
1538        try { var menuHeader = document.getElementById("menuHeader1").value; } catch (e) { }
1539        var salad1 = "", attiributes = {};
1540    
1541  for (var i = 0; i < allextras.length; ++i) {
1542
1543    var extra = allextras[i];
1544    var isSelect = extra.tagName === "SELECT";
1545
1546    var isSelected = isSelect
1547        ? extra.value !== ""
1548        : extra.checked === true;
1549
1550    if (!isSelected) {
1551        continue;
1552    }
1553
1554    var rawPrice;
1555
1556    if (isSelect) {
1557        rawPrice =
1558            $(extra).find("option:selected").attr("data-price") || "0";
1559    } else {
1560        rawPrice = $(extra).data("price") || "0";
1561    }
1562
1563    var pricex = ((rawPrice + "").split("|").pop()).split(",");
1564
1565    var selectedPrice = parseFloat(pricex[pizzaSize]);
1566
1567    if (isNaN(selectedPrice)) {
1568        selectedPrice = 0;
1569    }
1570
1571    var t1 = selectedPrice.toFixed(2);
1572    var te1 = " ( £" + t1 + ")";
1573
1574    if (selectedPrice === 0) {
1575        t1 = 0;
1576        te1 = "";
1577    }
1578
1579    totalPrice += parseFloat(t1);
1580    itemSubtotal += parseFloat(t1);
1581
1582    featureBody +=
1583        '<p class="itemOptions"><strong class="blacks">' +
1584        extra.value +
1585        te1 +
1586        '</strong></p>';
1587
1588    tempBody += ", " + extra.value;
1589}
1590    
1591        if (salads.length > 0) {
1592            tempBody = ""; countMe = 0; tempName = "";
1593            for (var i = 0; i < salads.length; ++i) {
1594                tempName = salads[i].value;
1595                if (salads[i].checked == true) {
1596                    ++countMe;
1597                    tempBody += ', ' + tempName;
1598                }
1599                else {
1600                    salad1 = tempName;
1601                }
1602            }
1603            tempBody = tempBody.slice(2);
1604            if (countMe == saladNames.length) { tempBody = "All Salads"; }
1605            if (countMe == salads.length - 1) { tempBody = "All Salads <br> No " + salad1; }
1606            if (countMe > 0) {
1607                featureBody += '<p class="itemOptions"><strong>Salads: </strong>' + tempBody + '</p>';
1608                offerProp += 'Salads: </strong>' + tempBody + '|';
1609            }
1610        }
1611        tempBody = ""; var tmpcounter = 0;
1612        attiributes.etoppings = "";
1613    
1614        for (var i = 0; i < etoppings14.length; ++i) {
1615            if (etoppings14[i].checked == true) {
1616                tempBody += etoppings14[i].value + ', ';
1617                totalPrice += parseFloat(etoppings3Prices[i]);
1618                itemSubtotal += parseFloat(etoppings3Prices[i]);
1619                ++tmpcounter;
1620                offerProp += tempBody;
1621            }
1622        }
1623    
1624        if (tmpcounter > 0) { offerProp += '|'; }
1625    
1626        tempBody = ""; var tmpcounter = 0;
1627        try {
1628            var pricez = 0;
1629for (var i = 0; i < extrasxx.length; ++i) {
1630
1631    var element = extrasxx[i];
1632
1633    var isCheckedInput = element.checked == true;
1634
1635    var isSelectedBox =
1636        element.tagName == "SELECT" &&
1637        element.value != "";
1638
1639    if (isCheckedInput || isSelectedBox) {
1640
1641        var rawPrice = 0;
1642
1643        if (isSelectedBox) {
1644
1645            rawPrice =
1646                $(element)
1647                    .find("option:selected")
1648                    .attr("data-price") || 0;
1649
1650        } else {
1651
1652            rawPrice =
1653                $(element).attr("data-price") || 0;
1654        }
1655
1656        pricez = parseFloat(rawPrice);
1657
1658        if (isNaN(pricez)) {
1659            pricez = 0;
1660        }
1661
1662        var priceText =
1663            isSelectedBox && pricez > 0
1664                ? ' (£' + pricez.toFixed(2) + ')'
1665                : '';
1666
1667        featureBody +=
1668            '<p class="itemOptions">' +
1669            element.value +
1670            priceText +
1671            '</p>';
1672
1673        totalPrice += pricez;
1674
1675        itemSubtotal += pricez;
1676
1677        tempBody +=
1678            ', ' +
1679            element.value;
1680
1681        ++tmpcounter;
1682
1683        offerProp += tempBody;
1684    }
1685}
1686        } catch (e) { }
1687        if (tmpcounter > 0) { offerProp += '|'; }
1688    
1689        tempBody = "<strong>Salad: </strong>"; tmpcounter = 0;
1690        for (var i = 0; i < etoppings13.length; ++i) {
1691            if (etoppings13[i].checked == true) {
1692                tempBody += etoppings13[i].value + ', ';
1693                ++tmpcounter;
1694            }
1695        }
1696        if (tmpcounter > 0) { featureBody += '<p class="itemOptions"> ' + tempBody.slice(0, -2) + '</p>'; }
1697        tempBody = ""
1698        for (var i = 0; i < etoppings12.length; ++i) {
1699            if (etoppings12[i].checked == true) {
1700                featureBody += '<p class="itemOptions">' + etoppings12[i].value + '</p>';
1701                totalPrice += parseFloat(etoppings1Prices[i]);
1702                itemSubtotal += parseFloat(etoppings1Prices[i]);
1703                tempBody += ', ' + etoppings12[i].value
1704            }
1705        }
1706        tempBody = tempBody.slice(2);
1707    
1708        if (sauces.length > 0) {
1709            tempBody = ""; countMe = 0; tempName = "";
1710            for (var i = 0; i < sauces.length; ++i) {
1711                tempName = sauces[i].value;
1712                if (sauces[i].checked == true) {
1713                    ++countMe;
1714                    tempBody += ', ' + tempName;
1715                }
1716            }
1717            tempBody = tempBody.slice(2);
1718            if (countMe > 0) { featureBody += '<p class="itemOptions"><strong>Sauces:</strong>' + tempBody + '</p>'; }
1719        }
1720        if (extraCheese == true) {
1721            featureBody += '<p class="itemOptions">Extra Cheese (&#163;' + cheeseprice + ')</p>';
1722            totalPrice += parseFloat(cheeseprice);
1723            itemSubtotal += parseFloat(cheeseprice);
1724            offerProp += 'Extra Cheese (£' + cheeseprice + ')|';
1725        }
1726        if (chipsCheese == true) {
1727            featureBody += '<p class="itemOptions">Extra Cheese on Chips (&#163;' + cheeseprice + ')</p>';
1728            totalPrice += parseFloat(cheeseprice);
1729            itemSubtotal += parseFloat(cheeseprice);
1730            offerProp += 'Extra Cheese on Chips (£' + cheeseprice + ')|';
1731        }
1732        if (extraBurgerCheese == true) {
1733            featureBody += '<p class="itemOptions">Add Burger Cheese (&#163;' + bcheeseprice + ')</p>';
1734            totalPrice += parseFloat(bcheeseprice);
1735            itemSubtotal += parseFloat(bcheeseprice);
1736            offerProp += 'Add Burger Cheese (£' + bcheeseprice + ')|';
1737        }
1738        if (nocheeseCheck == true) { featureBody += '<p class="itemOptions">No Cheese</p>'; offerProp += 'No Cheese|'; }
1739        if (extraToppings.length > 0) {
1740            for (var i = 0; i < pbases.length; ++i) {
1741                if (pbases[i].checked == true) {
1742                    featureBody += '<p class="itemOptions"><strong class="blacks">' + pbases[i].value + '</strong></p>';
1743                    offerProp += pbases[i].value + '|';
1744                }
1745            }
1746            if (stuffedCheck == true) {
1747                var stuffedPrice = stuffedPrices[pizzaSize];
1748                stuffedPrice = (Math.round(stuffedPrice * 100) / 100).toFixed(2);
1749                totalPrice += parseFloat(stuffedPrice);
1750                itemSubtotal += parseFloat(stuffedPrice);
1751                featureBody += '<p class="itemOptions"><strong>Stuffed Crust (£' + stuffedPrice + ')</strong></p>';
1752                attiributes.stuffed = "yes";
1753                offerProp += 'Stuffed Crust (£' + stuffedPrice + ')|';
1754            }
1755    
1756            if (stuffedCheck2 == true) {
1757                var stuffedPrice = stuffedPrices2[pizzaSize];
1758                stuffedPrice = (Math.round(stuffedPrice * 100) / 100).toFixed(2);
1759                totalPrice += parseFloat(stuffedPrice);
1760                itemSubtotal += parseFloat(stuffedPrice);
1761                featureBody += '<p class="itemOptions"><strong>Hot Dog Crust (£' + stuffedPrice + ')</strong></p>';
1762                attiributes.stuffed = "yes";
1763                offerProp += 'Hot Dog Crust  (£' + stuffedPrice + ')|';
1764            }
1765    
1766            tempBody = ""; countMe = 0; tempName = "";
1767            for (var i = 0; i < toppings.length; ++i) {
1768                if (toppings[i].checked == false) {
1769                    tempBody += 'No ' + toppings[i].value + ', ';
1770                    ++countMe;
1771                }
1772            }
1773            if (countMe > 0) {
1774                featureBody += '<p class="itemOptions">' + tempBody.slice(0, -2) + '</p>';
1775                offerProp += tempBody.slice(0, -2) + '|';
1776            }
1777    
1778            tempBody = ""; var countMe2 = 0; tempName = "";
1779            for (var i = 0; i < toppingNames.length; ++i) {
1780                if (extraToppings[i].checked == true) {
1781                    tempBody += extraToppings[i].value + ', ';
1782                    ++countMe2;
1783                }
1784            }
1785    
1786            if (countMe2 > 0) {
1787                countMe2 = parseInt(countMe2) - parseInt(countMe);
1788                if (countMe2 < 0) { countMe2 = 0; }
1789                var extraToppingPrice = parseFloat(toppingPrices[pizzaSize] * countMe2);
1790                extraToppingPrice = (Math.round(extraToppingPrice * 100) / 100).toFixed(2);
1791                if (itemtype.includes("freechoice")) {
1792                    try { maximumToppings = parseInt(itemtype.slice(-1)); } catch (e) { maximumToppings = 4; }
1793    
1794                    if (countMe2 > maximumToppings) {
1795                        var top = countMe2 - maximumToppings;
1796                        extraToppingPrice = parseFloat(toppingPrices[pizzaSize] * top);
1797                        extraToppingPrice = (Math.round(extraToppingPrice * 100) / 100).toFixed(2);
1798                    }
1799                    else {
1800                        extraToppingPrice = parseFloat(0).toFixed(2);
1801                    }
1802                }
1803                totalPrice += parseFloat(extraToppingPrice);
1804                itemSubtotal += parseFloat(extraToppingPrice);
1805                featureBody += '<p class="itemOptions"><strong>Extra:</strong>' + tempBody.slice(0, -2) + ' (£' + extraToppingPrice + ')</p>';
1806    
1807                attiributes.extraToppings = tempBody.slice(0, -2);
1808                offerProp += "Extras: " + tempBody.slice(0, -2) + '|';
1809            }
1810        }
1811        if (salt == true) { featureBody += '<p class="itemOptions"><strong>Salt</strong></p>'; offerProp += 'Salt|'; }
1812        if (vinegar == true) { featureBody += '<p class="itemOptions"><strong>Vinegar</strong></p>'; offerProp += 'Vinegar|'; }
1813        featureBody += '</div>';
1814    
1815        offerProp += '~';
1816    
1817        // Save this offer
1818        offerDetails[j] = {
1819            name: itemName,
1820            size: itemInfo.offerSizes[j],
1821            subtotal: itemSubtotal
1822        };
1823    }
1824    
1825    // dd
1826
1827    if (itemInfo.offers[0].includes("|")) {
1828        let minIndex = 0;
1829        for (let i = 1; i < offerDetails.length; i++) {
1830            if (offerDetails[i].subtotal < offerDetails[minIndex].subtotal) {
1831                minIndex = i;
1832            }
1833        }
1834    
1835        // ✅ New price = sum of all except cheapest
1836        let newTotal = 0;
1837        for (let i = 0; i < offerDetails.length; i++) {
1838            if (i !== minIndex) {
1839                newTotal += offerDetails[i].subtotal;
1840            }
1841        }
1842        totalPrice = newTotal;
1843    
1844        // Mark cheapest item as FREE
1845        featureBody = featureBody.replace(
1846            new RegExp(offerDetails[minIndex].name + ' ' + offerDetails[minIndex].size, 'i'),
1847            offerDetails[minIndex].name + ' ' + offerDetails[minIndex].size + ' - FREE'
1848        );
1849    }
1850    
1851    
1852      
1853    
1854    $('#invokeMyModal').modal('hide');
1855    itemInfo.portion = " ";
1856    itemInfo.fullPrice = parseFloat(totalPrice);
1857    itemInfo.basePrice = parseFloat(basePrice);
1858    itemInfo.amount = 1;
1859    itemInfo.pizza = "no";
1860 
1861 try{
1862    var xyz1=(offerText.slice(0,-1)).split(',');
1863    var xyz2=(offerProp.slice(0,-1)).split('~');
1864   
1865    var xyz4="";
1866    var tempxy="";
1867
1868    for (var i=0; i<xyz1.length; ++i){
1869        xyz4 +='<LEFT><SMALL><MEDIUM3>'+xyz1[i]+'<BR>';
1870        tempxy=xyz2[i].split('|');
1871
1872        for (var j=0; j<tempxy.length; ++j){
1873            xyz4 +='<LEFT> '+tempxy[j] +'<BR>';  // new line
1874        }
1875    }
1876
1877    itemInfo.offersx=xyz4;
1878}catch(e){}
1879    attiributes.features = featureBody;
1880    attiributes.additions = customizedBody;
1881    itemInfo.customization = attiributes;
1882    itemInfo.menuHeader = menuHeader;
1883   
1884    var flyFrom = $('#foodItem' + itemInfo.id).closest('div').find('img.menuImage');
1885    flyToElement(flyFrom);
1886    itemInfo = JSON.stringify(itemInfo);
1887  
1888
1889    localStorage.setItem(currentLength, itemInfo);
1890loadPopUp();
1891
1892    sendNumber();
1893 
1894}
1895
1896function enableExtras(idItem){
1897    if($('#pizzaDiv'+idItem).is(":hidden")){
1898        $('#pizzaDiv'+idItem).show();
1899        $('#'+idItem).html("Hide Toppings ▴").css('background','#0659b8ff');
1900    }
1901    else{
1902        $('#pizzaDiv'+idItem).hide();
1903        $('#'+idItem).html("Extra Toppings ▾").css('background','#009908ff');   
1904    }
1905
1906     setTimeout(centerInvokeModal, 0);
1907}
1908
1909function invokeItem(myId) {
1910
1911  try{  var formModal = "", offerBody = "",marker=0, nchoice=0, my
1911Data={};
1912     myData = $("#" + myId).data("json");
1913  
1914 
1915    try{ myData.portions=myData.portions.split(',');
1916     myData.prices=myData.prices.split(',');
1917     myData.toppings=myData.toppings.split(',');
1918     myData.offers=myData.offers.split(',');
1919     myData.offerSizes=myData.offerSizes.split(',');}catch(e){}
1920
1921    if (myData.type == "offer") {
1922        addOffer(myId);
1923        return;
1924    }
1925     
1926    //$('body').css('position', 'fixed');
1927    formModal += '<div class="modal fade flex3Modal" id="invokeMyModal" role="dialog"  ><div class="modal-dialog  modal-md">';
1928    formModal += '<div class="modal-content" style="background:#222020;"><div class="modal-header">';
1929    formModal += '<button type="button" class="close_new2x" data-dismiss="modal" aria-label="Close" style="top:10px;"> × </button>';
1930    formModal += '<input type="text"  style="display:none;" id="menuHeader1" value="'+myData.menuHeader+'" >';
1931
1932    var jsons = {}; jsons.image = myData.image; jsons.name = myData.itemName; jsons.id = myId.slice(8); jsons.type = myData.type; jsons.pizza = myData.pizza; try{jsons.cat = myData.cat;}catch(e){jsons.cat = myData.Cat;} jsons.printers=myData.printers; jsons.printers2=myData.printers2; jsons.typex=myData.typex; jsons.dable=myData.dable;
1933    jsons.countz=myData.countz; jsons.divider=myData.divider; jsons.conly=myData.conly;
1934 
1935    jsons = JSON.stringify(jsons);
1936
1937 
1938    formModal += '<h4 class="modal-title foodName" id="foodInfo" data-json=\'' + jsons + '\' >' + myData.itemName + '</h4></div><div class="modal-body">';
1939    formModal += '<div class="row" style="margin-right:3px; margin-left:-5px; display:flex;">';
1940    var formModal2=formModal;
1941
1942    // for (var i=0; i<extraTypes.length; ++i){
1943    //     var x= window[extraTypes[i].type];
1944    //     formModal += x(extraTypes[i],i,"");
1945    // }
1946 
1947    if (myData.pizza != "no") {
1948        formModal += tableFiller("Toppings");
1949        for (var i = 0; i < myData.toppings.length; ++i) {
1950            formModal += createPizzaToppings("checkbox", myData.toppings[i], "toppings", i);
1951        }
1952        formModal += finishTable();
1953        formModal += tableFiller("Size");
1954        for (var i = 0; i < myData.portions.length; ++i) {
1955            formModal += createRadioBox("radio", myData.portions[i] + '"  ', "portion", i, myData.prices[i]);
1956        }
1957        formModal += finishTable();
1958
1959        if(stuffedPrices[0]!="no"){
1960            formModal += tableFiller("Customize");
1961            if (stuffedPrices[0] != "no") {
1962                formModal += createCheckBox("checkbox", "Stuffed Crust", "stuffedCrust", 24);
1963            }
1964    
1965            if (stuffedPrices2[0] != "no") { formModal += createCheckBox("checkbox", "HotDog Crust", "stuffedCrust", 25); }
1966    
1967            try {
1968                if (bases[0].length > 0) {
1969                    for (var i = 0; i < bases.length; ++i) {
1970                        formModal += createCheckBox4(boxt[i], bases[i], "bases33", i);
1971                    }
1972                }
1973            } catch (e) { }
1974
1975         
1976            if(myData.makeMeal=="true"){
1977                //formModal +=headersub("Make it Meal only for £"+makeMeal);
1978                formModal += makeMealx("makeMeal");
1979            }
1980
1981            formModal += finishTable();
1982        }
1983
1984        else{
1985 
1986            for (var i=0; i<extraTypes.length; ++i){
1987                var x= window[extraTypes[i].type];
1988                formModal += x(extraTypes[i],i,"");
1989 
1990            }
1991        }
1992     
1993        formModal += '</div>';
1994        
1995        if(toppingNames.length>10){
1996            formModal +='<div class="wrapb"><button type="button" class="btn btn-default footerButtons addtobutton xxenable" id="enable10" onclick="enableExtras(this.id);"  style="text-align: center;width: 100%;">Extra Toppings ▾</button></div>';
1997            formModal +='<div class="row pizzaRow"  style="margin-right:3px; margin-left:-5px; display:none;" id="pizzaDivenable10">';
1998        }
1999        else{
2000            formModal +='<div class="row pizzaRow"  style="margin-right:3px; margin-left:-5px;" id="pizzaDivenable10">';
2001        }
2002        //formModal += tableFiller("Extra Topping");
2003  
2004        var jx=0;
2005        for (var i=0; i<arx.length; ++i){
2006            formModal += tableFiller("Extra Topping");
2007            for (jx; jx<arx[i]; ++jx){
2008                formModal += createExtraToppings("checkbox", toppingNames[jx], "extratoppings", jx);
2009            }
2010            jx=arx[i];
2011            formModal += finishTable();
2012        }
2013   
2014 
2015    }
2016
2017    if (myData.salads == "yes") {
2018        marker=1;
2019   
2020         formModal += window.createSaladSection(saladNames);
2021    }
2022
2023    if (myData.etoppings2 == "yes") {
2024    formModal += tableFiller("Customize"); marker=1;
2025        for (var i = 0; i < etoppings2.length; ++i) {
2026            formModal += createCheckBox("checkbox", etoppings2[i], "etoppings2", i);
2027        }
2028
2029        
2030
2031        formModal += finishTable();
2032    }
2033   
2034    if (myData.sauces == "yes") {
2035        marker=1;
2036        if (myData.itemName == "Pot of Sauce" || myData.itemName == "Dips") {
2037            formModal += tableFiller("Dip Sauces");
2038            for (var i = 0; i < DipNames.length-1; ++i) {
2039                formModal += createCheckBox("radio", DipNames[i], "sauce", i);
2040            }
2041            formModal += finishTable();
2042	formModal += createRadioBox("radio", myData.portions[0] + '', "portion", 0, myData.prices[0]);
2043        }
2044        else {
2045            formModal += tableFiller("Sauces");
2046            for (var i = 0; i < sauceNames.length; ++i) {
2047                formModal += createCheckBox5("checkbox", sauceNames[i], "sauce", i);
2048            }
2049            formModal += finishTable();
2050        }
2051    }
2052    var tpot=0;
2053    if (myData.pizza == "no") {
2054        if (myData.portions.length != 1 && (myData.sauces!="yes" || myData.salads!="yes") ) {
2055 
2056            formModal += tableFiller("Portions");
2057            tpot=1;
2058            for (var i = 0; i < myData.portions.length; ++i) {
2059                formModal += createRadioBox("radio", myData.portions[i] + '', "portion", i, myData.prices[i]);
2060            }
2061            formModal += finishTable();
2062        }
2063       
2064        else{
2065            formModal += tableFiller("Choose");
2066            nchoice=1;
2067            for (var i = 0; i < myData.portions.length; ++i) {
2068                formModal += createRadioBox("radio", myData.portions[i] + '', "portion", i, myData.prices[i]);
2069            }
2070          
2071        }
2072        formModal += offerBody;
2073        
2074    }
2075    if (myData.pizza == "no") {
2076        var otherCounter = 0;
2077        var otherBody = "";
2078        if (myData.extraCheese == "yes") {
2079            otherBody += createCheckBox("checkbox", "Extra Cheese", "cheese", 33);
2080            ++otherCounter;
2081        }
2082        if (myData.chipsCheese == "yes") {
2083            if(myData.itemName!="Chips")
2084            {
2085            otherBody += createCheckBox("checkbox", "Ex.Cheese (Chips)", "cheese", 334);
2086            ++otherCounter;
2087            }
2088        }
2089        if (myData.burgerCheese == "yes") {
2090            otherBody += createCheckBox("checkbox", "with Cheese", "cheese", 44);
2091            ++otherCounter;
2092        }
2093        if (myData.saltvinegar == "yes") {
2094            otherBody += createCheckBox("checkbox", "Salt", "salt", 33);
2095            otherBody += createCheckBox("checkbox", "Vinegar", "vinegar", 33);
2096            ++otherCounter;
2097        }
2098        if (myData.noCheese == "yes") {
2099            otherBody += createCheckBox("checkbox", "No Cheese", "nocheese", 33);
2100            ++otherCounter;
2101        }
2102        if (myData.etoppings1 == "yes") {
2103            for (var i = 0; i < etoppings1.length; ++i) {
2104                otherBody += createCheckBox("checkbox", etoppings1[i] + ("(" + etoppings1Prices[i] + ")"), "etoppings1", i);
2105            }
2106            ++otherCounter;
2107        }
2108        if (myData.etoppings3 == "yes") {
2109            for (var i = 0; i < etoppings3.length; ++i) {
2110                if(etoppings3Prices[i]=="0"){
2111                    otherBody += createCheckBox("checkbox", etoppings3[i] , "etoppings3", i);
2112                }
2113                else{
2114                    otherBody += createCheckBox("checkbox", etoppings3[i] + ("(" + etoppings3Prices[i] + ")"), "etoppings3", i);
2115                 }
2116            }
2117            ++otherCounter;
2118        }
2119
2120        if (myData.etoppings5 != "no" && myData.etoppings5) {
2121     var toppingz = (myData.etoppings5).split(',');
2122
2123var lenx = parseInt(toppingz.length / 2);
2124
2125for (var i = 0; i < toppingz.length; ++i) {
2126    if (i == lenx && lenx > 8) {
2127        otherBody += finishTable();
2128        otherBody += tableFiller("Other");
2129    }
2130
2131    let tops = extraAll.find(({ id }) => id == toppingz[i]);
2132 
2133
2134    if (!tops) {
2135        continue;
2136    }
2137
2138
2139    if (tops.type == "selectBox") {
2140        otherBody += createSelectBox(
2141            tops.extra,
2142            "extrasxx",
2143            i,
2144            tops.price,
2145            tops.type
2146        );
2147    } else if (tops.price == "0") {
2148
2149        otherBody += createCheckBox3(
2150            "radio",
2151            tops.extra,
2152            "extrasxx",
2153            i,
2154            tops.price,
2155            tops.type
2156        );
2157
2158    } else if (tops.price == "blank") {
2159
2160        otherBody += finishTable();
2161        otherBody += tableFiller("Customize");
2162
2163    } else {
2164
2165        otherBody += createCheckBox3(
2166            "radio",
2167            tops.extra + " (" + tops.price + ")",
2168            "extrasxx",
2169            i,
2170            tops.price,
2171            tops.type
2172        );
2173    }
2174}
2175            ++otherCounter;
2176        }
2177 
2178        if (otherCounter > 0) {
2179            //if (myData.portions.length == 1 ) { formModal += createRadioBox("radio", myData.portions[0] + '', "portion", 0, myData.prices[0]); }
2180            if(myData.portions.length>1 &&  myData.sauces=="yes" && myData.salads=="yes" && myData.etoppings5!="no"){
2181                if(myData.portions.length<2){  formModal += tableFiller("Other");
2182                for (var i = 0; i < myData.portions.length; ++i) {
2183                    formModal += createRadioBox("radio", myData.portions[i] + '', "portion", i, myData.prices[i]);
2184                }
2185            }
2186            
2187        }
2188        else{ 
2189            if(nchoice==0){
2190                formModal += tableFiller("Other");     
2191            }
2192        }
2193            formModal += otherBody;
2194            if (myData.type == "combo") {
2195                for (var i = 0; i < myData.offers.length; ++i) {
2196                    formModal += createDropdown("checkbox", "comboDrink", i, myData.offers[i]);
2197                }
2198                ++otherCounter;
2199            }
2200            if(myData.makeMeal=="true"){
2201                //formModal +=headersub("Make it Meal only for £"+makeMeal);
2202                formModal += makeMealx("makeMeal");
2203            }
2204            formModal += finishTable();
2205
2206            
2207        }
2208        else { 
2209            if(marker!=1){
2210                var imgTag = '<img src="' + myData.image + '" alt="" width="186" height="156" class="menuImage ">';
2211                formModal = formModal2;
2212                if(myData.portions.length>1){
2213                    formModal += tableFiller("Portions");
2214                    for (var i = 0; i < myData.portions.length; ++i) {
2215                        formModal += createRadioBox("radio", myData.portions[i] + '', "portion", i, myData.prices[i]);
2216                    }
2217
2218                    if(myData.makeMeal=="true"){
2219                        //formModal +=headersub("Make it Meal only for £"+makeMeal);
2220
2221                        formModal += makeMealx("makeMeal");
2222                    }
2223        
2224                    formModal += finishTable();
2225                }
2226                else{
2227                    if(myData.makeMeal=="true"){
2228                        //formModal +=headersub("Make it Meal only for £"+makeMeal);
2229                        formModal += tableFiller("Other");
2230                        formModal += createRadioBox("radio", myData.portions[0] + '', "portion", 0, myData.prices[0]);
2231                        formModal += makeMealx("makeMeal");
2232                        formModal += finishTable();
2233                    }
2234                    else{
2235                        formModal += singleTable(imgTag, myData.portions[0], myData.prices[0]);
2236                    }
2237                    
2238                }
2239                
2240                //formModal += finishTable()+'</div>';
2241            }
2242            else{
2243                if(myData.portions.length>1 &&  myData.sauces=="yes" && myData.salads=="yes" && myData.etoppings5!="no"){
2244                      formModal += finishTable();
2245                //     if(myData.portions.length<2){  formModal += tableFiller("Other");
2246                //    /* for (var i = 0; i < myData.portions.length; ++i) {
2247                //         formModal += createRadioBox("radio", myData.portions[i] + '', "portion", i, myData.prices[i]);
2248                //     }*/
2249                // }
2250            }
2251            else{
2252                if(tpot==0){
2253                    formModal += finishTable();
2254                }
2255               // formModal += singleTable(" ", myData.portions[0], myData.prices[0]);
2256            }
2257            }
2258        }
2259    }
2260
2261    
2262    formModal += '</div>';
2263    /*end of row class*/
2264    formModal += '</div>';
2265    /* Modal Body Ends */
2266    /*Modal Footer Start */
2267    formModal += '<div class="modal-footer">';
2268    if(myData.typex!="no"){
2269    formModal += '<div class="wrapButtons wrapincs" style="display:none;">';
2270    }
2271    else{
2272    formModal += '<div class="wrapButtons wrapincs" >';
2273    }
2274    formModal += '<button type="button" class="clean-icon addMinus qty-minus  " onclick="minusItem();" > − </button>';
2275    formModal += '<input id="amountItem" type="text"   class="text-center amountItem"    value="1" >';
2276    formModal += '<button type="button" class="clean-icon addMinus qty-plus " onclick="plusItem();" > + </button>';
2277    formModal += '</div>';
2278    formModal += '<div class="wrapButtons"><input style="display:none;" id="forwho" value="nonex">';
2279    formModal += '<button type="button" class="addMinus fa fa-pencil-square forwhoxy" onclick="forwho();"  style=" margin-top: 9px; margin-right: 11px; margin-left: -27px; display:none;">  </button><button type="button" class="btn btn-default footerButtons addtobutton"  id="addbtnxxx" onclick="addToCart();" data-dismiss="modal" >Add to Cart <i class="fa fa-icon-add2x icon-classes-general2"></i></button>';
2280    formModal += '</div>';
2281    formModal += '</div>';
2282    /*Footer end*/
2283    formModal += '</div>';
2284    formModal += '</div>';
2285    formModal += '</div>';
2286    /*End of fade, dialog, content*/
2287    $('#modalArea').html(formModal);
2288    $('#invokeMyModal').modal('show');
2289 centerInvokeModal();
2290}catch(e){console.log("error caught",e); $('body').css('position', '');}
2291
2292}
2293
2294function createSelectBox(itemName, className, iterator, price, type) {
2295
2296    var parts = itemName.split("::");
2297    var header = "";
2298    var options = [];
2299
2300    if (parts.length > 1) {
2301        header = parts[0];
2302        options = parts[1].split("|");
2303    } else {
2304        options = itemName.split("|");
2305    }
2306
2307    // New: support individual option prices separated by ;
2308    var optionPrices = String(price || "0").split(";");
2309    var hasIndividualPrices = optionPrices.length > 1;
2310
2311    var html = "";
2312
2313    html += '<tr><td>';
2314
2315    if (header != "") {
2316        html += '<div class="modifierHeader">' + header + '</div>';
2317    }
2318
2319    html += '<select ' +
2320        'class="modifierSelect ' + className + ' ' + type + '" ' +
2321        'id="' + className + iterator + '" ' +
2322        'data-price="' + price + '" ' +
2323        'data-checked="false">';
2324
2325    html += '<option value="" data-price="0">Choose...</option>';
2326
2327    for (var i = 0; i < options.length; i++) {
2328
2329        var optionName = options[i].trim();
2330
2331        var optionPrice;
2332
2333        if (hasIndividualPrices) {
2334            optionPrice = optionPrices[i] !== undefined
2335                ? optionPrices[i].trim()
2336                : "0";
2337        } else {
2338            // OLD behaviour - one price applies to every option
2339            optionPrice = String(price || "0").trim();
2340        }
2341
2342        html += '<option ' +
2343            'value="' + optionName + '" ' +
2344            'data-price="' + optionPrice + '">' +
2345            optionName +
2346            (optionPrice == "0" || optionPrice == "0.00"
2347                ? ""
2348                : " (" + optionPrice + ")") +
2349            '</option>';
2350    }
2351
2352    html += '</select>';
2353    html += '</td></tr>';
2354
2355    return html;
2356}
2357
2358function flyToElement(flyer) {
2359    try {
2360        var flyingTo = document.getElementById('cartdivision');
2361        var $func = $(this);
2362        var divider = 3;
2363        var flyerClone = $(flyer).clone();
2364        $(flyerClone).css({ position: 'absolute', top: $(flyer).offset().top + "px", left: $(flyer).offset().left + "px", opacity: 1, 'z-index': 1000 });
2365        $('body').append($(flyerClone));
2366        var gotoX = $(flyingTo).offset().left + ($(flyingTo).width() / 2) - ($(flyer).width() / divider) / 2;
2367        var gotoY = $(flyingTo).offset().top + ($(flyingTo).height() / 2) - ($(flyer).height() / divider) / 2;
2368
2369        $(flyerClone).animate({
2370            opacity: 0.4,
2371            left: gotoX,
2372            top: gotoY,
2373            width: $(flyer).width() / divider,
2374            height: $(flyer).height() / divider
2375        }, 700,
2376            function () {
2377                $(flyingTo).fadeOut('fast', function () {
2378                    $(flyingTo).fadeIn('fast', function () {
2379                        $(flyerClone).fadeOut('fast', function () {
2380                            $(flyerClone).remove();
2381                        });
2382                    });
2383                });
2384            });
2385    } catch (e) {
2386        flyingTo = document.getElementById('iosCart');
2387        $(flyingTo).fadeOut('fast', function () {
2388            $(flyingTo).fadeIn('fast', function () {
2389                $(flyerClone).fadeOut('fast', function () {
2390                    $(flyerClone).remove();
2391                });
2392            });
2393        });
2394    }
2395    //$('#cartdivision').fadeOut('slow');  $('#cartdivision').fadeIn('slow');
2396   // $('.popupIos').fadeOut('slow','swing'); $('.popupIos').fadeIn('slow','swing');
2397}
2398 
2399window.createSaladSection = window.createSaladSection || function (saladNames, suffix) {
2400
2401    suffix = suffix || "";
2402
2403    var html = "";
2404    var saladClass = "salad" + suffix;
2405
2406    html += createSalad(saladClass);
2407
2408    for (var i = 0; i < saladNames.length; ++i) {
2409        html += createCheckBox(
2410            "checkbox",
2411            saladNames[i],
2412            saladClass,
2413            i
2414        );
2415    }
2416
2417 
2418    html += finishTable();
2419
2420    return html;
2421};
2422
2423
2424
2425
2426function createSalad(offerid) {
2427    var body = '<div class="col-xs-4 modalMenuDetails"  > <div class="funkyradio allsaladsdiv" ><div class="funkyradio-default adefault"  ><div class="funkyradio-success">';
2428    body += '<input type="checkbox" name="checkbox" class="saladsz" id="Salads3'+offerid+'" value="All Salads" onclick="selectors(\'' + offerid + '\',this.id);"><label for="Salads3'+offerid+'" class="saladclass saladclassx" style="height:29px;" >';
2429    body += '<span class="label-box" style="left:-18px;"></span><span class="label-text atexta">All Salads</span> </label></div></div></div>';
2430    body += '<table class="table">  <thead>  </thead><tbody class="texts">';
2431    return body;
2432}
2433function makeMealx(offerid) {
2434    var body = '</tbody> </table> <div class="funkyradio allsaladsdiv mmealdiv" style="height:52px; margin-top:10px;"><div class="funkyradio-default adefault"  ><div class="funkyradio-success">';
2435    body += '<input type="checkbox" name="checkbox" class="saladszx" id="makeMealSelect" value="Make it Meal <br>for £'+makeMeal+'" onclick="makeMealy(this.id);"><label for="makeMealSelect" class="saladclass saladclassxy" style="height:52px;" >';
2436    body += '<span class="label-box" style="left:-18px; height:18px; width:18px;"></span><span class="label-text atextax">Make it Meal <br>for £'+makeMeal+'</span> </label></div></div></div>';
2437    body += '<table class="table">  <thead>  </thead><tbody class="texts">';
2438    body +=createDropdownx("checkbox", "comboDrink", 0, "Can");
2439  
2440 
2441    //if list sep - 
2442    for (var i=0; i<mmNames.length; ++i){
2443        body +=createDropdownt("checkbox", "comboDrink", i+1, mmNames[i]);
2444    }
2445    
2446    return body;
2447}
2448
2449 
2450
2451function makeMealy(className,id) {
2452    if( $('#makeMealSelect').prop('checked')==true){
2453        $('.makeMealsx').show();
2454    }
2455    else{
2456        $('.makeMealsx').hide();
2457    }
2458}
2459
2460function createDropdownt(itemName, className, iterator,sentItems) {
2461    var items = sentItems.split("-");
2462    var checkbox = '';
2463    checkbox += '<tr style="display:none;  " class="makeMealsx"><td>';
2464    checkbox += ' <div class="form-group">';
2465    checkbox += ' <select class="form-control mealItemsm" id="mealx' + iterator + '" style="margin-bottom:20px;">';
2466    for (var i = 0; i < items.length; ++i) {
2467        checkbox += ' <option value="'+items[i]+'">' + items[i] + '</option>';
2468    }
2469    checkbox += '</select></div></td></tr>';
2470    return checkbox;
2471}
2472
2473
2474 
2475
2476function createDropdownx(itemName, className, iterator, type) {
2477    var items = window[type + 'Names'];
2478    var checkbox = '';
2479    checkbox += '<tr style="display:none;  " class="makeMealsx"><td>';
2480    checkbox += ' <div class="form-group">';
2481    checkbox += ' <select class="form-control mealItems mealItemsm" id="mealx' + iterator + '" style="margin-bottom:20px;">';
2482    for (var i = 0; i < items.length; ++i) {
2483        checkbox += ' <option value="'+items[i]+'">' + items[i] + '</option>';
2484    }
2485    checkbox += '</select></div></td></tr>';
2486    return checkbox;
2487}
2488
2489
2490
2491function createDropdown(itemName, className, iterator, type) {
2492    var items = window[type + 'Names'];
2493    var checkbox = '';
2494    checkbox += '<tr><td>';
2495    checkbox += ' <div class="form-group">';
2496    checkbox += ' <select class="form-control comboItems" id="combo' + iterator + '">';
2497    for (var i = 0; i < items.length; ++i) {
2498        checkbox += ' <option value="'+items[i]+'">' + items[i] + '</option>';
2499    }
2500    checkbox += '</select></div></td></tr>';
2501    return checkbox;
2502}
2503
2504 
2505
2506$(document).on('click', '.etoppings2', function () {
2507    if($(this).val()=="No Salad"){
2508        $('.etoppings2').prop('checked', false);
2509        $(this).prop('checked', true);
2510    }
2511    else{
2512        $('#etoppings22').prop('checked', false);
2513    }
2514});
2515
2516$(document).on('click', '#stuffedCrust24', function () {
2517    var checked = $(this).is(':checked');
2518    if(checked){
2519        $('#stuffedCrust25').prop('checked',false);
2520    }  
2521});
2522$(document).on('click', '#stuffedCrust25', function () {
2523    var checked = $(this).is(':checked');
2524    if(checked){
2525        $('#stuffedCrust24').prop('checked',false);
2526    }
2527});
2528
2529// $(document).on('click', '.notavailable', function () {
2530
2531//     if (!$(this).is(':checked')) {
2532//         return;
2533//     }
2534
2535//     let rawPrice = $(this).data("price") + "";
2536
2537//     if (!rawPrice.startsWith("notavailable:")) {
2538//         return;
2539//     }
2540
2541//     let split = rawPrice.split("|");
2542
2543//     let blockedPart = split[0]; 
2544
2545//     let blockedSizes = blockedPart
2546//         .replace("notavailable:", "")
2547//         .split(",");
2548
2549//     let selectedPortion = '';
2550
2551//     $('.portionRadio:checked').each(function () {
2552//         selectedPortion = $(this).val();
2553//     });
2554
2555//     // extract only number from 10" £7.20
2556//     selectedPortion = selectedPortion.match(/\d+/)?.[0];
2557
2558//     if (blockedSizes.includes(selectedPortion)) {
2559
2560//         alertUser(
2561//             "You can not have " +
2562//             $(this).val() +
2563//             " on " +
2564//             selectedPortion +
2565//             '" ' +
2566//             $('#menuHeader1').val()
2567//         );
2568
2569//         $(this).prop('checked', false);
2570//         $(this).attr('data-checked', "false");
2571
2572//         return false;
2573//     }
2574
2575// });
2576
2577 
2578
2579
2580$(document).on('change', '.notavailable', function () {
2581
2582    var $checkbox = $(this);
2583
2584    if (!$checkbox.is(':checked')) {
2585        return;
2586    }
2587
2588    var xyy = ($checkbox.attr("data-price") || "").toString();
2589
2590    if (!xyy.startsWith("notavailable:")) {
2591        return;
2592    }
2593
2594    var blockedPart = xyy.split("|")[0];
2595    var blockedSizes = blockedPart
2596        .replace("notavailable:", "")
2597        .split(",");
2598
2599
2600    var selectedSize = "";
2601    $('input[id^="portion"]:checked').each(function () {
2602
2603        var val = ($(this).val() || "").toString();
2604        var match = val.match(/\d+/);
2605        if (match) {
2606            selectedSize = match[0];
2607        }
2608    });
2609
2610    if (!selectedSize) {
2611    selectedSize = $checkbox.closest('.stepOptions').data('xxx');
2612}
2613
2614selectedSize = (selectedSize || "").toString();
2615 
2616 
2617if (blockedSizes.includes(selectedSize)) {
2618
2619    var dealName = $checkbox
2620        .closest('.stepOptions')
2621        .find('.headersOffer')
2622        .first()
2623        .text()
2624        .trim();
2625
2626    if (dealName) {
2627
2628        alertUser(
2629            $checkbox.val() +
2630            " is not available for " +
2631            dealName +
2632            " (" + selectedSize + '\")'
2633        );
2634
2635    } else {
2636
2637        alertUser(
2638            "You can not have " +
2639            $checkbox.val() +
2640            " on " +
2641            selectedSize +
2642            '" ' +
2643            $('#menuHeader1').val()
2644        );
2645
2646    }
2647
2648setTimeout(function () {
2649
2650    $checkbox.prop('checked', false);
2651    $checkbox.attr('data-checked', "false");
2652
2653 
2654
2655
2656}, 10);
2657
2658    return false;
2659}
2660
2661});
2662
2663$(document).on('mousedown touchstart', 'input[type="radio"]', function () {
2664
2665    var $radio = $(this);
2666    var groupName = $radio.attr('name');
2667
2668    if (!groupName) return;
2669
2670    var $checked = $('input[type="radio"][name="' + groupName + '"]:checked');
2671
2672    if ($checked.length > 0) {
2673        $radio.data('previousRadioId', $checked.attr('id'));
2674    }
2675});
2676
2677$(document).on('change', 'input[id^="portion"]', function () {
2678
2679    var selectedSize = "";
2680
2681    $('input[id^="portion"]:checked').each(function () {
2682        var match = (($(this).val() || "") + "").match(/\d+/);
2683        if (match) {
2684            selectedSize = match[0];
2685        }
2686    });
2687
2688    $('.notavailable:checked').each(function () {
2689
2690        var $checkbox = $(this);
2691        var rawPrice = ($checkbox.attr("data-price") || "").toString();
2692
2693        if (!rawPrice.startsWith("notavailable:")) {
2694            return;
2695        }
2696
2697        var blockedSizes = rawPrice
2698            .split("|")[0]
2699            .replace("notavailable:", "")
2700            .split(",");
2701
2702        if (blockedSizes.includes(selectedSize)) {
2703
2704            $checkbox.prop('checked', false);
2705            $checkbox.attr('data-checked', "false");
2706
2707            alertUser(
2708                $checkbox.val() +
2709                " is not available on " +
2710                selectedSize +
2711                '" ' +
2712                $('#menuHeader1').val()
2713            );
2714        }
2715    });
2716
2717    $('.modifierSelect').each(function () {
2718
2719        var $select = $(this);
2720        var $option = $select.find('option:selected');
2721
2722        if (!$option.val()) {
2723            return;
2724        }
2725
2726        var blockedText = ($option.attr('data-notavailable') || '').toString();
2727
2728        if (!blockedText) {
2729            return;
2730        }
2731
2732        if (blockedText.split(",").includes(selectedSize)) {
2733
2734            alertUser(
2735                $option.val() +
2736                " is not available on " +
2737                selectedSize +
2738                '" ' +
2739                $('#menuHeader1').val()
2740            );
2741
2742            $select.prop('selectedIndex', 0);
2743        }
2744    });
2745});
2746
2747
2748 
2749$(document).on('change', '.modifierSelect', function () {
2750
2751    var $select = $(this);
2752    var $option = $select.find('option:selected');
2753
2754    if (!$option.val()) {
2755        return;
2756    }
2757
2758    var blockedText = ($option.attr('data-notavailable') || '').toString();
2759
2760    if (!blockedText) {
2761        return;
2762    }
2763
2764    var blockedSizes = blockedText.split(",");
2765
2766    var selectedSize = "";
2767
2768    $('input[id^="portion"]:checked').each(function () {
2769        var val = ($(this).val() || "").toString();
2770        var match = val.match(/\d+/);
2771
2772        if (match) {
2773            selectedSize = match[0];
2774        }
2775    });
2776
2777    // Meal-deal fallback
2778    if (!selectedSize) {
2779        selectedSize = $select.closest('.stepOptions').data('xxx');
2780    }
2781
2782    selectedSize = (selectedSize || "").toString();
2783
2784    if (blockedSizes.includes(selectedSize)) {
2785
2786        var dealName = $select
2787            .closest('.stepOptions')
2788            .find('.headersOffer')
2789            .first()
2790            .text()
2791            .trim();
2792
2793        if (dealName) {
2794            alertUser(
2795                $option.val() +
2796                " is not available for " +
2797                dealName +
2798                " (" + selectedSize + '")'
2799            );
2800        } else {
2801            alertUser(
2802                "You can not have " +
2803                $option.val() +
2804                " on " +
2805                selectedSize +
2806                '" ' +
2807                $('#menuHeader1').val()
2808            );
2809        }
2810
2811        $select.prop('selectedIndex', 0);
2812
2813        return false;
2814    }
2815});
2816
2817function getSelectedPortionForModifier($checkbox) {
2818
2819    var selectedSize = "";
2820
2821    $('input[id^="portion"]:checked, .portionRadio:checked').each(function () {
2822        var val = ($(this).val() || "").toString();
2823        var match = val.match(/\d+/);
2824        if (match) selectedSize = match[0];
2825    });
2826
2827    if (selectedSize) {
2828        return selectedSize;
2829    }
2830
2831    var stepSize = $checkbox.closest('.stepOptions').data('xxx');
2832
2833    if (stepSize !== undefined && stepSize !== null && stepSize !== "") {
2834        return stepSize.toString();
2835    }
2836
2837    return "";
2838}
2839
2840
2841
2842 
2843
2844
2845// $(document).on('click', 'div[class^=notavailable]', function(){
2846//     alert($(this).text());                              
2847// }); 
2848
2849 
2850$(document).on('click', '.sauce, .sauce1, .sauce2, .sauce3', function () {
2851    var classt=$(this).attr('class');
2852    if($(this).val()!="No Sauce"){
2853        $(this).prop('checked',true);
2854        $('.'+classt+'[value="No Sauce"]').prop('checked',false);
2855    }
2856    else if($(this).val()=="No Sauce"){
2857        $('.'+classt).prop('checked',false);
2858        $(this).prop('checked',true);
2859    }
2860    var checkclass = $(this).attr('class');
2861    var count = $('input.' + checkclass + ':checked');
2862    if (count.length > maxSauces) {
2863      
2864        $(count).prop('checked', false);
2865        $(count).attr('data-checked', false);
2866        $(this).prop('checked', true);
2867    }
2868});
2869
2870 
2871
2872function singleTable(singleImage, portion, price) {
2873    var fillTable = '';
2874    fillTable += '<div class="col-xs-6 col-xs-offset-3 modalMenuDetails hede">' + singleImage;
2875    fillTable += '<input type="radio" name="radioBox" class="portion" id="portion0"  style="display:none;" value="' + portion + '" data-price="' + price + '" data-name="' + portion + '" checked/></div>';
2876    return fillTable;
2877}
2878 
2879function createExtraToppings(typeBox, itemName, className, iterator) {
2880    var checkbox = '';
2881    checkbox += '<tr><td>';
2882    checkbox += '<div class="funkyradio">';
2883    checkbox += '<div class="funkyradio-default">';
2884    checkbox += '<div class="funkyradio-success">';
2885    checkbox += '<input type="' + typeBox + '" name="checkbox"  class="' + className + '" id="' + className + iterator + '" value="' + itemName.topping + '" />';
2886    checkbox += '<label for="' + className + iterator + '" class="topping'+itemName.class+'"> <span class="label-box"></span><span class="label-text">' + itemName.topping + '</span> </label>';
2887    checkbox += '</div> </div></div></td></tr>';
2888    return checkbox;
2889}
2890
2891function createCheckBox(typeBox, itemName, className, iterator) {
2892    var checkbox = '';
2893    checkbox += '<tr><td>';
2894    checkbox += '<div class="funkyradio">';
2895    checkbox += '<div class="funkyradio-default">';
2896    checkbox += '<div class="funkyradio-success">';
2897    checkbox += '<input type="' + typeBox + '" name="checkbox'+iterator+'"  class="' + className + '" id="' + className + iterator + '" value="' + itemName + '" />';
2898    checkbox += '<label for="' + className + iterator + '"> <span class="label-box"></span><span class="label-text">' + itemName + '</span> </label>';
2899    checkbox += '</div> </div></div></td></tr>';
2900    return checkbox;
2901}
2902
2903
2904
2905function createCheckBox5(typeBox, itemName, className, iterator) {
2906    var checkbox = '';
2907    checkbox += '<tr><td>';
2908    checkbox += '<div class="funkyradio">';
2909    checkbox += '<div class="funkyradio-default">';
2910    checkbox += '<div class="funkyradio-success">';
2911    checkbox += '<input type="' + typeBox + '" name="checkbox'+iterator+'"  class="' + className + '" id="' + className + iterator + '" value="' + itemName + '" data-checked="false" />';
2912    checkbox += '<label for="' + className + iterator + '"> <span class="label-box"></span><span class="label-text">' + itemName + '</span> </label>';
2913    checkbox += '</div> </div></div></td></tr>';
2914    return checkbox;
2915}
2916
2917
2918function createCheckBox4(typeBox, itemName, className, iterator) {
2919    var checkbox = '';
2920    checkbox += '<tr><td>';
2921    checkbox += '<div class="funkyradio">';
2922    checkbox += '<div class="funkyradio-default">';
2923    checkbox += '<div class="funkyradio-success">';
2924    checkbox += '<input type="' + typeBox + '"  name="'+className+'"  class="' + className + '" id="' + className + iterator + '" value="' + itemName + '" />';
2925    checkbox += '<label for="' + className + iterator + '"> <span class="label-box"></span><span class="label-text">' + itemName + '</span> </label>';
2926    checkbox += '</div> </div></div></td></tr>';
2927    return checkbox;
2928}
2929
2930function createCheckBox3(typeBox, itemName, className, iterator,pricesx,type) {
2931    var checkbox = '';
2932    checkbox += '<tr><td>';
2933    checkbox += '<div class="funkyradio">';
2934    checkbox += '<div class="funkyradio-default">';
2935    checkbox += '<div class="funkyradio-success">';
2936    checkbox += '<input type="' + typeBox + '" name="'+type+'"  class="' + className + '" id="' + className + iterator + '" value="' + itemName + '" data-checked="false" data-price="'+pricesx+'"/>';
2937    checkbox += '<label for="' + className + iterator + '"> <span class="label-box"></span><span class="label-text">' + itemName + '</span> </label>';
2938    checkbox += '</div> </div></div></td></tr>';
2939    return checkbox;
2940}
2941
2942/*$(document).on('click', ".extrasxx,.sauce, .sauce1, .sauce2, .sauce3, .typexyz", function () {
2943
2944    // if ($(this).attr("type") === "radio") {
2945    //     $(this).attr("data-checked", "true");
2946    //     return;
2947    // } 
2948
2949    if ($(this).attr("data-checked") == "false") {
2950        $(this).attr("data-checked", "true");
2951        $(this).prop('checked', true);
2952    } else {
2953        $(this).attr("data-checked", "false");
2954        $(this).prop('checked', false);
2955    }
2956});*/
2957
2958$(document).on('click', ".extrasxx,.sauce,.sauce1,.sauce2,.sauce3,.typexyz", function () {
2959
2960    var $input = $(this);
2961
2962    if ($input.attr("type") === "radio") {
2963
2964        if ($input.attr("data-checked") === "true") {
2965            $input.attr("data-checked", "false");
2966            $input.prop("checked", false);
2967        } else {
2968            var radioName = $input.attr("name");
2969
2970            $('input[type="radio"][name="' + radioName + '"]')
2971                .attr("data-checked", "false")
2972                .prop("checked", false);
2973
2974            $input.attr("data-checked", "true");
2975            $input.prop("checked", true);
2976        }
2977
2978        return;
2979    }
2980
2981    if ($input.attr("data-checked") === "false") {
2982        $input.attr("data-checked", "true");
2983        $input.prop("checked", true);
2984    } else {
2985        $input.attr("data-checked", "false");
2986        $input.prop("checked", false);
2987    }
2988});
2989
2990  
2991function createCheckBox2(typeBox, itemName, className, iterator,pricesx) {
2992    var checkbox = '';
2993    checkbox += '<tr><td>';
2994    checkbox += '<div class="funkyradio">';
2995    checkbox += '<div class="funkyradio-default">';
2996    checkbox += '<div class="funkyradio-success">';
2997    checkbox += '<input type="' + typeBox + '" name="checkbox"  class="' + className + '" id="' + className + iterator + '" value="' + itemName + '" data-price="'+pricesx+'" />';
2998    checkbox += '<label for="' + className + iterator + '"> <span class="label-box"></span><span class="label-text">' + itemName + '</span> </label>';
2999    checkbox += '</div> </div></div></td></tr>';
3000    return checkbox;
3001}
3002
3003function createPizzaToppings(typeBox, itemName, className, iterator) {
3004    var checkbox = '';
3005    checkbox += '<tr><td>';
3006    checkbox += '<div class="funkyradio">';
3007    checkbox += '<div class="funkyradio-default">';
3008    checkbox += '<div class="funkyradio-success">';
3009    checkbox += '<input type="' + typeBox + '" name="checkbox"  class="' + className + '" id="' + className + iterator + '" value="' + itemName + '" checked/>';
3010    checkbox += '<label for="' + className + iterator + '" ><span class="label-box"></span><span class="label-text">' + itemName + '</span></label>';
3011    checkbox += '</div> </div></div></td></tr>';
3012    return checkbox;
3013}
3014 
3015function minusItem() { var amount = $('#amountItem').val(); if (amount > 0) { --amount; } $('#amountItem').val(amount); }
3016function plusItem() { var amount = $('#amountItem').val(); ++amount; $('#amountItem').val(amount); }
3017
3018function selectors(className,id) {
3019    if( $('#'+id).prop('checked')==true){
3020        $('.'+className).prop('checked', true);
3021    }
3022    else{
3023        $('.'+className).prop('checked', false);
3024    }
3025}
3026 
3027function createRadioBox(typeBox, itemName, className, iterator, itemPrice) {
3028    var checkbox = '';
3029    checkbox += '<tr>';
3030    checkbox += '<td>';
3031    checkbox += '<div class="funkyradio">';
3032    checkbox += '<div class="funkyradio-default">';
3033    checkbox += '<div class="funkyradio-success">';
3034    if (iterator == 0) {
3035        checkbox += '<input type="' + typeBox + '" name="radioBox" class="' + className + '" id="' + className + iterator + '" value="' + itemName + '" data-price="' + itemPrice + '" data-name="' + itemName + '" checked/>';
3036        checkbox += '<label for="' + className + iterator + '"><span class="label-box"></span><span class="label-text">' + itemName + ' £' + itemPrice + '</span></label>';
3037    }
3038    else {
3039        checkbox += '<input type="' + typeBox + '" name="radioBox" class="' + className + '" id="' + className + iterator + '" value="' + itemName + '" data-price="' + itemPrice + '"data-name="' + itemName + '"/>';
3040        checkbox += '<label for="' + className + iterator + '"><span class="label-box"></span><span class="label-text">' + itemName + ' £' + itemPrice + '</span></label>';
3041    }
3042    checkbox += '</div>';
3043    checkbox += '</div>';
3044    checkbox += '</div>';
3045    checkbox += '</td>';
3046    checkbox += '</tr>';
3047    return checkbox;
3048}
3049
3050function tableFiller(tableName) {
3051    var fillTable = '';
3052    if (tableName == "Salads") { fillTable += '<div class="col-xs-4 modalMenuDetails"  > <h4 class="sub-header" id="' + tableName + '3" onclick="selectors(this.id);" >' + tableName + '</h4>'; }
3053    else { fillTable += '<div class="col-xs-4 modalMenuDetails"  > <h4 class="sub-header"   style="cursor:default;"  >' + tableName + '</h4>'; }
3054    fillTable += '<table class="table "   >  <thead>  </thead><tbody class="texts">';
3055    return fillTable;
3056}
3057
3058function headersub(tableName) {
3059    var fillTable = '';
3060   fillTable += '</tbody></table><h4 class="sub-header"   style="cursor:default; margin-top:10px;"  >' + tableName + '</h4>';  
3061    fillTable += '<table class="table "   >  <thead>  </thead><tbody class="texts">';
3062    return fillTable;
3063}
3064
3065function finishTable() {
3066    var endTable = '</tbody></table> </div>';
3067    return endTable;
3068}
3069
3070$(window).scroll(function () {
3071    if ($(window).width() < 991) {
3072        if ($(this).scrollTop() > 350) {
3073            $('#goDown').fadeIn('slow');
3074        }
3075        else if ($(this).scrollTop() < 250) {
3076            $('#goDown').fadeOut('slow');
3077        }
3078    }
3079});
3080
3081var slider = $('#slider');
3082var filterButtons = $('.filterButtons');
3083filterButtons.on('click', 'a', function () {
3084    var filterValue = $(this).attr('data-filter');
3085    var slide = slider.find('.slide');
3086    if (filterValue == 'all') {
3087        slide.fadeIn(450);
3088        slide.addClass('flickity');
3089    } else {
3090        var active = $('.' + filterValue).fadeIn(450);
3091        slide.addClass('flickity');
3092        slide.not(active).removeClass('flickity');
3093        slide.not(active).hide();
3094    }
3095    $('.current').removeClass('current');
3096    $(this).addClass('current');
3097});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.