Update jot-header.tpl

do the math on i-1
This commit is contained in:
Ray 2023-02-24 09:39:27 -05:00
parent 0f0f50aa20
commit c860e7261c

View file

@ -789,24 +789,24 @@ let postSaveTimer = null;
for(let i=0; i<results.length; i++) {
if (results[i].is_dir === '1' && results[i-1].is_dir === '1') {
if (results[i].is_dir === '1' && results[(i-1)].is_dir === '1') {
// is_dir preceded by another is_dir = add opening <ul> to the beginning of the button
content += `<ul class="collapse" id="#embedDir-${i}">
<button class="btn btn-primary" type="button" data-bs-toggle="collapse" data-bs-target="#embedDir-${i}" aria-expanded="false" aria-controls="#embedDir-${i}">
${results[i].filename}
</button>`;
} else if (results[i].is_dir === '1' && results[i-1].is_dir !== '1') {
} else if (results[i].is_dir === '1' && results[(i-1)].is_dir !== '1') {
// is_dir preceded by a file = add closing </ul> to the beginning of the button
content += `</ul><button class="btn btn-primary" type="button" data-bs-toggle="collapse" data-bs-target="#embedDir-${i}" aria-expanded="false" aria-controls="#embedDir-${i}">
${results[i].filename}
</button>`;
} else if (results[i].is_dir !== '1' && results[i-1].is_dir === '1') {
} else if (results[i].is_dir !== '1' && results[(i-1)].is_dir === '1') {
// file preceded by a is_dir = add opening <ul> to the beginning of file
content += `<ul class="collapse" id="#embedDir-${i}"><li>${results[i].filename}</li>`;
} else if (results[i].is_dir !== '1' && results[i-1].is_dir === '1') {
} else if (results[i].is_dir !== '1' && results[(i-1)].is_dir === '1') {
// file preceded by another file = just the line item
content += `<li>${results[i].filename}</li>`;