From e259dd6329ce781699e0ed2fc28ae547f33e98a0 Mon Sep 17 00:00:00 2001 From: tiger2005 <41613797+tiger2005@users.noreply.github.com> Date: Thu, 18 Nov 2021 13:54:54 +0800 Subject: [PATCH 1/4] Add Security Checks --- css/client.css | 14 +++++-- css/problem/client.css | 8 ++-- index.html | 26 +++++++++++-- js/authorize.js | 8 +++- js/locale.js | 4 ++ js/multi.js | 2 +- js/problem-watcher.js | 82 ++++++++++++++++++++++++++++++++++++--- js/problem.js | 87 ++++++++++++++++++++++++++++-------------- js/profile.js | 0 js/settings.js | 2 +- js/submission.js | 11 ++++-- package.json | 4 +- 12 files changed, 195 insertions(+), 53 deletions(-) create mode 100644 js/profile.js diff --git a/css/client.css b/css/client.css index c0b9930..19d4d95 100644 --- a/css/client.css +++ b/css/client.css @@ -116,7 +116,7 @@ body{ height: 80px; } .contentRowInfo{ - height: 680px; + height: 630px; display: flex; flex-direction: row; position: absolute; @@ -738,7 +738,7 @@ img[src=""],img:not([src]){opacity:0;} display: flex; flex-direction: row; padding: 3px 10px; - font-size: 16px; + font-size: 14px; width: calc(100% - 20px); text-align: center; } @@ -1281,8 +1281,14 @@ pre{ - - +/* PROFILE */ +.infoUserSelector{ + width: calc(100% - 10px); + padding: 5px; + position: absolute; + top: 0px; + transition: 0.2s; +} diff --git a/css/problem/client.css b/css/problem/client.css index d118e1c..761ef54 100644 --- a/css/problem/client.css +++ b/css/problem/client.css @@ -53,12 +53,12 @@ body{ } .sideBar > div{ overflow-x: hidden; - overflow-y: scroll; - width: 160px; + overflow-y: auto; + width: 175px; height: 100%; } .sideBar:hover{ - width: 160px; + width: 175px; } .sideBarGroupContents{ border-radius: 10px; @@ -69,7 +69,7 @@ body{ font-size: 16px; padding: 10px; padding-left: 10px; - width: 135px; + width: calc(100% - 20px); font-family: var(--font-family); border-left: 0px solid rgb(255, 204, 102); user-select: none; diff --git a/index.html b/index.html index 500731e..63270ad 100644 --- a/index.html +++ b/index.html @@ -18,7 +18,8 @@ delimiters: [ {left: "$$", right: "$$", display: true}, {left: "$", right: "$", display: false} - ] + ], + colorIsTextColor: true, }; Codeforces Contest Helper @@ -542,8 +543,26 @@
-
- +
+
@@ -950,6 +969,7 @@ + `) + problemNewWinJQ.append(``) }, 1000); } , function(x, y){ @@ -664,8 +695,8 @@ function openProblemWin(xx, gid){ nw.Window.open("problem.html",{ "title": "Codeforces Problems", "icon": "favicon.png", - "width": 600, - "height": 420, + "width": 800, + "height": 570, "position": "center", "resizable": true, "min_width": 450, @@ -703,7 +734,7 @@ function openProblemWin(xx, gid){ }); } function addContest(ci){ - loadContestProblemset(ci, function(data, info){ + loadContestProblemset(ci, false, function(data, info){ addProblems(data, ci, info); }, function(){}); } @@ -717,8 +748,8 @@ function openContestProblems(xx){ nw.Window.open("problem.html",{ "title": "Codeforces Problems", "icon": "favicon.png", - "width": 600, - "height": 420, + "width": 800, + "height": 570, "position": "center", "resizable": true, "min_width": 450, diff --git a/js/profile.js b/js/profile.js new file mode 100644 index 0000000..e69de29 diff --git a/js/settings.js b/js/settings.js index 10f3335..172e586 100644 --- a/js/settings.js +++ b/js/settings.js @@ -877,7 +877,7 @@ function toSmallInfo(x){ return ""; } function toDetailedInfo(x, ptType){ - if(x == undefined || x == "") return languageOption.compile["IN_QUEUE"]; + if(x == undefined || x == "" || x == null) return languageOption.compile["IN_QUEUE"]; if(x == "OK"){ if(ptType == "PRETESTS") return languageOption.compile["PRETEST_PASSED"]; diff --git a/js/submission.js b/js/submission.js index 72f61f8..7ffa1ed 100644 --- a/js/submission.js +++ b/js/submission.js @@ -13,10 +13,12 @@ function openSubmission(c, u){ setTimeout(function(){$(".submissionContainer").css("opacity", 1);}, 100); $(".submissionContainer > div:first-child > i").attr("class", 'fas fa-spin fa-sync-alt'); var data; + var submissionAjax; function loader(callback){ - $.ajax({ + submissionAjax = $.ajax({ url: settings.mainURL + `/${c >= 100000 ? "gym" : "contest"}/` + c + '/submission/' + u, success: function(j){ + submissionAjax = null; if(T.getTime() != submissionLastOperated.getTime()) return; data = $(j); if(j.indexOf(`data-entityId="${u}"`) == -1) @@ -24,6 +26,7 @@ function openSubmission(c, u){ setTimeout(callback, 100); }, error: function(){ + submissionAjax = null; if(T.getTime() != submissionLastOperated.getTime()) return; $(".submissionContainer > div:first-child > i").css("opacity", 0); setTimeout(function(){ @@ -64,8 +67,8 @@ function openSubmission(c, u){ $(".submissionLanguage").html(ctL.children().eq(3).text()); var pwp = ctL.children().eq(4); var vdl = ""; - pwp.children().each(function(){ - if($(this).attr("class") != undefined && $(this).attr("class").indexOf("verdict") != -1) + pwp.contents().each(function(){ + if(($(this).attr("class") != undefined && $(this).attr("class").indexOf("verdict") != -1) || $.trim($(this).text()) == "Compilation error") vdl += $(this).text(); }) $(".submissionVerdict").html(vdl); @@ -130,6 +133,8 @@ function openSubmission(c, u){ } $(".submissionCloser").unbind("click").click(function(){ submissionLastOperated = new Date(); + if(submissionAjax != null) + submissionAjax.abort(); $(".submissionContainer").css("opacity", 0); setTimeout(function(){$(".submissionContainer").css("display", "none");}, 500); }) diff --git a/package.json b/package.json index 7b16203..d810445 100644 --- a/package.json +++ b/package.json @@ -31,5 +31,5 @@ "page-cache": false, "plugin": true, "java": true - } -} \ No newline at end of file + }, +} From 78ea269291efb4beba7047ce645c215185b6f36a Mon Sep 17 00:00:00 2001 From: tiger2005 <41613797+tiger2005@users.noreply.github.com> Date: Thu, 18 Nov 2021 13:59:05 +0800 Subject: [PATCH 2/4] Resave package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d810445..8c07009 100644 --- a/package.json +++ b/package.json @@ -31,5 +31,5 @@ "page-cache": false, "plugin": true, "java": true - }, + } } From b557d41737a81d5f30a777c026defb0356fd190e Mon Sep 17 00:00:00 2001 From: tiger2005 <41613797+tiger2005@users.noreply.github.com> Date: Fri, 26 Nov 2021 14:12:58 +0800 Subject: [PATCH 3/4] Title Improve & Standings page bug fix --- css/client.css | 10 +- css/dark.css | 3 - css/default.css | 3 - css/problem/client.css | 9 +- css/problem/dark.css | 3 - css/problem/default.css | 3 - index.html | 20 +-- js/client.js | 2 +- js/locale.js | 4 +- js/multi.js | 286 ++++++++++++++++++++-------------------- js/problem-watcher.js | 91 ++++++------- package.json | 2 +- 12 files changed, 203 insertions(+), 233 deletions(-) diff --git a/css/client.css b/css/client.css index 19d4d95..06cb4bf 100644 --- a/css/client.css +++ b/css/client.css @@ -21,7 +21,7 @@ body{ } .HtmlContainer{ width: 1000px; - height: 668px; + height: 658px; overflow: hidden; margin: 0px; user-select:none; @@ -70,18 +70,18 @@ body{ .ToolList{ -webkit-app-region: drag; position: relative; - height: 38px; + height: 30px; } .ToolListTitle{ margin: 8px 12px; - font-size: 16px; + font-size: 14px; } .ToolListButton{ -webkit-app-region: no-drag; cursor: pointer; transition: 0.2s; - width: 55px; - height: 38px; + width: 45px; + height: 30px; font-size: 16px; display: grid; place-items: center; diff --git a/css/dark.css b/css/dark.css index 4cb8717..a805cda 100644 --- a/css/dark.css +++ b/css/dark.css @@ -13,9 +13,6 @@ body{ .ToolListMinimize:hover{ background: #666; } -.ToolList{ - border-bottom: 2px solid #555; -} .NavBarCurr{ background: #555; } diff --git a/css/default.css b/css/default.css index 0ee40c0..035189b 100644 --- a/css/default.css +++ b/css/default.css @@ -13,9 +13,6 @@ body{ .ToolListMinimize:hover{ background: #bbb; } -.ToolList{ - border-bottom: 2px solid #ccc; -} .NavBarCurr{ background: #999; } diff --git a/css/problem/client.css b/css/problem/client.css index 761ef54..ac282cd 100644 --- a/css/problem/client.css +++ b/css/problem/client.css @@ -34,6 +34,7 @@ body{ flex-direction: column; font-family: var(--font-family); position: relative; + overflow: hidden; } .HtmlContainer > div:last-child{ flex: 1; @@ -109,19 +110,19 @@ body{ .ToolList{ -webkit-app-region: drag; position: relative; - height: 36px; + height: 30px; } .ToolListTitle{ margin: 8px 12px; - font-size: 16px; + font-size: 14px; user-select: none; } .ToolListButton{ -webkit-app-region: no-drag; cursor: pointer; transition: 0.2s; - width: 55px; - height: 38px; + width: 45px; + height: 30px; font-size: 16px; display: grid; place-items: center; diff --git a/css/problem/dark.css b/css/problem/dark.css index d4b0d4d..a5b9bfb 100644 --- a/css/problem/dark.css +++ b/css/problem/dark.css @@ -18,9 +18,6 @@ body{ .sideBarItem:hover, .addProblemSidebar:hover{ background: #888; } -.ToolList{ - border-bottom: 2px solid #555; -} .ToolListMinimize:hover, .ToolListMaximize:hover{ background: #666; } diff --git a/css/problem/default.css b/css/problem/default.css index 0ed3cac..c3834ea 100644 --- a/css/problem/default.css +++ b/css/problem/default.css @@ -18,9 +18,6 @@ body{ .sideBarItem:hover, .addProblemSidebar:hover{ background: #eee; } -.ToolList{ - border-bottom: 2px solid #ccc; -} .ToolListMinimize:hover, .ToolListMaximize:hover{ background: #bbb; } diff --git a/index.html b/index.html index 63270ad..40501d9 100644 --- a/index.html +++ b/index.html @@ -544,25 +544,7 @@
- +
diff --git a/js/client.js b/js/client.js index 3c63fb2..1b5c025 100644 --- a/js/client.js +++ b/js/client.js @@ -1494,7 +1494,7 @@ function loadStandingsService(un, ci, forced){ if(settings.showProblemStatus){ contestProblemStatusBarInfo[0] = loadProblemStatusBar(false); contestProblemStatusBarInfo[1] = loadProblemStatusBar(true); - setTimeout(function(){flushProblemStatusBar()}, 300); + setTimeout(function(){flushProblemStatusBar()}, 200); } } function singleContestantSyncHacks(un, ci, json, p){ diff --git a/js/locale.js b/js/locale.js index fd22655..eb1b3df 100644 --- a/js/locale.js +++ b/js/locale.js @@ -296,7 +296,7 @@ var lang_en = { INPUT_PREPARATION_CRASHED: "Input preparation crashed", CHALLENGED: "Hacked", SKIPPED: "Skipped", - TESTING: "Testing", + TESTING: "Running", REJECTED: "Rejected", }, phase: { @@ -629,7 +629,7 @@ var lang_zh = { INPUT_PREPARATION_CRASHED: "Input preparation crashed", CHALLENGED: "Hacked", SKIPPED: "Skipped", - TESTING: "Testing", + TESTING: "Running", REJECTED: "Rejected", }, phase: { diff --git a/js/multi.js b/js/multi.js index 24aaccd..eb2e28e 100644 --- a/js/multi.js +++ b/js/multi.js @@ -127,160 +127,164 @@ function multiRenderList(data){ for(var j=0; j${un}
`; - } - function getVirtualTag(u){ - var len = Math.floor((new Date()).getTime() / 1000) - u; - if(len < data.contest.durationSeconds) - return getTimeLength(len * 1000); - return '#'; - } - flushMultiStatusBar(localize("ok") + " | " + `${languageOption.phase[data.contest.phase]}`, false); - $(".multiMask").css("display", "none"); - $(".multiInfoTable").css("display", "table"); - var hd = $(".multiInfoThead"); - hd.html(""); - var p = `#${localize("multiUser")}`; - if(data.contest.type == "IOI") - p += `=`; - else if(data.contest.type == "ICPC") - p += `=&*`; - else - p += `=*`; - for(var i=0; i${data.problems[i].index}${data.contest.type == "CF" ? `${data.problems[i].points}` : ""}` - hd.append("" + p + ""); - var bd = $(".multiInfoTbody"); - bd.html(""); - for(var t=0; t${user.party.teamName}`; - var l = []; - var addi = ""; - for(var i=0; i${user.party.participantType == "PRACTICE" ? "" : user.rank}`; - var rr = $(`${user.party.ghost ? " " : ""}${(user.party.participantType == "PRACTICE" || user.party.participantType == "OUT_OF_COMPETITION") ? "* " : ""}${uList}${user.party.participantType == "VIRTUAL" && !user.party.ghost ? `${getVirtualTag(user.party.startTimeSeconds)}` : ""}`); - if(user.party.members.length != 0){ - rr.css("cursor", "pointer"); - rr.attr("contestId", data.contest.id); - rr.attr("handle", user.party.members[0].handle); - rr.attr("startTime", user.party.participantType == "PRACTICE" ? 0 : user.party.startTimeSeconds); - rr.attr("participantType", user.party.participantType); - rr.addClass("eventLister"); + function calcStandingList(){ + loadUserColors(userList, function(colors){ + function calcUserBlock(un){ + return `
${un}
`; + } + function getVirtualTag(u){ + var len = Math.floor((new Date()).getTime() / 1000) - u; + if(len < data.contest.durationSeconds) + return getTimeLength(len * 1000); + return '#'; } - q += rr.prop("outerHTML"); + flushMultiStatusBar(localize("ok") + " | " + `${languageOption.phase[data.contest.phase]}`, false); + $(".multiMask").css("display", "none"); + $(".multiInfoTable").css("display", "table"); + var hd = $(".multiInfoThead"); + hd.html(""); + var p = `#${localize("multiUser")}`; if(data.contest.type == "IOI") - q += `${user.pointsInfo != undefined ? user.pointsInfo : user.points}`; + p += `=`; else if(data.contest.type == "ICPC") - q += `${user.points}${user.party.participantType == "PRACTICE" ? "" : user.penalty}${getMultiHack(user.successfulHackCount, user.unsuccessfulHackCount)}`; + p += `=&*`; else - q += `${user.points}${getMultiHack(user.successfulHackCount, user.unsuccessfulHackCount)}`; - for(var i=0; i?`; - else if(r.pointsInfo != undefined){ - s = r.pointsInfo; - if(r.bestSubmissionTimeSeconds != undefined) - s += `${getTimeLength(Number(r.bestSubmissionTimeSeconds * 1000))}`; - } - else if(r.points == 0){ - if(r.rejectedAttemptCount != 0) - s = '-' + r.rejectedAttemptCount + ""; + p += `=*`; + for(var i=0; i${data.problems[i].index}${data.contest.type == "CF" ? `${data.problems[i].points}` : ""}` + hd.append("" + p + ""); + var bd = $(".multiInfoTbody"); + bd.html(""); + for(var t=0; t${user.party.teamName}`; + var l = []; + var addi = ""; + for(var i=0; i${user.party.participantType == "PRACTICE" ? "" : user.rank}`; + var rr = $(`${user.party.ghost ? " " : ""}${(user.party.participantType == "PRACTICE" || user.party.participantType == "OUT_OF_COMPETITION") ? "* " : ""}${uList}${user.party.participantType == "VIRTUAL" && !user.party.ghost ? `${getVirtualTag(user.party.startTimeSeconds)}` : ""}`); + if(user.party.members.length != 0){ + rr.css("cursor", "pointer"); + rr.attr("contestId", data.contest.id); + rr.attr("handle", user.party.members[0].handle); + rr.attr("startTime", user.party.participantType == "PRACTICE" ? 0 : user.party.startTimeSeconds); + rr.attr("participantType", user.party.participantType); + rr.addClass("eventLister"); } + q += rr.prop("outerHTML"); + if(data.contest.type == "IOI") + q += `${user.pointsInfo != undefined ? user.pointsInfo : user.points}`; else if(data.contest.type == "ICPC") - s = `+${r.rejectedAttemptCount == 0 ? "" : r.rejectedAttemptCount}${user.party.participantType == "PRACTICE" ? "" : `${getTimeLength(Number(r.bestSubmissionTimeSeconds * 1000))}`}`; + q += `${user.points}${user.party.participantType == "PRACTICE" ? "" : user.penalty}${getMultiHack(user.successfulHackCount, user.unsuccessfulHackCount)}`; else - s = `${r.points}${user.party.participantType == "PRACTICE" ? "" : `${getTimeLength(Number(r.bestSubmissionTimeSeconds * 1000))}`}`; - var tt = $(`${s}`); - if(user.party.members.length != 0 && s != ""){ - tt.css("cursor", "pointer"); - tt.attr("contestId", data.contest.id); - tt.attr("handle", user.party.members[0].handle); - tt.attr("startTime", user.party.participantType == "PRACTICE" ? 0 : user.party.startTimeSeconds); - tt.attr("participantType", user.party.participantType); - tt.attr("problemId", data.problems[i].index); - tt.addClass("eventLister"); + q += `${user.points}${getMultiHack(user.successfulHackCount, user.unsuccessfulHackCount)}`; + for(var i=0; i?`; + else if(r.pointsInfo != undefined){ + s = r.pointsInfo; + if(r.bestSubmissionTimeSeconds != undefined) + s += `${getTimeLength(Number(r.bestSubmissionTimeSeconds * 1000))}`; + } + else if(r.points == 0){ + if(r.rejectedAttemptCount != 0) + s = '-' + r.rejectedAttemptCount + ""; + } + else if(data.contest.type == "ICPC") + s = `+${r.rejectedAttemptCount == 0 ? "" : r.rejectedAttemptCount}${user.party.participantType == "PRACTICE" ? "" : `${getTimeLength(Number(r.bestSubmissionTimeSeconds * 1000))}`}`; + else + s = `${r.points}${user.party.participantType == "PRACTICE" ? "" : `${getTimeLength(Number(r.bestSubmissionTimeSeconds * 1000))}`}`; + var tt = $(`${s}`); + if(user.party.members.length != 0 && s != ""){ + tt.css("cursor", "pointer"); + tt.attr("contestId", data.contest.id); + tt.attr("handle", user.party.members[0].handle); + tt.attr("startTime", user.party.participantType == "PRACTICE" ? 0 : user.party.startTimeSeconds); + tt.attr("participantType", user.party.participantType); + tt.attr("problemId", data.problems[i].index); + tt.addClass("eventLister"); + } + q += tt.prop("outerHTML"); } - q += tt.prop("outerHTML"); + bd.append(`${q}`); } - bd.append(`${q}`); - } - $(".eventLister").unbind("click").click(function(){ - var cid = Number($(this).attr("contestId")); - var had = $(this).attr("handle"); - var stt = Number($(this).attr("startTime")); - var ptt = $(this).attr("participantType"); - var pid = $(this).attr("problemId"); - $(".eventContainer").css("display", "grid"); - setTimeout(function(){ - $(".eventContainer").css("opacity", "1"); - }, 50); - $(".eventList").html(`
`) - eventAjax = $.ajax({ - url: generateAuthorizeURL(settings.codeforcesApiUrl + '/contest.status', {contestId: cid, handle: had}), - timeout: settings.largeTimeLimit, - success: function(json){ - eventAjax = null; - if(json.status != "OK") - $(".eventList").html(`
`) - else{ - json = json.result; - var useful = []; - for(var i = json.length - 1; i >= 0; i --){ - var q = json[i]; - var _stt = q.author.startTimeSeconds; - if(_stt == undefined || q.author.participantType == "PRACTICE") - _stt = 0; - if(q.author.participantType != ptt || _stt != stt || (pid != undefined && pid != q.problem.index)) - continue; - useful.push(q); - } - $(".eventList").html(''); - for(var i = 0; i < useful.length; i++){ - var tim = ""; - var curr = useful[i]; - if(stt == 0) - tim = (new Date(curr.creationTimeSeconds * 1000).pattern("yyyy/MM/dd hh:mm")); - else - tim = getTimeLength2((curr.creationTimeSeconds - stt) * 1000); - var vid = ""; - // toDetailedTestset - // toDetailedInfo - if(curr.verdict == "OK") - vid = `${toDetailedInfo(curr.verdict, curr.testset)}` - else if(curr.verdict == "PARTIAL" || curr.verdict == "COMPILATION_ERROR" || curr.verdict == "SKIPPED" || curr.verdict == "REJECTED") - vid = `${toDetailedInfo(curr.verdict, curr.testset)}` - else if(curr.verdict == "CHALLENGED") - vid = `${toDetailedInfo(curr.verdict, curr.testset)}` - else - vid = `${toDetailedInfo(curr.verdict, curr.testset)} on test ${curr.passedTestCount + 1}` - vid = $(vid); - vid.attr("onclick", `openSubmission(${cid}, ${curr.id})`); - vid.css("cursor", "pointer"); - vid = vid.prop("outerHTML"); - $(".eventList").append(`

${tim} ${pid == undefined ? `${curr.problem.index} ` : ""}${vid}${curr.points != undefined || curr.pointsInfo != undefined ? ` | ${curr.pointsInfo != undefined ? curr.pointsInfo : curr.points}` : ""} [${toDetailedTestset(curr.testset)}]

`) + $(".eventLister").unbind("click").click(function(){ + var cid = Number($(this).attr("contestId")); + var had = $(this).attr("handle"); + var stt = Number($(this).attr("startTime")); + var ptt = $(this).attr("participantType"); + var pid = $(this).attr("problemId"); + $(".eventContainer").css("display", "grid"); + setTimeout(function(){ + $(".eventContainer").css("opacity", "1"); + }, 50); + $(".eventList").html(`
`) + eventAjax = $.ajax({ + url: generateAuthorizeURL(settings.codeforcesApiUrl + '/contest.status', {contestId: cid, handle: had}), + timeout: settings.largeTimeLimit, + success: function(json){ + eventAjax = null; + if(json.status != "OK") + $(".eventList").html(`
`) + else{ + json = json.result; + var useful = []; + for(var i = json.length - 1; i >= 0; i --){ + var q = json[i]; + var _stt = q.author.startTimeSeconds; + if(_stt == undefined || q.author.participantType == "PRACTICE") + _stt = 0; + if(q.author.participantType != ptt || _stt != stt || (pid != undefined && pid != q.problem.index)) + continue; + useful.push(q); + } + $(".eventList").html(''); + for(var i = 0; i < useful.length; i++){ + var tim = ""; + var curr = useful[i]; + if(stt == 0) + tim = (new Date(curr.creationTimeSeconds * 1000).pattern("yyyy/MM/dd hh:mm")); + else + tim = getTimeLength2((curr.creationTimeSeconds - stt) * 1000); + var vid = ""; + if(curr.verdict == "OK") + vid = `${toDetailedInfo(curr.verdict, curr.testset)}` + else if(curr.verdict == undefined) + vid = `${toDetailedInfo(curr.verdict, curr.testset)}` + else if(curr.verdict == "TESTING") + vid = `${toDetailedInfo(curr.verdict, curr.testset)} on test ${curr.passedTestCount + 1}` + else if(curr.verdict == "PARTIAL" || curr.verdict == "COMPILATION_ERROR" || curr.verdict == "SKIPPED" || curr.verdict == "REJECTED") + vid = `${toDetailedInfo(curr.verdict, curr.testset)}` + else if(curr.verdict == "CHALLENGED") + vid = `${toDetailedInfo(curr.verdict, curr.testset)}` + else + vid = `${toDetailedInfo(curr.verdict, curr.testset)} on test ${curr.passedTestCount + 1}` + vid = $(vid); + vid.attr("onclick", `openSubmission(${cid}, ${curr.id})`); + vid.css("cursor", "pointer"); + vid = vid.prop("outerHTML"); + $(".eventList").append(`

${tim} ${pid == undefined ? `${curr.problem.index} ` : ""}${vid}${curr.points != undefined || curr.pointsInfo != undefined ? ` | ${curr.pointsInfo != undefined ? curr.pointsInfo : curr.points}` : ""} [${toDetailedTestset(curr.testset)}]

`) + } } + }, + error: function(){ + $(".eventList").html(`
`) } - }, - error: function(){ - $(".eventList").html(`
`) - } + }) }) + }, function(){ + setTimeout(calcStandingList, 2000); }) - }, function(){ - - }) - + } + calcStandingList(); } function fetchStandingsMainTrack(){ diff --git a/js/problem-watcher.js b/js/problem-watcher.js index 3ccf636..6d6f63f 100644 --- a/js/problem-watcher.js +++ b/js/problem-watcher.js @@ -35,13 +35,11 @@ function addWatcher(id, idx, gc){ chnl.onopen = function(){ wsOpened = true; console.log("ws started") }; chnl.onerror = function(){ console.log("ws error"), chnl.close(); wsOpened = false; }; chnl.onclose = function(){ console.log("ws closed"); wsOpened = false; }; - var DT = new Date(); chnl.onmessage = function(data){ if(wsGetResult){ chnl.close(); return; } - DT = new Date(); var j = JSON.parse(data.data); j = JSON.parse(j.text); if(j.t != "s") @@ -72,62 +70,59 @@ function addWatcher(id, idx, gc){ fadeIn(), fadeOut(vdl); lastJudgement = vdl; if(j[6] != "TESTING" && j[6] != null && j[6] != undefined){ - chnl.close(); wsGetResult = true; + wsGetResult = true; p.find(".singleWatchTitle").html(`${idx} ${tim} | ${mem}`); if(settings.openNotification){ new Notification(`Result of CF${idx}`, {body: `${$(vdl).html()}\n${tim} | ${mem}`, icon: '../favicon.png'}); } + chnl.close(); } }; - function checkSub(){ - if(!wsGetResult && (new Date()).getTime() - DT.getTime() >= 10000){ - chnl.close(); loadWatchType(); - return; - } - setTimeout(checkSub, 1000); - } - checkSub(); } - startWS(); - $.ajax({ - url: settings.mainURL + `/${getProblemIndexes(idx)[0] >= 100000 ? "gym" : "contest"}/` + getProblemIndexes(idx)[0] + '/submission/' + id, - success: function(data){ - if(data.indexOf(`data-entityId="${id}"`) == -1){ - setTimeout(loadWatchType, 10000); - return; - } - if(wsGetResult) - return; - var ctL = $(data).find("table").eq(0).find("tr").eq(1); - if(ctL.children().eq(4).children().eq(0).hasClass("verdict-accepted")){ - p.find(".singleWatchInfo").addClass("green").css("font-weight", "bold"); - } - if(ctL.children().eq(4).children().eq(0).hasClass("verdict-rejected") - || ctL.children().eq(4).children().eq(0).hasClass("verdict-failed")){ - p.find(".singleWatchInfo").addClass("red"); - } - p.find(".singleWatchInfo").html(ctL.children().eq(4).text()); - if(ctL.children().eq(4).text() != lastJudgement) - fadeIn(), fadeOut(ctL.children().eq(4).text()); - lastJudgement = ctL.children().eq(4).text(); - if(ctL.children().eq(4).children().eq(0).hasClass("verdict-waiting") - || lastJudgement == "In queue" || lastJudgement == ""){ - if(wsOpened) + // startWS(); + function reloadByAjax(){ + console.log("Reloading by ajax..."); + $.ajax({ + url: settings.mainURL + `/${getProblemIndexes(idx)[0] >= 100000 ? "gym" : "contest"}/` + getProblemIndexes(idx)[0] + '/submission/' + id, + success: function(data){ + if(data.indexOf(`data-entityId="${id}"`) == -1){ + setTimeout(reloadByAjax, 10000); return; - setTimeout(loadWatchType, 1500); - } - else{ - wsGetResult = true; - p.find(".singleWatchTitle").html(`${idx} ${ctL.children().eq(5).text().trim()} | ${ctL.children().eq(6).text().trim()}`); - if(settings.openNotification){ - new Notification(`Result of CF${idx}`, {body: `${ctL.children().eq(4).text().trim()}\n${ctL.children().eq(5).text().trim()} | ${ctL.children().eq(6).text().trim()}`, icon: '../favicon.png'}); } + if(wsGetResult) + return; + var ctL = $(data).find("table").eq(0).find("tr").eq(1); + if(ctL.children().eq(4).children().eq(0).hasClass("verdict-accepted")){ + p.find(".singleWatchInfo").addClass("green").css("font-weight", "bold"); + } + if(ctL.children().eq(4).children().eq(0).hasClass("verdict-rejected") + || ctL.children().eq(4).children().eq(0).hasClass("verdict-failed")){ + p.find(".singleWatchInfo").addClass("red"); + } + p.find(".singleWatchInfo").html(ctL.children().eq(4).text()); + if(ctL.children().eq(4).text() != lastJudgement) + fadeIn(), fadeOut(ctL.children().eq(4).text()); + lastJudgement = ctL.children().eq(4).text(); + if(ctL.children().eq(4).children().eq(0).hasClass("verdict-waiting") + || lastJudgement == "In queue" || lastJudgement == ""){ + setTimeout(reloadByAjax, 2000); + if(wsOpened) + return; + } + else{ + wsGetResult = true; + p.find(".singleWatchTitle").html(`${idx} ${ctL.children().eq(5).text().trim()} | ${ctL.children().eq(6).text().trim()}`); + if(settings.openNotification){ + new Notification(`Result of CF${idx}`, {body: `${ctL.children().eq(4).text().trim()}\n${ctL.children().eq(5).text().trim()} | ${ctL.children().eq(6).text().trim()}`, icon: '../favicon.png'}); + } + } + }, + error: function(){ + setTimeout(reloadByAjax, 2000); } - }, - error: function(){ - setTimeout(loadWatchType, 1500); - } - }) + }) + } + reloadByAjax(); } setTimeout(function(){loadWatchType()}, 200); } \ No newline at end of file diff --git a/package.json b/package.json index 8c07009..aa0ae07 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "resizable": false, "show_in_taskbar": true, "width": 1000, - "height": 668, + "height": 658, "toolbar": true, "as_desktop": false, "position": "center", From ba4c4ecf54c34a743019af0a64c4f8173444f626 Mon Sep 17 00:00:00 2001 From: tiger2005 <41613797+tiger2005@users.noreply.github.com> Date: Fri, 26 Nov 2021 17:23:01 +0800 Subject: [PATCH 4/4] Add "Double click" option to exit single page & Improve UI --- css/client.css | 2 +- css/problem/client.css | 2 +- index.html | 11 +++++ js/authorize.js | 6 ++- js/client.js | 110 ++++++++++++++++++++++++++--------------- js/contest.js | 12 +++++ js/locale.js | 18 ++++++- js/settings.js | 27 +++++++++- package.json | 2 +- 9 files changed, 142 insertions(+), 48 deletions(-) diff --git a/css/client.css b/css/client.css index 06cb4bf..c3caba5 100644 --- a/css/client.css +++ b/css/client.css @@ -82,7 +82,7 @@ body{ transition: 0.2s; width: 45px; height: 30px; - font-size: 16px; + font-size: 14px; display: grid; place-items: center; } diff --git a/css/problem/client.css b/css/problem/client.css index ac282cd..34cf4b6 100644 --- a/css/problem/client.css +++ b/css/problem/client.css @@ -123,7 +123,7 @@ body{ transition: 0.2s; width: 45px; height: 30px; - font-size: 16px; + font-size: 14px; display: grid; place-items: center; } diff --git a/index.html b/index.html index 40501d9..a46036d 100644 --- a/index.html +++ b/index.html @@ -807,6 +807,17 @@
+
+
+
Radio Name
+
Radio Addition
+
+
+
+
+
+
+
Radio Name
diff --git a/js/authorize.js b/js/authorize.js index 1b01f7f..168e7bc 100644 --- a/js/authorize.js +++ b/js/authorize.js @@ -163,10 +163,14 @@ function submitSolution(ci, idx, code, lang, S, E){ "source": code, "sourceFile": "", "tabSize": "4", - "_tta": "493", + "_tta": "594", "sourceCodeConfirmed": "true", }, success: function(d){ + if($(d).find(".lang-chooser > div").length == 0){ + E('errorNetworkError', languageOption.error.errorNetworkError); + return; + } var q = $(d).find(".lang-chooser > div").eq(1); if(q.children("a").eq(1).html() == "Register"){ currentLoginHandle = ""; diff --git a/js/client.js b/js/client.js index 1b5c025..5a66282 100644 --- a/js/client.js +++ b/js/client.js @@ -624,7 +624,7 @@ function getSingleRatingChanges(currSingleLastTimeUpdate, un, ci){ callbacks(); return; } - for(var i=0; i span:last-child") .html(`${json[i].oldRating} ${json[i].newRating>=json[i].oldRating?'+':'-'}${Math.abs(Number(json[i].newRating)-Number(json[i].oldRating))} ${json[i].newRating}`) if(contestNewWinLoaded) contestNewWinJQ.find(".ratingChanges").html($(".singleContestProgressRatingChangesDisplayer > span:last-child").html()); @@ -2416,46 +2416,7 @@ $(".searchArgumentsItem").click(function(){ var timeLoader, ifInObserve; -$(".singleHeadBack > span").mousedown(function(e){ - $(".singleHeadBackProgress").addClass("selected"); - timeStart = new Date(); - ifInObserve = true; - var x = e.clientX; - var y = e.clientY; - $(".singleHeadBackProgress").css("top", y).css("left", x); - window.onmousemove = function(evt){ - var x = evt.clientX; - var y = evt.clientY; - $(".singleHeadBackProgress").css("top", y).css("left", x); - } - timeLoader = setInterval(function(){ - timeEnd = new Date(); - if(timeEnd.getTime() - timeStart.getTime() > 600){ - clearInterval(timeLoader); - $(".singleContent > div").css("left", "0px"); - $(".singleHeadBackProgress").removeClass("selected"); - $("body").attr("onmouseup", ""); - ifInObserve = false; - contestEnterInPage = false; - singleLastTimeUpdate = new Date(); - for(var i=0; i${languageOption.general.singleSmallWindow} `); - } - ++ singleContestantTimeCountdownTimeCnt; - setTimeout(function(){ - if(!ifInObserve) window.onmousemove = function(){} - }, 300); - } - },100); - $("body").attr("onmouseup", "singleButtonMouseUp()"); -}); +var singleHeadBackClkd = 0; function singleButtonMouseUp(){ clearInterval(timeLoader); ifInObserve = false; @@ -2469,6 +2430,73 @@ function singleButtonMouseUp(){ }, 300); } +function reinitSingleButton(){ + if(settings.headBackOption == 0){ + $(".singleHeadBack > span").mousedown(function(e){ + $(".singleHeadBackProgress").addClass("selected"); + timeStart = new Date(); + ifInObserve = true; + var x = e.clientX; + var y = e.clientY; + $(".singleHeadBackProgress").css("top", y).css("left", x); + window.onmousemove = function(evt){ + var x = evt.clientX; + var y = evt.clientY; + $(".singleHeadBackProgress").css("top", y).css("left", x); + } + timeLoader = setInterval(function(){ + timeEnd = new Date(); + if(timeEnd.getTime() - timeStart.getTime() > 600){ + clearInterval(timeLoader); + $(".singleContent > div").css("left", "0px"); + $(".singleHeadBackProgress").removeClass("selected"); + $("body").attr("onmouseup", ""); + ifInObserve = false; + contestEnterInPage = false; + singleLastTimeUpdate = new Date(); + for(var i=0; i${languageOption.general.singleSmallWindow} `); + } + ++ singleContestantTimeCountdownTimeCnt; + setTimeout(function(){ + if(!ifInObserve) window.onmousemove = function(){} + }, 300); + } + },100); + $("body").attr("onmouseup", "singleButtonMouseUp()"); + }); + $(".singleHeadBack > span").unbind("click"); + } + else{ + $(".singleHeadBack > span").click(function(){ + if(settings.headBackOption == 1){ + console.log("!"); + if(singleHeadBackClkd == 1){ + singleHeadBackClkd = 0; + $(".singleHeadBack > span").css("font-weight", "normal"); + $(".singleContent > div").css("left", "0px"); + return; + } + singleHeadBackClkd = 1; + $(".singleHeadBack > span").css("font-weight", "bold"); + setTimeout(function(){ + $(".singleHeadBack > span").css("font-weight", "normal"); + singleHeadBackClkd = 0; + }, 1000); + } + }) + $(".singleHeadBack > span").unbind("mousedown"); + } +} +reinitSingleButton(); + $(".singleOpenSmallWindow").click(function(){ if(!RunInNwjs) return; if(contestNewWinOpened && !contestNewWinLoaded) diff --git a/js/contest.js b/js/contest.js index 48a6f17..34ae758 100644 --- a/js/contest.js +++ b/js/contest.js @@ -191,6 +191,18 @@ function loadContestList(){ $(".contestListLoadIf > span").unbind("click").click(function(){ loadContestList(); }) + }, + xhr: function() { + var xhr = new XMLHttpRequest(); + var fr = false; + xhr.addEventListener('progress', function (e) { + if(! fr){ + $(".contestListLoadIf > span").append(``); + fr = true; + } + $(".contestLoadedInfo").html(` (${toMemoryInfo(e.loaded)})`); + }); + return xhr; } }) } diff --git a/js/locale.js b/js/locale.js index eb1b3df..a6568b2 100644 --- a/js/locale.js +++ b/js/locale.js @@ -14,7 +14,10 @@ var lang_en = { singleContestantButton: "Fetch Information", singleVirtualButton: "Fetch Information", singleCheckExist: "Checking Existance...", - singleHeadBack: "Go back (Long press)", + singleHeadBack0: "Go back (Long press)", + singleHeadBack1: "Go back (Double click)", + singleHeadBackOptions0: "Long press", + singleHeadBackOptions1: "Double click", singleSmallWindow: "Open small window", singleSmallWindowClose: "Close small window", alertLoadSuccess: "Load Success!", @@ -276,6 +279,10 @@ var lang_en = { apiSecret: [ " API Secret", "Your API secret." + ], + headBackOption: [ + " Head back option", + "Choose how to exit \"Single\" page." ] }, compile: { @@ -323,7 +330,10 @@ var lang_zh = { singleContestantButton: "获取信息", singleVirtualButton: "获取信息", singleCheckExist: "检查合法性...", - singleHeadBack: "返回选择界面(长按)", + singleHeadBack0: "返回选择界面(长按)", + singleHeadBack1: "返回选择界面(双击)", + singleHeadBackOptions0: "长按", + singleHeadBackOptions1: "双击", singleSmallWindow: "打开小窗口", singleSmallWindowClose: "关闭小窗口", alertLoadSuccess: "加载成功!", @@ -588,6 +598,10 @@ var lang_zh = { apiSecret: [ " API Secret", "你的 API secret." + ], + headBackOption: [ + " 返回选项", + "选择如何返回个人选项界面。", ] }, // compile: { diff --git a/js/settings.js b/js/settings.js index 172e586..c7371eb 100644 --- a/js/settings.js +++ b/js/settings.js @@ -421,6 +421,30 @@ var settingsFunctions = { saveSettings(); return settings.showProblemStatus; } + }, + headBackOption: { + initial: function(){ + var q = $("[info=singleHeadBack]"); + q.attr("info", "singleHeadBack" + (settings.headBackOption)); + q.html(languageOption.general["singleHeadBack" + (settings.headBackOption)]); + return [localize("singleHeadBackOptions" + (settings.headBackOption)), true, true]; + }, + previous: function(){ + var q = $(`[info=singleHeadBack${settings.headBackOption}]`); + settings.headBackOption = 1 - settings.headBackOption; + q.attr("info", "singleHeadBack" + (settings.headBackOption)); + q.html(languageOption.general["singleHeadBack" + (settings.headBackOption)]); + reinitSingleButton(); saveSettings(); + return [localize("singleHeadBackOptions" + (settings.headBackOption)), true, true]; + }, + next: function(){ + var q = $(`[info=singleHeadBack${settings.headBackOption}]`); + settings.headBackOption = 1 - settings.headBackOption; + q.attr("info", "singleHeadBack" + (settings.headBackOption)); + q.html(languageOption.general["singleHeadBack" + (settings.headBackOption)]); + reinitSingleButton(); saveSettings(); + return [localize("singleHeadBackOptions" + (settings.headBackOption)), true, true]; + }, } }; String.prototype.format = function() { @@ -456,7 +480,8 @@ var currentDefaultSettings = { openNotification: true, useApiKeys: false, apiKey: "", - apiSecret: "" + apiSecret: "", + headBackOption: 0, }; function setAsDefault(op){ if(op == undefined) op = false; diff --git a/package.json b/package.json index aa0ae07..6b09d57 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "single-instance": true, "main": "index.html", "chromium-args": "--disable-web-security --user-data-dir --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-renderer-backgrounding", - "double-tap-to_zoom-enabled": false, + "double-tap-to-zoom-enabled": false, "webkit": { "page-cache": false, "plugin": true,