-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathscript.js
89 lines (77 loc) · 2.78 KB
/
script.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
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
/*
* for bulma
*/
function fixBulmanNavbarBurgers() {
// Get all "navbar-burger" elements
const $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0);
// Check if there are any navbar burgers
if ($navbarBurgers.length > 0) {
// Add a click event on each of them
$navbarBurgers.forEach(function ($el) {
$el.addEventListener('click', function () {
// Get the target from the "data-target" attribute
const target = $el.dataset.target;
const $target = document.getElementById(target);
// Toggle the class on both the "navbar-burger" and the "navbar-menu"
$el.classList.toggle('is-active');
$target.classList.toggle('is-active');
})
})
}
}
document.addEventListener('DOMContentLoaded', fixBulmanNavbarBurgers)
/*
* table of contents toggle
*/
const sidebarToggle = document.querySelector('#toc-sidebar-toggle')
if (sidebarToggle) {
const sidebarContent = document.querySelector('#toc-sidebar .toc-wrapper')
const mainContent = document.querySelector('main')
sidebarToggle.onclick = function onClickSidebarToggle () {
sidebarToggle.classList.toggle('closed')
sidebarContent.classList.toggle('is-one-third')
sidebarContent.classList.toggle('is-hidden')
mainContent.classList.toggle('is-two-thirds')
mainContent.classList.toggle('has-toc-padding')
}
}
/*
* Toggle google search
*/
function ToggleSearchActive2() {
document.getElementById("button-header").style.display = "none";
document.getElementById("google-search-header").style.visibility = "visible";
}
/*
* - Linkify videos in publications list / hide non-URL video (stemming from
* reusing the CSL short-title field for video URL)
* - fix the `doi.org//` links
*/
function linkifyVideosInPublications() {
const label = ' Video: '
document.querySelectorAll('.csl-entry').forEach(entry => {
const entry_text = entry.innerHTML
if (entry_text.indexOf(label) > -1) {
let [part_before, part_after] = entry_text.split(label)
if (part_after.indexOf('https://') > -1) {
// contains a link, linkify
part_after = part_after.replace('<', '').replace('>', '').replace(/\.$/, '')
link_label = part_after
if (link_label.length > 50) {
link_label = `${link_label.substr(0, 50)}...`
}
part_after = `${label}<<a href=${part_after}>${link_label}</a>>.`
} else {
// contains something else, hide
part_after = ''
part_before = part_before.replace(/ ;$/, '.')
}
entry.innerHTML = `${part_before}${part_after}`
}
entry.querySelectorAll('a').forEach(link => {
if (link.href.indexOf('https://doi.org//') === 0) {
link.href = link.href.replace('https://doi.org//', '/')
}
})
})
}