document.addEventListener("DOMContentLoaded", () => { deleteDot(); initMenu(); addMenuToggle(); pagePreloader(); setBiggerMessage(); if (window.innerWidth <= 768) addMobileIcon(); }); function pagePreloader() { setTimeout(() => { const mainContent = document.querySelector(".gc-main-content"); const preloader = document.querySelector(".loader-container"); mainContent.classList.add("show"); mainContent.style.opacity = 1; preloader.remove(); }, 200); } function setBiggerMessage() { const url = window.location.href; if(url.includes("/webinar")) { const input = document.querySelector("input.new-comment-input"); return input.maxLength = 700; } } function initMenu() { const nativeMenu = document.querySelector(".gc-account-leftbar"); const mainContent = document.querySelector(".gc-main-content"); const menuItems = { admin: [ { name: "Профиль", link: "#", icon: ``, submenu: [ { name: "Посмотреть профиль", link: "/user/my/profile" }, { name: "Изменить пароль", link: "/user/my/changePassword" }, { name: "Уведомления", link: "/pl/notifications/settings/my" }, { name: "Прием платежей", link: "/saas/account/paymentsSettings" }, { name: "Настройки аккаунта", link: "/pl/saas/account/show" }, { name: "Хранилище", link: "/pl/fileindex/file/index" }, { name: "Поддержка ГК", link: "/pl/notifications/support" } ], }, { name: "Сайт", link: "#", icon: ``, submenu: [ { name: "Страницы", link: "/pl/cms/page" }, { name: "Виджеты", link: "/cms/control/xdget"}, { name: "Вебинары", link: "/pl/webinar/control/index" }, { name: "Трафик", link: "/pl/metrika/traffic" } ], }, { name: "Курсы", link: "#", icon: ``, submenu: [ { name: "Курсы", link: "/teach/control/stream" }, { name: "Расписание", link: "/pl/teach/control/schedule" }, { name: "Ответы", link: "/teach/control/answers/unanswered" }, { name: "Тесты", link: "/pl/teach/questionary" }, { name: "Дипломы", link: "/pl/teach/control/diploma" }, { name: "Цели", link: "/pl/teach/goal" }, { name: "Контоль качества", link: "/teach/control/stat/userTrainingFeedback" }, { name: "Поиск", link: "/c/s/search" } ], }, { name: "Ученики", link: "#", icon: ``, submenu: [ { name: "Списки", link: "/pl/user/user/index" }, { name: "Звонки и встречи", link: "/pl/user/contact/index" }, { name: "Дашборды", link: "/pl/logic/funnel" }, { name: "Статистика", link: "/user/control/user/statistic" }, { name: "Настройки", link: "/pl/user/settings" } ], }, { name: "CRM", link: "#", icon: ``, submenu: [ { name: "Доска заказов", link: "/pl/tasks/task/kanban/deals" }, { name: "Доска задач", link: "/pl/tasks/task/kanban/tasks/kanban" }, { name: "Списки задач", link: "/pl/tasks/task/kanban/tasks/list" }, { name: "Процессы", link: "/pl/tasks/mission/index" }, { name: "Статистика", link: "/pl/tasks/task/stat" }, { name: "Мои задачи", link: "/pl/tasks/task/my" } ], }, { name: "Сообщения", link: "#", icon: ``, submenu: [ { name: "Входящие", link: "/pl/tasks/resp" }, { name: "Рассылки", link: "/notifications/control/mailings" }, { name: "Настройки", link: "/pl/notifications/control/account-settings" }, { name: "Шаблоны", link: "/pl/notifications/control/mailings/templates-list" }, { name: "VK", link: "/pl/vk/control/themes" }, { name: "WhatsApp", link: "/pl/whatsapp/control/bots" }, { name: "Telegram", link: "/pl/telegram/control/bots" }, { name: "Viber", link: "/pl/viber/control/bots" }, { name: "Отчеты", link: "/pl/user/employers-stat/index" } ], }, { name: "Покупки", link: "#", icon: ``, submenu: [ { name: "Доска заказов", link: "/pl/tasks/task/kanban/deals" }, { name: "Список заказов", link: "/sales/default/deals" }, { name: "Продукты", link: "/pl/sales/product/index" }, { name: "Партнерская программа", link: "/sales/control/participant" }, { name: "Статистика", link: "/pl/sales/dealstat/index" }, { name: "Мои покупки", link: "/sales/control/userProduct/my" }, { name: "Промоакции", link: "/pl/sales/promo" }, { name: "Потоки", link: "/pl/sales/stream/stream-stat" }, { name: "Платежный модуль", link: "/pl/gcpay/client/payment" } ] } ], teacher: [ { name: "Профиль", link: "#", icon: ``, submenu: [ { name: "Посмотреть профиль", link: "/user/my/profile" }, { name: "Изменить пароль", link: "/user/my/changePassword" }, { name: "Уведомления", link: "/pl/notifications/settings/my" }, { name: "Поддержка ГК", link: "/pl/notifications/support" } ] }, { name: "Сайт", link: "#", icon: ``, submenu: [ { name: "Страницы", link: "/pl/cms/page" }, { name: "Виджеты", link: "/cms/control/xdget"}, { name: "Вебинары", link: "/pl/webinar/control/index" } ], }, { name: "Курсы", link: "#", icon: ``, submenu: [ { name: "Курсы", link: "/teach/control/stream" }, { name: "Расписание", link: "/pl/teach/control/schedule" }, { name: "Ответы", link: "/teach/control/answers/unanswered" }, { name: "Тесты", link: "/pl/teach/questionary" }, { name: "Дипломы", link: "/pl/teach/control/diploma" }, { name: "Цели", link: "/pl/teach/goal" }, { name: "Контоль качества", link: "/teach/control/stat/userTrainingFeedback" }, { name: "Поиск", link: "/c/s/search" } ], }, { name: "Ученики", link: "#", icon: ``, submenu: [ { name: "Списки", link: "/pl/user/user/index" }, { name: "Звонки и встречи", link: "/pl/user/contact/index" }, { name: "Дашборды", link: "/pl/logic/funnel" }, { name: "Статистика", link: "/user/control/user/statistic" }, { name: "Настройки", link: "/pl/user/settings" } ], }, { name: "CRM", link: "#", icon: ``, submenu: [ { name: "Доска заказов", link: "/pl/tasks/task/kanban/deals" }, { name: "Доска задач", link: "/pl/tasks/task/kanban/tasks/kanban" }, { name: "Списки задач", link: "/pl/tasks/task/kanban/tasks/list" }, { name: "Процессы", link: "/pl/tasks/mission/index" }, { name: "Статистика", link: "/pl/tasks/task/stat" }, { name: "Мои задачи", link: "/pl/tasks/task/my" } ], }, { name: "Сообщения", link: "#", icon: ``, submenu: [ { name: "Входящие", link: "/pl/tasks/resp" }, { name: "Рассылки", link: "/notifications/control/mailings" }, { name: "Настройки", link: "/pl/notifications/control/account-settings" }, { name: "Отчеты", link: "/pl/user/employers-stat/index" } ], }, { name: "Покупки", link: "#", icon: ``, submenu: [ { name: "Доска заказов", link: "/pl/tasks/task/kanban/deals" }, { name: "Список заказов", link: "/sales/default/deals" }, { name: "Продукты", link: "/pl/sales/product/index" }, { name: "Партнерская программа", link: "/sales/control/participant" }, { name: "Статистика", link: "/pl/sales/dealstat/index" }, { name: "Мои покупки", link: "/sales/control/userProduct/my" }, { name: "Промоакции", link: "/pl/sales/promo" }, { name: "Потоки", link: "/pl/sales/stream/stream-stat" } ], } ], user: [ { name: "Профиль", link: "#", icon: ``, submenu: [ { name: "Посмотреть профиль", link: "/user/my/profile" }, { name: "Изменить пароль", link: "/user/my/changePassword" }, { name: "Уведомления", link: "/pl/notifications/settings/my" }, { name: "Выйти из аккаунта", link: "/user/my/logout" } ] }, { name: "Курсы", link: "#", icon: ``, submenu: [ { name: "Курсы", link: "/teach/control/stream" }, { name: "Расписание", link: "/pl/teach/control/schedule" }, { name: "Ответы", link: "/teach/control/answers/my" }, { name: "Тестирования", link: "/user/control/user/questionary" }, { name: "Поиск", link: "/c/s/search" } ], }, { name: "Сообщения", link: "#", icon: ``, submenu: [ { name: "Сообщения", link: "/pl/talks/conversation" } ], }, { name: "Покупки", link: "#", icon: ``, submenu: [ { name: "Мои покупки", link: "/sales/control/userProduct/my" } ], } ], }; let currentMenu = []; if (mainContent.classList.contains("gc-user-admin")) { currentMenu = menuItems.admin; } else if (mainContent.classList.contains("gc-user-teacher")) { currentMenu = menuItems.teacher; } else if (mainContent.classList.contains("gc-user-user")) { currentMenu = menuItems.user; } const generateMenuHTML = (items) => { return items.map(item => { const submenuHTML = item.submenu ? `` : ''; return `
  • ${submenuHTML}
  • `; }).join(''); }; const generateSubmenuHTML = (items) => { return items.map(item => { return `
  • ${item.name}
  • `; }).join(''); }; nativeMenu.innerHTML = ``; const menuItemsElements = nativeMenu.querySelectorAll('.custom-menu-item'); menuItemsElements.forEach(item => { item.addEventListener('click', function (event) { const submenu = this.querySelector('.custom-submenu'); const isVisible = submenu && submenu.classList.contains('visible'); menuItemsElements.forEach(elem => elem.classList.remove('active')); const allSubmenus = nativeMenu.querySelectorAll('.custom-submenu'); allSubmenus.forEach(sub => sub.classList.remove('visible')); if (submenu) { if (!isVisible) { item.classList.add('active'); submenu.classList.add('visible'); } } }) }); } function addMobileIcon() { const nativeMenu = document.querySelector(".gc-account-leftbar"); const customMenu = document.querySelector(".custom-menu"); const menuSVG = ``; const closeSVG = ``; customMenu.classList.add("mobile-menu"); const mobileWrapper = document.createElement("div"); const mobileIcon = document.createElement("div"); mobileIcon.innerHTML = `${menuSVG}`; mobileIcon.classList.add("mobile-icon"); mobileWrapper.classList.add("mobile-wrapper"); nativeMenu.prepend(mobileWrapper); mobileWrapper.appendChild(mobileIcon); mobileWrapper.appendChild(customMenu); mobileIcon.addEventListener("click", () => { mobileWrapper.classList.toggle("collapsed"); mobileIcon.innerHTML = `${mobileWrapper.classList.contains("collapsed") ? closeSVG : menuSVG}`; }); } function addMenuToggle() { const nativeMenu = document.querySelector(".gc-account-leftbar"); const customMenu = document.querySelector(".custom-menu"); const menuNames = Array.from(document.querySelectorAll(".menu-item-name")); const menuToggleSVG = ``; const menuToggleWrapper = document.createElement("div"); menuToggleWrapper.classList.add("menu-toggle-wrapper"); menuToggleWrapper.innerHTML = `${menuToggleSVG}`; customMenu.prepend(menuToggleWrapper); const menuState = JSON.parse(localStorage.getItem('menuState')) || {}; const mainContent = document.querySelector(".gc-main-content.with-left-menu"); if (menuState.menuToggled) { nativeMenu.classList.add("toggled"); menuNames.forEach(item => item.classList.add("hide")); mainContent.classList.add("short"); } document.querySelector(".menu-toggle-button").addEventListener("click", () => { nativeMenu.classList.toggle("toggled"); menuNames.forEach(item => item.classList.toggle("hide")); menuState.menuToggled = nativeMenu.classList.contains("toggled"); localStorage.setItem('menuState', JSON.stringify(menuState)); if (nativeMenu.classList.contains("toggled")) { mainContent.classList.add("short"); } else { mainContent.classList.remove("short"); } }); } function deleteDot() { document.querySelectorAll(".stream-table tbody tr td a > div > b").forEach(item => item.textContent = item.textContent.replace(".", "")); }