Skip to content

Commit

Permalink
Add Virtual Participate Register in contest page and Show Data option…
Browse files Browse the repository at this point in the history
…s in submission page
  • Loading branch information
tiger2005 committed Dec 10, 2021
1 parent a555409 commit a521391
Show file tree
Hide file tree
Showing 10 changed files with 287 additions and 12 deletions.
17 changes: 13 additions & 4 deletions css/client.css
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ img[src=""],img:not([src]){opacity:0;}
width: calc(100% - 10px);
height: calc(100% - 10px);
}
.submissionDisplayer > div:first-child{
.submissionDisplayer > div{
padding: 5px 10px;
height: calc(100% - 10px);
width: calc(100% - 20px);
Expand Down Expand Up @@ -895,7 +895,7 @@ pre code{
pre{
font-family: inherit !important;
}
.submissionCloser{
.submissionCloser, .submissionDataLister, .submissionCodeLister{
cursor: pointer;
}

Expand Down Expand Up @@ -1754,7 +1754,16 @@ pre{


/* CSS */

.submissionDataDetail{
user-select: text;
}
.submissionDataListItem{
cursor: pointer;
transition: 0.3s;
}
.submissionDataListItem:hover, .submissionDataListItem.selected{
background: var(--pop-out-block-background-color-1);
}
.searchPageTop, .searchPageTip{
background: var(--contest-info-bar-background-color);
}
Expand Down Expand Up @@ -1812,7 +1821,7 @@ pre{
.probpageSelectIf.selected{
background: var(--problist-sort-button-selected-background-color);
}
.infoChangeUsernameInterface{
.infoChangeUsernameInterface, .contestInsertTimeInterface{
background: var(--pop-out-block-background-color);
}
.inputButtonSplitter > button{
Expand Down
5 changes: 3 additions & 2 deletions css/dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
--single-progress-bar-color: #777;
--single-memory-used-border-bottom-color: #777;
--single-switch-buttons-background-color: #424254;
--single-switch-buttons-hover-background-color: #424254;
--single-switch-buttons-selected-background-color: #424254;
--single-switch-buttons-hover-background-color: #48485a;
--single-switch-buttons-selected-background-color: #55556a;
--single-rank-delta-background-color: #455055;
--single-progress-bar-poptip-background-color: #111;
--single-grid-mode-background-color: #434348;
Expand Down Expand Up @@ -69,6 +69,7 @@
--settings-select-background-color: rgb(36, 41, 46);
/* POPOUTS */
--pop-out-block-background-color: rgb(35, 40, 45);
--pop-out-block-background-color-1: rgb(45, 50, 55);
--pop-out-block-closer-background-color: #555;
--pop-out-block-closer-hover-background-color: #666;
/* SCROLL */
Expand Down
1 change: 1 addition & 0 deletions css/default.css
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
--settings-select-background-color: #ddd;
/* POPOUTS */
--pop-out-block-background-color: #ddd;
--pop-out-block-background-color-1: #ccc;
--pop-out-block-closer-background-color: #ccc;
--pop-out-block-closer-hover-background-color: #bbb;
/* SCROLL */
Expand Down
26 changes: 26 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,21 @@
</div>
<div>
<span class="submissionCloser"><i class="fas fa-angle-left"></i> <span info='back'></span></span>
<span class="submissionDataLister" style="float: right">
<i class='fas fa-database'></i> <span info='showData'></span>
</span>
</div>
</div>
<div style="display: flex; flex-direction: column; height: calc(100% - 10px)">
<div style="flex: 1; display: flex; flex-direction: row; overflow: hidden;">
<div style="width: 200px; overflow-y: auto; margin-right: 10px; background: var(--pop-out-block-background-color); border-radius: 5px" class="submissionDataList"></div>
<div style="flex: 1; background: var(--pop-out-block-background-color); border-radius: 5px; overflow-y: auto;" class="submissionDataDetail"></div>
</div>
<div style="margin-top: 10px">
<span class="submissionCloser"><i class="fas fa-angle-left"></i> <span info='back'></span></span>
<span class="submissionCodeLister" style="float: right">
<i class='fas fa-code'></i> <span info='showCode'></span>
</span>
</div>
</div>
</div>
Expand Down Expand Up @@ -485,6 +500,17 @@
<div class="contentWrapper contestContent">
<div class="contentRowInfo">
<div class="contentPage">
<div class="loadingInterface contestInsertTimeWindow" style="display: none; opacity: 0"><div style="height: 90px; width: 450px; padding: 10px; border-radius: 5px; display: flex; flex-direction: column; overflow: hidden" class="contestInsertTimeInterface">
<div class="contestInsertTimeWindow" style="height: 30px; width: 100%; font-size: 16px;display: flex; flex-direction: row; overflow: hidden; position: relative;">
<div style="overflow: hidden; flex: 1;">
<span info="contestInsertTime" style="user-select: none"></span>
</div><div style="position: absolute; width: 24px; top: 0px; right: 0px;"><i class="fas fa-times red closeContestInsertTime" style="cursor: pointer"></i></div>
</div>
<div class="inputButtonSplitter contestInsertTimeInputArea">
<input info="contestTimeInput"></input>
<button class="primaryColor"><i class="fas fa-paper-plane"></i></button>
</div>
</div></div>
<div class="loadingInterface contestLoadingInterface" style="display: none; opacity: 0; z-index: 999">
<div>
<i class='fas fa-clock'></i>
Expand Down
58 changes: 58 additions & 0 deletions js/authorize.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,64 @@ function registerContest(ci, S, E){
});
}

function registerVirtualRound(ci, tm, S, E){
var months = [
"January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"
];
var offsetTime = new Date(tm.getTime() + tm.getTimezoneOffset() * 60 * 1000);
$.ajax({
url: settings.mainURL,
success: function(data){
var csrf = queryCsrf.exec(data);
if(csrf == null){
E("fa-unlink");
return;
}
csrf = csrf[1];
$.ajax({
url: settings.mainURL + '/contestRegistration/' + ci + '/virtual/true',
type: "POST",
data: {
csrf_token: csrf,
action: "formSubmitted",
ftaa: getFtaa(),
bfaa: "f1b3f18c715565b589b7823cda7448ce",
_tta: 292,
virtual: "true",
backUrl: "",
takePartAs: "personal",
initialDatetime: `${months[offsetTime.getMonth()].substring(0, 3)}/${offsetTime.getDate()}/${offsetTime.getFullYear()} ${offsetTime.pattern("hh:mm")}`,
clientTimezoneOffset: (- tm.getTimezoneOffset()),
startDay: `${months[tm.getMonth()].substring(0, 3)}/${tm.getDate()}/${tm.getFullYear()}`,
startTime: tm.pattern("hh:mm"),
teamId: -1,
requiredConfirmation: "true"
},
success: function(d){
var q = $(d).find(".lang-chooser > div").eq(1);
if(q.children("a").eq(1).html() == "Register"){
currentLoginHandle = "";
getSolvedProblemsByContest = {problemCountsByContestId: {}, solvedProblemCountsByContestId: {}};
E("fa-unlink");
return;
}
if(d.indexOf("You have been successfully registered") == -1){
E("fa-exclamation-triangle"); return;
}
S();
},
error: function(){
E("fa-unlink");
}
})
},
error: function(){
E("fa-unlink");
}
});
}

function generateAuthorizeURL(url, data){
function parseObject(x){
var ret = [];
Expand Down
68 changes: 67 additions & 1 deletion js/contest.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,66 @@ function contestListSort(useTime, incIf){
contestListSortResult.sort(compareFunc);
}

$(".contestInsertTimeInputArea > input").bind('keydown', function(event){
if(event.keyCode == "13")
$(".contestInsertTimeInputArea > button").click();
})
function contestStartVirtualIf(x){
$(".contestInsertTimeWindow").css("display", "grid");
setTimeout(function(){
$(".contestInsertTimeWindow").css("opacity", 1);
}, 50);
$(".contestInsertTimeInputArea > input").val("");
$(".contestInsertTimeInputArea > button").unbind("click").click(function(){
if(!$(this).find("i").hasClass("fa-paper-plane"))
return;
var q1 = $(".contestInsertTimeInputArea > input").val();
q1 = queryTime.exec(q1);
if(q1 == null){
$(".contestInsertTimeInputArea > button").html(`<i class='fas fa-clock'></i>`);
$(".contestInsertTimeInputArea > button").removeClass("primaryColor").addClass("dangerColor").attr("disabled", true);
setTimeout(function(){
$(".contestInsertTimeInputArea > button").html(`<i class="fas fa-paper-plane"></i>`);
$(".contestInsertTimeInputArea > button").addClass("primaryColor").removeClass("dangerColor").attr("disabled", false);
}, 1000);
return;
}
var q = [parseInt(q1[1], 10), parseInt(q1[2], 10), parseInt(q1[3], 10), parseInt(q1[4], 10), parseInt(q1[5], 10)];
var d = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
if(isLoopYear(q[0])) ++d[2];
var flg = true;
if(q[1] < 1 || q[1] > 12 || d[q[1]] < q[2] || q[2] < 1)
flg = false;
if(q[3] == 24 && q[4] != 0) flg = false;
if(q[3] != 24 && (q[3] < 0 || q[4] < 0 || q[4] >= 60)) flg = false;
if(!flg){
$(".contestInsertTimeInputArea > button").html(`<i class='fas fa-clock'></i>`);
$(".contestInsertTimeInputArea > button").removeClass("primaryColor").addClass("dangerColor").attr("disabled", true);
setTimeout(function(){
$(".contestInsertTimeInputArea > button").html(`<i class="fas fa-paper-plane"></i>`);
$(".contestInsertTimeInputArea > button").addClass("primaryColor").removeClass("dangerColor").attr("disabled", false);
}, 1000);
return;
}
$(".contestInsertTimeInputArea > button").html(`<i class='fas fa-sync-alt fa-spin'></i>`);
$(".contestInsertTimeInputArea > button").attr("disabled", true);
registerVirtualRound(x, new Date(q[0], q[1]-1, q[2], q[3], q[4]), function(){
$(".closeContestInsertTime").click();
$("[for=singleContent]").click();
loadSingleInformation(true, currentLoginHandle, x, new Date(q[0], q[1]-1, q[2], q[3], q[4]), (new Date(q[0], q[1]-1, q[2], q[3], q[4])).getTime() <= (new Date()).getTime());
$(".contestInsertTimeInputArea > button").html(`<i class="fas fa-paper-plane"></i>`);
$(".contestInsertTimeInputArea > button").attr("disabled", false);
}, function(x){
$(".contestInsertTimeInputArea > button").html(`<i class='fas ${x}'></i>`);
$(".contestInsertTimeInputArea > button").removeClass("primaryColor").addClass("dangerColor").attr("disabled", true);
setTimeout(function(){
$(".contestInsertTimeInputArea > button").html(`<i class="fas fa-paper-plane"></i>`);
$(".contestInsertTimeInputArea > button").addClass("primaryColor").removeClass("dangerColor").attr("disabled", false);
}, 1000);
});
})
}

function displayContestListPage(){
$(".contestListMatchedCount").html(String(contestListSortResult.length) + ' / ' + String(contestAllList.length));
if(contestListSortResult.length == 0){
Expand Down Expand Up @@ -130,7 +190,7 @@ function displayContestListPage(){
rep[5] = `<span class="fas fa-clock"></span> ${(new Date(x[3] * 1000)).pattern("yyyy-MM-dd hh:mm")} >>> ${(new Date((x[3] + x[4]) * 1000)).pattern("yyyy-MM-dd hh:mm")}`;
var rtList = [`<span><span class="fas fa-clock"></span> ${localize('contestListStart')}</span>`
, `<span class="red"><span class="fas fa-running"></span> ${localize('contestListRun')}</span>`
, `<span class="green"><span class="fas fa-check"></span> ${localize('contestListEnd')}</span>`];
, `<span class="green"><span class="fas fa-check"></span> ${localize('contestListEnd')}</span> | <span style="cursor: pointer; color: grey" onclick='contestStartVirtualIf(${x[1]})'><span class="fas fa-user-secret"></span> ${localize('contestListVirtual')}</span>`];
if((new Date()).getTime() <= x[3] * 1000)
rep[6] = 0, rep[5] += ` | <span class='dangerColor' style="padding: 0px 5px">${localize('contestPageBeforeStart')}<span class="contestPageCountdown" time="${x[3] * 1000}" style="padding-left: 10px"></span></span>`;
else if((new Date()).getTime() <= (x[3] + x[4]) * 1000)
Expand Down Expand Up @@ -252,6 +312,12 @@ $(".contestSearch .searchPagesButton").eq(3).click(function(){
contestListCurrentPage = r;
displayContestListPage();
})
$(".closeContestInsertTime").click(function(){
$(".contestInsertTimeWindow").css("opacity", 0);
setTimeout(function(){
$(".contestInsertTimeWindow").css("display", "none");
}, 500)
})

function reloadContestPageCountdown(){
setTimeout(reloadContestPageCountdown, 500);
Expand Down
22 changes: 22 additions & 0 deletions js/locale.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,24 @@ var lang_en = {
month9: "Oct",
month10: "Nov",
month11: "Dec",
contestListVirtual: "Virtual Participation",
contestInsertTime: "Insert Time",
showData: "Show Data",
showCode: "Show Code",
selectToShow: "Select a group of data.",
testcase: "Test",
allTestcase: "All Tests",
count: "Count",
answer: "Answer",
result: "Message",
},
input: {
singleContestantUsername: "Username",
singleContestantContestId: "Contest ID",
singleVirtualUsername: "Username",
singleVirtualContestId: "Contest ID",
singleVirtualTime: "Time (YYYY/M/D HH:MM)",
contestTimeInput: "Time (YYYY/M/D HH:MM)",
search: "Search",
problemId: "Problem ID",
contestId: "Contest ID",
Expand Down Expand Up @@ -525,13 +536,24 @@ var lang_zh = {
month9: "十月",
month10: "十一月",
month11: "十二月",
contestListVirtual: "虚拟赛",
contestInsertTime: "输入时间",
showData: "显示数据",
showCode: "显示代码",
selectToShow: "选择一组数据查看",
testcase: "测试点",
allTestcase: "所有测试点",
count: "个数",
answer: "答案",
result: "信息",
},
input: {
singleContestantUsername: "用户名",
singleContestantContestId: "比赛 ID",
singleVirtualUsername: "用户名",
singleVirtualContestId: "比赛 ID",
singleVirtualTime: "时间 (YYYY/M/D HH:MM)",
contestTimeInput: "时间 (YYYY/M/D HH:MM)",
search: "搜索",
problemId: "题目 ID",
contestId: "比赛 ID",
Expand Down
1 change: 1 addition & 0 deletions js/multi.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ function multiRenderList(data){
setTimeout(calcStandingList, 2000);
})
}
delete(data);
calcStandingList();
}

Expand Down
4 changes: 2 additions & 2 deletions js/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -749,9 +749,9 @@ function profileRefreshSubmissionListPages(){
var tm = new Date(t.creationTimeSeconds * 1000);
p.append(`<div style="font-size: 14px; text-align: center">${tm.pattern("yyyy-MM-dd")}<br/>${tm.pattern("hh:mm:ss")}</div>`);
p.append(`<div style="flex: 1; text-align: center"><span style="cursor: pointer" onclick='openProblemWin(["${t.problem.contestId}${t.problem.index}"])'>${t.problem.contestId}${t.problem.index} - ${t.problem.name}</span></div>`)
p.append(`<div style="cursor: pointer" onclick='openSubmission(${t.contestId}, ${t.id})'><div style='display: inline-block; width: 20px; text-align: center'>${getSubmissionIcon(t.verdict)}</div><div style='width: 50px; text-align: center; display: inline-block'> ${toColoredSubmissionInfo(t.verdict)}</div></div>`);
p.append(`<div><span style="cursor: pointer" onclick='openSubmission(${t.contestId}, ${t.id})'><div style='display: inline-block; width: 20px; text-align: center'>${getSubmissionIcon(t.verdict)}</div><div style='width: 50px; text-align: center; display: inline-block'> ${toColoredSubmissionInfo(t.verdict)}</div></span></div>`);
p.append(`<div style="width: 55px">${toSmallTestset(t.testset)}${t.verdict == "OK" ? "" : `<span style='font-size: 12px'>#${t.passedTestCount + 1}</span>`}</div>`);
p.append(`<div style="font-size: 14px; width: 90px; text-align: center">${t.timeConsumedMillis}ms<br/>${Math.floor(t.memoryConsumedBytes / 1000)}KB</div>`)
p.append(`<div style="font-size: 14px; width: 90px; text-align: center">${t.timeConsumedMillis}ms<br/>${Math.floor(t.memoryConsumedBytes / 1024)}KB</div>`)
$(".profileSubmissionsList").append(p);
}
}
Expand Down
Loading

0 comments on commit a521391

Please sign in to comment.