forked from evancohen/smart-mirror
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* RSS Service (evancohen#161) * Create rss-service * RSS service * Support for RSS service * RSS service * Update index.html * RSS service * minor updates * Added rss-service * Randomize the news * Revert "Randomize the news" This reverts commit ef94678. * RSS fixes * RSS fixes * RSS fixes * removing rss-service.js * Fixing an unpextec line issue after merge * RSS display fixes * RSS display fixes * RSS display fixes * Removing ding as a result of evancohen#287 The ding was causing a freeze in a rewind. This is a temporary workaround to stop the keyword spotter from hanging after a few utterances.
- Loading branch information
Showing
8 changed files
with
117 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
(function(annyang) { | ||
'use strict'; | ||
|
||
function RssService($http) { | ||
var service = {}; | ||
service.feed = []; | ||
service.currentFeed = 0; | ||
|
||
service.init = function() { | ||
service.feed = []; | ||
service.currentFeed = 0; | ||
var currentTime = new moment(); | ||
|
||
angular.forEach(config.rss.feeds, function(url) { | ||
$http.jsonp('http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=50&callback=JSON_CALLBACK&q=' + encodeURIComponent(url)).then(function(response) { | ||
for (var i=0; i < response.data.responseData.feed.entries.length; i++){ | ||
var feedEntry = { | ||
title : response.data.responseData.feed.title, | ||
content: response.data.responseData.feed.entries[i].title, | ||
lastUpdated : currentTime, | ||
}; | ||
//console.log(feedEntry); | ||
service.feed.push(feedEntry); | ||
} | ||
}); | ||
}); | ||
return service.feed; | ||
}; | ||
|
||
service.refreshRssList = function() { | ||
return service.init(); | ||
}; | ||
|
||
service.getNews = function() { | ||
if (service.feed == null) { | ||
return null; | ||
} | ||
switch (config.rss.mode) { | ||
case 'random': | ||
service.currentFeed = Math.floor(Math.random() * service.feed.length); | ||
break; | ||
|
||
case 'sequence': | ||
default: | ||
if (service.currentFeed == (service.feed.length-1)){ | ||
service.currentFeed = 0; | ||
} | ||
else { | ||
service.currentFeed = service.currentFeed + 1; | ||
} | ||
}; | ||
return service.feed[service.currentFeed]; | ||
} ; | ||
|
||
return service; | ||
} | ||
|
||
angular.module('SmartMirror') | ||
.factory('RssService', RssService); | ||
}(window.annyang)); |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters