Add clarification comments
This commit is contained in:
		
							parent
							
								
									bcb166c21c
								
							
						
					
					
						commit
						5c602ab16f
					
				
					 3 changed files with 7 additions and 3 deletions
				
			
		| 
						 | 
					@ -16,9 +16,8 @@ async function drawGraph(
 | 
				
			||||||
    ...new Set(links.flatMap((link) => [link.source, link.target])),
 | 
					    ...new Set(links.flatMap((link) => [link.source, link.target])),
 | 
				
			||||||
  ];
 | 
					  ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // links is mutated by d3
 | 
					  // Links is mutated by d3. We want to use links later on, so we make a copy and pass that one to d3
 | 
				
			||||||
  // we want to use links later on, so we make a copy and pass
 | 
					  // Note: shallow cloning does not work because it copies over references from the original array
 | 
				
			||||||
  // that one to d3
 | 
					 | 
				
			||||||
  const copyLinks = JSON.parse(JSON.stringify(links));
 | 
					  const copyLinks = JSON.parse(JSON.stringify(links));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const neighbours = new Set();
 | 
					  const neighbours = new Set();
 | 
				
			||||||
| 
						 | 
					@ -176,6 +175,7 @@ async function drawGraph(
 | 
				
			||||||
    .attr('fill', color)
 | 
					    .attr('fill', color)
 | 
				
			||||||
    .style('cursor', 'pointer')
 | 
					    .style('cursor', 'pointer')
 | 
				
			||||||
    .on('click', (_, d) => {
 | 
					    .on('click', (_, d) => {
 | 
				
			||||||
 | 
					      // SPA navigation
 | 
				
			||||||
      window.navigate(
 | 
					      window.navigate(
 | 
				
			||||||
        new URL(`${baseUrl}${decodeURI(d.id).replace(/\s+/g, '-')}/`),
 | 
					        new URL(`${baseUrl}${decodeURI(d.id).replace(/\s+/g, '-')}/`),
 | 
				
			||||||
        '.singlePage'
 | 
					        '.singlePage'
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -145,6 +145,7 @@ const removeMarkdown = (
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const redir = (id, term) => {
 | 
					  const redir = (id, term) => {
 | 
				
			||||||
 | 
					    // SPA navigation
 | 
				
			||||||
    window.navigate(
 | 
					    window.navigate(
 | 
				
			||||||
      new URL(
 | 
					      new URL(
 | 
				
			||||||
        `${BASE_URL.slice(0, -1)}${id}#:~:text=${encodeURIComponent(term)}/`
 | 
					        `${BASE_URL.slice(0, -1)}${id}#:~:text=${encodeURIComponent(term)}/`
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -57,9 +57,12 @@
 | 
				
			||||||
  </script>
 | 
					  </script>
 | 
				
			||||||
  <script type="module">
 | 
					  <script type="module">
 | 
				
			||||||
    import { router, navigate } from "https://unpkg.com/million/dist/router.mjs";
 | 
					    import { router, navigate } from "https://unpkg.com/million/dist/router.mjs";
 | 
				
			||||||
 | 
					    // SPA navigation for access later
 | 
				
			||||||
    window.navigate = navigate;
 | 
					    window.navigate = navigate;
 | 
				
			||||||
 | 
					    // We only mutate document.title and content within .singlePage element
 | 
				
			||||||
    router(".singlePage");
 | 
					    router(".singlePage");
 | 
				
			||||||
    const callback = () => {
 | 
					    const callback = () => {
 | 
				
			||||||
 | 
					      // requestAnimationFrame()
 | 
				
			||||||
      const draw = () => {
 | 
					      const draw = () => {
 | 
				
			||||||
        const container = document.getElementById("graph-container");
 | 
					        const container = document.getElementById("graph-container");
 | 
				
			||||||
        // retry if the graph is not ready
 | 
					        // retry if the graph is not ready
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue