Skip to content

Commit

Permalink
sub
Browse files Browse the repository at this point in the history
  • Loading branch information
Weedshaker committed Nov 4, 2024
1 parent 066ad1c commit f07546d
Showing 1 changed file with 92 additions and 0 deletions.
92 changes: 92 additions & 0 deletions test-p2p-graph.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/example/p2p-graph.js"></script>
<title>p2p-graph</title>
</head>
<body>
<style>
div > svg {
overflow: visible;
}
</style>
<div class=root>Hello World</div>
<script>
// https://github.com/feross/p2p-graph?tab=readme-ov-file
var graph = new P2PGraph('.root')

graph.on('select', function (id) {
console.log(id + ' selected!')
})

// Add Providers
graph.add({
id: 'provider1',
me: true,
fixed: true,
name: 'heroku'
})
graph.add({
id: 'provider2',
me: true,
fixed: true,
name: 'localhost'
})
graph.add({
id: 'provider3',
me: true,
fixed: true,
name: 'astrangehost'
})
// Add Clients
graph.add({
id: 'client1',
name: 'Another Client'
})
graph.add({
id: 'client2',
name: 'Another Client'
})
graph.add({
id: 'client3',
name: 'Another Client'
})
graph.add({
id: 'client4',
name: 'Another Client'
})
graph.add({
id: 'client5',
name: 'Another Client'
})
graph.add({
id: 'client6',
name: 'Another Client'
})
graph.add({
id: 'client7',
name: 'Another Client'
})
// color green by isSeeding true
graph.seed('client5', true)
// Connect them
graph.connect('provider1', 'client1')
graph.connect('provider1', 'client2')
graph.connect('provider1', 'client3')
graph.connect('provider2', 'client4')
graph.connect('provider2', 'client5')
graph.connect('client1', 'provider2')
graph.connect('client2', 'provider2')
graph.connect('client6', 'provider3')
graph.connect('client7', 'provider3')
// speed
graph.rate('provider1', 'client3', 5000)
// Click behavior
graph.on('select', (id, ...args) => {console.log('*********', id, args)})

console.log(graph.list())
</script>
</body>
</html>

0 comments on commit f07546d

Please sign in to comment.