selflore 0.1.0 → 0.2.0
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/README.md +64 -31
- package/dist/cli.js +81 -19
- package/dist/hooks/user-prompt-submit.js +2 -1
- package/dist/init.js +26 -10
- package/dist/lib/background.js +23 -4
- package/dist/lib/capture-prompt.js +13 -7
- package/dist/lib/commands.js +199 -35
- package/dist/lib/config.js +24 -4
- package/dist/lib/entries.js +56 -4
- package/dist/lib/heat.js +141 -0
- package/dist/lib/hook-logic.js +44 -9
- package/dist/lib/index-cache.js +46 -0
- package/dist/lib/links.js +58 -0
- package/dist/lib/logo.js +6 -0
- package/dist/lib/notes-graph.js +585 -0
- package/dist/lib/notes-html.js +148 -339
- package/dist/lib/notes-page-css.js +279 -0
- package/dist/lib/notes-page-js.js +959 -0
- package/dist/lib/notes.js +19 -13
- package/dist/lib/nudge.js +2 -1
- package/dist/lib/paths.js +6 -0
- package/dist/lib/question.js +19 -0
- package/dist/lib/queue.js +6 -4
- package/dist/lib/recall.js +149 -0
- package/dist/lib/results.js +1 -0
- package/dist/lib/retag.js +150 -0
- package/dist/lib/server-launch.js +73 -0
- package/dist/lib/server.js +120 -0
- package/dist/lib/session.js +1 -1
- package/dist/lib/signals.js +51 -0
- package/dist/lib/stats.js +71 -44
- package/dist/lib/struggle.js +120 -0
- package/dist/lib/surface.js +75 -0
- package/dist/lib/transcript.js +61 -15
- package/dist/lib/ui.js +127 -0
- package/dist/notes-server.js +39 -0
- package/dist/sl.js +29 -4
- package/dist/vendor/graph3d.js +5402 -0
- package/package.json +6 -3
- package/skill/SKILL.md +6 -5
- package/skill/references/capture.md +6 -5
- package/skill/references/recall.md +44 -0
- package/skill/references/stats.md +5 -1
- package/skill/references/test.md +35 -30
|
@@ -0,0 +1,585 @@
|
|
|
1
|
+
// The notes page's map: you → hubs (project | topic | kind) → notes, laid out by a small force
|
|
2
|
+
// simulation and drawn on one canvas. Dot colour and size are heat: slate where things are settled,
|
|
3
|
+
// through amber, to red where the user gets stuck; a hollow grey dot means no signal yet. It is a
|
|
4
|
+
// map, not a grade. This is the flat view; the 3D one (web/graph3d.js) shares the heat scale and
|
|
5
|
+
// the side panel defined here.
|
|
6
|
+
import { DARK_TOKENS } from "./notes-page-css.js";
|
|
7
|
+
export const GRAPH_CSS = String.raw `
|
|
8
|
+
.gwrap { position: relative; height: clamp(420px, calc(100vh - 148px), 760px); background: var(--stage); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
|
|
9
|
+
/* The 3D view always sits on a dark stage: the glow of a stuck note needs it, in either theme. */
|
|
10
|
+
.gwrap.three {${DARK_TOKENS} color: var(--text); }
|
|
11
|
+
.gwrap.three .hdot:not(.none) { background: var(--hd, var(--faint)); }
|
|
12
|
+
.gwrap.three .heatbar { background: var(--gd); }
|
|
13
|
+
.gwrap canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
|
|
14
|
+
.gwrap canvas[hidden], .gwrap .g3d[hidden] { display: none; }
|
|
15
|
+
.gwrap canvas.over { cursor: pointer; }
|
|
16
|
+
.gwrap canvas.drag { cursor: grabbing; }
|
|
17
|
+
.gwrap .g3d { position: absolute; inset: 0; transition: opacity 0.2s ease-out; }
|
|
18
|
+
.gwrap .g3d.settling { opacity: 0; transition: none; }
|
|
19
|
+
.gctl { position: absolute; display: flex; gap: 8px; align-items: center; z-index: 2; }
|
|
20
|
+
.gctl.tl { top: 12px; left: 12px; }
|
|
21
|
+
.gctl.tr { top: 12px; right: 12px; }
|
|
22
|
+
.gctl.br { bottom: 12px; right: 12px; flex-direction: column; gap: 4px; }
|
|
23
|
+
.gctl.bl { bottom: 12px; left: 12px; max-width: calc(100% - 72px); flex-direction: column; align-items: flex-start; gap: 4px; pointer-events: none; padding: 8px 12px; border-radius: 10px; background: color-mix(in srgb, var(--stage) 82%, transparent); }
|
|
24
|
+
.gctl .seg, .gctl .btn, .gctl .chip { background: color-mix(in srgb, var(--surface) 90%, transparent); }
|
|
25
|
+
.gctl .seg button[aria-pressed="true"] { background: var(--accent-soft); }
|
|
26
|
+
.legend { display: flex; gap: 4px 12px; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: 12px; }
|
|
27
|
+
.legend span { display: inline-flex; align-items: center; gap: 8px; }
|
|
28
|
+
.gcap { color: var(--faint); font-size: 12px; }
|
|
29
|
+
.gcap b { color: var(--muted); font-weight: 600; }
|
|
30
|
+
.ghint { position: absolute; left: 12px; right: 12px; top: 56px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; color: var(--muted); font-size: 13px; pointer-events: none; z-index: 2; }
|
|
31
|
+
.ghint button { pointer-events: auto; }
|
|
32
|
+
.gempty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: var(--muted); padding: 24px; }
|
|
33
|
+
.g3labels { overflow: hidden; z-index: 1; }
|
|
34
|
+
.gwrap .float-tooltip-kap { z-index: 2; }
|
|
35
|
+
.hring { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid var(--faint); display: inline-block; flex-shrink: 0; }
|
|
36
|
+
.legend .hdot.none { width: 8px; height: 8px; }
|
|
37
|
+
.g3l { position: absolute; left: 0; top: 0; display: flex; gap: 4px; align-items: center; white-space: nowrap; font-size: 13px; font-weight: 600; color: var(--text); text-shadow: 0 0 3px var(--stage), 0 0 6px var(--stage), 0 1px 2px var(--stage); opacity: 0; transition: opacity 0.15s ease-out; will-change: transform; }
|
|
38
|
+
.g3l.minor { font-weight: 500; color: var(--muted); }
|
|
39
|
+
.g3l .hdot { width: 6px; height: 6px; }
|
|
40
|
+
.g3tip { max-width: 320px; font-size: 13px; line-height: 1.4; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; }
|
|
41
|
+
.gpanel { position: absolute; top: 12px; right: 12px; bottom: 12px; width: min(400px, calc(100% - 24px)); overflow: auto; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 16px; box-shadow: var(--shadow); z-index: 3; }
|
|
42
|
+
.gpanel .phead { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
|
|
43
|
+
.gpanel .phead h2 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; overflow-wrap: anywhere; }
|
|
44
|
+
.gpanel .sub { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
|
|
45
|
+
.gpanel .counts { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: 13px; margin: 0 0 16px; }
|
|
46
|
+
.gpanel .counts dt { display: flex; align-items: center; gap: 8px; color: var(--muted); }
|
|
47
|
+
.gpanel .counts dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
|
|
48
|
+
.gpanel .note { border-top: 0; }
|
|
49
|
+
.gpanel .note > summary { padding-top: 4px; grid-template-columns: 10px minmax(0, 1fr) auto 16px; }
|
|
50
|
+
.gpanel .note .side .p, .gpanel .note .side .d::before { display: none; }
|
|
51
|
+
.gpanel .note .body { padding-left: 4px; }
|
|
52
|
+
.gpanel .related { margin-top: 16px; }
|
|
53
|
+
.gpanel .related button { display: block; width: 100%; text-align: left; font-size: 13px; line-height: 1.45; color: var(--text); background: transparent; border: 0; border-top: 1px solid var(--border); padding: 8px 4px; }
|
|
54
|
+
.gpanel .related button:hover { text-decoration: underline; text-underline-offset: 3px; }
|
|
55
|
+
@media (max-width: 960px) {
|
|
56
|
+
.gwrap { height: min(72vh, 100vw); min-height: 360px; }
|
|
57
|
+
}
|
|
58
|
+
@media (max-width: 640px) {
|
|
59
|
+
.gpanel { top: 56px; left: 12px; right: 12px; width: auto; }
|
|
60
|
+
.gctl.tl .seg button, .gctl.tr .seg button { padding: 0 8px; }
|
|
61
|
+
/* A phone has pinch to zoom; keep only "fit", and the one-line legend. */
|
|
62
|
+
#gzoomin, #gzoomout, .gcap { display: none; }
|
|
63
|
+
}
|
|
64
|
+
`;
|
|
65
|
+
// Plain ES2017, no template literals, like the page script. Defines window.selfloreGraph(opts),
|
|
66
|
+
// plus the heat scale and side panel that the 3D graph reuses.
|
|
67
|
+
export const GRAPH_JS = String.raw `
|
|
68
|
+
// The heat scale: one place for the colours, the bands and the group rule (same as heat.ts).
|
|
69
|
+
// It is warm only, and ordered by brightness as well as hue, so it still ranks without colour
|
|
70
|
+
// vision: on the dark stage hotter is brighter, on a light surface hotter is darker.
|
|
71
|
+
var selfloreHeat = (function () {
|
|
72
|
+
var DARK = [[0, [96, 106, 133]], [0.3, [124, 119, 104]], [0.5, [163, 125, 58]], [0.7, [219, 119, 41]], [1, [255, 106, 70]]];
|
|
73
|
+
var LIGHT = [[0, [135, 145, 165]], [0.3, [148, 138, 110]], [0.5, [169, 122, 34]], [0.7, [198, 90, 24]], [1, [205, 45, 29]]];
|
|
74
|
+
var HOT = 0.7, WARM = 0.5, MIXED = 0.3;
|
|
75
|
+
function rgb(h, light) {
|
|
76
|
+
var stops = light ? LIGHT : DARK;
|
|
77
|
+
h = Math.max(0, Math.min(1, h));
|
|
78
|
+
for (var i = 1; i < stops.length; i++) {
|
|
79
|
+
if (h <= stops[i][0]) {
|
|
80
|
+
var a = stops[i - 1], b = stops[i], t = (h - a[0]) / (b[0] - a[0]);
|
|
81
|
+
return [0, 1, 2].map(function (k) { return Math.round(a[1][k] + (b[1][k] - a[1][k]) * t); });
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return stops[stops.length - 1][1];
|
|
85
|
+
}
|
|
86
|
+
function color(h, alpha, light) { var c = rgb(h, light); return alpha == null ? "rgb(" + c.join(",") + ")" : "rgba(" + c.join(",") + "," + alpha + ")"; }
|
|
87
|
+
function band(h) { return h == null ? "none" : h >= HOT ? "stuck" : h >= WARM ? "warm" : h >= MIXED ? "mixed" : "settled"; }
|
|
88
|
+
// A group leans toward its hottest note, so one real trouble spot shows from a distance.
|
|
89
|
+
function group(values) {
|
|
90
|
+
var known = values.filter(function (v) { return v != null; });
|
|
91
|
+
if (!known.length) return null;
|
|
92
|
+
var sum = 0, max = 0;
|
|
93
|
+
known.forEach(function (v) { sum += v; if (v > max) max = v; });
|
|
94
|
+
return 0.6 * (sum / known.length) + 0.4 * max;
|
|
95
|
+
}
|
|
96
|
+
function gradient(light) { return "linear-gradient(90deg, " + [0, 0.15, 0.3, 0.5, 0.7, 0.85, 1].map(function (v) { return color(v, null, light); }).join(", ") + ")"; }
|
|
97
|
+
function lightTheme() {
|
|
98
|
+
if (document.documentElement.getAttribute("data-theme") === "light") return true;
|
|
99
|
+
return !(window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches);
|
|
100
|
+
}
|
|
101
|
+
/** A heat dot for the page: both colour sets ride along, and the stylesheet picks one. */
|
|
102
|
+
function dot(h, heat) {
|
|
103
|
+
var i = h("i", { class: "hdot" + (heat == null ? " none" : ""), "aria-hidden": "true" });
|
|
104
|
+
if (heat != null) { i.style.setProperty("--hd", color(heat)); i.style.setProperty("--hl", color(heat, null, true)); }
|
|
105
|
+
return i;
|
|
106
|
+
}
|
|
107
|
+
return { HOT: HOT, WARM: WARM, MIXED: MIXED, rgb: rgb, color: color, band: band, group: group, gradient: gradient, lightTheme: lightTheme, dot: dot,
|
|
108
|
+
BANDS: [["stuck", "Stuck", 0.92], ["warm", "Warm", 0.6], ["mixed", "Mostly settled", 0.4], ["settled", "Settled", 0.08], ["none", "No signal yet", null]] };
|
|
109
|
+
})();
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Fill the side panel for a selected node. Shared by the flat and the 3D graph.
|
|
113
|
+
* node: { type: "entry", e, related: [entry…] } or { type: "hub", key, label, group, entries: [entry…] }
|
|
114
|
+
* api: { close(), selectEntry(id) }
|
|
115
|
+
*/
|
|
116
|
+
function selfloreGraphPanel(opts, panel, node, api) {
|
|
117
|
+
var h = opts.h;
|
|
118
|
+
panel.textContent = ""; panel.hidden = false;
|
|
119
|
+
function head(title) {
|
|
120
|
+
return h("div", { class: "phead" }, h("h2", { text: title }), h("button", { class: "btn quiet icon", "aria-label": "Close", onclick: api.close }, opts.icon("x")));
|
|
121
|
+
}
|
|
122
|
+
function related(title, list) {
|
|
123
|
+
var box = h("div", { class: "related" }, h("div", { class: "label", text: title }));
|
|
124
|
+
list.forEach(function (m) { var b = h("button", { onclick: function () { api.selectEntry(m.id); } }); opts.rich(b, m.testable); box.appendChild(b); });
|
|
125
|
+
return box;
|
|
126
|
+
}
|
|
127
|
+
if (node.type === "entry") {
|
|
128
|
+
panel.appendChild(head("Note"));
|
|
129
|
+
panel.appendChild(opts.card(node.e));
|
|
130
|
+
if (node.related && node.related.length) panel.appendChild(related("Related", node.related));
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
var list = node.entries, total = list.length, counts = { stuck: 0, warm: 0, mixed: 0, settled: 0, none: 0 };
|
|
134
|
+
list.forEach(function (e) { counts[selfloreHeat.band(e.heat)]++; });
|
|
135
|
+
panel.appendChild(head(node.label));
|
|
136
|
+
panel.appendChild(h("p", { class: "sub", text: total + (total === 1 ? " note" : " notes") + (counts.stuck ? " · you get stuck on " + counts.stuck : "") }));
|
|
137
|
+
var dl = h("dl", { class: "counts" });
|
|
138
|
+
selfloreHeat.BANDS.forEach(function (row) {
|
|
139
|
+
if (!counts[row[0]]) return;
|
|
140
|
+
dl.appendChild(h("dt", null, selfloreHeat.dot(h, row[2]), row[1]));
|
|
141
|
+
dl.appendChild(h("dd", { text: String(counts[row[0]]) }));
|
|
142
|
+
});
|
|
143
|
+
panel.appendChild(dl);
|
|
144
|
+
var actions = h("div", { class: "actions" });
|
|
145
|
+
var scope = node.group === "project" ? { project: node.key } : node.group === "skill" ? { skill: node.key } : null;
|
|
146
|
+
var n = scope && opts.canTest ? opts.clusterCount(scope) : 0;
|
|
147
|
+
if (n) actions.appendChild(h("button", { class: "btn primary", text: "Test me · " + (n === 1 ? "1 question" : n + " questions"), onclick: function () { opts.onTest(scope); } }));
|
|
148
|
+
actions.appendChild(h("button", { class: "btn", text: "Show in Notes", onclick: function () { opts.onFilter(node.group, node.key); } }));
|
|
149
|
+
panel.appendChild(actions);
|
|
150
|
+
if (scope && opts.canTest && !n) panel.appendChild(h("p", { class: "sub", text: "Nothing to test here right now: everything has been asked and passed." }));
|
|
151
|
+
var hottest = list.filter(function (e) { return e.heat != null && e.heat >= selfloreHeat.WARM; }).sort(function (a, b) { return b.heat - a.heat; }).slice(0, 4);
|
|
152
|
+
if (hottest.length) panel.appendChild(related("Hottest here", hottest));
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function selfloreGraph(opts) {
|
|
156
|
+
var h = opts.h;
|
|
157
|
+
var wrap = opts.wrap, canvas = opts.canvas, panel = opts.panel, emptyEl = opts.empty;
|
|
158
|
+
var ctx = canvas.getContext("2d");
|
|
159
|
+
var FONT = "ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif";
|
|
160
|
+
|
|
161
|
+
// ---- simulation constants (tuned for dots, not cards) ----
|
|
162
|
+
var REPULSION = 900, GRAVITY = 0.012, DAMPING = 0.82, ALPHA_DECAY = 0.985, ALPHA_MIN = 0.02;
|
|
163
|
+
var SPRING_ROOT = 0.03, SPRING_HUB = 0.05, SPRING_LINK = 0.012, REST_LINK = 46, COLLIDE_PAD = 3;
|
|
164
|
+
var CHARGE = { root: 5, hub: 6, entry: 1 }; // hubs push each other hard: their labels need the room
|
|
165
|
+
|
|
166
|
+
var nodes = [], edges = [], byId = {}, adj = {}, hubs = [], named = {}, root = null;
|
|
167
|
+
var signature = "", group = "project";
|
|
168
|
+
var alpha = 0, running = false, anim = null;
|
|
169
|
+
var touched = false; // the user panned, zoomed or dragged: stop auto-fitting until the data changes
|
|
170
|
+
var labelsOn = true;
|
|
171
|
+
var view = { x: 0, y: 0, k: 1 };
|
|
172
|
+
var width = 0, height = 0, dpr = 1;
|
|
173
|
+
var hover = null, selected = null, drag = null, panning = false, moved = false, last = { x: 0, y: 0 };
|
|
174
|
+
var colors = {}, light = false;
|
|
175
|
+
|
|
176
|
+
function cssVar(name) { return getComputedStyle(wrap).getPropertyValue(name).trim(); }
|
|
177
|
+
function readColors() {
|
|
178
|
+
["--stage", "--text", "--muted", "--faint", "--border", "--border-strong", "--accent"].forEach(function (v) { colors[v] = cssVar(v) || "#888"; });
|
|
179
|
+
light = selfloreHeat.lightTheme();
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function hubRadius(n) { return 6 + Math.min(8, Math.sqrt(n) * 1.4); }
|
|
183
|
+
|
|
184
|
+
/** Rebuild the graph for a set of entries. Nodes that survive keep their positions. */
|
|
185
|
+
function setData(entries, mode) {
|
|
186
|
+
var list = entries.filter(function (e) { return e.status !== "suppressed"; });
|
|
187
|
+
readColors();
|
|
188
|
+
var sig = mode + "|" + list.map(function (e) { return e.id; }).join(",");
|
|
189
|
+
if (sig === signature) { list.forEach(function (e) { if (byId[e.id]) byId[e.id].e = e; }); tally(); draw(); return; }
|
|
190
|
+
var old = byId, regroup = mode !== group;
|
|
191
|
+
signature = sig; group = mode;
|
|
192
|
+
nodes = []; edges = []; byId = {}; adj = {}; hubs = [];
|
|
193
|
+
hover = null; drag = null;
|
|
194
|
+
if (selected && (selected.type !== "entry" || !list.some(function (e) { return e.id === selected.id; }))) closePanel();
|
|
195
|
+
|
|
196
|
+
emptyEl.hidden = list.length > 0;
|
|
197
|
+
root = { id: "__root__", type: "root", label: "you", x: 0, y: 0, vx: 0, vy: 0, r: 7, pinned: true };
|
|
198
|
+
nodes.push(root);
|
|
199
|
+
if (!list.length) { alpha = 0; draw(); return; }
|
|
200
|
+
|
|
201
|
+
var buckets = {}, order = [];
|
|
202
|
+
list.forEach(function (e) {
|
|
203
|
+
var key = e[mode] || "(none)";
|
|
204
|
+
if (!buckets[key]) { buckets[key] = []; order.push(key); }
|
|
205
|
+
buckets[key].push(e);
|
|
206
|
+
});
|
|
207
|
+
order.sort(function (a, b) { return buckets[b].length - buckets[a].length || (a < b ? -1 : 1); });
|
|
208
|
+
var restRoot = 150 + 11 * Math.sqrt(list.length);
|
|
209
|
+
var kept = 0;
|
|
210
|
+
|
|
211
|
+
order.forEach(function (key, i) {
|
|
212
|
+
var kids = buckets[key];
|
|
213
|
+
var ang = (i / order.length) * Math.PI * 2 - Math.PI / 2;
|
|
214
|
+
var prev = !regroup && old["hub:" + key];
|
|
215
|
+
var hub = {
|
|
216
|
+
id: "hub:" + key, type: "hub", key: key, label: key, leaves: [], r: hubRadius(kids.length),
|
|
217
|
+
x: prev ? prev.x : Math.cos(ang) * restRoot, y: prev ? prev.y : Math.sin(ang) * restRoot, vx: 0, vy: 0,
|
|
218
|
+
};
|
|
219
|
+
nodes.push(hub); hubs.push(hub); byId[hub.id] = hub;
|
|
220
|
+
edges.push({ a: root, b: hub, rest: restRoot, k: SPRING_ROOT, link: false });
|
|
221
|
+
var restHub = 34 + 7 * Math.sqrt(kids.length);
|
|
222
|
+
kids.forEach(function (e, c) {
|
|
223
|
+
var p = !regroup && old[e.id];
|
|
224
|
+
if (p) kept++;
|
|
225
|
+
// Fan new entries out behind their hub so the simulation starts untangled.
|
|
226
|
+
var a2 = ang + (c - (kids.length - 1) / 2) * (2.4 / Math.max(6, kids.length));
|
|
227
|
+
var leaf = {
|
|
228
|
+
id: e.id, type: "entry", e: e, hub: hub, r: 5,
|
|
229
|
+
x: p ? p.x : hub.x + Math.cos(a2) * restHub, y: p ? p.y : hub.y + Math.sin(a2) * restHub, vx: 0, vy: 0,
|
|
230
|
+
};
|
|
231
|
+
nodes.push(leaf); byId[e.id] = leaf; hub.leaves.push(leaf);
|
|
232
|
+
edges.push({ a: hub, b: leaf, rest: restHub, k: SPRING_HUB, link: false });
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
opts.links.forEach(function (l) {
|
|
237
|
+
var a = byId[l[0]], b = byId[l[1]];
|
|
238
|
+
if (!a || !b) return;
|
|
239
|
+
edges.push({ a: a, b: b, rest: REST_LINK, k: SPRING_LINK, link: true });
|
|
240
|
+
(adj[a.id] = adj[a.id] || {})[b.id] = true;
|
|
241
|
+
(adj[b.id] = adj[b.id] || {})[a.id] = true;
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
tally();
|
|
245
|
+
touched = false;
|
|
246
|
+
if (kept < list.length * 0.6) {
|
|
247
|
+
// A new layout: settle it out of sight and fit once, so the first thing drawn is the finished map.
|
|
248
|
+
alpha = 1;
|
|
249
|
+
for (var t = 0; t < 320 && alpha >= ALPHA_MIN; t++) tick();
|
|
250
|
+
fit(true);
|
|
251
|
+
} else {
|
|
252
|
+
// Mostly the same notes (a filter changed): settle gently, then fit.
|
|
253
|
+
alpha = 0.4;
|
|
254
|
+
kick();
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/** Hub heat, and the few hottest notes that get their name on the map. */
|
|
259
|
+
function tally() {
|
|
260
|
+
hubs.forEach(function (hub) { hub.heat = selfloreHeat.group(hub.leaves.map(function (n) { return n.e.heat; })); });
|
|
261
|
+
named = {};
|
|
262
|
+
nodes.filter(function (n) { return n.type === "entry" && n.e.heat != null && n.e.heat >= selfloreHeat.HOT; })
|
|
263
|
+
.sort(function (a, b) { return b.e.heat - a.e.heat || (a.id < b.id ? -1 : 1); }).slice(0, 4)
|
|
264
|
+
.forEach(function (n, i) { named[n.id] = i + 1; });
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
function tick() {
|
|
268
|
+
var i, j, n, m, dx, dy, d2, d, f, count = nodes.length;
|
|
269
|
+
for (i = 0; i < count; i++) {
|
|
270
|
+
n = nodes[i];
|
|
271
|
+
for (j = i + 1; j < count; j++) {
|
|
272
|
+
m = nodes[j];
|
|
273
|
+
dx = m.x - n.x; dy = m.y - n.y;
|
|
274
|
+
d2 = dx * dx + dy * dy;
|
|
275
|
+
if (d2 > 360000) continue; // beyond 600px: negligible
|
|
276
|
+
if (d2 < 16) { d2 = 16; dx = dx || (i % 2 ? 1 : -1); dy = dy || (j % 2 ? 1 : -1); }
|
|
277
|
+
d = Math.sqrt(d2);
|
|
278
|
+
f = (REPULSION * CHARGE[n.type] * CHARGE[m.type] / d2) * alpha;
|
|
279
|
+
var ux = dx / d, uy = dy / d;
|
|
280
|
+
n.vx -= ux * f; n.vy -= uy * f;
|
|
281
|
+
m.vx += ux * f; m.vy += uy * f;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
for (i = 0; i < edges.length; i++) {
|
|
285
|
+
var e = edges[i];
|
|
286
|
+
dx = e.b.x - e.a.x; dy = e.b.y - e.a.y;
|
|
287
|
+
d = Math.sqrt(dx * dx + dy * dy) || 1;
|
|
288
|
+
f = (d - e.rest) * e.k * alpha;
|
|
289
|
+
var sx = (dx / d) * f, sy = (dy / d) * f;
|
|
290
|
+
e.a.vx += sx; e.a.vy += sy;
|
|
291
|
+
e.b.vx -= sx; e.b.vy -= sy;
|
|
292
|
+
}
|
|
293
|
+
for (i = 0; i < count; i++) {
|
|
294
|
+
n = nodes[i];
|
|
295
|
+
if (n.pinned || n === drag) { n.vx = 0; n.vy = 0; continue; }
|
|
296
|
+
n.vx = (n.vx - n.x * GRAVITY * alpha) * DAMPING;
|
|
297
|
+
n.vy = (n.vy - n.y * GRAVITY * alpha) * DAMPING;
|
|
298
|
+
n.x += n.vx; n.y += n.vy;
|
|
299
|
+
}
|
|
300
|
+
// Circle collision: dots never sit on top of each other.
|
|
301
|
+
for (i = 0; i < count; i++) {
|
|
302
|
+
n = nodes[i];
|
|
303
|
+
for (j = i + 1; j < count; j++) {
|
|
304
|
+
m = nodes[j];
|
|
305
|
+
dx = m.x - n.x; dy = m.y - n.y;
|
|
306
|
+
var min = n.r + m.r + COLLIDE_PAD;
|
|
307
|
+
d2 = dx * dx + dy * dy;
|
|
308
|
+
if (d2 >= min * min) continue;
|
|
309
|
+
d = Math.sqrt(d2) || 0.01;
|
|
310
|
+
var push = (min - d) / d, nf = !(n.pinned || n === drag), mf = !(m.pinned || m === drag);
|
|
311
|
+
if (nf && mf) { n.x -= dx * push / 2; n.y -= dy * push / 2; m.x += dx * push / 2; m.y += dy * push / 2; }
|
|
312
|
+
else if (nf) { n.x -= dx * push; n.y -= dy * push; }
|
|
313
|
+
else if (mf) { m.x += dx * push; m.y += dy * push; }
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
alpha *= ALPHA_DECAY;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// ---- drawing (screen space, so text stays one size at any zoom) ----
|
|
320
|
+
function sx(n) { return n.x * view.k + view.x; }
|
|
321
|
+
function sy(n) { return n.y * view.k + view.y; }
|
|
322
|
+
function sr(n) { return Math.max(n.type === "entry" ? 2.5 : 5, n.r * Math.min(2.2, Math.max(0.55, view.k))); }
|
|
323
|
+
/** A note's drawn radius: size repeats what colour says, so the map reads without colour vision. */
|
|
324
|
+
function er(n) { var ht = n.e.heat; return sr(n) * (ht == null ? 0.7 : 0.8 + ht * 0.7); }
|
|
325
|
+
|
|
326
|
+
function lit() {
|
|
327
|
+
// The node under the pointer (or the selected one) plus its neighbourhood.
|
|
328
|
+
var focus = hover || selected;
|
|
329
|
+
if (!focus) return null;
|
|
330
|
+
var on = {};
|
|
331
|
+
on[focus.id] = true;
|
|
332
|
+
if (focus.type === "hub") focus.leaves.forEach(function (n) { on[n.id] = true; });
|
|
333
|
+
else if (focus.type === "entry") { on[focus.hub.id] = true; for (var id in adj[focus.id] || {}) on[id] = true; }
|
|
334
|
+
else return null;
|
|
335
|
+
return on;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
function truncate(s, n) { return s.length > n ? s.slice(0, n - 1) + "…" : s; }
|
|
339
|
+
|
|
340
|
+
/** Draw the labels that fit, most important first: a label never lands on another one. */
|
|
341
|
+
function drawLabels(list) {
|
|
342
|
+
var placed = [];
|
|
343
|
+
list.sort(function (a, b) { return a.rank - b.rank; }).forEach(function (l) {
|
|
344
|
+
ctx.font = (l.strong ? "600 12px " : "12px ") + FONT;
|
|
345
|
+
var w = ctx.measureText(l.text).width + (l.heat === undefined ? 0 : 12);
|
|
346
|
+
var box = { x: l.x - w / 2 - 4, y: l.y - 2, w: w + 8, h: 18 };
|
|
347
|
+
var clash = l.rank > 0 && placed.some(function (p) { return box.x < p.x + p.w && p.x < box.x + box.w && box.y < p.y + p.h && p.y < box.y + box.h; });
|
|
348
|
+
if (clash) return;
|
|
349
|
+
placed.push(box);
|
|
350
|
+
ctx.globalAlpha = l.alpha * 0.88;
|
|
351
|
+
ctx.fillStyle = colors["--stage"];
|
|
352
|
+
ctx.fillRect(box.x, box.y, box.w, box.h);
|
|
353
|
+
ctx.globalAlpha = l.alpha;
|
|
354
|
+
var tx = l.x - w / 2;
|
|
355
|
+
if (l.heat !== undefined) {
|
|
356
|
+
ctx.beginPath(); ctx.arc(tx + 3, l.y + 7, 3, 0, Math.PI * 2);
|
|
357
|
+
if (l.heat == null) { ctx.lineWidth = 1.2; ctx.strokeStyle = colors["--faint"]; ctx.stroke(); }
|
|
358
|
+
else { ctx.fillStyle = selfloreHeat.color(l.heat, null, light); ctx.fill(); }
|
|
359
|
+
tx += 12;
|
|
360
|
+
}
|
|
361
|
+
ctx.fillStyle = l.strong ? colors["--text"] : colors["--muted"];
|
|
362
|
+
ctx.textAlign = "left"; ctx.textBaseline = "top";
|
|
363
|
+
ctx.fillText(l.text, tx, l.y);
|
|
364
|
+
});
|
|
365
|
+
ctx.globalAlpha = 1;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
function draw() {
|
|
369
|
+
if (!width) return;
|
|
370
|
+
ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
|
|
371
|
+
ctx.clearRect(0, 0, width, height);
|
|
372
|
+
var on = lit(), i, n;
|
|
373
|
+
// Naming every dot of a 40-note hub is noise; name neighbours only when a note has the focus.
|
|
374
|
+
var nameLit = on && (hover || selected).type === "entry";
|
|
375
|
+
|
|
376
|
+
for (i = 0; i < edges.length; i++) {
|
|
377
|
+
var e = edges[i];
|
|
378
|
+
var hot = on && on[e.a.id] && on[e.b.id];
|
|
379
|
+
// The links between related notes only show around the note in focus: all at once they are a web.
|
|
380
|
+
if (e.link && !hot) continue;
|
|
381
|
+
ctx.beginPath();
|
|
382
|
+
ctx.setLineDash(e.link ? [4, 4] : []);
|
|
383
|
+
ctx.moveTo(sx(e.a), sy(e.a)); ctx.lineTo(sx(e.b), sy(e.b));
|
|
384
|
+
ctx.lineWidth = hot ? 1.6 : 1;
|
|
385
|
+
ctx.strokeStyle = hot ? colors["--accent"] : colors["--border-strong"];
|
|
386
|
+
ctx.globalAlpha = on && !hot ? 0.3 : 1;
|
|
387
|
+
ctx.stroke();
|
|
388
|
+
}
|
|
389
|
+
ctx.setLineDash([]);
|
|
390
|
+
|
|
391
|
+
for (i = 0; i < nodes.length; i++) {
|
|
392
|
+
n = nodes[i];
|
|
393
|
+
var x = sx(n), y = sy(n), r = sr(n);
|
|
394
|
+
ctx.globalAlpha = on && !on[n.id] && n !== root ? 0.22 : 1;
|
|
395
|
+
if (n.type === "entry") {
|
|
396
|
+
var ht = n.e.heat;
|
|
397
|
+
r = er(n);
|
|
398
|
+
if (ht == null) {
|
|
399
|
+
// No signal: a small hollow ring.
|
|
400
|
+
ctx.beginPath(); ctx.arc(x, y, r, 0, Math.PI * 2);
|
|
401
|
+
ctx.fillStyle = colors["--stage"]; ctx.fill();
|
|
402
|
+
ctx.lineWidth = 1.4; ctx.strokeStyle = colors["--faint"]; ctx.stroke();
|
|
403
|
+
} else {
|
|
404
|
+
// Only a stuck note gets a halo.
|
|
405
|
+
if (ht >= selfloreHeat.HOT) { ctx.beginPath(); ctx.arc(x, y, r + 5, 0, Math.PI * 2); ctx.fillStyle = selfloreHeat.color(ht, 0.24, light); ctx.fill(); }
|
|
406
|
+
ctx.beginPath(); ctx.arc(x, y, r, 0, Math.PI * 2);
|
|
407
|
+
ctx.fillStyle = selfloreHeat.color(ht, null, light); ctx.fill();
|
|
408
|
+
ctx.lineWidth = 1.5; ctx.strokeStyle = colors["--stage"]; ctx.stroke();
|
|
409
|
+
}
|
|
410
|
+
if (n === selected || n === hover) { ctx.beginPath(); ctx.arc(x, y, r + 3.5, 0, Math.PI * 2); ctx.lineWidth = 2; ctx.strokeStyle = colors["--text"]; ctx.stroke(); }
|
|
411
|
+
} else {
|
|
412
|
+
// Hubs are neutral rings: colour belongs to the notes. A hub's own heat is the dot in its label.
|
|
413
|
+
ctx.beginPath(); ctx.arc(x, y, r, 0, Math.PI * 2);
|
|
414
|
+
ctx.fillStyle = n.type === "root" ? colors["--text"] : colors["--stage"]; ctx.fill();
|
|
415
|
+
if (n.type === "hub") { ctx.lineWidth = 1.5; ctx.strokeStyle = colors["--faint"]; ctx.stroke(); }
|
|
416
|
+
if (n === selected || n === hover) { ctx.beginPath(); ctx.arc(x, y, r + 4, 0, Math.PI * 2); ctx.lineWidth = 2; ctx.strokeStyle = colors["--text"]; ctx.stroke(); }
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
// Labels: hubs and the hottest notes always, other notes when zoomed in or lit.
|
|
421
|
+
var labels = [];
|
|
422
|
+
for (i = 0; i < nodes.length; i++) {
|
|
423
|
+
n = nodes[i];
|
|
424
|
+
var dim = on && !on[n.id] && n !== root;
|
|
425
|
+
var focus = n === hover || n === selected;
|
|
426
|
+
if (n.type === "entry") {
|
|
427
|
+
var show = focus || (!dim && labelsOn && (named[n.id] || view.k >= 1.7 || (nameLit && on[n.id])));
|
|
428
|
+
if (!show) continue;
|
|
429
|
+
labels.push({ text: truncate(n.e.testable, focus ? 72 : 38), x: sx(n), y: sy(n) + er(n) + 6, strong: focus, alpha: 1, rank: focus ? 0 : named[n.id] ? 200 + named[n.id] : 400 });
|
|
430
|
+
} else {
|
|
431
|
+
if (!labelsOn && !focus) continue;
|
|
432
|
+
labels.push({
|
|
433
|
+
text: n.type === "hub" ? truncate(n.label, 30) + " · " + n.leaves.length : n.label, x: sx(n), y: sy(n) + sr(n) + 6, strong: true,
|
|
434
|
+
heat: n.type === "hub" ? n.heat : undefined, alpha: dim ? 0.3 : 1, rank: focus ? 0 : n.type === "root" ? 1 : 100 - Math.min(90, n.leaves.length),
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
drawLabels(labels);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
function frame() {
|
|
442
|
+
if (alpha >= ALPHA_MIN) {
|
|
443
|
+
tick();
|
|
444
|
+
if (alpha < ALPHA_MIN && !touched) fit(false);
|
|
445
|
+
}
|
|
446
|
+
if (anim) anim();
|
|
447
|
+
draw();
|
|
448
|
+
if (alpha >= ALPHA_MIN || anim || drag) requestAnimationFrame(frame);
|
|
449
|
+
else running = false;
|
|
450
|
+
}
|
|
451
|
+
function kick() { if (!running && width) { running = true; requestAnimationFrame(frame); } }
|
|
452
|
+
|
|
453
|
+
// ---- view ----
|
|
454
|
+
function clamp(v, a, b) { return Math.max(a, Math.min(b, v)); }
|
|
455
|
+
function animateTo(tx, ty, tk) {
|
|
456
|
+
var s = { x: view.x, y: view.y, k: view.k }, t0 = performance.now();
|
|
457
|
+
anim = function () {
|
|
458
|
+
var t = Math.min(1, (performance.now() - t0) / 400);
|
|
459
|
+
var e = 1 - Math.pow(1 - t, 4);
|
|
460
|
+
view.x = s.x + (tx - s.x) * e; view.y = s.y + (ty - s.y) * e; view.k = s.k + (tk - s.k) * e;
|
|
461
|
+
if (t >= 1) anim = null;
|
|
462
|
+
};
|
|
463
|
+
kick();
|
|
464
|
+
}
|
|
465
|
+
/** Frame every node, leaving room for the controls in the corners and the labels under the hubs. */
|
|
466
|
+
function fit(now) {
|
|
467
|
+
if (!width) return;
|
|
468
|
+
if (nodes.length < 2) { view = { x: width / 2, y: height / 2, k: 1 }; draw(); return; }
|
|
469
|
+
var minX = Infinity, maxX = -Infinity, minY = Infinity, maxY = -Infinity;
|
|
470
|
+
nodes.forEach(function (n) {
|
|
471
|
+
minX = Math.min(minX, n.x - n.r); maxX = Math.max(maxX, n.x + n.r);
|
|
472
|
+
minY = Math.min(minY, n.y - n.r); maxY = Math.max(maxY, n.y + n.r);
|
|
473
|
+
});
|
|
474
|
+
var padX = 56, top = 60, bottom = 84;
|
|
475
|
+
var k = clamp(Math.min((width - padX * 2) / Math.max(1, maxX - minX), (height - top - bottom) / Math.max(1, maxY - minY)), 0.15, 1.6);
|
|
476
|
+
var tx = width / 2 - ((minX + maxX) / 2) * k, ty = top + (height - top - bottom) / 2 - ((minY + maxY) / 2) * k;
|
|
477
|
+
if (now) { anim = null; view = { x: tx, y: ty, k: k }; draw(); } else animateTo(tx, ty, k);
|
|
478
|
+
}
|
|
479
|
+
function zoomBy(factor, cx, cy) {
|
|
480
|
+
var k = clamp(view.k * factor, 0.15, 4);
|
|
481
|
+
view.x = cx - (cx - view.x) * (k / view.k);
|
|
482
|
+
view.y = cy - (cy - view.y) * (k / view.k);
|
|
483
|
+
view.k = k;
|
|
484
|
+
draw();
|
|
485
|
+
}
|
|
486
|
+
function resize() {
|
|
487
|
+
var w = wrap.clientWidth, hh = wrap.clientHeight;
|
|
488
|
+
if (!w || !hh) return;
|
|
489
|
+
var first = !width, same = w === width && hh === height;
|
|
490
|
+
dpr = window.devicePixelRatio || 1;
|
|
491
|
+
width = w; height = hh;
|
|
492
|
+
canvas.width = Math.round(w * dpr); canvas.height = Math.round(hh * dpr);
|
|
493
|
+
if (first || (!same && !touched)) fit(true);
|
|
494
|
+
draw(); kick();
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
// ---- pointer ----
|
|
498
|
+
function at(ev) { var b = canvas.getBoundingClientRect(); return { x: ev.clientX - b.left, y: ev.clientY - b.top }; }
|
|
499
|
+
function hit(p) {
|
|
500
|
+
var best = null, bestD = Infinity;
|
|
501
|
+
for (var i = 0; i < nodes.length; i++) {
|
|
502
|
+
var n = nodes[i];
|
|
503
|
+
if (n.type === "root") continue;
|
|
504
|
+
var dx = sx(n) - p.x, dy = sy(n) - p.y;
|
|
505
|
+
var d = Math.sqrt(dx * dx + dy * dy) - sr(n);
|
|
506
|
+
if (d < 7 && d < bestD) { best = n; bestD = d; }
|
|
507
|
+
}
|
|
508
|
+
return best;
|
|
509
|
+
}
|
|
510
|
+
canvas.addEventListener("pointerdown", function (ev) {
|
|
511
|
+
var p = at(ev), n = hit(p);
|
|
512
|
+
moved = false; last = p;
|
|
513
|
+
if (n) drag = n; else panning = true;
|
|
514
|
+
canvas.setPointerCapture(ev.pointerId);
|
|
515
|
+
canvas.classList.add("drag");
|
|
516
|
+
});
|
|
517
|
+
canvas.addEventListener("pointermove", function (ev) {
|
|
518
|
+
var p = at(ev);
|
|
519
|
+
if (drag || panning) {
|
|
520
|
+
var dx = p.x - last.x, dy = p.y - last.y;
|
|
521
|
+
if (Math.abs(dx) + Math.abs(dy) > 2) moved = true;
|
|
522
|
+
if (!moved) return;
|
|
523
|
+
last = p;
|
|
524
|
+
touched = true;
|
|
525
|
+
if (drag) { drag.x += dx / view.k; drag.y += dy / view.k; alpha = Math.max(alpha, 0.3); kick(); }
|
|
526
|
+
else { view.x += dx; view.y += dy; draw(); }
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
529
|
+
var n = hit(p);
|
|
530
|
+
if (n !== hover) { hover = n; canvas.classList.toggle("over", !!n); draw(); }
|
|
531
|
+
});
|
|
532
|
+
function release(ev) {
|
|
533
|
+
var was = drag;
|
|
534
|
+
canvas.classList.remove("drag");
|
|
535
|
+
drag = null; panning = false;
|
|
536
|
+
if (ev.type === "pointercancel" || moved) return;
|
|
537
|
+
if (was) select(was); else closePanel();
|
|
538
|
+
}
|
|
539
|
+
canvas.addEventListener("pointerup", release);
|
|
540
|
+
canvas.addEventListener("pointercancel", release);
|
|
541
|
+
canvas.addEventListener("pointerleave", function () { if (hover && !drag) { hover = null; canvas.classList.remove("over"); draw(); } });
|
|
542
|
+
// Plain wheel scrolls the page; pinch (ctrl) or ⌘/alt + wheel zooms, so the canvas never traps scrolling.
|
|
543
|
+
canvas.addEventListener("wheel", function (ev) {
|
|
544
|
+
if (!(ev.ctrlKey || ev.metaKey || ev.altKey)) return;
|
|
545
|
+
ev.preventDefault();
|
|
546
|
+
touched = true;
|
|
547
|
+
var p = at(ev);
|
|
548
|
+
zoomBy(Math.pow(2, -ev.deltaY * (ev.ctrlKey ? 0.02 : 0.004)), p.x, p.y);
|
|
549
|
+
}, { passive: false });
|
|
550
|
+
|
|
551
|
+
// ---- side panel ----
|
|
552
|
+
function closePanel() { selected = null; panel.hidden = true; panel.textContent = ""; draw(); }
|
|
553
|
+
function select(n) {
|
|
554
|
+
selected = n;
|
|
555
|
+
var api = { close: closePanel, selectEntry: function (id) { if (byId[id]) select(byId[id]); } };
|
|
556
|
+
if (n.type === "entry") {
|
|
557
|
+
var near = Object.keys(adj[n.id] || {}).map(function (id) { return byId[id]; }).filter(Boolean).map(function (m) { return m.e; });
|
|
558
|
+
selfloreGraphPanel(opts, panel, { type: "entry", e: n.e, related: near }, api);
|
|
559
|
+
} else {
|
|
560
|
+
selfloreGraphPanel(opts, panel, { type: "hub", key: n.key, label: n.label, group: group, entries: n.leaves.map(function (l) { return l.e; }) }, api);
|
|
561
|
+
}
|
|
562
|
+
// Keep the selected node in the part of the canvas the panel doesn't cover.
|
|
563
|
+
var free = width - panel.offsetWidth - 24;
|
|
564
|
+
if (panel.offsetWidth < width * 0.7 && sx(n) > free - 40) animateTo(view.x - (sx(n) - free / 2), view.y, view.k);
|
|
565
|
+
draw();
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
if (window.ResizeObserver) new ResizeObserver(resize).observe(wrap); else window.addEventListener("resize", resize);
|
|
569
|
+
if (window.matchMedia) {
|
|
570
|
+
var mq = window.matchMedia("(prefers-color-scheme: dark)");
|
|
571
|
+
var recolor = function () { readColors(); draw(); };
|
|
572
|
+
if (mq.addEventListener) mq.addEventListener("change", recolor); else if (mq.addListener) mq.addListener(recolor);
|
|
573
|
+
}
|
|
574
|
+
readColors();
|
|
575
|
+
|
|
576
|
+
return {
|
|
577
|
+
setData: setData, resize: resize, closePanel: closePanel, hasPanel: function () { return !panel.hidden; },
|
|
578
|
+
zoom: function (factor) { touched = true; zoomBy(factor, width / 2, height / 2); },
|
|
579
|
+
fit: function () { touched = false; fit(false); },
|
|
580
|
+
setLabels: function (on) { labelsOn = !!on; draw(); },
|
|
581
|
+
/** Open a note by id, or the hub with this key, if it is on the map. */
|
|
582
|
+
focus: function (id) { var n = byId[id] || byId["hub:" + id]; if (n) select(n); return !!n; },
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
`;
|