app=angular.module('app', []); app.controller('main', function($scope,$http,$interval) { var ROOT_PATH="/backend/"; $scope.searchlist=[] $scope.results = []; $scope.book=""; $scope.extension=""; $scope.activeTab = 'SEARCH'; //ws = new WebSocket("wss://books.davidventura.com.ar/ws/"); ws = new WebSocket("ws://david-dotopc.labs:8099/"); ws.onmessage = function(event) { var j = JSON.parse(event.data); console.log(j); $scope.$apply(function() { $scope.searchlist=j['SEARCH']; $scope.results=j['BOOKS']; }); }; $scope.download = function(book) { ws.send(JSON.stringify({"type":"BOOK","book":book})); }; $scope.newElement = function(bool){ $scope.new = bool; } $scope.searchBook = function(book,extension){ ws.send(JSON.stringify({"type":"search","book":book,"extension":extension})); }; $scope.isActiveTab = function(tab){ return $scope.activeTab === tab; } $scope.changeTab = function(tab){ $scope.activeTab = tab; } $scope.limit = {}; $scope.showMore = function(l){ $scope.limit[l.ID] = $scope.limit[l.ID] ? undefined : l.OUT.length; } $scope.clean = function(s) { s = s.replace(/\(.*?\)/g, ''); s.replace(/\s+/g, " "); s.replace(/\s+\./g, "."); return s; } }); app.directive('progressBar', function(){ return { template: '
{{progress}}%
', restrict: 'E', scope: { progress: '=' }, link: function(scope, elem, attrs){ console.log('progress', scope.progress, elem, attrs); } } });