var csrftoken = document.querySelector("[name=csrfmiddlewaretoken]").value; const body = document.querySelector('body'); const darkmode_checkbox = document.getElementById("darkmode_checkbox"); darkmode_checkbox.addEventListener("change", () => { isDarkMode = darkmode_checkbox.checked; if (isDarkMode){ body.classList.add('dark-mode'); } else{ body.classList.remove('dark-mode'); } const data = { isDarkMode: isDarkMode }; fetch("/update_user_theme", { method: "POST", headers: { "X-CSRFToken": csrftoken, "Content-Type": "application/json", }, body: JSON.stringify(data), }) .then(() => { }) .catch((error) => { }); }); function SupportTicket(){ const message = $("#supportticketmessage").val().trim(); if (!message) { Swal.fire({ icon: 'warning', text: 'Message cannot be empty...', }) return; } Swal.fire({ title: 'Processing...', text: 'Please wait while we generate your support ticket.', allowOutsideClick: false, showConfirmButton: false, willOpen: () => { Swal.showLoading(); } }); const data = { message }; fetch("/create_support_ticket", { method: "POST", headers: { "X-CSRFToken": csrftoken, "Content-Type": "application/json", }, body: JSON.stringify(data), }) .then((response) => response.json()) .then((data) => { if (data.success) { Swal.fire({ title: `Support Ticket #${data.ticket_id} Generated Successfully!!`, text: "Our team will reach you out shortly.", icon: "success" }).then(() => { $('#viewSupportModal').modal('hide'); }); } else if (data.error) { Swal.fire({ icon: 'error', title: 'Oops...', text: 'Something went wrong! Try again later...', }).then(() => { $('#viewSupportModal').modal('hide'); }); } }) .catch((error) => { console.error("Error:", error); Swal.fire({ icon: 'error', title: 'Oops...', text: 'Something went wrong! Try again later...', }).then(() => { $('#viewSupportModal').modal('hide'); }) }); } $("#viewSupportModal").on("hidden.bs.modal", function () { $("#supportticketmessage").val(""); });