-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnews.js
More file actions
28 lines (19 loc) · 749 Bytes
/
news.js
File metadata and controls
28 lines (19 loc) · 749 Bytes
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
function news(id) {
setInterval(function(){
YUI().use('yql', function(Y){
var x = Math.floor((Math.random() * 2) + 1);
if (x==1) {
var query = 'select * from rss where url = "http://www.hindustantimes.com/rss/topnews/rssfeed.xml"'}
else if (x==2) {
var query = 'select * from rss where url = "http://www.hindustantimes.com/rss/cities/delhi/rssfeed.xml"'
}
var q = Y.YQL(query, function(r){
//r now contains the result of the YQL Query as a JSON
console.log(r);
var _randomIndex= Math.floor(Math.random() *(r['query'].results['item']).length );
var msg= r['query'].results['item'][_randomIndex].title;
document.getElementById('txt2').innerHTML =msg;
})
})
}, 3000);
}