-
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
89 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,42 @@ | ||
(() => { | ||
|
||
const uri = new URL(location.href); | ||
|
||
let headers = document.querySelector('header nav h2'); | ||
if (headers) { | ||
headers.addEventListener('click', function () { | ||
headers.addEventListener('click', () => { | ||
this.parentNode.querySelector('ul').classList.toggle('show'); | ||
}, false); | ||
} | ||
|
||
let contentHeaders = document.querySelectorAll("main h2[id]"); | ||
if (contentHeaders && !document.querySelector('html').classList.contains('homepage')) { | ||
contentHeaders.forEach((header) => { | ||
uri.hash = header.id; | ||
let link = document.createElement("a"); | ||
link.className = "header-permalink"; | ||
link.title = "Permalink"; | ||
link.href = uri.toString(); | ||
link.innerHTML = "¶"; | ||
header.appendChild(link); | ||
}); | ||
if (!document.querySelector('html').classList.contains('homepage') && contentHeaders) { | ||
const uri = new URL(location.href); | ||
contentHeaders.forEach((header) => { | ||
uri.hash = header.id; | ||
let link = document.createElement("a"); | ||
link.classList.add("header-permalink"); | ||
link.title = "Permalink"; | ||
link.href = uri.toString(); | ||
link.innerHTML = "¶"; | ||
header.appendChild(link); | ||
}); | ||
} | ||
|
||
const sponsorDiv = document.querySelector('.sponsors'); | ||
if (sponsorDiv) { | ||
let hideSponsorUntil = localStorage.getItem('hideSponsorUntil'); | ||
if (hideSponsorUntil === null || hideSponsorUntil < (new Date().getTime())) { | ||
sponsorDiv.classList.remove('hide'); | ||
} | ||
const sponsorBanner = document.querySelector('.sponsors'); | ||
if (sponsorBanner) { | ||
let hideUntil = localStorage.getItem('hideSponsorUntil'); | ||
if (hideUntil === null || hideUntil < (new Date().getTime())) { | ||
localStorage.removeItem('hideSponsorUntil'); | ||
sponsorBanner.classList.remove('hide'); | ||
} | ||
|
||
let closeButton = document.createElement('a'); | ||
closeButton.classList.add('close'); | ||
closeButton.innerHTML = 'close me'; | ||
closeButton.addEventListener('click', () => { | ||
localStorage.setItem('hideSponsorUntil', new Date().getTime() + (7 * 86400 * 1e4)); | ||
sponsorBanner.classList.add('hide'); | ||
}, false); | ||
|
||
sponsorDiv.querySelector('a.close').addEventListener('click', function () { | ||
sponsorDiv.classList.add('hide'); | ||
localStorage.setItem('hideSponsorUntil', new Date().getTime() + (7 * 86400 * 1e4)); | ||
}, false); | ||
sponsorBanner.firstElementChild.appendChild(closeButton); | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters