Skip to content
This repository has been archived by the owner on May 26, 2021. It is now read-only.

Commit

Permalink
js: support non-topic tables
Browse files Browse the repository at this point in the history
  • Loading branch information
Jens John committed Aug 27, 2017
1 parent 6f1cafe commit a289a04
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions fluxbbactivity/www/lib/vendor.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,24 +287,33 @@ function make_table(anchor, data) {
table.appendChild(thead);

let tbody = document.createElement("tbody");

body.forEach((row) => {
let tr = document.createElement("tr");
let id = row[0];
let colidx = 0;
row.slice(1).forEach((col) => {
let td = document.createElement("td");
if(anchor.search(/^top-/)) {

/* topic-based tables */
if(anchor.search(/^top-/)) {
let id = row[0];
let colidx = 0;
row.slice(1).forEach((col) => {
let td = document.createElement("td");
let a = document.createElement("a");
a.setAttribute("href", `https://forums.bunsenlabs.org/viewtopic.php?id=${id}`);
a.textContent = ++colidx>1 ? parseFloat(col).toLocaleString() : col;
td.appendChild(a);
} else {
tr.appendChild(td);
});
} else {
row.forEach((col) => {
let td = document.createElement("td");
td.textContent = col;
}
tr.appendChild(td);
});
tr.appendChild(td);
});
}

tbody.appendChild(tr);
});

table.appendChild(tbody);
};

Expand Down

0 comments on commit a289a04

Please sign in to comment.