generated from MLNLP-World/MyArxiv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
39 lines (34 loc) · 1.49 KB
/
index.js
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
/* Exapand/Collapse with TAB key */
var expanded = false;
document.onkeydown = function (e) {
if (e.keyCode === 9) {
expanded = !expanded;
document.querySelectorAll("details").forEach(detail => detail.open = expanded);
return false;
}
};
/* Switch Theme */
const toggleSwitch = document.querySelector('.theme-switch input[type="checkbox"]');
function switchTheme(e) {
if (e.target.checked) {
document.documentElement.setAttribute('data-theme', 'light');
document.getElementById("theme-icon").className = "ri-sun-line";
localStorage.setItem('theme', 'light'); //add this
} else {
document.documentElement.setAttribute('data-theme', 'dark');
document.getElementById("theme-icon").className = "ri-moon-line";
localStorage.setItem('theme', 'dark'); //add this
}
}
toggleSwitch.addEventListener('change', switchTheme, false);
const currentTheme = localStorage.getItem('theme') ? localStorage.getItem('theme') : null;
if (currentTheme) {
document.documentElement.setAttribute('data-theme', currentTheme);
if (currentTheme === 'light') {
toggleSwitch.checked = true;
}
}
const timestamp = document.getElementById("build-timestamp");
const timestamp_local = new Date(timestamp.getAttribute("datetime")).toLocaleString();
const badge = document.getElementById("build-timestamp-badge");
// badge.src = `https://img.shields.io/github/workflow/status/mlnlp-world/myarxiv/Update?=${timestamp_local}&style=for-the-badge`