4dbe208f38cedb32b68f1f6cc09a621dd32f3dad
[unimgr.git] / dlux / cpeui / cpeui-module / src / main / resources / cpeui / services / utils.js
1 define([ 'app/cpeui/cpeui.module' ], function(cpeui) {
2
3   Array.prototype.filterByField = function(field_name, value, to_filter_out) {
4       if (to_filter_out == undefined) {
5           to_filter_out = false;
6       }
7       return this.filter(function(item) {
8           return (item[field_name] == value) != to_filter_out;
9       });
10   };
11
12   cpeui.factory('Utils', function() {
13       var svc = {};
14
15       svc.randomId = function () {
16           return Math.floor(Math.random() * Math.pow(2, 31));
17       };
18       return svc;
19   });
20
21 });