summaryrefslogtreecommitdiff
path: root/poxy/poxy.js
blob: 40c2468938777bf732ddebd59f5ad60bc02c9b14 (plain)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
function do_with_debounce(fn)
{
	fn();
	setTimeout(function() { fn(); }, 200);
}

function set_theme(theme)
{
	localStorage.setItem('poxy-theme', theme);
	document.documentElement.className = 'poxy-theme-' + theme;
	console.log("poxy theme set to '" + theme + "'");
}

function initialize_theme(default_theme)
{
	current = localStorage.getItem('poxy-theme');
	if (!current)
		current = default_theme
	set_theme(current);
}

function toggle_theme()
{
	current = localStorage.getItem('poxy-theme');
	if (!current || current === 'light')
		set_theme('dark');
	else
		set_theme('light');
}

function install_mcss_search_shim()
{
	let showSearch_impl = window.showSearch;
	window.showSearch = function()
	{
		if (window.location.hash == '#search')
		{
			document.getElementById('search-input').focus();
			return false;
		}
		return showSearch_impl.apply(null);
	};
}

/*
$(function()
{
	page_header = $('body > header')[0]

	fix_body_header_padding = function()
	{
		document.body.style.paddingTop = page_header.offsetHeight + 'px';
	};

	$(page_header).resize(function()
	{
		do_with_debounce(fix_body_header_padding);
	});

	do_with_debounce(fix_body_header_padding);
});
*/