- News widget max items is now configurable
- Update the news list whenever the loop over the current list is done
This commit is contained in:
parent
1b1016fba2
commit
f322f71447
1 changed files with 8 additions and 2 deletions
|
@ -3,6 +3,7 @@ $(document).ready(function() {
|
||||||
config = window.widgets['rss-news'],
|
config = window.widgets['rss-news'],
|
||||||
db = config.db,
|
db = config.db,
|
||||||
news = [],
|
news = [],
|
||||||
|
default_limit = 10,
|
||||||
cur_article_index = -1;
|
cur_article_index = -1;
|
||||||
|
|
||||||
var getNews = function() {
|
var getNews = function() {
|
||||||
|
@ -15,7 +16,8 @@ $(document).ready(function() {
|
||||||
query: "select s.title as source, e.title, e.summary, " +
|
query: "select s.title as source, e.title, e.summary, " +
|
||||||
"strftime('%Y-%m-%dT%H:%M:%fZ', e.published) as published " +
|
"strftime('%Y-%m-%dT%H:%M:%fZ', e.published) as published " +
|
||||||
"from FeedEntry e join FeedSource s " +
|
"from FeedEntry e join FeedSource s " +
|
||||||
"on e.source_id = s.id order by e.published desc limit 10"
|
"on e.source_id = s.id order by e.published desc limit " +
|
||||||
|
('limit' in config ? config.limit : default_limit)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -40,6 +42,7 @@ $(document).ready(function() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var updateNewsList = cur_article_index == news.length-1;
|
||||||
var nextArticle = news[++cur_article_index % news.length];
|
var nextArticle = news[++cur_article_index % news.length];
|
||||||
var dt = new Date(nextArticle.published);
|
var dt = new Date(nextArticle.published);
|
||||||
var $article = $('<div></div>').addClass('article');
|
var $article = $('<div></div>').addClass('article');
|
||||||
|
@ -57,11 +60,14 @@ $(document).ready(function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
$article.hide().appendTo($newsElement).fadeIn();
|
$article.hide().appendTo($newsElement).fadeIn();
|
||||||
|
|
||||||
|
if (updateNewsList) {
|
||||||
|
getNews();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var initWidget = function() {
|
var initWidget = function() {
|
||||||
getNews();
|
getNews();
|
||||||
setInterval(getNews, 600000);
|
|
||||||
setInterval(refreshNews, 15000);
|
setInterval(refreshNews, 15000);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue