import "jsvectormap/dist/jsvectormap.min.css"; import "flatpickr/dist/flatpickr.min.css"; import "dropzone/dist/dropzone.css"; import "../css/style.css"; import Alpine from "alpinejs"; import persist from "@alpinejs/persist"; import flatpickr from "flatpickr"; import Dropzone from "dropzone"; import chart01 from "./components/charts/chart-01"; import chart02 from "./components/charts/chart-02"; import chart03 from "./components/charts/chart-03"; import map01 from "./components/map-01"; import "./components/calendar-init.js"; import "./components/image-resize"; Alpine.plugin(persist); window.Alpine = Alpine; Alpine.start(); // Init flatpickr flatpickr(".datepicker", { mode: "range", static: true, monthSelectorType: "static", dateFormat: "M j", defaultDate: [new Date().setDate(new Date().getDate() - 6), new Date()], prevArrow: '', nextArrow: '', onReady: (selectedDates, dateStr, instance) => { // eslint-disable-next-line no-param-reassign instance.element.value = dateStr.replace("to", "-"); const customClass = instance.element.getAttribute("data-class"); instance.calendarContainer.classList.add(customClass); }, onChange: (selectedDates, dateStr, instance) => { // eslint-disable-next-line no-param-reassign instance.element.value = dateStr.replace("to", "-"); }, }); // Init Dropzone const dropzoneArea = document.querySelectorAll("#demo-upload"); if (dropzoneArea.length) { let myDropzone = new Dropzone("#demo-upload", { url: "/file/post" }); } // Document Loaded document.addEventListener("DOMContentLoaded", () => { chart01(); chart02(); chart03(); map01(); }); // Get the current year const year = document.getElementById("year"); if (year) { year.textContent = new Date().getFullYear(); } // For Copy// document.addEventListener("DOMContentLoaded", () => { const copyInput = document.getElementById("copy-input"); if (copyInput) { // Select the copy button and input field const copyButton = document.getElementById("copy-button"); const copyText = document.getElementById("copy-text"); const websiteInput = document.getElementById("website-input"); // Event listener for the copy button copyButton.addEventListener("click", () => { // Copy the input value to the clipboard navigator.clipboard.writeText(websiteInput.value).then(() => { // Change the text to "Copied" copyText.textContent = "Copied"; // Reset the text back to "Copy" after 2 seconds setTimeout(() => { copyText.textContent = "Copy"; }, 2000); }); }); } }); document.addEventListener("DOMContentLoaded", function () { const searchInput = document.getElementById("search-input"); const searchButton = document.getElementById("search-button"); // Function to focus the search input function focusSearchInput() { searchInput.focus(); } // Add click event listener to the search button searchButton.addEventListener("click", focusSearchInput); // Add keyboard event listener for Cmd+K (Mac) or Ctrl+K (Windows/Linux) document.addEventListener("keydown", function (event) { if ((event.metaKey || event.ctrlKey) && event.key === "k") { event.preventDefault(); // Prevent the default browser behavior focusSearchInput(); } }); // Add keyboard event listener for "/" key document.addEventListener("keydown", function (event) { if (event.key === "/" && document.activeElement !== searchInput) { event.preventDefault(); // Prevent the "/" character from being typed focusSearchInput(); } }); });