summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--js/news.js45
-rw-r--r--templates/part.items.php2
2 files changed, 30 insertions, 17 deletions
diff --git a/js/news.js b/js/news.js
index 4c71e2a90..013e44598 100644
--- a/js/news.js
+++ b/js/news.js
@@ -91,20 +91,20 @@ News={
import:function(button){
$(button).attr("disabled", true);
$(button).prop('value', t('news', 'Importing...'));
-
+
var path = '';
if (News.Opml.importkind == 'cloud') {
path = News.Opml.importpath;
} else {
-
+
}
$.post(OC.filePath('news', 'ajax', 'importopml.php'), { path: path }, function(jsondata){
if (jsondata.status == 'success') {
alert(jsondata.data.title);
}
- });
-
+ });
+
}
},
Folder: {
@@ -200,18 +200,31 @@ News={
});
return false;
},
- markItem:function(itemid) {
- $.post(OC.filePath('news', 'ajax', 'markitem.php'),{'itemid':itemid},function(jsondata){
- if(jsondata.status == 'success'){
- var $currentitem = $('#rightcontent [data-id="'+jsondata.data.itemid+'"]');
- $currentitem.removeClass('title_unread');
- $currentitem.addClass('title_read');
- //set a timeout for this
- }
- else{
- OC.dialogs.alert(jsondata.data.message, t('news', 'Error'));
- }
- });
+ markItem:function(itemid, feedid) {
+ var currentitem = $('#rightcontent [data-id="' + itemid + '"]');
+ if (currentitem.hasClass('title_unread')) {
+ $.post(OC.filePath('news', 'ajax', 'markitem.php'),{'itemid':itemid},function(jsondata){
+ if(jsondata.status == 'success'){
+ currentitem.removeClass('title_unread');
+ currentitem.addClass('title_read');
+
+ // decrement counter
+ var counterplace = $('.feeds_list[data-id="'+feedid+'"]').find('#unreaditemcounter');
+ var oldcount = counterplace.html();
+ counterplace.empty();
+ if (--oldcount <= 0) {
+ counterplace.removeClass('nonzero').addClass('zero');
+ }
+ else {
+ counterplace.append(--oldcount);
+ }
+ //set a timeout for this
+ }
+ else{
+ OC.dialogs.alert(jsondata.data.message, t('news', 'Error'));
+ }
+ })
+ };
},
updateAll:function() {
$.post(OC.filePath('news', 'ajax', 'feedlist.php'),function(jsondata){
diff --git a/templates/part.items.php b/templates/part.items.php
index 24ca958e9..c1619085e 100644
--- a/templates/part.items.php
+++ b/templates/part.items.php
@@ -15,7 +15,7 @@ foreach($items as $item) {
echo ' class="title_read">';
}
else {
- echo ' class="title_unread" onClick="News.Feed.markItem(' . $item->getId() . ')">';
+ echo ' class="title_unread" onClick="News.Feed.markItem(' . $item->getId() . ',' . $feedid . ')">';
}
echo $title . '</div><div class="body">' . $item->getBody() . '</div>';
echo '</li>';