SupPepper commited on
Commit ·
d09ba91
1
Parent(s): b4fea55
Update index.html
Browse files- frontend/index.html +41 -21
frontend/index.html
CHANGED
|
@@ -664,28 +664,48 @@ function renderRelations() {
|
|
| 664 |
// --- section 2: NPC↔NPC bond graph + directed list ---
|
| 665 |
let graphHtml = "";
|
| 666 |
if (knownChars.length >= 2) {
|
| 667 |
-
// Group bonds by unordered pair
|
| 668 |
-
const
|
| 669 |
-
for (const b of npcBonds) {
|
| 670 |
-
|
| 671 |
-
|
| 672 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 673 |
}
|
| 674 |
-
|
| 675 |
-
|
| 676 |
-
|
| 677 |
-
|
| 678 |
-
|
| 679 |
-
|
| 680 |
-
|
| 681 |
-
|
| 682 |
-
|
| 683 |
-
|
| 684 |
-
|
| 685 |
-
</
|
| 686 |
-
|
| 687 |
-
|
| 688 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 689 |
|
| 690 |
graphHtml = `<div class="rel-section-title">Between them</div>
|
| 691 |
<div class="bond-graph-wrap">${_buildBondGraph(knownChars, npcBonds)}</div>
|
|
|
|
| 664 |
// --- section 2: NPC↔NPC bond graph + directed list ---
|
| 665 |
let graphHtml = "";
|
| 666 |
if (knownChars.length >= 2) {
|
| 667 |
+
// Group bonds by unordered pair; always show BOTH directions (fill missing with neutral 0)
|
| 668 |
+
const bondIndex = {}; // "srcId|tgtId" -> bond object
|
| 669 |
+
for (const b of npcBonds) bondIndex[`${b.source_id}|${b.target_id}`] = b;
|
| 670 |
+
|
| 671 |
+
// Collect all unique unordered pairs from all known characters
|
| 672 |
+
const seenPairs = new Set();
|
| 673 |
+
const pairList = [];
|
| 674 |
+
for (let i = 0; i < knownChars.length; i++) {
|
| 675 |
+
for (let j = i + 1; j < knownChars.length; j++) {
|
| 676 |
+
const a = knownChars[i], b = knownChars[j];
|
| 677 |
+
const key = [a.id, b.id].sort().join("|");
|
| 678 |
+
if (seenPairs.has(key)) continue;
|
| 679 |
+
seenPairs.add(key);
|
| 680 |
+
// Only show pairs where at least one direction has a recorded bond
|
| 681 |
+
const ab = bondIndex[`${a.id}|${b.id}`];
|
| 682 |
+
const ba = bondIndex[`${b.id}|${a.id}`];
|
| 683 |
+
if (!ab && !ba) continue;
|
| 684 |
+
pairList.push({ a, b, ab, ba });
|
| 685 |
+
}
|
| 686 |
}
|
| 687 |
+
|
| 688 |
+
const _bondRow = (srcName, tgtName, bond) => {
|
| 689 |
+
const val = bond ? bond.value : 0;
|
| 690 |
+
const note = bond ? bond.note : "";
|
| 691 |
+
const col = _bondColor(note, val);
|
| 692 |
+
const sign = val > 0 ? "+" : "";
|
| 693 |
+
const noteStr = note || (val === 0 ? "neutral" : "");
|
| 694 |
+
return `<div class="bond-row">
|
| 695 |
+
<span class="bond-name">${srcName}</span>
|
| 696 |
+
<span class="bond-arrow">→</span>
|
| 697 |
+
<span class="bond-name">${tgtName}</span>
|
| 698 |
+
<span class="bond-note" style="color:${col}">${noteStr}</span>
|
| 699 |
+
<span class="bond-val" style="color:${col}">${sign}${val}</span>
|
| 700 |
+
</div>`;
|
| 701 |
+
};
|
| 702 |
+
|
| 703 |
+
const bondListHtml = pairList.map(({ a, b, ab, ba }) =>
|
| 704 |
+
`<div class="bond-pair">
|
| 705 |
+
${_bondRow(a.name, b.name, ab)}
|
| 706 |
+
${_bondRow(b.name, a.name, ba)}
|
| 707 |
+
</div>`
|
| 708 |
+
).join("") || `<div class="je-empty" style="font-size:.78rem">No bonds recorded yet</div>`;
|
| 709 |
|
| 710 |
graphHtml = `<div class="rel-section-title">Between them</div>
|
| 711 |
<div class="bond-graph-wrap">${_buildBondGraph(knownChars, npcBonds)}</div>
|