-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvisualize.js
88 lines (77 loc) · 2.64 KB
/
visualize.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import {QBIxora} from 'ixora'
import helper from './helper.js'
async function visualize_force_graph (req, detected, type) {
try {
const graph = new QBIxora('Social-Analyzer', false)
const temp_filtered = detected.filter(item => item.status === 'good')
if (temp_filtered.length > 0) {
if (req.body.group) {
graph.add_node(req.body.string, req.body.string, {
header: req.body.string
})
req.body.string.split(',').forEach(username => {
graph.add_node(username, username, {
header: username
})
graph.add_edge(username, req.body.string, {
width: 1
})
})
} else {
graph.add_node(req.body.string, req.body.string, {
header: req.body.string
})
}
temp_filtered.forEach(site => {
graph.add_node(site.link, site.link, {
header: site.link
})
graph.add_edge(site.username, site.link, {
width: 1
})
if ('metadata' in site) {
if (site.metadata !== 'unavailable' && site.metadata.length > 0) {
site.metadata.forEach(meta => {
if ('content' in meta) {
let temp_string = ''
if ('name' in meta) {
temp_string = meta.name + ' -> ' + meta.content
} else if ('itemprop' in meta) {
temp_string = meta.itemprop + ' -> ' + meta.content
} else if ('property' in meta) {
temp_string = meta.property + ' -> ' + meta.content
}
if (temp_string.length > 70) {
temp_string = temp_string.substring(0, 70).replace(/\r?\n|\r/g, '') + '..'
} else {
temp_string = temp_string.replace(/\r?\n|\r/g, '')
}
if (temp_string !== '' && temp_string.length > 0) {
graph.add_node(temp_string, temp_string, {
header: temp_string
})
graph.add_edge(site.link, temp_string, {
width: 1
})
}
}
})
}
}
})
}
const ret_graph = graph.create_graph('#ixora-graph', 'Ixora random nodes exmaple', 'Search Box', 'Search in extracted patterns', 'https://github.com/qeeqbox/ixora', 'Qeeqbox-ixora', ['search', 'tooltip'], 10, 100, graph.graph, 'object', undefined, undefined)
return ret_graph
} catch (err) {
helper.verbose && console.log(err)
}
return {
graph: {
nodes: [],
links: []
}
}
}
export default{
visualize_force_graph
}