Spaces:
Runtime error
Runtime error
File size: 82,199 Bytes
cfd7e45 6cca62e cfd7e45 6cca62e cfd7e45 6cca62e 5808600 dc7be63 40f227c 0139513 dc7be63 0139513 79b0032 32a7972 8bcc74b 40f227c 8bcc74b 32a7972 56e8c68 32a7972 56e8c68 32a7972 56e8c68 dc7be63 56e8c68 8bcc74b 56e8c68 0139513 56e8c68 270feec 8bcc74b 32a7972 56e8c68 270feec 56e8c68 32a7972 b3fc3b4 32a7972 b3fc3b4 ec024ba b3fc3b4 32a7972 79b0032 b3fc3b4 79b0032 b3fc3b4 79b0032 b3fc3b4 79b0032 b3fc3b4 79b0032 c129ae7 6f1e6c2 c129ae7 79b0032 c129ae7 6f1e6c2 32a7972 c129ae7 32a7972 c129ae7 32a7972 c129ae7 32a7972 c129ae7 32a7972 c129ae7 32a7972 c129ae7 32a7972 c5276eb 32a7972 dc7be63 c5276eb 32a7972 c5276eb dc7be63 c5276eb 6cba4cc dc7be63 c5276eb dc7be63 c5276eb 32a7972 6cba4cc dc7be63 c5276eb dc7be63 c5276eb 32a7972 c5276eb 6cba4cc 32a7972 8394fb4 32a7972 8394fb4 32a7972 8394fb4 32a7972 8394fb4 32a7972 472b62d 32a7972 472b62d 32a7972 0b8a5a2 32a7972 0b8a5a2 32a7972 0b8a5a2 32a7972 0b8a5a2 32a7972 0b8a5a2 32a7972 cf024a7 32a7972 6507511 32a7972 8361547 32a7972 aec7d6b 32a7972 6507511 32a7972 8361547 32a7972 8394fb4 8361547 8394fb4 79b0032 b3fc3b4 686f4a7 b3fc3b4 686f4a7 b3fc3b4 8394fb4 b3fc3b4 8394fb4 b3fc3b4 8394fb4 b3fc3b4 686f4a7 1041c1f c129ae7 1041c1f c129ae7 1041c1f c129ae7 1041c1f c129ae7 1041c1f c129ae7 1041c1f db28e53 c129ae7 801f090 8394fb4 0b8a5a2 dc7be63 0b8a5a2 dc7be63 0b8a5a2 8394fb4 0b8a5a2 8394fb4 8361547 8394fb4 0b8a5a2 8394fb4 0b8a5a2 8394fb4 0b8a5a2 8394fb4 e4101cf 8394fb4 c129ae7 8394fb4 c129ae7 e4101cf 8394fb4 6f1e6c2 c129ae7 8394fb4 c129ae7 8394fb4 c129ae7 8394fb4 c5276eb dc7be63 c5276eb dc7be63 56e8c68 0b8a5a2 1f94420 94677e6 1f94420 79b0032 63c427c 79b0032 53c7c69 79b0032 cf024a7 79b0032 cf024a7 79b0032 53c7c69 dc7be63 1f94420 d2cd186 1f94420 d2cd186 1f94420 d2cd186 1f94420 d2cd186 1f94420 94677e6 dc7be63 6cca62e 314a610 c5276eb e757288 56e8c68 53c7c69 6cca62e 79b0032 6507511 79b0032 813bd2f 79b0032 8394fb4 6507511 79b0032 ec024ba 8361547 8bcc74b 3b95b48 af6d23e 6ffada7 2ed63af f356e18 8361547 f356e18 79b0032 af6d23e 79b0032 813bd2f 79b0032 813bd2f 79b0032 32a7972 56e8c68 c5276eb cf024a7 c5276eb cf024a7 b3fc3b4 8361547 b3fc3b4 8361547 b3fc3b4 8361547 b3fc3b4 8361547 b3fc3b4 8361547 b3fc3b4 8361547 b3fc3b4 8361547 b3fc3b4 8361547 b3fc3b4 8361547 b3fc3b4 8361547 b3fc3b4 8361547 b3fc3b4 8361547 b3fc3b4 8361547 b3fc3b4 8361547 b3fc3b4 8361547 b3fc3b4 8361547 b3fc3b4 8361547 b3fc3b4 8361547 b3fc3b4 db28e53 40f227c 56e8c68 8394fb4 40f227c b3fc3b4 8361547 b3fc3b4 0139513 40f227c 0139513 514c2c8 40f227c 0139513 40f227c 514c2c8 0139513 514c2c8 b3fc3b4 686f4a7 cf024a7 c5276eb cf024a7 c5276eb cf024a7 c5276eb 6cba4cc b3fc3b4 ec024ba 40f227c 514c2c8 c5276eb ec024ba 32a7972 ec024ba 1041c1f c129ae7 1041c1f 32a7972 8361547 32a7972 06f605c 6ffada7 3b95b48 f356e18 3b95b48 af6d23e 32a7972 6ffada7 3b95b48 f356e18 65a5760 8e135aa 3b95b48 af6d23e 32a7972 3b95b48 af6d23e 32a7972 8394fb4 32a7972 af6d23e 32a7972 6ffada7 3b95b48 8361547 8e135aa 32a7972 3b95b48 6ffada7 f356e18 6ffada7 32a7972 b7be7b3 aec7d6b f356e18 aec7d6b 32a7972 8e135aa 32a7972 3b95b48 32a7972 af6d23e 3b95b48 f356e18 3b95b48 af6d23e 3b95b48 af6d23e 3b95b48 32a7972 7fa6b81 3b95b48 af6d23e 3b95b48 7fa6b81 32a7972 af6d23e 32a7972 f356e18 32a7972 6507511 aec7d6b f356e18 32a7972 8e135aa 32a7972 8e135aa 32a7972 6507511 f356e18 6507511 c5276eb 6507511 c5276eb 6507511 c5276eb 6507511 c5276eb 6507511 c5276eb 6507511 c5276eb 6507511 c5276eb 6507511 c5276eb 6507511 c5276eb 6507511 c5276eb 6507511 c5276eb 6507511 c5276eb 6c87837 c5276eb 6cba4cc 6507511 6cba4cc 6507511 8361547 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Menu</title>
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.css" rel="stylesheet">
<!-- Preload Critical Resources -->
<link rel="preload" href="/static/placeholder.jpg" as="image">
{% for section, items in ordered_menu.items() %}
{% for item in items[:1] %}
<link rel="preload" href="{{ item.Image1__c }}" as="image" fetchpriority="high">
{% endfor %}
{% endfor %}
<style>
body {
font-family: Arial, sans-serif;
background-color: #fdf4e3;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
}
.container {
max-width: 900px;
}
.menu-card {
max-width: 350px;
border-radius: 15px;
overflow: hidden;
background-color: #fff;
margin: auto;
display: flex;
flex-direction: column;
opacity: 0;
transition: opacity 0.3s ease-in-out;
}
.menu-card.visible {
opacity: 1;
}
/* Video Container Styles */
.video-container {
position: relative;
width: 100%;
height: 200px;
overflow: hidden;
border-radius: 15px 15px 0 0;
background-color: #000;
}
.video-container video {
width: 100%;
height: 100%;
object-fit: cover;
transition: opacity 0.5s ease;
}
.video-container .video-placeholder {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
background-color: #f0f0f0;
color: #666;
font-size: 14px;
}
.video-container .play-button {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 50px;
height: 50px;
background-color: rgba(0, 0, 0, 0.7);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
z-index: 10;
opacity: 0;
transition: opacity 0.3s ease;
}
/* .video-container:hover .play-button {
opacity: 1;
}
.video-container .play-button i {
color: white;
font-size: 20px;
margin-left: 3px;
} */
.card-title {
font-size: 1.2rem;
font-weight: bold;
margin: 10px 0;
}
.card-text {
font-size: 1rem;
color: #6c757d;
}
.addbutton .btn {
background-color: #28a745;
color: white;
padding: 10px 20px;
font-size: 16px;
font-weight: bold;
border-radius: 5px;
border: none;
transition: background-color 0.3s ease;
margin-left: 13px;
}
.addbutton .btn:hover {
background-color: #218838;
}
.button-container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 6px;
}
.customisable-text {
color: #0FAA39;
font-size: 10px;
font-weight: 500;
margin: 0;
text-align: center;
line-height: 1;
}
.btn-primary {
font-size: 12px;
font-weight: bold;
border-radius: 8px;
width: 70px;
height: 35px;
background-color: #0FAA39;
border-color: #0FAA39;
display: flex;
align-items: center;
justify-content: center;
padding: 0;
transition: background-color 0.3s ease, transform 0.1s ease;
}
.btn-primary:hover {
background-color: #0D9232;
border-color: #0D9232;
transform: scale(1.05);
}
.btn-primary:active,
.btn-primary:focus {
background-color: #0B7A29;
border-color: #0B7A29;
box-shadow: none;
transform: scale(0.98);
}
.view-cart-container {
position: fixed;
bottom: 20px;
right: 20px;
z-index: 999;
display: flex;
align-items: center;
}
.view-cart-button {
background-color: #0FAA39;
color: #fff;
padding: 10px 20px;
border-radius: 30px;
font-size: 1rem;
font-weight: bold;
text-decoration: none;
box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);
display: flex;
align-items: center;
justify-content: center;
gap: 8px;
transition: background-color 0.3s ease, transform 0.2s ease;
}
.view-cart-button:hover {
background-color: #109835;
text-decoration: none;
color: #fff;
transform: scale(1.05);
}
.cart-icon-badge {
background-color: #fff;
color: #0FAA39;
border-radius: 50%;
width: 24px;
height: 24px;
display: flex;
align-items: center;
justify-content: center;
font-size: 12px;
font-weight: bold;
margin-left: 5px;
transition: background-color 0.3s ease, color 0.3s ease;
}
.cart-icon-badge.active {
background-color: #ffcc00;
color: #0FAA39;
}
.avatar-dropdown-container {
position: absolute;
right: 10px;
top: 50%;
transform: translateY(-50%);
display: flex;
align-items: right;
justify-content: center;
}
.avatar-icon {
width: 40px;
height: 40px;
border-radius: 50%;
background-color: #5bbfc1;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
color: white;
font-size: 20px;
font-weight: bold;
}
.dropdown-menu {
position: absolute;
right: 0;
top: 100%;
background-color: #fff;
border-radius: 5px;
width: 220px;
box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);
display: none;
}
.dropdown-menu .dropdown-item {
padding: 12px 16px;
text-decoration: none;
color: #333;
border-bottom: 1px solid #ddd;
display: block;
font-size: 15px;
}
.dropdown-menu .dropdown-item:last-child {
border-bottom: none;
}
.dropdown-menu .dropdown-item:hover {
background-color: #f1f1f1;
}
.fixed-top-bar {
position: relative;
top: 0;
left: 0;
width: 100%;
height: 54px;
background: linear-gradient(45deg, #FFA07A, #FFB347);
color: white;
padding: 15px;
display: flex;
justify-content: space-between;
align-items: center;
z-index: 1000;
}
.search-bar-container {
position: absolute;
left: 20px;
top: 50%;
transform: translateY(-50%);
display: flex;
align-items: center;
width: 300px;
max-width: 90%;
}
.search-bar-container input {
width: 100%;
padding: 8px 15px 8px 40px;
font-size: 16px;
border-radius: 25px;
border: none;
background-color: #fff;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
outline: none;
}
.search-bar-container input::placeholder {
color: #888;
}
.search-icon {
position: absolute;
left: 15px;
font-size: 18px;
color: #888;
}
.autocomplete-suggestions {
position: absolute;
top: 100%;
left: 0;
width: 100%;
max-height: 200px;
overflow-y: auto;
background-color: #fff;
border: 1px solid #ddd;
border-radius: 5px;
box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);
z-index: 1000;
display: none;
}
.autocomplete-suggestions .suggestion-item {
padding: 8px 15px;
cursor: pointer;
font-size: 14px;
color: #333;
}
.autocomplete-suggestions .suggestion-item:hover {
background-color: #f1f1f1;
}
.addon-section {
background-color: #fff;
border: 2px solid #6c757d;
border-radius: 8px;
padding: 12px;
margin-bottom: 10px;
}
.addon-section h6 {
margin-bottom: 10px;
font-size: 1.1rem;
font-weight: bold;
color: #343a40;
}
.addon-section .form-check {
display: inline-flex;
align-items: center;
margin-left: 10px;
color: #343a40;
}
.addon-section .form-check-input {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
width: 20px;
height: 20px;
border: 2px solid #343a40;
border-radius: 5px;
background-color: #f0f0f0;
position: relative;
margin-right: 10px;
}
.addon-section .form-check-input:checked {
background-color: #006400;
border-color: #006400;
}
.addon-section .form-check-input:checked::before {
content: '\2713';
font-size: 14px;
position: absolute;
top: 3px;
left: 4px;
color: white;
}
.addon-section .form-check-label {
font-size: 16px;
margin-left: 5px;
margin-right: 15px;
cursor: pointer;
display: inline-block;
vertical-align: middle;
}
form.text-center.mb-4 {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
margin-bottom: 5px;
}
.modal-header {
padding: 10px 15px;
}
.modal-title {
font-size: 16px;
font-weight: bold;
}
.modal-body {
max-height: 60vh;
overflow-y: auto;
padding: 15px;
}
.modal-body #modal-img {
max-height: 200px;
width: 100%;
object-fit: cover;
border-radius: 8px;
margin-bottom: 10px;
}
.modal-body #modal-name {
font-size: 20px;
font-weight: bold;
text-align: center;
margin-bottom: 5px;
}
.modal-body #modal-price {
font-size: 16px;
font-weight: bold;
color: #6c757d;
text-align: center;
margin-bottom: 10px;
}
.modal-body #modal-description {
font-size: 14px;
color: #6c757d;
margin-bottom: 10px;
}
.modal-body .nutritional-info {
font-size: 12px;
color: #6c757d;
margin-bottom: 10px;
}
.modal-body #modal-addons h6,
.modal-body #first-row h6 {
font-size: 14px;
font-weight: bold;
margin-bottom: 10px;
}
.modal-footer {
display: flex;
align-items: center;
justify-content: space-between;
padding: 10px;
}
.modal-footer .d-flex {
display: flex;
align-items: center;
gap: 10px;
}
.modal-footer .btn {
height: 40px;
padding: 0 15px;
}
.modal-footer .form-control {
width: 50px;
height: 40px;
text-align: center;
}
.modal-footer .btn-primary {
background-color: #0FAA39;
border-color: #0FAA39;
font-weight: bold;
padding: 10px 20px;
height: 40px;
display: flex;
justify-content: center;
align-items: center;
width: auto;
}
.modal-footer .btn-outline-secondary {
height: 40px;
width: 40px;
}
.item-details {
background-color: #f8f9fa;
border-radius: 8px;
padding: 10px;
margin: 10px 15px;
display: none;
}
.item-details.show {
display: block;
}
.item-details h6 {
font-size: 0.9rem;
font-weight: bold;
margin-bottom: 5px;
}
.item-details p {
font-size: 0.85rem;
margin-bottom: 5px;
color: #333;
}
.item-details .nutritional-info {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 10px;
background-color: #e9ecef;
padding: 10px;
border-radius: 5px;
font-size: 0.85rem;
line-height: 1.5;
}
.toggle-details {
cursor: pointer;
color: #0FAA39;
font-size: 0.9rem;
margin-left: 15px;
margin-bottom: 10px;
display: inline-block;
}
.toggle-details:hover {
text-decoration: underline;
}
.category-buttons {
display: flex;
flex-wrap: wrap;
gap: 10px;
justify-content: center;
margin-top: 10px;
}
.category-button {
background-color: #fff;
border: 2px solid #0FAA39;
color: #0FAA39;
padding: 5px 15px;
border-radius: 20px;
font-size: 0.9rem;
cursor: pointer;
transition: background-color 0.3s, color 0.3s;
}
.category-button.selected {
background-color: #0FAA39;
color: #fff;
border-color: #0FAA39;
}
.category-button:hover {
background-color: #e6f4ea;
}
.quantity-selector {
display: flex;
align-items: center;
gap: 5px;
}
.quantity-selector .btn {
width: 25px;
height: 25px;
padding: 0;
font-size: 12px;
line-height: 25px;
text-align: center;
}
.quantity-selector .quantity-display {
width: 25px;
text-align: center;
font-size: 12px;
font-weight: bold;
line-height: 25px;
}
.quantity-selector .quantity-to-add,
.quantity-selector .quantity-to-remove {
width: 45px;
height: 25px;
font-size: 12px;
padding: 0 5px;
}
.modal-dialog {
max-height: 90vh;
}
.modal-body::-webkit-scrollbar {
width: 8px;
}
.modal-body::-webkit-scrollbar-track {
background: #f1f1f1;
border-radius: 10px;
}
.modal-body::-webkit-scrollbar-thumb {
background: #0FAA39;
border-radius: 10px;
}
.modal-body::-webkit-scrollbar-thumb:hover {
background: #0D9232;
}
@media (max-width: 576px) {
.fixed-top-bar {
height: 60px;
padding: 10px;
}
.search-bar-container {
width: 80%;
max-width: 100%;
left: 10px;
top: 50%;
transform: translateY(-50%);
}
.search-bar-container input {
padding: 6px 12px 6px 35px;
font-size: 14px;
border-radius: 20px;
}
.search-icon {
left: 12px;
font-size: 16px;
}
.avatar-dropdown-container {
right: 10px;
}
.avatar-icon {
width: 40px;
height: 40px;
font-size: 20px;
}
.dropdown-menu {
width: 220px;
}
.dropdown-menu .dropdown-item {
padding: 12px 16px;
font-size: 15px;
}
.category-buttons {
gap: 8px;
}
.category-button {
padding: 4px 12px;
font-size: 0.85rem;
}
.modal-dialog {
max-width: 96%;
margin: 5px auto;
}
.modal-header {
padding: 5px 10px;
}
.modal-title {
font-size: 14px;
}
.modal-body {
max-height: 50vh;
padding: 8px;
}
.modal-body #modal-img {
max-height: 150px;
width: 100%;
max-width: 150px;
margin: 0 auto 5px;
display: block;
}
.modal-body #modal-name {
font-size: 18px;
margin-bottom: 3px;
}
.modal-body #modal-price {
font-size: 14px;
margin-bottom: 5px;
}
.modal-body #modal-description {
font-size: 12px;
margin-bottom: 5px;
}
.modal-body .nutritional-info {
font-size: 10px;
margin-bottom: 5px;
}
.modal-body #modal-addons h6,
.modal-body #first-row h6 {
font-size: 12px;
margin-bottom: 5px;
}
.modal-footer {
padding: 5px;
}
.modal-footer .btn {
height: 30px;
padding: 0 10px;
}
.modal-footer .form-control {
width: 30px;
height: 30px;
font-size: 12px;
font-weight: bold;
}
.modal-footer .btn-outline-secondary {
width: 25px;
height: 25px;
font-size: 12px;
line-height: 25px;
}
.modal-footer .btn-primary {
font-size: 12px;
height: 30px;
padding: 0 15px;
border-radius: 5px;
}
.btn-primary {
font-size: 10px;
width: 50px;
height: 25px;
}
.customisable-text {
font-size: 8px;
}
.button-container {
gap: 3px;
}
.quantity-selector .btn {
width: 18px;
height: 18px;
font-size: 9px;
line-height: 18px;
}
.quantity-selector .quantity-display {
width: 18px;
font-size: 9px;
line-height: 18px;
}
.quantity-selector .quantity-to-add,
.quantity-selector .quantity-to-remove {
width: 35px;
height: 18px;
font-size: 9px;
}
.view-cart-button {
padding: 8px 16px;
font-size: 14px;
}
.cart-icon-badge {
width: 20px;
height: 20px;
font-size: 10px;
}
/* Mobile video adjustments */
.video-container {
height: 150px;
}
}
</style>
</head>
<body>
<div class="fixed-top-bar">
<div class="avatar-dropdown-container">
<div class="avatar-icon">
<span>{{ first_letter }}</span>
</div>
<div class="dropdown-menu">
<a href="{{ url_for('user_details.customer_details') }}" class="dropdown-item">View Profile</a>
<a href="{{ url_for('orderhistory.order_history') }}" class="dropdown-item">Order History</a>
<a href="{{ url_for('logout') }}" class="dropdown-item">Logout</a>
</div>
</div>
<div class="search-bar-container">
<input type="text" id="searchBar" class="form-control" placeholder="Search items or sections..." autocomplete="off">
<i class="bi bi-search search-icon"></i>
<div id="autocompleteSuggestions" class="autocomplete-suggestions"></div>
</div>
</div>
<form method="get" action="/menu" class="text-center mb-4" id="categoryForm">
<label class="form-label fw-bold">Select a Category:</label>
<div class="category-buttons">
{% for category in categories %}
<button type="button" class="category-button {% if selected_category == category %}selected{% endif %}" data-category="{{ category }}">{{ category }}</button>
{% endfor %}
<button type="button" class="category-button {% if selected_category == 'Customized Dish' %}selected{% endif %}" data-category="Customized Dish">Customized Dish</button>
</div>
<input type="hidden" name="category" id="selectedCategoryInput" value="{{ selected_category }}">
</form>
<!-- carouel######### -->
<!-- Category Carousel -->
<div id="categoryCarousel" class="carousel slide mt-4" data-bs-ride="carousel">
<div class="carousel-inner">
{% for category in categories %}
<div class="carousel-item {% if loop.first %}active{% endif %}">
<div class="d-flex justify-content-center">
<button class="category-button" onclick="loadCategoryItems('{{ category }}')">{{ category }}</button>
</div>
</div>
{% endfor %}
</div>
<button class="carousel-control-prev" type="button" data-bs-target="#categoryCarousel" data-bs-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="visually-hidden">Previous</span>
</button>
<button class="carousel-control-next" type="button" data-bs-target="#categoryCarousel" data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="visually-hidden">Next</span>
</button>
</div>
<!-- carouel######### -->
<div class="view-cart-container">
<a href="{{ url_for('cart.cart') }}" class="view-cart-button">
<i class="bi bi-cart"></i>
view Cart
<span id="cart-item-count" class="cart-icon-badge {% if cart_item_count > 0 %}active{% endif %}">
{{ cart_item_count if cart_item_count > 0 else '' }}
</span>
</a>
</div>
<div class="modal fade" id="itemModal" tabindex="-1" aria-labelledby="itemModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="itemModalLabel">Item Details</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<img id="modal-img" class="img-fluid rounded mb-3 d-block mx-auto" alt="Item Image">
<h5 id="modal-name" class="fw-bold text-center"></h5>
<p id="modal-price" class="text-muted text-center"></p>
<p id="modal-description" class="text-secondary"></p>
<p class="nutritional-info" id="modal-nutritional-info"></p>
<div id="first-row">
<h6 id="first-row-title" style="display: none;">Customization Options</h6>
<div class="addon-section">
<h6>Choose Preparation Style</h6>
<div id="prep-style-options"></div>
</div>
<div class="addon-section">
<h6>Type</h6>
<div id="type-options"></div>
</div>
<div class="addon-section">
<h6>Spice Level</h6>
<div id="spice-level-options"></div>
</div>
</div>
<div id="modal-addons" class="modal-addons mt-4">
<h6 id="addons-title">Customization Options</h6>
<div id="addons-list" class="addons-container">Loading customization options...</div>
</div>
<div class="mt-4">
<h6>Custom Request</h6>
<textarea id="modal-instructions" class="form-control" placeholder="Enter any special instructions here..."></textarea>
</div>
<span id="modal-section" data-section="" data-category="" style="display: none;"></span>
</div>
<div class="modal-footer d-flex align-items-center justify-content-between">
<div class="d-flex align-items-center gap-2">
<button type="button" class="btn btn-outline-secondary" id="decreaseQuantity">-</button>
<input type="text" class="form-control text-center" id="quantityInput" value="1" readonly style="width: 50px;"/>
<button type="button" class="btn btn-outline-secondary" id="increaseQuantity">+</button>
</div>
<button type="button" class="btn btn-primary" onclick="addToCartFromModal()">Add to Cart</button>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
<script>
// Video Handling Functions
function togglePlay(button) {
const videoContainer = button.closest('.video-container');
const video = videoContainer.querySelector('video');
if (video.paused) {
// Load video source if not already loaded
if (!video.src && video.dataset.src) {
video.src = video.dataset.src;
}
video.play()
.then(() => {
button.innerHTML = '<i class="bi bi-pause-fill"></i>';
})
.catch(e => {
console.log('Video play error:', e);
// Show error to user if needed
});
} else {
video.pause();
button.innerHTML = '<i class="bi bi-play-fill"></i>';
}
}
// Dynamically populate menuItems from ordered_menu
const menuItems = [
{% for section, items in ordered_menu.items() %}
{% for item in items %}
"{{ item.Name }}",
{% endfor %}
{% endfor %}
];
const ingredientsList = [
"Basmati Rice", "Bell Pepper", "Biryani Masala", "Butter", "Capsicum", "Cauliflower",
"Chickpea Flour (Besan)", "Chickpea Flour (for batter)", "Chickpeas (Channa)", "Chili Powder",
"Chili Sauce", "Coconut Milk", "Coriander Powder", "Cornflour", "Cream", "Cumin Powder",
"Cumin Seeds", "Curd (Yogurt)", "Curry Leaves", "Fish (e.g., King Fish or Salmon)",
"Fresh Coriander Leaves", "Garam Masala", "Garlic", "Ghee (Clarified Butter)", "Ginger",
"Ginger-Garlic Paste", "Goat Meat (Mutton)", "Green Chilies", "Honey",
"Kasuri Methi (dried fenugreek leaves)", "Lemon Juice", "Mango Puree", "Mint Leaves",
"Mixed Vegetables (Carrot, Peas, Potato, Cauliflower)", "Mixed Vegetables (Carrot, Peas, Potato)",
"Mustard Seeds", "Mutton (Goat Meat)", "Oil", "Oil (for frying)", "Onion",
"Paneer (Indian Cottage Cheese)", "Peas", "Potatoes", "Prawns", "Red Chili Powder",
"Rice Flour", "Saffron", "Salt", "Soy Sauce", "Spring Onion", "Tamarind (for sourness)",
"Tomato Ketchup", "Tomatoes", "Turmeric Powder", "Vinegar", "Water", "Wheat Flour (for dough)",
"Whole Wheat Flour", "Yogurt (Curd)"
];
const menuItemDetails = {
"Veg Manchurian": {
ingredients: "Cauliflower, Onion, Ginger, Garlic, Soy Sauce, Cornflour, Green Chilies, Capsicum, Spring Onion",
nutritionalInfo: { calories: 250, protein: 5, carbs: 35, fats: 12, fiber: 3, sugar: 2 },
allergens: "Soy, Gluten"
},
"Veg Biryani": {
ingredients: "Basmati Rice, Mixed Vegetables (Carrot, Peas, Potato, Cauliflower), Ginger, Garlic, Biryani Masala, Mint Leaves, Curd, Onion, Ghee",
nutritionalInfo: { calories: 300, protein: 6, carbs: 50, fats: 12, fiber: 5, sugar: 3 },
allergens: "Dairy"
},
"Sukka Gosht (Goat)": {
ingredients: "Goat Meat, Ginger-Garlic Paste, Green Chilies, Onion, Tomatoes, Garam Masala, Coriander Powder, Cumin Powder, Fresh Coriander",
nutritionalInfo: { calories: 450, protein: 35, carbs: 10, fats: 30, fiber: 2, sugar: 1 },
allergens: "None"
},
"Samosa": {
ingredients: "Potatoes, Peas, Onion, Ginger, Cumin Seeds, Garam Masala, Wheat Flour (for dough), Oil (for frying)",
nutritionalInfo: { calories: 150, protein: 3, carbs: 25, fats: 7, fiber: 2, sugar: 1 },
allergens: "Gluten"
},
"Roti": {
ingredients: "Whole Wheat Flour, Water, Salt",
nutritionalInfo: { calories: 150, protein: 4, carbs: 30, fats: 1, fiber: 3, sugar: 0 },
allergens: "Gluten"
},
"Prawn Fry": {
ingredients: "Prawns, Garlic, Ginger, Chili Powder, Coriander Powder, Cumin Powder, Lemon Juice, Oil",
nutritionalInfo: { calories: 350, protein: 25, carbs: 10, fats: 20, fiber: 1, sugar: 1 },
allergens: "Shellfish"
},
"Paneer Butter Masala": {
ingredients: "Paneer, Butter, Cream, Tomato Puree, Onion, Ginger, Garlic, Garam Masala",
nutritionalInfo: { calories: 400, protein: 15, carbs: 20, fats: 25, fiber: 2, sugar: 3 },
allergens: "Dairy"
},
"Paneer Biryani": {
ingredients: "Paneer, Basmati Rice, Mixed Vegetables (Carrot, Peas, Potato), Onion, Tomatoes, Biryani Masala, Mint Leaves, Curd",
nutritionalInfo: { calories: 350, protein: 12, carbs: 55, fats: 15, fiber: 4, sugar: 3 },
allergens: "Dairy"
},
"Onion Pakoda": {
ingredients: "Onion, Chickpea Flour (Besan), Rice Flour, Green Chilies, Cumin Seeds, Ginger, Turmeric Powder, Oil (for frying)",
nutritionalInfo: { calories: 200, protein: 5, carbs: 30, fats: 8, fiber: 3, sugar: 2 },
allergens: "Gluten (if cross-contamination)"
},
"Mutton Biryani": {
ingredients: "Mutton, Basmati Rice, Onion, Tomatoes, Ginger-Garlic Paste, Biryani Masala, Mint Leaves, Yogurt, Ghee",
nutritionalInfo: { calories: 500, protein: 30, carbs: 50, fats: 25, fiber: 4, sugar: 3 },
allergens: "Dairy"
},
"Fish Curry": {
ingredients: "Fish (any firm fish like Salmon or King Fish), Onion, Tomato, Ginger-Garlic Paste, Curry Leaves, Coconut Milk, Tamarind, Mustard Seeds",
nutritionalInfo: { calories: 300, protein: 25, carbs: 10, fats: 20, fiber: 2, sugar: 1 },
allergens: "Fish"
},
"Fiery Mango Glaze Chicken": {
ingredients: "Chicken, Mango Puree, Chili Sauce, Soy Sauce, Honey, Garlic, Ginger, Lemon Juice",
nutritionalInfo: { calories: 350, protein: 30, carbs: 15, fats: 18, fiber: 1, sugar: 5 },
allergens: "Soy"
},
"Chilli Gobi": {
ingredients: "Cauliflower, Onion, Green Chilies, Soy Sauce, Cornflour, Garlic, Ginger, Cumin Powder",
nutritionalInfo: { calories: 250, protein: 6, carbs: 35, fats: 12, fiber: 3, sugar: 2 },
allergens: "Soy, Gluten"
},
"Chilli Chicken": {
ingredients: "Chicken, Bell Pepper, Onion, Green Chilies, Soy Sauce, Cornflour, Garlic, Ginger",
nutritionalInfo: { calories: 400, protein: 35, carbs: 20, fats: 18, fiber: 2, sugar: 2 },
allergens: "Soy, Gluten"
},
"Chicken Manchurian": {
ingredients: "Chicken, Onion, Garlic, Ginger, Soy Sauce, Cornflour, Green Chilies, Capsicum",
nutritionalInfo: { calories: 350, protein: 25, carbs: 20, fats: 18, fiber: 2, sugar: 2 },
allergens: "Soy, Gluten"
},
"Chicken Curry": {
ingredients: "Chicken, Onion, Tomatoes, Ginger-Garlic Paste, Garam Masala, Coconut Milk, Coriander Leaves",
nutritionalInfo: { calories: 350, protein: 28, carbs: 15, fats: 12, fiber: 4, sugar: 2 },
allergens: "None"
},
"Chicken Biryani": {
ingredients: "Chicken, Basmati Rice, Onion, Tomatoes, Ginger-Garlic Paste, Biryani Masala, Mint Leaves, Curd",
nutritionalInfo: { calories: 500, protein: 35, carbs: 60, fats: 20, fiber: 5, sugar: 3 },
allergens: "Dairy"
},
"Channa Masala": {
ingredients: "Chickpeas, Onion, Tomatoes, Ginger-Garlic Paste, Garam Masala, Coriander Powder, Cumin Seeds, Lemon Juice",
nutritionalInfo: { calories: 250, protein: 10, carbs: 45, fats: 5, fiber: 6, sugar: 2 },
allergens: "None"
}
};
function addToCartLocalStorage(payload) {
let cart = JSON.parse(localStorage.getItem('cart')) || [];
const existingItem = cart.find(item =>
item.itemName === payload.itemName &&
item.instructions === payload.instructions &&
JSON.stringify(item.addons) === JSON.stringify(payload.addons)
);
if (existingItem) {
existingItem.quantity += payload.quantity;
} else {
cart.push(payload);
}
localStorage.setItem('cart', JSON.stringify(cart));
return cart;
}
function removeFromCartLocalStorage(itemName, quantityToRemove, instructions, addons) {
let cart = JSON.parse(localStorage.getItem('cart')) || [];
const itemIndex = cart.findIndex(item =>
item.itemName === itemName &&
item.instructions === instructions &&
JSON.stringify(item.addons) === JSON.stringify(addons)
);
if (itemIndex !== -1) {
if (quantityToRemove >= cart[itemIndex].quantity) {
cart.splice(itemIndex, 1);
} else {
cart[itemIndex].quantity -= quantityToRemove;
}
}
localStorage.setItem('cart', JSON.stringify(cart));
return cart;
}
function getCartLocalStorage() {
return JSON.parse(localStorage.getItem('cart')) || [];
}
document.addEventListener('DOMContentLoaded', function () {
// Initialize video handling
const videoContainers = document.querySelectorAll('.video-container');
videoContainers.forEach(container => {
const video = container.querySelector('video');
// Only load video when container is in viewport
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting && video.dataset.src && !video.src) {
video.src = video.dataset.src;
observer.unobserve(entry.target);
}
});
}, {
rootMargin: '200px',
threshold: 0.1
});
observer.observe(container);
// Handle hover play/pause
container.addEventListener('mouseenter', () => {
if (video.src) {
video.play().catch(e => console.log('Autoplay prevented:', e));
}
});
container.addEventListener('mouseleave', () => {
if (!video.paused) {
video.pause();
const playButton = container.querySelector('.play-button');
if (playButton) {
playButton.innerHTML = '<i class="bi bi-play-fill"></i>';
}
}
});
});
const avatarContainer = document.querySelector('.avatar-dropdown-container');
const dropdownMenu = document.querySelector('.dropdown-menu');
avatarContainer.addEventListener('click', function (event) {
event.stopPropagation();
dropdownMenu.style.display = dropdownMenu.style.display === 'block' ? 'none' : 'block';
});
document.addEventListener('click', function (event) {
if (!avatarContainer.contains(event.target)) {
dropdownMenu.style.display = 'none';
}
});
const dropdownItems = document.querySelectorAll('.dropdown-item');
dropdownItems.forEach(item => {
item.addEventListener('click', function () {
dropdownMenu.style.display = 'none';
});
});
const menuCards = document.querySelectorAll('.menu-card');
menuCards.forEach(card => {
const itemName = card.querySelector('.card-title').innerText;
const detailsDiv = card.querySelector('.item-details');
const detailsData = menuItemDetails[itemName];
if (detailsData) {
detailsDiv.innerHTML = `
<h6>Ingredients</h6>
<p>${detailsData.ingredients}</p>
<h6>Nutritional Info</h6>
<div class="nutritional-info">
<span>Calories: ${detailsData.nutritionalInfo.calories} kcal</span>
<span>Carbs: ${detailsData.nutritionalInfo.carbs}g</span>
<span>Protein: ${detailsData.nutritionalInfo.protein}g</span>
<span>Fats: ${detailsData.nutritionalInfo.fats}g</span>
</div>
<h6>Allergens</h6>
<p>${detailsData.allergens}</p>
`;
} else {
detailsDiv.innerHTML = '<p>No details available for this item.</p>';
}
});
const cardObserver = new IntersectionObserver((entries, observer) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('visible');
observer.unobserve(entry.target);
}
});
}, {
root: null,
rootMargin: '0px',
threshold: 0.1
});
menuCards.forEach(card => cardObserver.observe(card));
const toggleLinks = document.querySelectorAll('.toggle-details');
toggleLinks.forEach(link => {
link.addEventListener('click', function () {
const itemName = this.getAttribute('data-item-name').replace(/ /g, '-');
const detailsDiv = document.getElementById(`details-${itemName}`);
detailsDiv.classList.toggle('show');
this.innerText = detailsDiv.classList.contains('show') ? 'Hide Details' : 'Show Details';
});
});
const categoryButtons = document.querySelectorAll('.category-button');
const categoryForm = document.getElementById('categoryForm');
const selectedCategoryInput = document.getElementById('selectedCategoryInput');
if (!selectedCategoryInput.value) {
selectedCategoryInput.value = "All";
document.querySelector('.category-button[data-category="All"]').classList.add('selected');
}
categoryButtons.forEach(button => {
button.addEventListener('click', function () {
categoryButtons.forEach(btn => btn.classList.remove('selected'));
this.classList.add('selected');
selectedCategoryInput.value = this.getAttribute('data-category');
categoryForm.submit();
});
});
const searchBar = document.getElementById('searchBar');
const suggestionsContainer = document.getElementById('autocompleteSuggestions');
searchBar.addEventListener('input', function () {
const input = this.value.trim().toLowerCase();
suggestionsContainer.innerHTML = '';
suggestionsContainer.style.display = 'none';
if (input) {
const filteredItems = menuItems.filter(item =>
item.toLowerCase().includes(input)
);
if (filteredItems.length > 0) {
filteredItems.forEach(item => {
const suggestionDiv = document.createElement('div');
suggestionDiv.classList.add('suggestion-item');
suggestionDiv.innerText = item;
suggestionDiv.addEventListener('click', function () {
searchBar.value = item;
suggestionsContainer.style.display = 'none';
filterMenu();
});
suggestionsContainer.appendChild(suggestionDiv);
});
suggestionsContainer.style.display = 'block';
}
}
filterMenu();
});
document.addEventListener('click', function (event) {
if (!searchBar.contains(event.target) && !suggestionsContainer.contains(event.target)) {
suggestionsContainer.style.display = 'none';
}
});
const descriptionTextarea = document.getElementById('custom-dish-description');
const descriptionSuggestions = document.getElementById('descriptionSuggestions');
if (descriptionTextarea && descriptionSuggestions) {
let usedIngredients = new Set();
function updateUsedIngredients() {
const inputText = descriptionTextarea.value.trim();
usedIngredients.clear();
if (inputText) {
const words = inputText.split(/,\s*/).map(word => word.trim());
words.forEach(word => {
if (word && ingredientsList.includes(word)) {
usedIngredients.add(word);
}
});
}
}
descriptionTextarea.addEventListener('input', function () {
const inputText = this.value.trim();
const words = inputText.split(/,\s*/);
const lastWord = words[words.length - 1].trim().toLowerCase();
descriptionSuggestions.innerHTML = '';
descriptionSuggestions.style.display = 'none';
updateUsedIngredients();
if (lastWord) {
const filteredIngredients = ingredientsList.filter(ingredient =>
ingredient.toLowerCase().includes(lastWord) && !usedIngredients.has(ingredient)
);
if (filteredIngredients.length > 0) {
filteredIngredients.forEach(ingredient => {
const suggestionDiv = document.createElement('div');
suggestionDiv.classList.add('suggestion-item');
suggestionDiv.innerText = ingredient;
suggestionDiv.addEventListener('click', function () {
const currentValue = descriptionTextarea.value;
const lastCommaIndex = currentValue.lastIndexOf(',');
const baseText = lastCommaIndex !== -1 ? currentValue.substring(0, lastCommaIndex + 1) : '';
descriptionTextarea.value = baseText + (baseText ? ' ' : '') + ingredient + ', ';
descriptionSuggestions.style.display = 'none';
descriptionTextarea.focus();
updateUsedIngredients();
});
descriptionSuggestions.appendChild(suggestionDiv);
});
descriptionSuggestions.style.display = 'block';
}
}
});
document.addEventListener('click', function (event) {
if (!descriptionTextarea.contains(event.target) && !descriptionSuggestions.contains(event.target)) {
descriptionSuggestions.style.display = 'none';
}
});
}
fetch('/cart/get')
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
return response.json();
})
.then(data => {
if (data.success) {
updateCartUI(data.cart);
} else {
console.error('Failed to fetch cart:', data.error);
const cart = getCartLocalStorage();
updateCartUI(cart);
}
})
.catch(err => {
console.error('Error fetching cart:', err);
const cart = getCartLocalStorage();
updateCartUI(cart);
});
const preloadedImages = document.querySelectorAll('link[rel="preload"]');
preloadedImages.forEach(link => {
const img = new Image();
img.src = link.href;
});
const decreaseBtn = document.getElementById('decreaseQuantity');
const increaseBtn = document.getElementById('increaseQuantity');
const quantityInput = document.getElementById('quantityInput');
decreaseBtn.addEventListener('click', function () {
let currentQuantity = parseInt(quantityInput.value);
if (currentQuantity > 1) {
currentQuantity--;
quantityInput.value = currentQuantity;
}
});
increaseBtn.addEventListener('click', function () {
let currentQuantity = parseInt(quantityInput.value);
currentQuantity++;
quantityInput.value = currentQuantity;
});
});
function debounce(func, wait) {
let timeout;
return function (...args) {
clearTimeout(timeout);
timeout = setTimeout(() => func.apply(this, args), wait);
};
}
function filterMenu() {
const input = document.getElementById('searchBar').value.trim().toLowerCase();
const sections = document.querySelectorAll('h3');
const items = document.querySelectorAll('.menu-card');
let matchedSections = new Set();
items.forEach(item => {
const itemName = item.querySelector('.card-title').innerText.toLowerCase();
const itemSection = item.closest('.row').previousElementSibling.innerText.toLowerCase();
if (itemName.includes(input) || (itemSection && itemSection.includes(input))) {
item.style.display = 'block';
item.classList.add('visible');
matchedSections.add(item.closest('.row'));
} else {
item.style.display = 'none';
}
});
sections.forEach(section => {
const sectionRow = section.nextElementSibling;
if (matchedSections.has(sectionRow)) {
section.style.display = 'block';
sectionRow.style.display = 'flex';
} else {
section.style.display = 'none';
sectionRow.style.display = 'none';
}
});
if (!input) {
sections.forEach(section => {
section.style.display = 'block';
section.nextElementSibling.style.display = 'flex';
});
items.forEach(item => {
item.style.display = 'block';
item.classList.add('visible');
});
}
}
function showItemDetails(name, price, image, description, section, selectedCategory) {
document.getElementById('modal-name').innerText = name;
document.getElementById('modal-price').innerText = `$${price}`;
const modalImg = document.getElementById('modal-img');
if (section.toLowerCase() === 'soft drinks') {
modalImg.style.display = 'none';
} else {
modalImg.style.display = 'block';
modalImg.src = image || '/static/placeholder.jpg';
}
document.getElementById('modal-description').innerText = description || 'No description available.';
const nutritionalInfoEl = document.getElementById('modal-nutritional-info');
const itemDetails = menuItemDetails[name];
if (itemDetails && itemDetails.nutritionalInfo) {
const { calories, protein, carbs, fats, fiber, sugar } = itemDetails.nutritionalInfo;
nutritionalInfoEl.innerText = `[Energy: ${calories} kcal, Protein: ${protein}g, Carbohydrates: ${carbs}g, Fiber: ${fiber}g, Fat: ${fats}g, Sugar: ${sugar}g]`;
} else {
nutritionalInfoEl.innerText = '[No nutritional info available.]';
}
document.getElementById('addons-list').innerHTML = 'Loading customization options...';
document.getElementById('modal-instructions').value = '';
const modalSectionEl = document.getElementById('modal-section');
modalSectionEl.setAttribute('data-section', section);
modalSectionEl.setAttribute('data-category', selectedCategory);
document.getElementById('quantityInput').value = 1;
const prepStyleOptions = document.getElementById('prep-style-options');
const typeOptions = document.getElementById('type-options');
const spiceLevelOptions = document.getElementById('spice-level-options');
const firstRow = document.getElementById('first-row');
const firstRowTitle = document.getElementById('first-row-title');
const addonsTitle = document.getElementById('addons-title');
prepStyleOptions.innerHTML = '';
typeOptions.innerHTML = '';
spiceLevelOptions.innerHTML = '';
if (section.toLowerCase() === 'starters') {
firstRow.style.display = 'block';
firstRowTitle.style.display = 'block';
addonsTitle.style.display = 'none';
} else {
firstRow.style.display = 'none';
firstRowTitle.style.display = 'none';
addonsTitle.style.display = 'block';
}
const addonsList = document.getElementById('addons-list');
addonsList.innerHTML = '';
const dummySections = [
{ name: "Beverages", options: ["Sprite ($3)", "Thums Up ($3)", "Virgin Mojito ($3)", "Lemonade ($3)", "Blue Lagoon Mocktail ($3)"] },
{ name: "Sauces", options: ["Mint Chutney", "Tomato Sauce"] },
{ name: "Extra Toppings", options: ["Cheese ($2)", "Olives ($1)", "Jalapenos ($1)", "Mushrooms ($2)", "Peppers ($1)"] },
{ name: "Sides", options: ["Fries ($3)", "Salad ($2)", "Garlic Bread ($3)", "Onion Rings ($2)", "Coleslaw ($2)"] },
{ name: "Desserts", options: ["Ice Cream ($3)", "Brownie ($3)", "Cheesecake ($4)", "Gulab Jamun ($3)", "Rasmalai ($4)"] }
];
dummySections.forEach(addon => {
const sectionDiv = document.createElement('div');
sectionDiv.classList.add('addon-section');
sectionDiv.setAttribute('data-addon-name', addon.name);
const title = document.createElement('h6');
title.innerText = addon.name;
sectionDiv.appendChild(title);
const optionsContainer = document.createElement('div');
addon.options.forEach((option, index) => {
const optionId = `addon-${addon.name.replace(/\s+/g, '')}-${index}`;
const listItem = document.createElement('div');
listItem.classList.add('form-check');
listItem.innerHTML = `
<input type="checkbox" class="form-check-input addon-option" id="${optionId}" value="${option}"
data-name="${option}" data-group="${addon.name}" data-price="0">
<label class="form-check-label" for="${optionId}">
${option}
</label>
`;
optionsContainer.appendChild(listItem);
});
sectionDiv.appendChild(optionsContainer);
addonsList.appendChild(sectionDiv);
});
fetch(`/api/addons?item_name=${encodeURIComponent(name)}&item_section=${encodeURIComponent(section)}`)
.then(response => response.json())
.then(data => {
const addonsList = document.getElementById('addons-list');
addonsList.innerHTML = '';
if (!data.success || !data.addons || data.addons.length === 0) {
addonsList.innerHTML = '<p>No customization options available.</p>';
addonsTitle.style.display = 'none';
return;
}
if (section.toLowerCase() === 'starters') {
data.addons.forEach(addon => {
if (addon.name.toLowerCase() === "choose preparation style") {
addon.options.forEach(option => {
const optionId = `addon-prep-style-${option}`;
const optionHTML = `
<div class="form-check">
<input type="checkbox" class="form-check-input" id="${optionId}" value="${option}" data-name="${option}" data-group="Choose Preparation Style">
<label class="form-check-label" for="${optionId}">
${option}
</label>
</div>
`;
prepStyleOptions.innerHTML += optionHTML;
});
}
if (addon.name.toLowerCase() === "type") {
addon.options.forEach(option => {
const optionId = `addon-type-${option}`;
const optionHTML = `
<div class="form-check">
<input type="checkbox" class="form-check-input" id="${optionId}" value="${option}" data-name="${option}" data-group="Type">
<label class="form-check-label" for="${optionId}">
${option}
</label>
</div>
`;
typeOptions.innerHTML += optionHTML;
});
}
if (addon.name.toLowerCase() === "spice level") {
addon.options.forEach(option => {
const optionId = `addon-spice-level-${option}`;
const optionHTML = `
<div class="form-check">
<input type="checkbox" class="form-check-input spice-level-option" id="${optionId}" value="${option}" data-name="${option}" data-group="Spice Level">
<label class="form-check-label" for="${optionId}">
${option}
</label>
</div>
`;
spiceLevelOptions.innerHTML += optionHTML;
});
}
});
}
data.addons.forEach(addon => {
if (section.toLowerCase() === 'starters' &&
(addon.name.toLowerCase() === "type" ||
addon.name.toLowerCase() === "spice level" ||
addon.name.toLowerCase() === "choose preparation style")) {
return;
}
const sectionDiv = document.createElement('div');
sectionDiv.classList.add('addon-section');
sectionDiv.setAttribute('data-addon-name', addon.name);
const title = document.createElement('h6');
title.innerText = addon.name;
sectionDiv.appendChild(title);
const optionsContainer = document.createElement('div');
addon.options.forEach((option, index) => {
const optionId = `addon-${addon.name.replace(/\s+/g, '')}-${index}`;
const listItem = document.createElement('div');
listItem.classList.add('form-check');
listItem.innerHTML = `
<input type="checkbox" class="form-check-input ${addon.name.toLowerCase() === 'spice level' ? 'spice-level-option' : 'addon-option'}" id="${optionId}" value="${option}"
data-name="${option}" data-group="${addon.name}" data-price="${addon.extra_charge ? addon.extra_charge_amount : 0}">
<label class="form-check-label" for="${optionId}">
${option} ${addon.extra_charge ? `($${addon.extra_charge_amount})` : ''}
</label>
`;
optionsContainer.appendChild(listItem);
});
sectionDiv.appendChild(optionsContainer);
addonsList.appendChild(sectionDiv);
});
const startersOrder = [
"Select Dip/Sauce",
"Extra Add-ons",
"Make it a Combo"
];
const desiredOrder = [
"Spice Level",
"Choose Preparation Style",
"Select Dip/Sauce",
"Extra Add-ons",
"Make it a Combo",
"Type"
];
const orderToUse = section.toLowerCase() === 'starters' ? startersOrder : desiredOrder;
const sections = Array.from(addonsList.children);
addonsList.innerHTML = '';
orderToUse.forEach(sectionName => {
const section = sections.find(s => s.getAttribute('data-addon-name') === sectionName);
if (section) {
addonsList.appendChild(section);
}
});
sections.forEach(section => {
if (!orderToUse.includes(section.getAttribute('data-addon-name'))) {
addonsList.appendChild(section);
}
});
})
.catch(err => {
console.error('Error fetching add-ons:', err);
document.getElementById('addons-list').innerHTML = '<p>Error loading customization options.</p>';
addonsTitle.style.display = 'none';
});
}
document.addEventListener('click', function(event) {
if (event.target.classList.contains('spice-level-option') || event.target.classList.contains('addon-option')) {
handleAddonClick(event.target);
}
});
function handleAddonClick(checkbox) {
const groupName = checkbox.getAttribute('data-group');
const isMultiSelectGroup = ["Extra Toppings", "Choose Raita/Sides", "Select Dip/Sauce", "Extra Add-ons", "Make it a Combo", "Beverages", "Sauces"].includes(groupName);
if (groupName.toLowerCase() === "spice level") {
const allSpiceLevelCheckboxes = document.querySelectorAll('.spice-level-option');
allSpiceLevelCheckboxes.forEach(otherCheckbox => {
if (otherCheckbox !== checkbox) {
otherCheckbox.checked = false;
}
});
}
else if (!isMultiSelectGroup) {
const checkboxes = document.querySelectorAll(`.addon-option[data-group="${groupName}"]`);
checkboxes.forEach(otherCheckbox => {
if (otherCheckbox !== checkbox) {
otherCheckbox.checked = false;
}
});
}
}
function addToCartFromModal() {
const itemName = document.getElementById('modal-name').innerText;
let itemPrice = parseFloat(document.getElementById('modal-price').innerText.replace('$', ''));
if (isNaN(itemPrice)) {
alert('Invalid price for the item. Please check the item details.');
return;
}
const itemImage = document.getElementById('modal-img').src;
const modalSectionEl = document.getElementById('modal-section');
const section = modalSectionEl.getAttribute('data-section');
const selectedCategory = modalSectionEl.getAttribute('data-category');
if (!itemName || !itemPrice || !section || !itemImage) {
console.error('Missing data for cart item:', { itemName, itemPrice, section, itemImage});
return;
}
let selectedAddOns = [];
const addonsListOptions = document.querySelectorAll('#addons-list .addon-option');
addonsListOptions.forEach(option => {
if (option.checked) {
selectedAddOns.push({
name: option.getAttribute('data-name') || 'Default Name',
price: parseFloat(option.getAttribute('data-price') || 0)
});
}
});
if (section.toLowerCase() === 'starters') {
const prepStyleOptions = Array.from(
document.querySelectorAll('#prep-style-options input[type="checkbox"]:checked')
).map(option => ({
name: option.getAttribute('data-name') || 'Default Prep Style',
price: 0
}));
const typeOptions = Array.from(
document.querySelectorAll('#type-options input[type="checkbox"]:checked')
).map(option => ({
name: option.getAttribute('data-name') || 'Default Type',
price: 0
}));
const spiceLevelOption = document.querySelector('#spice-level-options input[type="checkbox"].spice-level-option:checked');
const spiceLevelOptions = spiceLevelOption ? [{
name: spiceLevelOption.getAttribute('data-name') || 'Default Spice Level',
price: 0
}] : [];
selectedAddOns = [...selectedAddOns, ...prepStyleOptions, ...typeOptions, ...spiceLevelOptions];
}
const quantity = parseInt(document.getElementById('quantityInput').value) || 1;
const instructions = document.getElementById('modal-instructions').value;
const cartPayload = {
itemName: itemName,
itemPrice: itemPrice,
itemImage: itemImage,
section: section,
category: selectedCategory,
addons: selectedAddOns,
instructions: instructions,
quantity: quantity
};
fetch('/cart/add', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(cartPayload)
})
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
return response.json();
})
.then(data => {
if (data.success) {
alert('Item added to cart successfully!');
updateCartUI(data.cart);
const modal = document.getElementById('itemModal');
const modalInstance = bootstrap.Modal.getInstance(modal);
modalInstance.hide();
} else {
console.error('Failed to add item to cart:', data.error);
alert(data.error || 'Failed to add item to cart.');
}
})
.catch(err => {
console.error('Error adding item to cart:', err);
alert('An error occurred while adding the item to the cart: ' + err.message);
const cart = addToCartLocalStorage(cartPayload);
updateCartUI(cart);
const modal = document.getElementById('itemModal');
const modalInstance = bootstrap.Modal.getInstance(modal);
modalInstance.hide();
});
}
function handleSoftDrinkAdd(button) {
const buttonContainer = button.closest('.button-container');
const quantitySelector = buttonContainer.querySelector('.quantity-selector');
const addButton = buttonContainer.querySelector('.add-to-cart-btn');
const quantityDisplay = quantitySelector.querySelector('.quantity-display');
const quantityToAddSelect = quantitySelector.querySelector('.quantity-to-add');
const quantityToAdd = parseInt(quantityToAddSelect.value);
const itemName = buttonContainer.getAttribute('data-item-name');
const itemPrice = parseFloat(buttonContainer.getAttribute('data-item-price'));
const itemImage = buttonContainer.getAttribute('data-item-image');
const section = buttonContainer.getAttribute('data-item-section');
const selectedCategory = buttonContainer.getAttribute('data-item-category');
addButton.style.display = 'none';
quantitySelector.style.display = 'flex';
let currentQuantity = parseInt(quantityDisplay.innerText) || 0;
currentQuantity += quantityToAdd;
quantityDisplay.innerText = currentQuantity;
const cartPayload = {
itemName: itemName,
itemPrice: itemPrice,
itemImage: itemImage,
section: section,
category: selectedCategory,
addons: [],
instructions: '',
quantity: quantityToAdd
};
button.disabled = true;
fetch('/cart/add', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(cartPayload)
})
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
return response.json();
})
.then(data => {
if (data.success) {
alert(`Added ${quantityToAdd} item(s) to cart successfully!`);
updateCartUI(data.cart);
} else {
console.error('Failed to add item to cart:', data.error);
alert(data.error || 'Failed to add item to cart.');
currentQuantity -= quantityToAdd;
quantityDisplay.innerText = currentQuantity;
}
})
.catch(err => {
console.error('Error adding item to cart:', err);
alert('An error occurred while adding the item to the cart: ' + err.message);
const cart = addToCartLocalStorage(cartPayload);
updateCartUI(cart);
})
.finally(() => {
button.disabled = false;
});
}
function increaseQuantity(button) {
const buttonContainer = button.closest('.button-container');
const quantityDisplay = buttonContainer.querySelector('.quantity-display');
const quantityToAddSelect = buttonContainer.querySelector('.quantity-to-add');
const quantityToAdd = parseInt(quantityToAddSelect.value);
const itemName = buttonContainer.getAttribute('data-item-name');
const itemPrice = parseFloat(buttonContainer.getAttribute('data-item-price'));
const itemImage = buttonContainer.getAttribute('data-item-image');
const section = buttonContainer.getAttribute('data-item-section');
const selectedCategory = buttonContainer.getAttribute('data-item-category');
let currentQuantity = parseInt(quantityDisplay.innerText) || 0;
currentQuantity += quantityToAdd;
quantityDisplay.innerText = currentQuantity;
const cartPayload = {
itemName: itemName,
itemPrice: itemPrice,
itemImage: itemImage,
section: section,
category: selectedCategory,
addons: [],
instructions: '',
quantity: quantityToAdd
};
fetch('/cart/add', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(cartPayload)
})
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
return response.json();
})
.then(data => {
if (data.success) {
alert(`Added ${quantityToAdd} item(s) to cart successfully!`);
updateCartUI(data.cart);
} else {
console.error('Failed to add item to cart:', data.error);
alert(data.error || 'Failed to add item to cart.');
currentQuantity -= quantityToAdd;
quantityDisplay.innerText = currentQuantity;
}
})
.catch(err => {
console.error('Error adding item to cart:', err);
alert('An error occurred while adding the item to the cart: ' + err.message);
const cart = addToCartLocalStorage(cartPayload);
updateCartUI(cart);
});
}
function decreaseQuantity(button) {
const buttonContainer = button.closest('.button-container');
const quantityDisplay = buttonContainer.querySelector('.quantity-display');
const quantityToRemoveSelect = buttonContainer.querySelector('.quantity-to-remove');
const quantityToRemove = parseInt(quantityToRemoveSelect.value);
const addButton = buttonContainer.querySelector('.add-to-cart-btn');
const quantitySelector = buttonContainer.querySelector('.quantity-selector');
let currentQuantity = parseInt(quantityDisplay.innerText);
if (currentQuantity <= quantityToRemove) {
const itemName = buttonContainer.getAttribute('data-item-name');
fetch(`/cart/remove?item_name=${encodeURIComponent(itemName)}&quantity=${currentQuantity}&instructions=&addons=[]`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
}
})
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
return response.json();
})
.then(data => {
if (data.success) {
updateCartUI(data.cart);
addButton.style.display = 'block';
quantitySelector.style.display = 'none';
quantityDisplay.innerText = 0;
} else {
console.error('Failed to remove item from cart:', data.error);
alert(data.error || 'Failed to remove item from cart.');
}
})
.catch(err => {
console.error('Error removing item from cart:', err);
alert('An error occurred while removing the item from the cart: ' + err.message);
const cart = removeFromCartLocalStorage(itemName, currentQuantity, '', []);
updateCartUI(cart);
addButton.style.display = 'block';
quantitySelector.style.display = 'none';
quantityDisplay.innerText = 0;
});
} else {
currentQuantity -= quantityToRemove;
quantityDisplay.innerText = currentQuantity;
const itemName = buttonContainer.getAttribute('data-item-name');
fetch(`/cart/remove?item_name=${encodeURIComponent(itemName)}&quantity=${quantityToRemove}&instructions=&addons=[]`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
}
})
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
return response.json();
})
.then(data => {
if (data.success) {
alert(`Removed ${quantityToRemove} item(s) from cart successfully!`);
updateCartUI(data.cart);
} else {
console.error('Failed to remove item from cart:', data.error);
alert(data.error || 'Failed to remove item from cart.');
currentQuantity += quantityToRemove;
quantityDisplay.innerText = currentQuantity;
}
})
.catch(err => {
console.error('Error removing item from cart:', err);
alert('An error occurred while removing the item from the cart: ' + err.message);
const cart = removeFromCartLocalStorage(itemName, quantityToRemove, '', []);
updateCartUI(cart);
});
}
}
function updateCartUI(cart) {
if (!Array.isArray(cart)) {
console.error('Invalid cart data:', cart);
return;
}
// Calculate total quantity of items in cart
let totalQuantity = 0;
cart.forEach(item => {
totalQuantity += item.quantity;
});
// Update cart item count badge
const cartItemCount = document.getElementById('cart-item-count');
if (cartItemCount) {
cartItemCount.innerText = totalQuantity;
if (totalQuantity > 0) {
cartItemCount.classList.add('active');
} else {
cartItemCount.classList.remove('active');
}
}
// Update quantity displays for soft drinks
const buttonContainers = document.querySelectorAll('.button-container');
buttonContainers.forEach(container => {
const itemName = container.getAttribute('data-item-name');
const quantityDisplay = container.querySelector('.quantity-display');
const addButton = container.querySelector('.add-to-cart-btn');
const quantitySelector = container.querySelector('.quantity-selector');
const cartItem = cart.find(item =>
item.itemName === itemName &&
item.instructions === '' &&
JSON.stringify(item.addons) === JSON.stringify([])
);
if (cartItem && cartItem.quantity > 0) {
quantityDisplay.innerText = cartItem.quantity;
addButton.style.display = 'none';
quantitySelector.style.display = 'flex';
} else {
quantityDisplay.innerText = 0;
addButton.style.display = 'block';
quantitySelector.style.display = 'none';
}
});
}
</script>
</body>
</html> |