diff options
Diffstat (limited to 'src/js/notice.js')
-rw-r--r-- | src/js/notice.js | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/js/notice.js b/src/js/notice.js new file mode 100644 index 0000000..9bd92eb --- /dev/null +++ b/src/js/notice.js @@ -0,0 +1,66 @@ +var notice = new function(){ + var that = this; + var j_noticetag; + var j_noticelist; + + that.ready = function(){ + function _set_unseen_count(count){ + if(count == 0){ + j_noticetag.removeClass('notice_hl'); + }else{ + j_noticetag.addClass('notice_hl'); + } + j_noticetag.text('[' + count + ']'); + } + + j_noticetag = $('#index_paneltag > div.notice'); + j_noticelist = $('#index_panel > div.notice > ul.nav'); + + j_noticetag.on('click',function(e){ + j_noticelist.empty(); + + com.call_backend('core/notice/','list_notice',function(result){ + var i; + var data = result.data; + var notice; + var j_item; + + if(com.is_callerr(result)){ + index.add_alert('','警告','通知發生錯誤'); + }else{ + console.log(data); + + for(i = 0;i < data.length;i++){ + notice = data[i]; + + j_item = $('<li><a><h5></h5><p></p></a></li>'); + j_item.find('h5').text(notice.title); + j_item.find('p').text(notice.content); + + if(notice.noticemodid == null){ + j_item.find('a').attr('href','/toj' + notice.metadata); + } + + j_noticelist.append(j_item); + } + } + }); + }); + + imc.Proxy.instance.register_call('core/notice/','update_notice',function(callback,unseen_count){ + _set_unseen_count(unseen_count); + callback('Success'); + }); + + com.call_backend('core/notice/','get_unseen_count',function(result){ + var data = result.data; + + if(com.is_callerr(result)){ + index.add_alert('','警告','通知發生錯誤'); + }else{ + _set_unseen_count(data.unseen_count); + } + }); + }; + +}; |