blob: 4f421005e99d183f493c84c838cfb8f9bd37ad90 [file] [log] [blame]
Davit Tabidze207ce082024-04-09 19:15:25 +04001document.addEventListener("DOMContentLoaded", function () {
gio18d5c682024-05-02 10:30:57 +04002 document.querySelector('iframe').contentDocument.write("Welcome to the dodo: application launcher, think of it as your desktop environment. You can launch applications from left-hand side dock. You should setup VPN clients on your devices, so you can install applications from Application Manager and access your private network. Instructions on how to do that can be viewed by clicking <b>Help</b> button after hovering over <b>Headscale</b> icon in the dock.");
3
Davit Tabidze207ce082024-04-09 19:15:25 +04004 function showTooltip(obj) {
5 // obj.style.display = 'flex';
6 obj.style.visibility = 'visible';
7 obj.style.opacity = '1';
8 }
9 function hideTooltip(obj) {
10 obj.style.visibility = 'hidden';
11 obj.style.opacity = '0';
12 // obj.style.display = '';
13 }
14 const circle = document.querySelector(".user-circle");
15 const tooltipUser = document.querySelector("#tooltip-user");
16 [
17 ['mouseenter', () => showTooltip(tooltipUser)],
18 ['mouseleave', () => hideTooltip(tooltipUser)],
19 ].forEach(([event, listener]) => {
20 circle.addEventListener(event, listener);
21 });
22 const icons = document.querySelectorAll(".app-icon-tooltip");
23 icons.forEach(function (icon) {
24 icon.addEventListener("click", function (event) {
25 event.stopPropagation();
26 const appUrl = this.getAttribute("data-app-url");
27 document.getElementById('appFrame').src = 'about:blank';
28 document.getElementById('appFrame').src = appUrl;
29 document.querySelectorAll(".app-icon-tooltip .background-glow").forEach((e) => e.remove());
30 const glow = document.createElement('div');
31 glow.classList.add("background-glow");
32 glow.setAttribute("style", "transform: none; transform-origin: 50% 50% 0px;")
33 this.appendChild(glow);
34 });
35 const tooltip = icon.querySelector('.tooltip');
36 tooltip.addEventListener("click", function (event) {
37 event.stopPropagation();
38 });
39 [
40 ['mouseenter', () => showTooltip(tooltip)],
41 ['mouseleave', () => hideTooltip(tooltip)],
42 ['focus', () => showTooltip(tooltip)],
43 ['blur', () => hideTooltip(tooltip)],
44 ].forEach(([event, listener]) => {
45 icon.addEventListener(event, listener);
46 });
47 });
gio92d86862024-05-21 12:51:31 +040048 let visibleModal = undefined;
49 const openModal = function(modal) {
50 modal.removeAttribute("close");
51 modal.setAttribute("open", true);
52 visibleModal = modal;
53 };
54 const closeModal = function(modal) {
55 modal.removeAttribute("open");
56 modal.setAttribute("close", true);
57 visibleModal = undefined;
58 };
Davit Tabidze207ce082024-04-09 19:15:25 +040059 const helpButtons = document.querySelectorAll('.help-button');
60 helpButtons.forEach(function (button) {
61 button.addEventListener('click', function (event) {
62 event.stopPropagation();
63 const buttonId = button.getAttribute('id');
64 const modalId = 'modal-' + buttonId.substring("help-button-".length);
65 const closeHelpId = "close-help-" + buttonId.substring("help-button-".length);
66 const modal = document.getElementById(modalId);
gio92d86862024-05-21 12:51:31 +040067 openModal(modal);
Davit Tabidze207ce082024-04-09 19:15:25 +040068 const closeHelpButton = document.getElementById(closeHelpId);
69 closeHelpButton.addEventListener('click', function (event) {
gio92d86862024-05-21 12:51:31 +040070 event.stopPropagation();
71 closeModal(modal);
Davit Tabidze207ce082024-04-09 19:15:25 +040072 });
73 });
74 });
75 const modalHelpButtons = document.querySelectorAll('.title-menu');
76 modalHelpButtons.forEach(function (button) {
77 button.addEventListener('click', function (event) {
78 event.stopPropagation();
79 const helpTitle = button.getAttribute('id');
80 const helpTitleId = helpTitle.substring('title-'.length);
81 const helpContentId = 'help-content-' + helpTitleId;
82 const allContentElements = document.querySelectorAll('.help-content');
83 allContentElements.forEach(function (contentElement) {
gio106b0242024-05-21 12:17:03 +040084 contentElement.style.display = "none";
Davit Tabidze207ce082024-04-09 19:15:25 +040085 });
gio106b0242024-05-21 12:17:03 +040086 modalHelpButtons.forEach(function (button) {
87 button.removeAttribute("aria-current");
88 });
89 document.getElementById(helpContentId).style.display = 'block';
90 button.setAttribute("aria-current", "page");
Davit Tabidze207ce082024-04-09 19:15:25 +040091 });
92 });
gio92d86862024-05-21 12:51:31 +040093 document.addEventListener("keydown", (event) => {
94 if (event.key === "Escape" && visibleModal) {
95 closeModal(visibleModal);
96 }
97 });
98 document.addEventListener("click", (event) => {
99 if (visibleModal === null) return;
100 const modalContent = visibleModal.querySelector("article");
101 const isClickInside = modalContent.contains(event.target);
102 if (!isClickInside) {
103 closeModal(visibleModal);
104 }
105 });
Davit Tabidze207ce082024-04-09 19:15:25 +0400106});