Skip to content

Commit

Permalink
#1 filter nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Scobiform committed Apr 17, 2024
1 parent b0d1f01 commit dd51d0d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions templates/graph.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@

function filterNodes(filterType) {
const filteredData = {
nodes: graphData.nodes.filter(node => filterType === 'all' || node.type === filterType),
links: graphData.links.filter(link => {
const sourceVisible = filterType === 'all' || link.source.type === filterType;
const targetVisible = filterType === 'all' || link.target.type === filterType;
return sourceVisible && targetVisible;
})
};
nodes: graphData.nodes.filter(node => filterType === 'all' || node.type === filterType),
links: graphData.links.filter(link => {
const sourceVisible = filterType === 'all' || link.source.type === filterType;
const targetVisible = filterType === 'all' || link.target.type === filterType;
return sourceVisible && targetVisible;
})
};

// Update the graph with the filtered data
Graph.graphData(filteredData);
Expand Down
4 changes: 2 additions & 2 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
<header>
{% if logged_in %}
<p>Welcome, {{ user.username }}!</p>
<a href="/logout">Logout</a>
<button onclick="window.location.href='/logout';">Logout</button>
{% else %}
<a href="/login">Login with Mastodon</a>
<button onclick="window.location.href='/login';">Login with Mastodon</button>
{% endif %}

<!-- Buttons to show and hide nodes based on type-->
Expand Down

0 comments on commit dd51d0d

Please sign in to comment.