Adding sort to tables.

This commit is contained in:
Sergiotarxz 2023-05-07 03:09:36 +02:00
parent 65a79f1e21
commit 220ffb4c8d
8 changed files with 241 additions and 1 deletions

26
.eslintrc.js Normal file
View File

@ -0,0 +1,26 @@
module.exports = {
env: {
browser: true,
es2021: true
},
overrides: [
],
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: 'tsconfig.json'
},
plugins: [ ],
rules: {
indent: ['error', 4, { SwitchCase: 1 }],
},
settings: {
'import/resolver': {
typescript: {
project: [
'tsconfig.json'
]
}
}
}
}

2
babel.config.json Normal file
View File

@ -0,0 +1,2 @@
{
}

25
js-src/index.ts Normal file
View File

@ -0,0 +1,25 @@
"use strict";
import tablesort from 'tablesort';
window.onload = () => {
const menu_expand = document.querySelector('a.menu-expand');
const mobile_foldable = document.querySelector('nav.mobile-foldable');
const tables = document.querySelectorAll('table')
if (menu_expand !== null && mobile_foldable !== null) {
menu_expand.addEventListener('click', () => {
mobile_foldable.classList.toggle('show');
});
}
for (const table of tables) {
const header = document.querySelector('tr');
if (header !== null) {
header.setAttribute('data-sort-method', 'none')
for (const th of header.querySelectorAll('th')) {
th.setAttribute('data-sort-method', 'thead')
}
}
tablesort(table)
}
};

23
package.json Normal file
View File

@ -0,0 +1,23 @@
{
"name": "BurguillosInfo",
"version": "0.1.1",
"description": "",
"private": true,
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "AGPL-v3",
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.59.2",
"@typescript-eslint/parser": "^5.59.2",
"eslint": "^8.40.0",
"eslint-plugin-no-relative-import-paths": "^1.5.2",
"typescript": "^5.0.4",
"webpack-cli": "^5.0.2"
},
"dependencies": {
"tablesort": "^5.3.0"
}
}

108
public/js/bundle.js Normal file

File diff suppressed because one or more lines are too long

View File

@ -9,7 +9,7 @@
% my $base_url = config 'base_url';
<html lang="es">
<head>
<script src="/js/index.js"></script>
<script src="/js/bundle.js"></script>
% my $css_version = config 'css_version';
<link rel="stylesheet" href="/css/styles.css?v=<%=$css_version%>"/>
<title><%= title %></title>

28
tsconfig.json Normal file
View File

@ -0,0 +1,28 @@
{
"compilerOptions": {
"outDir": "./public/js/",
"noImplicitAny": true,
"module": "es2020",
"target": "es2020",
"allowJs": true,
"moduleResolution": "node",
"strictNullChecks": true,
"baseUrl": ".",
"paths": {
"@burguillosinfo/*": ["js-src/*"],
"/*": ["js-src/*"]
},
"plugins": [
{
"transform": "typescript-transform-paths"
},
{
"transform": "typescript-transform-paths",
"afterDeclarations": true
}
]
},
"include": [
"js-src/*.ts", "js-src/*/*.ts"
]
}

28
webpack.config.js Normal file
View File

@ -0,0 +1,28 @@
const path = require('path')
module.exports = {
entry: './js-src/index.ts',
mode: 'development',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'public/js/')
},
resolve: {
extensions: ['.js', '.ts'],
roots: [
path.resolve(__dirname, 'js-src/')
],
alias: {
'@burguillosinfo': path.resolve(__dirname, 'js-src')
}
},
module: {
rules: [
{
test: /\.jpe?g|png$/,
exclude: /node_modules/,
use: ['url-loader', 'file-loader']
}
]
}
}