var id = 1; // Represents the ID of order items
var options_id = 0; // Used for something related to options
var item_map = new Map(); // Map to store order items
var total = 0; // Represents the total price of the order
var order_id = -1; // Represents the ID of the order
document.addEventListener("DOMContentLoaded", function() {
// ... Event listener code ...
});
Creates an order item based on a template and manages related functionalities.
Parameters:
item
(HTMLElement
): The item to be added to the order.
function createOrderItem(item) {
// ... Function code ...
}
Filters and shows/hides items based on the selected category.
Parameters:
category
(string
): The category to be displayed.
function changeCategory(category) {
// ... Function code ...
}
Increments the quantity of an item and updates the order list.
Parameters:
item
(HTMLElement
): The order item to be updated.item_price
(number
): The price of the item.new_quantity
(number
): The quantity to be added.editing
(boolean
): Indicates if the quantity is being edited.
function addQuantity(item, item_price, new_quantity, editing=false) {
// ... Function code ...
}
Subtracts quantity from an order item.
Parameters:
item
(HTMLElement
): The order item element.item_price
(string
): The price of the item.new_quantity
(number
): The quantity to subtract.editing
(boolean
): Whether the quantity is being edited.
function subtractQuantity(item, item_price, new_quantity, editing=false) {
// ... Function code ...
}
Edits the quantity of an order item.
Parameters:
item
(HTMLElement
): The order item element.item_price
(string
): The price of the item.
function editQuantity(item, item_price) {
// ... Function code ...
}
Deletes an order item.
Parameters:
item
(HTMLElement
): The order item element.item_price
(string
): The price of the item.
function deleteItem(item, item_price) {
// ... Function code ...
}
Saves the order.
function save_order() {
// ... Function code ...
}
Clears the order.
function clear_order() {
// ... Function code ...
}
Prints the item map to the console.
function print() {
// ... Function code ...
}
Constructor function for a map item.
Parameters:
id
(number
): The unique identifier of the item.name
(string
): The name of the item.price
(number
): The price of the item.quantity
(number
): The quantity of the item.
/**
* @param {number} id - The unique identifier of the item.
* @param {string} name - The name of the item.
* @param {number} price - The price of the item.
* @param {number} quantity - The quantity of the item.
*/
map_item = function (id, name, price, quantity){
// ... Constructor code ...
}
Function to get the value of a cookie by name.
Parameters:
name
(string
): The name of the cookie.
/**
* @param {string} name - The name of the cookie.
* @returns {string} The value of the cookie.
*/
function getCookie(name) {
// ... Function code ...
}