-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexport.html
218 lines (197 loc) · 7.76 KB
/
export.html
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<!DOCTYPE HTML>
<html>
<head>
<title>Map Digi</title>
<meta name="viewport"
content="width=device-width, user-scalable=no, minimum-scale=1, maximum-scale=1,initial-scale=1" />
<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />
<script>window.version = 6;</script>
<script src="scripts/azure-storage.common.min.js"></script>
<script src="scripts/azure-storage.blob.min.js"></script>
<script src="scripts/util.js?v=1"></script>
<script src="scripts/model.js"></script>
<script src="scripts/azuredb.js"></script>
<script src="scripts/index.js"></script>
<link rel="icon" type="img/png" href="img/favicon96.png" sizes="96x96" />
<link rel="icon" type="img/png" href="img/favicon32.png" sizes="32x32" />
<link rel="icon" type="img/png" href="img/favicon16.png" sizes="16x16" />
<style>
body {
font-family: 'Raleway', 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
}
h1,
h2,
h3 {
font-family: Georgia, 'Times New Roman', Times, serif;
color: darkblue;
}
img {
max-width: 800px;
max-height: 800px;
}
.caption {
margin-left: 100px;
}
.mapref {
font-family: monospace, sans-serif;
}
@page {
size: A4;
margin: 11mm 17mm 17mm 17mm;
}
@media screen {
footer {
display: none;
}
}
@media print {
footer {
font-size: 9px;
color: #f00;
text-align: center;
position: fixed;
bottom: 0;
}
.content-block,
p {
page-break-inside: avoid;
}
html,
body {
width: 210mm;
height: 297mm;
}
}
</style>
<script>
async function init() {
window.project = await Project.get();
html("head", window.project.title);
window.Places = {};
window.groupsAvailable = {};
dbGetKeys(function (data) {
dbLoadPlaces(function (placeArray) {
placeArray.forEach(function (place) {
try {
if (!place.deleted) {
window.Places[place.id] = place;
let group = place.group || "";
if (!window.groupsAvailable[group]) {
window.groupsAvailable[group] = [];
}
window.groupsAvailable[place.group].push(place);
}
}
catch (e) {
g("content").innerHTML = e;
}
});
window.groupList = sortGroups();
window.pages = divideIntoPages(window.groupList, window.groupsAvailable);
setSelector(window.pages, 0);
window.selectedPageIndex = 0;
showPage(pages, groupsAvailable, 0);
});
});
}
/** Break whole set of places into groups of about 20 places, ordered by containing group.
* @param groupList - Ordered list of group names
* @param groupedPlaces - map group name -> list of places
* @returns List of list of group name
*/
function divideIntoPages(groupList, groupedPlaces) {
let pages = [];
let pageContentCount = 0;
let page = [];
for (let i = 0; i < groupList.length; i++) {
page.push(groupList[i]);
pageContentCount += groupedPlaces[groupList[i]].length;
if (pageContentCount >= 20) {
pages.push(page);
pageContentCount = 0;
page = [];
}
}
if (pageContentCount > 0) {
pages.push(page);
}
return pages;
}
function sortGroups() {
let groupList = [];
Object.keys(groupsAvailable).forEach(groupId => { groupList.push(groupId); });
groupList.sort();
return groupList;
}
function chunk(tag, content) {
let h2 = document.createElement(tag);
if (content) html(h2, content);
g("content").appendChild(h2);
return h2;
}
function selectGroup() {
window.selectedPageIndex = g("groupSelectorUi").selectedIndex;
showPage(window.pages, window.groupsAvailable, window.selectedPageIndex);
}
function nextSection(inc) {
window.selectedPageIndex = ((window.selectedPageIndex + inc) + window.pages.length) % window.pages.length;
g("groupSelectorUi").selectedIndex = window.selectedPageIndex;
showPage(window.pages, window.groupsAvailable, window.selectedPageIndex);
}
function showPage(pages, groupedPlaces, index) {
g("content").innerHTML = "";
let page = pages[index];
for (let gi = 0; gi < page.length; gi++) {
let groupName = page[gi];
chunk("h2", groupName);
chunk("footer", groupName);
let group = groupedPlaces[groupName];
group.sort((a, b) => (a.Title || "").localeCompare(b.Title || ""));
for (let pi = 0; pi < group.length; pi++) {
let place = group[pi];
chunk("h3", place.Title);
chunk("p", `<a href="${getLink(place)}" target="map">{${d6(place.loc.n)}, ${d6(place.loc.e)}}</a>`).className = "mapref";
chunk("div", place.text);
for (let k = 0; k < place.pics.length; k++) {
let pic = place.pics[k];
if (pic.isPicture) {
let img = chunk("img", null);
img.onload = () => {
img.style.transform = pic.transform;
};
img.src = PicUrl(pic.id);
} else {
let a = chunk("a", `<img src='${pic.fileTypeIcon}' />`);
a.href = PicUrl(pic.id);
a.target = "_blank";
}
if (pic.Caption) chunk("div", pic.Caption).className = "caption";
}
}
}
}
function setSelector(pages, selectedIndex) {
let gsHtml = "";
gsHtml += "<select id='groupSelectorUi' onchange='selectGroup()'>";
for (let i = 0; i < pages.length; i++) {
gsHtml += "<option value='{0}' {1}>{2}</option>".format(
i,
selectedIndex == i ? "selected" : "",
pages[i][0]);
}
gsHtml += "</select>";
g("groupSelectorBox").innerHTML = gsHtml;
}
</script>
</head>
<body onload="init()">
<h1 id="head"></h1>
<div style="float: right;"><a href="https://mapdigi.org/api/kml" target="_blank">KML</a></div>
Select page:
<div><button onclick="nextSection(-1)"><</button><span id="groupSelectorBox"></span><button
onclick="nextSection(1)">></button></div>
<div id="content"><i>Loading...</i></div>
<div><button onclick="nextSection(-1)">< Previous</button><button
onclick="nextSection(1)">Next ></button></div>
</body>
</html>