对以下代码中的主要功能进行解释：    <div class="header">
        <div class="wrap">
            <div class="logo">
    
            </div>
            <div class="search">
                <div>
                    <div class="search-log"></div>
                    <div class="form">
                        <button>
                            <img src="./images/放大镜.png" alt="">
                        </button>
                        <div class="list">
    
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="cart">
        <div class="wrap">
            <div class="cart-tit">
                <input type="checkbox" id="all-check"><label for="all-check">全选</label>
                <span>商品信息</span>
                <span>单价</span>
                <span>数量</span>
                <span>小计</span>
                <span>操作</span>
            </div>
            <div class="cart-list">
                <ul>
                    <li>
                        <input type="checkbox" class="item-check" checked>
                        <div class="item-info">
                            <a href="detail.html"><img src="./images/9.jpg" alt=""></a>
                            <div class="item-name">
                                <a href="detail.html">海贼王</a>
                                <p>颜色：黑色 尺码：L</p>
                            </div>
                        </div>
                        <div class="item-price">199</div>
                        <div class="item-num">
                            <a href="javascript:;" class="minus">-</a>
                            <input type="text" value="1">
                            <a href="javascript:;" class="add">+</a>
                        </div>
                        <div class="item-total">199</div>
                        <div class="item-operate">
                            <a href="javascript:;">删除</a>
                        </div>
                    </li>
                    <li>
                        <input type="checkbox" class="item-check" checked>
                        <div class="item-info">
                            <a href="detail.html"><img src="./images/10.jpg" alt=""></a>
                            <div class="item-name">
                                <a href="detail.html">海贼王</a>
                                <p>颜色：白色 尺码：M</p>
                            </div>
                        </div>
                        <div class="item-price">199</div>
                        <div class="item-num">
                            <a href="javascript:;" class="minus">-</a>
                            <input type="text" value="1">
                            <a href="javascript:;" class="add">+</a>
                        </div>
                        <div class="item-total">199</div>
                        <div class="item-operate">
                            <a href="javascript:;">删除</a>
                        </div>
                    </li>
                </ul>
            </div>
            <div class="cart-footer">
                <div class="footer-left">
                    <input type="checkbox" id="all-check2"><label for="all-check2">全选</label>
                    <a href="javascript:;">删除</a>
                </div>
                <div class="footer-right">
                    <div class="total-price">
                        <p>合计：<span>398</span></p>
                        <p>不含运费</p>
                    </div>
                    <a href="javascript:;" class="pay">结算</a>
                </div>
            </div>
        </div>
    </div>
    <script src="./js/cart.js"></script>
    <script>// 添加在这里
        var pluses = document.getElementsByClassName("plus");
        var reduces = document.getElementsByClassName("reduce");
        var checkboxes = document.getElementsByClassName("item-check");
        var deleteBtns = document.getElementsByClassName("item-operate");
    
        function updateTotal() {
            var totalPrice = 0;
            for (let index = 0; index < checkboxes.length; index++) {
                const checkbox = checkboxes[index];
                if (checkbox.checked) {
                    var li = checkbox.parentNode;
                    var num = parseInt(li.querySelector(".item-num input").value);
                    var price = parseInt(li.querySelector(".item-price").innerText);
                    var subtotal = num * price;
                    li.querySelector(".item-total").innerText = subtotal;
                    totalPrice += subtotal;
                }
            }
            document.querySelector(".total-price span").innerText = totalPrice;
        }
    
        function deleteItem() {
            var li = this.parentNode.parentNode;
            li.parentNode.removeChild(li);
        }
    
        for (let index = 0; index < pluses.length; index++) {
            const btnPlus = pluses[index];
            btnPlus.onclick = function () {
                var inputObj = this.previousElementSibling;
                inputObj.value = Number(inputObj.value) + 1;
                updateTotal();
            }
        }
    
        for (let index = 0; index < reduces.length; index++) {
            const btnReduce = reduces[index];
            btnReduce.onclick = function () {
                var inputObj = this.nextElementSibling;
                if (inputObj.value > 1) {
                    inputObj.value = Number(inputObj.value) - 1;
                } else {
                    inputObj.value = 1;
                }
                updateTotal();
            }
        }
    
        for (let index = 0; index < checkboxes.length; index++) {
            const checkbox = checkboxes[index];
            checkbox.onclick = updateTotal;
        }
    
        for (let index = 0; index < deleteBtns.length; index++) {
            const btnDelete = deleteBtns[index].querySelector("a");
            btnDelete.onclick = deleteItem;
        }
    
        document.getElementById("all-check").onclick = function () {
            var isChecked = this.checked;
            for (let index = 0; index < checkboxes.length; index++) {
                const checkbox = checkboxes[index];
                checkbox.checked = isChecked;
            }
            updateTotal();
        }
    
        document.getElementById("all-check2").onclick = function () {
            var isChecked = this.checked;
            checkboxs = document.querySelectorAll(".cart-list input[type='checkbox'");
            for (let index = 0; index < checkboxs.length; index++) {
                const checkbox = checkboxs[index];
                checkbox.checked = isChecked;
            }
            updateTotal();
        }
    
        document.querySelector(".footer-left a").onclick = function () {
            var checkedItems = document.querySelectorAll(".cart-list input[type='checkbox']:checked");
            for (let index = 0; index < checkedItems.length; index++) {
                const checkedItem = checkedItems[index];
                checkedItem.parentNode.parentNode.remove();
            }
            updateTotal();
        }
    
        document.querySelector(".pay").onclick = function () {
            alert("结算");