Skip to content

Commit b9d5231

Browse files
author
prima
committed
feat: Addition of expandable sections to the character manager
1 parent 01b30a6 commit b9d5231

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

klite.embd

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37500,6 +37500,7 @@ flowchart TD\n${treeToViewOutput.outputText.trim()}`
3750037500
window.popupUtils = new PopupUtils()
3750137501
})
3750237502

37503+
let maxLengthForSection = 500, halfMaxLengthForSection = Math.floor(maxLengthForSection / 2);
3750337504
let showCharacterList = async () => {
3750437505
let containers = []
3750537506

@@ -37567,15 +37568,30 @@ flowchart TD\n${treeToViewOutput.outputText.trim()}`
3756737568
sectionElem = document.createElement("ul");
3756837569
text.forEach(listContent => {
3756937570
let listElem = document.createElement("li");
37570-
let summaryOfKey = listContent.length > 100 ? `${listContent.substr(0, 50).trim()}...${listContent.substr(-50).trim()}` : listContent.trim();
37571+
let summaryOfKey = listContent.length > maxLengthForSection ? `${listContent.substr(0, halfMaxLengthForSection).trim()}...${listContent.substr(-halfMaxLengthForSection).trim()}` : listContent.trim();
3757137572
listElem.innerText = summaryOfKey
37573+
if (listContent.length !== summaryOfKey.length)
37574+
{
37575+
listElem.onclick = () => {
37576+
listElem.innerText = listElem.innerText === summaryOfKey ? listContent : summaryOfKey
37577+
}
37578+
listElem.title = "Click to show / hide full content"
37579+
}
3757237580
sectionElem.appendChild(listElem)
3757337581
})
3757437582
}
3757537583
else
3757637584
{
3757737585
sectionElem = document.createElement("span");
37578-
sectionElem.innerText = text.trim();
37586+
let summaryOfKey = text.length > maxLengthForSection ? `${text.substr(0, halfMaxLengthForSection).trim()}...${text.substr(-halfMaxLengthForSection).trim()}` : text.trim();
37587+
sectionElem.innerText = summaryOfKey
37588+
if (text.length !== summaryOfKey.length)
37589+
{
37590+
sectionElem.onclick = () => {
37591+
sectionElem.innerText = sectionElem.innerText === summaryOfKey ? text : summaryOfKey
37592+
}
37593+
sectionElem.title = "Click to show / hide full content"
37594+
}
3757937595
}
3758037596
sectionContainer.appendChild(sectionElem);
3758137597
containerElem.appendChild(sectionContainer);

0 commit comments

Comments
 (0)