增加显示的时候修改输出

This commit is contained in:
2024-12-06 16:16:21 +08:00
parent fdcbd1f980
commit 8916300510

View File

@@ -1,27 +1,29 @@
<?php <?php
if($pr_flag){ if ($pr_flag) {
$show_title="P$id - ".$row['title']." - $OJ_NAME"; $show_title = "P$id - " . $row['title'] . " - $OJ_NAME";
}else{ } else {
$id=$row['problem_id']; $id = $row['problem_id'];
$show_title="$MSG_PROBLEM ".$PID[$pid].": ".$row['title']." - $OJ_NAME"; $show_title = "$MSG_PROBLEM " . $PID[$pid] . ": " . $row['title'] . " - $OJ_NAME";
} }
?> ?>
<?php include("template/$OJ_TEMPLATE/header.php");?> <?php include("template/$OJ_TEMPLATE/header.php"); ?>
<style> <style>
.ace_cursor { .ace_cursor {
border-left-width: 1px !important; border-left-width: 1px !important;
color: #000 !important; color: #000 !important;
} }
#languages-menu::-webkit-scrollbar, #testcase-menu::-webkit-scrollbar { #languages-menu::-webkit-scrollbar,
#testcase-menu::-webkit-scrollbar {
width: 0px; width: 0px;
background: transparent; background: transparent;
} }
div[class*=ace_br] { div[class*=ace_br] {
border-radius: 0 !important; border-radius: 0 !important;
} }
.copy {
.copy {
font-size: 12px; font-size: 12px;
color: #4d4d4d; color: #4d4d4d;
background-color: white; background-color: white;
@@ -29,29 +31,29 @@ div[class*=ace_br] {
margin: 8px; margin: 8px;
border-radius: 4px; border-radius: 4px;
cursor: pointer; cursor: pointer;
box-shadow: 0 2px 4px rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.05); box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05), 0 2px 4px rgba(0, 0, 0, 0.05);
} }
</style> </style>
<script src="<?php echo $OJ_CDN_URL.$path_fix."template/$OJ_TEMPLATE/"?>clipboard.min.js"></script> <script src="<?php echo $OJ_CDN_URL . $path_fix . "template/$OJ_TEMPLATE/" ?>clipboard.min.js"></script>
<script src="<?php echo $OJ_CDN_URL.$path_fix."template/bs3/"?>marked.min.js"></script> <script src="<?php echo $OJ_CDN_URL . $path_fix . "template/bs3/" ?>marked.min.js"></script>
<script src="<?php echo $OJ_CDN_URL.$path_fix."template/syzoj/js/"?>markdown-it.min.js"></script> <script src="<?php echo $OJ_CDN_URL . $path_fix . "template/syzoj/js/" ?>markdown-it.min.js"></script>
<div class="padding "> <div class="padding ">
<div class="ui center aligned grid"> <div class="ui center aligned grid">
<div class="row"> <div class="row">
<h1 class="ui header"> <h1 class="ui header">
<?php <?php
if($pr_flag){ if ($pr_flag) {
echo "$id: ".$row['title']; echo "$id: " . $row['title'];
// <%= problem.title %><% if (problem.allowedEdit && !problem.is_public) { %><span class="ui tiny red label">未公开</span><% } %>"; // <%= problem.title %><% if (problem.allowedEdit && !problem.is_public) { %><span class="ui tiny red label">未公开</span><% } %>";
//echo "<title>$MSG_PROBLEM".$row['problem_id']."--". $row['title']."</title>"; //echo "<title>$MSG_PROBLEM".$row['problem_id']."--". $row['title']."</title>";
//echo "<center><h2><strong>$id: ".$row['title']."</strong></h2>"; //echo "<center><h2><strong>$id: ".$row['title']."</strong></h2>";
}else{ } else {
$id=$row['problem_id']; $id = $row['problem_id'];
//echo "<title>$MSG_PROBLEM ".$PID[$pid].": ".$row['title']." </title>"; //echo "<title>$MSG_PROBLEM ".$PID[$pid].": ".$row['title']." </title>";
echo "$MSG_PROBLEM ".$PID[$pid].": ".$row['title']; echo "$MSG_PROBLEM " . $PID[$pid] . ": " . $row['title'];
} }
if($row['defunct']=="Y") if ($row['defunct'] == "Y")
echo "<span class=\"p-label ui tiny red label\">$MSG_RESERVED</span>"; echo "<span class=\"p-label ui tiny red label\">$MSG_RESERVED</span>";
?> ?>
</h1> </h1>
@@ -63,28 +65,31 @@ div[class*=ace_br] {
</div> </div>
<div class="row" style="margin-top: -23px"> <div class="row" style="margin-top: -23px">
<!-- <span class="ui label">题目类型:传统</span> --> <!-- <span class="ui label">题目类型:传统</span> -->
<span class="ui label"><?php echo $MSG_JUDGE_STYLE ?><?php echo array($MSG_NJ,$MSG_SPJ,$MSG_RTJ)[$row['spj']] ; ?> </span> <span
class="ui label"><?php echo $MSG_JUDGE_STYLE ?><?php echo array($MSG_NJ, $MSG_SPJ, $MSG_RTJ)[$row['spj']]; ?>
</span>
<span class="ui label"><?php echo $MSG_Creator ?><span id='creator'></span></span> <span class="ui label"><?php echo $MSG_Creator ?><span id='creator'></span></span>
</div> </div>
<div class="row" style="margin-top: -23px"> <div class="row" style="margin-top: -23px">
<span class="ui label"><?php echo $MSG_SUBMIT ?><?php echo $row['submit']; ?></span> <span class="ui label"><?php echo $MSG_SUBMIT ?><?php echo $row['submit']; ?></span>
<span class="ui label"><?php echo $MSG_SOVLED ?><?php echo $row['accepted']; ?></span> <span class="ui label"><?php echo $MSG_SOVLED ?><?php echo $row['accepted']; ?></span>
</div> </div>
</div> </div>
<div class="ui grid"> <div class="ui grid">
<div class="row" id="submit-buttons"> <div class="row" id="submit-buttons">
<div class="column"> <div class="column">
<div class="ui buttons"> <div class="ui buttons">
<?php <?php
if($pr_flag){ if ($pr_flag) {
echo "<a id='submit' class=\"small ui primary button\" href=\"submitpage.php?id=$id\">$MSG_SUBMIT</a>"; echo "<a id='submit' class=\"small ui primary button\" href=\"submitpage.php?id=$id\">$MSG_SUBMIT</a>";
echo "<a class=\"small ui positive button\" href=\"status.php?problem_id=$id\">$MSG_SUBMIT_RECORD</a>"; echo "<a class=\"small ui positive button\" href=\"status.php?problem_id=$id\">$MSG_SUBMIT_RECORD</a>";
echo "<a class=\"small ui orange button\" href=\"problemstatus.php?id=$id\">$MSG_STATISTICS</a>"; echo "<a class=\"small ui orange button\" href=\"problemstatus.php?id=$id\">$MSG_STATISTICS</a>";
if($OJ_BBS)echo "<a class=\"small ui red button\" href=\"discuss.php?pid=$id\">$MSG_BBS</a>"; if ($OJ_BBS)
}else{ echo "<a class=\"small ui red button\" href=\"discuss.php?pid=$id\">$MSG_BBS</a>";
} else {
echo "<a href=\"contest.php?cid=$cid\" class=\"ui orange button\">$MSG_RETURN_CONTEST</a>"; echo "<a href=\"contest.php?cid=$cid\" class=\"ui orange button\">$MSG_RETURN_CONTEST</a>";
if($contest_is_over) if ($contest_is_over)
echo "<a id='submit' class=\"small ui primary button\" href=\"submitpage.php?id=$id\">$MSG_SUBMIT</a>"; echo "<a id='submit' class=\"small ui primary button\" href=\"submitpage.php?id=$id\">$MSG_SUBMIT</a>";
else else
echo "<a id='submit' class=\"small ui primary button\" href=\"submitpage.php?cid=$cid&pid=$pid&langmask=$langmask\">$MSG_SUBMIT</a>"; echo "<a id='submit' class=\"small ui primary button\" href=\"submitpage.php?cid=$cid&pid=$pid&langmask=$langmask\">$MSG_SUBMIT</a>";
@@ -92,153 +97,160 @@ div[class*=ace_br] {
echo "<a class=\"small ui orange button\" href=\"status.php?problem_id=$PID[$pid]&cid=$cid\">$MSG_THIS_CONTEST$MSG_SUBMIT_RECORD</a>"; echo "<a class=\"small ui orange button\" href=\"status.php?problem_id=$PID[$pid]&cid=$cid\">$MSG_THIS_CONTEST$MSG_SUBMIT_RECORD</a>";
} }
if(!file_exists($OJ_DATA."/".$id."/solution.name")) echo "<a class='small ui primary button' href='#' onclick='transform()' role='button'>$MSG_SHOW_OFF</a>"; if (!file_exists($OJ_DATA . "/" . $id . "/solution.name"))
echo "<a class='small ui primary button' href='#' onclick='transform()' role='button'>$MSG_SHOW_OFF</a>";
?> ?>
</div> </div>
<?php <?php
if ( isset($_SESSION[$OJ_NAME.'_'.'administrator']) || isset($_SESSION[$OJ_NAME.'_'."p".$row['problem_id']]) ) { //only the original editor can edit this problem if (isset($_SESSION[$OJ_NAME . '_' . 'administrator']) || isset($_SESSION[$OJ_NAME . '_' . "p" . $row['problem_id']])) { //only the original editor can edit this problem
require_once("include/set_get_key.php"); require_once("include/set_get_key.php");
?> ?>
<div class="ui buttons right floated"> <div class="ui buttons right floated">
<a class="small ui button" href="admin/problem_edit.php?id=<?php echo $id?>&getkey=<?php echo $_SESSION[$OJ_NAME.'_'.'getkey']?>"><?php echo $MSG_EDIT.$MSG_PROBLEM?></a> <a class="small ui button"
<a class="small ui button" href='javascript:phpfm(<?php echo $row['problem_id'];?>)'><?php echo $MSG_TEST_DATA?></a> href="admin/problem_edit.php?id=<?php echo $id ?>&getkey=<?php echo $_SESSION[$OJ_NAME . '_' . 'getkey'] ?>"><?php echo $MSG_EDIT . $MSG_PROBLEM ?></a>
<a class="small ui button"
href='javascript:phpfm(<?php echo $row['problem_id']; ?>)'><?php echo $MSG_TEST_DATA ?></a>
</div> </div>
<?php }?> <?php } ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="column"> <div class="column">
<h4 class="ui top attached block header"><?php echo $MSG_Description?></h4> <h4 class="ui top attached block header"><?php echo $MSG_Description ?></h4>
<div id="description" class="ui bottom attached segment font-content"> <div id="description" class="ui bottom attached segment font-content">
<span class='md auto_select'> <span class='md auto_select'>
<?php <?php
// if (str_contains($row['description'],"md auto_select")) echo bbcode_to_html($row['description']);
echo $row['description'];
// else echo bbcode_to_html($row['description']);
?> ?>
</span> </span>
</div> </div>
</div> </div>
</div> </div>
<?php if($row['input']||isset($_GET['spa'])){ ?> <?php if ($row['input'] || isset($_GET['spa'])) { ?>
<div class="row"> <div class="row">
<div class="column"> <div class="column">
<h4 class="ui top attached block header"><?php echo $MSG_Input?></h4> <h4 class="ui top attached block header"><?php echo $MSG_Input ?></h4>
<div id='input' class="ui bottom attached segment font-content"> <div id='input' class="ui bottom attached segment font-content">
<span class='md auto_select'> <span class='md auto_select'>
<?php echo <?php echo
// bbcode_to_html( bbcode_to_html(
$row['input'] $row['input']
// ); );
?> ?>
</span> </span>
</div> </div>
</div> </div>
</div> </div>
<?php }?> <?php } ?>
<?php if($row['output']||isset($_GET['spa'])){ ?> <?php if ($row['output'] || isset($_GET['spa'])) { ?>
<div class="row"> <div class="row">
<div class="column"> <div class="column">
<h4 class="ui top attached block header"><?php echo $MSG_Output?></h4> <h4 class="ui top attached block header"><?php echo $MSG_Output ?></h4>
<div id='output' class="ui bottom attached segment font-content"> <div id='output' class="ui bottom attached segment font-content">
<span class='md auto_select'> <span class='md auto_select'>
<?php echo <?php echo
// bbcode_to_html( bbcode_to_html(
$row['output'] $row['output']
// ); );
?> ?>
</span> </span>
</div> </div>
</div> </div>
</div> </div>
<?php }?> <?php } ?>
<?php <?php
$sinput=str_replace("<","&lt;",$row['sample_input']); $sinput = str_replace("<", "&lt;", $row['sample_input']);
$sinput=str_replace(">","&gt;",$sinput); $sinput = str_replace(">", "&gt;", $sinput);
$soutput=str_replace("<","&lt;",$row['sample_output']); $soutput = str_replace("<", "&lt;", $row['sample_output']);
$soutput=str_replace(">","&gt;",$soutput); $soutput = str_replace(">", "&gt;", $soutput);
?> ?>
<?php if(strlen($sinput)>0 && $sinput!="\n"||isset($_GET['spa'])){ ?> <?php if (strlen($sinput) > 0 && $sinput != "\n" || isset($_GET['spa'])) { ?>
<div class="row"> <div class="row">
<div class="column"> <div class="column">
<h4 class="ui top attached block header"><?php echo $MSG_Sample_Input?> <h4 class="ui top attached block header"><?php echo $MSG_Sample_Input ?>
<span class="copy" id="copyin" data-clipboard-text="<?php echo htmlentities($sinput, ENT_QUOTES, 'UTF-8'); ?>"><?php echo $MSG_COPY; ?></span> <span class="copy" id="copyin"
data-clipboard-text="<?php echo htmlentities($sinput, ENT_QUOTES, 'UTF-8'); ?>"><?php echo $MSG_COPY; ?></span>
</h4> </h4>
<!-- <span class=copy id=\"copyin\" data-clipboard-text=\"".($sinput)."\"><?php echo $MSG_COPY; ?></span> --> <!-- <span class=copy id=\"copyin\" data-clipboard-text=\"".($sinput)."\"><?php echo $MSG_COPY; ?></span> -->
<div class="ui bottom attached segment font-content"> <div class="ui bottom attached segment font-content">
<!-- <pre><?php echo ($sinput); ?></pre> --> <!-- <pre><?php echo ($sinput); ?></pre> -->
<pre style="margin-top: 0; margin-bottom: 0; "><code id='sinput' class="lang-plain"><?php echo ($sinput); ?></code></pre> <pre
style="margin-top: 0; margin-bottom: 0; "><code id='sinput' class="lang-plain"><?php echo ($sinput); ?></code></pre>
</div> </div>
</div> </div>
</div> </div>
<?php }?> <?php } ?>
<?php if(strlen($soutput)>0 && $soutput!="\n"||isset($_GET['spa'])){ ?> <?php if (strlen($soutput) > 0 && $soutput != "\n" || isset($_GET['spa'])) { ?>
<div class="row"> <div class="row">
<div class="column"> <div class="column">
<h4 class="ui top attached block header"><?php echo $MSG_Sample_Output?> <h4 class="ui top attached block header"><?php echo $MSG_Sample_Output ?>
<span class="copy" id="copyout" data-clipboard-text="<?php echo htmlentities($soutput, ENT_QUOTES, 'UTF-8'); ?>"><?php echo $MSG_COPY; ?></span> <span class="copy" id="copyout"
data-clipboard-text="<?php echo htmlentities($soutput, ENT_QUOTES, 'UTF-8'); ?>"><?php echo $MSG_COPY; ?></span>
</h4> </h4>
<!-- <span class=copy id=\"copyout\" data-clipboard-text=\"".($soutput)."\"><?php echo $MSG_COPY; ?></span> --> <!-- <span class=copy id=\"copyout\" data-clipboard-text=\"".($soutput)."\"><?php echo $MSG_COPY; ?></span> -->
<div class="ui bottom attached segment font-content"> <div class="ui bottom attached segment font-content">
<!-- <div class="ui existing segment"> --> <!-- <div class="ui existing segment"> -->
<pre style="margin-top: 0; margin-bottom: 0; "><code id='soutput' class="lang-plain"><?php echo ($soutput); ?></code></pre> <pre
style="margin-top: 0; margin-bottom: 0; "><code id='soutput' class="lang-plain"><?php echo ($soutput); ?></code></pre>
<!-- </div> --> <!-- </div> -->
</div> </div>
</div> </div>
</div> </div>
<?php }?> <?php } ?>
<?php if($row['hint']||isset($_GET['spa'])){ ?> <?php if ($row['hint'] || isset($_GET['spa'])) { ?>
<div class="row"> <div class="row">
<div class="column"> <div class="column">
<h4 class="ui top attached block header"><?php echo $MSG_HINT?></h4> <h4 class="ui top attached block header"><?php echo $MSG_HINT ?></h4>
<div id='hint' class="ui bottom attached segment font-content hint"> <div id='hint' class="ui bottom attached segment font-content hint">
<span class='md auto_select'> <span class='md auto_select'>
<?php echo <?php echo
// bbcode_to_html( bbcode_to_html(
$row['hint'] $row['hint']
// ); );
?> ?>
</span> </span>
</div> </div>
</div> </div>
</div> </div>
<?php }?> <?php } ?>
<?php <?php
$color=array("blue","teal","orange","pink","olive","red","violet","yellow","green","purple"); $color = array("blue", "teal", "orange", "pink", "olive", "red", "violet", "yellow", "green", "purple");
$tcolor=0; $tcolor = 0;
?> ?>
<?php if($row['source'] && !isset($_GET['cid']) ){ <?php if ($row['source'] && !isset($_GET['cid'])) {
$cats=explode(" ",$row['source']); $cats = explode(" ", $row['source']);
?> ?>
<div class="row"> <div class="row">
<div class="column"> <div class="column">
<h4 class="ui block header top attached" id="show_tag_title_div" style="margin-bottom: 0; margin-left: -1px; margin-right: -1px; "> <h4 class="ui block header top attached" id="show_tag_title_div"
<?php echo $MSG_SOURCE?> style="margin-bottom: 0; margin-left: -1px; margin-right: -1px; ">
<?php echo $MSG_SOURCE ?>
</h4> </h4>
<div class="ui bottom attached segment" id="show_tag_div"> <div class="ui bottom attached segment" id="show_tag_div">
<?php foreach($cats as $cat){ <?php foreach ($cats as $cat) {
if(trim($cat)=="") continue; if (trim($cat) == "")
$label_theme=$color[$tcolor%count($color)]; continue;
$label_theme = $color[$tcolor % count($color)];
$tcolor++; $tcolor++;
?> ?>
<a href="<?php <a href="<?php
if(mb_ereg("^http",$cat)) // remote oj pop links if (mb_ereg("^http", $cat)) // remote oj pop links
echo htmlentities($cat,ENT_QUOTES,'utf-8').'" target="_blank' ; echo htmlentities($cat, ENT_QUOTES, 'utf-8') . '" target="_blank';
else else
echo "problemset.php?search=".urlencode(htmlentities($cat,ENT_QUOTES,'utf-8')) ; echo "problemset.php?search=" . urlencode(htmlentities($cat, ENT_QUOTES, 'utf-8'));
?>" class="ui medium <?php echo $label_theme; ?> label"> ?>" class="ui medium <?php echo $label_theme; ?> label">
<?php echo htmlentities($cat,ENT_QUOTES,'utf-8'); ?> <?php echo htmlentities($cat, ENT_QUOTES, 'utf-8'); ?>
</a> </a>
<?php } ?> <?php } ?>
@@ -252,78 +264,82 @@ div[class*=ace_br] {
<div class="ui buttons"> <div class="ui buttons">
<?php <?php
if($pr_flag){ if ($pr_flag) {
echo "<a id='submit' class=\"small ui primary button\" href=\"submitpage.php?id=$id\">$MSG_SUBMIT</a>"; echo "<a id='submit' class=\"small ui primary button\" href=\"submitpage.php?id=$id\">$MSG_SUBMIT</a>";
echo "<a class=\"small ui positive button\" href=\"status.php?problem_id=$id\">$MSG_SUBMIT_RECORD</a>"; echo "<a class=\"small ui positive button\" href=\"status.php?problem_id=$id\">$MSG_SUBMIT_RECORD</a>";
echo "<a class=\"small ui orange button\" href=\"problemstatus.php?id=$id\">$MSG_STATISTICS</a>"; echo "<a class=\"small ui orange button\" href=\"problemstatus.php?id=$id\">$MSG_STATISTICS</a>";
if($OJ_BBS)echo "<a class=\"small ui red button\" href=\"discuss.php?pid=$id\">$MSG_BBS</a>"; if ($OJ_BBS)
}else{ echo "<a class=\"small ui red button\" href=\"discuss.php?pid=$id\">$MSG_BBS</a>";
} else {
echo "<a href=\"contest.php?cid=$cid\" class=\"ui orange button\">$MSG_RETURN_CONTEST</a>"; echo "<a href=\"contest.php?cid=$cid\" class=\"ui orange button\">$MSG_RETURN_CONTEST</a>";
if($contest_is_over) if ($contest_is_over)
echo "<a id='submit' class=\"small ui primary button\" href=\"submitpage.php?id=$id\">$MSG_SUBMIT</a>"; echo "<a id='submit' class=\"small ui primary button\" href=\"submitpage.php?id=$id\">$MSG_SUBMIT</a>";
else else
echo "<a id='submit' class=\"small ui primary button\" href=\"submitpage.php?cid=$cid&pid=$pid&langmask=$langmask\">$MSG_SUBMIT</a>"; echo "<a id='submit' class=\"small ui primary button\" href=\"submitpage.php?cid=$cid&pid=$pid&langmask=$langmask\">$MSG_SUBMIT</a>";
echo "<a class=\"small ui positive button\" href=\"status.php?problem_id=$PID[$pid]&cid=$cid\">$MSG_SUBMIT_RECORD</a>"; echo "<a class=\"small ui positive button\" href=\"status.php?problem_id=$PID[$pid]&cid=$cid\">$MSG_SUBMIT_RECORD</a>";
} }
if(!file_exists($OJ_DATA."/".$id."/solution.name")) echo "<a class='small ui primary button' href='#' onclick='transform()' role='button'>$MSG_SHOW_OFF</a>"; if (!file_exists($OJ_DATA . "/" . $id . "/solution.name"))
echo "<a class='small ui primary button' href='#' onclick='transform()' role='button'>$MSG_SHOW_OFF</a>";
?> ?>
</div> </div>
</div> </div>
<style> <style>
#dragButton { #dragButton {
width: 10px; width: 10px;
height: 10%; height: 10%;
background-color: gray; background-color: gray;
position: absolute; position: absolute;
top:350px; top: 350px;
left: 0; left: 0;
cursor: col-resize; /* 显示可调整宽度的光标 */ cursor: col-resize;
} /* 显示可调整宽度的光标 */
</style> }
</style>
<script type="text/javascript"> <script type="text/javascript">
function transform(){ function transform() {
let height=document.body.clientHeight; let height = document.body.clientHeight;
<?php if ( $row[ 'spj' ]==2 ) {?> <?php if ($row['spj'] == 2) { ?>
let width=parseInt(document.body.clientWidth*0.3); let width = parseInt(document.body.clientWidth * 0.3);
let width2=parseInt(document.body.clientWidth*0.7); let width2 = parseInt(document.body.clientWidth * 0.7);
<?php }else{ ?> <?php } else { ?>
let width=parseInt(document.body.clientWidth*0.6); let width = parseInt(document.body.clientWidth * 0.6);
let width2=parseInt(document.body.clientWidth*0.4); let width2 = parseInt(document.body.clientWidth * 0.4);
<?php } ?> <?php } ?>
let submitURL=$("#submit")[0].href; let submitURL = $("#submit")[0].href;
<?php <?php
if(isset($_GET['sid'])) echo "submitURL+='&sid=".intval($_GET['sid'])."';"; if (isset($_GET['sid']))
echo "submitURL+='&sid=" . intval($_GET['sid']) . "';";
?> ?>
console.log(width); console.log(width);
let main=$("#main"); let main = $("#main");
let problem=main.html(); let problem = main.html();
if (window.screen.width < 500){ if (window.screen.width < 500) {
main.parent().append("<div id='submitPage' class='container' style='opacity:0.95;z-index:2;top:49px;'></div>"); main.parent().append("<div id='submitPage' class='container' style='opacity:0.95;z-index:2;top:49px;'></div>");
$("#submitPage").html("<iframe id='ansFrame' src='"+submitURL+"&spa' width='100%' height='"+window.screen.height+"px' ></iframe>"); $("#submitPage").html("<iframe id='ansFrame' src='" + submitURL + "&spa' width='100%' height='" + window.screen.height + "px' ></iframe>");
window.setTimeout('$("#ansFrame")[0].scrollIntoView()',1000); window.setTimeout('$("#ansFrame")[0].scrollIntoView()', 1000);
}else{ } else {
main.removeClass("container"); main.removeClass("container");
main.css("width",width2); main.css("width", width2);
main.css("margin-left","10px"); main.css("margin-left", "10px");
main.parent().append("<div id='submitPage' class='container' style='opacity:0.95;position:fixed;z-index:2;top:49px;right:-"+width2+"px'></div>"); main.parent().append("<div id='submitPage' class='container' style='opacity:0.95;position:fixed;z-index:2;top:49px;right:-" + width2 + "px'></div>");
$("#submitPage").html("<iframe src='"+submitURL+"&spa' width='"+width+"px' height='"+height+"px' ></iframe>"); $("#submitPage").html("<iframe src='" + submitURL + "&spa' width='" + width + "px' height='" + height + "px' ></iframe>");
} }
$("#submit").remove(); $("#submit").remove();
<?php if ($row['spj']>1){ ?> <?php if ($row['spj'] > 1) { ?>
window.setTimeout('$("iframe")[0].contentWindow.$("#TestRun").remove();',1000); window.setTimeout('$("iframe")[0].contentWindow.$("#TestRun").remove();', 1000);
<?php }?> <?php } ?>
// Add code to place drag button on the left side of the iframe // Add code to place drag button on the left side of the iframe
$("#submitPage").prepend("<div id='dragButton'></div>"); $("#submitPage").prepend("<div id='dragButton'></div>");
$(document).ready(function() { $(document).ready(function () {
let isDragging = false; let isDragging = false;
let startX = 0; let startX = 0;
let initialWidth = 0; let initialWidth = 0;
function setIframeReadonly (readonly) { function setIframeReadonly(readonly) {
const iframe = $("#submitPage").find('iframe') const iframe = $("#submitPage").find('iframe')
if (readonly) { if (readonly) {
iframe.css({ iframe.css({
@@ -340,7 +356,7 @@ $(document).ready(function() {
// 鼠标按下时开始拖拽,颜色变为绿色 // 鼠标按下时开始拖拽,颜色变为绿色
$("#dragButton").mousedown(function(event) { $("#dragButton").mousedown(function (event) {
if (event.target === this) { // Only allow dragging if the mouse button is clicked on the drag button itself if (event.target === this) { // Only allow dragging if the mouse button is clicked on the drag button itself
isDragging = true; isDragging = true;
startX = event.pageX; startX = event.pageX;
@@ -353,7 +369,7 @@ $(document).ready(function() {
}); });
// 拖拽过程中更新宽度 // 拖拽过程中更新宽度
$(document).mousemove(function(event) { $(document).mousemove(function (event) {
if (isDragging) { if (isDragging) {
let diffX = event.pageX - startX; let diffX = event.pageX - startX;
let newWidth = initialWidth + diffX; let newWidth = initialWidth + diffX;
@@ -364,7 +380,7 @@ $(document).ready(function() {
}); });
// 鼠标释放时停止拖拽,恢复原始颜色 // 鼠标释放时停止拖拽,恢复原始颜色
$(document).mouseup(function() { $(document).mouseup(function () {
if (isDragging) { if (isDragging) {
$("#dragButton").css("background-color", "gray"); $("#dragButton").css("background-color", "gray");
} }
@@ -375,7 +391,7 @@ $(document).ready(function() {
}); });
// 鼠标移开页面或失焦时停止拖拽,恢复原始颜色 // 鼠标移开页面或失焦时停止拖拽,恢复原始颜色
$(document).mouseleave(function() { $(document).mouseleave(function () {
if (isDragging) { if (isDragging) {
$("#dragButton").css("background-color", "gray"); $("#dragButton").css("background-color", "gray");
} }
@@ -385,7 +401,7 @@ $(document).ready(function() {
}); });
$(window).blur(function() { $(window).blur(function () {
if (isDragging) { if (isDragging) {
$("#dragButton").css("background-color", "gray"); $("#dragButton").css("background-color", "gray");
} }
@@ -394,7 +410,7 @@ $(document).ready(function() {
}); });
}); });
} }
@@ -409,7 +425,7 @@ $(document).ready(function() {
// $('#languages-menu')[0].scrollTop = $('#languages-menu .active')[0].offsetTop - $('#languages-menu')[0].firstElementChild.offsetTop; // $('#languages-menu')[0].scrollTop = $('#languages-menu .active')[0].offsetTop - $('#languages-menu')[0].firstElementChild.offsetTop;
$(function () { $(function () {
$('#languages-menu .item').click(function() { $('#languages-menu .item').click(function () {
$(this) $(this)
.addClass('active') .addClass('active')
.closest('.ui.menu') .closest('.ui.menu')
@@ -423,37 +439,37 @@ $(document).ready(function() {
</script> </script>
<?php include("template/$OJ_TEMPLATE/footer.php");?> <?php include("template/$OJ_TEMPLATE/footer.php"); ?>
<script> <script>
function phpfm(pid){ function phpfm(pid) {
//alert(pid); //alert(pid);
$.post("admin/phpfm.php",{'frame':3,'pid':pid,'pass':''},function(data,status){ $.post("admin/phpfm.php", { 'frame': 3, 'pid': pid, 'pass': '' }, function (data, status) {
if(status=="success"){ if (status == "success") {
document.location.href="admin/phpfm.php?frame=3&pid="+pid; document.location.href = "admin/phpfm.php?frame=3&pid=" + pid;
} }
}); });
} }
function selectOne( num, answer){ function selectOne(num, answer) {
let editor = $("iframe")[0].contentWindow.$("#source"); let editor = $("iframe")[0].contentWindow.$("#source");
let old=editor.text(); let old = editor.text();
let key= num+".*"; let key = num + ".*";
console.log(key); console.log(key);
let rep=old.replace(new RegExp(key),num+" "+answer); let rep = old.replace(new RegExp(key), num + " " + answer);
editor.text(rep); editor.text(rep);
} }
function selectMulti( num, answer){ function selectMulti(num, answer) {
let editor = $("iframe")[0].contentWindow.$("#source"); let editor = $("iframe")[0].contentWindow.$("#source");
let old=editor.text(); let old = editor.text();
let key= num+".*"; let key = num + ".*";
console.log(key); console.log(key);
let rep=old.replace(new RegExp(key),num+" "+answer); let rep = old.replace(new RegExp(key), num + " " + answer);
editor.text(rep); editor.text(rep);
} }
$(document).ready(function(){ $(document).ready(function () {
$("#creator").load("problem-ajax.php?pid=<?php echo $id?>"); $("#creator").load("problem-ajax.php?pid=<?php echo $id ?>");
<?php if(isset($OJ_MARKDOWN)&&$OJ_MARKDOWN){ ?> <?php if (isset($OJ_MARKDOWN) && $OJ_MARKDOWN) { ?>
marked.use({ marked.use({
// 开启异步渲染 // 开启异步渲染
async: true, async: true,
@@ -463,18 +479,18 @@ function selectMulti( num, answer){
headerIds: false headerIds: false
}); });
$(".md").each(function(){ $(".md").each(function () {
<?php if ($OJ_MARKDOWN && $OJ_MARKDOWN=="marked.js") {?> <?php if ($OJ_MARKDOWN && $OJ_MARKDOWN == "marked.js") { ?>
$(this).html(marked.parse($(this).html())); $(this).html(marked.parse($(this).html()));
<?php }else if ($OJ_MARKDOWN && $OJ_MARKDOWN=="markdown-it") {?> <?php } else if ($OJ_MARKDOWN && $OJ_MARKDOWN == "markdown-it") { ?>
const md = window.markdownit(); const md = window.markdownit();
$(this).html(md.render($(this).text())); $(this).html(md.render($(this).text()));
<?php } ?> <?php } ?>
}); });
// adding note for ```input1 ```output1 in description // adding note for ```input1 ```output1 in description
for(let i=1;i<10;i++){ for (let i = 1; i < 10; i++) {
$(".language-input"+i).parent().before("<div><?php echo $MSG_Input?>"+i+":</div>"); $(".language-input" + i).parent().before("<div><?php echo $MSG_Input ?>" + i + ":</div>");
$(".language-output"+i).parent().before("<div><?php echo $MSG_Output?>"+i+":</div>"); $(".language-output" + i).parent().before("<div><?php echo $MSG_Output ?>" + i + ":</div>");
} }
@@ -495,142 +511,142 @@ function selectMulti( num, answer){
<?php } ?> <?php } ?>
//单纯文本1. A. B. C. D. 自动变控件 //单纯文本1. A. B. C. D. 自动变控件
$('span[class=auto_select]').each(function(){ $('span[class=auto_select]').each(function () {
let i=1; let i = 1;
let start=0; let start = 0;
let next=0; let next = 0;
let raw=$(this).html(); let raw = $(this).html();
let options=['A','B','C','D']; let options = ['A', 'B', 'C', 'D'];
console.log("scanning..."); console.log("scanning...");
while(start>=0){ while (start >= 0) {
start=raw.indexOf("\n"+i+".",start); start = raw.indexOf("\n" + i + ".", start);
if(start<0) break; if (start < 0) break;
let end=start; let end = start;
let type="radio" let type = "radio"
for(let j=0;j<4;j++){ for (let j = 0; j < 4; j++) {
let option=options[j]; let option = options[j];
end=raw.indexOf(option+".",start); end = raw.indexOf(option + ".", start);
next=raw.indexOf("\n"+(i+1)+".",start); next = raw.indexOf("\n" + (i + 1) + ".", start);
console.log("["+raw.substring(start,end)+"]"); console.log("[" + raw.substring(start, end) + "]");
if ( end<0 || ( end > next && next > 0 )) { if (end < 0 || (end > next && next > 0)) {
console.log("i:"+i+" j:"+option+" end:"+end+" next:"+next); console.log("i:" + i + " j:" + option + " end:" + end + " next:" + next);
end=start; end = start;
break; break;
} }
if(j==0&&raw.substring(start,end).indexOf("多选")>0) type="checkbox"; if (j == 0 && raw.substring(start, end).indexOf("多选") > 0) type = "checkbox";
let disp="<input type=\""+type+"\" name=\""+i+"\" value=\""+option+"\" />"+option+"."; let disp = "<input type=\"" + type + "\" name=\"" + i + "\" value=\"" + option + "\" />" + option + ".";
//console.log(disp); //console.log(disp);
raw= raw.substring(0,end-1)+disp+raw.substring(end+2); raw = raw.substring(0, end - 1) + disp + raw.substring(end + 2);
start+=disp.length; start += disp.length;
} }
start=end+1; start = end + 1;
i++; i++;
} }
//console.log(raw); //console.log(raw);
$(this).html(raw); $(this).html(raw);
}); });
// subjective problems from hydroOJ markdown and embeded marks // subjective problems from hydroOJ markdown and embeded marks
$('span[class="md auto_select"]').each(function(){ $('span[class="md auto_select"]').each(function () {
let i=1; let i = 1;
let options=['A','B','C','D','E','F','G']; let options = ['A', 'B', 'C', 'D', 'E', 'F', 'G'];
$(this).find("ul").each(function(){ $(this).find("ul").each(function () {
let type="radio"; let type = "radio";
let ol=$(this).prev("ol"); let ol = $(this).prev("ol");
if(ol!=undefined && ol.attr("start")!=undefined) i=ol.attr("start"); if (ol != undefined && ol.attr("start") != undefined) i = ol.attr("start");
console.log("id["+i+"]"); console.log("id[" + i + "]");
if($(this).html().indexOf("多选")>0|| (ol!=undefined && ol.html()!=undefined && ol.html().indexOf("multiselect")>0)) type="checkbox"; if ($(this).html().indexOf("多选") > 0 || (ol != undefined && ol.html() != undefined && ol.html().indexOf("multiselect") > 0)) type = "checkbox";
let j=0; let j = 0;
$(this).find("li").each(function(){ $(this).find("li").each(function () {
let option=options[j]; let option = options[j];
let disp="<input type=\""+type+"\" name=\""+i+"\" value=\""+option+"\" />"+option+"."; let disp = "<input type=\"" + type + "\" name=\"" + i + "\" value=\"" + option + "\" />" + option + ".";
$(this).prepend(disp); $(this).prepend(disp);
//console.log(options[j]); //console.log(options[j]);
j++; j++;
}); });
i++; i++;
}); });
let html=$(this).html(); let html = $(this).html();
for(;i>0;i--){ for (; i > 0; i--) {
console.log("searching..."+i); console.log("searching..." + i);
html=html.replace("{{ input("+i+") }}","<input type='text' size=5 name='"+i+"' placeholder='第"+i+"题' ><br>"); html = html.replace("{{ input(" + i + ") }}", "<input type='text' size=5 name='" + i + "' placeholder='第" + i + "题' ><br>");
} }
html=html.replaceAll("","&lt;"); html = html.replaceAll("", "&lt;");
html=html.replaceAll("","&gt;"); html = html.replaceAll("", "&gt;");
$(this).html(html); $(this).html(html);
}); });
$(".auto_select").find('input[type="text"]').change(function(){ $(".auto_select").find('input[type="text"]').change(function () {
selectOne($(this).attr("name"),$(this).val()); selectOne($(this).attr("name"), $(this).val());
}); });
$('input[type="radio"]').click(function(){ $('input[type="radio"]').click(function () {
if ($(this).is(':checked')) if ($(this).is(':checked'))
selectOne($(this).attr("name"),$(this).val()); selectOne($(this).attr("name"), $(this).val());
}).css("width","24px").css("height","21px"); }).css("width", "24px").css("height", "21px");
$('input[type="checkbox"]').click(function(){ $('input[type="checkbox"]').click(function () {
let num=$(this).attr("name"); let num = $(this).attr("name");
let answer=""; let answer = "";
$("input[type=checkbox][name="+num+"]").each(function(){ $("input[type=checkbox][name=" + num + "]").each(function () {
if ($(this).is(':checked')) if ($(this).is(':checked'))
answer+=$(this).val(); answer += $(this).val();
}); });
selectMulti(num,answer); selectMulti(num, answer);
}).css("width","24px").css("height","21px"); }).css("width", "24px").css("height", "21px");
<?php if ($row['spj']>1 || isset($_GET['sid']) || (isset($OJ_AUTO_SHOW_OFF)&&$OJ_AUTO_SHOW_OFF)){?> <?php if ($row['spj'] > 1 || isset($_GET['sid']) || (isset($OJ_AUTO_SHOW_OFF) && $OJ_AUTO_SHOW_OFF)) { ?>
transform(); transform();
<?php }?> <?php } ?>
}); });
</script> </script>
<script> <script>
if($('#copyin')[0]!= undefined ){ if ($('#copyin')[0] != undefined) {
var clipboardin=new Clipboard($('#copyin')[0]); var clipboardin = new Clipboard($('#copyin')[0]);
clipboardin.on('success', function(e){ clipboardin.on('success', function (e) {
$("#copyin").text("<?php echo $MSG_COPY.$MSG_SUCCESS; ?>!"); $("#copyin").text("<?php echo $MSG_COPY . $MSG_SUCCESS; ?>!");
setTimeout(function () {$("#copyin").text("<?php echo $MSG_COPY; ?>"); }, 1500); setTimeout(function () { $("#copyin").text("<?php echo $MSG_COPY; ?>"); }, 1500);
console.log(e); console.log(e);
}); });
clipboardin.on('error', function(e){ clipboardin.on('error', function (e) {
$("#copyin").text("<?php echo $MSG_COPY.$MSG_FAIL; ?>!"); $("#copyin").text("<?php echo $MSG_COPY . $MSG_FAIL; ?>!");
setTimeout(function () {$("#copyin").text("<?php echo $MSG_COPY; ?>"); }, 1500); setTimeout(function () { $("#copyin").text("<?php echo $MSG_COPY; ?>"); }, 1500);
console.log(e); console.log(e);
}); });
} }
if($('#copyout')[0]!= undefined ){ if ($('#copyout')[0] != undefined) {
var clipboardout=new Clipboard($('#copyout')[0]); var clipboardout = new Clipboard($('#copyout')[0]);
clipboardout.on('success', function(e){ clipboardout.on('success', function (e) {
$("#copyout").text("<?php echo $MSG_COPY.$MSG_SUCCESS; ?>!"); $("#copyout").text("<?php echo $MSG_COPY . $MSG_SUCCESS; ?>!");
setTimeout(function () {$("#copyout").text("<?php echo $MSG_COPY; ?>"); }, 1500); setTimeout(function () { $("#copyout").text("<?php echo $MSG_COPY; ?>"); }, 1500);
console.log(e); console.log(e);
}); });
clipboardout.on('error', function(e){ clipboardout.on('error', function (e) {
$("#copyout").text("<?php echo $MSG_COPY.$MSG_FAIL; ?>!"); $("#copyout").text("<?php echo $MSG_COPY . $MSG_FAIL; ?>!");
setTimeout(function () {$("#copyout").text("<?php echo $MSG_COPY; ?>"); }, 1500); setTimeout(function () { $("#copyout").text("<?php echo $MSG_COPY; ?>"); }, 1500);
console.log(e); console.log(e);
}); });
} }
</script> </script>
<?php if (isset($OJ_MATHJAX)&&$OJ_MATHJAX){?> <?php if (isset($OJ_MATHJAX) && $OJ_MATHJAX) { ?>
<!--以下为了加载公式的使用而既加入--> <!--以下为了加载公式的使用而既加入-->
<script> <script>
MathJax = { MathJax = {
tex: {inlineMath: [['$', '$'], ['\\(', '\\)']]} tex: { inlineMath: [['$', '$'], ['\\(', '\\)']] }
}; };
</script> </script>
<script id="MathJax-script" async src="template/bs3/tex-chtml.js"></script> <script id="MathJax-script" async src="template/bs3/tex-chtml.js"></script>
<style> <style>
.jumbotron1{ .jumbotron1 {
font-size: 18px; font-size: 18px;
} }
</style> </style>
<?php } ?> <?php } ?>