diff --git a/web/app/app.js b/web/app/app.js index 30de9f59..4137a743 100644 --- a/web/app/app.js +++ b/web/app/app.js @@ -13,7 +13,8 @@ angular.module('myApp', [ 'myApp.enabledExchanges', 'myApp.buyOrders', 'myApp.sellOrders', - 'myApp.stringUtils' + 'myApp.stringUtils', + 'myApp.webSocket' ]). config(['$locationProvider', '$routeProvider', 'NotificationProvider', function($locationProvider, $routeProvider, NotificationProvider) { NotificationProvider.setOptions({ diff --git a/web/app/components/helpers/stringUtils.js b/web/app/components/helpers/stringUtils.js index 8f10d6b0..dd8a8cd6 100644 --- a/web/app/components/helpers/stringUtils.js +++ b/web/app/components/helpers/stringUtils.js @@ -1,25 +1,9 @@ angular.module('myApp.stringUtils', []) - .filter('removeSpaces', [function () { - return function (string) { - if (!angular.isString(string)) { - return string; - } - return string.replace(/[\s]/g, ''); - }; - }]); -/* - angular.module('myApp.currenctExchangeFactory', []).factory('currentExchangeCurrency', function() { - var currentExchangeAndCurrency = {}; - var exchangeService = {}; - - exchangeService.get = function() { - return currentExchangeAndCurrency; - }; - exchangeService.update = function(exchange, currency) { - currentExchangeAndCurrency.Exchange = exchange; - currentExchangeAndCurrency.Currency = currency; - }; - - return exchangeService; -}); -*/ + .filter('removeSpaces', [function() { + return function(string) { + if (!angular.isString(string)) { + return string; + } + return string.replace(/[\s]/g, ''); + }; + }]); \ No newline at end of file diff --git a/web/app/components/helpers/webSocket.js b/web/app/components/helpers/webSocket.js new file mode 100644 index 00000000..a706658d --- /dev/null +++ b/web/app/components/helpers/webSocket.js @@ -0,0 +1,21 @@ +angular.module('myApp.webSocket', ['ngWebSocket']) + .factory('webSocket', function($websocket) { + // Open a WebSocket connection + var dataStream = $websocket('ws://localhost:9050/'); + + var collection = []; + + dataStream.onMessage(function(message) { + collection.push(JSON.parse(message.data)); + }); + + var methods = { + collection: collection, + get: function() { + dataStream.send(JSON.stringify({ action: 'get' })); + } + }; + + return methods; + + }) \ No newline at end of file diff --git a/web/app/index.html b/web/app/index.html index a7aa6939..2f799735 100644 --- a/web/app/index.html +++ b/web/app/index.html @@ -25,7 +25,7 @@
-