Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
1052 lines (975 loc) · 64.7 KB
/
Copy pathindex.html
File metadata and controls
1052 lines (975 loc) · 64.7 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
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Neverwinter — Interactive Map</title>
<style>
:root{
--ink:#e8dfcc; --ink-dim:#a49c8b; --ink-faint:#6f6a5e;
--bg:#14120f; --panel:#1c1a16; --panel-2:#232019; --line:#38332a;
--gold:#d9b04a; --gold-dim:#8a6f2c;
--accent:#c8703c;
--font-ui:"Iowan Old Style","Palatino Linotype",Palatino,Georgia,serif;
--font-sans:ui-sans-serif,-apple-system,"Segoe UI",Roboto,sans-serif;
}
*{box-sizing:border-box}
html,body{height:100%;margin:0}
body{
background:var(--bg); color:var(--ink); font-family:var(--font-ui);
display:flex; overflow:hidden; -webkit-font-smoothing:antialiased;
}
button{font:inherit;color:inherit;cursor:pointer}
/* ---------- sidebar ---------- */
#side{
width:326px; flex:0 0 326px; height:100%; background:var(--panel);
border-right:1px solid var(--line); display:flex; flex-direction:column;
}
#side header{padding:16px 18px 12px;border-bottom:1px solid var(--line)}
#side h1{
margin:0; font-size:21px; font-weight:600; letter-spacing:.14em;
text-transform:uppercase; color:var(--gold);
}
#side header p{margin:6px 0 0;font-size:11.5px;color:var(--ink-faint);line-height:1.5;font-family:var(--font-sans)}
.scroll{flex:1;overflow-y:auto;overflow-x:hidden}
.sec{border-bottom:1px solid var(--line);padding:14px 18px}
.sec h2{
margin:0 0 10px; font-size:10.5px; letter-spacing:.18em; text-transform:uppercase;
color:var(--ink-faint); font-family:var(--font-sans); font-weight:600;
}
.row{display:flex;align-items:center;gap:9px;padding:5px 0;font-size:13.5px;cursor:pointer;user-select:none}
.row:hover{color:#fff}
.sw{width:11px;height:11px;border-radius:2px;flex:0 0 11px;border:1px solid rgba(0,0,0,.5)}
.row input{accent-color:var(--gold);margin:0;cursor:pointer}
.row .ct{margin-left:auto;font-size:11px;color:var(--ink-faint);font-family:var(--font-sans)}
.row.off{opacity:.42}
.btn{
background:var(--panel-2); border:1px solid var(--line); color:var(--ink);
padding:8px 12px; border-radius:5px; font-size:12.5px; font-family:var(--font-sans);
display:inline-flex; align-items:center; gap:7px; transition:.12s;
}
.btn:hover{background:#2b2720;border-color:#4d463a}
.btn.wide{width:100%;justify-content:center}
.btn.on{background:var(--gold);color:#1a1508;border-color:var(--gold);font-weight:600}
.btn.sm{padding:6px 9px;font-size:11.5px}
.btns{display:flex;gap:7px}
#search{
width:100%;background:#12100d;border:1px solid var(--line);color:var(--ink);
padding:8px 10px;border-radius:5px;font-size:13px;font-family:var(--font-sans);
}
#search:focus{outline:none;border-color:var(--gold-dim)}
#chips{display:flex;flex-wrap:wrap;gap:5px;margin-top:9px}
#chips button{
background:#12100d;border:1px solid var(--line);color:var(--ink-dim);
padding:4px 9px;border-radius:20px;font-size:11.5px;font-family:var(--font-sans);
}
#chips button:hover{border-color:var(--gold-dim);color:var(--ink)}
#results{margin-top:9px}
#results:empty{margin-top:0}
.tags{display:flex;flex-wrap:wrap;gap:4px;margin-top:4px}
.tags span{
font-size:9.5px;letter-spacing:.06em;text-transform:uppercase;font-family:var(--font-sans);
background:rgba(217,176,74,.14);color:#c9a552;border-radius:3px;padding:2px 5px;
}
.item{
padding:8px 10px;border-radius:5px;cursor:pointer;font-size:13.5px;
display:flex;align-items:flex-start;gap:8px;line-height:1.35;
}
.item:hover{background:var(--panel-2)}
.item .dot{width:8px;height:8px;border-radius:50%;flex:0 0 8px;margin-top:5px}
.item .nm{flex:1;min-width:0}
.item .sub{display:block;font-size:10.5px;color:var(--ink-faint);font-family:var(--font-sans);margin-top:2px}
.item .x{opacity:0;background:none;border:none;color:var(--ink-faint);padding:0 3px;font-size:15px;line-height:1}
.item:hover .x{opacity:1}
.item .x:hover{color:#e07050}
.empty{font-size:12px;color:var(--ink-faint);font-family:var(--font-sans);line-height:1.6;padding:2px 0}
/* ---------- map ---------- */
#map{flex:1;position:relative;overflow:hidden;background:#0d0c0a;cursor:grab}
#map.grabbing{cursor:grabbing}
#map.placing{cursor:crosshair}
#map.measuring{cursor:crosshair}
#world{position:absolute;top:0;left:0;transform-origin:0 0;will-change:transform}
#world img{display:block;width:1600px;height:1128px;user-select:none;-webkit-user-drag:none}
#zones{position:absolute;top:0;left:0;pointer-events:none}
#zones path{transition:fill-opacity .18s, stroke-opacity .18s}
.mk{position:absolute;top:0;left:0;transform-origin:0 0;will-change:transform}
.mk>*{pointer-events:auto}
.dlab{
transform-origin:0 0; white-space:nowrap; text-align:center; pointer-events:none;
font-size:21px; letter-spacing:.16em; text-transform:uppercase; font-weight:700;
padding:8px 18px 9px; border-radius:5px;
background:rgba(10,9,7,.74); backdrop-filter:blur(4px);
border:1px solid rgba(255,255,255,.13);
box-shadow:0 3px 16px rgba(0,0,0,.55);
text-shadow:0 1px 3px rgba(0,0,0,.95);
}
.dlab small{
display:block; font-size:11.5px; letter-spacing:.05em; text-transform:none;
color:rgba(240,234,220,.82); margin-top:5px; font-family:var(--font-sans);
font-weight:400; text-shadow:0 1px 3px rgba(0,0,0,.95);
}
.pin{
width:16px;height:16px;border-radius:50%;border:2px solid #0e0c0a;
box-shadow:0 0 0 1.5px rgba(255,255,255,.65),0 2px 7px rgba(0,0,0,.8);
cursor:pointer;
}
.pin:hover{box-shadow:0 0 0 3px rgba(255,255,255,.85),0 2px 10px rgba(0,0,0,.8)}
.pin.sel{box-shadow:0 0 0 3.5px var(--gold),0 2px 12px rgba(0,0,0,.9)}
.pin.wp{
width:28px;height:28px;border-radius:50%;border:2px solid #0e0c0a;
display:flex;align-items:center;justify-content:center;
font-size:15px;line-height:1;font-family:var(--font-sans);
text-shadow:0 1px 2px rgba(0,0,0,.5);
box-shadow:0 0 0 1.5px rgba(255,255,255,.7),0 3px 9px rgba(0,0,0,.85);
}
.pin.wp.sel{box-shadow:0 0 0 3.5px var(--gold),0 3px 14px rgba(0,0,0,.9)}
.pin.hist{border-radius:2px;width:12px;height:12px;border-style:dashed;border-width:1px}
.ptip{
position:absolute; left:14px; top:-6px; white-space:nowrap; pointer-events:none;
background:rgba(10,9,7,.94); border:1px solid rgba(255,255,255,.16); color:#f2ece0;
padding:5px 10px; border-radius:4px; font-size:13px; font-weight:600;
font-family:var(--font-sans); letter-spacing:.01em;
box-shadow:0 3px 12px rgba(0,0,0,.6); text-shadow:0 1px 2px rgba(0,0,0,.9);
opacity:0; transition:opacity .1s;
}
.mk:hover .ptip,.mk.sel .ptip{opacity:1}
/* ---------- overlays ---------- */
#ctrls{position:absolute;top:14px;right:14px;display:flex;flex-direction:column;gap:6px;z-index:5}
#ctrls .btn{background:rgba(28,26,22,.94);backdrop-filter:blur(6px);width:36px;height:34px;justify-content:center;padding:0}
#hud{
position:absolute;left:14px;bottom:14px;z-index:5;display:flex;align-items:center;gap:14px;
background:rgba(20,18,15,.9);backdrop-filter:blur(6px);border:1px solid var(--line);
border-radius:6px;padding:8px 12px;font-family:var(--font-sans);font-size:11px;color:var(--ink-dim);
}
#bar{height:5px;border:1px solid var(--ink-dim);border-top:none;min-width:40px}
#banner{
position:absolute;top:14px;left:50%;transform:translateX(-50%);z-index:6;
background:var(--gold);color:#1a1508;padding:7px 16px;border-radius:20px;
font-family:var(--font-sans);font-size:12.5px;font-weight:600;box-shadow:0 4px 18px rgba(0,0,0,.5);
}
#banner[hidden]{display:none}
#card{
position:absolute;right:14px;bottom:14px;width:330px;max-height:52%;z-index:6;
background:rgba(24,22,18,.97);backdrop-filter:blur(10px);border:1px solid var(--line);
border-radius:8px;box-shadow:0 12px 40px rgba(0,0,0,.6);display:flex;flex-direction:column;
}
#card[hidden]{display:none}
#card .hd{display:flex;align-items:flex-start;gap:10px;padding:14px 14px 8px;border-bottom:1px solid var(--line)}
#card .hd .dot{width:10px;height:10px;border-radius:50%;margin-top:6px;flex:0 0 10px}
#card h3{margin:0;font-size:16px;flex:1;line-height:1.3}
#card .kind{font-size:10px;letter-spacing:.14em;text-transform:uppercase;color:var(--ink-faint);font-family:var(--font-sans);margin-top:4px;display:block}
#card .bd{padding:12px 14px 14px;overflow-y:auto;font-size:13.5px;line-height:1.62;color:#d5cbb6}
#card .bd p{margin:0 0 10px}
#card .bd p:last-child{margin-bottom:0}
#card .ft{padding:0 14px 13px;display:flex;gap:7px}
#card .ft[hidden]{display:none}
#card .cl{background:none;border:none;color:var(--ink-faint);font-size:19px;line-height:1;padding:0 2px}
#card .cl:hover{color:var(--ink)}
#modal{position:fixed;inset:0;z-index:20;background:rgba(8,7,6,.7);display:flex;align-items:center;justify-content:center}
#modal[hidden]{display:none}
#modal .box{width:390px;background:var(--panel);border:1px solid var(--line);border-radius:9px;padding:20px;box-shadow:0 24px 70px rgba(0,0,0,.7)}
#modal h3{margin:0 0 15px;font-size:17px;color:var(--gold)}
#modal label{display:block;font-size:10.5px;letter-spacing:.14em;text-transform:uppercase;color:var(--ink-faint);font-family:var(--font-sans);margin:0 0 5px}
#modal input[type=text],#modal textarea{
width:100%;background:#12100d;border:1px solid var(--line);color:var(--ink);
padding:8px 10px;border-radius:5px;font-size:13.5px;font-family:var(--font-ui);margin-bottom:13px;
}
#modal textarea{resize:vertical;min-height:74px;line-height:1.5}
#modal input:focus,#modal textarea:focus{outline:none;border-color:var(--gold-dim)}
#icons{display:grid;grid-template-columns:repeat(8,1fr);gap:6px;margin-bottom:15px}
#icons button{
aspect-ratio:1;border:1px solid var(--line);background:#12100d;border-radius:5px;
font-size:16px;padding:0;display:flex;align-items:center;justify-content:center;
font-family:var(--font-sans);
}
#icons button:hover{border-color:#5b5245}
#icons button[aria-pressed=true]{border-color:var(--gold);background:#2a2416}
.gly{
width:20px;height:20px;border-radius:50%;flex:0 0 20px;margin-top:1px;
display:flex;align-items:center;justify-content:center;font-size:11px;
font-family:var(--font-sans);border:1px solid rgba(0,0,0,.5);
}
#swatches{display:flex;gap:7px;margin-bottom:16px}
#swatches button{width:26px;height:26px;border-radius:50%;border:2px solid transparent;padding:0}
#swatches button[aria-pressed=true]{border-color:var(--ink)}
#modal .act{display:flex;gap:8px;justify-content:flex-end}
::-webkit-scrollbar{width:9px;height:9px}
::-webkit-scrollbar-thumb{background:#332e26;border-radius:5px}
::-webkit-scrollbar-track{background:transparent}
</style>
</head>
<body>
<aside id="side">
<header>
<h1>Neverwinter</h1>
<p>The Jewel of the North, 1490s DR · double-click the map to drop a waypoint</p>
</header>
<div class="scroll">
<div class="sec">
<h2>Ask the map</h2>
<input id="search" type="search" placeholder="somewhere to buy a sword…" autocomplete="off">
<div id="chips"></div>
<div id="results"></div>
</div>
<div class="sec">
<h2>Layers</h2>
<label class="row"><input type="checkbox" id="L-districts" checked><span>Districts</span><span class="ct" id="c-districts"></span></label>
<label class="row"><input type="checkbox" id="L-landmarks" checked><span>Landmarks & lore</span><span class="ct" id="c-landmarks"></span></label>
<label class="row"><input type="checkbox" id="L-historic"><span>Lost quarters (pre-1451)</span><span class="ct" id="c-historic"></span></label>
<label class="row"><input type="checkbox" id="L-waypoints" checked><span>My waypoints</span><span class="ct" id="c-waypoints"></span></label>
</div>
<div class="sec">
<h2>Districts</h2>
<div id="dlist"></div>
</div>
<div class="sec">
<h2>Waypoints</h2>
<button class="btn wide" id="addBtn">+ Add waypoint <span style="opacity:.55">(W)</span></button>
<p class="empty" style="margin:7px 0 0">…or just double-click the map. Drag a pin to move it.</p>
<div id="wlist" style="margin-top:10px"></div>
<div class="btns" style="margin-top:11px">
<button class="btn sm" id="expBtn">Export</button>
<button class="btn sm" id="impBtn">Import</button>
<button class="btn sm" id="clrBtn" style="margin-left:auto">Clear all</button>
</div>
<input type="file" id="impFile" accept="application/json" hidden>
</div>
<div class="sec" style="border-bottom:none">
<h2>Credits</h2>
<p class="empty" id="credit"></p>
</div>
</div>
</aside>
<main id="map">
<div id="world">
<img id="mapimg" alt="Map of Neverwinter" draggable="false">
<svg id="zones" width="1600" height="1128" viewBox="0 0 1600 1128"></svg>
<div id="pins"></div>
</div>
<div id="ctrls">
<button class="btn" id="zin" title="Zoom in">+</button>
<button class="btn" id="zout" title="Zoom out">−</button>
<button class="btn" id="fit" title="Fit map (F)">⤢</button>
<button class="btn" id="rule" title="Measure distance (M)">📏</button>
</div>
<div id="banner" hidden></div>
<div id="hud">
<span id="coord">—</span>
<span style="display:flex;align-items:center;gap:6px"><span id="bar"></span><span id="barlab"></span></span>
<span id="zlab"></span>
</div>
<div id="card" hidden>
<div class="hd">
<span class="dot"></span>
<div style="flex:1"><h3></h3><span class="kind"></span></div>
<button class="cl" title="Close">×</button>
</div>
<div class="bd"></div>
<div class="ft" hidden>
<button class="btn sm" data-act="edit">Edit</button>
<button class="btn sm" data-act="del">Delete</button>
</div>
</div>
</main>
<div id="modal" hidden>
<div class="box">
<h3 id="mTitle">New waypoint</h3>
<label for="mName">Name</label>
<input type="text" id="mName" placeholder="Ambush point, safe house, session 4 fight…">
<label for="mNote">Notes</label>
<textarea id="mNote" placeholder="What happens here?"></textarea>
<label>Icon</label>
<div id="icons"></div>
<label>Colour</label>
<div id="swatches"></div>
<div class="act">
<button class="btn" id="mCancel">Cancel</button>
<button class="btn on" id="mSave">Save</button>
</div>
</div>
</div>
<script>
const DATA = {"image":{"w":1600,"h":1128},"scale":{"px":311,"feet":1000},"credit":"Base map by Mike Schley — data compiled from aidedd.org/atlas/neverwinter","districts":[{"id":"bluelake","name":"Bluelake District","alias":"formerly the Blacklake District","quarter":"Northwest bank","color":"#4c9be0","path":"M 254.9,471.8 269.4,452.1 379.8,319.4 488.8,231.3 521.7,209 703,123.6 772.7,126.2 770,135.4 747.7,149.8 729.3,177.4 721.4,197.1 724,202.4 751.6,210.3 767.4,219.5 783.2,249.7 780.6,281.2 763.5,308.8 745.1,325.9 729.3,340.4 724,350.9 728,382.4 728,391.6 713.5,400.8 703,399.5 697.8,408.7 697.8,417.9 707,428.4 703,454.7 712.2,466.5 714.8,481 701.7,503.3 671.5,507.3 633.4,521.7 613.7,537.5 594,557.2 572.9,595.3 548,616.3 516.4,625.5 492.8,629.5 465.2,625.5 453.4,622.9 446.8,609.8 431,601.9 416.6,586.1 424.4,569 419.2,557.2 390.3,541.4 C 390.3,541.4 374.5,532.2 366.6,532.2 358.7,532.2 340.3,529.6 340.3,529.6 L 265.4,490.2 Z","label":[432,296],"desc":"The old noble quarter. Its stone estates were built well enough to survive the eruption of Mount Hotenow in 1451 DR, but most of their owners were not — and the abandoned manors became a nest for every shadow faction in the city: the Dead Rats, the Sons of Alagondar, the Ashmadai. Lord Neverember's men were attacked repeatedly trying to resettle it. It has improved dramatically in recent years. The lake at its heart, choked with volcanic ash for decades, was dredged on Neverember's orders and renamed from Blacklake to Bluelake.","tags":["district","noble","luxury","water","crime","faction"]},{"id":"tower","name":"Tower District","alias":"also called the River District","quarter":"Northeast bank","color":"#a97ddb","path":"M 772.7,126.2 770,135.4 747.7,149.8 729.3,177.4 721.4,197.1 724,202.4 751.6,210.3 767.4,219.5 783.2,249.7 780.6,281.2 763.5,308.8 745.1,325.9 729.3,340.4 724,350.9 728,382.4 728,391.6 713.5,400.8 703,399.5 697.8,408.7 697.8,417.9 707,428.4 703,454.7 712.2,466.5 714.8,481 701.7,503.3 708.3,504.6 751.6,516.5 789.8,520.4 846.3,538.8 879.1,536.2 908,541.4 934.3,534.9 956.6,530.9 C 956.6,530.9 1014,524.3 1025,524.3 1035,524.3 1060,529.6 1060,529.6 L 1133,541.4 1181,541.4 1243,533.5 1318,532.2 1377,525.7 1407,525.7 1436,527 1477,524.3 1389,302.3 1380,290.4 1251,211.6 1239,205 1080,152.5 1039,143.3 C 1039,143.3 933,127.5 927.7,126.2 922.5,124.9 791.1,126.2 791.1,126.2 Z","label":[1055,232],"desc":"The northeastern quarter, along the north bank of the Neverwinter River. Home to the city's arcane landmarks — the Cloak Tower of the Many-Starred Cloak, the floating Shard of the Moon (once the Netherese Shard of Night), and the ruined Sacred Park of Sune. Heavily damaged in the cataclysm and only sparsely reclaimed; the further east you walk, the emptier and more dangerous it gets.","tags":["district","magic","arcane","tower","ruins","temple","danger"]},{"id":"enclave","name":"Protector's Enclave","alias":"the fused City Core, Peninsula District and Merchant Quarter","quarter":"Southwest bank","color":"#e0b04a","path":"M 222.1,709.6 C 236.5,703.1 283.8,668.9 283.8,668.9 L 310.1,638.7 339,620.3 353.7,617.2 368,608.4 377.5,609.2 393.3,605.7 403.4,611.1 412.6,633.4 425.1,641.4 429.7,655.8 463.9,667.6 C 463.9,667.6 496.7,672.8 507.2,670.2 517.7,667.6 565.2,657.1 565.2,657.1 L 582.5,642.9 606.5,597.9 630.7,570.3 662,548.2 687.3,548.5 724,544.1 757.9,545.6 801.3,551.9 804.2,586.1 805.5,607.1 830.5,809.5 831.5,940.6 741.1,939.6 739.8,1006 626.8,1004 542.7,980.3 503.3,964.6 369.3,866 247,730.7 Z","label":[470,800],"desc":"The living heart of Neverwinter and the only quarter fully under control. When Dagult Neverember began rebuilding in the late 15th century DR he fused three pre-cataclysm districts — the City Core, the Peninsula District and the Merchant Quarter — into a single defensible zone; survivors named it the Protector's Enclave. Trade, crafting and government all happen here, centred on the Hall of Justice. The Docks, the House of Knowledge and the approach to Neverdeath all fall inside or against its walls.","tags":["district","trade","shop","craft","government","law","docks","money"]},{"id":"chasm","name":"New District","alias":"the Chasm District","quarter":"Southeast bank","color":"#d4663c","path":"M 749,1003 C 749,1003 808.8,1013 812.7,1013 816.7,1013 1011,979.5 1011,979.5 L 1142,982.4 1188,975.5 1268,951 1281,943.2 1347,903 1362,892.2 1415,783.4 1441,725.5 1450,697.1 1459,657.9 1463,630.4 1474,567.7 1463,567.7 1437,567.7 1421,562.8 1389,558.9 1359,562.5 1321,565.7 1277,568.7 C 1277,568.7 1225,573.6 1222,573.6 1218,573.6 1199,571.6 1199,571.6 L 1167,578.5 1125,581.4 1098,574.3 1079,575.5 C 1079,575.5 1050,566.7 1044,566.7 1038,566.7 1017,564.8 1017,564.8 L 991.2,560.8 963.7,557.9 937.3,562.8 894.3,572.7 C 894.3,572.7 884.3,568.7 877.5,568.7 870.6,568.7 852.9,566.7 848,565.7 843.1,564.8 821.6,558.9 821.6,558.9 L 801.3,551.9 804.2,586.1 805.5,607.1 830.5,809.5 831.5,940.6 741.1,939.6 739.8,1002 Z","label":[1245,880],"desc":"The southeastern quadrant that fell into the earth. When Mount Hotenow erupted in 1451 DR it tore a canyon straight down into a Spellplague-tainted stretch of the Underdark, levelling the Arcanist Quarter and the Beggar's Nest and vomiting horrors into the streets. A wall was raised to contain it. Neverember eventually had the Chasm sealed with powerful magic at enormous cost, leaving a district of flat ruin that is now free for the taking — and the poor are flocking to it to build something new.","tags":["district","ruins","poor","cheap","danger","magic","work"]}],"landmarks":[{"name":"Beached Leviathan","x":319,"y":501,"html":"<p>Three-decked tavern that catered to sailors, smugglers, slavers, merchants, and others arriving by sea. Was built in and around the refurbished wreckage of a ship. The innkeeper is a sallow former pirate captain.</p>","tags":["tavern","inn","drink","food","lodging","docks","ships","smugglers","crime","pirates"]},{"name":"Bluelake","x":655,"y":299,"html":"<p></p>","tags":["water","nature","landmark"]},{"name":"Board Laid Bare","x":927,"y":222,"html":"<p>This place just inside the city's northeast gate offers dining for very low prices. It serves no beer, wine, or spirits, but fills guests full of fresh fish cooked in cream sauces.</p>","tags":["food","drink","cheap","gate"]},{"name":"Castle Never","x":500,"y":551,"html":"<p>Castle Never stands as a monument to the city's former glory. Now it's a dangerous ruin, home for banshees and ghosts.</p>","tags":["castle","ruins","danger","undead","dead","government","landmark","noble"]},{"name":"Chasm","x":1118,"y":781,"html":"<p>After the eruption of Mount Hotenow in 1451, much of the southeastern quadrant of the city collapsed into a yawning pit, known as the Chasm, that continually spawned horrors. Neverwinter remained in ruins for decades, but thanks to Lord Neverember's efforts the city was repaired to its former glory and the Chasm has been sealed by powerful magic.</p>","tags":["ruins","danger","magic","landmark"]},{"name":"Cloak Tower","x":1392,"y":450,"html":"<p>Meeting place and citadel of the Many-Starred Cloak, a band of wizards.</p>","tags":["magic","arcane","tower","faction","guild"]},{"name":"Dannar's Mechanical Marvels","x":377,"y":383,"html":"<p>This shop sells gnomish and dwarven clockwork wonders.</p>","tags":["shop","craft","magic","gnome","dwarf","luxury"]},{"name":"Docks","x":315,"y":640,"html":"<p>The commercial heart of the city. Supplies and coin flow into Neverwinter through here.</p>","tags":["docks","water","ships","trade","work"]},{"name":"Dolphin Bridge","x":612,"y":566,"html":"<p>Bridge.</p>","tags":["bridge","river","water","landmark"]},{"name":"Driftwood Tavern","x":386,"y":525,"html":"<p>Prices for room and board in this tavern are high. Home of the Graycloaks faction where they meet to discuss their plans.</p>","tags":["tavern","inn","drink","lodging","faction","secret","luxury"]},{"name":"Fallen Tower","x":1187,"y":296,"html":"<p>One of the most popular taverns in Neverwinter. Deep cellars beneath the old circular tower. Was run by orcs in the past.</p>","tags":["tavern","drink","tower","ruins","orc"]},{"name":"Fisher's Float","x":90,"y":1034,"html":"<p>Home and workplace of fishers who have lived on this earthmote since the Spellplague. Fearless of the weather and the turbulent sea, they provide a great deal of food for the city.</p>","tags":["earthmote","food","water","cheap"]},{"name":"Githyanki hideout","x":504,"y":935,"html":"","tags":["danger","secret","faction"]},{"name":"Neverdeath — Mausoleums","x":777,"y":839,"html":"<p>Main graveyard</p><p>The cruel mistress of the graveyard, called Neverdeath, is the sorceress Valindra Shadowmantle. After the cataclysm, visitors who breach Neverdeath walls came under attack from undead creatures that emerge from the ground.</p>","tags":["graveyard","dead","undead","danger","ruins"]},{"name":"Neverdeath — Pauper’s Section","x":687,"y":929,"html":"<p>Pauper's section</p>","tags":["graveyard","dead","undead","danger","ruins"]},{"name":"Hall of Justice","x":379,"y":667,"html":"<p>Former temple of Tyr, located on a cliff overlooking the Sea of Swords, and one of the few buildings left almost untouched by the pyroclastic flow. Seat of government since Dagult Neverember arrived in the city.</p>","tags":["temple","worship","law","government","guard","landmark"]},{"name":"House of a Thousand Faces","x":659,"y":393,"html":"<p>Popular tavern in the Bluelake District. A secret basement serves as command center for the Harpers. The owner is the elf Theryis, an harper.</p>","tags":["tavern","drink","faction","secret","noble"]},{"name":"House of Knowledge","x":768,"y":578,"html":"<p>A temple to Oghma located at one end of the Dolphin Bridge.</p>","tags":["temple","worship","knowledge","library","books","landmark"]},{"name":"Iron Flagon Inn","x":566,"y":897,"html":"<p>Located in the market district, the Iron Flagon Inn is knownn for its Poison Serpent ale, so named for its potency, and a spot for adventurers. The Inn is run by a former adventurer, the beautiful Lyrana Delmont.</p>","tags":["inn","tavern","drink","lodging","adventurers","work"]},{"name":"Jaesor's Fineware","x":349,"y":404,"html":"<p>Here the Ryndyl family craft and sell painted plates. Many local families and personalities like to have their family arms or personal likenesses painted on their dinnerware.</p>","tags":["shop","craft","luxury","noble"]},{"name":"Manycoins Moneylending","x":298,"y":444,"html":"<p>Moneychanger where you can changes money from coinage to coinage for small fees. Owned and run by professional thieves.</p>","tags":["money","shop","crime","trade"]},{"name":"Maskado's Maps and Legends","x":648,"y":614,"html":"<p>This shop is specialized in maps, records, hints and tales of the North concerned with exploration, treasure, trails, and hidden ways.</p>","tags":["shop","maps","knowledge","books","adventurers"]},{"name":"Merchant Guild Hall","x":1277,"y":466,"html":"","tags":["trade","guild","government","money"]},{"name":"Moonstone Mask","x":187,"y":633,"html":"<p>Quiet inn of comfortable quality famous among sailors, it's also one of the most reknowned festhalls (on the upper floor) in Neverwinter. Most of the staff are beautiful anonymous women with moonstone-adorned half-masks. A bridge between the earthmote and the docks allows visitors to enter and exit the Moonstone. The cellars of the Mask conceal a gate, but the destination reached by this magic still remains a mystery.</p>","tags":["inn","lodging","festhall","luxury","earthmote","magic","secret","noble"]},{"name":"Mute Lute","x":401,"y":369,"html":"<p>Built around an old oak tree, this house is the home of an half-elven lutemaker.</p>","tags":["shop","craft","nature"]},{"name":"Neverwinter River","x":1134,"y":561,"html":"<p>The waters are so warm that the harbor never freezes.</p>","tags":["water","river","landmark"]},{"name":"Old Kraken Society building","x":698,"y":854,"html":"<p>The Sons of Alagondar's violent Nasher faction makes its headquarters in the old Kraken Society building. This building also serves for joint meetings between the Nashers and the more political Graycloaks faction.</p>","tags":["faction","crime","secret","danger"]},{"name":"Pirates' Skyhold","x":113,"y":97,"html":"<p>Once unassailable harbor for sky pirates in the years following the Spellplague, Pirates' Skyhold has long been abandoned.</p>","tags":["earthmote","ruins","pirates","danger"]},{"name":"Sacred Park of Sune","x":1289,"y":291,"html":"<p>Before the cataclysm, this was one of the most famous shrines to the goddess of love and beauty. Now a ruin.</p>","tags":["temple","worship","ruins","nature"]},{"name":"Shard of the Moon","x":998,"y":274,"html":"<p>Bright white alabaster tower, dedicated to Selûne, that rises high into the sky over Neverwinter.</p><p>In 1479 DR, a group of adventurers seeking the Shards of Selûne raided the Shard of Night, defeating the guards there and allowing Lady Jasmine and other selûnite priests to recover the tower. The Shard of Night was later purified, reconsecrated to Selûne by using the power of the Shards, and became a beacon of hope in Neverwinter. The Neverwintans began to call it the 'Shard of the Moon' afterwards</p>","tags":["temple","worship","magic","arcane","tower","landmark"]},{"name":"Shining Knight Arms and Armor","x":746,"y":755,"html":"<p>Down the street from the Hall of Knowledge to the southwest, stand a shop where the best armor can be ordered. Produced speedily thanks to good dwarven contacts and a mage owner who has mastered some spells to reshape metal.</p>","tags":["shop","weapons","armor","craft","magic","dwarf","trade"]},{"name":"Shining Serpent Inn","x":1038,"y":685,"html":"<p>Was the largest and most popular guesthouse in Neverwinter. A clean and safe place to stay.</p>","tags":["inn","lodging","food"]},{"name":"Sleeping Dragon Bridge","x":456,"y":647,"html":"<p>Bridge.</p>","tags":["bridge","river","water","landmark"]},{"name":"Tarmalune Trade House","x":334,"y":642,"html":"<p>Large warehouse complex next to the docks. The Tarmalune Trade House is a busy area where contacts gather, deals are made, and adventurers find their services in high demand.</p>","tags":["trade","docks","work","adventurers","guild"]},{"name":"Temple of Waukeen Neverwinter","x":561,"y":474,"html":"","tags":["temple","worship","trade","money"]},{"name":"Tomb of the Betrayers","x":345,"y":755,"html":"","tags":["dead","graveyard","ruins","danger"]},{"name":"Tower of Solace","x":657,"y":645,"html":"","tags":["tower","landmark"]},{"name":"Trade of Blades","x":477,"y":729,"html":"","tags":["weapons","shop","adventurers","work","guild","trade"]},{"name":"Vellgard Manor","x":524,"y":329,"html":"<p> Mordai Vell inherited the manor after the eruption of Mount Hotenow, in 1451 DR, when all his human relatives died in the cataclysm. He then repurposed the manor to use it as the headquarters of his Ashmadai cell.</p>","tags":["noble","faction","cult","danger","secret","magic"]},{"name":"Wall","x":814,"y":691,"html":"<p>The wall that separated the rest of the city from the Chasm and its horrors is now torn down.</p>","tags":["wall","ruins","guard"]},{"name":"Winged Wyvern Bridge","x":562,"y":636,"html":"<p>After the eruption of Mount Hotenow, the city was almost entirely destroyed. Of the three bridges, only the Winged Wyvern remained functional.</p>","tags":["bridge","river","water","landmark"]},{"name":"Wintershield Watchmen HQ","x":607,"y":697,"html":"","tags":["law","guard","government"]}],"historic":[{"name":"City Core","x":620,"y":745,"era":"pre-1451 DR","desc":"The central district, connected to every other quarter and the district where the city gates stood. Absorbed into the Protector's Enclave during the rebuilding.","tags":["district","historic","gate","government","trade"]},{"name":"Merchant Quarter","x":700,"y":690,"era":"pre-1451 DR","desc":"Created out of the parts of the City Core rebuilt after the Wailing Death plague of 1372 DR. Absorbed into the Protector's Enclave.","tags":["district","historic","trade","money","shop"]},{"name":"Peninsula District","x":320,"y":830,"era":"pre-1451 DR","desc":"The southwestern spur of the city, home to Neverwinter Prison. Absorbed into the Protector's Enclave.","tags":["district","historic","prison","law"]},{"name":"Blacklake District","x":400,"y":390,"era":"pre-1451 DR","desc":"The noble quarter's old name, taken from the ash-black lake at its centre. Renamed Bluelake after Neverember had the lake dredged.","tags":["district","historic","noble","water"]},{"name":"Arcanist Quarter","x":1195,"y":690,"era":"destroyed 1451 DR","desc":"Built around a lavish cathedral to Mystra in the city's southeast. Wizards and sorcerers came from all along the Sword Coast to study and argue here. Almost completely destroyed by the earthquakes that followed the eruption; the Chasm opened where it stood.","tags":["district","historic","magic","arcane","temple","worship","school","ruins"]},{"name":"Beggar's Nest","x":1010,"y":900,"era":"destroyed 1451 DR","desc":"The poorest quarter of old Neverwinter, in the southeast beside the Arcanist Quarter, and once home to the Neverwinter Academy. Swallowed whole by the Chasm.","tags":["district","historic","poor","cheap","school","ruins","crime"]},{"name":"The Docks","x":268,"y":700,"era":"current","desc":"The commercial mouth of the city, on the southwest harbour. Supplies and coin flow into Neverwinter through here. The Beached Leviathan, the Tarmalune Trade House and the Driftwood Tavern all sit within a few streets of the water.","tags":["district","docks","water","ships","trade","work"]},{"name":"Neverdeath","x":745,"y":900,"era":"current","desc":"The city graveyard, walled off on the southern edge. Split into a Pauper's section to the southwest — rows of nameless graves from Neverwinter's many catastrophes — and a section of mausoleums for the wealthy. The Spellplague left the dead unwilling to stay down, so Neverwinter now burns its dead.","tags":["district","graveyard","dead","undead","danger"]},{"name":"Castle Never","x":500,"y":512,"era":"current","desc":"Straddles the boundary of the Protector's Enclave, the Docks and Bluelake on the cliffs above the estuary — arguably its own district. Three bridges radiate from its rock across the Neverwinter River: the Sleeping Dragon, the Winged Wyvern and the Dolphin. Over a thousand years old, commissioned by the sun elf Lord Halueth Never, and a haunted ruin since 1451 DR.","tags":["district","castle","ruins","noble","landmark","bridge"]}]};
const IMG_SRC = "neverwinter.jpg";
/* ---------------- state ---------------- */
const KEY = "nw-map-waypoints-v1";
const WP_COLORS = ["#e0483c","#e08c2a","#d9b04a","#5fb85f","#4c9be0","#a97ddb","#e8dfcc"];
const WP_ICONS = ["\u{1F4CD}","\u2694\uFE0F","\u{1F480}","\u{1F3E0}","\u{1F511}","\u2B50","\u{1F451}","\u{1F409}",
"\u{1F4B0}","\u{1F525}","\u{1F441}\uFE0F","\u2693","\u{1F37A}","\u{1F4DC}","\u26A0\uFE0F","\u{1F6AA}"];
const IW = DATA.image.w, IH = DATA.image.h;
let view = { k: 1, x: 0, y: 0 };
let waypoints = load();
let mode = "pan"; // pan | place | measure
let measurePts = [];
let selected = null; // {type,id}
let editing = null; // waypoint being edited
let pendingXY = null;
let draftColor = WP_COLORS[0];
let draftIcon = WP_ICONS[0];
const $ = s => document.querySelector(s);
const mapEl=$("#map"), worldEl=$("#world"), pinsEl=$("#pins"), zonesEl=$("#zones");
function load(){
try{ const r = localStorage.getItem(KEY); return r ? JSON.parse(r) : []; }
catch(e){ return []; }
}
function save(){
try{ localStorage.setItem(KEY, JSON.stringify(waypoints)); }
catch(e){ flash("Could not save — storage unavailable"); }
}
/* ---------------- build the map ---------------- */
$("#mapimg").src = IMG_SRC;
$("#credit").textContent = DATA.credit;
const SVG_NS = "http://www.w3.org/2000/svg";
const zonePaths = {};
DATA.districts.forEach(d => {
const p = document.createElementNS(SVG_NS, "path");
p.setAttribute("d", d.path);
p.setAttribute("fill", d.color);
p.setAttribute("fill-opacity", ".14");
p.setAttribute("stroke", d.color);
p.setAttribute("stroke-opacity", ".7");
p.setAttribute("stroke-width", "2");
p.setAttribute("vector-effect", "non-scaling-stroke");
zonesEl.appendChild(p);
zonePaths[d.id] = p;
});
function marker(x, y, node){
const m = document.createElement("div");
m.className = "mk";
m.style.left = x + "px";
m.style.top = y + "px";
m.appendChild(node);
pinsEl.appendChild(m);
return m;
}
function tip(text){
const t = document.createElement("span");
t.className = "ptip";
t.textContent = text;
return t;
}
/* district labels */
const labelEls = DATA.districts.map(d => {
const el = document.createElement("div");
el.className = "dlab";
el.style.color = d.color;
el.innerHTML = "";
el.append(d.name.replace(/'/g, "’"));
const s = document.createElement("small");
s.textContent = d.alias;
el.appendChild(s);
const m = marker(d.label[0], d.label[1], el);
m.dataset.anchor = "center";
return { d, m };
});
/* landmark pins */
const lmEls = DATA.landmarks.map((p, i) => {
const dot = document.createElement("div");
dot.className = "pin";
dot.style.background = districtColorAt(p.x, p.y);
const m = marker(p.x, p.y, dot);
m.appendChild(tip(p.name));
dot.addEventListener("click", e => { e.stopPropagation(); select("landmark", i); });
return { p, m, dot };
});
/* historic pins */
const hEls = DATA.historic.map((p, i) => {
const dot = document.createElement("div");
dot.className = "pin hist";
dot.style.background = "transparent";
dot.style.borderColor = "#e8dfcc";
dot.style.boxShadow = "0 0 0 1px rgba(0,0,0,.6)";
const m = marker(p.x, p.y, dot);
m.appendChild(tip(p.name + " · " + p.era));
dot.addEventListener("click", e => { e.stopPropagation(); select("historic", i); });
return { p, m, dot };
});
function districtColorAt(x, y){
// rough: pick the district whose label is nearest — good enough for tinting pins
let best = null, bd = Infinity;
for (const d of DATA.districts){
const dx = d.label[0]-x, dy = d.label[1]-y, dist = dx*dx+dy*dy;
if (dist < bd){ bd = dist; best = d; }
}
return best.color;
}
/* measure line */
const mLine = document.createElementNS(SVG_NS,"polyline");
mLine.setAttribute("fill","none");
mLine.setAttribute("stroke","#d9b04a");
mLine.setAttribute("stroke-width","2");
mLine.setAttribute("stroke-dasharray","7 5");
mLine.setAttribute("vector-effect","non-scaling-stroke");
zonesEl.appendChild(mLine);
/* ---------------- waypoint rendering ---------------- */
let wpEls = [];
function renderWaypoints(){
wpEls.forEach(w => w.m.remove());
wpEls = waypoints.map(w => {
const dot = document.createElement("div");
dot.className = "pin wp";
dot.style.background = w.color;
dot.textContent = w.icon || WP_ICONS[0];
const m = marker(w.x, w.y, dot);
m.appendChild(tip(w.name || "Untitled"));
dot.addEventListener("mousedown", e => startDrag(e, w, m));
dot.addEventListener("dblclick", e => { e.stopPropagation(); editing = w; pendingXY = null;
openModal("Edit waypoint", w.name, w.note, w.color, w.icon); });
dot.addEventListener("click", e => { e.stopPropagation(); if(!dragMoved) select("waypoint", w.id); });
return { w, m, dot };
});
renderWpList();
applyView();
syncSelection();
}
function renderWpList(){
const box = $("#wlist");
box.innerHTML = "";
if (!waypoints.length){
box.innerHTML = '<p class="empty">None yet. <b>Double-click</b> anywhere on the map to drop one.</p>';
}
waypoints.forEach(w => {
const el = document.createElement("div");
el.className = "item";
el.innerHTML = '<span class="gly"></span><span class="nm"></span><button class="x" title="Delete">×</button>';
const g = el.querySelector(".gly");
g.style.background = w.color;
g.textContent = w.icon || WP_ICONS[0];
const nm = el.querySelector(".nm");
nm.append(w.name || "Untitled");
if (w.note){ const s=document.createElement("span"); s.className="sub"; s.textContent=w.note.split("\n")[0]; nm.appendChild(s); }
el.addEventListener("click", () => { flyTo(w.x, w.y); select("waypoint", w.id); });
el.querySelector(".x").addEventListener("click", e => { e.stopPropagation(); delWaypoint(w.id); });
box.appendChild(el);
});
$("#c-waypoints").textContent = waypoints.length || "";
}
function delWaypoint(id){
waypoints = waypoints.filter(w => w.id !== id);
if (selected && selected.type === "waypoint" && selected.id === id) closeCard();
save(); renderWaypoints();
}
/* drag a waypoint */
let dragMoved = false, dragging = null;
function startDrag(e, w, m){
if (mode !== "pan") return;
e.stopPropagation(); e.preventDefault();
dragMoved = false;
dragging = { w, m, sx: e.clientX, sy: e.clientY, ox: w.x, oy: w.y };
}
window.addEventListener("mousemove", e => {
if (!dragging) return;
const dx = (e.clientX - dragging.sx) / view.k, dy = (e.clientY - dragging.sy) / view.k;
if (Math.abs(dx) > 1 || Math.abs(dy) > 1) dragMoved = true;
dragging.w.x = clamp(dragging.ox + dx, 0, IW);
dragging.w.y = clamp(dragging.oy + dy, 0, IH);
dragging.m.style.left = dragging.w.x + "px";
dragging.m.style.top = dragging.w.y + "px";
});
window.addEventListener("mouseup", () => {
if (dragging){ if (dragMoved) save(); dragging = null; setTimeout(()=>dragMoved=false, 0); }
});
/* ---------------- view / transform ---------------- */
const clamp = (v,a,b) => Math.max(a, Math.min(b, v));
function applyView(){
const { k, x, y } = view;
worldEl.style.transform = `translate(${x}px,${y}px) scale(${k})`;
const inv = 1 / k;
for (const m of pinsEl.children){
const anchor = m.dataset.anchor === "center" ? "translate(-50%,-50%)" : "translate(-50%,-50%)";
m.style.transform = `scale(${inv}) ${anchor}`;
}
$("#zlab").textContent = Math.round(k * 100) + "%";
updateBar();
}
function updateBar(){
// choose a round distance in feet that lands 60–170 screen px
const pxPerFoot = DATA.scale.px / DATA.scale.feet * view.k;
const steps = [50,100,250,500,1000,2000,5000,10000];
let ft = steps[steps.length-1];
for (const s of steps){ const w = s * pxPerFoot; if (w >= 60 && w <= 170){ ft = s; break; } if (w > 170){ ft = s; break; } }
$("#bar").style.width = Math.round(ft * pxPerFoot) + "px";
$("#barlab").textContent = ft >= 5280 ? (ft/5280).toFixed(1) + " mi" : ft + " ft";
}
function fit(){
const r = mapEl.getBoundingClientRect();
const k = Math.min(r.width / IW, r.height / IH) * 0.96;
view = { k, x: (r.width - IW*k)/2, y: (r.height - IH*k)/2 };
applyView();
}
function zoomAt(cx, cy, factor){
const k2 = clamp(view.k * factor, 0.15, 8);
const f = k2 / view.k;
view.x = cx - (cx - view.x) * f;
view.y = cy - (cy - view.y) * f;
view.k = k2;
applyView();
}
function flyTo(ix, iy, k){
const r = mapEl.getBoundingClientRect();
view.k = k || Math.max(view.k, 1.6);
view.x = r.width/2 - ix*view.k;
view.y = r.height/2 - iy*view.k;
applyView();
}
function toImage(e){
const r = mapEl.getBoundingClientRect();
return { x: (e.clientX - r.left - view.x)/view.k, y: (e.clientY - r.top - view.y)/view.k };
}
/* pan + wheel */
let pan = null;
mapEl.addEventListener("mousedown", e => {
if (e.button !== 0 || dragging) return;
if (mode !== "pan") return;
pan = { sx: e.clientX, sy: e.clientY, ox: view.x, oy: view.y };
mapEl.classList.add("grabbing");
});
window.addEventListener("mousemove", e => {
if (pan){ view.x = pan.ox + (e.clientX - pan.sx); view.y = pan.oy + (e.clientY - pan.sy); applyView(); }
});
window.addEventListener("mouseup", () => { pan = null; mapEl.classList.remove("grabbing"); });
mapEl.addEventListener("wheel", e => {
e.preventDefault();
const r = mapEl.getBoundingClientRect();
zoomAt(e.clientX - r.left, e.clientY - r.top, e.deltaY < 0 ? 1.14 : 1/1.14);
}, { passive:false });
mapEl.addEventListener("mousemove", e => {
const p = toImage(e);
$("#coord").textContent = (p.x>=0&&p.y>=0&&p.x<=IW&&p.y<=IH) ? `${Math.round(p.x)}, ${Math.round(p.y)}` : "—";
});
/* click on the map */
mapEl.addEventListener("click", e => {
if (pan && (Math.abs(e.clientX-pan.sx)>3)) return;
const p = toImage(e);
if (mode === "place"){
if (p.x<0||p.y<0||p.x>IW||p.y>IH) return;
pendingXY = p; editing = null;
openModal("New waypoint", "", "", WP_COLORS[0], WP_ICONS[0]);
setMode("pan");
return;
}
if (mode === "measure"){
measurePts.push(p); drawMeasure(); return;
}
// plain click: district hit-test
const d = hitDistrict(e);
if (d) select("district", d.id); else closeCard();
});
mapEl.addEventListener("dblclick", e => {
if (mode !== "pan") return;
const p = toImage(e);
if (p.x<0||p.y<0||p.x>IW||p.y>IH) return;
pendingXY = p; editing = null;
openModal("New waypoint", "", "", WP_COLORS[0], WP_ICONS[0]);
});
function hitDistrict(e){
for (const d of DATA.districts){
const path = zonePaths[d.id];
const r = mapEl.getBoundingClientRect();
const pt = zonesEl.createSVGPoint();
pt.x = e.clientX - r.left; pt.y = e.clientY - r.top;
const p = toImage(e);
const sp = zonesEl.createSVGPoint(); sp.x = p.x; sp.y = p.y;
if (path.isPointInFill && path.isPointInFill(sp)) return d;
}
return null;
}
/* ---------------- measuring ---------------- */
function drawMeasure(){
mLine.setAttribute("points", measurePts.map(p => p.x+","+p.y).join(" "));
let total = 0;
for (let i=1;i<measurePts.length;i++){
total += Math.hypot(measurePts[i].x-measurePts[i-1].x, measurePts[i].y-measurePts[i-1].y);
}
const feet = total / DATA.scale.px * DATA.scale.feet;
if (measurePts.length < 2) flash("Measure: click points along the route · Esc to finish");
else flash(`${Math.round(feet).toLocaleString()} ft · ${(feet/5280).toFixed(2)} mi · ${Math.ceil(feet/5)} squares`);
}
function clearMeasure(){ measurePts = []; mLine.removeAttribute("points"); }
/* ---------------- selection & card ---------------- */
function select(type, id){
selected = { type, id };
const card = $("#card"), ft = card.querySelector(".ft");
let title, kind, body, color;
if (type === "landmark"){
const p = DATA.landmarks[id];
title = p.name; kind = "Landmark"; body = p.html || "<p>No description recorded.</p>";
color = districtColorAt(p.x, p.y); ft.hidden = true;
flyTo(p.x, p.y, Math.max(view.k, 1.8));
} else if (type === "historic"){
const p = DATA.historic[id];
title = p.name; kind = p.era === "current" ? "District" : "Lost quarter · " + p.era;
body = "<p>"+p.desc+"</p>"; color = "#e8dfcc"; ft.hidden = true;
flyTo(p.x, p.y, Math.max(view.k, 1.4));
} else if (type === "district"){
const d = DATA.districts.find(d => d.id === id);
title = d.name; kind = d.quarter + " · " + d.alias;
body = "<p>"+d.desc+"</p>"; color = d.color; ft.hidden = true;
} else {
const w = waypoints.find(w => w.id === id);
if (!w) return;
title = (w.icon ? w.icon + " " : "") + (w.name || "Untitled");
kind = "Waypoint · " + Math.round(w.x) + ", " + Math.round(w.y);
body = w.note ? "<p>"+esc(w.note).replace(/\n/g,"<br>")+"</p>" : '<p style="color:#6f6a5e">No notes.</p>';
color = w.color; ft.hidden = false;
}
card.querySelector(".dot").style.background = color;
card.querySelector("h3").textContent = title;
card.querySelector(".kind").textContent = kind;
card.querySelector(".bd").innerHTML = body;
card.hidden = false;
syncSelection();
}
function closeCard(){ selected = null; $("#card").hidden = true; syncSelection(); }
function syncSelection(){
lmEls.forEach((e,i) => e.dot.classList.toggle("sel", !!selected && selected.type==="landmark" && selected.id===i));
hEls.forEach((e,i) => e.dot.classList.toggle("sel", !!selected && selected.type==="historic" && selected.id===i));
wpEls.forEach(e => e.dot.classList.toggle("sel", !!selected && selected.type==="waypoint" && selected.id===e.w.id));
DATA.districts.forEach(d => {
const on = !!selected && selected.type==="district" && selected.id===d.id;
zonePaths[d.id].setAttribute("fill-opacity", on ? ".3" : ".14");
});
}
const esc = s => s.replace(/[&<>]/g, c => ({"&":"&","<":"<",">":">"}[c]));
$("#card .cl").addEventListener("click", closeCard);
$("#card").querySelector('[data-act="edit"]').addEventListener("click", () => {
const w = waypoints.find(w => w.id === selected.id);
editing = w; pendingXY = null;
openModal("Edit waypoint", w.name, w.note, w.color, w.icon);
});
$("#card").querySelector('[data-act="del"]').addEventListener("click", () => delWaypoint(selected.id));
/* ---------------- modal ---------------- */
const swBox = $("#swatches");
WP_COLORS.forEach(c => {
const b = document.createElement("button");
b.style.background = c; b.dataset.c = c; b.setAttribute("aria-pressed","false");
b.addEventListener("click", () => { draftColor = c; paintSwatches(); });
swBox.appendChild(b);
});
const icBox = $("#icons");
WP_ICONS.forEach(ic => {
const b = document.createElement("button");
b.textContent = ic; b.dataset.i = ic; b.setAttribute("aria-pressed","false");
b.addEventListener("click", () => { draftIcon = ic; paintSwatches(); });
icBox.appendChild(b);
});
function paintSwatches(){
[...swBox.children].forEach(b => b.setAttribute("aria-pressed", String(b.dataset.c === draftColor)));
[...icBox.children].forEach(b => {
b.setAttribute("aria-pressed", String(b.dataset.i === draftIcon));
b.style.background = b.dataset.i === draftIcon ? draftColor + "33" : "";
});
}
function openModal(title, name, note, color, icon){
$("#mTitle").textContent = title;
$("#mName").value = name || "";
$("#mNote").value = note || "";
draftColor = color || WP_COLORS[0];
draftIcon = icon || WP_ICONS[0];
paintSwatches();
$("#modal").hidden = false;
setTimeout(() => $("#mName").focus(), 10);
}
$("#mCancel").addEventListener("click", () => { $("#modal").hidden = true; editing = null; pendingXY = null; });
$("#mSave").addEventListener("click", saveModal);
$("#mName").addEventListener("keydown", e => { if (e.key === "Enter") saveModal(); });
function saveModal(){
const name = $("#mName").value.trim(), note = $("#mNote").value.trim();
if (editing){ editing.name = name; editing.note = note; editing.color = draftColor; editing.icon = draftIcon; }
else if (pendingXY){
waypoints.push({ id: "w"+Date.now()+Math.random().toString(36).slice(2,6),
name, note, color: draftColor, icon: draftIcon,
x: pendingXY.x, y: pendingXY.y });
}
$("#modal").hidden = true; editing = null; pendingXY = null;
save(); renderWaypoints();
if (selected && selected.type === "waypoint") select("waypoint", selected.id);
}
/* ---------------- modes ---------------- */
function setMode(m){
mode = m;
mapEl.classList.toggle("placing", m === "place");
mapEl.classList.toggle("measuring", m === "measure");
$("#addBtn").classList.toggle("on", m === "place");
$("#rule").classList.toggle("on", m === "measure");
if (m === "place") flash("Click the map to place a waypoint · Esc to cancel");
else if (m === "measure"){ clearMeasure(); drawMeasure(); }
else { clearMeasure(); flash(null); }
}
let flashT;
function flash(msg){
const b = $("#banner");
clearTimeout(flashT);
if (!msg){ b.hidden = true; return; }
b.textContent = msg; b.hidden = false;
if (mode === "pan") flashT = setTimeout(() => b.hidden = true, 2600);
}
$("#addBtn").addEventListener("click", () => setMode(mode === "place" ? "pan" : "place"));
$("#rule").addEventListener("click", () => setMode(mode === "measure" ? "pan" : "measure"));
$("#zin").addEventListener("click", () => { const r = mapEl.getBoundingClientRect(); zoomAt(r.width/2, r.height/2, 1.35); });
$("#zout").addEventListener("click", () => { const r = mapEl.getBoundingClientRect(); zoomAt(r.width/2, r.height/2, 1/1.35); });
$("#fit").addEventListener("click", fit);
document.addEventListener("keydown", e => {
if (/^(INPUT|TEXTAREA)$/.test(e.target.tagName)){
if (e.key === "Escape") $("#mCancel").click();
return;
}
if (e.key === "Escape"){ if (mode !== "pan") setMode("pan"); else closeCard(); }
else if (e.key === "w" || e.key === "W") setMode(mode === "place" ? "pan" : "place");
else if (e.key === "m" || e.key === "M") setMode(mode === "measure" ? "pan" : "measure");
else if (e.key === "f" || e.key === "F") fit();
});
/* ---------------- layers ---------------- */
const layers = {
districts: () => { zonesEl.style.display = $("#L-districts").checked ? "" : "none";
labelEls.forEach(l => l.m.style.display = $("#L-districts").checked ? "" : "none"); },
landmarks: () => lmEls.forEach(l => l.m.style.display = $("#L-landmarks").checked ? "" : "none"),
historic: () => hEls.forEach(l => l.m.style.display = $("#L-historic").checked ? "" : "none"),
waypoints: () => wpEls.forEach(l => l.m.style.display = $("#L-waypoints").checked ? "" : "none"),
};
Object.keys(layers).forEach(k => {
const cb = $("#L-"+k);
cb.addEventListener("change", () => { layers[k](); cb.closest(".row").classList.toggle("off", !cb.checked); });
});
$("#c-districts").textContent = DATA.districts.length;
$("#c-landmarks").textContent = DATA.landmarks.length;
$("#c-historic").textContent = DATA.historic.length;
$("#L-historic").closest(".row").classList.add("off");
/* district list in sidebar */
DATA.districts.forEach(d => {
const el = document.createElement("div");
el.className = "item";
el.innerHTML = '<span class="dot"></span><span class="nm"></span>';
el.querySelector(".dot").style.background = d.color;
const nm = el.querySelector(".nm");
nm.append(d.name);
const s = document.createElement("span"); s.className = "sub"; s.textContent = d.quarter + " · " + d.alias;
nm.appendChild(s);
el.addEventListener("click", () => { select("district", d.id); flyTo(d.label[0], d.label[1], 1.0); });
$("#dlist").appendChild(el);
});
/* ---------------- semantic search ---------------- */
/* No backend and no embedding model: a concept lexicon maps everyday phrasing
onto the tag vocabulary, and matches are ranked with IDF so rare concepts
("weapons") outweigh common ones ("trade"). */
const LEX = {
weapons:["weapon","sword","swords","blade","blades","arms","arm","axe","axes","bow","bows","dagger","daggers","mace","spear","steel","armory","armoury","weaponry","knife","knives","martial"],
armor:["armour","armored","shield","shields","mail","plate","helm","helmet","protection","smith","blacksmith","forge"],
shop:["buy","buying","purchase","purchasing","sell","selling","seller","shopping","store","stores","market","marketplace","vendor","vendors","wares","goods","merchant","merchants","shopkeeper","commerce","spend"],
craft:["crafter","crafts","craftsman","artisan","smith","forge","maker","handmade","workshop","made"],
magic:["magical","wizard","wizards","mage","mages","sorcerer","sorcerers","spell","spells","enchanted","enchantment","ritual","portal","arcane"],
arcane:["wizard","wizards","mage","mages","magic","spellcaster","scholar"],
tavern:["taverns","pub","pubs","bar","bars","alehouse","alehouses","drinking","beer","ale","wine","booze"],
drink:["beer","ale","wine","booze","drinking","drunk","tavern","pub","bar","mead","spirits","thirsty"],
food:["eat","eating","meal","meals","dine","dining","dinner","supper","feast","hungry","hunger","kitchen","restaurant","fish","bread","cook","cooking"],
inn:["inns","lodge","lodging","stay","staying","sleep","sleeping","rest","resting","bed","beds","room","rooms","guesthouse","hostel","overnight","night","accommodation"],
lodging:["sleep","stay","bed","rest","room","night","lodge"],
festhall:["brothel","pleasure","company","companion","companions","entertainment","courtesan","dancing"],
temple:["temples","shrine","shrines","church","cathedral","chapel","holy","sacred","priest","priests","cleric","clerics","god","goddess","deity","faith","pray","prayer","heal","healing"],
worship:["pray","prayer","god","goddess","deity","holy","sacred","faith","religion","religious","priest","cleric"],
knowledge:["learn","learning","study","studying","research","lore","information","info","history","records","scholar","scholars","sage","wisdom","answers"],
library:["libraries","books","book","tome","tomes","archive","archives","records","reading"],
books:["book","tome","tomes","reading","library","scroll","scrolls"],
maps:["map","cartography","chart","charts","directions","navigation","exploration","explore"],
government:["govern","ruler","rule","lord","authority","official","officials","politics","civic","council","seat","power","administration","mayor"],
law:["legal","justice","court","courts","trial","judge","judgement","punishment","arrest","jail"],
guard:["guards","watch","watchmen","soldier","soldiers","militia","patrol","security","defense","defence"],
crime:["criminal","criminals","thief","thieves","thieving","steal","stealing","rogue","rogues","smuggler","smugglers","gang","gangs","underworld","illegal","shady","seedy","fence"],
secret:["secrets","hidden","hide","hideout","conspiracy","covert","spy","spies","clandestine","meeting"],
faction:["factions","guild","guilds","organization","organisation","order","cult","society","group","harpers","harper","nashers","graycloaks","ashmadai","cell"],
undead:["zombie","zombies","skeleton","skeletons","ghost","ghosts","ghoul","ghouls","wight","lich","banshee","banshees","haunted","haunt","necromancy","risen","wraith"],
dead:["death","die","dying","corpse","corpses","body","bodies","burial","buried","funeral","bury"],
graveyard:["cemetery","cemeteries","grave","graves","tomb","tombs","crypt","crypts","mausoleum","mausoleums","burial"],
ruins:["ruin","ruined","rubble","destroyed","abandoned","derelict","collapsed","wreck","wreckage","broken","razed"],
danger:["dangerous","deadly","threat","threats","monster","monsters","hostile","risky","perilous","peril","unsafe","combat","ambush","trouble"],
water:["sea","ocean","lake","lakes","harbor","harbour","bay","coast","waterfront","shore"],
river:["rivers","stream","crossing"],
docks:["dock","harbor","harbour","port","wharf","quay","pier","waterfront","sailors","sailor","unload"],
ships:["ship","boat","boats","vessel","vessels","sail","sailing","sailor","sailors","fleet"],
bridge:["bridges","cross","crossing","span"],
trade:["trading","trader","traders","commerce","commercial","business","deal","deals","merchant","merchants","cargo","import","export","caravan","supplies"],
money:["coin","coins","gold","cash","currency","bank","banking","loan","loans","lend","lending","moneylender","moneychanger","exchange","wealth","pay","broke"],
guild:["guilds","guildhall","union","order","company"],
noble:["nobles","nobility","aristocrat","aristocracy","lord","lords","lady","manor","manors","estate","estates","wealthy","gentry"],
luxury:["luxurious","expensive","fine","finest","fancy","upscale","posh","elegant","comfort","comfortable","best","rich"],
cheap:["affordable","inexpensive","budget","humble","cheapest"],
poor:["poverty","beggar","beggars","slum","slums","destitute","humble"],
work:["job","jobs","hire","hiring","employment","contract","contracts","quest","quests","hired","errand"],
adventurers:["adventurer","adventure","adventuring","party","hero","heroes","mercenary","mercenaries","sellsword"],
tower:["towers","spire","spires"],
castle:["fortress","keep","citadel","stronghold","palace"],
earthmote:["floating","float","flying","sky","airborne"],
nature:["park","garden","gardens","trees","tree","green","grove","wood","woods"],
landmark:["landmarks","sight","sights","notable","famous","monument","see"],
district:["districts","quarter","quarters","ward","wards","neighborhood","neighbourhood","area","region"],
historic:["history","historical","old","former","past","ancient","before","used"],
gate:["gates","entrance","entry"],
wall:["walls","fortification","rampart"],
prison:["jail","dungeon","dungeons","cell","cells","captive","prisoner","prisoners"],
school:["academy","academies","university","college","teaching","training","student","students","apprentice"],
cult:["cultist","cultists","devil","devils","demon","demons","infernal","heresy","sinister"],
dwarf:["dwarves","dwarven"], gnome:["gnomes","gnomish"], orc:["orcs","orcish"],
pirates:["pirate","buccaneer","raider","raiders"],
smugglers:["smuggler","smuggling","contraband"]
};
const STOP = new Set(("a an the to for of in on at and or is are was were be am i me my we you it that this " +
"there here where what which who how somewhere anywhere place places spot spots something anything " +
"need needs want wants find finding look looking looks get getting go going can could would should " +
"do does near nearby around city town somewhere s t re ve").split(" "));
const WORD2TAG = new Map();
function bindWord(w, tag){
if (!WORD2TAG.has(w)) WORD2TAG.set(w, new Set());
WORD2TAG.get(w).add(tag);
}
Object.entries(LEX).forEach(([tag, words]) => { bindWord(tag, tag); words.forEach(w => bindWord(w, tag)); });
/* corpus */
const stripTags = h => (h || "").replace(/<[^>]*>/g, " ");
const CORPUS = [
...DATA.districts.map(d => ({ t:"district", id:d.id, name:d.name, kind:"District", color:d.color,
x:d.label[0], y:d.label[1], tags:d.tags, text:(d.name+" "+d.alias+" "+d.quarter+" "+d.desc).toLowerCase() })),
...DATA.landmarks.map((p,i) => ({ t:"landmark", id:i, name:p.name, kind:"Landmark", color:districtColorAt(p.x,p.y),
x:p.x, y:p.y, tags:p.tags, text:(p.name+" "+stripTags(p.html)).toLowerCase() })),
...DATA.historic.map((p,i) => ({ t:"historic", id:i, name:p.name, kind: p.era==="current" ? "District" : "Lost quarter",
color:"#e8dfcc", x:p.x, y:p.y, tags:p.tags, text:(p.name+" "+p.era+" "+p.desc).toLowerCase() })),
];
/* inverse document frequency per tag — rare concepts count for more */
const IDF = {};
{
const N = CORPUS.length, df = {};
CORPUS.forEach(c => new Set(c.tags).forEach(t => df[t] = (df[t]||0) + 1));
Object.keys(LEX).forEach(t => IDF[t] = Math.log(N / ((df[t]||0) + 0.5)));
}
const tokenize = q => q.toLowerCase().split(/[^a-z0-9']+/).filter(w => w && w.length > 1 && !STOP.has(w));
function variants(w){
const v = [w];
if (w.endsWith("ies") && w.length > 4) v.push(w.slice(0,-3)+"y");
else if (w.endsWith("es") && w.length > 4) v.push(w.slice(0,-2));
if (w.endsWith("s") && w.length > 3) v.push(w.slice(0,-1));
if (w.endsWith("ing") && w.length > 5) v.push(w.slice(0,-3));
return v;
}
function conceptsFor(word){
const out = new Set();
for (const v of variants(word)){
const hit = WORD2TAG.get(v);
if (hit) hit.forEach(t => out.add(t));
}
return out;
}
function rank(query){
const toks = tokenize(query);
if (!toks.length) return [];
const scored = [];
for (const c of CORPUS){
let score = 0;
const why = new Set();
const nameLc = c.name.toLowerCase();
const nameToks = new Set(nameLc.split(/[^a-z0-9']+/).filter(Boolean));
for (const tok of toks){
let nameHit = false;
for (const v of variants(tok)){
if (nameToks.has(v)){ score += 15; nameHit = true; break; }
if (v.length > 2 && nameLc.includes(v)){ score += 9; nameHit = true; break; }
}
for (const tag of conceptsFor(tok)){
if (c.tags.includes(tag)){ score += 7 * (IDF[tag] || 1); why.add(tag); }
}
/* a literal mention in the write-up always counts — it is what separates
"the Harpers" from every other faction hideout on the map */
if (!nameHit){
for (const v of variants(tok)){
if (v.length > 3 && c.text.includes(v)){ score += 4; break; }
}
}
}
if (score > 0) scored.push({ c, score, why:[...why] });
}
/* waypoints join in on plain name/note matching */
const q = query.toLowerCase();
waypoints.forEach(w => {
const hay = ((w.name||"") + " " + (w.note||"")).toLowerCase();
if (q && hay.includes(q)) scored.push({
c:{ t:"waypoint", id:w.id, name:w.name||"Untitled", kind:"Waypoint", color:w.color, x:w.x, y:w.y },
score: 20, why: []
});
});
return scored.sort((a,b) => b.score - a.score || a.c.name.localeCompare(b.c.name)).slice(0, 12);
}
function renderResults(query){
const box = $("#results");
box.innerHTML = "";
if (!query.trim()) return;
const hits = rank(query);
if (!hits.length){
box.innerHTML = '<p class="empty">Nothing matched. Try a need rather than a name — “buy armour”, “somewhere to sleep”, “undead”.</p>';
return;
}
hits.forEach(h => {
const el = document.createElement("div");
el.className = "item";
el.innerHTML = '<span class="dot"></span><span class="nm"></span>';
el.querySelector(".dot").style.background = h.c.color;
const nm = el.querySelector(".nm");
nm.append(h.c.name);
const sub = document.createElement("span"); sub.className = "sub"; sub.textContent = h.c.kind;
nm.appendChild(sub);
if (h.why.length){
const tg = document.createElement("span"); tg.className = "tags";
h.why.sort((a,b) => (IDF[b]||0)-(IDF[a]||0)).slice(0,3).forEach(t => {
const s = document.createElement("span"); s.textContent = t; tg.appendChild(s);
});
nm.appendChild(tg);
}
el.addEventListener("click", () => { flyTo(h.c.x, h.c.y, Math.max(view.k, 1.8)); select(h.c.t, h.c.id); });
box.appendChild(el);
});
}