-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
55 lines (53 loc) · 2.14 KB
/
index.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
////////////////////////////////////////////////////////////////////////////
// Initialize SuperSlide
////////////////////////////////////////////////////////////////////////////
$(function ()
{
$('#fullpageslider').superslides(
{
hashchange: false
});
});
////////////////////////////////////////////////////////////////////////////
// connect to webTrading push notification service
////////////////////////////////////////////////////////////////////////////
var socket = io.connect('http://localhost:8000',
{
'sync disconnect on unload': true
});
window.onbeforeunload = function ()
{
socket.disconnect();
};
////////////////////////////////////////////////////////////////////////////
// Angular module
////////////////////////////////////////////////////////////////////////////
var app = angular.module('weBTrading', ['weBTrading.graph',
'weBTrading.pie',
'weBTrading.col',
'weBTrading.historical',
'weBTrading.candlestick']);
////////////////////////////////////////////////////////////////////////
// Get Acocount realtime data from push service
////////////////////////////////////////////////////////////////////////
app.run(function ()
{
socket.on('notification', function (data)
{
var slide2Scope = angular.element($('#slide2')).scope();
var slide1Scope = angular.element($('#slide1')).scope();
// Every X second
if (data.Ballance)
{
slide2Scope.updateAccountData(data);
slide2Scope.updateBallanceGraph(data);
slide1Scope.updatePossitionLine(data);
}
// Every sell order
else
{
slide1Scope.updateShareDashboard();
slide2Scope.updateHistoricalPositionsDataByTime(undefined, undefined);
}
});
});