-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmap.js
More file actions
42 lines (35 loc) · 1.07 KB
/
map.js
File metadata and controls
42 lines (35 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const tooltip = document.getElementById('tooltip');
const places = document.querySelectorAll(".place")
places.forEach((place) => {
if(place.dataset.status == "Занят"){
place.classList.add("occupied")
}
if(place.dataset.status == "Резерв"){
place.classList.add("reserve")
}
})
document.addEventListener('mouseover', (e) => {
const target = e.target.closest('.has-tooltip');
if (!target) return;
let name = target.dataset.tooltip;
let status= target.dataset.status;
let owner = target.dataset.owner;
let html = `
<div class="tooltip_title">${name}</div>
<div class="tooltip_row">${status}</div>
`;
if (status === "Занят" && owner) {
html += `<div class="tooltip_row">${owner}</div>`;
}
tooltip.innerHTML = html;
tooltip.style.opacity = 1;
});
document.addEventListener('mousemove', (e) => {
tooltip.style.left = (e.pageX + 10) + 'px';
tooltip.style.top = (e.pageY + 10) + 'px';
});
document.addEventListener('mouseout', (e) => {
if (e.target.closest('.has-tooltip')) {
tooltip.style.opacity = 0;
}
});