wiki-plugin-rcnmap 0.4.3 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/rcnmap.js +258 -20
- package/package.json +1 -1
- package/pages/about-rcnmap-plugin +32 -0
package/client/rcnmap.js
CHANGED
|
@@ -1,5 +1,178 @@
|
|
|
1
1
|
(function () {
|
|
2
2
|
|
|
3
|
+
// BEGIN rcn-lineup-follow — pasted from tools/rcn-lineup-follow.js by tools/paste-lineup-follow.js. Edit that file, never this block.
|
|
4
|
+
/* rcn-lineup-follow — the timeline, map and drawing items on a wiki page follow
|
|
5
|
+
* each other, across the whole lineup and into the full tools open in other tabs.
|
|
6
|
+
*
|
|
7
|
+
* ONE SOURCE. tools/paste-lineup-follow.js pastes this file into the three
|
|
8
|
+
* plugins (rcntimeline, rcnmap, rcngraph) between the BEGIN/END marker lines,
|
|
9
|
+
* so each plugin stays one file. Edit this file, then run
|
|
10
|
+
* node tools/paste-lineup-follow.js
|
|
11
|
+
*
|
|
12
|
+
* WHY IT IS EASY ON A WIKI. A FedWiki lineup is one browser document: every
|
|
13
|
+
* page beside the others is a .page inside .main, even pages from other sites.
|
|
14
|
+
* So items on different pages can call each other directly. The first plugin
|
|
15
|
+
* to load makes window.rcnLineup; the others use it.
|
|
16
|
+
*
|
|
17
|
+
* WHAT GOES OUT. The same two messages the full tools send (tools/rcn-switch.js):
|
|
18
|
+
* { type:'rcn-walk', src, lead, k, all, label, ids, places, eips } a walk step
|
|
19
|
+
* { type:'rcn-walk', src, lead, k, end:true } the walk stopped
|
|
20
|
+
* { type:'rcn-follow', src, k, click:true, id, place, eip, ids, places, eips, clear? }
|
|
21
|
+
* ids are timeline bars, places map points, eips drawing nodes. The sender
|
|
22
|
+
* widens what it lights one hop through every timeline in the lineup: each bar
|
|
23
|
+
* names a place and a node, so a map step on the Magma mine lights the Magma
|
|
24
|
+
* bars and the Magma Copper box. x:1 marks a message already widened.
|
|
25
|
+
*
|
|
26
|
+
* HOW IT TRAVELS. As a bubbling DOM event 'rcnwalkStream' from the item (the
|
|
27
|
+
* naming FedWiki's Frame plugin uses for its LINEUP topics), heard once at the
|
|
28
|
+
* document and handed to every joined item but the sender; and over the
|
|
29
|
+
* BroadcastChannel 'rcn-follow', where the full tools of the same site listen.
|
|
30
|
+
*
|
|
31
|
+
* Marc Pierson with Claude Opus 5.5, Nov 2026. MIT licence.
|
|
32
|
+
*/
|
|
33
|
+
const RL = (function () {
|
|
34
|
+
if (typeof window === 'undefined' || typeof document === 'undefined') return null
|
|
35
|
+
if (window.rcnLineup) return window.rcnLineup
|
|
36
|
+
const R = window.rcnLineup = { v: 1, members: [], heard: {} }
|
|
37
|
+
const CH = ('BroadcastChannel' in window) ? new BroadcastChannel('rcn-follow') : null
|
|
38
|
+
const none = () => ({ ids: [], places: [], eips: [] })
|
|
39
|
+
|
|
40
|
+
// The bridges: every bar of every timeline item in the lineup.
|
|
41
|
+
R.bars = function () {
|
|
42
|
+
const out = []
|
|
43
|
+
document.querySelectorAll('.rcntimeline-source').forEach(el => {
|
|
44
|
+
if (!el.timelineData) return
|
|
45
|
+
try {
|
|
46
|
+
(el.timelineData().intervals || []).forEach(iv => {
|
|
47
|
+
const x = iv.extra || {}
|
|
48
|
+
out.push({ id: String(iv.id), place: iv.place || x.place || null, eip: iv.eip || x.eip || null })
|
|
49
|
+
})
|
|
50
|
+
} catch (e) {}
|
|
51
|
+
})
|
|
52
|
+
return out
|
|
53
|
+
}
|
|
54
|
+
// One hop: a bar named, or at a lit place, or about a lit node, adds its bar, place and node.
|
|
55
|
+
R.expand = function (o) {
|
|
56
|
+
const I = {}, P = {}, E = {}, i0 = {}, p0 = {}, e0 = {}
|
|
57
|
+
;(o.ids || []).filter(Boolean).forEach(x => { I[x] = i0[x] = 1 })
|
|
58
|
+
;(o.places || []).filter(Boolean).forEach(x => { P[x] = p0[x] = 1 })
|
|
59
|
+
;(o.eips || []).filter(Boolean).forEach(x => { E[x] = e0[x] = 1 })
|
|
60
|
+
R.bars().forEach(b => {
|
|
61
|
+
if (i0[b.id] || (b.place && p0[b.place]) || (b.eip && e0[b.eip])) {
|
|
62
|
+
I[b.id] = 1; if (b.place) P[b.place] = 1; if (b.eip) E[b.eip] = 1
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
return { ids: Object.keys(I), places: Object.keys(P), eips: Object.keys(E) }
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// An item joins: fn(m) hears the others and returns true when it lit something.
|
|
69
|
+
// Joining again (a redraw) replaces the item's old listener.
|
|
70
|
+
R.join = function (el, src, fn) {
|
|
71
|
+
R.members = R.members.filter(x => x.el !== el && document.contains(x.el))
|
|
72
|
+
R.members.push({ el, src, fn })
|
|
73
|
+
}
|
|
74
|
+
R.others = el => R.members.filter(x => x.el !== el && document.contains(x.el)).length
|
|
75
|
+
|
|
76
|
+
function deliver (m, fromEl) {
|
|
77
|
+
if (!m || !m.k || R.heard[m.k]) return 0
|
|
78
|
+
R.heard[m.k] = 1
|
|
79
|
+
R.members = R.members.filter(x => document.contains(x.el))
|
|
80
|
+
let n = 0
|
|
81
|
+
R.members.slice().forEach(x => {
|
|
82
|
+
if (x.el === fromEl) return
|
|
83
|
+
try { if (x.fn(m)) n++ } catch (e) { console.warn('rcn-lineup-follow:', e) }
|
|
84
|
+
})
|
|
85
|
+
return n
|
|
86
|
+
}
|
|
87
|
+
// Returns how many items in this lineup lit something.
|
|
88
|
+
function send (el, m) {
|
|
89
|
+
m.k = Date.now() + ':' + Math.random()
|
|
90
|
+
let n = 0
|
|
91
|
+
try {
|
|
92
|
+
const ev = new CustomEvent('rcnwalkStream', { bubbles: true, detail: m })
|
|
93
|
+
el.dispatchEvent(ev)
|
|
94
|
+
n = ev.rcnLit || 0
|
|
95
|
+
} catch (e) {}
|
|
96
|
+
try { if (CH) CH.postMessage(m) } catch (e) {}
|
|
97
|
+
return n
|
|
98
|
+
}
|
|
99
|
+
document.addEventListener('rcnwalkStream', e => { e.rcnLit = deliver(e.detail, e.target) })
|
|
100
|
+
// The full tools in other tabs: their walks come widened through their set;
|
|
101
|
+
// their clicks name one thing, so widen those here.
|
|
102
|
+
if (CH) CH.addEventListener('message', ev => {
|
|
103
|
+
const m = ev.data
|
|
104
|
+
if (!m || !m.k) return
|
|
105
|
+
if (m.type === 'rcn-walk') { deliver(m, null); return }
|
|
106
|
+
if (m.type !== 'rcn-follow' || !m.click) return
|
|
107
|
+
if (m.x) { deliver(m, null); return }
|
|
108
|
+
const x = m.id ? R.expand({ ids: m.src === 'timeline' ? [m.id] : [], places: [m.place], eips: [m.eip] }) : none()
|
|
109
|
+
deliver(Object.assign({}, m, x, { x: 1, clear: !m.id }), null)
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
// A step of this item's walk. o: {ids|places|eips: [...], all, label}
|
|
113
|
+
R.step = function (el, src, o) {
|
|
114
|
+
if (!el.rcnLead) el.rcnLead = src + ':' + Date.now().toString(36) + Math.random().toString(36).slice(2, 6)
|
|
115
|
+
const x = o.all ? none() : R.expand(o)
|
|
116
|
+
return send(el, Object.assign({ type: 'rcn-walk', src, lead: el.rcnLead, all: !!o.all, pointer: false, label: o.label || null, x: 1 }, x))
|
|
117
|
+
}
|
|
118
|
+
// This item's walk stopped. Sends nothing if it was not leading.
|
|
119
|
+
R.end = function (el, src) {
|
|
120
|
+
if (!el.rcnLead) return
|
|
121
|
+
const lead = el.rcnLead
|
|
122
|
+
el.rcnLead = null
|
|
123
|
+
send(el, { type: 'rcn-walk', src, lead, end: true })
|
|
124
|
+
}
|
|
125
|
+
// A click on one thing, or {clear:true} to let go. o: {id} for a bar (it
|
|
126
|
+
// lights the bar's own place and node), {place} for a map point (the bars there
|
|
127
|
+
// and their nodes), {eip} for a drawing box (the bars about it and their places).
|
|
128
|
+
// Returns how many items in this lineup lit something.
|
|
129
|
+
R.click = function (el, src, o) {
|
|
130
|
+
el.rcnClicked = !o.clear
|
|
131
|
+
const x = o.clear ? none() : R.expand({ ids: o.id ? [o.id] : [], places: [o.place], eips: [o.eip] })
|
|
132
|
+
const bar = o.id && R.bars().find(b => b.id === String(o.id))
|
|
133
|
+
return send(el, Object.assign({ type: 'rcn-follow', src, click: true, clear: !!o.clear,
|
|
134
|
+
id: o.clear ? null : (o.id || o.place || o.eip || null), label: o.label || null,
|
|
135
|
+
place: o.place || (bar && bar.place) || null, eip: o.eip || (bar && bar.eip) || null, x: 1 }, x))
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// A follower's state after hearing m. f: {lead, lit:Set|null, seen:Set, click}
|
|
139
|
+
// or null. mine: the ids of this item that m names. Returns the new state; the
|
|
140
|
+
// same object means nothing changes (a step about nothing here leaves it be).
|
|
141
|
+
R.update = function (f, m, mine) {
|
|
142
|
+
if (m.type === 'rcn-walk' && m.end) return f && f.lead === m.lead ? null : f
|
|
143
|
+
if (m.type === 'rcn-follow' && m.clear) return f && f.click ? null : f
|
|
144
|
+
const same = f && m.lead && f.lead === m.lead
|
|
145
|
+
if (m.all) return { lead: m.lead || null, lit: null, seen: same ? f.seen : new Set(), click: false }
|
|
146
|
+
if (!mine.length) return f
|
|
147
|
+
const seen = same ? new Set([...f.seen, ...(f.lit || [])]) : new Set()
|
|
148
|
+
return { lead: m.lead || null, lit: new Set(mine), seen, click: m.type === 'rcn-follow' }
|
|
149
|
+
}
|
|
150
|
+
// How strongly to draw one thing: lit full, seen half, the rest faded
|
|
151
|
+
// (less faded after a click than in a walk).
|
|
152
|
+
R.op = function (f, id) {
|
|
153
|
+
if (!f || !f.lit || f.lit.has(id)) return 1
|
|
154
|
+
if (f.seen.has(id)) return 0.42
|
|
155
|
+
return f.click ? 0.3 : 0.13
|
|
156
|
+
}
|
|
157
|
+
// "⧉ Open together": the Time Place Causality Explorer on an item's set file
|
|
158
|
+
// (item.set). A bare file name lives in the site's /assets/NDC/ folder beside
|
|
159
|
+
// the explorer and the full tools; a full address may point anywhere, and the
|
|
160
|
+
// explorer is then looked for in that set's own folder. A local wiki opens the
|
|
161
|
+
// working copy on :8765.
|
|
162
|
+
R.together = function (set) {
|
|
163
|
+
const local = /(^|\.)localhost$/.test(location.hostname)
|
|
164
|
+
const s = new URL(set, location.origin + '/assets/NDC/')
|
|
165
|
+
const page = local ? 'http://localhost:8765/tools/rcn-together.html' : new URL('rcn-together.html', s).href
|
|
166
|
+
return page + '?set=' + encodeURIComponent(new URL(page).origin === s.origin ? s.pathname : s.href)
|
|
167
|
+
}
|
|
168
|
+
R.togetherButton = item => item && typeof item.set === 'string' && item.set.trim()
|
|
169
|
+
? '<button class="rcn-together" style="cursor:pointer;font-size:12px;padding:2px 8px" title="Open this with its timeline, map and sketch side by side in the Time Place Causality Explorer">⧉ Open together ↗</button>'
|
|
170
|
+
: ''
|
|
171
|
+
R.openTogether = item => { const w = window.open(R.together(item.set.trim()), 'rcntogether'); if (w) try { w.focus() } catch (e) {} }
|
|
172
|
+
return R
|
|
173
|
+
})()
|
|
174
|
+
// END rcn-lineup-follow
|
|
175
|
+
|
|
3
176
|
// RCN Map — a small map on a wiki page that draws points AND the ties between
|
|
4
177
|
// them. FedWiki's own Map plugin draws points only; the full RCN Map is a
|
|
5
178
|
// full-screen tool in the site's assets. This sits between the two: the item
|
|
@@ -260,10 +433,13 @@
|
|
|
260
433
|
|
|
261
434
|
// Restyle the drawn map for the open step, or put it back (no walk open).
|
|
262
435
|
// el.rcnmDrawn is what draw() made: {map, markers:{id}, ties:[{key,layer,weight}], home()}.
|
|
263
|
-
|
|
436
|
+
// stay: put the styles back but leave the view where it is.
|
|
437
|
+
function walkPaint (el, item, stay) {
|
|
264
438
|
const d = el.rcnmDrawn, wk = el.rcnmWalk
|
|
265
439
|
if (!d) return
|
|
266
440
|
const L = window.L, walk = wk && wk.w !== null ? walkList(item)[wk.w] : null
|
|
441
|
+
const f = !walk && el.rcnmFollow && el.rcnmFollow.lit ? el.rcnmFollow : null
|
|
442
|
+
if (f) { followPaint(d, item, f); return }
|
|
267
443
|
const st = walk && walk.steps[wk.i], lit = st ? stepLit(st) : null
|
|
268
444
|
const seenP = new Set(), seenT = new Set()
|
|
269
445
|
if (walk) walk.steps.slice(0, wk.i).forEach(s => { const x = stepLit(s); if (x) { x.P.forEach(v => seenP.add(v)); x.T.forEach(v => seenT.add(v)) } })
|
|
@@ -281,23 +457,50 @@
|
|
|
281
457
|
})
|
|
282
458
|
const tiles = d.map.getPane('tilePane')
|
|
283
459
|
if (tiles) tiles.style.opacity = walk ? '0.55' : ''
|
|
284
|
-
|
|
285
|
-
if (
|
|
286
|
-
if (lit && lit.P.size <= WALK_LABELS_MAX) {
|
|
287
|
-
const byId = {}
|
|
288
|
-
model(item).parcels.forEach(p => { byId[p.id] = p })
|
|
289
|
-
d.labels = L.layerGroup([...lit.P].filter(id => d.markers[id] && byId[id]).map(id =>
|
|
290
|
-
L.marker(d.markers[id].getLatLng(), { interactive: false, keyboard: false,
|
|
291
|
-
icon: L.divIcon({ className: 'rcnm-label', iconSize: [0, 0], html: `<span>${esc(byId[id].label)}</span>` }) }))).addTo(d.map)
|
|
292
|
-
walkDeclutter(d)
|
|
293
|
-
}
|
|
294
|
-
if (!walk) { d.home(); return }
|
|
460
|
+
walkLabels(d, item, lit ? lit.P : null)
|
|
461
|
+
if (!walk) { if (!stay) d.home(); return }
|
|
295
462
|
if (st.view && Array.isArray(st.view.center)) { d.map.flyTo(st.view.center, st.view.zoom || 12, { duration: 1.1 }); return }
|
|
296
463
|
const pts = lit ? [...lit.P].map(id => d.markers[id] && d.markers[id].getLatLng()).filter(Boolean) : []
|
|
297
464
|
if (!pts.length) d.home()
|
|
298
465
|
else if (pts.length === 1) d.map.flyTo(pts[0], Math.max(d.map.getZoom(), 13), { duration: 1.1 })
|
|
299
466
|
else d.map.flyToBounds(L.latLngBounds(pts), { padding: [30, 30], maxZoom: 14, duration: 1.1 })
|
|
300
467
|
}
|
|
468
|
+
// Name the points a step is about, unless so many are lit the names would pile up.
|
|
469
|
+
function walkLabels (d, item, P) {
|
|
470
|
+
const L = window.L
|
|
471
|
+
if (d.labels) { d.map.removeLayer(d.labels); d.labels = null }
|
|
472
|
+
if (!P || P.size > WALK_LABELS_MAX) return
|
|
473
|
+
const byId = {}
|
|
474
|
+
model(item).parcels.forEach(p => { byId[p.id] = p })
|
|
475
|
+
d.labels = L.layerGroup([...P].filter(id => d.markers[id] && byId[id]).map(id =>
|
|
476
|
+
L.marker(d.markers[id].getLatLng(), { interactive: false, keyboard: false,
|
|
477
|
+
icon: L.divIcon({ className: 'rcnm-label', iconSize: [0, 0], html: `<span>${esc(byId[id].label)}</span>` }) }))).addTo(d.map)
|
|
478
|
+
walkDeclutter(d)
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
// Following another item in the lineup (see rcn-lineup-follow): the points it
|
|
482
|
+
// lights here at full strength and named, a tie between two of them heavier,
|
|
483
|
+
// what it lit before at half, the rest faded; the map flies to the lit points.
|
|
484
|
+
function followPaint (d, item, f) {
|
|
485
|
+
const L = window.L, op = id => RL.op(f, id)
|
|
486
|
+
d.ties.forEach(t => {
|
|
487
|
+
const [a, b] = t.key.split('>'), on = f.lit.has(a) && f.lit.has(b)
|
|
488
|
+
t.layer.setStyle({ opacity: on ? 1 : 0.85 * Math.min(op(a), op(b)), weight: on ? Math.max(5, t.weight * 2) : t.weight })
|
|
489
|
+
if (on) t.layer.bringToFront()
|
|
490
|
+
})
|
|
491
|
+
Object.keys(d.markers).forEach(id => {
|
|
492
|
+
const o = op(id)
|
|
493
|
+
d.markers[id].setStyle({ opacity: o, fillOpacity: 0.95 * o })
|
|
494
|
+
if (o === 1) d.markers[id].bringToFront()
|
|
495
|
+
})
|
|
496
|
+
const tiles = d.map.getPane('tilePane')
|
|
497
|
+
if (tiles) tiles.style.opacity = '0.55'
|
|
498
|
+
walkLabels(d, item, f.lit)
|
|
499
|
+
const pts = [...f.lit].map(id => d.markers[id] && d.markers[id].getLatLng()).filter(Boolean)
|
|
500
|
+
if (pts.length === 1) d.map.flyTo(pts[0], Math.max(d.map.getZoom(), 13), { duration: 1.1 })
|
|
501
|
+
else if (pts.length) d.map.flyToBounds(L.latLngBounds(pts), { padding: [30, 30], maxZoom: 14, duration: 1.1 })
|
|
502
|
+
}
|
|
503
|
+
|
|
301
504
|
// Downtown, lit points sit within a block of each other: try each name right
|
|
302
505
|
// of its dot, then left, above and below, and keep the first place that
|
|
303
506
|
// covers no name already placed. Runs again whenever the map settles.
|
|
@@ -355,8 +558,10 @@
|
|
|
355
558
|
if (!walk) return
|
|
356
559
|
wk.i = Math.max(0, Math.min(walk.steps.length - 1, i))
|
|
357
560
|
wk.token++; stopVoice()
|
|
561
|
+
el.rcnmFollow = null // leading now, not following
|
|
358
562
|
walkPaint(el, item)
|
|
359
563
|
const st = walk.steps[wk.i]
|
|
564
|
+
if (RL) { const lit = stepLit(st); RL.step(el, 'map', { places: lit ? [...lit.P] : [], all: !lit, label: walk.name }) }
|
|
360
565
|
$item.find('.walk-say').text(st.say || '').css({ color: st.ask ? '#7c2d12' : '#1e1b4b', fontStyle: st.ask ? 'italic' : 'normal' })
|
|
361
566
|
ui()
|
|
362
567
|
if (wk.playing) speak()
|
|
@@ -376,10 +581,25 @@
|
|
|
376
581
|
const end = () => {
|
|
377
582
|
wk.playing = false; wk.token++; wk.w = null; wk.heard = null
|
|
378
583
|
if (window.rcnActiveWalk === wk) { stopVoice(); window.rcnActiveWalk = null }
|
|
584
|
+
if (RL) RL.end(el, 'map')
|
|
379
585
|
walkPaint(el, item)
|
|
380
586
|
ui()
|
|
381
587
|
}
|
|
382
588
|
wk.end = end
|
|
589
|
+
// Follow the other timeline, map and drawing items in the lineup, and the full
|
|
590
|
+
// tools in other tabs. A walk played elsewhere stops this one; a click elsewhere
|
|
591
|
+
// is ignored while this item's own walk is open. A point is lit by its own id,
|
|
592
|
+
// as a place or as a drawing node (a sketch area and its map area share one id).
|
|
593
|
+
if (RL) RL.join(el, 'map', msg => {
|
|
594
|
+
if (wk.w !== null) { if (msg.type !== 'rcn-walk' || msg.end) return false; end() }
|
|
595
|
+
const have = el.rcnmDrawn ? el.rcnmDrawn.markers : {}
|
|
596
|
+
const mine = [...new Set([...(msg.places || []), ...(msg.eips || [])])].filter(id => have[id])
|
|
597
|
+
const was = el.rcnmFollow || null, f = RL.update(was, msg, mine)
|
|
598
|
+
if (f === was) return false
|
|
599
|
+
el.rcnmFollow = f
|
|
600
|
+
walkPaint(el, item)
|
|
601
|
+
return !!(f && f.lit)
|
|
602
|
+
})
|
|
383
603
|
$item.off('.rcnmwalk')
|
|
384
604
|
$item.on('click.rcnmwalk', '.walk-start', e => {
|
|
385
605
|
e.stopPropagation()
|
|
@@ -472,7 +692,7 @@
|
|
|
472
692
|
const blob = await (await fetch(dataUrl)).blob()
|
|
473
693
|
const sum = new Uint8Array(await crypto.subtle.digest('SHA-256', await blob.arrayBuffer()))
|
|
474
694
|
const hex = [...sum.slice(0, 12)].map(b => b.toString(16).padStart(2, '0')).join('')
|
|
475
|
-
const ext = /mp4|m4a|aac/.test(blob.type) ? 'm4a' : /wav/.test(blob.type) ? 'wav' : /ogg/.test(blob.type) ? 'ogg' : 'webm'
|
|
695
|
+
const ext = /mpeg|mp3/.test(blob.type) ? 'mp3' : /mp4|m4a|aac/.test(blob.type) ? 'm4a' : /wav/.test(blob.type) ? 'wav' : /ogg/.test(blob.type) ? 'ogg' : 'webm'
|
|
476
696
|
const name = hex + '.' + ext
|
|
477
697
|
const url = location.origin + '/assets/' + VOICE_FOLDER + '/' + name
|
|
478
698
|
const have = await fetch(url, { method: 'HEAD', cache: 'no-store' }).then(r => r.ok, () => false)
|
|
@@ -579,7 +799,7 @@
|
|
|
579
799
|
<p class="caption" style="margin:4px 0 0;">${wiki.resolveLinks ? wiki.resolveLinks(esc(caption(item))) : esc(caption(item))}</p>
|
|
580
800
|
${controls}
|
|
581
801
|
${walkBar(item)}
|
|
582
|
-
${canOpen(item) ? `<div style="text-align:center;padding-top:6px"
|
|
802
|
+
${canOpen(item) || (RL && RL.togetherButton(item)) ? `<div style="text-align:center;padding-top:6px">${canOpen(item) ? `<button class="rcnm-open" style="cursor:pointer;font-size:12px;padding:2px 8px" title="Open this map in the full RCN Map to write or change its walks; Save to wiki there brings them back here">🗺 Open in RCN Map</button> ` : ''}${RL ? RL.togetherButton(item) : ''}</div>` : ''}
|
|
583
803
|
</div>
|
|
584
804
|
<style>
|
|
585
805
|
.rcnm-label{background:none;border:0}
|
|
@@ -623,18 +843,32 @@
|
|
|
623
843
|
drawn.ties.push({ key: l.from + '>' + l.to, layer: line, weight: k.weight || 2.5 })
|
|
624
844
|
})
|
|
625
845
|
|
|
626
|
-
const $page = $item.parents('.page:first')
|
|
846
|
+
const $page = $item.parents('.page:first'), el = $item.get(0)
|
|
627
847
|
m.parcels.forEach(p => {
|
|
628
848
|
const t = (m.types || {})[p.type] || {}
|
|
629
849
|
const c = p.contact || {}
|
|
630
850
|
const tip = `<b>${esc(p.label)}</b>` + (t.label ? `<br>${esc(t.label)}` : '')
|
|
631
851
|
+ (c.website ? `<br>${esc(c.website.replace(/^https?:\/\/(www\.)?/, '').replace(/\/$/, ''))}` : '')
|
|
632
852
|
+ (c.phone ? `<br>${esc(c.phone)}` : '')
|
|
633
|
-
|
|
853
|
+
const hint = () => RL && RL.others(el)
|
|
854
|
+
? '<br><i style="color:#64748b">click to light it beside · shift-click to open its page</i>'
|
|
855
|
+
: '<br><i style="color:#64748b">click to open its page</i>'
|
|
856
|
+
// A click lights the point in the items beside it; it opens the point's page
|
|
857
|
+
// when nothing beside it lights up. Shift-click opens the page at the end of
|
|
858
|
+
// the lineup, keeping the pages already open.
|
|
634
859
|
drawn.markers[p.id] = L.circleMarker(p.latLng, {
|
|
635
860
|
radius: 7, fillColor: t.color || DEFAULT_COLOR, color: '#fff', weight: 1.5, fillOpacity: 0.95
|
|
636
|
-
}).bindTooltip(tip, { direction: 'top', offset: [0, -6] })
|
|
637
|
-
.on('click',
|
|
861
|
+
}).bindTooltip(() => tip + hint(), { direction: 'top', offset: [0, -6] })
|
|
862
|
+
.on('click', e => {
|
|
863
|
+
L.DomEvent.stopPropagation(e)
|
|
864
|
+
if (e.originalEvent && e.originalEvent.shiftKey) { wiki.doInternalLink(p.wikiTitle || p.label, null); return }
|
|
865
|
+
if (RL && !(el.rcnmWalk && el.rcnmWalk.w !== null)) {
|
|
866
|
+
if (el.rcnmFollow) { el.rcnmFollow = null; walkPaint(el, item, true) }
|
|
867
|
+
if (RL.click(el, 'map', { place: p.id, label: p.label })) return
|
|
868
|
+
}
|
|
869
|
+
// beside items that follow, open it at the end so they stay open
|
|
870
|
+
wiki.doInternalLink(p.wikiTitle || p.label, RL && RL.others(el) ? null : $page)
|
|
871
|
+
})
|
|
638
872
|
.addTo(map)
|
|
639
873
|
})
|
|
640
874
|
|
|
@@ -646,13 +880,16 @@
|
|
|
646
880
|
else map.fitBounds(L.latLngBounds(m.parcels.map(p => p.latLng)), { padding: [24, 24], maxZoom: 15 })
|
|
647
881
|
}
|
|
648
882
|
drawn.home()
|
|
649
|
-
const el = $item.get(0)
|
|
650
883
|
el.rcnmDrawn = drawn
|
|
884
|
+
// A click on the map itself lets go of what this map last lit beside it.
|
|
885
|
+
map.on('click', () => { if (RL && el.rcnClicked) RL.click(el, 'map', { clear: true }) })
|
|
651
886
|
map.on('zoomend moveend', () => walkDeclutter(drawn))
|
|
652
887
|
|
|
653
888
|
// Dragging the map must not drag the item, and a double-click on the map
|
|
654
889
|
// should open the editor, as it does anywhere else on the item.
|
|
655
|
-
L.DomEvent.disableClickPropagation
|
|
890
|
+
// (Not L.DomEvent.disableClickPropagation: its one-shot click guard makes the
|
|
891
|
+
// map ignore every second click, so a click on the map could not let go.)
|
|
892
|
+
L.DomEvent.on(document.getElementById(id), 'mousedown touchstart dblclick', L.DomEvent.stopPropagation)
|
|
656
893
|
map.doubleClickZoom.disable()
|
|
657
894
|
}
|
|
658
895
|
|
|
@@ -696,6 +933,7 @@
|
|
|
696
933
|
aboutMark($item, 'rcnmap')
|
|
697
934
|
bindWalk($item, item)
|
|
698
935
|
$item.on('click', '.rcnm-open', e => { e.stopPropagation(); openTool($item, item) })
|
|
936
|
+
$item.on('click', '.rcn-together', e => { e.stopPropagation(); RL.openTogether(item) })
|
|
699
937
|
$item.dblclick(e => { if (!$(e.target).closest('button, .walk-bar').length) wiki.textEditor($item, item) })
|
|
700
938
|
$item.on('click', '.rcnm-refresh', e => { e.stopPropagation(); emit($item, item) })
|
|
701
939
|
$item.on('click', '.rcnm-freeze', e => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wiki-plugin-rcnmap",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Federated Wiki plugin: a small RCN map on a page that draws points and the ties between them; each point opens its page",
|
|
5
5
|
"keywords": ["wiki", "federated wiki", "plugin", "rcn", "map"],
|
|
6
6
|
"author": "RCN Network <rcn@relocalizecreativity.net>",
|
|
@@ -133,6 +133,16 @@
|
|
|
133
133
|
"text": "Walks. A map made from an RCN Map issue can carry walks: a reading of the map, one step at a time. Press \u25b6 Walk under the map. Each step flies the map to the points and ties it is about, names those points, fades the rest (the ones already visited stay half lit) and reads one or two sentences aloud, shown as a caption too. Space plays or pauses, \u2190 and \u2192 step, Esc stops. Voice on or off and the choice of voice are kept in this browser and shared with the Graph Tool and Timeline walks. To write or change them, press \ud83d\uddfa Open in RCN Map: the full map opens with this map in it, a blue banner names this page, and after \ud83d\udeb6 Walk \u2192 \u270e Edit, \u2b06 Save to wiki brings the walks back into the item as an ordinary edit. Only walks come back; points and ties are edited in the item's text for now. a LINEUP or frozen map plays none, because its points are gathered from other pages.",
|
|
134
134
|
"id": "acad2aaf540683fe"
|
|
135
135
|
},
|
|
136
|
+
{
|
|
137
|
+
"type": "paragraph",
|
|
138
|
+
"id": "b6ab902739e74ee2",
|
|
139
|
+
"text": "Following. Put this page in a lineup beside pages with an RCN timeline, map or drawing, and the items follow each other. Press \u25b6 Walk in any of them: each step lights what it is about there, and the others light what is related to it: full strength for this step, half for earlier steps, the rest faded. Click a point and the timeline lights the bars there, and the drawing their boxes. The others light where it is for them. Click empty space to let go. The timeline's bars are the bridges: each bar names a place on the map (place) and a box in the drawing (eip). One walk plays at a time, and starting one stops the others. A click that lights nothing beside it opens its page as before; beside items that follow, the page opens at the end of the lineup so they stay open, and shift-click always opens it. The full Timeline, Map and Graph Tool, opened from this wiki's assets in another tab, follow too, and lead too."
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
"type": "paragraph",
|
|
143
|
+
"id": "167c2d7ef5bb6a19",
|
|
144
|
+
"text": "Opening the explorer. Give the item a set field naming a set file, for example \"set\": \"superior.set.json\", and it shows a \u29c9 Open together button. The button opens the Time Place Causality Explorer, which puts the timeline, the map and the sketch side by side on one page. A bare file name means the site's /assets/NDC/ folder, where the explorer and the full tools sit; a full address can point to a set anywhere."
|
|
145
|
+
},
|
|
136
146
|
{
|
|
137
147
|
"type": "paragraph",
|
|
138
148
|
"id": "22dca488818d034f",
|
|
@@ -350,6 +360,28 @@
|
|
|
350
360
|
},
|
|
351
361
|
"after": "acad2aaf540683fe",
|
|
352
362
|
"date": 1792642784633
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
"type": "add",
|
|
366
|
+
"id": "b6ab902739e74ee2",
|
|
367
|
+
"item": {
|
|
368
|
+
"type": "paragraph",
|
|
369
|
+
"id": "b6ab902739e74ee2",
|
|
370
|
+
"text": "Following. Put this page in a lineup beside pages with an RCN timeline, map or drawing, and the items follow each other. Press \u25b6 Walk in any of them: each step lights what it is about there, and the others light what is related to it: full strength for this step, half for earlier steps, the rest faded. Click a point and the timeline lights the bars there, and the drawing their boxes. The others light where it is for them. Click empty space to let go. The timeline's bars are the bridges: each bar names a place on the map (place) and a box in the drawing (eip). One walk plays at a time, and starting one stops the others. A click that lights nothing beside it opens its page as before; beside items that follow, the page opens at the end of the lineup so they stay open, and shift-click always opens it. The full Timeline, Map and Graph Tool, opened from this wiki's assets in another tab, follow too, and lead too."
|
|
371
|
+
},
|
|
372
|
+
"after": "acad2aaf540683fe",
|
|
373
|
+
"date": 1794193621097
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
"type": "add",
|
|
377
|
+
"id": "167c2d7ef5bb6a19",
|
|
378
|
+
"item": {
|
|
379
|
+
"type": "paragraph",
|
|
380
|
+
"id": "167c2d7ef5bb6a19",
|
|
381
|
+
"text": "Opening the explorer. Give the item a set field naming a set file, for example \"set\": \"superior.set.json\", and it shows a \u29c9 Open together button. The button opens the Time Place Causality Explorer, which puts the timeline, the map and the sketch side by side on one page. A bare file name means the site's /assets/NDC/ folder, where the explorer and the full tools sit; a full address can point to a set anywhere."
|
|
382
|
+
},
|
|
383
|
+
"after": "b6ab902739e74ee2",
|
|
384
|
+
"date": 1794195627668
|
|
353
385
|
}
|
|
354
386
|
]
|
|
355
387
|
}
|