From 56688ed6d0b18f68ac8ddd82c4944c5d2777d20a Mon Sep 17 00:00:00 2001 From: pzread Date: Fri, 1 Mar 2013 22:30:00 +0800 Subject: Taiwan Online Judge Alpha 1 --- toj/pmod/pmod_multisub/pmod_multisub.css | 52 ++++++++++++++++ toj/pmod/pmod_multisub/pmod_multisub.html | 40 +++++++++++++ toj/pmod/pmod_multisub/pmod_multisub.js | 98 +++++++++++++++++++++++++++++++ toj/pmod/pmod_multisub/pmod_multisub.php | 77 ++++++++++++++++++++++++ toj/pmod/pmod_test/pmod_test.css | 53 +++++++++++++++++ toj/pmod/pmod_test/pmod_test.html | 37 ++++++++++++ toj/pmod/pmod_test/pmod_test.js | 74 +++++++++++++++++++++++ toj/pmod/pmod_test/pmod_test.php | 42 +++++++++++++ 8 files changed, 473 insertions(+) create mode 100755 toj/pmod/pmod_multisub/pmod_multisub.css create mode 100755 toj/pmod/pmod_multisub/pmod_multisub.html create mode 100755 toj/pmod/pmod_multisub/pmod_multisub.js create mode 100755 toj/pmod/pmod_multisub/pmod_multisub.php create mode 100755 toj/pmod/pmod_test/pmod_test.css create mode 100755 toj/pmod/pmod_test/pmod_test.html create mode 100755 toj/pmod/pmod_test/pmod_test.js create mode 100755 toj/pmod/pmod_test/pmod_test.php (limited to 'toj/pmod') diff --git a/toj/pmod/pmod_multisub/pmod_multisub.css b/toj/pmod/pmod_multisub/pmod_multisub.css new file mode 100755 index 0000000..308cc94 --- /dev/null +++ b/toj/pmod/pmod_multisub/pmod_multisub.css @@ -0,0 +1,52 @@ +div.pmod_multisub > div.main_content{ + margin:32px 0px 32px 256px; +} +div.pmod_multisub > table.probox{ + width:100%; + margin:0px 0px 32px 0px; + border-collapse:collapse; +} +div.pmod_multisub > table.probox td.info{ + width:250px; + padding:0px 0px 0px 6px; + vertical-align:top; +} +div.pmod_multisub > table.probox td.info > table.statlist{ + width:100%; + text-align:left; + border-collapse:collapse; +} +div.pmod_multisub > table.probox td.info > table.statlist td.name{ + width:96px; +} +div.pmod_multisub > table.probox td.info > table.statlist td.value{ + width:auto; +} +div.pmod_multisub > table.probox td.info > table.limitlist{ + width:100%; + text-align:left; + border-collapse:collapse; +} +div.pmod_multisub > table.probox td.info > table.limitlist td.name{ + width:96px +} +div.pmod_multisub > table.probox td.info > table.limitlist td.value{ + width:auto; +} +div.pmod_multisub > table.probox td.info > table.scorelist{ + width:100%; + text-align:left; + border-collapse:collapse; +} +div.pmod_multisub > table.probox td.info > table.scorelist tr.item{ + font-size:16; +} +div.pmod_multisub > table.probox td.info > table.scorelist th.no,div.pmod_multisub > td.info > table.scorelist td.no{ + width:64px; +} +div.pmod_multisub > table.probox td.info > table.scorelist th.score,div.pmod_multisub > td.info > table.scorelist td.score{ + width:auto; +} +div.pmod_multisub > table.probox td.content{ + vertical-align:top; +} diff --git a/toj/pmod/pmod_multisub/pmod_multisub.html b/toj/pmod/pmod_multisub/pmod_multisub.html new file mode 100755 index 0000000..07b19a9 --- /dev/null +++ b/toj/pmod/pmod_multisub/pmod_multisub.html @@ -0,0 +1,40 @@ +
+ + + + diff --git a/toj/pmod/pmod_multisub/pmod_multisub.js b/toj/pmod/pmod_multisub/pmod_multisub.js new file mode 100755 index 0000000..9cbd7a3 --- /dev/null +++ b/toj/pmod/pmod_multisub/pmod_multisub.js @@ -0,0 +1,98 @@ +var pmod_multisub = { + that:null, + j_page:null, + + init:function(that,j_page){ + pmod_multisub.that = that; + pmod_multisub.j_page = j_page; + + that.export_urlchange = function(direct){ + if(direct == 'in'){ + that.fadein(j_page); + + $.post('/toj/pmod/pmod_multisub/pmod_multisub.php',{'proid':JSON.stringify(that.proid)},function(res){ + var i; + var reto; + + reto = JSON.parse(res); + if(reto.redirect != undefined){ + common.pushurl('/toj/pro/' + reto.redirect + '/'); + }else{ + j_page.find('div.main_content').text(reto.main_content); + index.setcontent($('' + reto.proname + '')); + + for(i = 0;i < reto.pro.length;i++){ + pmod_multisub.probox_add(reto.pro[i]); + } + } + }); + }else if(direct == 'out'){ + that.fadeout(j_page); + }else if(direct == 'same'){ + + } + }; + }, + probox_add:function(proo){ + var i; + + var j_probox; + var j_table; + var j_item; + + j_probox = pmod_multisub.j_page.find('table.ori_probox').clone(); + j_probox.removeClass('ori_probox'); + + j_probox.find('td.info > h2.partname').text(proo.partname + ' (' + proo.score + '%)'); + j_probox.find('td.content').html(proo.content); + + $.post('/toj/php/problem.php',{'action':'get_pro_stat','data':JSON.stringify({'proid':proo.proid})},function(res){ + var reto + + if(res[0] != 'E'){ + reto = JSON.parse(res); + j_probox.find('td.info > table.statlist td.bscore').text(reto.score); + if(reto.tried == false){ + j_probox.find('td.info > table.statlist td.bscore').css('color','#1C1C1C'); + j_probox.find('td.info > table.statlist td.stat').text('未嘗試'); + }else{ + if(reto.score < 60){ + j_probox.find('td.info > table.statlist td.bscore').css('color','#FF0000'); + }else if(reto.score < 80){ + j_probox.find('td.info > table.statlist td.bscore').css('color','#00FF00'); + }else if(reto.score < 100){ + j_probox.find('td.info > table.statlist td.bscore').css('color','#FFFF00'); + }else{ + + j_probox.find('td.info > table.statlist td.bscore').css('color','#FFFFFF'); + } + + if(reto.is_ac == true){ + j_probox.find('td.info > table.statlist td.stat').text('已通過'); + }else{ + j_probox.find('td.info > table.statlist td.stat').text('已嘗試'); + } + } + } + }); + + j_probox.find('td.info > table.limitlist td.timelimit').text(proo.timelimit + ' ms'); + j_probox.find('td.info > table.limitlist td.memlimit').text(proo.memlimit + ' KB'); + + j_table = j_probox.find('table.scorelist'); + j_table.find('tr.item').remove(); + for(i = 0;i < proo.partition.count;i++){ + j_item = $(''); + j_item.find('td.no').text(i + 1); + j_item.find('td.score').text(proo.partition.score[i]); + j_table.append(j_item); + } + + j_probox.find('td.info > button.submit').on('click',function(e){ + pmod_multisub.that.submit(proo.proid); + }); + + j_probox.show(); + pmod_multisub.j_page.append(j_probox); + } +}; diff --git a/toj/pmod/pmod_multisub/pmod_multisub.php b/toj/pmod/pmod_multisub/pmod_multisub.php new file mode 100755 index 0000000..342ff41 --- /dev/null +++ b/toj/pmod/pmod_multisub/pmod_multisub.php @@ -0,0 +1,77 @@ +pmodname != PMODNAME) + exit('Ewrong_pmod'); + +$prodir = '/srv/http/toj/center/pro/'; + +$redir = file_get_contents($prodir.$proid.'/redirect'); +if($redir) +{ + $ret = new stdClass(); + $ret->redirect = intval($redir); + exit(json_encode($ret)); +} + +$ret = new stdClass(); + +$mfile = file_get_contents($prodir.$proid.'/multiset'); +$multiset = json_decode($mfile); + +$main_cont = file_get_contents($prodir.$proid.'/public/main_content'); +$ret->main_content = $main_cont; +$ret->pro = array(); +$ret->proname = $multiset->proname; + +foreach($multiset->prolist as $spro) +{ + $apro = new stdClass(); + $apro->proid = $spro->proid; + $apro->score = $spro->score; + $apro->partname = $spro->partname; + + $apro->content = file_get_contents($prodir.$apro->proid.'/public/content'); + $setting = get_set($prodir.$apro->proid.'/'); + $apro->timelimit = $setting->timelimit; + $apro->memlimit = $setting->memlimit; + $apro->partition = new stdClass(); + $apro->partition->count = $setting->count; + $apro->partition->score = $setting->score; + + array_push($ret->pro, $apro); +} + +echo(json_encode($ret)); +db_close($sqlc); +?> diff --git a/toj/pmod/pmod_test/pmod_test.css b/toj/pmod/pmod_test/pmod_test.css new file mode 100755 index 0000000..2cd5bfb --- /dev/null +++ b/toj/pmod/pmod_test/pmod_test.css @@ -0,0 +1,53 @@ +div.pmod_test > div.info{ + width:250px; + height:100%; + padding:0px 0px 0px 6px; + position:absolute; + top:0px; + left:0px; + overflow:auto; +} +div.pmod_test > div.info > table.statlist{ + width:100%; + text-align:left; + border-collapse:collapse; +} +div.pmod_test > div.info > table.statlist td.name{ + width:96px; +} +div.pmod_test > div.info > table.statlist td.value{ + width:auto; +} +div.pmod_test > div.info > table.limitlist{ + width:100%; + text-align:left; + border-collapse:collapse; +} +div.pmod_test > div.info > table.limitlist td.name{ + width:96px +} +div.pmod_test > div.info > table.limitlist td.value{ + width:auto; +} +div.pmod_test > div.info > table.scorelist{ + width:100%; + text-align:left; + border-collapse:collapse; +} +div.pmod_test > div.info > table.scorelist tr.item{ + font-size:16; +} +div.pmod_test > div.info > table.scorelist th.no,div.pmod_test > div.info > table.scorelist td.no{ + width:64px; +} +div.pmod_test > div.info > table.scorelist th.score,div.pmod_test > div.info > table.scorelist td.score{ + width:auto; +} +div.pmod_test > div.content{ + height:100%; + padding:0px 6px 0px 0px; + position:absolute; + top:0px; + left:256px; + overflow:auto; +} diff --git a/toj/pmod/pmod_test/pmod_test.html b/toj/pmod/pmod_test/pmod_test.html new file mode 100755 index 0000000..10b297b --- /dev/null +++ b/toj/pmod/pmod_test/pmod_test.html @@ -0,0 +1,37 @@ +
+

