forked from fungiboletus/JsCHRIST
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtable.js
More file actions
67 lines (56 loc) · 1.43 KB
/
table.js
File metadata and controls
67 lines (56 loc) · 1.43 KB
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
var JsCHRIST_Table = function(core, screen)
{
// Représente l'instance des données à traiter
this.core = core;
// Zonede travail du graphique
this.screen = screen;
this.div_table = newDom('div');
this.div_table.className = 'table';
var table = newDom('table');
var thead = newDom('thead');
var tr_head = newDom('tr');
thead.appendChild(tr_head);
table.appendChild(thead);
this.tbody = newDom('tbody');
table.appendChild(this.tbody);
this.div_table.appendChild(table);
this.screen.appendChild(this.div_table);
// Gestion de la taille de la zone
this.manageSize();
$(window).resize(this, this.manageSize);
var obj = this;
$(core).bind("jschrist.new_tuples", function(a, b)
{
for (var i = 0; i < b.data.length; ++i)
obj.addRow(b.data[i]);
});
}
JsCHRIST_Table.prototype =
{
// Gestion de la taille du graphe
manageSize: function(obj)
{
var obj = obj == null ? this : obj.data;
obj.width = $(obj.screen).width();
obj.height = $(obj.screen).height();
obj.div_table.style.maxHeight = obj.height+'px';
},
addRow: function(tuple)
{
var tr = newDom('tr');
var obj = this;
tr.onmouseover = function(e)
{
$(obj.core).trigger("jschrist.time_sync", {time_t: tuple.time_t});
}
for (var key in tuple)
{
var td = newDom('td');
td.appendChild(document.createTextNode(tuple[key]));
tr.appendChild(td);
}
this.tbody.appendChild(tr);
var t = $(this.div_table);
t.scrollTop(t.height()*1000);
}
}