blob: d13c120b79f9b20432ce23e1a7e9980b501c08f9 (
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
|
function set_theme(name) {
var themes = {
default: {
bootstrap: '/static/css/bootstrap.flatly.min.css',
pygments: '/highlight_stylesheet',
pastepy: '/static/css/paste.css',
},
dark: {
bootstrap: '/static/css/bootstrap.darkly.min.css',
pygments: '/highlight_stylesheet/paraiso-dark',
pastepy: '/static/css/paste.dark.css',
}
};
var bootstrap_css = document.getElementById('bootstrap-css');
var pygments_css = document.getElementById('pygments-css');
var pastepy_css = document.getElementById('pastepy-css');
var theme = themes[name];
bootstrap_css.href = theme.bootstrap;
if (pygments_css) {
pygments_css.href = theme.pygments;
}
if (pastepy_css) {
pastepy_css.href = theme.pastepy;
}
var theme = localStorage.setItem('theme', name);
}
function switch_theme(event) {
if (event && event.type !== 'load') {
event.preventDefault();
}
var bootstrap_css = document.getElementById('bootstrap-css');
var pygments_css = document.getElementById('pygments-css');
var theme = localStorage.getItem('theme');
set_theme(theme === 'dark' ? 'default' : 'dark');
}
window.addEventListener('load', function() {
var theme = localStorage.getItem('theme');
if (theme) {
set_theme(theme);
}
});
|