annotate src/citymap.js @ 2725:7a0ec8693402

Remove debug logs.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 07 Mar 2024 10:35:05 +0200
parents 8f923c830b19
children b68157126f41
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2562
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 //
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 // Positioning, tooltip etc utility functions in JavaScript for BatMUD maps
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3 // Programmed by Matti 'ccr' Hamalainen <ccr@tnsp.org>
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4 // (C) Copyright 2006-2024 Tecnic Software productions (TNSP)
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5 //
2570
8f923c830b19 Generate tooltips in citymaps via Javascript instead of building them into div elements in mkcitymap.
Matti Hamalainen <ccr@tnsp.org>
parents: 2569
diff changeset
6 var mapTipData = null;
8f923c830b19 Generate tooltips in citymaps via Javascript instead of building them into div elements in mkcitymap.
Matti Hamalainen <ccr@tnsp.org>
parents: 2569
diff changeset
7 var mapTipItem = null, mapTipTitle = null, mapTipNames = null, mapTipFreeform;
8f923c830b19 Generate tooltips in citymaps via Javascript instead of building them into div elements in mkcitymap.
Matti Hamalainen <ccr@tnsp.org>
parents: 2569
diff changeset
8 var mapTipXC = 0, mapTipYC = 0;
2562
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9
2570
8f923c830b19 Generate tooltips in citymaps via Javascript instead of building them into div elements in mkcitymap.
Matti Hamalainen <ccr@tnsp.org>
parents: 2569
diff changeset
10 var mapElem = null, listElem = null, mapElemPrev = null;
2562
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11 var mapDragEnable = true, mapDragGoing = false;
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12 var mapDragPos = { x: 0, y: 0, mx: 0, my: 0 };
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
13 var mapCurrID;
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16 function mapFindElemCoords(elem)
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17 {
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18 var xc = yc = 0;
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19 if (elem.offsetParent)
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20 {
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21 xc = elem.offsetLeft;
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22 yc = elem.offsetTop;
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
23 while (elem = elem.offsetParent)
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
24 {
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
25 xc += elem.offsetLeft;
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
26 yc += elem.offsetTop;
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
27 }
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
28 }
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
29
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
30 return { x: xc, y: yc, mx: 0, my: 0 };
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31 }
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34 function mapGetWindowSize()
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35 {
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36 var winW = 0, winH = 0;
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37 if (typeof(window.innerWidth) == 'number')
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38 {
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39 // Non-MSIE
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40 winW = window.innerWidth;
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41 winH = window.innerHeight;
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
42 }
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
43 else
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44 if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45 {
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
46 // MSIE 6+ in 'standards compliant mode'
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
47 winW = document.documentElement.clientWidth;
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
48 winH = document.documentElement.clientHeight;
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
49 }
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
50 else
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
51 if (document.body && (document.body.clientWidth || document.body.clientHeight))
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
52 {
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
53 // MSIE 4 compatible
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
54 winW = document.body.clientWidth;
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
55 winH = document.body.clientHeight;
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
56 }
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
57
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
58 return { w: winW, h: winH };
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
59 }
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
60
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
61
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
62 // Add or remove given CSS class to specified element
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
63 function mapSetStyle(uid, ustyle, uset)
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
64 {
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
65 var uelem = document.getElementById(uid);
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
66 if (uelem)
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
67 {
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
68 if (uset)
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
69 uelem.classList.add(ustyle);
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
70 else
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
71 uelem.classList.remove(ustyle);
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
72 }
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
73 }
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
74
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
75
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
76 // Update the tooltip box
2569
575e23079e62 Rename some functions for cleaner names and consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 2567
diff changeset
77 function mapTooltipUpdate(ev)
2562
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
78 {
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
79 var x = document.all ? (window.event.x + document.body.scrollLeft) : ev.pageX;
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
80 var y = document.all ? (window.event.y + document.body.scrollTop) : ev.pageY;
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
81 if (mapTipItem != null)
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
82 {
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
83 const dim = mapGetWindowSize();
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
84 var boxW = mapTipItem.clientWidth + 25, boxH = mapTipItem.clientHeight + 25;
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
85
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
86 if (x + boxW + 15 >= dim.w)
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
87 x -= boxW;
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
88 else
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
89 x += 15;
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
90
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
91 if (y + boxH + 15 >= dim.h)
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
92 y -= boxH;
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
93 else
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
94 y += 15;
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
95
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
96 mapTipXC = x;
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
97 mapTipYC = y;
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
98
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
99 mapTipItem.style.left = x + "px";
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
100 mapTipItem.style.top = y + "px";
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
101 }
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
102 }
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
103
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
104
2569
575e23079e62 Rename some functions for cleaner names and consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 2567
diff changeset
105 function mapTooltipShow(ev)
2562
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
106 {
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
107 const eid = ev.target.dataset.id;
2570
8f923c830b19 Generate tooltips in citymaps via Javascript instead of building them into div elements in mkcitymap.
Matti Hamalainen <ccr@tnsp.org>
parents: 2569
diff changeset
108 mapTipData = document.getElementById("listloc"+ eid);
8f923c830b19 Generate tooltips in citymaps via Javascript instead of building them into div elements in mkcitymap.
Matti Hamalainen <ccr@tnsp.org>
parents: 2569
diff changeset
109 if (mapTipData != null)
8f923c830b19 Generate tooltips in citymaps via Javascript instead of building them into div elements in mkcitymap.
Matti Hamalainen <ccr@tnsp.org>
parents: 2569
diff changeset
110 {
8f923c830b19 Generate tooltips in citymaps via Javascript instead of building them into div elements in mkcitymap.
Matti Hamalainen <ccr@tnsp.org>
parents: 2569
diff changeset
111 mapTipTitle.textContent = mapTipData.dataset.ttTitle;
8f923c830b19 Generate tooltips in citymaps via Javascript instead of building them into div elements in mkcitymap.
Matti Hamalainen <ccr@tnsp.org>
parents: 2569
diff changeset
112 mapTipNames.textContent = mapTipData.dataset.ttNames;
8f923c830b19 Generate tooltips in citymaps via Javascript instead of building them into div elements in mkcitymap.
Matti Hamalainen <ccr@tnsp.org>
parents: 2569
diff changeset
113 mapTipFreeform.textContent = mapTipData.dataset.ttFreeform;
8f923c830b19 Generate tooltips in citymaps via Javascript instead of building them into div elements in mkcitymap.
Matti Hamalainen <ccr@tnsp.org>
parents: 2569
diff changeset
114 }
2562
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
115
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
116 mapTipItem.style.left = mapTipXC + "px";
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
117 mapTipItem.style.top = mapTipYC + "px";
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
118 mapTipItem.style.display = "block";
2570
8f923c830b19 Generate tooltips in citymaps via Javascript instead of building them into div elements in mkcitymap.
Matti Hamalainen <ccr@tnsp.org>
parents: 2569
diff changeset
119 mapTooltipUpdate(ev);
2562
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
120 }
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
121
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
122
2569
575e23079e62 Rename some functions for cleaner names and consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 2567
diff changeset
123 function mapTooltipHide(ev)
2562
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
124 {
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
125 if (mapTipItem)
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
126 {
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
127 mapTipItem.style.display = "none";
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
128 }
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
129 }
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
130
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
131
2569
575e23079e62 Rename some functions for cleaner names and consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 2567
diff changeset
132 function mapSetActive(eid, uset)
575e23079e62 Rename some functions for cleaner names and consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 2567
diff changeset
133 {
575e23079e62 Rename some functions for cleaner names and consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 2567
diff changeset
134 mapSetStyle('maploc'+eid, "locactive", uset);
575e23079e62 Rename some functions for cleaner names and consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 2567
diff changeset
135 mapSetStyle('listloc'+eid, "locactive", uset);
575e23079e62 Rename some functions for cleaner names and consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 2567
diff changeset
136 }
575e23079e62 Rename some functions for cleaner names and consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 2567
diff changeset
137
575e23079e62 Rename some functions for cleaner names and consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 2567
diff changeset
138
575e23079e62 Rename some functions for cleaner names and consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 2567
diff changeset
139 function mapLocationShow2(ev)
575e23079e62 Rename some functions for cleaner names and consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 2567
diff changeset
140 {
575e23079e62 Rename some functions for cleaner names and consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 2567
diff changeset
141 const eid = ev.target.dataset.id;
575e23079e62 Rename some functions for cleaner names and consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 2567
diff changeset
142
2570
8f923c830b19 Generate tooltips in citymaps via Javascript instead of building them into div elements in mkcitymap.
Matti Hamalainen <ccr@tnsp.org>
parents: 2569
diff changeset
143 if (mapElemPrev != null) mapSetActive(mapElemPrev, false);
2569
575e23079e62 Rename some functions for cleaner names and consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 2567
diff changeset
144 mapSetActive(eid, true);
2570
8f923c830b19 Generate tooltips in citymaps via Javascript instead of building them into div elements in mkcitymap.
Matti Hamalainen <ccr@tnsp.org>
parents: 2569
diff changeset
145 mapElemPrev = eid;
2569
575e23079e62 Rename some functions for cleaner names and consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 2567
diff changeset
146 }
575e23079e62 Rename some functions for cleaner names and consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 2567
diff changeset
147
575e23079e62 Rename some functions for cleaner names and consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 2567
diff changeset
148
575e23079e62 Rename some functions for cleaner names and consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 2567
diff changeset
149 function mapLocationHide(ev)
575e23079e62 Rename some functions for cleaner names and consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 2567
diff changeset
150 {
2570
8f923c830b19 Generate tooltips in citymaps via Javascript instead of building them into div elements in mkcitymap.
Matti Hamalainen <ccr@tnsp.org>
parents: 2569
diff changeset
151 if (mapElemPrev != null) mapSetActive(mapElemPrev, false);
8f923c830b19 Generate tooltips in citymaps via Javascript instead of building them into div elements in mkcitymap.
Matti Hamalainen <ccr@tnsp.org>
parents: 2569
diff changeset
152 mapElemPrev = null;
2569
575e23079e62 Rename some functions for cleaner names and consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 2567
diff changeset
153 mapTooltipHide(ev);
575e23079e62 Rename some functions for cleaner names and consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 2567
diff changeset
154 }
575e23079e62 Rename some functions for cleaner names and consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 2567
diff changeset
155
575e23079e62 Rename some functions for cleaner names and consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 2567
diff changeset
156
575e23079e62 Rename some functions for cleaner names and consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 2567
diff changeset
157 function mapLocationShow1(ev)
575e23079e62 Rename some functions for cleaner names and consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 2567
diff changeset
158 {
575e23079e62 Rename some functions for cleaner names and consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 2567
diff changeset
159 const eid = ev.target.dataset.id;
575e23079e62 Rename some functions for cleaner names and consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 2567
diff changeset
160 mapLocationShow2(ev);
575e23079e62 Rename some functions for cleaner names and consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 2567
diff changeset
161
575e23079e62 Rename some functions for cleaner names and consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 2567
diff changeset
162 mapTooltipHide(ev);
575e23079e62 Rename some functions for cleaner names and consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 2567
diff changeset
163 mapTooltipShow(ev);
575e23079e62 Rename some functions for cleaner names and consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 2567
diff changeset
164 }
575e23079e62 Rename some functions for cleaner names and consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 2567
diff changeset
165
575e23079e62 Rename some functions for cleaner names and consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 2567
diff changeset
166
2562
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
167 function mapSetMapPosToID(eid)
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
168 {
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
169 const dim = mapGetWindowSize();
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
170 var nelem = document.getElementById('maploc'+eid);
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
171 if (nelem)
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
172 {
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
173 const pos = mapFindElemCoords(nelem);
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
174 mapDragPos.x = pos.x - (dim.w / 2);
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
175 mapDragPos.y = pos.y - (dim.h / 2);
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
176
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
177 mapElem.scrollLeft = mapDragPos.x;
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
178 mapElem.scrollTop = mapDragPos.y;
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
179 }
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
180
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
181 nelem = document.getElementById('listloc'+eid);
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
182 if (nelem)
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
183 {
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
184 const pos = mapFindElemCoords(nelem);
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
185 listElem.scrollTop = pos.y - 10;
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
186 }
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
187 }
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
188
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
189
2569
575e23079e62 Rename some functions for cleaner names and consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 2567
diff changeset
190 function mapLocationClick(ev)
2562
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
191 {
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
192 const eid = ev.target.dataset.id;
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
193 if (mapCurrID != eid)
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
194 {
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
195 mapSetStyle('maploc'+mapCurrID, "lochilite", false);
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
196 mapSetStyle('listloc'+mapCurrID, "lochilite", false);
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
197 }
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
198 mapCurrID = eid;
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
199
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
200 mapSetStyle('maploc'+eid, "lochilite", true);
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
201 mapSetStyle('listloc'+eid, "lochilite", true);
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
202 mapSetMapPosToID(eid);
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
203 }
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
204
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
205
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
206 function mapDragUpHandler(ev)
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
207 {
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
208 if (mapDragGoing)
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
209 {
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
210 mapDragGoing = false;
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
211 mapElem.style.cursor = "grab";
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
212 mapElem.style.removeProperty("user-select");
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
213 }
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
214 }
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
215
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
216
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
217 function mapDragMoveHandler(ev)
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
218 {
2569
575e23079e62 Rename some functions for cleaner names and consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 2567
diff changeset
219 mapTooltipUpdate(ev);
2562
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
220 if (mapDragGoing)
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
221 {
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
222 const dx = ev.clientX - mapDragPos.mx;
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
223 const dy = ev.clientY - mapDragPos.my;
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
224
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
225 mapElem.scrollLeft = mapDragPos.x - dx;
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
226 mapElem.scrollTop = mapDragPos.y - dy;
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
227 }
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
228 }
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
229
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
230
2569
575e23079e62 Rename some functions for cleaner names and consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 2567
diff changeset
231 function mapDragStartPan(ev)
2562
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
232 {
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
233 if (mapDragEnable)
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
234 {
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
235 mapElem.style.cursor = "grabbing";
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
236 mapElem.style.userSelect = "none";
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
237
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
238 mapDragPos = {
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
239 x: mapElem.scrollLeft,
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
240 y: mapElem.scrollTop,
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
241 mx: ev.clientX,
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
242 my: ev.clientY,
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
243 };
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
244
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
245 mapDragGoing = true;
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
246 }
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
247 }
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
248
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
249
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
250 function mapOnLoad()
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
251 {
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
252 mapElem = document.getElementById("smap");
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
253 listElem = document.getElementById("loclist");
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
254
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
255 mapElem.style.cursor = "grab";
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
256
2570
8f923c830b19 Generate tooltips in citymaps via Javascript instead of building them into div elements in mkcitymap.
Matti Hamalainen <ccr@tnsp.org>
parents: 2569
diff changeset
257 // Create tooltip div
8f923c830b19 Generate tooltips in citymaps via Javascript instead of building them into div elements in mkcitymap.
Matti Hamalainen <ccr@tnsp.org>
parents: 2569
diff changeset
258 mapTipItem = document.createElement("div");
8f923c830b19 Generate tooltips in citymaps via Javascript instead of building them into div elements in mkcitymap.
Matti Hamalainen <ccr@tnsp.org>
parents: 2569
diff changeset
259 mapTipItem.id = "tooltip";
8f923c830b19 Generate tooltips in citymaps via Javascript instead of building them into div elements in mkcitymap.
Matti Hamalainen <ccr@tnsp.org>
parents: 2569
diff changeset
260 mapTipItem.style.display = "none";
8f923c830b19 Generate tooltips in citymaps via Javascript instead of building them into div elements in mkcitymap.
Matti Hamalainen <ccr@tnsp.org>
parents: 2569
diff changeset
261 mapTipTitle = document.createElement("h1");
8f923c830b19 Generate tooltips in citymaps via Javascript instead of building them into div elements in mkcitymap.
Matti Hamalainen <ccr@tnsp.org>
parents: 2569
diff changeset
262 mapTipNames = document.createElement("div");
8f923c830b19 Generate tooltips in citymaps via Javascript instead of building them into div elements in mkcitymap.
Matti Hamalainen <ccr@tnsp.org>
parents: 2569
diff changeset
263 mapTipNames.className = "names";
8f923c830b19 Generate tooltips in citymaps via Javascript instead of building them into div elements in mkcitymap.
Matti Hamalainen <ccr@tnsp.org>
parents: 2569
diff changeset
264 mapTipFreeform = document.createElement("div");
8f923c830b19 Generate tooltips in citymaps via Javascript instead of building them into div elements in mkcitymap.
Matti Hamalainen <ccr@tnsp.org>
parents: 2569
diff changeset
265 mapTipFreeform.className = "freeform";
8f923c830b19 Generate tooltips in citymaps via Javascript instead of building them into div elements in mkcitymap.
Matti Hamalainen <ccr@tnsp.org>
parents: 2569
diff changeset
266 mapTipItem.appendChild(mapTipTitle);
8f923c830b19 Generate tooltips in citymaps via Javascript instead of building them into div elements in mkcitymap.
Matti Hamalainen <ccr@tnsp.org>
parents: 2569
diff changeset
267 mapTipItem.appendChild(mapTipNames);
8f923c830b19 Generate tooltips in citymaps via Javascript instead of building them into div elements in mkcitymap.
Matti Hamalainen <ccr@tnsp.org>
parents: 2569
diff changeset
268 mapTipItem.appendChild(mapTipFreeform);
8f923c830b19 Generate tooltips in citymaps via Javascript instead of building them into div elements in mkcitymap.
Matti Hamalainen <ccr@tnsp.org>
parents: 2569
diff changeset
269 document.body.appendChild(mapTipItem);
8f923c830b19 Generate tooltips in citymaps via Javascript instead of building them into div elements in mkcitymap.
Matti Hamalainen <ccr@tnsp.org>
parents: 2569
diff changeset
270
2562
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
271 // Add event listeners to locations
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
272 var elems = document.getElementsByClassName("loc");
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
273 for (let i = 0; i < elems.length; i++)
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
274 {
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
275 var elem = elems[i];
2569
575e23079e62 Rename some functions for cleaner names and consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 2567
diff changeset
276 elem.addEventListener("mouseover", mapTooltipShow);
575e23079e62 Rename some functions for cleaner names and consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 2567
diff changeset
277 elem.addEventListener("mouseout", mapTooltipHide);
575e23079e62 Rename some functions for cleaner names and consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 2567
diff changeset
278 elem.addEventListener("click", mapLocationClick);
2562
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
279 }
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
280
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
281 // .. and location list items
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
282 var elems = document.getElementsByClassName("item");
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
283 for (let i = 0; i < elems.length; i++)
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
284 {
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
285 var elem = elems[i];
2569
575e23079e62 Rename some functions for cleaner names and consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 2567
diff changeset
286 elem.addEventListener("mouseover", elem.dataset.info == "true" ? mapLocationShow1 : mapLocationShow2);
575e23079e62 Rename some functions for cleaner names and consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 2567
diff changeset
287 elem.addEventListener("mouseout", mapLocationHide);
575e23079e62 Rename some functions for cleaner names and consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 2567
diff changeset
288 elem.addEventListener("click", mapLocationClick);
2562
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
289 }
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
290
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
291 // And map navigation / tooltip stuff
2569
575e23079e62 Rename some functions for cleaner names and consistency.
Matti Hamalainen <ccr@tnsp.org>
parents: 2567
diff changeset
292 mapElem.addEventListener("mousedown", mapDragStartPan);
2562
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
293 document.addEventListener("mousemove", mapDragMoveHandler);
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
294 document.addEventListener("mouseup", mapDragUpHandler);
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
295
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
296 // Finally, scroll to position
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
297 var slink = window.location.href;
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
298 if ((spos = slink.indexOf("#")) >= 0)
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
299 {
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
300 var eid = unescape(slink.substr(spos + 1).toLowerCase()).trim();
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
301 var elem = document.getElementById('maploc'+eid);
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
302 if (elem)
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
303 {
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
304 mapCurrID = eid;
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
305
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
306 mapSetStyle('maploc'+eid, "lochilite", true);
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
307 mapSetStyle('listloc'+eid, "lochilite", true);
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
308
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
309 setTimeout(function()
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
310 {
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
311 mapSetMapPosToID(eid);
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
312 },
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
313 50);
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
314 }
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
315 }
2b81727da194 Refactor some of the javascript snippets out from the HTML files themselves
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
316 }