diff options
author | pzread <netfirewall@gmail.com> | 2013-03-10 15:02:19 +0800 |
---|---|---|
committer | pzread <netfirewall@gmail.com> | 2013-03-10 15:02:19 +0800 |
commit | 0bcc905d92d2f69a0b961746be1f19ef096857a3 (patch) | |
tree | 514abd4fd4319cb6e05df7007580f8afc5896040 /toj/jcs/notice.js | |
parent | 898913018b1d3f289f10d4716e28489497c977cb (diff) | |
download | taiwan-online-judge-0bcc905d92d2f69a0b961746be1f19ef096857a3.tar taiwan-online-judge-0bcc905d92d2f69a0b961746be1f19ef096857a3.tar.gz taiwan-online-judge-0bcc905d92d2f69a0b961746be1f19ef096857a3.tar.bz2 taiwan-online-judge-0bcc905d92d2f69a0b961746be1f19ef096857a3.tar.lz taiwan-online-judge-0bcc905d92d2f69a0b961746be1f19ef096857a3.tar.xz taiwan-online-judge-0bcc905d92d2f69a0b961746be1f19ef096857a3.tar.zst taiwan-online-judge-0bcc905d92d2f69a0b961746be1f19ef096857a3.zip |
Add Virtual URI System. New UI design. Improve sqmod_test
Diffstat (limited to 'toj/jcs/notice.js')
-rw-r--r-- | toj/jcs/notice.js | 142 |
1 files changed, 75 insertions, 67 deletions
diff --git a/toj/jcs/notice.js b/toj/jcs/notice.js index 64e93ef..016b652 100644 --- a/toj/jcs/notice.js +++ b/toj/jcs/notice.js @@ -1,48 +1,9 @@ -var notice = { - j_ajax:null, - enid:null, +var notice = new function(){ + var that = this; + var j_ajax = null; + var enid = null; - init:function(){ - $('body').on('click',function(e){ - var j_notice; - - if(e.target == null || ($(e.target).parents('a.item').length == 0 && $(e.target).parents('#notice_list').length > 0)){ - return; - } - - j_notice = $('#index_head_notice'); - if(e.target.id == 'index_head_notice' && !j_notice.hasClass('notice_s')){ - j_notice.addClass('notice_s'); - $('#notice_list_box').stop().animate({width:256},'slow','easeOutExpo'); - $('#notice_list').css('opacity','1').stop().animate({right:0},'slow','easeOutExpo'); - $('#notice_list a.item').stop().animate({left:0},'slow','easeOutQuart'); - }else{ - j_notice.removeClass('notice_s'); - $('#notice_list').stop().animate({opacity:0},'fast','easeOutQuad', - function(){ - $('#notice_list_box').css('width','0px'); - $('#notice_list').css('right','-256px'); - $('#notice_list a.item').css('left','50%'); - } - ); - } - }); - $('#index_head_notice').on('click',function(e){ - var j_list; - - j_list = $('#notice_list'); - if(j_list.css('opacity') == 0){ - j_list.empty(); - notice.enid = null; - notice.updatenew(); - } - }).on('mousedown',function(e){ - return false; - }); - - notice.refresh(); - }, - listnew:function(noticeo){ + var listnew = function(noticeo){ j_item = $('<li class="item"><a class="item"><div class="head"></div><div class="content"></div></a></li>') j_a = j_item.find('a.item'); j_head = j_item.find('div.head'); @@ -50,23 +11,28 @@ var notice = { switch(noticeo.type){ case 'result': - j_a.attr('href','/toj/stat/allsub/' + noticeo.subid + '/'); - j_head.text('Submit ' + noticeo.subid); - j_content.html('ProID ' + noticeo.proid + ' 結果: ' + RESULTMAP[noticeo.result] + '<br>' + noticeo.runtime+ 'ms / ' + noticeo.memory + 'KB'); + j_a.attr('href','/toj/m/sub/' + noticeo.subid + '/res/'); + if(noticeo.rejudge_flag == false){ + j_head.text('Submit ' + noticeo.subid); + }else{ + j_head.text('Rejudge ' + noticeo.subid); + } + j_content.html('ProID ' + noticeo.proid + ' 結果: ' + RESULTMAP[noticeo.result] + ' 分數: ' + noticeo.score + '<br>' + + noticeo.runtime+ 'ms / ' + noticeo.memory + 'KB'); break; } return j_item; - }, - updatenew:function(){ + }; + var updatenew = function(){ var j_list; - if(notice.j_ajax != null){ - notice.j_ajax.abort(); + if(j_ajax != null){ + j_ajax.abort(); } j_list = $('#notice_list'); - notice.j_ajax = $.post('/toj/php/notice.php',{'action':'get','data':JSON.stringify({'nid':0,'count':10})}, + j_ajax = $.post('/toj/php/notice.php',{'action':'get','data':JSON.stringify({'nid':0,'count':10})}, function(res){ var i; @@ -86,25 +52,25 @@ var notice = { j_a.stop().animate({left:0},'slow','easeOutQuart'); } - if(notice.enid == null){ + if(enid == null){ if(reto.length == 0){ - notice.enid = 2147483647; + enid = 2147483647; }else{ - notice.enid = reto[0].nid; + enid = reto[0].nid; } - notice.updateprev(); + updateprev(); } } - notice.j_ajax = null; + j_ajax = null; } ); - }, - updateprev:function(){ + }; + var updateprev = function(){ var j_list; j_list = $('#notice_list'); - $.post('/toj/php/notice.php',{'action':'get','data':JSON.stringify({'nid':notice.enid,'count':10})}, + $.post('/toj/php/notice.php',{'action':'get','data':JSON.stringify({'nid':enid,'count':10})}, function(res){ var i; @@ -116,17 +82,17 @@ var notice = { reto = JSON.parse(res); for(i = reto.length - 1;i >= 0;i--){ noticeo = JSON.parse(reto[i].txt); - j_item = notice.listnew(noticeo); + j_item = listnew(noticeo); j_list.append(j_item); j_item.find('a.item').stop().animate({left:0},'slow','easeOutQuart'); } - notice.enid = 0; + enid = 0; } } ); - }, - refresh:function(){ + }; + var refresh = function(){ $.post('/toj/php/notice.php',{'action':'count','data':JSON.stringify({})}, function(res){ var count; @@ -140,16 +106,58 @@ var notice = { j_notice.text('[' + count + ']'); }else{ if($('#notice_list').css('opacity') == 1){ - notice.updatenew(); + updatenew(); }else{ j_notice.addClass('notice_h'); j_notice.text('[' + count + ']'); } } - setTimeout(notice.refresh,1000); + setTimeout(refresh,2000); } } ); - } + }; + + that.init = function(){ + $(window).on('click',function(e){ + var j_notice; + + if(e.target == null || ($(e.target).parents('a.item').length == 0 && $(e.target).parents('#notice_list').length > 0)){ + return; + } + + j_notice = $('#index_head_notice'); + if(e.target.id == 'index_head_notice' && !j_notice.hasClass('notice_s')){ + j_notice.addClass('notice_s'); + $('#notice_list_box').stop().animate({width:322},'slow','easeOutExpo'); + $('#notice_list').css('opacity','1').stop().animate({right:0},'slow','easeOutExpo'); + $('#notice_list a.item').stop().animate({left:0},'slow','easeOutQuart'); + }else{ + j_notice.removeClass('notice_s'); + $('#notice_list').stop().animate({opacity:0},'fast','easeOutQuad', + function(){ + $('#notice_list_box').css('width','0px'); + $('#notice_list').css('right','-322px'); + $('#notice_list a.item').css('left','50%'); + } + ); + } + }); + $('#index_head_notice').on('click',function(e){ + var j_list; + + j_list = $('#notice_list'); + if(j_list.css('opacity') == 0){ + j_list.empty(); + enid = null; + updatenew(); + } + }).on('mousedown',function(e){ + return false; + }); + + refresh(); + }; + }; |