From 978d5ca1aee23d6663e508aa24b389b6c9003d04 Mon Sep 17 00:00:00 2001
From: Claudio Yanes <me@claudio4.com>
Date: Mon, 07 Mar 2022 18:25:02 +0000
Subject: [PATCH] Format JS
---
assets/js/popover.js | 36 ++++++++++++++++++------------------
1 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/assets/js/popover.js b/assets/js/popover.js
index 6dfd2d2..cf6f84b 100644
--- a/assets/js/popover.js
+++ b/assets/js/popover.js
@@ -5,29 +5,29 @@
return template.content.firstChild
}
-function initPopover(base) {
- const baseUrl = base.replace(window.location.origin, "") // is this useless?
+function initPopover(baseURL) {
+ const basePath = baseURL.replace(window.location.origin, "")
document.addEventListener("DOMContentLoaded", () => {
- fetchData.then(({content}) => {
- const links = [...document.getElementsByClassName("internal-link")]
- links.forEach(li => {
- const linkDest = content[li.dataset.src.replace(baseUrl, "")]
- // const linkDest = content[li.dataset.src]
- if (linkDest) {
- const popoverElement = `<div class="popover">
+ fetchData.then(({ content }) => {
+ const links = [...document.getElementsByClassName("internal-link")]
+ links.forEach(li => {
+ const linkDest = content[li.dataset.src.replace(basePath, "")]
+ // const linkDest = content[li.dataset.src]
+ if (linkDest) {
+ const popoverElement = `<div class="popover">
<h3>${linkDest.title}</h3>
<p>${removeMarkdown(linkDest.content).split(" ", 20).join(" ")}...</p>
<p class="meta">${new Date(linkDest.lastmodified).toLocaleDateString()}</p>
</div>`
- const el = htmlToElement(popoverElement)
- li.appendChild(el)
- li.addEventListener("mouseover", () => {
- el.classList.add("visible")
- })
- li.addEventListener("mouseout", () => {
- el.classList.remove("visible")
- })
- }
+ const el = htmlToElement(popoverElement)
+ li.appendChild(el)
+ li.addEventListener("mouseover", () => {
+ el.classList.add("visible")
+ })
+ li.addEventListener("mouseout", () => {
+ el.classList.remove("visible")
+ })
+ }
})
})
})
--
Gitblit v1.10.0