Limit max length in download table (fixes #244)

This commit is contained in:
Alex Ling 2021-11-17 13:10:44 +00:00
parent 1199eb7a03
commit 921628ba6d

View File

@ -68,7 +68,12 @@ const buildTable = (chapters) => {
$('table').append(thead); $('table').append(thead);
const rows = chapters.map(ch => { const rows = chapters.map(ch => {
const tds = Object.values(ch).map(v => `<td>${v}</td>`).join(''); const tds = Object.values(ch).map(v => {
const maxLength = 40;
const shouldShrink = v.length > maxLength;
const content = shouldShrink ? `<span title="${v}">${v.substring(0, maxLength)}...</span><div uk-dropdown><span>${v}</span></div>` : v;
return `<td>${content}</td>`
}).join('');
return `<tr data-id="${ch.id}" data-title="${ch.title}">${tds}</tr>`; return `<tr data-id="${ch.id}" data-title="${ch.title}">${tds}</tr>`;
}); });
const tbody = `<tbody id="selectable">${rows}</tbody>`; const tbody = `<tbody id="selectable">${rows}</tbody>`;