diff --git a/modules/core/client/app/init.js b/modules/core/client/app/init.js index 75d14659..6b6c98d1 100644 --- a/modules/core/client/app/init.js +++ b/modules/core/client/app/init.js @@ -56,7 +56,7 @@ function writeLeaveTime(localStorageService, $window) { $window.onbeforeunload = function () { localStorageService.set('last_leave_time', Date.now()); - } + }; } markedConfig.$inject = ['markedProvider']; diff --git a/modules/core/client/app/trans-string-en.js b/modules/core/client/app/trans-string-en.js index 561addb0..52f2fdf7 100644 --- a/modules/core/client/app/trans-string-en.js +++ b/modules/core/client/app/trans-string-en.js @@ -677,6 +677,9 @@ DELETE_REPLY_CONFIRM_BODY_TEXT: 'Are you sure want to delete this reply?', READ_ONLY_POST: '*** Readonly forum, cannot to post topic!', READ_ONLY_REPLY: '*** Readonly topic, cannot to post reply!', + TODAY_NEW_COUNT_ALL: '(Today: {{topic}} topics, {{reply}} replies)', + TODAY_NEW_COUNT_TOPIC: '(Today: {{topic}} topics)', + TODAY_NEW_COUNT_REPLY: '(Today: {{reply}} replies)', CATEGORY: { AFFAIRS: 'Affairs', diff --git a/modules/core/client/app/trans-string-zh.js b/modules/core/client/app/trans-string-zh.js index 3eba3190..56666a6b 100644 --- a/modules/core/client/app/trans-string-zh.js +++ b/modules/core/client/app/trans-string-zh.js @@ -677,6 +677,9 @@ DELETE_REPLY_CONFIRM_BODY_TEXT: '您确定要删除这条回复?', READ_ONLY_POST: '*** 只读版块,不能发表话题!', READ_ONLY_REPLY: '*** 只读话题,不能发表回复!', + TODAY_NEW_COUNT_ALL: '(今日: {{topic}} 话题, {{reply}} 回复)', + TODAY_NEW_COUNT_TOPIC: '(今日: {{topic}} 话题)', + TODAY_NEW_COUNT_REPLY: '(今日: {{reply}} 回复)', CATEGORY: { AFFAIRS: '站务区', diff --git a/modules/forums/client/controllers/forums.client.controller.js b/modules/forums/client/controllers/forums.client.controller.js index 77bc54cf..a2be57d7 100644 --- a/modules/forums/client/controllers/forums.client.controller.js +++ b/modules/forums/client/controllers/forums.client.controller.js @@ -28,9 +28,11 @@ vm.last_leave_time = localStorageService.get('last_leave_time') || Date.now(); // get forums list - ForumsService.query({}, function (items) { + ForumsService.get({}, function (items) { console.log(items); - vm.forums = items; + vm.forums = items.forumsList; + vm.forumsTopicsCount = items.forumsTopicsCount; + vm.forumsRepliesCount = items.forumsRepliesCount; }); }; @@ -61,5 +63,45 @@ } }; + vm.getTodayNewCount = function (f) { + if (f) { + var n_topic = getNewTopic(f); + var n_reply = getNewReply(f); + if (n_topic === 0 && n_reply === 0) { + return undefined; + } else if (n_topic === 0 && n_reply !== 0) { + return $translate.instant('FORUMS.TODAY_NEW_COUNT_REPLY', {reply: n_reply}); + } else if (n_topic !== 0 && n_reply === 0) { + return $translate.instant('FORUMS.TODAY_NEW_COUNT_TOPIC', {topic: n_topic}); + } else { + return $translate.instant('FORUMS.TODAY_NEW_COUNT_ALL', {topic: n_topic, reply: n_reply}); + } + } else { + return undefined; + } + + function getNewTopic(f) { + var c = 0; + angular.forEach(vm.forumsTopicsCount, function (tc) { + if (tc._id === f._id) { + c = c + tc.count; + } + }); + + return c; + } + + function getNewReply(f) { + var c = 0; + angular.forEach(vm.forumsRepliesCount, function (rc) { + if (rc._id === f._id) { + c = c + rc.count; + } + }); + + return c; + } + }; + } }()); diff --git a/modules/forums/client/less/forum.less b/modules/forums/client/less/forum.less index 5e6c91fd..2be8ad86 100644 --- a/modules/forums/client/less/forum.less +++ b/modules/forums/client/less/forum.less @@ -80,6 +80,12 @@ font-size: 16px; margin-top: 2px; } + .today-new-count { + color: #999; + font-size: 12px; + font-weight: normal; + margin-left: 10px; + } } .moderators-title { color: #666; diff --git a/modules/forums/client/views/index.client.view.html b/modules/forums/client/views/index.client.view.html index b0d5aa7d..acacaf4a 100644 --- a/modules/forums/client/views/index.client.view.html +++ b/modules/forums/client/views/index.client.view.html @@ -51,6 +51,7 @@