Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/jakewies/hugo-theme-codex.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Valls Pla <xaviervallspla@gmail.com>2020-06-25 16:35:11 +0300
committerXavier Valls Pla <xaviervallspla@gmail.com>2020-06-25 16:35:11 +0300
commitc42aeb8076c2de24a8658e573b4a84b197acd530 (patch)
tree23f2199d5a5f74fbc24c541319db35a712b0faf9
parent8e307d837d9efa3851f0d0568b864b3cd7f0711b (diff)
fix indentation
-rw-r--r--static/js/table-of-contents.js60
1 files changed, 30 insertions, 30 deletions
diff --git a/static/js/table-of-contents.js b/static/js/table-of-contents.js
index 2fe26d4..55f1ecb 100644
--- a/static/js/table-of-contents.js
+++ b/static/js/table-of-contents.js
@@ -1,42 +1,42 @@
function elementInToC(entry) {
- return document.querySelector(`#TableOfContents ul li a[href="#${entry.target.getAttribute('id')}"]`);
+ return document.querySelector(`#TableOfContents ul li a[href="#${entry.target.getAttribute('id')}"]`);
}
window.addEventListener('DOMContentLoaded', () => {
- var previousActive = null;
+ var previousActive = null;
- const observer = new IntersectionObserver(entries => {
- var foundActive = false;
- entries.forEach(entry => {
- if (!foundActive && entry.isIntersecting) {
- if(previousActive) {
- previousActive.classList.remove('active');
- }
- elementInToC(entry).classList.add('active');
- foundActive = true;
- previousActive = elementInToC(entry);
- }
- else {
- elementInToC(entry).classList.remove('active');
- }
- })
+ const observer = new IntersectionObserver(entries => {
+ var foundActive = false;
+ entries.forEach(entry => {
+ if (!foundActive && entry.isIntersecting) {
+ if (previousActive) {
+ previousActive.classList.remove('active');
+ }
+ elementInToC(entry).classList.add('active');
+ foundActive = true;
+ previousActive = elementInToC(entry);
+ }
+ else {
+ elementInToC(entry).classList.remove('active');
+ }
+ })
- if (!foundActive) {
- previousActive.classList.add('active');
- };
- });
+ if (!foundActive) {
+ previousActive.classList.add('active');
+ };
+ });
- // Track all headers that have an `id` applied
- document.querySelectorAll('article h3[id], article h2[id]').forEach((section) => {
- observer.observe(section);
- });
+ // Track all headers that have an `id` applied
+ document.querySelectorAll('article h3[id], article h2[id]').forEach((section) => {
+ observer.observe(section);
+ });
});
// Post title doesn't get parsed as it is not part of the content file
(function addPostTitle2ToC() {
- var toc = document.getElementById('TableOfContents');
- if (!toc) return;
- var title = document.getElementById("post__title").innerText;
- var ul = toc.querySelector('ul');
- ul.outerHTML = `<ul><li><a href="#post__title" class="active">${title}</a>${ul.outerHTML}</li></ul>`;
+ var toc = document.getElementById('TableOfContents');
+ if (!toc) return;
+ var title = document.getElementById("post__title").innerText;
+ var ul = toc.querySelector('ul');
+ ul.outerHTML = `<ul><li><a href="#post__title" class="active">${title}</a>${ul.outerHTML}</li></ul>`;
})();