Skip to content

Commit

Permalink
Fix the "stuck" bug when add problems in creating a contest.
Browse files Browse the repository at this point in the history
  • Loading branch information
chaoshxxu committed Oct 15, 2014
1 parent 3d73b49 commit 25d8cfc
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 58 deletions.
19 changes: 16 additions & 3 deletions src/main/java/judge/service/JudgeService.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,26 @@ public Object[] findProblemSimple(String OJ, String problemId){
problemInfoUpdateManager.updateProblem(OJ, problemId, false);

Map paraMap = new HashMap<String, String>();
paraMap.put("OJ", OJ.trim());
paraMap.put("OJ", OJ);
paraMap.put("pid", problemId.trim());
List<Object[]> list = baseService.query("select p.id, p.title, p.timeLimit from Problem p where p.originOJ = :OJ and p.originProb = :pid", paraMap);
if (!list.isEmpty()) {
return list.get(0);
return new Object[] { //
list.get(0)[0], //
list.get(0)[1], //
list.get(0)[2], //
OJ, //
problemId.trim() //
};
} else {
return new Object[] { //
null, //
null, //
null, //
OJ, //
problemId.trim() //
};
}
return null;
}

/**
Expand Down
6 changes: 1 addition & 5 deletions src/main/webapp/contest/view.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
<head>
<%@ include file="/header.jsp" %>
<title><s:property value="contest.title" escape="false" /> - Virtual Judge</title>
<%-- <style type="text/css" media="screen">
table.blue_border td {border:1px solid #A6C9E2;}
</style>
--%>

<%-- <link rel="stylesheet" type="text/css" href="${contextPath}/css/contest_view.css?<%=application.getAttribute("version")%>" /> --%>
<%-- <script type="text/javascript" src="${contextPath}/javascript/contest_view.js?<%=application.getAttribute("version")%>"></script> --%>
Expand All @@ -18,7 +14,7 @@
<body>
<s:hidden id="js_require_view_contest" />
<s:include value="/top.jsp" />
<s:if test="contest.announcement != null && !contest.announcement.isEmpty()">
<s:if test="contest.announcement != null && !contest.announcement.isEmpty() && contestAuthorizeStatus != 0">
<marquee id="contest_announcement" height="25" style="text-align:center;color:red;font-weight:bold" onmouseout="this.start()" onmouseover="this.stop()" scrollamount="2" scrolldelay="1" behavior="alternate">${contest.announcement}</marquee>
</s:if>
<s:hidden id="cid" name="cid" />
Expand Down
1 change: 1 addition & 0 deletions src/main/webapp/index.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
<div style="line-height:20px;padding-top:5px;clear:both;">
<p>What's new:</p>
<ul>
<li>2014-10-15 UI update. Please <a href="mailto:[email protected]">contact me</a> if you find any bugs. Thanks very much!</li>
<li style="color:red;">
2014-09-20 Currently Virtual Judge has two access address:<br />
<ul>
Expand Down
57 changes: 30 additions & 27 deletions src/main/webapp/javascript/contest_edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ $(function(){
return;
}

DWREngine.setAsync(false);
// DWREngine.setAsync(false);

var beginTime = parseInt($("[name=beginTime]").val());
if (beginTime != NaN && beginTime > 0) {
Expand Down Expand Up @@ -84,11 +84,6 @@ $(function(){
break;
}
}
// tmp = $trs.eq(i).children().eq(-1).html().charAt(1);
// if (tmp != 'a' && tmp != 'A'){
// err = 1;
// break;
// }
if ($trs.eq(i).find("td span").length > 0) {
err = 1;
break;
Expand Down Expand Up @@ -149,28 +144,35 @@ $(function(){

/////////////////////////////////////////////////////////////////////////

var problemInfo;
function callBack(_problemInfo){
problemInfo = _problemInfo;
}

var last;
function updateTitle($row, enforce){
if (!enforce && $("[name=probNums]", $row).val() == last)return;
last = $("[name=probNums]", $row).val();
judgeService.findProblemSimple($("[name=OJs]", $row).val(), $("[name=probNums]", $row).val(), callBack);
if (problemInfo == null){
$row.children().eq(-1).html("<span style='color:red'>No such problem!</span>");
} else {
$row.children().eq(-1).html("<a target='_blank' href='" + basePath + "/problem/viewProblem.action?id=" + problemInfo[0] + "'>" + problemInfo[1] + "</a>" + (problemInfo[2] == 2 ? "<span style='color:red'>(Crawl Failed)</span>" : problemInfo[2] == 1 ? "<span style='color:green'>(Crawling)</span>" : ""));
$("[name=pids]", $row).val(problemInfo[0]);
if (problemInfo[2] == 1) {
setTimeout(function(){
updateTitle($row, true);
}, 1000);
}
}
updateNum();
var oj = $("[name=OJs]", $row).val();
var probNums = $("[name=probNums]", $row).val();

if (!enforce && probNums == last)return;
last = probNums;
judgeService.findProblemSimple(oj, probNums, function(problemInfo){
var _problemId = problemInfo[0];
var _problemTitle = problemInfo[1];
var _problemTimeLimit = problemInfo[2];
var _problemOJ = problemInfo[3];
var _problemNum = problemInfo[4];

if (oj == _problemOJ && probNums.trim() == _problemNum) {
if (_problemId == null){
$row.children().eq(-1).html("<span style='color:red'>No such problem!</span>");
} else {
$row.children().eq(-1).html("<a target='_blank' href='" + basePath + "/problem/viewProblem.action?id=" + _problemId + "'>" + _problemTitle + "</a>" + (_problemTimeLimit == 2 ? "<span style='color:red'>(Crawl Failed)</span>" : _problemTimeLimit == 1 ? "<span style='color:green'>(Crawling)</span>" : ""));
$("[name=pids]", $row).val(_problemId);
if (_problemTimeLimit == 1) {
setTimeout(function(){
updateTitle($row, true);
}, 1000);
}
}
updateNum();
}
});
}

function updateNum(){
Expand All @@ -193,7 +195,8 @@ $(function(){
}
$newRow = $originRow.clone();
$("[name=OJs]", $newRow).val($("[name=OJs]", $originRow).val());
$("[name=titles]", $newRow).val("");
$("[name=titles]", $newRow).val("");
$("td:eq(4), td:eq(5)", $newRow).html("");

$newRow.removeAttr("id");
$(":input", $newRow).removeAttr("id");
Expand Down
52 changes: 30 additions & 22 deletions src/main/webapp/javascript/min/script.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/main/webapp/javascript/min/script.min.js

Large diffs are not rendered by default.

0 comments on commit 25d8cfc

Please sign in to comment.