ProID:

+ + +

狀態

+ + + + + + + + + +
最佳分數
解題狀態
+ +

限制

+ + + + + + + + + +
時間限制
記憶體限制
+ +

配分

+ + + + + +
#Score
+
+
diff --git a/toj/pmod/pmod_test/pmod_test.js b/toj/pmod/pmod_test/pmod_test.js new file mode 100755 index 0000000..c691c8a --- /dev/null +++ b/toj/pmod/pmod_test/pmod_test.js @@ -0,0 +1,74 @@ +var pmod_test = { + init:function(that,j_page){ + that.export_urlchange = function(direct){ + if(direct == 'in'){ + that.fadein(j_page); + j_page.find('div.info > h2.proid').text('ProID:' + that.proid); + $.post('/toj/pmod/pmod_test/pmod_test.php',{'proid':JSON.stringify(that.proid)},function(res){ + var i; + var reto; + var seto; + var j_table; + var j_item; + + if(res[0] != 'E'){ + reto = JSON.parse(res); + seto = reto.set; + index.setcontent($('' + that.proname + '')); + j_page.find('div.content').html(reto.content); + + $.post('/toj/php/problem.php',{'action':'get_pro_stat','data':JSON.stringify({'proid':that.proid})},function(res){ + var reto + + if(res[0] != 'E'){ + reto = JSON.parse(res); + j_page.find('div.info > table.statlist td.bscore').text(reto.score); + if(reto.tried == false){ + j_page.find('div.info > table.statlist td.bscore').css('color','#1C1C1C'); + j_page.find('div.info > table.statlist td.stat').text('未嘗試'); + }else{ + if(reto.score < 60){ + j_page.find('div.info > table.statlist td.bscore').css('color','#FF0000'); + }else if(reto.score < 80){ + j_page.find('div.info > table.statlist td.bscore').css('color','#00FF00'); + }else if(reto.score < 100){ + j_page.find('div.info > table.statlist td.bscore').css('color','#FFFF00'); + }else{ + + j_page.find('div.info > table.statlist td.bscore').css('color','#FFFFFF'); + } + + if(reto.is_ac == true){ + j_page.find('div.info > table.statlist td.stat').text('已通過'); + }else{ + j_page.find('div.info > table.statlist td.stat').text('已嘗試'); + } + } + } + }); + + j_page.find('div.info > table.limitlist td.timelimit').text(seto.timelimit + ' ms'); + j_page.find('div.info > table.limitlist td.memlimit').text(seto.memlimit + ' KB'); + + j_table = j_page.find('table.scorelist'); + j_table.find('tr.item').remove(); + for(i = 0;i < seto.count;i++){ + j_item = $(''); + j_item.find('td.no').text(i + 1); + j_item.find('td.score').text(seto.score[i]); + j_table.append(j_item); + } + } + }); + }else if(direct == 'out'){ + that.fadeout(j_page); + }else if(direct == 'same'){ + + } + }; + + j_page.find('div.info > button.submit').on('click',function(e){ + that.submit(); + }); + } +}; diff --git a/toj/pmod/pmod_test/pmod_test.php b/toj/pmod/pmod_test/pmod_test.php new file mode 100755 index 0000000..27eecf2 --- /dev/null +++ b/toj/pmod/pmod_test/pmod_test.php @@ -0,0 +1,42 @@ +pmodname != PMODNAME) + exit('Ewrong_pmod'); + +db_close($sqlc); + +$prodir = '/srv/http/toj/center/pro/'.$proid.'/'; + +$fd = fopen($prodir.'setting','r'); +while($line = fgets($fd)){ + if($line[0] == '='){ + break; + } +} +$set = ''; +while(($line = fgets($fd))){ + $set = $set.$line; +} +fclose($fd); + +$content = file_get_contents($prodir.'public/content'); + +echo(json_encode(array( + 'set' => json_decode($set), + 'content' => $content +))); +?> -- cgit v1.2.3