booru: put context menu in loader, add tooltip for tags

This commit is contained in:
end-4
2025-05-16 14:56:14 +02:00
parent 3b764ca70e
commit 9a68f80ffa
2 changed files with 98 additions and 67 deletions
@@ -91,4 +91,21 @@ function splitMarkdownBlocks(markdown) {
function escapeBackslashes(str) {
return str.replace(/\\/g, '\\\\');
}
function wordWrap(str, maxLen) {
if (!str) return "";
let words = str.split(" ");
let lines = [];
let current = "";
for (let i = 0; i < words.length; ++i) {
if ((current + (current.length > 0 ? " " : "") + words[i]).length > maxLen) {
if (current.length > 0) lines.push(current);
current = words[i];
} else {
current += (current.length > 0 ? " " : "") + words[i];
}
}
if (current.length > 0) lines.push(current);
return lines.join("\n");
}