-
-
Notifications
You must be signed in to change notification settings - Fork 82
/
Copy pathcategories-service.js
37 lines (29 loc) · 983 Bytes
/
categories-service.js
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
angular
.module('nzbhydraApp')
.factory('CategoriesService', CategoriesService);
function CategoriesService(ConfigService) {
return {
getByName: getByName,
getAllCategories: getAllCategories,
getDefault: getDefault,
getWithoutAll: getWithoutAll
};
function getByName(name) {
for (var cat in ConfigService.getSafe().categoriesConfig.categories) {
var category = ConfigService.getSafe().categoriesConfig.categories[cat];
if (category.name === name) {
return category;
}
}
}
function getAllCategories() {
return ConfigService.getSafe().categoriesConfig.categories;
}
function getWithoutAll() {
var cats = ConfigService.getSafe().categoriesConfig.categories;
return cats.slice(1, cats.length);
}
function getDefault() {
return getByName(ConfigService.getSafe().categoriesConfig.defaultCategory);
}
}