owlcode.tech/js-src/index.ts

35 lines
1.2 KiB
TypeScript
Raw Normal View History

2023-05-07 03:09:36 +02:00
"use strict";
2023-05-07 03:31:01 +02:00
import Tablesort from 'tablesort';
window.Tablesort = require('tablesort');
2023-05-07 03:29:47 +02:00
require('tablesort/src/sorts/tablesort.number');
2023-05-07 03:09:36 +02:00
window.onload = () => {
const menu_expand = document.querySelector('a.menu-expand');
const mobile_foldable = document.querySelector('nav.mobile-foldable');
2023-05-17 07:26:46 +02:00
const first_box = document.querySelector('#first-box');
2023-05-07 03:09:36 +02:00
const tables = document.querySelectorAll('table')
if (menu_expand !== null && mobile_foldable !== null) {
menu_expand.addEventListener('click', () => {
mobile_foldable.classList.toggle('show');
2023-05-17 07:26:46 +02:00
if (first_box !== null) {
console.log('hola')
first_box.classList.toggle('margin');
}
2023-05-07 03:09:36 +02:00
});
}
for (const table of tables) {
2023-05-07 03:12:02 +02:00
const header = table.querySelector('tr');
2023-05-07 03:09:36 +02:00
if (header !== null) {
header.setAttribute('data-sort-method', 'none')
for (const th of header.querySelectorAll('th')) {
if (th.getAttribute('data-sort-method') == null) {
th.setAttribute('data-sort-method', 'thead')
}
2023-05-07 03:09:36 +02:00
}
}
2023-05-07 03:31:01 +02:00
new Tablesort(table)
2023-05-07 03:09:36 +02:00
}
};