summaryrefslogtreecommitdiffstats
path: root/js/controller
diff options
context:
space:
mode:
Diffstat (limited to 'js/controller')
-rw-r--r--js/controller/ExploreController.js37
1 files changed, 24 insertions, 13 deletions
diff --git a/js/controller/ExploreController.js b/js/controller/ExploreController.js
index 4bc3a6d3e..16d263ed3 100644
--- a/js/controller/ExploreController.js
+++ b/js/controller/ExploreController.js
@@ -8,22 +8,33 @@
* @copyright Bernhard Posselt 2014
*/
app.controller('ExploreController', function (sites, $rootScope, FeedResource) {
- 'use strict';
+ 'use strict';
- this.sites = sites;
+ this.sites = sites;
+ // join all sites
+ this.feeds = Object.keys(sites).map(function (key) {
+ return [key, sites[key]];
+ }).reduce(function (xs, x) {
+ var category = x[0];
+ var feedList = x[1];
+ feedList.forEach(function (feed) {
+ feed.category = category;
+ });
+ return xs.concat(feedList);
+ }, []);
- this.feedExists = function (location) {
- return FeedResource.getByLocation(location) !== undefined;
- };
+ this.feedExists = function (location) {
+ return FeedResource.getByLocation(location) !== undefined;
+ };
- this.subscribeTo = function (location) {
- $rootScope.$broadcast('addFeed', location);
- };
+ this.subscribeTo = function (location) {
+ $rootScope.$broadcast('addFeed', location);
+ };
- this.isCategoryShown = function (data) {
- return data.filter(function (element) {
- return FeedResource.getByLocation(element.feed) === undefined;
- }).length > 0;
- };
+ this.isCategoryShown = function (data) {
+ return data.filter(function (element) {
+ return FeedResource.getByLocation(element.feed) === undefined;
+ }).length > 0;
+ };
}); \ No newline at end of file