ctucx.git: oeffi-web

[nimlang] oeffisearch fork that works without javascript

1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
26 
27 
28 
29 
30 
31 
32 
33 'use strict';

import { registerLoaderOnLinks, showLoader, hideOverlay } from './helpers.js';
import { html, render } from './lit-html.js';

export const go = (url) => {
	window.location = url;
	showLoader();
}

const registerTableEvents = () => {
	let table =  document.getElementsByTagName("table")[0]; 

	for (let i = 1, row; row = table.rows[i]; i++) {
		const link = row.dataset.link;

		row.classList.add('pointer');
		row.addEventListener('click', () => go(link));
	}
}

registerTableEvents();
registerLoaderOnLinks();

window.onbeforeunload = function(e) {
	hideOverlay();
}

window.onpageshow = function(event) {
	if (event.persisted) {
		hideOverlay();
	}
};