-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
90 lines (83 loc) · 2.82 KB
/
Copy pathscript.js
File metadata and controls
90 lines (83 loc) · 2.82 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// from: http://www.robots.ox.ac.uk/~vedaldi/assets/hidebib.js
// const currentTheme = window.localStorage.getItem("theme");
// if (currentTheme == "dark") {
// document.body.classList.add("dark-mode");
// const getIcon = document.getElementById('moonIcon');
// getIcon.src = 'images/sun.png';
// getIcon.alt = 'Light';
// }
function setDarkMode(dark, preference) {
console.log('Button triggered')
if (dark) {
preference !== "dark" ? localStorage.setItem('theme', 'dark') : localStorage.removeItem('theme');
document.documentElement.classList.add('dark-mode');
} else if (!dark) {
preference !== "light" ? localStorage.setItem('theme', 'light') : localStorage.removeItem('theme');
document.documentElement.classList.remove('dark-mode');
}
}
const preference = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
if (localStorage.getItem('theme') === "dark" || (!('theme' in localStorage) && preference === 'dark')) {
setDarkMode(true, preference);
}
function onloadfunc(){
document.getElementById('darkBtn').addEventListener('click', function() {
setDarkMode(!document.documentElement.classList.contains('dark-mode'), preference);
});
}
window.onload = onloadfunc;
function hideallbibs()
{
var el = document.getElementsByTagName("div") ;
for (var i = 0 ; i < el.length ; ++i) {
if (el[i].className == "paper") {
var bib = el[i].getElementsByTagName("pre") ;
if (bib.length > 0) {
bib [0] .style.display = 'none' ;
}
}
}
}
function togglebib(paperid)
{
var paper = document.getElementById(paperid) ;
var bib = paper.getElementsByTagName('pre') ;
if (bib.length > 0) {
if (bib [0] .style.display == 'none') {
bib [0] .style.display = 'block' ;
} else {
bib [0] .style.display = 'none' ;
}
}
}
function toggleblock(blockId)
{
var block = document.getElementById(blockId);
if (block.style.display == 'none') {
block.style.display = 'block' ;
} else {
block.style.display = 'none' ;
}
}
function hideblock(blockId)
{
var block = document.getElementById(blockId);
block.style.display = 'none' ;
}
// function toggleDarkMode(){
// const getIcon = document.getElementById('moonIcon');
// document.body.classList.toggle("dark-mode");
// if (getIcon.src.match('images/moon.png')) {
// getIcon.src = 'images/sun.png';
// getIcon.alt = 'Light';
// } else {
// getIcon.src = 'images/moon.png';
// getIcon.alt = 'Dark';
// }
// const getLink = document.getElementById('darkBtn')
// let theme = "light";
// if (document.body.classList.contains("dark-mode")) {
// theme = "dark";
// }
// window.localStorage.setItem("theme", theme);
// }