-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathwidget_versioning.html
142 lines (130 loc) · 5.05 KB
/
widget_versioning.html
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<!DOCTYPE html>
<html>
<head>
<title>widget versioning</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="./assets/css/examples.css" />
<link rel="stylesheet" href="./assets/css/loading_screen.css" />
<link rel="stylesheet" href="./assets/css/widget_versioning.css" />
</head>
<body>
<script src="../dist/RUN_MODE/bundle.js"></script>
<script type="text/javascript">
const udviz = window.udviz;
const setColor = function (d, default_color, override_color = undefined) {
if (override_color) return override_color;
return default_color;
};
udviz
.loadMultipleJSON([
'./assets/config/widget/versioning_widget.json',
'./assets/config/server/sparql_versioning_server.json',
])
.then((configs) => {
const sparqlVersioningWidgetView =
new udviz.widgetVersioning.SparqlVersioningQueryWindow(
new udviz.widgetSPARQL.SparqlEndpointResponseProvider(
configs['sparql_versioning_server']
),
configs['versioning_widget']
);
sparqlVersioningWidgetView.addEventListeners({
mouseover: ({ event, datum, graphId }) => {
// Add mouseover event listener to the nodes of the d3Graphs
const node_value =
sparqlVersioningWidgetView.getNodesByIdGraphAndIdNode(
graphId,
datum.index
);
if (node_value !== undefined) {
sparqlVersioningWidgetView.d3Graphs.forEach((d3Graph) => {
const index = d3Graph.data.nodes.findIndex(
(d) => d.id === node_value
);
const nodes = d3Graph.data.nodes.map((d) => Object.create(d));
if (nodes[index] !== undefined) {
event.target.style['stroke'] = setColor(
nodes[index].color_id,
'white',
'white'
);
event.target.style['fill'] = setColor(
nodes[index].color_id,
'#333'
);
}
d3Graph.node_label
.filter((e, j) => {
return index == j;
})
.style('fill', 'white')
.style('opacity', '1');
d3Graph.link_label
.filter((e) => {
return index == e.source.index || index == e.target.index;
})
.style('fill', 'white')
.style('opacity', '1');
});
}
},
mouseout: function ({ event, datum, graphId }) {
// Add mouseout event listener to the nodes of the d3Graphs
const node_value =
sparqlVersioningWidgetView.getNodesByIdGraphAndIdNode(
graphId,
datum.index
);
if (node_value !== undefined) {
sparqlVersioningWidgetView.d3Graphs.forEach((d3Graph) => {
const index = d3Graph.data.nodes.findIndex(
(d) => d.id === node_value
);
const nodes = d3Graph.data.nodes.map((d) => Object.create(d));
if (nodes[index] !== undefined) {
event.target.style['stroke'] = setColor(
nodes[index].color_id,
'#ddd',
'#111'
);
event.target.style['fill'] = setColor(
nodes[index].color_id,
'white'
);
}
d3Graph.node_label
.filter((e, j) => {
return index == j;
})
.style('fill', 'lightgrey')
.style('opacity', '0.5');
d3Graph.link_label
.filter((e) => {
return (
index == e.source.index ||
index == e.target.index
);
})
.style('fill', 'lightgrey')
.style('opacity', '0.5');
});
}
},
click: ({ event, datum, graphId }) => {
// Add click event listener to the nodes of the d3Graphs
console.log('clicked node data:', event, datum, graphId);
},
});
sparqlVersioningWidgetView.domElement.classList.add(
'widget_versioning'
);
// Add UI
const uiDomElement = sparqlVersioningWidgetView.domElement;
uiDomElement.classList.add('full_screen');
document.body.appendChild(uiDomElement);
});
</script>
SCRIPT_TAG_RELOAD
</body>
</html>