Merge "Add qtip job to pod zte-virtual6"
[releng.git] / utils / test / testapi / 3rd_party / static / testapi-ui / shared / filters.js
1 /*
2  * Licensed under the Apache License, Version 2.0 (the "License");
3  * you may not use this file except in compliance with the License.
4  * You may obtain a copy of the License at
5  *
6  * http://www.apache.org/licenses/LICENSE-2.0
7  *
8  * Unless required by applicable law or agreed to in writing, software
9  * distributed under the License is distributed on an "AS IS" BASIS,
10  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11  * See the License for the specific language governing permissions and
12  * limitations under the License.
13  */
14
15 (function () {
16     'use strict';
17
18     /**
19      * Convert an object of objects to an array of objects to use with ng-repeat
20      * filters.
21      */
22     angular
23         .module('testapiApp')
24         .filter('arrayConverter', arrayConverter);
25
26     /**
27      * Convert an object of objects to an array of objects to use with ng-repeat
28      * filters.
29      */
30     function arrayConverter() {
31         return function (objects) {
32             var array = [];
33             angular.forEach(objects, function (object, key) {
34                 if (!('id' in object)) {
35                     object.id = key;
36                 }
37                 array.push(object);
38             });
39             return array;
40         };
41     }
42
43     angular
44         .module('testapiApp')
45         .filter('capitalize', capitalize);
46
47     /**
48      * Angular filter that will capitalize the first letter of a string.
49      */
50     function capitalize() {
51         return function (string) {
52             return string.substring(0, 1).toUpperCase() + string.substring(1);
53         };
54     }
55 })();