blob: d7d2cf0642b8328f66ef819f199a1bedb43e5644 [file] [log] [blame]
Simon Hunt8a9cee32016-01-08 14:11:26 -08001/*
2 * Copyright 2016 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17// js for UI Reference App extra view
18(function () {
19 'use strict';
20
21 // injected refs
22 var $log, $scope, wss, ks, flash;
23
24 // constants -- may be used in future
25 var dataReq = 'uiRefExtraDataRequest',
26 dataResp = 'uiRefExtraDataResponse';
27
28
29 function doOpen() {
30 flash.flash('++ OPEN ++');
31 }
32
33 function doClose() {
34 flash.flash('++ CLOSE ++');
35 }
36
37 function keyFallback(token, key, code, event) {
38 $log.debug('Fallback keystroke:', token, key, code, event);
39 }
40
41 function addKeyBindings() {
42 var map = {
43 openBracket: [doOpen, 'open function'],
44 closeBracket: [doClose, 'close function'],
45
46 _helpFormat: [
47 ['openBracket', 'closeBracket']
48 ]
49 };
50
51 // map explicit key bindings
52 ks.keyBindings(map);
53
54 // provide a fallback key handler for any other keys
55 ks.keyBindings(keyFallback);
56 }
57
58 //function getData() {
59 // wss.sendEvent(dataReq);
60 //}
61 //
62 //function respDataCb(data) {
63 // $scope.data = data;
64 // $scope.$apply();
65 //}
66
67
68 angular.module('ovUiRefExtra', [])
69 .controller('OvUiRefExtraCtrl',
70 ['$log', '$scope', 'WebSocketService', 'KeyService', 'FlashService',
71
72 function (_$log_, _$scope_, _wss_, _ks_, _flash_) {
73 $log = _$log_;
74 $scope = _$scope_;
75 wss = _wss_;
76 ks = _ks_;
77 flash = _flash_;
78
79 //var handlers = {};
80 //$scope.data = {};
81
82 // data response handler
83 //handlers[dataResp] = respDataCb;
84 //wss.bindHandlers(handlers);
85
86 addKeyBindings();
87
88 // Extra click handler
89 //$scope.getData = getData;
90
91 // get data the first time...
92 //getData();
93
94 // cleanup
95 $scope.$on('$destroy', function () {
96 //wss.unbindHandlers(handlers);
97 ks.unbindKeys();
98 $log.log('OvUiRefExtraCtrl has been destroyed');
99 });
100
101 $log.log('OvUiRefExtraCtrl has been created');
102 }]);
103
104}());