Spaces:
Running
Running
Update templates/index.html
Browse files- templates/index.html +65 -13
templates/index.html
CHANGED
|
@@ -504,6 +504,40 @@
|
|
| 504 |
.related-stack .chip {
|
| 505 |
margin-bottom: 6px;
|
| 506 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 507 |
.related-score {
|
| 508 |
color: var(--accent);
|
| 509 |
border-color: rgba(108,131,255,.22);
|
|
@@ -969,18 +1003,23 @@
|
|
| 969 |
return `
|
| 970 |
<div class="related-stack">
|
| 971 |
<div class="chip muted">from similar questions</div>
|
| 972 |
-
|
| 973 |
-
<
|
| 974 |
-
|
| 975 |
-
|
| 976 |
-
|
| 977 |
-
|
| 978 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 979 |
</div>
|
| 980 |
-
|
| 981 |
-
</div>
|
| 982 |
-
|
| 983 |
-
<div class="related-note">These are read-only answers from semantically similar questions, so you can reuse context without writing into the wrong thread.</div>
|
| 984 |
</div>
|
| 985 |
`;
|
| 986 |
}
|
|
@@ -1023,7 +1062,7 @@
|
|
| 1023 |
<div class="bubble no-answer-bubble">No answer yet. Be the first to write one.</div>
|
| 1024 |
<div class="turn-meta"><span class="chip warn">awaiting answer</span></div>
|
| 1025 |
${renderWriteAnswer()}
|
| 1026 |
-
|
| 1027 |
</div>
|
| 1028 |
</div>`);
|
| 1029 |
} else {
|
|
@@ -1036,7 +1075,7 @@
|
|
| 1036 |
${renderAnswerBlock(best, 0, true)}
|
| 1037 |
${renderWriteAnswer()}
|
| 1038 |
${renderOtherAnswers(answers)}
|
| 1039 |
-
|
| 1040 |
</div>
|
| 1041 |
</div>`);
|
| 1042 |
|
|
@@ -1052,6 +1091,11 @@
|
|
| 1052 |
}
|
| 1053 |
}
|
| 1054 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1055 |
bindHandlers();
|
| 1056 |
scrollBottom();
|
| 1057 |
}
|
|
@@ -1096,6 +1140,14 @@
|
|
| 1096 |
oat.classList.toggle("open", open);
|
| 1097 |
};
|
| 1098 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1099 |
// Propose toggle
|
| 1100 |
document.querySelectorAll("[data-propose]").forEach(btn => {
|
| 1101 |
btn.onclick = () => {
|
|
|
|
| 504 |
.related-stack .chip {
|
| 505 |
margin-bottom: 6px;
|
| 506 |
}
|
| 507 |
+
.related-toggle {
|
| 508 |
+
margin-top: 2px;
|
| 509 |
+
border: 1px solid var(--border);
|
| 510 |
+
background: rgba(255,255,255,.02);
|
| 511 |
+
color: var(--muted);
|
| 512 |
+
border-radius: 10px;
|
| 513 |
+
padding: 6px 12px;
|
| 514 |
+
font: inherit; font-size: 11px;
|
| 515 |
+
cursor: pointer;
|
| 516 |
+
transition: all 180ms ease;
|
| 517 |
+
display: inline-flex; align-items: center; gap: 5px;
|
| 518 |
+
}
|
| 519 |
+
.related-toggle:hover {
|
| 520 |
+
border-color: rgba(108,131,255,.3);
|
| 521 |
+
color: var(--text);
|
| 522 |
+
}
|
| 523 |
+
.related-toggle .arrow {
|
| 524 |
+
display: inline-block;
|
| 525 |
+
transition: transform 200ms ease;
|
| 526 |
+
font-size: 10px;
|
| 527 |
+
}
|
| 528 |
+
.related-toggle.open .arrow { transform: rotate(90deg); }
|
| 529 |
+
.related-panel {
|
| 530 |
+
max-height: 0;
|
| 531 |
+
overflow: hidden;
|
| 532 |
+
transition: max-height 280ms ease, opacity 180ms ease, margin-top 180ms ease;
|
| 533 |
+
opacity: 0;
|
| 534 |
+
margin-top: 0;
|
| 535 |
+
}
|
| 536 |
+
.related-panel.open {
|
| 537 |
+
max-height: 3000px;
|
| 538 |
+
opacity: 1;
|
| 539 |
+
margin-top: 6px;
|
| 540 |
+
}
|
| 541 |
.related-score {
|
| 542 |
color: var(--accent);
|
| 543 |
border-color: rgba(108,131,255,.22);
|
|
|
|
| 1003 |
return `
|
| 1004 |
<div class="related-stack">
|
| 1005 |
<div class="chip muted">from similar questions</div>
|
| 1006 |
+
<button class="related-toggle" id="relatedToggle">
|
| 1007 |
+
<span class="arrow">▶</span> ${rel.length} related answer${rel.length > 1 ? "s" : ""}
|
| 1008 |
+
</button>
|
| 1009 |
+
<div class="related-panel" id="relatedPanel">
|
| 1010 |
+
${rel.map(r => `
|
| 1011 |
+
<div class="other-answer-card related">
|
| 1012 |
+
<div class="other-answer-head">
|
| 1013 |
+
<span class="chip matched">related</span>
|
| 1014 |
+
<span>${esc(r.question || "")}</span>
|
| 1015 |
+
<span>·</span>
|
| 1016 |
+
<span class="chip related-score">score ${(Number(r.score || 0)).toFixed(2)}</span>
|
| 1017 |
+
</div>
|
| 1018 |
+
<div class="other-answer-text">${nl2br(r.answer || "")}</div>
|
| 1019 |
</div>
|
| 1020 |
+
`).join("")}
|
| 1021 |
+
<div class="related-note">These are read-only answers from semantically similar questions, so you can reuse context without writing into the wrong thread.</div>
|
| 1022 |
+
</div>
|
|
|
|
| 1023 |
</div>
|
| 1024 |
`;
|
| 1025 |
}
|
|
|
|
| 1062 |
<div class="bubble no-answer-bubble">No answer yet. Be the first to write one.</div>
|
| 1063 |
<div class="turn-meta"><span class="chip warn">awaiting answer</span></div>
|
| 1064 |
${renderWriteAnswer()}
|
| 1065 |
+
<div id="relatedMount"></div>
|
| 1066 |
</div>
|
| 1067 |
</div>`);
|
| 1068 |
} else {
|
|
|
|
| 1075 |
${renderAnswerBlock(best, 0, true)}
|
| 1076 |
${renderWriteAnswer()}
|
| 1077 |
${renderOtherAnswers(answers)}
|
| 1078 |
+
<div id="relatedMount"></div>
|
| 1079 |
</div>
|
| 1080 |
</div>`);
|
| 1081 |
|
|
|
|
| 1091 |
}
|
| 1092 |
}
|
| 1093 |
|
| 1094 |
+
const relatedMount = $("relatedMount");
|
| 1095 |
+
if (relatedMount && S.relatedAnswers.length) {
|
| 1096 |
+
relatedMount.innerHTML = renderRelated(S.relatedAnswers);
|
| 1097 |
+
}
|
| 1098 |
+
|
| 1099 |
bindHandlers();
|
| 1100 |
scrollBottom();
|
| 1101 |
}
|
|
|
|
| 1140 |
oat.classList.toggle("open", open);
|
| 1141 |
};
|
| 1142 |
|
| 1143 |
+
const rt = $("relatedToggle");
|
| 1144 |
+
if (rt) rt.onclick = () => {
|
| 1145 |
+
const p = $("relatedPanel");
|
| 1146 |
+
if (!p) return;
|
| 1147 |
+
const open = p.classList.toggle("open");
|
| 1148 |
+
rt.classList.toggle("open", open);
|
| 1149 |
+
};
|
| 1150 |
+
|
| 1151 |
// Propose toggle
|
| 1152 |
document.querySelectorAll("[data-propose]").forEach(btn => {
|
| 1153 |
btn.onclick = () => {
|