-
Notifications
You must be signed in to change notification settings - Fork 941
Expand file tree
/
Copy pathtarget-base-position.ts
More file actions
51 lines (41 loc) · 1.7 KB
/
target-base-position.ts
File metadata and controls
51 lines (41 loc) · 1.7 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
/// <reference path="../common/models.ts" />
/// <reference path="../common/messaging.ts" />
/// <reference path="shared_directives.ts"/>
/// <reference path="pair.ts"/>
import angular = require("angular");
import Models = require("../common/models");
import io = require("socket.io-client");
import moment = require("moment");
import Messaging = require("../common/messaging");
import Pair = require("./pair");
import Shared = require("./shared_directives");
interface TargetBasePositionScope extends ng.IScope {
targetBasePosition : number;
}
var TargetBasePositionController = ($scope : TargetBasePositionScope, $log : ng.ILogService, subscriberFactory : Shared.SubscriberFactory) => {
var update = (value : Models.TargetBasePositionValue) => {
if (value == null) return;
$scope.targetBasePosition = value.data;
};
var subscriber = subscriberFactory.getSubscriber($scope, Messaging.Topics.TargetBasePosition)
.registerDisconnectedHandler(() => $scope.targetBasePosition = null)
.registerSubscriber(update, us => us.forEach(update));
$scope.$on('$destroy', () => {
subscriber.disconnect();
$log.info("destroy target base position");
});
$log.info("started target base position");
};
export var targetBasePositionDirective = "targetBasePositionDirective";
angular
.module(targetBasePositionDirective, ['sharedDirectives'])
.directive("targetBasePosition", () => {
var template = '<span>{{ targetBasePosition|number:2 }}</span>';
return {
restrict: 'E',
replace: true,
transclude: false,
template: template,
controller: TargetBasePositionController
}
});