aboutsummaryrefslogtreecommitdiffstats
path: root/toj/jcs
diff options
context:
space:
mode:
Diffstat (limited to 'toj/jcs')
-rw-r--r--toj/jcs/common.css19
-rw-r--r--toj/jcs/common.js336
-rw-r--r--toj/jcs/home.css0
-rw-r--r--toj/jcs/home.js433
-rw-r--r--toj/jcs/index.css177
-rw-r--r--toj/jcs/index.js128
-rw-r--r--toj/jcs/notice.css58
-rw-r--r--toj/jcs/notice.js155
-rw-r--r--toj/jcs/pro.css28
-rw-r--r--toj/jcs/pro.js165
-rw-r--r--toj/jcs/sq.css0
-rw-r--r--toj/jcs/sq.js100
-rw-r--r--toj/jcs/stat.css56
-rw-r--r--toj/jcs/stat.js364
-rw-r--r--toj/jcs/user.css175
-rw-r--r--toj/jcs/user.js1025
16 files changed, 3219 insertions, 0 deletions
diff --git a/toj/jcs/common.css b/toj/jcs/common.css
new file mode 100644
index 0000000..f693f3d
--- /dev/null
+++ b/toj/jcs/common.css
@@ -0,0 +1,19 @@
+div.common_page{
+ height:100%;
+ position:relative;
+ overflow:auto;
+ display:none;
+}
+div.common_tab{
+ height:100%;
+ position:relative;
+ overflow:auto;
+ display:none;
+}
+div.common_mask_box{
+ margin:32px auto;
+ padding:0px 32px 0px 32px;
+ background-color:#373C38;
+ position:relative;
+ display:none;
+}
diff --git a/toj/jcs/common.js b/toj/jcs/common.js
new file mode 100644
index 0000000..84468e3
--- /dev/null
+++ b/toj/jcs/common.js
@@ -0,0 +1,336 @@
+var RESULTMAP = {0:'AC',1:'WA',2:'TLE',3:'MLE',4:'RF',5:'RE',6:'CE',7:'ERR',100:'WAIT'};
+
+var USER_PER_USER = 0x00000001;
+var USER_PER_PROCREATOR = 0x00000002;
+var USER_PER_PROADMIN = 0x00000004;
+
+var USER_LEVEL_USER = 0x00000001;
+var USER_LEVEL_PROCREATOR = 0x00000003;
+var USER_LEVEL_PROADMIN = 0x00000007;
+var USER_LEVEL_ADMIN = 0x0000ffff;
+var USER_LEVEL_SUPERADMIN = -1;
+
+var __extend = function(child,parent){
+ child.prototype.__super = parent;
+};
+
+var common = {
+ page_list:new Array(),
+ url_prev:null,
+ url_curr:null,
+ mbox_curr:null,
+ mbox_defer:null,
+
+ init:function(){
+ var i;
+ var url;
+ var urlpart;
+
+ urlpart = location.href.split('?');
+ if(urlpart[0].search(/\/$/) == -1){
+ url = urlpart[0] + '/';
+ if(urlpart.length > 1){
+ url = url + '?';
+ for(i = 1;i < urlpart.length;i++){
+ url = url + urlpart[i];
+ }
+ }
+ window.history.replaceState(null,document.title,url);
+ }
+
+ common.url_curr = location.href;
+
+ $(document).on('click','a',function(e){
+ common.pushurl($(this).attr('href'));
+ return false;
+ });
+ $(document).on('keyup',function(e){
+ if(e.which == 27){
+ common.hidembox(false);
+ }
+ });
+ },
+
+ exheight:function(){
+ var i;
+ var es;
+ var extop;
+ var exbottom;
+ var j_e;
+ var j_parent;
+
+ es = $('[exheight=true]');
+ for(i = 0;i < es.length;i++){
+ j_e = $(es[i]);
+ if((extop = j_e.attr('extop')) == undefined){
+ extop = j_e.css('top').match(/(.+)px/)[1];
+ }
+ if((exbottom = j_e.attr('exbottom')) == undefined){
+ exbottom = 0;
+ }
+ extop = parseInt(extop);
+ exbottom = parseInt(exbottom);
+
+ j_e.css('height',($(window).height() - (extop + exbottom) + 'px'));
+ }
+ },
+ getcookie:function(){
+ var ret;
+ var i;
+ var part;
+ var subpart;
+
+ ret = new Array();
+ part = document.cookie.split(';');
+ for(i = 0;i < part.length;i++){
+ part[i] = part[i].replace(/\+/g,' ');
+ subpart = part[i].split('=');
+ ret[decodeURIComponent(subpart[0])] = decodeURIComponent(subpart[1]);
+ }
+
+ return ret;
+ },
+ getdate:function(str){
+ var part;
+ part = str.match(/(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)/);
+ return new Date(part[1],parseInt(part[2]) - 1,part[3],part[4],part[5],part[6],0);
+ },
+ getdatestring:function(date,secflag){
+ var month;
+ var day;
+ var hr;
+ var min;
+ var sec;
+
+ month = date.getMonth() + 1;
+ if(month < 10){
+ month = '0' + month;
+ }
+ day = date.getDate();
+ if(day < 10){
+ day = '0' + day;
+ }
+ hr = date.getHours();
+ if(hr < 10){
+ hr = '0' + hr;
+ }
+ min = date.getMinutes();
+ if(min < 10){
+ min = '0' + min;
+ }
+ if(secflag == true){
+ sec = date.getSeconds();
+ if(sec < 10){
+ sec = '0' + sec;
+ }
+
+ return date.getFullYear() + '-' + month + '-' + day + ' ' + hr + ':' + min + ':' + sec;
+ }else{
+ return date.getFullYear() + '-' + month + '-' + day + ' ' + hr + ':' + min;
+ }
+ },
+ getlang:function(value){
+ var i;
+ var ret;
+ var langlist = ['C++','JAVA','Pascal'];
+
+ ret = new Array;
+ i = 0;
+ while(value > 0){
+ if((value & 1) == 1){
+ ret.push(langlist[i]);
+ }
+ value = value >> 1;
+ }
+
+ return ret;
+ },
+
+ geturlpart:function(url){
+ if(url == undefined){
+ return location.href.match(/toj\/(.*)/)[1].split('/');
+ }else{
+ return url.match(/toj\/(.*)/)[1].split('/');
+ }
+ },
+ pushurl:function(url){
+ common.url_prev = location.href;
+ window.history.pushState(null,document.title,url);
+ common.url_curr = location.href;
+ common.page_urlchange();
+ },
+ replaceurl:function(url){
+ window.history.replaceState(null,document.title,url);
+ common.url_curr = location.href;
+ },
+ prevurl:function(notpagename){
+ if(common.url_prev == null || common.geturlpart(common.url_prev)[0] == notpagename){
+ common.pushurl('/toj/home/');
+ }else{
+ common.pushurl(common.url_prev);
+ }
+ },
+ page_urlchange:function(){
+ var urlpart;
+ var pagename;
+ var pagename_prev;
+
+ if(arguments.callee.reentrant == true){
+ arguments.callee.hasnext = true;
+ return;
+ }else{
+ arguments.callee.reentrant = true;
+ arguments.callee.hasnext = true;
+ }
+
+ while(arguments.callee.hasnext){
+ arguments.callee.hasnext = false;
+
+ if(common.mbox_curr != null){
+ common.hidembox(false);
+ }
+
+ urlpart = common.geturlpart();
+ pagename = urlpart[0];
+ if(pagename == ''){
+ common.replaceurl('/toj/home/');
+ common.page_urlchange();
+ continue;
+ }else if(!(pagename in common.page_list)){
+ common.replaceurl('/toj/none/');
+ common.page_urlchange();
+ continue;
+ }
+
+ if(common.url_prev != null){
+ pagename_prev = common.geturlpart(common.url_prev)[0];
+ if(pagename == pagename_prev){
+ common.page_list[pagename].urlchange('same');
+ }else{
+ if(pagename_prev in common.page_list){
+ common.page_list[pagename_prev].urlchange('out');
+ }
+ common.page_list[pagename].urlchange('in');
+ }
+ }else{
+ common.page_list[pagename].urlchange('in');
+ }
+ }
+ arguments.callee.reentrant = false;
+ },
+ addpage:function(pagename,pageobj){
+ common.page_list[pagename] = pageobj;
+ },
+ removepage:function(pagename){
+ delete common.page_list[pagename];
+ },
+
+ showmbox:function(mboxobj){
+ common.mbox_curr = mboxobj;
+ mboxobj.switchchange('in');
+ common.mbox_defer = $.Deferred();
+ return common.mbox_defer.promise();
+ },
+ hidembox:function(done){
+ if(common.mbox_curr != null){
+ common.mbox_curr.switchchange('out');
+ common.mbox_curr = null;
+ if(done == true){
+ common.mbox_defer.resolve();
+ }else{
+ common.mbox_defer.reject();
+ }
+ }
+ }
+};
+
+var class_common_page = function(){
+ var that = this;
+ that.tab_list = Array();
+ that.tabname_curr = null;
+
+ that.urlchange = function(direct){};
+ that.fadein = function(j_e){
+ j_e.stop().fadeIn('fast');
+ };
+ that.fadeout = function(j_e){
+ j_e.stop().hide();
+ };
+
+ that.tab_urlchange = function(tabname){
+ if(arguments.callee.reentrant == true){
+ arguments.callee.hasnext = true;
+ return;
+ }else{
+ arguments.callee.reentrant = true;
+ arguments.callee.hasnext = true;
+ }
+
+ while(arguments.callee.hasnext){
+ arguments.callee.hasnext = false;
+
+ if(tabname == null){
+ if(that.tabname_curr in that.tab_list){
+ index.lltab(that.tabname_curr);
+ that.tab_list[that.tabname_curr].urlchange('out');
+ }
+ that.tab_list = new Array();
+ that.tabname_curr = null;
+ continue;
+ }
+
+ if(!(tabname in that.tab_list)){
+ common.replaceurl('/toj/none/');
+ common.page_urlchange();
+ return;
+ }
+
+ if(tabname == that.tabname_curr){
+ that.tab_list[tabname].urlchange('same');
+ }else{
+ if(that.tabname_curr in that.tab_list){
+ index.lltab(that.tabname_curr);
+ that.tab_list[that.tabname_curr].urlchange('out');
+ }
+ that.tabname_curr = tabname;
+ index.hltab(tabname);
+ that.tab_list[tabname].urlchange('in');
+ }
+ }
+ arguments.callee.reentrant = false;
+ };
+ that.addtab = function(tabname,tabobj){
+ that.tab_list[tabname] = tabobj;
+ };
+ that.removetab = function(tabname){
+ delete that.tab_list[tabname];
+ };
+};
+
+var class_common_tab = function(paobj){
+ var that = this;
+ that.paobj = paobj;
+
+ that.urlchange = function(direct){};
+ that.fadein = function(j_e){
+ j_e.stop().fadeIn('fast');
+ };
+ that.fadeout = function(j_e){
+ j_e.stop().hide();
+ };
+};
+
+var class_common_mbox = function(paobj){
+ var that = this;
+ that.paobj = paobj;
+
+ that.switchchange = function(direct){};
+ that.fadein = function(j_e){
+ j_e.stop().show();
+ index.showmask();
+ };
+ that.fadeout = function(j_e){
+ index.hidemask();
+ j_e.stop().hide();
+ };
+}
diff --git a/toj/jcs/home.css b/toj/jcs/home.css
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/toj/jcs/home.css
diff --git a/toj/jcs/home.js b/toj/jcs/home.js
new file mode 100644
index 0000000..bdc509d
--- /dev/null
+++ b/toj/jcs/home.js
@@ -0,0 +1,433 @@
+var home = {
+ init:function(){
+ home.home_page = new class_home_page;
+ home.none_page = new class_none_page;
+ }
+};
+
+var class_home_page = function(){
+ var that = this;
+ var j_page = $($('#index_page > [page="home"]')[0]);
+
+ that.__super();
+
+ that.urlchange = function(direct){
+ if(direct == 'in'){
+ that.fadein(j_page);
+ index.settitle('Taiwan Online Judge');
+ tmp();
+ }else if(direct == 'out'){
+ that.fadeout(j_page);
+ tmp_stop = true;
+ }
+ }
+ common.addpage('home',that);
+
+
+ var tmp_stop = true;
+ var tmp_first = true;
+
+ var load;
+ var prog = 0;
+ var bd = Math.PI / 180;
+
+ var co_table = [
+ '255,255,0',
+ '255,0,255',
+ '255,255,0',
+ '255,255,255',
+ '17,50,133',
+ '203,27,69',
+ '233,139,42',
+ '186,145,50',
+ '123,162,63',
+ '27,129,62',
+ '0,170,144',
+ '0,137,167',
+ '0,92,175',
+ '203,64,66',
+ '233,205,76',
+ '232,48,21',
+ '255,196,8'
+ ];
+
+ var st;
+ var et;
+ var pa_off = 0;
+ var pa_c = 6;
+ var pa_co = 0;
+ var pb_off = 0;
+ var pb_c = 6;
+ var pb_co = 0;
+
+ function tmp(){
+ var e_ani;
+ var e_canvas;
+ var ctx;
+ var e_audio;
+
+ function drawTextAlongArc(context,str,centerX,centerY,radius,angle,offangle) {
+ var len = str.length, s;
+ context.save();
+ context.translate(centerX,centerY);
+ context.rotate(-1 * offangle);
+ context.rotate(-1 * angle / 2);
+ context.rotate(-1 * (angle / len) / 2);
+ for(var n = 0; n < len; n++) {
+ context.rotate(angle / len);
+ context.save();
+ context.translate(0, -1 * radius);
+ s = str[n];
+ context.fillText(s,0,0);
+ context.restore();
+ }
+ context.restore();
+ }
+ function drawRect(ctx,x,y,w,h){
+ ctx.beginPath();
+ ctx.rect(x,y,w,h);
+ ctx.fill();
+ }
+ function drawCircle(ctx,x,y,r,a,off){
+ ctx.beginPath();
+ ctx.arc(x,y,r,off,a + off,false);
+ ctx.stroke();
+ }
+ function drawLine(ctx,ax,ay,bx,by){
+ ctx.beginPath();
+ ctx.moveTo(ax,ay);
+ ctx.lineTo(bx,by);
+ ctx.stroke();
+ }
+ function drawPoly(ctx,x,y,r,c,offangle){
+ var i;
+
+ ctx.save();
+ ctx.beginPath();
+ ctx.translate(x,y);
+ ctx.rotate(-1 * offangle);
+ ctx.moveTo(0,-r);
+ for(i = 1;i <= c;i++){
+ ctx.rotate(bd * 360 / c);
+ ctx.lineTo(0,-r);
+ }
+ ctx.stroke();
+ ctx.restore();
+ }
+
+ var ani = function(){
+ var i;
+ var u,v;
+
+ if(tmp_stop == true){
+ return;
+ }
+
+ et = new Date().getTime();
+ if((et - st) < 20){
+ window.requestAnimationFrame(ani);
+ return;
+ }
+ ctx.clearRect(0,0,1920,1080);
+
+ ctx.fillStyle = 'rgba(128,128,128,1)';
+ ctx.shadowBlur = 0;
+
+ ctx.strokeStyle = 'rgba(30,30,30,1)';
+ ctx.lineWidth = 2;
+ u = 3000 - (prog % 240) / 240 * 3000;
+ for(i = 0;i < 12;i++){
+ v = (u + i * 250) % 3000;
+ drawLine(ctx,v - 540,-5,v - 1040,1085);
+ }
+ ctx.strokeStyle = 'rgba(30,30,30,1)';
+ ctx.lineWidth = 2;
+ u = 2500 - (prog % 240) / 240 * 2500;
+ for(i = 0;i < 10;i++){
+ v = (u + i * 250) % 2500;
+ drawLine(ctx,-5,v - 1250,1925,v - 540);
+ }
+
+ ctx.strokeStyle = 'rgba(128,128,128,1)';
+
+ ctx.lineWidth = 12;
+ drawCircle(ctx,700,500,550,bd * 30,-bd * (prog % 360));
+ drawCircle(ctx,700,500,550,bd * 30,-bd * (prog % 360 + 120));
+ drawCircle(ctx,700,500,550,bd * 30,-bd * (prog % 360 + 240));
+
+ ctx.lineWidth = 8;
+ drawCircle(ctx,700,500,450,bd * 360,0);
+
+ ctx.lineWidth = 16;
+ drawCircle(ctx,700,500,440,bd * 60,-bd * ((prog * 2) % 360));
+ drawCircle(ctx,700,500,440,bd * 60,-bd * ((prog * 2) % 360 + 120));
+ drawCircle(ctx,700,500,440,bd * 60,-bd * ((prog * 2) % 360 + 240));
+
+ ctx.lineWidth = 10;
+ drawCircle(ctx,700,500,390,bd * 60,bd * ((prog * 7) % 360 + 160));
+ ctx.lineWidth = 8;
+ drawCircle(ctx,700,500,370,bd * 30,-bd * ((prog * 8) % 360 + 290));
+
+ ctx.lineWidth = 8;
+ drawCircle(ctx,700,500,350,bd * 60,bd * ((prog * 3) % 360));
+ ctx.lineWidth = 38;
+ drawCircle(ctx,700,500,335,bd * 20,bd * ((prog * 3) % 360 + 59));
+ ctx.lineWidth = 8;
+ drawCircle(ctx,700,500,320,bd * 80,bd * ((prog * 3) % 360 + 60));
+
+ ctx.lineWidth = 8;
+ drawCircle(ctx,700,500,350,bd * 50,bd * ((prog * 3) % 360 + 200));
+ ctx.lineWidth = 28;
+ drawCircle(ctx,700,500,340,bd * 40,bd * ((prog * 3) % 360 + 249));
+ ctx.lineWidth = 8;
+ drawCircle(ctx,700,500,330,bd * 60,bd * ((prog * 3) % 360 + 260));
+
+ ctx.lineWidth = 4;
+ drawCircle(ctx,700,500,300,bd * 360,0);
+ ctx.lineWidth = 16;
+ drawCircle(ctx,700,500,295,bd * 80,-bd * ((prog * 4) % 360 + 90));
+
+ ctx.lineWidth = 8;
+ drawCircle(ctx,700,500,260,bd * 90,bd * ((prog * 4) % 360));
+ drawCircle(ctx,700,500,230,bd * 120,-bd * ((prog * 5) % 360 + 120));
+ drawCircle(ctx,700,500,210,bd * 160,bd * ((prog * 3) % 360 + 270));
+
+ ctx.strokeStyle = 'rgba(128,128,128,' + (1 - (prog % 24)/24) + ')';
+ ctx.lineWidth = 8;
+ drawCircle(ctx,700,500,80 + (prog % 24) * 4,bd * 360,0);
+ ctx.lineWidth = 4;
+ drawCircle(ctx,700,500,70 + (prog % 24) * 4,bd * 360,0);
+
+ ctx.font = 'bold 16px tahoma';
+ drawTextAlongArc(ctx,"Hello TOJ [FORCORO]",700,500,460,bd * 60,bd * (prog % 360 + 115) * 2);
+ drawTextAlongArc(ctx,"Are You Happy?",700,500,460,bd * 50,bd * (prog % 360 + 30) * 2);
+
+ if(prog < 456 || prog > 912){
+ ctx.strokeStyle = 'rgba(255,255,255,1)';
+ ctx.lineWidth = 6;
+ drawCircle(ctx,700,500,60,bd * 60,bd * ((prog * 4) % 360));
+ drawCircle(ctx,700,500,60,bd * 60,bd * ((prog * 4) % 360 + 180));
+ }else{
+ u = prog % 48;
+ if(u == 0){
+ pa_off = bd * (prog % 373);
+ pa_c = prog % 5 + 3;
+ pa_co = Math.round(Math.random() * co_table.length);
+ }
+ ctx.strokeStyle = 'rgba(' + co_table[pa_co] + ',' + (1 - u / 48) + ')';
+ drawPoly(ctx,700,500,u * 20,pa_c,pa_off);
+ u = (prog + 24) % 48;
+ if(u == 0){
+ pb_off = bd * (prog % 173);
+ pb_c = prog % 5 + 3;
+ pb_co = Math.round(Math.random() * co_table.length);
+ }
+ ctx.strokeStyle = 'rgba(' + co_table[pb_co] + ',' + (1 - u / 48) + ')';
+ drawPoly(ctx,700,500,u * 20,pb_c,pb_off);
+
+ ctx.strokeStyle = 'rgba(255,255,255,1)';
+ ctx.lineWidth = 6;
+ drawCircle(ctx,700,500,60,bd * 60,-bd * ((prog * 15) % 360));
+ drawCircle(ctx,700,500,60,bd * 60,-bd * ((prog * 15) % 360 + 180));
+ }
+
+ v = prog % 96;
+ if((v >= 24 && v < 26)|| (v >= 28 && v < 30)){
+ ctx.shadowBlur = 5;
+ }else{
+ ctx.shadowBlur = 0;
+ }
+
+ ctx.font = 'bold 64px tahoma';
+ u = 0;
+ ctx.fillStyle = 'rgba(255,255,0,1)';
+ ctx.shadowColor = 'rgba(255,255,0,1)';
+ ctx.fillText('T',1000 + u,600);
+ ctx.fillStyle = 'rgba(255,255,255,1)';
+ ctx.shadowColor = 'rgba(255,255,255,1)';
+ u += ctx.measureText('T').width;
+ ctx.fillText('aiwan',1000 + u,600);
+ u += ctx.measureText('aiwan').width;
+
+ if((v >= 32 && v < 34)|| (v >= 36 && v < 38)){
+ ctx.shadowBlur = 5;
+ }else{
+ ctx.shadowBlur = 0;
+ }
+
+ ctx.fillStyle = 'rgba(255,0,255,1)';
+ ctx.shadowColor = 'rgba(255,0,255,1)';
+ ctx.fillText(' O',1000 + u,600);
+ ctx.fillStyle = 'rgba(255,255,255,1)';
+ ctx.shadowColor = 'rgba(255,255,255,1)';
+ u += ctx.measureText(' O').width;
+ ctx.fillText('nline',1000 + u,600);
+ u += ctx.measureText('nline').width;
+
+ if((v >= 40 && v < 42)|| (v >= 44 && v < 46)){
+ ctx.shadowBlur = 5;
+ }else{
+ ctx.shadowBlur = 0;
+ }
+
+ ctx.fillStyle = 'rgba(0,255,255,1)';
+ ctx.shadowColor = 'rgba(0,255,255,1)';
+ ctx.fillText(' J',1000 + u,600);
+ ctx.fillStyle = 'rgba(255,255,255,1)';
+ ctx.shadowColor = 'rgba(255,255,255,1)';
+ u += ctx.measureText(' J').width;
+ ctx.fillText('udge',1000 + u,600);
+
+ ctx.shadowBlur = 0;
+
+ ctx.fillStyle = 'rgba(255,196,8,0.9)';
+ drawRect(ctx,0,930,1920,70);
+
+ ctx.font = 'bold 50px 微軟正黑體';
+ ctx.fillStyle = 'rgba(255,255,255,1)';
+ ctx.fillText('Taiwan Online Judge へようこそ システムテスト',1920 - (prog % 360) / 360 * 3000,980);
+ ctx.fillText('Taiwan Online Judge へようこそ システムテスト',1920 - ((prog + 180) % 360) / 360 * 3000,980);
+
+ ctx.font = 'bold 36px 微軟正黑體';
+ u = ctx.measureText('Parallel Judge 使用可能').width + 64;
+ ctx.fillText('Parallel Judge 使用可能',1920 - u,64);
+
+ if(prog % 24 < 12){
+ ctx.font = 'bold 36px 微軟正黑體';
+ u = ctx.measureText('INSERT COIN[S]').width + 64;
+ ctx.fillText('INSERT COIN[S]',1920 - u,1045);
+ }
+
+ if(prog <= 45){
+ ctx.fillStyle = 'rgba(8,8,8,1)';
+ drawRect(ctx,0,0,1920,1080);
+ }else if(prog < 50){
+ ctx.fillStyle = 'rgba(8,8,8,' + (1 - (prog / 50)) + ')';
+ drawRect(ctx,0,0,1920,1080);
+ }
+
+ if(prog > 25){
+ if(prog <= 45){
+ ctx.fillStyle = 'rgba(255,255,0,1)';
+ drawRect(ctx,1000 * ((prog - 25) / 20) * 4 - 3000,500,200,128);
+ ctx.fillStyle = 'rgba(255,0,255,1)';
+ drawRect(ctx,1200 * ((prog - 25) / 20) * 4 - 3600,500,200,128);
+ ctx.fillStyle = 'rgba(0,255,255,1)';
+ drawRect(ctx,1400 * ((prog - 25) / 20) * 4 - 4200,500,200,128);
+ }else if(prog < 50){
+ ctx.fillStyle = 'rgba(255,255,0,' + (1 - (prog / 50)) + ')';
+ drawRect(ctx,1000,500,200,128);
+ ctx.fillStyle = 'rgba(255,0,255,' + (1 - (prog / 50)) + ')';
+ drawRect(ctx,1200,500,200,128);
+ ctx.fillStyle = 'rgba(0,255,255,' + (1 - (prog / 50)) + ')';
+ drawRect(ctx,1400,500,200,128);
+ }
+ }
+
+ st = et;
+ prog++;
+ if(prog == 1080){
+ prog = 360;
+ }
+ window.requestAnimationFrame(ani);
+ };
+
+ var loadani = function(){
+ var u;
+ var v;
+
+ ctx.clearRect(0,0,1920,1080);
+
+ if(tmp_stop == true){
+ return;
+ }
+
+ if(prog < 50){
+ u = 0;
+ }else if(prog < 100){
+ u = (prog - 50) / 50;
+ }else if(prog < 250){
+ u = 1;
+ }else if(prog < 300){
+ u = (300 - prog) / 50;
+ }else{
+ u = 0;
+ }
+
+ ctx.fillStyle = 'rgba(8,8,8,1)';
+ drawRect(ctx,0,0,1920,1080);
+
+ v = ctx.measureText('TF∪CK ').width;
+ ctx.fillStyle = 'rgba(128,0,0,' + u + ')';
+ ctx.fillRect(960 - v / 2 - 10,380,v + 20,200);
+
+ ctx.fillStyle = 'rgba(255,255,255,' + u + ')';
+ ctx.font = 'bold 192px tahoma';
+ ctx.fillText('TF∪CK ',960 - v / 2,550);
+
+ prog++;
+ if(prog == 400){
+ prog = 0;
+ st = 0;
+ document.getElementById('tmp_audio').play();
+ ani();
+ }else{
+ setTimeout(loadani,10);
+ }
+ }
+
+ e_ani = document.getElementById('tmpani');
+ e_canvas = document.getElementById('tmpcanv');
+
+ if(e_ani.clientWidth * 9 > e_ani.clientHeight * 16){
+ e_canvas.width = e_ani.clientHeight / 9 * 16;
+ e_canvas.height = e_ani.clientHeight;
+ }else{
+ e_canvas.width = e_ani.clientWidth;
+ e_canvas.height = e_ani.clientWidth / 16 * 9;
+ }
+
+ var waitaudio = function(){
+ if(document.getElementById('tmpload_audio').readyState != 4 || document.getElementById('tmp_audio').readyState != 4){
+ setTimeout(waitaudio,100);
+ }else{
+ e_audio = document.getElementById('tmpload_audio');
+ e_audio.play();
+ loadani();
+ }
+ }
+
+ ctx = e_canvas.getContext('2d');
+ ctx.scale(e_canvas.width / 1920,e_canvas.height / 1080);
+
+ tmp_stop = false;
+ if(tmp_first == true){
+ load = true;
+ waitaudio();
+ }else{
+ load = false;
+ ani();
+ }
+
+ tmp_first = false;
+ }
+}; __extend(class_home_page,class_common_page);
+
+var class_none_page = function(){
+ var that = this;
+ var j_page = $($('#index_page > [page="none"]')[0]);
+
+ that.__super();
+
+ that.urlchange = function(direct){
+ if(direct == 'in'){
+ that.fadein(j_page);
+ index.settitle('Taiwan Online Judge');
+ }else if(direct == 'out'){
+ that.fadeout(j_page);
+ }
+ }
+ common.addpage('none',that);
+}; __extend(class_none_page,class_common_page);
+
+
diff --git a/toj/jcs/index.css b/toj/jcs/index.css
new file mode 100644
index 0000000..d5d8dd2
--- /dev/null
+++ b/toj/jcs/index.css
@@ -0,0 +1,177 @@
+div.index_head{
+ width:100%;
+ height:32px;
+ font-size:20px;
+ line-height:32px;
+ background-color:#1C1C1C;
+ position:absolute;
+ left:0px;
+ top:0px;
+ z-index:1;
+}
+div.index_head > div.title{
+ width:250px;
+ height:100%;
+ margin:0px 0px 0px 6px;
+ float:left;
+}
+div.index_head > div.tab_box{
+ width:auto;
+ height:100%;
+ float:left;
+}
+div.index_head > div.tab_box > div.button{
+ height:100%;
+ margin:0px 0px;
+ float:left;
+}
+div.index_head > div.tab_box > div.button_s{
+ background-color:#3A8FB7;
+}
+div.index_head > div.tab_box > div.button > a.button{
+ height:100%;
+ padding:0px 16px 0px 16px;
+ color:#E9E9E9;
+ text-decoration:none;
+ display:block;
+}
+div.index_head > div.tab_box > div.button > a:hover.button{
+ color:#FFFFFF;
+}
+div.index_head > div.content_box{
+ width:auto;
+ height:100%;
+ float:left;
+}
+div.index_head > div.panel{
+ width:96px;
+ height:100%;
+ text-align:center;
+ cursor:pointer;
+ float:right;
+}
+div.index_head > div.panel_m{
+ color:#FFFFFF;
+}
+div.index_head > div.notice{
+ width:96px;
+ height:100%;
+ text-align:center;
+ font-family:monospace;
+ cursor:pointer;
+ float:right;
+}
+div.index_head > div:hover.notice{
+ color:#FFFFFF;
+}
+div.index_head > div.notice_s{
+ color:#FFFFFF;
+}
+div.index_head > div.notice_h{
+ background-color:#E83015;
+ color:#FFFFFF;
+}
+div.index_head > div.nickname{
+ height:100%;
+ padding:0px 16px 0px 16px;
+ float:right;
+}
+div.index_head > div.nickname > a.nickname{
+ height:100%;
+ color:#E9E9E9;
+ text-align:center;
+ text-decoration:none;
+}
+div.index_head > div.nickname > a:hover.nickname{
+ color:#FFFFFF;
+}
+
+div.index_panel_box{
+ width:0px;
+ position:absolute;
+ left:auto;
+ right:0px;
+ top:32px;
+ overflow:hidden;
+ z-index:110;
+}
+ul.index_panel{
+ width:256px;
+ height:100%;
+ margin:0px 0px;
+ padding:0px 0px;
+ background-color:#1C1C1C;
+ opacity:0;
+ position:absolute;
+ left:auto;
+ right:-256px;
+ top:0px;
+ z-index:2;
+ overflow-x:hidden;
+ overflow-y:auto;
+ list-style:none;
+}
+ul.index_panel > li.button{
+ width:auto;
+ height:64px;
+ padding:0px 0px 0px 32px;
+ font-size:20px;
+ line-height:64px;
+}
+ul.index_panel > li:hover.button{
+ color:#FFFFFF;
+ background-color:rgba(255,255,255,0.2);
+}
+ul.index_panel > ul.square_box{
+ width:100%;
+ margin:0px 0px;
+ padding:0px 0px;
+ list-style:none;
+ overflow:hidden;
+ display:none;
+}
+ul.index_panel > ul.square_box > li.button{
+ width:auto;
+ height:32px;
+ padding:0px 0px 0px 32px;
+ font-size:16px;
+ line-height:32px;
+}
+ul.index_panel > ul.square_box > li:hover.button{
+ color:#FFFFFF;
+ background-color:rgba(255,255,255,0.2);
+}
+ul.index_panel a.button{
+ width:100%;
+ height:100%;
+ color:#E9E9E9;
+ text-decoration:none;
+ position:relative;
+ top:0px;
+ left:50%;
+ cursor:pointer;
+ display:block;
+}
+ul.index_panel a.button_m{
+ color:#FFFFFF;
+}
+
+div.index_page{
+ width:100%;
+ position:absolute;
+ left:0px;
+ top:32px;
+ z-index:0;
+}
+
+div.index_mask{
+ width:100%;
+ height:100%;
+ background-color:rgba(0,0,0,0.9);
+ position:absolute;
+ top:0px;
+ left:0px;
+ z-index:3;
+ display:none;
+ overflow:auto;
+}
diff --git a/toj/jcs/index.js b/toj/jcs/index.js
new file mode 100644
index 0000000..e97242a
--- /dev/null
+++ b/toj/jcs/index.js
@@ -0,0 +1,128 @@
+var index = {
+ init:function(){
+ $('body').on('mouseover',function(e){
+ var j_panel;
+
+ if(e.target == null || e.target.id == 'index_panel' || $(e.target).parents('#index_panel').length > 0){
+ return;
+ }
+
+ j_panel = $('#index_head_panel');
+ if(e.target.id == 'index_head_panel'){
+ $('#index_head_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%');
+ }
+ );
+
+ j_panel.addClass('panel_m');
+ $('#index_panel_box').stop().animate({width:256},'slow','easeOutExpo');
+ $('#index_panel').css('opacity','1').stop().animate({right:0},'slow','easeOutExpo');
+ $('#index_panel a.button').stop().animate({left:0},'slow','easeOutQuart');
+ }else{
+ $('#index_head_panel').removeClass('panel_m');
+ $('#index_panel').stop().animate({opacity:0},'fast','easeOutQuad',
+ function(){
+ $('#index_panel_box').css('width','0px');
+ $('#index_panel').css('right','-256px');
+ $('#index_panel a.button').css('left','50%');
+ }
+ );
+ }
+ });
+ $('#index_head_panel').on('mousedown',function(e){
+ return false;
+ });
+
+ $('#index_panel > li').on('mousedown',function(e){
+ return false;
+ });
+
+ $('#index_panel > [page="square"] > a.button').off('click').on('click',function(e){
+ var j_ul;
+
+ j_ul = $('#index_panel > ul.square_box');
+ if(j_ul.is(':visible')){
+ j_ul.stop().slideUp('slow','easeOutExpo');
+ }else{
+ j_ul.stop().slideDown('slow','easeOutExpo');
+ }
+
+ return false;
+ });
+
+ $('#index_mask').on('click',function(e){
+ if((e.target == this || $(e.target).parents('div.common_mask_box').length == 0) && !$(e.target).hasClass('common_mask_box') && common.mbox_curr != null){
+ common.hidembox(false);
+ }
+ });
+ },
+
+ showpanel:function(pagename){
+ $('#index_panel > [page="' + pagename + '"]').show();
+ },
+ hidepanel:function(pagename){
+ $('#index_panel > [page="' + pagename + '"]').hide();
+ },
+ setpanel:function(pagename,panellink,paneltext){
+ var j_a;
+
+ j_a = $('#index_panel > [page="' + pagename + '"] > a.button');
+ j_a.attr('href',panellink);
+ j_a.text(paneltext);
+ },
+
+ settitle:function(titletext){
+ $('#index_head > div.title').text(titletext);
+ },
+
+ addtab:function(tabname,tablink,tabtext){
+ var j_div;
+ var j_a;
+
+ j_div = $('<div class="button"></div>');
+ j_div.attr('tab',tabname);
+
+ j_a = $('<a class="button"></a>');
+ j_a.attr('href',tablink);
+ j_a.text(tabtext);
+
+ j_div.append(j_a);
+ $('#index_head > div.tab_box').append(j_div);
+
+ return j_div;
+ },
+ settab:function(tabname,tablink,tabtext){
+ var j_a;
+
+ j_a = $('#index_head > div.tab_box [tab="' + tabname + '"] > a.button');
+ j_a.attr('href',tablink);
+ j_a.text(tabtext);
+ },
+ emptytab:function(){
+ $('#index_head > div.tab_box').empty();
+ },
+ hltab:function(tabname){
+ $('#index_head > div.tab_box > [tab="' + tabname + '"]').addClass('button_s');
+ },
+ lltab:function(tabname){
+ $('#index_head > div.tab_box > [tab="' + tabname + '"]').removeClass('button_s');
+ },
+
+ setcontent:function(j_content){
+ $('#index_head > div.content_box').append(j_content);
+ },
+ emptycontent:function(){
+ $('#index_head > div.content_box').empty();
+ },
+
+ showmask:function(){
+ $('#index_mask').stop().fadeIn('fast');
+ },
+ hidemask:function(){
+ $('#index_mask').stop().hide();
+ }
+};
diff --git a/toj/jcs/notice.css b/toj/jcs/notice.css
new file mode 100644
index 0000000..44c790e
--- /dev/null
+++ b/toj/jcs/notice.css
@@ -0,0 +1,58 @@
+div.notice_list_box{
+ width:0px;
+ position:absolute;
+ left:auto;
+ right:0px;
+ top:32px;
+ overflow:hidden;
+ z-index:100;
+}
+ul.notice_list{
+ width:256px;
+ height:100%;
+ margin:0px 0px;
+ padding:0px 0px;
+ background-color:#1C1C1C;
+ opacity:0;
+ position:absolute;
+ left:auto;
+ right:-256px;
+ top:0px;
+ z-index:2;
+ overflow-x:hidden;
+ overflow-y:auto;
+ list-style:none;
+}
+ul.notice_list > li.item{
+ width:auto;
+ height:96px;
+ padding:0px 0px 0px 6px;
+}
+ul.notice_list > li:hover.item{
+ color:#FFFFFF;
+ background-color:rgba(255,255,255,0.2);
+}
+ul.notice_list > li.item div.head{
+ padding:16px 0px 6px 0px;
+ font-weight:bold;
+ font-size:20px;
+}
+ul.notice_list > li.item div.content{
+ font-size:16px;
+ word-break:break-all;
+ overflow:hidden;
+}
+ul.notice_list a.item{
+ width:100%;
+ height:100%;
+ color:#91989F;
+ text-decoration:none;
+ position:relative;
+ top:0px;
+ left:50%;
+ cursor:pointer;
+ display:block;
+}
+ul.notice_list a.item_h{
+ color:#E9E9E9;
+}
diff --git a/toj/jcs/notice.js b/toj/jcs/notice.js
new file mode 100644
index 0000000..64e93ef
--- /dev/null
+++ b/toj/jcs/notice.js
@@ -0,0 +1,155 @@
+var notice = {
+ j_ajax:null,
+ 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){
+ 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');
+ j_content = j_item.find('div.content');
+
+ 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');
+ break;
+ }
+
+ return j_item;
+ },
+ updatenew:function(){
+ var j_list;
+
+ if(notice.j_ajax != null){
+ notice.j_ajax.abort();
+ }
+
+ j_list = $('#notice_list');
+ notice.j_ajax = $.post('/toj/php/notice.php',{'action':'get','data':JSON.stringify({'nid':0,'count':10})},
+ function(res){
+ var i;
+
+ var reto;
+ var noticeo;
+ var j_item;
+ var j_a;
+
+ if(res[0] != 'E'){
+ reto = JSON.parse(res);
+ for(i = 0;i < reto.length;i++){
+ noticeo = JSON.parse(reto[i].txt);
+ j_item = notice.listnew(noticeo);
+ j_list.prepend(j_item);
+ j_a = j_item.find('a.item');
+ j_a.addClass('item_h');
+ j_a.stop().animate({left:0},'slow','easeOutQuart');
+ }
+
+ if(notice.enid == null){
+ if(reto.length == 0){
+ notice.enid = 2147483647;
+ }else{
+ notice.enid = reto[0].nid;
+ }
+ notice.updateprev();
+ }
+ }
+
+ notice.j_ajax = null;
+ }
+ );
+ },
+ updateprev:function(){
+ var j_list;
+
+ j_list = $('#notice_list');
+ $.post('/toj/php/notice.php',{'action':'get','data':JSON.stringify({'nid':notice.enid,'count':10})},
+ function(res){
+ var i;
+
+ var reto;
+ var noticeo;
+ var j_item;
+
+ if(res[0] != 'E'){
+ reto = JSON.parse(res);
+ for(i = reto.length - 1;i >= 0;i--){
+ noticeo = JSON.parse(reto[i].txt);
+ j_item = notice.listnew(noticeo);
+ j_list.append(j_item);
+ j_item.find('a.item').stop().animate({left:0},'slow','easeOutQuart');
+ }
+
+ notice.enid = 0;
+ }
+ }
+ );
+ },
+ refresh:function(){
+ $.post('/toj/php/notice.php',{'action':'count','data':JSON.stringify({})},
+ function(res){
+ var count;
+ var j_notice;
+
+ if(res[0] != 'E'){
+ count = JSON.parse(res);
+ j_notice = $('#index_head_notice');
+ if(count == 0){
+ j_notice.removeClass('notice_h');
+ j_notice.text('[' + count + ']');
+ }else{
+ if($('#notice_list').css('opacity') == 1){
+ notice.updatenew();
+ }else{
+ j_notice.addClass('notice_h');
+ j_notice.text('[' + count + ']');
+ }
+ }
+
+ setTimeout(notice.refresh,1000);
+ }
+ }
+ );
+ }
+};
diff --git a/toj/jcs/pro.css b/toj/jcs/pro.css
new file mode 100644
index 0000000..0629ee1
--- /dev/null
+++ b/toj/jcs/pro.css
@@ -0,0 +1,28 @@
+div.pro_mask > div.sub_mbox{
+ width:62%;
+}
+div.pro_mask > div.sub_mbox > div.head{
+ width:100%;
+ height:32px;
+ padding:6px 0px 6px 0px;
+}
+div.pro_mask > div.sub_mbox > div.head > div.title{
+ font-size:20px;
+ line-height:32px;
+ float:left;
+}
+div.pro_mask > div.sub_mbox > div.head > div.error{
+ margin:0px 0px 0px 16px;
+ color:#FFA0A0;
+ font-size:16px;
+ line-height:32px;
+ float:left;
+}
+div.pro_mask > div.sub_mbox > div.head > div.oper{
+ float:right;
+}
+div.pro_mask > div.sub_mbox > div.head > div.oper > select{
+ height:32px;
+ border-width:0px;
+ font-size:16px;
+}
diff --git a/toj/jcs/pro.js b/toj/jcs/pro.js
new file mode 100644
index 0000000..5e4db35
--- /dev/null
+++ b/toj/jcs/pro.js
@@ -0,0 +1,165 @@
+var pro = {
+ init:function(){
+ pro.pro_page = new class_pro_page;
+ }
+};
+
+var class_pro_page = function(){
+ var that = this;
+ var ori_prop = new Object;
+ var j_page = $('#index_page > [page="pro"]');
+ var sub_mbox = new class_pro_sub_mbox(that);
+
+ that.proid = null;
+ that.proname = null;
+ that.pmodname = null;
+
+ that.__super();
+
+ that.urlchange = function(direct){
+ var proid;
+
+ var _check = function(){
+ proid = common.geturlpart()[1];
+ if(proid == ''){
+ return false;
+ }
+ proid = parseInt(proid);
+ return true;
+ };
+ var _in = function(){
+ index.settitle('TOJ-題目');
+
+ $.post('/toj/php/problem.php',{'action':'get_pro','data':JSON.stringify({'proid':proid})},function(res){
+ var css;
+ var reto;
+
+ if(res[0] != 'E'){
+ that.proid = proid;
+ reto = JSON.parse(res);
+ that.proname = reto.proname;
+ that.pmodname = reto.pmodname;
+ j_page.addClass(that.pmodname);
+
+ css = $('<link rel="stylesheet" type="text/css" href="/toj/pmod/' + that.pmodname + '/' + that.pmodname + '.css">');
+ $('head').append(css);
+ css.ready(function(){
+ $.get('/toj/pmod/' + that.pmodname + '/' + that.pmodname + '.html',{},function(res){
+ j_page.html(res);
+ $.getScript('/toj/pmod/' + that.pmodname + '/' + that.pmodname + '.js',function(script,stat,res){
+ eval(that.pmodname + '.init(that,j_page)');
+ that.export_urlchange('in');
+ });
+ });
+ });
+ }
+ });
+ };
+ var _out = function(){
+ that.export_urlchange('out');
+
+ for(key in that){
+ if(!(key in ori_prop)){
+ delete that[key];
+ }else{
+ that[key] = ori_prop[key];
+ }
+ }
+
+ j_page.empty();
+ j_page.removeClass(that.pmodname);
+ index.emptycontent();
+ index.emptytab();
+ that.proid = null;
+ that.proname = null;
+ that.pmodname = null;
+ };
+
+ if(direct == 'in'){
+ if(_check()){
+ _in();
+ }
+ }else if(direct == 'out'){
+ _out();
+ }else if(direct == 'same'){
+ if(_check()){
+ if(proid != that.proid){
+ _out();
+ _in();
+ }else{
+ that.export_urlchange('same');
+ }
+ }
+ }
+ };
+ that.submit = function(proid){
+ if(proid == undefined){
+ proid = that.proid
+ }
+ sub_mbox.init(proid);
+ common.showmbox(sub_mbox);
+ };
+
+ for(key in that){
+ ori_prop[key] = that[key];
+ }
+
+ common.addpage('pro',that);
+}; __extend(class_pro_page,class_common_page);
+
+var class_pro_sub_mbox = function(paobj){
+ var that = this;
+ var j_mbox = $('#index_mask > div.pro_mask > div.sub_mbox');
+ var j_error = j_mbox.find('div.head > div.error');
+ var codebox = CodeMirror(j_mbox.find('div.codebox')[0],{
+ mode:'text/x-c++src',
+ theme:'lesser-dark',
+ lineNumbers:true,
+ matchBrackets:true,
+ indentUnit:4
+ });
+
+ that.__super(paobj);
+
+ that.init = function(proid){
+ that.proid = proid;
+ j_mbox.find('div.head > div.title').text('上傳ProID:' + that.proid);
+ j_error.text('');
+ $(j_mbox.find('[name="lang"] > option')[0]).attr('selected',true);
+ codebox.setValue('');
+ };
+ that.switchchange = function(direct){
+ if(direct == 'in'){
+ that.fadein(j_mbox);
+ codebox.refresh();
+ }else if(direct == 'out'){
+ that.fadeout(j_mbox);
+ }
+ };
+
+ j_mbox.find('div.head > div.oper > button.submit').on('click',function(e){
+ $.post('/toj/php/problem.php',{'action':'submit_code','data':JSON.stringify({'proid':that.proid,'lang':1,'code':codebox.getValue()})},function(res){
+ if(res[0] == 'E'){
+ if(res == 'Enot_login'){
+ j_error.text('未登入');
+ }else if(res == 'Ewrong_language'){
+ j_error.text('語言錯誤');
+ }else if(res == 'Ecode_too_long'){
+ j_error.text('程式碼過長');
+ }else{
+ j_error.text('其他錯誤');
+ }
+ }else{
+ common.hidembox(j_mbox);
+ }
+ });
+ });
+ j_mbox.find('div.head > div.oper > button.cancel').on('click',function(e){
+ common.hidembox(j_mbox);
+ });
+
+ codebox.getWrapperElement().style.width = '100%';
+ codebox.getWrapperElement().style.height = '100%';
+ codebox.getScrollerElement().style.width = '100%';
+ codebox.getScrollerElement().style.height = '100%';
+}; __extend(class_pro_sub_mbox,class_common_mbox);
diff --git a/toj/jcs/sq.css b/toj/jcs/sq.css
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/toj/jcs/sq.css
diff --git a/toj/jcs/sq.js b/toj/jcs/sq.js
new file mode 100644
index 0000000..e3026b2
--- /dev/null
+++ b/toj/jcs/sq.js
@@ -0,0 +1,100 @@
+var sq = {
+ init:function(){
+ sq.sq_page = new class_sq_page;
+ }
+};
+
+var class_sq_page = function(){
+ var that = this;
+ var ori_prop = new Object;
+ var j_page = $('#index_page > [page="sq"]');
+
+ that.sqid = null;
+ that.sqname = null;
+ that.sqmodname = null;
+
+ that.__super();
+
+ that.urlchange = function(direct){
+ var sqid;
+
+ var _check = function(){
+ sqid = common.geturlpart()[1];
+ if(sqid == ''){
+ return false;
+ }
+ sqid = parseInt(sqid);
+ return true;
+ };
+ var _in = function(){
+ $.post('/toj/php/square.php',{'action':'get_sq','data':JSON.stringify({'sqid':sqid})},function(res){
+ var css;
+ var reto;
+
+ if(res[0] != 'E'){
+ that.sqid = sqid;
+ reto = JSON.parse(res);
+ that.sqname = reto.sqname;
+ that.sqmodname = reto.sqmodname;
+ j_page.addClass(that.sqmodname);
+ index.settitle('TOJ-' + that.sqname);
+
+ css = $('<link rel="stylesheet" type="text/css" href="/toj/sqmod/' + that.sqmodname + '/' + that.sqmodname + '.css">');
+ $('head').append(css);
+ css.ready(function(){
+ $.get('/toj/sqmod/' + that.sqmodname + '/' + that.sqmodname + '.html',{},function(res){
+ j_page.html(res);
+ $.getScript('/toj/sqmod/' + that.sqmodname + '/' + that.sqmodname + '.js',function(script,stat,res){
+ eval(that.sqmodname + '.init(that,j_page)');
+ that.export_urlchange('in');
+ });
+ });
+ });
+ }
+ });
+ };
+ var _out = function(){
+ that.export_urlchange('out');
+
+ for(key in that){
+ if(!(key in ori_prop)){
+ delete that[key];
+ }else{
+ that[key] = ori_prop[key];
+ }
+ }
+
+ j_page.empty();
+ j_page.removeClass(that.sqmodname);
+ index.emptycontent();
+ index.emptytab();
+ that.sqid = null;
+ that.sqname = null;
+ that.sqmodname = null;
+ };
+
+ if(direct == 'in'){
+ if(_check()){
+ _in();
+ }
+ }else if(direct == 'out'){
+ _out();
+ }else if(direct == 'same'){
+ if(_check()){
+ if(sqid != that.sqid){
+ _out();
+ _in();
+ }else{
+ that.export_urlchange('same');
+ }
+ }
+ }
+ }
+
+ for(key in that){
+ ori_prop[key] = that[key];
+ }
+
+ common.addpage('sq',that);
+}; __extend(class_sq_page,class_common_page);
+
diff --git a/toj/jcs/stat.css b/toj/jcs/stat.css
new file mode 100644
index 0000000..e0885e2
--- /dev/null
+++ b/toj/jcs/stat.css
@@ -0,0 +1,56 @@
+div.stat_page > div.sub_tab > table.sublist{
+ width:85%;
+ margin:0px auto 6px auto;
+ border-collapse:collapse;
+ text-align:left;
+}
+div.stat_page > div.sub_tab > table.sublist tr.head{
+ height:64px;
+ font-size:20px;
+}
+div.stat_page > div.sub_tab > table.sublist tr.item{
+ height:32px;
+ display:none;
+}
+div.stat_page > div.sub_tab > table.sublist tr:hover.item{
+ background-color:rgba(255,255,255,0.2);
+}
+div.stat_page > div.sub_tab > table.sublist th.subid,div.stat_page > div.sub_tab > table.sublist td.subid{
+ width:96px;
+}
+div.stat_page > div.sub_tab > table.sublist th.proid,div.stat_page > div.sub_tab > table.sublist td.proid{
+ width:96px;
+}
+div.stat_page > div.sub_tab > table.sublist th.nickname,div.stat_page > div.sub_tab > table.sublist td.nickname{
+ width:auto;
+}
+div.stat_page > div.sub_tab > table.sublist th.runtime,div.stat_page > div.sub_tab > table.sublist td.runtime{
+ width:96px;
+}
+div.stat_page > div.sub_tab > table.sublist th.memory,div.stat_page > div.sub_tab > table.sublist td.memory{
+ width:96px;
+}
+div.stat_page > div.sub_tab > table.sublist th.result,div.stat_page > div.sub_tab > table.sublist td.result{
+ width:64px;
+}
+div.stat_page > div.sub_tab > table.sublist th.score,div.stat_page > div.sub_tab > table.sublist td.score{
+ width:96px;
+}
+div.stat_page > div.sub_tab > table.sublist th.time,div.stat_page > div.sub_tab > table.sublist td.time{
+ width:256px;
+}
+div.stat_page > div.sub_tab > table.sublist th.lang,div.stat_page > div.sub_tab > table.sublist td.lang{
+ width:64px;
+}
+div.stat_page > div.sub_tab > table.sublist a.link{
+ color:#E9E9E9;
+ text-decoration:none;
+}
+div.stat_page > div.sub_tab > table.sublist a:hover.link{
+ color:#E9E9E9;
+ text-decoration:underline;
+}
+
+div.stat_mask > div.subinfo_mbox{
+ width:85%;
+}
diff --git a/toj/jcs/stat.js b/toj/jcs/stat.js
new file mode 100644
index 0000000..e0c7d55
--- /dev/null
+++ b/toj/jcs/stat.js
@@ -0,0 +1,364 @@
+var stat = {
+ init:function(){
+ stat.stat_page = new class_stat_page;
+ }
+};
+
+class_stat_page = function(){
+ var that = this;
+ var j_page = $('#index_page > [page="stat"]');
+ var j_blank = $('#index_page > [page="stat"] > div.blank');
+ var allsub_tab = new class_stat_allsub_tab(that);
+
+ that.subinfo_mbox = new class_stat_subinfo_mbox(that);
+
+ that.__super();
+
+ that.urlchange = function(direct){
+ var _in = function(){
+ that.fadein(j_page);
+
+ index.settitle('TOJ-狀態');
+
+ that.addtab('allsub',allsub_tab);
+ index.addtab('allsub','/toj/stat/allsub/','全部動態');
+
+ _change();
+ };
+ var _out = function(){
+ that.fadeout(j_page);
+ index.emptytab();
+ that.tab_urlchange(null);
+ };
+ var _change = function(){
+ var tabname;
+
+ tabname = common.geturlpart()[1];
+ if(!(tabname in that.tab_list)){
+ tabname = 'allsub';
+ common.replaceurl('/toj/stat/allsub/');
+ }
+ that.tab_urlchange(tabname);
+ }
+
+ if(direct == 'in'){
+ _in();
+ }else if(direct == 'out'){
+ _out();
+ }else if(direct == 'same'){
+ _change();
+ }
+ };
+
+ common.addpage('stat',that);
+}; __extend(class_stat_page,class_common_page);
+
+var class_stat_allsub_tab = function(paobj){
+ var that = this;
+ var j_tab = $('#index_page > [page="stat"] > [tab="allsub"]');
+ var j_table = j_tab.find('table.sublist');
+
+ var refresh_flag = false;
+ var j_ajax = null;
+ var ssubid = 0;
+ var esubid = 2147483647;
+ var lastupdate = null;
+ var topflag = true;
+ var topqueue = new Array;
+ var downblock = false;
+ var subid_curr = null;
+
+ var subinfo_switch = function(subid){
+ if(subid == undefined){
+ subid = common.geturlpart()[2];
+ }
+ if(subid != '' && subid != subid_curr){
+ subid_curr = parseInt(subid);
+ common.replaceurl('/toj/stat/allsub/' + subid_curr + '/');
+ that.paobj.subinfo_mbox.init(subid_curr);
+ common.showmbox(that.paobj.subinfo_mbox).always(function(){
+ subid_curr = null;
+ //common.prevurl();
+ });
+ }
+ };
+ var sub_listset = function(j_item,subo){
+ var j_a;
+
+ j_item.attr('subid',subo.subid);
+
+ j_item.find('td.subid').text(subo.subid);
+
+ j_a = j_item.find('td.proid > a.link');
+ j_a.attr('href','/toj/pro/' + subo.proid+ '/');
+ j_a.text(subo.proid);
+
+ j_a = j_item.find('td.nickname > a.link');
+ j_a.attr('href','/toj/user/' + subo.uid+ '/');
+ j_a.text(subo.nickname);
+
+ j_item.find('td.runtime').text(subo.runtime);
+ j_item.find('td.memory').text(subo.memory);
+ j_item.find('td.result').text(RESULTMAP[subo.result]);
+ j_item.find('td.score').text(subo.score);
+ j_item.find('td.time').text(common.getdatestring(subo.submit_time,true));
+ j_item.find('td.lang').text(common.getlang(subo.lang)[0]);
+
+ j_item.off('click').on('click',function(e){
+ if(e.target.tagName != 'A'){
+ subinfo_switch(subo.subid);
+ }
+ });
+ };
+ var sub_listnew = function(subo){
+ var j_item;
+
+ j_item = $('<tr class="item"><td class="subid"></td><td class="proid"><a class="link"></a></td><td class="nickname"><a class="link"></a></td><td class="runtime"></td><td class="memory"></td><td class="result"></td><td class="score"></td><td class="time"></td><td class="lang"></td></tr>');
+ sub_listset(j_item,subo);
+
+ return j_item;
+ };
+ var sub_refresh = function(){
+ if(refresh_flag == false){
+ return;
+ }
+ if(j_ajax != null){
+ j_ajax.abort();
+ }
+ j_ajax = $.post('/toj/php/status.php',{'action':'get_submit',
+ 'data':JSON.stringify({
+ 'filter':{'uid':null,'result':null,'proid':null,'lang':null},
+ 'sort':{'score':null,'runtime':null,'memory':null,'subid':[1,0]},
+ 'wait':10,
+ 'count':100,
+ 'last_update':lastupdate
+ })}
+ ,function(res){
+ var i;
+ var reto;
+ var j_item;
+ var maxsubid;
+
+ if(res[0] != 'E'){
+ reto = JSON.parse(res);
+
+ maxsubid = ssubid;
+ for(i = 0;i < reto.length;i++){
+ reto[i].submit_time = common.getdate(reto[i].submit_time);
+
+ j_item = j_table.find('[subid="' + reto[i].subid + '"]')
+ if(j_item.length > 0){
+ sub_listset(j_item,reto[i]);
+ }else if(reto[i].subid > ssubid){
+ if(topflag == true){
+ j_item = sub_listnew(reto[i]);
+ j_item.insertAfter(j_table.find('tr.head'));
+ j_item.css('opacity',0).slideDown('fast').fadeTo(100,1);
+ }else{
+ j_item = sub_listnew(reto[i]);
+ j_item.insertAfter(j_table.find('tr.head'));
+ topqueue.push(reto[i].subid);
+ }
+ }
+
+ if(reto[i].subid > maxsubid){
+ maxsubid = reto[i].subid;
+ }
+ if(reto[i].last_update > lastupdate){
+ lastupdate = reto[i].last_update;
+ }
+ }
+ ssubid = maxsubid;
+ }
+
+ j_ajax = null;
+ sub_refresh();
+ }
+ );
+ };
+ var sub_update = function(type){
+ if(type == 0){
+ while(topqueue.length > 0){
+ j_table.find('[subid="' + topqueue.pop() + '"]').css('opacity',0).slideDown('fast').fadeTo(100,1);
+ }
+ }else if(type == 1 && downblock == false){
+ downblock = true;
+ $.post('/toj/php/status.php',{'action':'get_submit',
+ 'data':JSON.stringify({
+ 'filter':{'uid':null,'result':null,'proid':null,'lang':null},
+ 'sort':{'score':null,'runtime':null,'memory':null,'subid':[0,esubid]},
+ 'wait':0,
+ 'count':50,
+ 'last_update':null
+ })}
+ ,function(res){
+ var i;
+ var reto;
+
+ if(res[0] == 'E'){
+ if(res != 'Eno_result'){
+ downblock = false;
+ }
+ }else{
+ reto = JSON.parse(res);
+ for(i = 0;i < reto.length;i++){
+ reto[i].submit_time = common.getdate(reto[i].submit_time);
+
+ j_item = sub_listnew(reto[i]);
+ j_table.append(j_item);
+ j_item.css('opacity',0).slideDown('fast').fadeTo(100,1);
+ }
+
+ if(lastupdate == null){
+ for(i = 0;i < reto.length;i++){
+ if(ssubid < reto[i].subid){
+ ssubid = reto[i].subid;
+ }
+ }
+
+ lastupdate = reto[0].last_update;
+ for(i = 1;i < reto.length;i++){
+ if(lastupdate < reto[i].last_update){
+ lastupdate = reto[i].last_update;
+ }
+ }
+
+ sub_refresh();
+
+ j_tab.on('scroll',function(e){
+ if(Math.floor(j_tab.scrollTop() / 32) < 10){
+ if(topflag == false){
+ topflag = true;
+ sub_update(0);
+ }
+ }else{
+ topflag = false;
+ }
+
+ if(Math.floor((j_table.height() - j_tab.scrollTop()) / 32) < 50){
+ sub_update(1);
+ }
+ });
+ }
+
+ esubid = reto[reto.length - 1].subid;
+ downblock = false;
+ }
+ }
+ );
+ }
+ };
+
+ that.__super(paobj);
+
+ that.urlchange = function(direct){
+ if(direct == 'in'){
+ that.fadein(j_tab);
+ refresh_flag = true;
+
+ sub_update(1);
+ subinfo_switch();
+ }else if(direct == 'out'){
+ that.fadeout(j_tab);
+ j_tab.off('scorll');
+ j_table.find('tr.item').remove();
+
+ if(j_ajax != null){
+ j_ajax.abort();
+ j_ajax = null;
+ }
+
+ refresh_flag = false;
+ j_ajax = null;
+ esubid = 2147483647;
+ lastupdate = null;
+ topflag = true;
+ topqueue = new Array;
+ downblock = false;
+ subid_curr = null;
+ }else if(direct == 'same'){
+ subinfo_switch();
+ }
+ };
+
+ j_table.on('mousedown',function(e){
+ return false;
+ });
+}; __extend(class_stat_allsub_tab,class_common_tab);
+
+var class_stat_subinfo_mbox = function(paobj){
+ var that = this;
+ var ori_prop = new Object;
+ var j_mbox = $('#index_mask > div.stat_mask > div.subinfo_mbox');
+ var subid = null;
+
+ that.subid = null;
+ that.smodname = null;
+ that.subo = null;
+
+ that.__super(paobj);
+
+ that.init = function(id){
+ subid = id;
+ };
+ that.switchchange = function(direct){
+ if(direct == 'in'){
+ $.post('/toj/php/status.php',{'action':'get_by_subid','data':JSON.stringify({'subid':subid})},function(res){
+ var reto;
+
+ if(res[0] != 'E'){
+ that.subid = subid;
+ reto = JSON.parse(res);
+ that.smodname = reto.smodname;
+ that.subo = reto;
+ delete that.subo.smodname;
+
+ j_mbox.addClass(that.smodname);
+
+ css = $('<link rel="stylesheet" type="text/css" href="/toj/smod/' + that.smodname + '/' + that.smodname + '.css">');
+ $('head').append(css);
+ css.ready(function(){
+ $.get('/toj/smod/' + that.smodname + '/' + that.smodname + '.html',{},function(res){
+ var j_h;
+ var j_button;
+
+ j_mbox.html(res);
+
+ j_h = $('<h2 style="padding:6px 0px 0px 0px;"></h2>');
+ j_h.text('SubID:' + that.subo.subid);
+ j_button = $('<button style="margin:6px 0px 0px 0px; float:right;">關閉</button>');
+ j_button.on('click',function(e){
+ common.hidembox('false');
+ });
+ j_mbox.prepend(j_h);
+ j_mbox.prepend(j_button);
+
+ $.getScript('/toj/smod/' + that.smodname + '/' + that.smodname + '.js',function(script,stat,res){
+ eval(that.smodname + '.init(that,j_mbox)');
+ that.export_switchchange('in');
+ });
+ });
+ });
+ }
+ });
+ }else if(direct == 'out'){
+ that.export_switchchange('out');
+
+ for(key in that){
+ if(!(key in ori_prop)){
+ delete that[key];
+ }
+ }
+
+ j_mbox.empty();
+ j_mbox.removeClass(that.smodname);
+ that.subid = null;
+ that.smodname = null;
+ that.subo = null;
+ }
+ };
+
+ for(key in that){
+ ori_prop[key] = true;
+ }
+}; __extend(class_stat_subinfo_mbox,class_common_mbox);
diff --git a/toj/jcs/user.css b/toj/jcs/user.css
new file mode 100644
index 0000000..171efaf
--- /dev/null
+++ b/toj/jcs/user.css
@@ -0,0 +1,175 @@
+div.user_page > div.main_tab > div.info_box{
+ width:256px;
+ height:100%;
+ background-color:#1C1C1C;
+ font-size:20px;
+ float:left;
+}
+div.user_page > div.main_tab > div.info_box > div.aboutme{
+ margin:6px 6px;
+ word-break:break-all;
+}
+div.user_page > div.main_tab > div.info_box > img.avatar{
+ width:100%;
+ display:block;
+}
+div.user_page > div.edit_tab > div.edit_box{
+ padding:64px 0px 64px 256px;
+}
+div.user_page > div.edit_tab > div.edit_box > img.avatar{
+ width:268px;
+ margin:0px 0px 16px 0px;
+ display:block;
+}
+div.user_page > div.edit_tab > div.edit_box > div.error{
+ margin:0px 0px 16px 0px;
+ font-size:16px;
+ color:#FFA0A0;
+}
+div.user_page > div.edit_tab > div.edit_box label{
+ font-size:16px;
+}
+div.user_page > div.edit_tab > div.edit_box input{
+ width:256px;
+ height:32px;
+ margin:0px 0px 16px 0px;
+ padding:0px 6px 0px 6px;
+ border-width:0px;
+ font-size:16px;
+ display:block;
+}
+div.user_page > div.mgsq_tab > div.in_box{
+ width:480px;
+ padding:0px 0px 64px 0px;
+ position:absolute;
+ top:64px;
+ left:256px;
+}
+div.user_page > div.mgsq_tab > div.out_box{
+ width:480px;
+ padding:0px 6px 64px 0px;
+ position:absolute;
+ top:64px;
+ left:752px;
+}
+div.user_page > div.mgsq_tab div.item{
+ margin:6px 0px 6px 0px;
+ padding:6px 6px;
+ font-size:16px;
+ cursor:pointer;
+}
+div.user_page > div.mgsq_tab div.item_s{
+ background-color:rgba(255,255,255,0.2);
+}
+div.user_page > div.mgsq_tab div:hover.item{
+ background-color:rgba(255,255,255,0.2);
+}
+div.user_page > div.mgsq_tab div.item > div.info{
+ width:100%;
+ height:32px;
+ line-height:32px;
+}
+div.user_page > div.mgsq_tab div.item > div.info > span.time{
+ height:32px;
+ font-size:14px;
+ line-height:32px;
+ text-align:right;
+ float:right;
+}
+div.user_page > div.mgsq_tab div.item > div.data{
+ width:100%;
+ height:32px;
+ margin:6px 0px 0px 0px;
+ display:none;
+}
+div.user_page > div.mgsq_tab div.item a{
+ height:100%;
+ text-decoration:none;
+ color:#E9E9E9;
+}
+div.user_page > div.mgsq_tab div.item a:hover{
+ text-decoration:underline;
+}
+div.user_page > div.mg_tab > div.left_box{
+ padding:64px 0px 0px 256px;
+ float:left;
+}
+div.user_mask > div.editsq_mbox{
+ width:31%;
+}
+div.user_mask > div.editsq_mbox > div.edit_box{
+ padding:64px 0px 64px 0px;
+}
+div.user_mask > div.editsq_mbox > div.edit_box > div.error{
+ margin:0px 0px 16px 0px;
+ font-size:16px;
+ color:#FFA0A0;
+}
+div.user_mask > div.editsq_mbox > div.edit_box label{
+ font-size:16px;
+}
+div.user_mask > div.editsq_mbox > div.edit_box input{
+ height:32px;
+ margin:0px 0px 16px 0px;
+ padding:0px 6px 0px 6px;
+ border-width:0px;
+ font-size:16px;
+ display:block;
+}
+div.user_mask > div.editsq_mbox > div.edit_box select{
+ height:32px;
+ margin:0px 0px 16px 0px;
+ border-width:0px;
+ font-size:16px;
+ display:block;
+}
+
+div.login_page > div.info_box{
+ width:31%;
+ margin:192px 0px 0px 19%;
+ float:left;
+}
+div.login_page > div.login_box{
+ width:31%;
+ margin:192px auto 0px auto;
+ float:left;
+}
+div.login_page > div.login_box > div.error{
+ margin:0px 0px 16px 0px;
+ font-size:16px;
+ color:#FFA0A0;
+}
+div.login_page > div.login_box > input{
+ width:256px;
+ height:32px;
+ margin:0px 0px 16px 0px;
+ padding:0px 6px 0px 6px;
+ border-width:0px;
+ font-size:16px;
+ display:block;
+}
+
+div.register_page > div.info_box{
+ width:31%;
+ margin:192px 0px 0px 19%;
+ float:left;
+}
+div.register_page > div.register_box{
+ width:31%;
+ margin:192px auto 0px auto;
+ float:left;
+}
+div.register_page > div.register_box > div.error{
+ margin:0px 0px 16px 0px;
+ font-size:16px;
+ color:#FFA0A0;
+}
+div.register_page > div.register_box > input{
+ width:256px;
+ height:32px;
+ margin:0px 0px 16px 0px;
+ padding:0px 6px 0px 6px;
+ border-width:0px;
+ font-size:16px;
+ display:block;
+}
diff --git a/toj/jcs/user.js b/toj/jcs/user.js
new file mode 100644
index 0000000..b8ffd3e
--- /dev/null
+++ b/toj/jcs/user.js
@@ -0,0 +1,1025 @@
+/*
+square state
+0 => wait
+1 => run
+2 => past
+*/
+
+var user = {
+ uid:null,
+ level:null,
+ username:null,
+ nickname:null,
+ avatar:null,
+ aboutme:null,
+ email:null,
+ sq_inlist:null,
+ loginchange:$.Callbacks(),
+ datachange:$.Callbacks(),
+
+ init:function(){
+ user.user_page = new class_user_page;
+ user.login_page = new class_login_page;
+ user.register_page = new class_register_page;
+
+ $('#index_panel > [page="logout"] > a.button').off('click').on('click',function(e){
+ var cookie;
+ var key;
+
+ cookie = common.getcookie();
+ for(key in cookie){
+ document.cookie = key + '=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/toj/';
+ }
+
+ location.href = '/toj/home/';
+ return false;
+ });
+ user.loginchange.add(function(login){
+ var j_notice;
+ var j_nickname;
+
+ j_notice = $('#index_head_notice');
+ j_nickname = $('#index_head_nickname > a.nickname')
+
+ if(login){
+ j_notice.show();
+ j_nickname.attr('href','/toj/user/' + user.uid + '/');
+ j_nickname.text(user.nickname);
+
+ index.showpanel('logout');
+ index.setpanel('user','/toj/user/' + user.uid + '/','個人');
+ index.showpanel('user');
+ }else{
+ j_notice.hide();
+ j_nickname.attr('href','');
+ j_nickname.text('');
+
+ index.hidepanel('logout');
+ index.hidepanel('user');
+ index.setpanel('user',null,'個人');
+ }
+ });
+ user.datachange.add(function(){
+ var i;
+ var j_ul;
+ var j_li;
+ var sqo;
+ var panelsq_listadd = function(j_ul,idx,sqid,sqname){
+ var j_li;
+ var j_a;
+
+ j_li = $(j_ul.find('li.button')[idx]);
+ if(j_li.length == 0){
+ j_li = $('<li class="button"><a class="button"></a></li>');
+ j_li.hide();
+ j_ul.append(j_li);
+ }
+
+ j_a = j_li.find('a.button');
+ j_a.attr('href','/toj/sq/' + sqid + '/pro/');
+ j_a.text(sqname);
+
+ j_li.show();
+ };
+
+ j_ul = $('#index_panel > ul.square_box');
+ j_ul.find('li.button').hide();
+ for(i = 0;i < user.sq_inlist.length;i++){
+ sqo = user.sq_inlist[i];
+ if(sqo.relationship != 1){
+ panelsq_listadd(j_ul,i,sqo.sqid,sqo.sqname);
+ }
+ }
+ });
+
+ user.updatedata(true);
+ },
+
+ updatedata:function(sync){
+ $.ajax({'url':'/toj/php/user.php',
+ 'type':'POST',
+ 'data':{'action':'view','data':JSON.stringify({'uid':null})},
+ 'async':!sync,
+ 'success':function(res){
+ var reto;
+ var old_uid;
+
+ old_uid = user.uid;
+ if(res[0] == 'E'){
+ user.uid = null;
+ user.level = null;
+ user.username = null;
+ user.nickname = null;
+ user.avatar = null;
+ user.aboutme = null;
+ user.email = null;
+ user.sq_inlist = null;
+
+ user.loginchange.fire(false);
+ }else{
+ reto = JSON.parse(res);
+ user.uid = reto.uid;
+ user.level = reto.level;
+ user.username = reto.username;
+ user.nickname = reto.nickname;
+ user.avatar = reto.avatar;
+ user.aboutme = reto.aboutme;
+ user.email = reto.email;
+
+ if(old_uid != user.uid){
+ user.loginchange.fire(true);
+ }
+
+ $.post('/toj/php/square.php',{'action':'get_entered_sq','data':JSON.stringify({'uid':user.uid})},function(res){
+ var i;
+ var reto;
+ var ts;
+ var sqlist;
+ var sqo;
+
+ if(res[0] == 'E'){
+ return;
+ }
+
+ reto = JSON.parse(res);
+ ts = common.getdate(reto.timestamp);
+ sqlist = reto.list;
+ for(i = 0;i < sqlist.length;i++){
+ sqo = sqlist[i];
+ sqo.state = 1;
+ if(sqo.start_time != null){
+ sqo.start_time = common.getdate(sqo.start_time);
+ if(ts < sqo.start_time){
+ sqo.state = 0;
+ }
+ }
+ if(sqo.end_time != null){
+ sqo.end_time = common.getdate(sqo.end_time);
+ if(sqo.end_time < ts){
+ sqo.state = 2;
+ }
+ }
+ }
+ user.sq_inlist = sqlist;
+
+ user.datachange.fire(true);
+ });
+ }
+ }
+ });
+ }
+};
+
+var class_user_page = function(){
+ var that = this;
+ var j_page = $('#index_page > [page="user"]');
+ var main_tab = new class_user_main_tab(that);
+ var edit_tab = new class_user_edit_tab(that);
+ var mgsq_tab = new class_user_mgsq_tab(that);
+ var mg_tab = new class_user_mg_tab(that);
+
+ that.__super();
+
+ that.editsq_mbox = new class_user_editsq_mbox(that);
+
+ that.uid = null;
+ that.nickname = null;
+ that.avatar = null;
+ that.aboutme = null;
+
+ that.urlchange = function(direct){
+ var uid;
+ var _check = function(){
+ uid = common.geturlpart()[1];
+ if(uid == ''){
+ if(user.uid == null){
+ common.pushurl('/toj/none/');
+ return false;
+ }
+ uid = user.uid;
+ common.replaceurl('/toj/user/' + uid + '/main/');
+ }
+ return true;
+ };
+ var _in = function(){
+ $.post('/toj/php/user.php',{'action':'view','data':JSON.stringify({'uid':uid})},function(res){
+ var reto;
+
+ if(res[0] == 'E'){
+ common.pushurl('/toj/none/');
+ }else{
+ reto = JSON.parse(res);
+ that.uid = reto.uid;
+ that.nickname = reto.nickname;
+ that.avatar = reto.avatar;
+ that.aboutme = reto.aboutme;
+
+ that.fadein(j_page);
+
+ index.settitle('TOJ-使用者');
+
+ that.addtab('main',main_tab);
+ index.addtab('main','/toj/user/' + that.uid + '/main/',that.nickname);
+
+ if(uid == user.uid){
+ that.addtab('mgsq',mgsq_tab);
+ index.addtab('mgsq','/toj/user/' + that.uid + '/mgsq/','你的方塊');
+ that.addtab('edit',edit_tab);
+ index.addtab('edit','/toj/user/' + that.uid + '/edit/','更改資料');
+
+ if((user.level & USER_LEVEL_SUPERADMIN) == USER_LEVEL_SUPERADMIN){
+ that.addtab('mg',mg_tab);
+ index.addtab('mg','/toj/user/' + that.uid + '/mg/','管理');
+ }
+ }
+
+ _change();
+ }
+ });
+ };
+ var _out = function(){
+ index.emptytab();
+ that.fadeout(j_page);
+ that.tab_urlchange(null);
+ that.uid = null;
+ };
+ var _change = function(){
+ var tabname;
+
+ tabname = common.geturlpart()[2];
+ if(!(tabname in that.tab_list)){
+ tabname = 'main';
+ common.replaceurl('/toj/user/' + that.uid + '/main/');
+ }
+ that.tab_urlchange(tabname);
+ };
+
+ if(direct == 'in'){
+ if(_check()){
+ _in();
+ }
+ }else if(direct == 'out'){
+ _out();
+ }else if(direct = 'same'){
+ if(_check()){
+ if(uid != that.uid || that.forceupdate){
+ that.forceupdate = false;
+ _out();
+ _in();
+ }else{
+ _change();
+ }
+ }
+ }
+ };
+
+ common.addpage('user',that);
+}; __extend(class_user_page,class_common_page);
+
+var class_user_main_tab = function(paobj){
+ var that = this;
+ var j_tab = $('#index_page > [page="user"] > [tab="main"]');
+
+ that.__super(paobj);
+
+ that.urlchange = function(direct){
+ if(direct == 'in'){
+ that.fadein(j_tab);
+
+ if(user.user_page.avatar == ''){
+ j_tab.find('div.info_box > img.avatar').attr('src','http://i.imgur.com/ykkQD.png');
+ }else{
+ j_tab.find('div.info_box > img.avatar').attr('src',that.paobj.avatar);
+ }
+ j_tab.find('div.info_box > div.aboutme').text(that.paobj.aboutme);
+ }else if(direct == 'out'){
+ that.fadeout(j_tab);
+ }
+ };
+}; __extend(class_user_main_tab,class_common_tab);
+
+var class_user_edit_tab = function(paobj){
+ var that = this;
+ var j_tab = $('#index_page > [page="user"] > [tab="edit"]');
+
+ that.__super(paobj);
+
+ that.urlchange = function(direct){
+ if(direct == 'in'){
+ that.fadein(j_tab);
+
+ j_tab.find('div.edit_box > [name="nickname"]').val(user.nickname);
+ j_tab.find('div.edit_box > [name="avatar"]').val(user.avatar);
+ if(user.avatar == ''){
+ j_tab.find('div.edit_box > img.avatar').attr('src','http://i.imgur.com/ykkQD.png');
+ }else{
+ j_tab.find('div.edit_box > img.avatar').attr('src',user.avatar);
+ }
+ j_tab.find('div.edit_box > [name="aboutme"]').val(user.aboutme);
+ j_tab.find('div.edit_box > [name="email"]').val(user.email);
+ }else if(direct == 'out'){
+ that.fadeout(j_tab);
+ j_tab.find('div.edit_box > input').val('');
+ j_tab.find('div.edit_box > img.avatar').attr('src',null);
+ j_tab.find('div.edit_box > div.error').text('');
+ }
+ };
+
+ j_tab.find('div.edit_box > [name="avatar"]').change(function(e){
+ var avatar;
+
+ avatar = $(this).val();
+ if(avatar == ''){
+ j_tab.find('div.edit_box > img.avatar').attr('src','http://i.imgur.com/ykkQD.png');
+ }else{
+ j_tab.find('div.edit_box > img.avatar').attr('src',avatar);
+ }('test')
+ });
+ j_tab.find('div.edit_box > button.submit').click(function(e){
+ var j_error;
+ var nickname;
+ var avatar;
+ var aboutme;
+ var email;
+ var password_old;
+ var password_new;
+ var password_repeat;
+ var data;
+
+ j_error = j_tab.find('div.edit_box > div.error');
+ nickname = j_tab.find('div.edit_box > [name="nickname"]').val();
+ avatar = j_tab.find('div.edit_box > [name="avatar"]').val();
+ aboutme = j_tab.find('div.edit_box > [name="aboutme"]').val();
+ email = j_tab.find('div.edit_box > [name="email"]').val();
+ password_old = j_tab.find('div.edit_box > [name="password_old"]').val();
+ password_new = j_tab.find('div.edit_box > [name="password_new"]').val();
+ password_repeat = j_tab.find('div.edit_box > [name="password_repeat"]').val();
+
+ data = {'nickname':nickname,'avatar':avatar,'aboutme':aboutme,'email':email};
+ if(password_old != '' || password_new != '' || password_repeat != ''){
+ if(password_new != password_repeat){
+ j_error.text('使用者密碼不相同');
+ return;
+ }
+ data.oldpw = password_old;
+ data.password = password_new;
+ }
+
+ $.post('/toj/php/user.php',{'action':'update','data':JSON.stringify(data)},function(res){
+ if(res[0] == 'E'){
+ switch(res){
+ case 'Epassword_too_short':
+ j_error.text('使用者密碼太短');
+ break;
+ case 'Epassword_too_long':
+ j_error.text('使用者密碼太長');
+ break;
+ case 'Enickname_too_short':
+ j_error.text('暱稱太短');
+ break;
+ case 'Enickname_too_long':
+ j_error.text('暱稱太長');
+ break;
+ case 'Eold_password_not_match':
+ j_error.text('舊使用者密碼錯誤');
+ break;
+ case 'Eempty_email':
+ j_error.text('電子郵件不能爲空');
+ break;
+ case 'Eemail_too_long':
+ j_error.text('電子郵件太長');
+ break;
+ default:
+ j_error.text('更新錯誤');
+ break;
+ }
+ }else{
+ user.updatedata(true);
+
+ that.paobj.forceupdate = true;
+ common.pushurl('/toj/user/' + user.uid + '/main/');
+ }
+ });
+ });
+ j_tab.find('div.edit_box > button.cancel').click(function(e){
+ common.pushurl('/toj/user/' + user.uid + '/main/');
+ });
+}; __extend(class_user_edit_tab,class_common_tab);
+
+var class_user_mgsq_tab = function(paobj){
+ var that = this;
+ var j_tab = $('#index_page > [page="user"] > [tab="mgsq"]');
+
+ var sq_join = function(sqid){
+ $.post('/toj/php/square.php',{'action':'add_user','data':JSON.stringify({'uid':user.uid,'sqid':sqid})},function(res){
+ if(res[0] != 'E'){
+ sq_update();
+ }
+ });
+ };
+ var sq_quit = function(sqid){
+ $.post('/toj/php/square.php',{'action':'delete_user','data':JSON.stringify({'uid':user.uid,'sqid':sqid})},function(res){
+ if(res[0] != 'E'){
+ sq_update();
+ }
+ });
+ };
+ var sq_listset = function(j_item,sqo){
+ var j_info;
+ var j_data;
+ var j_a;
+ var j_button;
+
+ j_info = j_item.find('div.info');
+ j_data = j_item.find('div.data');
+ j_data.empty();
+
+ j_item.attr('sqid',sqo.sqid);
+
+ j_a = j_info.find('span.name > a');
+ j_a.attr('href','/toj/sq/' + sqo.sqid + '/pro/');
+ j_a.text(sqo.sqname);
+
+ if(sqo.end_time == null){
+ j_info.find('span.time').text('');
+ }else{
+ j_info.find('span.time').text(common.getdatestring(sqo.start_time,false) + ' > ' + common.getdatestring(sqo.end_time,false));
+ }
+
+ if(sqo.relationship == 3 || (user.level & USER_LEVEL_SUPERADMIN) == USER_LEVEL_SUPERADMIN){
+ j_button = $('<button style="margin:0px 6px 0px 0px;">管理</button>');
+ j_button.on('click',function(e){
+ that.paobj.editsq_mbox.init('edit',sqo);
+ common.showmbox(that.paobj.editsq_mbox).done(sq_update);
+ return false;
+ });
+ j_data.append(j_button);
+ }
+
+ j_button = $('<button></button>');
+ if(sqo.relationship == 0){
+ if(sqo.publicity == 2 && (user.level & USER_LEVEL_SUPERADMIN) != USER_LEVEL_SUPERADMIN){
+ j_button.text('申請');
+ }else{
+ j_button.text('加入');
+ }
+ j_button.off('click').on('click',function(e){
+ sq_join(sqo.sqid);
+ return false;
+ });
+ }else{
+ if(sqo.relationship == 1 && (user.level & USER_LEVEL_SUPERADMIN) != USER_LEVEL_SUPERADMIN){
+ j_button.text('取消申請');
+ }else{
+ j_button.text('退出');
+ }
+ j_button.on('click',function(e){
+ sq_quit(sqo.sqid);
+ return false;
+ });
+ }
+ j_data.append(j_button);
+
+ j_item.off('click').on('click',function(e){
+ if(j_data.is(':visible')){
+ j_item.removeClass('item_s');
+ j_data.stop().fadeTo(100,0).slideUp('fast');
+ }else{
+ j_item.addClass('item_s');
+ j_data.stop().css('opacity',1).slideDown('fast');
+ }
+ });
+ };
+ var sq_listnew = function(sqo){
+ var j_item;
+ var j_info;
+ var j_data;
+
+ j_item = $('<div class="item"></div>');
+ j_info = $('<div class="info"><span class="name"><a></a></span><span class="time"></span></div>');
+ j_item.append(j_info);
+ j_data = $('<div class="data"></div>');
+ j_item.append(j_data);
+
+ sq_listset(j_item,sqo);
+
+ return j_item;
+ };
+ var sq_update = function(){
+ var _updatelist = function(j_list,sqlist){
+ var i;
+ var j;
+
+ var j_divs;
+ var j_last;
+ var j_item;
+ var oldhash;
+
+ j_divs = j_list.children('div.item');
+ oldhash = new Array();
+ for(i = 0;i < j_divs.length;i++){
+ oldhash[$(j_divs[i]).attr('sqid')] = i;
+ }
+
+ j = 0;
+ j_last = null;
+ for(i = 0;i < sqlist.length;i++){
+ sqo = sqlist[i];
+ if(sqo.sqid in oldhash){
+ for(;j < oldhash[sqo.sqid];j++){
+ j_item = $(j_divs[j]);
+ j_item.stop().fadeTo(100,0).slideUp('fast',function(){$(this).remove();});
+ }
+ j_item = $(j_divs[j]);
+ j++;
+
+ sq_listset(j_item,sqo);
+ j_last = j_item;
+ }else{
+ j_item = sq_listnew(sqo);
+ j_item.hide();
+ if(j_last == null){
+ j_list.prepend(j_item);
+ j_item.css('opacity',0).slideDown('fast').fadeTo(100,1);
+ }else{
+ j_item.insertAfter(j_last);
+ j_item.css('opacity',0).slideDown('fast').fadeTo(100,1);
+ }
+ j_last = j_item;
+ }
+ }
+ for(;j < j_divs.length;j++){
+ j_item = $(j_divs[j]);
+ j_item.stop().fadeTo(100,0).slideUp('fast',function(){$(this).remove();});
+ }
+ };
+
+ user.datachange.add(function(){
+ var i;
+ var sqo;
+ var sqwait;
+ var sqrun;
+ var sqpast;
+
+ var j_wait;
+ var j_run;
+ var j_past;
+
+ user.datachange.remove(arguments.callee);
+
+ sqwait = new Array();
+ sqrun = new Array();
+ sqpast = new Array();
+ for(i = 0;i < user.sq_inlist.length;i++){
+ sqo = user.sq_inlist[i];
+ switch(sqo.state){
+ case 0:
+ sqwait.push(sqo);
+ break;
+ case 1:
+ sqrun.push(sqo);
+ break;
+ case 2:
+ sqpast.push(sqo);
+ break;
+ };
+ }
+
+ j_wait = j_tab.find('div.in_box > div.wait');
+ j_run = j_tab.find('div.in_box > div.run');
+ j_past = j_tab.find('div.in_box > div.past');
+
+ _updatelist(j_wait,sqwait);
+ _updatelist(j_run,sqrun);
+ _updatelist(j_past,sqpast);
+ });
+ user.updatedata(false);
+
+ $.post('/toj/php/square.php',{'action':'get_available_sq','data':null},function(res){
+ var i;
+ var reto;
+ var ts;
+ var sqlist;
+ var sqo;
+ var sqwait;
+ var sqrun;
+ var sqpast;
+
+ var j_wait;
+ var j_run;
+ var j_past;
+
+ if(res[0] == 'E'){
+ return;
+ }
+
+ reto = JSON.parse(res);
+ ts = common.getdate(reto.timestamp);
+ sqlist = reto.list;
+ sqwait = new Array();
+ sqrun = new Array();
+ sqpast = new Array();
+ for(i = 0;i < sqlist.length;i++){
+ sqo = sqlist[i];
+ sqo.relationship = 0;
+ sqo.state = 1;
+ if(sqo.start_time != null){
+ sqo.start_time = common.getdate(sqo.start_time);
+ if(ts < sqo.start_time){
+ sqo.state = 0;
+ }
+ }
+ if(sqo.end_time != null){
+ sqo.end_time = common.getdate(sqo.end_time);
+ if(sqo.end_time < ts){
+ sqo.state = 2;
+ }
+ }
+
+ switch(sqo.state){
+ case 0:
+ sqwait.push(sqo);
+ break;
+ case 1:
+ sqrun.push(sqo);
+ break;
+ case 2:
+ sqpast.push(sqo);
+ break;
+ }
+ }
+
+ j_wait = j_tab.find('div.out_box > div.wait');
+ j_run = j_tab.find('div.out_box > div.run');
+ j_past = j_tab.find('div.out_box > div.past');
+
+ _updatelist(j_wait,sqwait);
+ _updatelist(j_run,sqrun);
+ _updatelist(j_past,sqpast);
+ });
+ }
+
+ that.__super(paobj);
+
+ that.urlchange = function(direct){
+ if(direct == 'in'){
+ that.fadein(j_tab);
+ sq_update();
+ }else if(direct == 'out'){
+ that.fadeout(j_tab);
+ j_tab.find('div.in_box > div > div').remove();
+ j_tab.find('div.out_box > div > div').remove();
+ }
+ };
+}; __extend(class_user_mgsq_tab,class_common_tab);
+
+var class_user_mg_tab = function(paobj){
+ var that = this;
+ var j_tab = $('#index_page > [page="user"] > [tab="mg"]');
+
+ that.__super(paobj);
+
+ that.urlchange = function(direct){
+ if(direct == 'in'){
+ that.fadein(j_tab);
+ }else if(direct == 'out'){
+ that.fadeout(j_tab);
+ }
+ };
+
+ j_tab.find('button.newsq').on('click',function(e){
+ that.paobj.editsq_mbox.init('new');
+ common.showmbox(that.paobj.editsq_mbox);
+ });
+}; __extend(class_user_mg_tab,class_common_tab);
+
+var class_user_editsq_mbox = function(paobj){
+ var that = this;
+ var j_mbox = $('#index_mask > div.user_mask > div.editsq_mbox');
+ var action = null;
+ var sqid;
+
+ that.__super(paobj);
+
+ that.init = function(act,sqo){
+ action = act;
+ if(action == 'edit'){
+ sqid = sqo.sqid;
+
+ console.log(sqo);
+ j_mbox.find('[name="sqname"]').val(sqo.sqname);
+ j_mbox.find('[name="sqmodname"]').val(sqo.sqmodname);
+ j_mbox.find('[name="publicity"]').val(sqo.publicity);
+ if(sqo.end_time == null){
+ j_mbox.find('[name="infinite"]').val(1);
+ }else{
+ j_mbox.find('[name="infinite"]').val(2);
+ j_mbox.find('div.time').show();
+ j_mbox.find('[name="s_year"]').val(sqo.start_time.getFullYear());
+ j_mbox.find('[name="s_month"]').val(sqo.start_time.getMonth() + 1);
+ j_mbox.find('[name="s_day"]').val(sqo.start_time.getDate());
+ j_mbox.find('[name="s_hr"]').val(sqo.start_time.getHours());
+ j_mbox.find('[name="s_min"]').val(sqo.start_time.getMinutes());
+ j_mbox.find('[name="e_year"]').val(sqo.end_time.getFullYear());
+ j_mbox.find('[name="e_month"]').val(sqo.end_time.getMonth() + 1);
+ j_mbox.find('[name="e_day"]').val(sqo.end_time.getDate());
+ j_mbox.find('[name="e_hr"]').val(sqo.end_time.getHours());
+ j_mbox.find('[name="e_min"]').val(sqo.end_time.getMinutes());
+ }
+ j_mbox.find('button.delete').show();
+ }
+ };
+ that.switchchange = function(direct){
+ if(direct == 'in'){
+ that.fadein(j_mbox);
+ }else if(direct == 'out'){
+ that.fadeout(j_mbox);
+ j_mbox.find('input').val('');
+ j_mbox.find('[name="publicity"]').val(3);
+ j_mbox.find('[name="infinite"]').val(1);
+ j_mbox.find('div.time').hide();
+ j_mbox.find('button.delete').hide();
+ j_mbox.find('div.error').text('');
+ }
+ };
+
+ j_mbox.find('[name="infinite"]').on('change',function(e){
+ if($(this).val() == 1){
+ j_mbox.find('div.time').hide();
+ }else{
+ j_mbox.find('div.time').show();
+ }
+ });
+ j_mbox.find('button.delete').on('click',function(e){
+ if(confirm('確定刪除方塊?')){
+ $.post('/toj/php/square.php',{'action':'delete_sq','data':JSON.stringify({'sqid':sqid})},function(res){
+ var j_error;
+
+ if(res[0] == 'E'){
+ j_error = j_mbox.find('div.error');
+ switch(res){
+ case 'Eno_login':
+ j_error.text('未登入');
+ case 'Epermission_denied':
+ j_error.text('權限不足');
+ break;
+ default:
+ j_error.text('其他錯誤');
+ break;
+ }
+ }else{
+ common.hidembox(true);
+ }
+ });
+ }
+ });
+ j_mbox.find('button.submit').on('click',function(e){
+ var sqname;
+ var sqmodname;
+ var publicity;
+ var start_time;
+ var end_time;
+ var j_error;
+
+ sqname = j_mbox.find('[name="sqname"]').val();
+ sqmodname = j_mbox.find('[name="sqmodname"]').val();
+ publicity = parseInt(j_mbox.find('[name="publicity"]').val());
+ if(j_mbox.find('[name="infinite"]').val() == 1){
+ start_time = null;
+ end_time = null;
+ }else{
+ start_time = j_mbox.find('[name="s_year"]').val() + '-' +
+ j_mbox.find('[name="s_month"]').val() + '-' +
+ j_mbox.find('[name="s_day"]').val() + ' ' +
+ j_mbox.find('[name="s_hr"]').val() + ':' +
+ j_mbox.find('[name="s_min"]').val();
+ end_time = j_mbox.find('[name="e_year"]').val() + '-' +
+ j_mbox.find('[name="e_month"]').val() + '-' +
+ j_mbox.find('[name="e_day"]').val() + ' ' +
+ j_mbox.find('[name="e_hr"]').val() + ':' +
+ j_mbox.find('[name="e_min"]').val();
+ }
+
+ j_error = j_mbox.find('div.error');
+ if(action == 'new'){
+ $.post('/toj/php/square.php',{'action':'add_sq','data':JSON.stringify({'sqname':sqname,'sqmodname':sqmodname,'publicity':publicity,'start_time':start_time,'end_time':end_time})},function(res){
+ if(res[0] == 'E'){
+ switch(res){
+ case 'Eno_login':
+ j_error.text('未登入');
+ case 'Epermission_denied':
+ j_error.text('權限不足');
+ break;
+ case 'Esqname_too_short':
+ j_error.text('方塊名稱太短');
+ break;
+ case 'Esqname_too_long':
+ j_error.text('方塊名稱太長');
+ break;
+ case 'Esqmodname_empty':
+ j_error.text('模組名稱不能爲空');
+ break;
+ default:
+ j_error.text('其他錯誤');
+ break;
+ }
+ }else{
+ common.hidembox(true);
+ }
+ });
+ }else if(action == 'edit'){
+ $.post('/toj/php/square.php',{'action':'edit_sq','data':JSON.stringify({'sqid':sqid,'sqname':sqname,'sqmodname':sqmodname,'publicity':publicity,'start_time':start_time,'end_time':end_time})},function(res){
+ if(res[0] == 'E'){
+ switch(res){
+ case 'Eno_login':
+ j_error.text('未登入');
+ case 'Epermission_denied':
+ j_error.text('權限不足');
+ break;
+ case 'Esqname_too_short':
+ j_error.text('方塊名稱太短');
+ break;
+ case 'Esqname_too_long':
+ j_error.text('方塊名稱太長');
+ break;
+ default:
+ j_error.text('其他錯誤');
+ break;
+ }
+ }else{
+ user.updatedata(false);
+ common.hidembox(true);
+ }
+ });
+ }
+ });
+ j_mbox.find('button.cancel').on('click',function(e){
+ common.hidembox(false);
+ });
+}; __extend(class_user_editsq_mbox,class_common_mbox);
+
+var class_login_page = function(){
+ var that = this;
+ var j_page = $('#index_page > [page="login"]');
+
+ that.__super();
+
+ that.urlchange = function(direct){
+ if(direct == 'in'){
+ that.fadein(j_page);
+ index.settitle('TOJ-登入');
+ j_page.find('div.login_box [name="username"]').focus();
+ }else if(direct == 'out'){
+ that.fadeout(j_page);
+ j_page.find('div.login_box > div.error').text('');
+ j_page.find('div.login_box > input').val('');
+ }
+ };
+
+ j_page.find('div.login_box > input').keypress(function(e){
+ if(e.which == 13){
+ j_page.find('div.login_box > button').click();
+ }
+ });
+
+ j_page.find('div.login_box > button').click(function(e){
+ var j_error;
+ var username;
+ var password;
+ var data;
+
+ j_error = j_page.find('div.login_box > div.error');
+ username = j_page.find('div.login_box [name="username"]').val();
+ password = j_page.find('div.login_box [name="password"]').val();
+
+ if(username == '' || password == ''){
+ j_error.text('欄位不可為空');
+ return;
+ }
+
+ data = {'username':username,'password':password};
+ $.post('/toj/php/user.php',{'action':'login','data':JSON.stringify(data)},function(res){
+ if(res[0] == 'E'){
+ j_error.text('登入錯誤');
+ }else{
+ user.updatedata(true);
+ common.prevurl('register');
+ }
+ });
+ });
+
+ user.loginchange.add(function(login){
+ if(login){
+ that.urlchange('out');
+ common.removepage('login');
+ index.hidepanel('login');
+ }else{
+ common.addpage('login',that);
+ index.showpanel('login');
+ }
+ });
+}; __extend(class_login_page,class_common_page);
+
+var class_register_page = function(){
+ var that = this;
+ var j_page = $('#index_page > [page="register"]');
+
+ that.__super();
+
+ that.urlchange = function(direct){
+ if(direct == 'in'){
+ that.fadein(j_page);
+ index.settitle('TOJ-註冊');
+ j_page.find('div.register_box [name="username"]').focus();
+ }else if(direct == 'out'){
+ that.fadeout(j_page);
+ j_page.find('div.register_box > div.error').text('');
+ j_page.find('div.register_box > div.register_box > input').val('');
+ j_page.find('div.register_box > div.register_box > div.cover').show();
+ }
+ };
+
+ j_page.find('div.register_box > input').keypress(function(e){
+ if(e.which == 13){
+ j_page.find('div.register_box > button').click();
+ }
+ });
+
+ j_page.find('div.register_box > button').click(function(e){
+ var j_error;
+ var username;
+ var password;
+ var password_repeat;
+ var nickname;
+ var email;
+ var data;
+
+ j_error = j_page.find('div.register_box > div.error');
+ username = j_page.find('div.register_box [name="username"]').val();
+ password = j_page.find('div.register_box [name="password"]').val();
+ password_repeat = j_page.find('div.register_box [name="password_repeat"]').val();
+ nickname = j_page.find('div.register_box [name="nickname"]').val();
+ email = j_page.find('div.register_box [name="email"]').val();
+
+ if(username == '' || password == '' || password_repeat == '' || nickname == '' || email == ''){
+ j_error.text('欄位不可為空');
+ return;
+ }
+ if(password != password_repeat){
+ j_error.text('使用者密碼不相同');
+ return;
+ }
+
+ data = {'username':username,'password':password,'nickname':nickname,'email':email};
+ $.post('/toj/php/user.php',{'action':'register','data':JSON.stringify(data)},function(res){
+ if(res[0] == 'E'){
+ switch(res){
+ case 'Eusername_too_short':
+ j_error.text('使用者名稱太短');
+ break;
+ case 'Eusername_too_long':
+ j_error.text('使用者名稱太長');
+ break;
+ case 'Epassword_too_short':
+ j_error.text('使用者密碼太短');
+ break;
+ case 'Epassword_too_long':
+ j_error.text('使用者密碼太長');
+ break;
+ case 'Enickname_too_short':
+ j_error.text('暱稱太短');
+ break;
+ case 'Enickname_too_long':
+ j_error.text('暱稱太長');
+ break;
+ case 'Eusername_exists':
+ j_error.text('使用者名稱已存在');
+ break;
+ case 'Eempty_email':
+ j_error.text('電子郵件不能爲空');
+ break;
+ case 'Eemail_too_long':
+ j_error.text('電子郵件太長');
+ break;
+ default:
+ j_error.text('註冊錯誤');
+ break;
+ }
+ }else{
+ user.updatedata(true);
+ common.prevurl('login');
+ }
+ });
+ });
+
+ user.loginchange.add(function(login){
+ if(login){
+ that.urlchange('out');
+ common.removepage('register');
+ index.hidepanel('register');
+ }else{
+ common.addpage('register',that);
+ index.showpanel('register');
+ }
+ });
+}; __extend(class_register_page,class_common_page);