summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlessandro Cosentino <cosenal@gmail.com>2012-07-26 19:20:21 -0400
committerAlessandro Cosentino <cosenal@gmail.com>2012-07-26 19:20:21 -0400
commitf80555a94cc1d2fb21233b538ef8a4dd140486ea (patch)
treed9861479d84b3f5b59d2f20520de52f96ebf80ae
parent3731be7db2273d76d55821cad34697bd5d7745a0 (diff)
shows a spinner while updating feed
-rw-r--r--css/news.css3
-rw-r--r--js/news.js28
-rw-r--r--templates/part.itemcounter.php5
3 files changed, 27 insertions, 9 deletions
diff --git a/css/news.css b/css/news.css
index 4d6d6d6ae..61cb8c001 100644
--- a/css/news.css
+++ b/css/news.css
@@ -16,7 +16,8 @@
#addfolder { background: url('%webroot%/core/img/places/folder.svg') no-repeat left center; padding-left: 20px !important; }
#addfeed { background: url('%appswebroot%/apps/news/img/rss.svg') no-repeat left center; padding-left: 20px !important; }
-#unreaditemcounter { position: relative; background: #5E5E5E; border-radius: 5px; padding: 0 5px; color: white; text-align: center; margin: 0 0.3em 0 0.3em;}
+#unreaditemcounter.nonzero { position: relative; background: #5E5E5E; border-radius: 5px; padding: 0 5px; color: white; text-align: center; margin: 0 0.3em 0 0.3em;}
+#unreaditemcounter.zero { position: relative; margin: 0 0.3em 0 0.3em;}
ul.controls li { float: left; }
diff --git a/js/news.js b/js/news.js
index 541d4e694..f2c5703f7 100644
--- a/js/news.js
+++ b/js/news.js
@@ -53,7 +53,8 @@ News={
cloudFileSelected:function(path){
$.getJSON(OC.filePath('news', 'ajax', 'selectfromcloud.php'),{'path':path},function(jsondata){
if(jsondata.status == 'success'){
- alert(jsondata.data.page);
+ $("#opml_file").prop('value', jsondata.data.tmp);
+
}
else{
OC.dialogs.alert(jsondata.data.message, t('news', 'Error'));
@@ -172,7 +173,7 @@ News={
if(jsondata.status == 'success'){
var feeds = jsondata.data;
for (var i = 0; i < feeds.length; i++) {
- News.Feed.updateFeed(feeds[i]['id'], feeds[i]['url'], feeds[i]['folderid']);
+ News.Feed.update(feeds[i]['id'], feeds[i]['url'], feeds[i]['folderid']);
}
}
else {
@@ -180,14 +181,26 @@ News={
}
});
},
- updateFeed:function(feedid, feedurl, folderid) {
+ update:function(feedid, feedurl, folderid) {
+ var counterplace = $('.feeds_list[data-id="'+feedid+'"]').find('#unreaditemcounter');
+ var oldcount = counterplace.html();
+ counterplace.removeClass('nonzero').addClass('zero');
+ counterplace.html('<img src="' + OC.imagePath('core','loader.gif') + '" alt="refresh" />');
$.post(OC.filePath('news', 'ajax', 'updatefeed.php'),{'feedid':feedid, 'feedurl':feedurl, 'folderid':folderid},function(jsondata){
if(jsondata.status == 'success'){
-
+ var newcount = oldcount;
+ if (newcount > 0) {
+ counterplace.addClass('nonzero');
+ }
+ counterplace.html(newcount);
}
else{
- //TODO:handle error case
+ if (oldcount > 0) {
+ counterplace.addClass('nonzero');
+ counterplace.html(oldcount);
+ }
}
+
});
}
}
@@ -242,8 +255,9 @@ $(document).ready(function(){
});
setupFeedList();
-
- var updateInterval = 500000; //how often the feeds should update (in msec)
+
+ News.Feed.updateAll();
+ var updateInterval = 20000; //how often the feeds should update (in msec)
setInterval('News.Feed.updateAll()', updateInterval);
});
diff --git a/templates/part.itemcounter.php b/templates/part.itemcounter.php
index ad24a991b..9a1127ea8 100644
--- a/templates/part.itemcounter.php
+++ b/templates/part.itemcounter.php
@@ -10,7 +10,10 @@ function countUnreadItems($feedid) {
++$counter;
}
if ($counter > 0) {
- echo '<span id="unreaditemcounter">' . $counter . '</span>';
+ echo '<span id="unreaditemcounter" class="nonzero">' . $counter . '</span>';
+ }
+ else {
+ echo '<span id="unreaditemcounter" class="zero"></span>';
}
}