mirror of
https://github.com/falsycat/ar.falsy.cat.git
synced 2024-12-25 16:14:50 +00:00
Format JS
This commit is contained in:
parent
6f9283e95b
commit
978d5ca1ae
@ -25,7 +25,7 @@ async function drawGraph(url, baseUrl, pathColors, depth, enableDrag, enableLege
|
||||
}
|
||||
|
||||
const data = {
|
||||
nodes: [...neighbours].map(id => ({id})),
|
||||
nodes: [...neighbours].map(id => ({ id })),
|
||||
links: links.filter(l => neighbours.has(l.source) && neighbours.has(l.target)),
|
||||
}
|
||||
|
||||
@ -52,18 +52,18 @@ async function drawGraph(url, baseUrl, pathColors, depth, enableDrag, enableLege
|
||||
d.fy = d.y;
|
||||
}
|
||||
|
||||
function dragged(event,d) {
|
||||
function dragged(event, d) {
|
||||
d.fx = event.x;
|
||||
d.fy = event.y;
|
||||
}
|
||||
|
||||
function dragended(event,d) {
|
||||
function dragended(event, d) {
|
||||
if (!event.active) simulation.alphaTarget(0);
|
||||
d.fx = null;
|
||||
d.fy = null;
|
||||
}
|
||||
|
||||
const noop = () => {}
|
||||
const noop = () => { }
|
||||
return d3.drag()
|
||||
.on("start", enableDrag ? dragstarted : noop)
|
||||
.on("drag", enableDrag ? dragged : noop)
|
||||
@ -86,15 +86,15 @@ async function drawGraph(url, baseUrl, pathColors, depth, enableDrag, enableLege
|
||||
|
||||
if (enableLegend) {
|
||||
const legend = [
|
||||
{"Current": "var(--g-node-active)"},
|
||||
{"Note": "var(--g-node)"},
|
||||
{ "Current": "var(--g-node-active)" },
|
||||
{ "Note": "var(--g-node)" },
|
||||
...pathColors
|
||||
]
|
||||
legend.forEach((legendEntry, i) => {
|
||||
const key = Object.keys(legendEntry)[0]
|
||||
const colour = legendEntry[key]
|
||||
svg.append("circle").attr("cx", -width/2 + 20).attr("cy", height/2 - 30 * (i+1)).attr("r", 6).style("fill", colour)
|
||||
svg.append("text").attr("x", -width/2 + 40).attr("y", height/2 - 30 * (i+1)).text(key).style("font-size", "15px").attr("alignment-baseline","middle")
|
||||
svg.append("circle").attr("cx", -width / 2 + 20).attr("cy", height / 2 - 30 * (i + 1)).attr("r", 6).style("fill", colour)
|
||||
svg.append("text").attr("x", -width / 2 + 40).attr("y", height / 2 - 30 * (i + 1)).text(key).style("font-size", "15px").attr("alignment-baseline", "middle")
|
||||
})
|
||||
}
|
||||
|
||||
@ -159,7 +159,7 @@ async function drawGraph(url, baseUrl, pathColors, depth, enableDrag, enableLege
|
||||
.transition()
|
||||
.duration(200)
|
||||
.style("opacity", 1)
|
||||
}).on("mouseleave", function (_,d) {
|
||||
}).on("mouseleave", function (_, d) {
|
||||
d3.selectAll(".node")
|
||||
.transition()
|
||||
.duration(200)
|
||||
@ -196,7 +196,7 @@ async function drawGraph(url, baseUrl, pathColors, depth, enableDrag, enableLege
|
||||
svg.call(d3.zoom()
|
||||
.extent([[0, 0], [width, height]])
|
||||
.scaleExtent([0.25, 4])
|
||||
.on("zoom", ({transform}) => {
|
||||
.on("zoom", ({ transform }) => {
|
||||
link.attr("transform", transform);
|
||||
node.attr("transform", transform);
|
||||
labels.attr("transform", transform);
|
||||
@ -217,5 +217,4 @@ async function drawGraph(url, baseUrl, pathColors, depth, enableDrag, enableLege
|
||||
.attr("x", d => d.x)
|
||||
.attr("y", d => d.y)
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,13 +5,13 @@ function htmlToElement(html) {
|
||||
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}) => {
|
||||
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.replace(basePath, "")]
|
||||
// const linkDest = content[li.dataset.src]
|
||||
if (linkDest) {
|
||||
const popoverElement = `<div class="popover">
|
||||
|
@ -58,7 +58,7 @@ const removeMarkdown = (
|
||||
};
|
||||
// -----
|
||||
|
||||
(async function() {
|
||||
(async function () {
|
||||
const contentIndex = new FlexSearch.Document({
|
||||
cache: true,
|
||||
charset: "latin:extra",
|
||||
@ -126,7 +126,7 @@ const removeMarkdown = (
|
||||
return `${startIndex === 0 ? "" : "..."}${mappedText}${endIndex === splitText.length ? "" : "..."}`
|
||||
}
|
||||
|
||||
const resultToHTML = ({url, title, content, term}) => {
|
||||
const resultToHTML = ({ url, title, content, term }) => {
|
||||
const text = removeMarkdown(content)
|
||||
const resultTitle = highlight(title, term)
|
||||
const resultText = highlight(text, term)
|
||||
|
Loading…
Reference in New Issue
Block a user