-
Notifications
You must be signed in to change notification settings - Fork 19
/
index.html
166 lines (146 loc) · 6.1 KB
/
index.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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>UMR LASTIG teams</title>
<script type="text/javascript" src="js/vis-network.min.js"></script>
<link rel="stylesheet" href="css/rSlider.min.css">
<script src="js/rSlider.min.js"></script>
<style type="text/css">
#mynetwork {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
}
#filter {
position: absolute;
bottom: 0;
left: 5%;
width: 90%;
}
</style>
</head>
<body>
<div id="filter">
<input type="checkbox" name="checkFilter" id="team" checked=""><label>Teams</label><br/>
<input type="checkbox" name="checkFilter" id="perm" checked=""><label>Permanent staff</label><br/>
<input type="checkbox" name="checkFilter" id="temp" checked=""><label>Temporary staff</label><br/>
<input type="checkbox" name="checkFilter" id="member"><label>Current staff only</label><br/>
<label>Double-click on teams or people to check their websites.</label><br/>
<input type="text" id="dateSlider" />
</div>
<div id="mynetwork"></div>
<script type="text/javascript">
const root = 'https://www.umr-lastig.fr';
const today = new Date();
const YYYY = today.getFullYear();
const removeAccents = str => str.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
function init(people) {
// create an array with nodes
var nodes = new vis.DataSet([]);
var edges = new vis.DataSet([]);
nodes.add({id:'LASTIG', shape:'image', size:50, image: root+'/img/lastig_400.png', href: root});
nodes.add({id:'ACTE', label:'ACTE', group:'team', image: root+'/img/icons/logo_acte_1280.png', href: root+'/acte/'});
nodes.add({id:'GEOVIS', label:'GEOVIS', group:'team', image: root+'/img/icons/logo_geovis_1280.png', href: root+'/geovis/'});
nodes.add({id:'STRUDEL', label:'STRUDEL', group:'team', image: root+'/img/icons/logo_strudel_1280.png', href: root+'/strudel/'});
nodes.add({id:'MEIG', label:'MEIG', group:'team', image: root+'/img/icons/logo_meig_1280.png', href: root+'/meig/'});
// "firstname","alt_firstname","lastname","team","statut","status","webpage","HAL","start_date","end_date","member","photo","perm"
for(const line of people.split('\n')) {
const cols = line.trim().split(',').map(s => s.startsWith('"') ? s.substr(1,s.length-2) : s);
if(cols.length < 3 || cols[0]=='firstname') continue;
const firstname = cols[0];
// const alt_firstname = cols[1];
const lastname = cols[2];
const team = cols[3];
// const statut = cols[4];
// const status = cols[5];
const href = (cols[6]===undefined) ? undefined : ((cols[6].startsWith('http'))? cols[6] : (root+cols[6]));
const HAL = cols[7];
const start_date = cols[8]!='' ? new Date(cols[8]) : undefined;
const end_date = cols[9]!='' ? new Date(cols[9]) : undefined;
// const member = cols[10] == 'true';
const member = !(today < start_date || end_date < today); // handles undefined dates as +- infinity
// const photo = cols[11];
const perm = cols[12] == 'true';
const label = firstname+'\n'+lastname;
const id = (HAL || removeAccents(firstname+'-'+lastname).replace(' ','-')).toLowerCase();
const image = "user/"+id+".jpg";
const node = { id: id, label:label, group:'people', image: image, opacity:member?1:0.3, href: href, perm: perm, member: member, start: start_date, end: end_date};
nodes.add(node);
edges.add({ from: id, to: team});
}
edges.add({ from: 'clement-mallet', to: 'LASTIG'});
edges.add({ from: 'ana-maria-olteanu-raimond', to: 'LASTIG'});
edges.add({ from: 'ACTE', to: 'LASTIG'});
edges.add({ from: 'MEIG', to: 'LASTIG'});
edges.add({ from: 'GEOVIS', to: 'LASTIG'});
edges.add({ from: 'STRUDEL', to: 'LASTIG'});
// create a network
const nodeFilterValues = {};
var mySlider = new rSlider({
target: '#dateSlider',
values: {min: 1995, max: YYYY+5},
step: 1,
range: true,
tooltip: true,
scale: true,
labels: false,
set: [YYYY, YYYY],
onChange: function(values) { nodesView.refresh(); }
});
nodeFilterValues.start = mySlider.values.start;
nodeFilterValues.end = mySlider.values.end;
const checkFilters = document.getElementsByName("checkFilter");
const nodesFilter = (node) => {
if (node.group != "people") return nodeFilterValues.team;
const end = node.end === undefined || mySlider.conf.values[mySlider.values.start] <= node.end .getFullYear();
const start = node.start === undefined || mySlider.conf.values[mySlider.values.end] >= node.start.getFullYear();
return (start && end) &&
(node.perm === undefined || (node.perm ? nodeFilterValues.perm : nodeFilterValues.temp)) &&
(node.member || !nodeFilterValues.member);
};
const edgesFilter = (edge) => {
return true;
};
const nodesView = new vis.DataView(nodes, { filter: nodesFilter });
const edgesView = new vis.DataView(edges, { filter: edgesFilter });
checkFilters.forEach((filter) => {
nodeFilterValues[filter.id] = filter.checked;
filter.addEventListener("change", (e) => {
const {id, checked} = e.target;
nodeFilterValues[id] = checked;
nodesView.refresh();
});
});
var container = document.getElementById("mynetwork");
var data = {
nodes: nodesView,
edges: edgesView,
};
var options = {
groups: {
team : {shape:'circularImage', size:60},
people: {shape:'circularImage', size:25}
}
};
var network = new vis.Network(container, {}, options);
network.on( 'doubleClick', function(properties) {
const nodeId = network.getNodeAt({x:properties.event.srcEvent.offsetX, y:properties.event.srcEvent.offsetY});
const node = nodeId && nodes.get(nodeId);
if (node) window.location=node.href;
});
network.on( 'click', function(properties) {
const nodeId = network.getNodeAt({x:properties.event.srcEvent.offsetX, y:properties.event.srcEvent.offsetY});
const node = nodeId && nodes.get(nodeId);
if (node) console.log(node);
});
nodesView.refresh();
network.setData(data);
}
fetch("people.csv").then(response => response.text()).then(init);
</script>
</body>
</html>