Skip to content

Commit ef9e8a6

Browse files
committed
toh.js: add rotate table setting
Signed-off-by: Jo-Philipp Wich <[email protected]>
1 parent bc7f072 commit ef9e8a6

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

static/toh.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ function loadJSONTableData() {
231231
}));
232232
}
233233

234-
function dataToTable(data, columnOrder, filterColumns, domSetting) {
234+
function dataToTable(data, columnOrder, filterColumns, domSetting, rotateTable) {
235235
let table = document.createElement('table');
236236
let columnFilter = data.columns.map((k, i) => filterColumns?.[k]).map(f => {
237237
if (!f)
@@ -258,6 +258,9 @@ function dataToTable(data, columnOrder, filterColumns, domSetting) {
258258
table.classList.add('table', 'table-striped', 'table-sm');
259259
table.innerHTML = '<thead><tr></tr><tr class="filters"></tr></thead><tbody></tbody>'
260260

261+
if (rotateTable)
262+
table.classList.add('rotate');
263+
261264
columnOrder.forEach(colSrcIdx => {
262265
let th = document.createElement('th');
263266

@@ -267,11 +270,15 @@ function dataToTable(data, columnOrder, filterColumns, domSetting) {
267270
}
268271

269272
th.classList.add(`toh_${data.columns[colSrcIdx]}`);
270-
th.style.maxWidth = 0;
271-
th.style.minWidth = '3em';
272-
th.style.whiteSpace = 'nowrap';
273-
th.style.overflow = 'hidden';
274-
th.style.textOverflow = 'ellipsis';
273+
274+
if (!rotateTable) {
275+
th.style.maxWidth = 0;
276+
th.style.minWidth = '3em';
277+
th.style.whiteSpace = 'nowrap';
278+
th.style.overflow = 'hidden';
279+
th.style.textOverflow = 'ellipsis';
280+
}
281+
275282
table.firstElementChild.firstElementChild.appendChild(th);
276283

277284
let filter = document.createElement('th');
@@ -351,7 +358,7 @@ function initToH() {
351358
catch(e) { console.error('Error parsing ToH settings: ' + e); }
352359

353360
profile ??= {};
354-
profile.source ??= 'min';
361+
profile.source ??= 'json';
355362

356363
let loadSource;
357364
switch (profile.source) {
@@ -402,7 +409,8 @@ function initToH() {
402409

403410
const domSetting = profile?.dom ?? 'lfrtip';
404411
const columnOrder = shownColumns.map(colName => srcData.columns.indexOf(colName));
405-
let table = $(dataToTable(srcData, columnOrder, filterColumns, domSetting));
412+
const rotateTable = profile?.rotate ?? false;
413+
let table = $(dataToTable(srcData, columnOrder, filterColumns, domSetting, rotateTable));
406414

407415
$(wrapper).hide().empty().append(table);
408416
$(wrapper).find('table').DataTable({

0 commit comments

Comments
 (0)