forked from jamesrom/jamesrom.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
87 lines (73 loc) · 1.55 KB
/
app.js
File metadata and controls
87 lines (73 loc) · 1.55 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
var data = [];
var mouseX;
//Function to move components to front from D3
d3.selection.prototype.moveToFront = function() {
return this.each(function(){
this.parentNode.appendChild(this);
});
};
function init() {
$(window).on('resize', resize);
$('#chart').on('mousewheel', mouseWheel)
.on('mousedown', mouseDown);
Stats.start = moment().format("YYYY-MM-DD HH:mm:ss");
resize();
}
function flairColor(seconds) {
if (seconds > 51) {
return '#820080';
}
if (seconds > 41) {
return '#0083C7';
}
if (seconds > 31) {
return '#02be01';
}
if (seconds > 21) {
return '#E5D900';
}
if (seconds > 11) {
return '#e59500';
}
return '#e50000';
}
function resize() {
Chart.resize();
Stats.resize();
Timer.resize();
Comms.resize();
if ($(window).width() < 400) {
$('.footer.twitter, .footer.web').hide();
}
else {
$('.footer.twitter, .footer.web').show();
}
}
//Mouse functions
function mouseWheel(e) {
e = window.event || e;
var deltaY = Math.max(-1, Math.min(1, (e.deltaFactor ? e.deltaY : -e.deltaY) || e.wheelDelta));
Chart.zoom(deltaY, e.pageX);
Chart.render(data);
Timer.updateBar();
}
function mouseDown(e) {
//e = window.event || e;
mouseX = e.pageX;
//Bind scrolling functions
$(window).on('mousemove', mouseMove)
.on('mouseup', mouseUp);
}
function mouseMove(e) {
mouseDelta = mouseX - e.pageX;
mouseX = e.pageX;
Chart.scroll(mouseDelta);
Chart.render(data);
Timer.updateBar();
e.preventDefault();
}
function mouseUp(e) {
//Unbind scrolling functions
$(window).off('mousemove')
.off('mouseup');
}