summaryrefslogtreecommitdiffstats
path: root/js/main.js
blob: efe4728b3db388859c2e3016599719f7cb2539cb (plain)
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/**
 * Nextcloud - contacts
 *
 * This file is licensed under the Affero General Public License version 3 or
 * later. See the COPYING file.
 *
 * @author Hendrik Leppelsack <hendrik@leppelsack.de>
 * @copyright Hendrik Leppelsack 2015
 */

/** findIndex polyfill */
if (!Array.prototype.findIndex) {
	Object.defineProperty(Array.prototype, 'findIndex', {
		value: function(predicate) {
			// 1. Let O be ? ToObject(this value).
			if (this == null) {
				throw new TypeError('"this" is null or not defined');
			}

			var o = Object(this);

			// 2. Let len be ? ToLength(? Get(O, "length")).
			var len = o.length >>> 0;

			// 3. If IsCallable(predicate) is false, throw a TypeError exception.
			if (typeof predicate !== 'function') {
				throw new TypeError('predicate must be a function');
			}

			// 4. If thisArg was supplied, let T be thisArg; else let T be undefined.
			var thisArg = arguments[1];

			// 5. Let k be 0.
			var k = 0;

			// 6. Repeat, while k < len
			while (k < len) {
				// a. Let Pk be ! ToString(k).
				// b. Let kValue be ? Get(O, Pk).
				// c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
				// d. If testResult is true, return k.
				var kValue = o[k];
				if (predicate.call(thisArg, kValue, k, o)) {
					return k;
				}
				// e. Increase k by 1.
				k++;
			}

			// 7. Return -1.
			return -1;
		},
		configurable: true,
		writable: true
	});
}

angular
	.module('contactsApp', [
		'uuid4',
		'angular-cache',
		'ngRoute',
		'ui.bootstrap',
		'ui.select',
		'ngSanitize',
		'angular-click-outside',
		'ngclipboard'
	])
	.config(function($routeProvider) {
		$routeProvider.when('/:gid', {
			template: '<contactdetails></contactdetails>'
		});

		$routeProvider.when('/contact/:uid', {
			redirectTo: function(parameters) {
				return ('/' + t('contacts', 'All contacts') + '/' + parameters.uid);
			}
		});

		$routeProvider.when('/:gid/:uid', {
			template: '<contactdetails></contactdetails>'
		});

		$routeProvider.otherwise('/' + t('contacts', 'All contacts'));
	});