<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<script>
document.addEventListener("DOMContentLoaded", function() {
    document.querySelectorAll(".sm2_button").forEach(button => {
        let audio = null; // Biến audio khai báo ngoài để lưu trữ audio đang phát
        
        button.addEventListener("click", function(event) {
            event.preventDefault(); // Ngăn chặn chuyển hướng
            
            // Nếu đang active thì dừng audio và gỡ class
            if (this.classList.contains('active')) {
                if (audio) {
                    audio.pause();
                    audio.currentTime = 0; // tua về đầu
                }
                this.classList.remove('active');
                return; // Không làm gì thêm nữa
            }

            // Nếu chưa có class 'active2' thì thêm vào
            if (!this.classList.contains('active2')) {
                this.classList.add('active2');
            }

            this.classList.add('active'); // Thêm class active
            audio = new Audio(this.href); // Tạo mới audio
            audio.play(); // Phát audio

            // Khi audio kết thúc, xóa class active
            audio.onended = () => {
                this.classList.remove('active');
            };
        });
    });
});

</script>
    <script>
        jQuery(document).ready(function ($) {
            $('.qh_Explanation > p').click(function(){
                $('.qh_Explanation > div').stop().slideToggle()
            });
    $(".qh_checkbox").on("change", function () {
        let checkbox = $(this);
        let isChecked = checkbox.prop("checked"); // Trạng thái checked hoặc unchecked
        let qh_mark_div = checkbox.closest(".qh_mark");
        let post_id = qh_mark_div.data("id"); // Lấy giá trị data-id

        $.ajax({
            url: 'https://mandarinmi.com/wp-admin/admin-ajax.php', // WordPress AJAX URL
            type: "POST",
            data: {
                action: "update_qh_mark",
                post_id: post_id,
                status: isChecked ? "checked" : "unchecked"
            },
            success: function (response) {
                Swal.fire({
                    icon: "success",
                    title: "Success!",
                    text: response.message,
                    timer: 2000,
                    showConfirmButton: false
                });
            },
            error: function () {
                Swal.fire({
                    icon: "error",
                    title: "Error!",
                    text: "An error occurred, please try again.",
                });
            }
        });
    });
});

</script>
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="https://mandarinmi.com/wp-sitemap-index.xsl" ?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap><loc>https://mandarinmi.com/wp-sitemap-posts-page-1.xml</loc></sitemap><sitemap><loc>https://mandarinmi.com/wp-sitemap-posts-hanzi_vocab-1.xml</loc></sitemap><sitemap><loc>https://mandarinmi.com/wp-sitemap-taxonomies-vocab_category-1.xml</loc></sitemap><sitemap><loc>https://mandarinmi.com/wp-sitemap-users-1.xml</loc></sitemap></sitemapindex>
