git ssb

2+

dinoworm 🐛 / ssb-graphviz



Commit 017dccaf96ae1acdf1a35abe8d1c90e213c964f8

show foaf highlighting?

mix irving committed on 12/7/2016, 9:58:04 AM
Parent: 41ec31f643175bf360ff1416e6448bffcccb4212

Files changed

graph.jschanged
index.jschanged
graph.jsView
@@ -1,7 +1,6 @@
11 const pull = require('pull-stream')
22 const Sbot = require('ssb-client')
3-const avatar = require('ssb-avatar')
43 const waterfall = require('run-waterfall')
54
65 const { keys } = Object
76
@@ -21,9 +20,16 @@
2120 ], cb)
2221 }
2322
2423 function buildNodes(friends) {
25- return keys(friends).map(id => ({ id }) )
24 + return keys(friends).map(id => {
25 + return {
26 + id,
27 + data: {
28 + friends: keys(friends[id])
29 + }
30 + }
31 + })
2632 }
2733
2834 function buildLinks(friends) {
2935 return keys(friends).reduce((sofar, friend) => {
index.jsView
@@ -2,14 +2,15 @@
22 const Path = require('path')
33 const fromJson = require('ngraph.fromjson')
44 const Renderer = require('ngraph.pixel')
55 const Graph = require('./graph')
6 +const avatar = require('ssb-avatar')
67
78 const config = {
89 physics: {
910 springLength : 80,
10- springCoeff : 0.00005,
11- gravity: -0.4,
11 + springCoeff : 0.0001,
12 + gravity: -1.4,
1213 theta : 0.4,
1314 dragCoeff : 0.04
1415 },
1516 link: (link) => {
@@ -32,20 +33,37 @@
3233
3334 display.on('nodehover', handleNodeHover)
3435 cb(null, display)
3536
36-
3737 function handleNodeHover (node) {
3838 if (node === undefined) return
39- console.log('handleNodeHover node: ', node)
39 + // avatar(sbot, node.id, node.id, (err, data) => console.log(err, data))
4040
41- node.links
42- .map(link => display.getLink(link.id))
43- .forEach(linkUI => {
44- let color = 0x80ffffff
45- linkUI.fromColor = color
46- linkUI.toColor = color
47- })
41 + display.forEachLink(linkUI => {
42 + const { from, to } = linkUI
43 + const friends = node.data.friends
44 +
45 + const involvesFoaF = friends.indexOf(from.id) > -1 || friends.indexOf(to.id) > -1
46 + const isFromTarget = node.id === from.id
47 + const isToTarget = node.id === to.id
48 +
49 + let fromColor = 0x000066
50 + let toColor = 0x000066
51 +
52 + if (involvesFoaF) {
53 + fromColor = 0xeeeeee
54 + toColor = 0xeeeeee
55 + } else if (isFromTarget) {
56 + fromColor = 0x00ff00
57 + } else if (isToTarget) {
58 + toColor = 0xff0000
59 + }
60 +
61 + linkUI.fromColor = fromColor
62 + linkUI.toColor = toColor
63 + })
64 +
65 +
4866 }
4967 })
5068 }
5169

Built with git-ssb-web