-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathscanimage-client.js
More file actions
52 lines (38 loc) · 1.44 KB
/
scanimage-client.js
File metadata and controls
52 lines (38 loc) · 1.44 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
angular.module('ui.scanimage.web', ['ngAnimate', 'ui.bootstrap', 'btford.socket-io']);
angular.module('ui.scanimage.web').controller('ScanImageCtrl', function ($scope, socket) {
$scope.inProgress = false;
$scope.scanFinished = false;
$scope.colorMode = 'Color';
$scope.resolution = '300';
$scope.currentProgress = 0.0;
socket.forward('progressEvent', $scope);
socket.forward('scanDoneEvent', $scope);
$scope.$on('socket:progressEvent', function (ev, data) {
// todo: improve parsing stuff, as data gets send multiple times at once sometimes
//console.log('got data: ' + data);
var progress = data.slice(10,-1);
//console.log(progress);
$scope.currentProgress = parseFloat(progress);
});
$scope.$on('socket:scanDoneEvent', function (ev, data) {
$scope.scanFinished = true;
$scope.inProgress = false;
$scope.currentProgress = 0.0;
});
$scope.startScanning = function() {
theData = { 'resolution': $scope.resolution,
'fileName': $scope.fileName,
'colorMode': $scope.colorMode };
socket.emit('parameterEvent', theData);
$scope.inProgress = true;
$scope.scanFinished = false;
};
$scope.stopScanning = function() {
socket.emit('stopScanEvent','1');
$scope.inProgress = false;
$scope.scanFinished = false;
};
}).
factory('socket', function (socketFactory) {
return socketFactory();
});