From 7f5b18baa84e1a5f94b48ac40f5361645521c5e6 Mon Sep 17 00:00:00 2001 From: Aiden Bai Date: Sat, 30 Apr 2022 13:51:12 -0700 Subject: [PATCH] Revert "Add comments" This reverts commit d703cd8c0e06e0bb58677f600c24dcd50ade3512. --- .prettierrc.json | 17 +++++++++++++++-- assets/js/graph.js | 18 ++++++------------ layouts/partials/head.html | 2 -- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/.prettierrc.json b/.prettierrc.json index f1bc35a4d..7ed5d6a71 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -1,6 +1,19 @@ { + "arrowParens": "always", + "bracketSameLine": false, + "bracketSpacing": true, + "embeddedLanguageFormatting": "auto", + "htmlWhitespaceSensitivity": "css", + "insertPragma": false, + "jsxSingleQuote": false, "printWidth": 100, + "proseWrap": "preserve", "quoteProps": "as-needed", - "trailingComma": "all", - "tabWidth": 2 + "requirePragma": false, + "semi": true, + "singleQuote": false, + "tabWidth": 2, + "trailingComma": "es5", + "useTabs": false, + "vueIndentScriptAndStyle": false } diff --git a/assets/js/graph.js b/assets/js/graph.js index a1cbba9ab..b7c95b3a6 100644 --- a/assets/js/graph.js +++ b/assets/js/graph.js @@ -1,8 +1,6 @@ async function drawGraph(url, baseUrl, pathColors, depth, enableDrag, enableLegend, enableZoom) { - const container = document.getElementById("graph-container"); - // We should clear the graph in case there is anything within it - if (!container) return; - container.textContent = ""; + if (!document.getElementById("graph-container")) return; + document.getElementById("graph-container").textContent = ""; const { index, links, content } = await fetchData; const curPage = url.replace(baseUrl, ""); @@ -10,10 +8,6 @@ async function drawGraph(url, baseUrl, pathColors, depth, enableDrag, enableLege const parseIdsFromLinks = (links) => [ ...new Set(links.flatMap((link) => [link.source, link.target])), ]; - - // links is mutated by d3 - // we want to use links later on, so we make a copy and pass - // that one to d3 const copyLinks = JSON.parse(JSON.stringify(links)); const neighbours = new Set(); @@ -83,8 +77,8 @@ async function drawGraph(url, baseUrl, pathColors, depth, enableDrag, enableLege .on("end", enableDrag ? dragended : noop); }; - const height = Math.max(container.offsetHeight, 250); - const width = container.offsetWidth; + const height = Math.max(document.getElementById("graph-container").offsetHeight, 250); + const width = document.getElementById("graph-container").offsetWidth; const simulation = d3 .forceSimulation(data.nodes) @@ -94,7 +88,7 @@ async function drawGraph(url, baseUrl, pathColors, depth, enableDrag, enableLege d3 .forceLink(data.links) .id((d) => d.id) - .distance(40), + .distance(40) ) .force("center", d3.forceCenter()); @@ -230,7 +224,7 @@ async function drawGraph(url, baseUrl, pathColors, depth, enableDrag, enableLege const scale = transform.k; const scaledOpacity = Math.max((scale - 1) / 3.75, 0); labels.attr("transform", transform).style("opacity", scaledOpacity); - }), + }) ); } diff --git a/layouts/partials/head.html b/layouts/partials/head.html index ec37f8816..4824d9b5c 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -51,7 +51,6 @@ window.navigate = navigate; router(".singlePage"); const callback = () => { - // RAF waits for Million to complete diffing, then draw requestAnimationFrame(() => { drawGraph( {{strings.TrimRight "/" .Page.Permalink}}, @@ -64,7 +63,6 @@ )} ); }; - // We need on initial load, then subsequent redirs window.addEventListener("million:navigate", callback); window.addEventListener("DOMContentLoaded", callback);