✨ feat: 更新问题页面和提交页面,集成Vditor适配器,优化Markdown渲染
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
<script src="<?php echo $OJ_CDN_URL.$path_fix."include/"?>jquery-latest.js"></script>
|
||||
|
||||
<?php if(isset($OJ_MARKDOWN)&&$OJ_MARKDOWN){ ?>
|
||||
<script src="<?php echo $OJ_CDN_URL.$path_fix."template/$OJ_TEMPLATE/"?>marked.min.js"></script>
|
||||
<script src="include/vditor-adapter.js"></script>
|
||||
<?php } ?>
|
||||
|
||||
<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
|
||||
|
||||
6
web/template/bs3/marked.min.js
vendored
6
web/template/bs3/marked.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -246,74 +246,93 @@
|
||||
}
|
||||
} );
|
||||
}
|
||||
function getFrameSourceValue(frameWindow) {
|
||||
if (frameWindow.editor && typeof frameWindow.editor.getValue === "function") {
|
||||
return frameWindow.editor.getValue();
|
||||
}
|
||||
return frameWindow.$("#source").text();
|
||||
}
|
||||
function setFrameSourceValue(frameWindow, value) {
|
||||
if (frameWindow.editor && typeof frameWindow.editor.setValue === "function") {
|
||||
frameWindow.editor.setValue(value);
|
||||
return;
|
||||
}
|
||||
frameWindow.$("#source").text(value);
|
||||
}
|
||||
function selectOne( num, answer){
|
||||
let editor = $("iframe")[0].contentWindow.$("#source");
|
||||
let old=editor.text();
|
||||
let frameWindow = $("iframe")[0].contentWindow;
|
||||
let old=getFrameSourceValue(frameWindow);
|
||||
let key= num+".*";
|
||||
console.log(key);
|
||||
let rep=old.replace(new RegExp(key),num+" "+answer);
|
||||
editor.text(rep);
|
||||
setFrameSourceValue(frameWindow, rep);
|
||||
}
|
||||
function selectMulti( num, answer){
|
||||
let editor = $("iframe")[0].contentWindow.$("#source");
|
||||
let old=editor.text();
|
||||
let frameWindow = $("iframe")[0].contentWindow;
|
||||
let old=getFrameSourceValue(frameWindow);
|
||||
let key= num+".*";
|
||||
console.log(key);
|
||||
let rep=old.replace(new RegExp(key),num+" "+answer);
|
||||
editor.text(rep);
|
||||
setFrameSourceValue(frameWindow, rep);
|
||||
}
|
||||
function renderProblemMarkdown() {
|
||||
<?php if(isset($OJ_MARKDOWN)&&$OJ_MARKDOWN){ ?>
|
||||
return HustOJVditor.renderMarkdownBlocks('.md');
|
||||
<?php } ?>
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
function initializeProblemChoices() {
|
||||
$('span[class=auto_select]').each(function(){
|
||||
let i=1;
|
||||
let start=0;
|
||||
let raw=$(this).html();
|
||||
let options=['A','B','C','D'];
|
||||
while(start>=0){
|
||||
start=raw.indexOf(i+".",start);
|
||||
if(start<0) break;
|
||||
let end=start;
|
||||
let type="radio"
|
||||
for(let j=0;j<4;j++){
|
||||
let option=options[j];
|
||||
end=raw.indexOf(option+".",start);
|
||||
if(j==0&&raw.substring(start,end).indexOf("多选")>0) type="checkbox";
|
||||
if (end<0) break;
|
||||
let disp="<input type=\""+type+"\" name=\""+i+"\" value=\""+option+"\" />"+option+".";
|
||||
raw= raw.substring(0,end-1)+disp+raw.substring(end+2);
|
||||
start+=disp.length;
|
||||
}
|
||||
start=end+1;
|
||||
i++;
|
||||
}
|
||||
$(this).html(raw);
|
||||
});
|
||||
$('input[type="radio"]').click(function(){
|
||||
if ($(this).is(':checked'))
|
||||
{
|
||||
selectOne($(this).attr("name"),$(this).val());
|
||||
}
|
||||
});
|
||||
$('input[type="checkbox"]').click(function(){
|
||||
let num=$(this).attr("name");
|
||||
let answer="";
|
||||
$("input[type=checkbox][name="+num+"]").each(function(){
|
||||
if ($(this).is(':checked'))
|
||||
answer+=$(this).val();
|
||||
});
|
||||
selectMulti(num,answer);
|
||||
});
|
||||
<?php if ($row['spj']>1 || isset($_GET['sid']) || (isset($OJ_AUTO_SHOW_OFF)&&$OJ_AUTO_SHOW_OFF)){ ?>
|
||||
transform();
|
||||
<?php }?>
|
||||
}
|
||||
window.renderProblemMarkdown = renderProblemMarkdown;
|
||||
$( document ).ready( function () {
|
||||
$( "#creator" ).load( "problem-ajax.php?pid=<?php echo $id?>" );
|
||||
<?php if(isset($OJ_MARKDOWN)&&$OJ_MARKDOWN){ ?>
|
||||
$(".md").each(function(){
|
||||
$(this).html(marked.parse($(this).html()));
|
||||
});
|
||||
<?php } ?>
|
||||
//单纯文本1. A. B. C. D. 自动变控件
|
||||
$('span[class=auto_select]').each(function(){
|
||||
let i=1;
|
||||
let start=0;
|
||||
let raw=$(this).html();
|
||||
let options=['A','B','C','D'];
|
||||
while(start>=0){
|
||||
start=raw.indexOf(i+".",start);
|
||||
if(start<0) break;
|
||||
let end=start;
|
||||
let type="radio"
|
||||
for(let j=0;j<4;j++){
|
||||
let option=options[j];
|
||||
end=raw.indexOf(option+".",start);
|
||||
if(j==0&&raw.substring(start,end).indexOf("多选")>0) type="checkbox";
|
||||
if (end<0) break;
|
||||
let disp="<input type=\""+type+"\" name=\""+i+"\" value=\""+option+"\" />"+option+".";
|
||||
//console.log(disp);
|
||||
raw= raw.substring(0,end-1)+disp+raw.substring(end+2);
|
||||
start+=disp.length;
|
||||
}
|
||||
start=end+1;
|
||||
i++;
|
||||
}
|
||||
//console.log(raw);
|
||||
$(this).html(raw);
|
||||
});
|
||||
$('input[type="radio"]').click(function(){
|
||||
if ($(this).is(':checked'))
|
||||
{
|
||||
selectOne($(this).attr("name"),$(this).val());
|
||||
}
|
||||
});
|
||||
$('input[type="checkbox"]').click(function(){
|
||||
let num=$(this).attr("name");
|
||||
let answer="";
|
||||
$("input[type=checkbox][name="+num+"]").each(function(){
|
||||
if ($(this).is(':checked'))
|
||||
answer+=$(this).val();
|
||||
});
|
||||
selectMulti(num,answer);
|
||||
});
|
||||
<?php if ($row['spj']>1 || isset($_GET['sid']) || (isset($OJ_AUTO_SHOW_OFF)&&$OJ_AUTO_SHOW_OFF)){ ?>
|
||||
transform();
|
||||
<?php }?>
|
||||
renderProblemMarkdown().catch(function (error) {
|
||||
console.error('Failed to render problem markdown.', error);
|
||||
}).then(function () {
|
||||
initializeProblemChoices();
|
||||
});
|
||||
|
||||
|
||||
} );
|
||||
|
||||
@@ -39,83 +39,78 @@
|
||||
<?php include("template/$OJ_TEMPLATE/js.php");?>
|
||||
|
||||
<?php if(isset($OJ_MARKDOWN)&&$OJ_MARKDOWN){ ?>
|
||||
<script src="<?php echo $OJ_CDN_URL.$path_fix."template/bs3/"?>marked.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
marked.use({
|
||||
// 开启异步渲染
|
||||
async: true,
|
||||
pedantic: false,
|
||||
gfm: true,
|
||||
mangle: false,
|
||||
headerIds: false
|
||||
});
|
||||
$("#errtxt").each(function(){
|
||||
$(this).html(marked.parse($(this).html()));
|
||||
});
|
||||
// adding note for ```input1 ```output1 in description
|
||||
for(let i=1;i<10;i++){
|
||||
$(".language-input"+i).parent().before("<div><?php echo $MSG_Input?>"+i+":</div>");
|
||||
$(".language-output"+i).parent().before("<div><?php echo $MSG_Output?>"+i+":</div>");
|
||||
}
|
||||
|
||||
|
||||
HustOJVditor.renderMarkdownBlocks('#errtxt', {
|
||||
getSource: function (element) {
|
||||
var pre = element.querySelector ? element.querySelector('pre') : null;
|
||||
return pre ? pre.textContent : element.textContent || '';
|
||||
}
|
||||
}).then(function () {
|
||||
for(let i=1;i<10;i++){
|
||||
$(".language-input"+i).parent().before("<div><?php echo $MSG_Input?>"+i+":</div>");
|
||||
$(".language-output"+i).parent().before("<div><?php echo $MSG_Output?>"+i+":</div>");
|
||||
}
|
||||
|
||||
|
||||
$("#errtxt table").addClass("ui mini-table cell striped");
|
||||
$("#errtxt table tr:odd td").css({
|
||||
"border": "1px solid grey",
|
||||
"text-align": "center",
|
||||
"width": "200px",
|
||||
"background-color": "#8521d022",
|
||||
"height": "30px"
|
||||
"border": "1px solid grey",
|
||||
"text-align": "center",
|
||||
"width": "200px",
|
||||
"background-color": "#8521d022",
|
||||
"height": "30px"
|
||||
});
|
||||
$("#errtxt table tr:even td").css({
|
||||
"border": "1px solid grey",
|
||||
"text-align": "center",
|
||||
"width": "200px",
|
||||
"background-color": "#2185d022",
|
||||
"height": "30px"
|
||||
"border": "1px solid grey",
|
||||
"text-align": "center",
|
||||
"width": "200px",
|
||||
"background-color": "#2185d022",
|
||||
"height": "30px"
|
||||
});
|
||||
$("#errtxt table th").css({
|
||||
"border": "1px solid grey",
|
||||
"width": "200px",
|
||||
"height": "30px",
|
||||
"background-color": "#2185d088",
|
||||
"text-align": "center"
|
||||
"border": "1px solid grey",
|
||||
"width": "200px",
|
||||
"height": "30px",
|
||||
"background-color": "#2185d088",
|
||||
"text-align": "center"
|
||||
});
|
||||
<?php
|
||||
if(isset($OJ_DOWNLOAD)&&$OJ_DOWNLOAD){
|
||||
if(isset($OJ_DL_1ST_WA_ONLY) && $OJ_DL_1ST_WA_ONLY){
|
||||
if(isset($OJ_DOWNLOAD)&&$OJ_DOWNLOAD){
|
||||
if(isset($OJ_DL_1ST_WA_ONLY) && $OJ_DL_1ST_WA_ONLY){
|
||||
?>
|
||||
let down=$($("#errtxt").find("h2")[0]);
|
||||
let filename=down.text();
|
||||
down.html("<a href='download.php?sid=<?php echo $id?>&name=" + filename+ "'>" + filename+ "</a>");
|
||||
let down=$($("#errtxt").find("h2")[0]);
|
||||
let filename=down.text();
|
||||
down.html("<a href='download.php?sid=<?php echo $id?>&name=" + filename+ "'>" + filename+ "</a>");
|
||||
<?php
|
||||
}else{
|
||||
}else{
|
||||
?>
|
||||
$("#errtxt").find("h2").each(function(){
|
||||
let down=$(this);
|
||||
let filename=down.text();
|
||||
console.log(filename);
|
||||
down.html("<a href='download.php?sid=<?php echo $id?>&name=" + filename+ "'>" + filename+ "</a>");
|
||||
});
|
||||
|
||||
$("#errtxt").find("h2").each(function(){
|
||||
let down=$(this);
|
||||
let filename=down.text();
|
||||
console.log(filename);
|
||||
down.html("<a href='download.php?sid=<?php echo $id?>&name=" + filename+ "'>" + filename+ "</a>");
|
||||
});
|
||||
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
$("th").each(function(){
|
||||
let html=$(this).html();
|
||||
html=html.replace("Expected","<?php echo $MSG_EXPECTED ?>");
|
||||
html=html.replace("Yours","<?php echo $MSG_YOURS ?>");
|
||||
html=html.replace("filename","<?php echo $MSG_FILENAME ?>");
|
||||
html=html.replace("size","<?php echo $MSG_SIZE ?>");
|
||||
html=html.replace("result","<?php echo $MSG_RESULT ?>");
|
||||
html=html.replace("memory","<?php echo $MSG_MEMORY?>");
|
||||
html=html.replace("time","<?php echo $MSG_TIME ?>");
|
||||
$(this).html(html);
|
||||
|
||||
let html=$(this).html();
|
||||
html=html.replace("Expected","<?php echo $MSG_EXPECTED ?>");
|
||||
html=html.replace("Yours","<?php echo $MSG_YOURS ?>");
|
||||
html=html.replace("filename","<?php echo $MSG_FILENAME ?>");
|
||||
html=html.replace("size","<?php echo $MSG_SIZE ?>");
|
||||
html=html.replace("result","<?php echo $MSG_RESULT ?>");
|
||||
html=html.replace("memory","<?php echo $MSG_MEMORY?>");
|
||||
html=html.replace("time","<?php echo $MSG_TIME ?>");
|
||||
$(this).html(html);
|
||||
|
||||
});
|
||||
|
||||
}).catch(function (error) {
|
||||
console.error('Failed to render reinfo markdown.', error);
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
@@ -65,30 +65,25 @@
|
||||
<!-- Placed at the end of the document so the pages load faster -->
|
||||
<?php include("template/$OJ_TEMPLATE/js.php");?>
|
||||
|
||||
<script src="<?php echo $OJ_CDN_URL?>ace/ace.js"></script>
|
||||
<script src="<?php echo $OJ_CDN_URL?>ace/ext-language_tools.js"></script>
|
||||
<script src="include/vditor-adapter.js"></script>
|
||||
<script>
|
||||
$("#language").on("change",changeLanguage);
|
||||
//初始化对象
|
||||
editor = ace.edit("code");
|
||||
editor = HustOJVditor.createDeferredCodeEditor({
|
||||
container: "code",
|
||||
sourceField: "source",
|
||||
readOnly: <?php echo $readOnly ?>,
|
||||
theme: "ace/theme/clouds",
|
||||
fontSize: 18
|
||||
});
|
||||
|
||||
//设置风格和语言(更多风格和语言,请到github上相应目录查看)
|
||||
theme = "clouds"
|
||||
language = "c_cpp"
|
||||
editor.setTheme("ace/theme/" + theme);
|
||||
editor.session.setMode("ace/mode/" + language);
|
||||
|
||||
//字体大小
|
||||
editor.setFontSize(18);
|
||||
|
||||
//设置只读(true时只读,用于展示代码)
|
||||
editor.setReadOnly(<?php echo $readOnly ?>);
|
||||
|
||||
//自动换行,设置为off关闭
|
||||
editor.setOption("wrap", "free")
|
||||
|
||||
//启用提示菜单
|
||||
ace.require("ace/ext/language_tools");
|
||||
editor.setOptions({
|
||||
enableBasicAutocompletion: true,
|
||||
enableSnippets: true,
|
||||
|
||||
@@ -389,20 +389,20 @@ function resume(){
|
||||
<script language="Javascript" type="text/javascript" src="<?php echo $OJ_CDN_URL?>include/base64.js"></script>
|
||||
|
||||
<?php if($OJ_ACE_EDITOR){ ?>
|
||||
<script src="<?php echo $OJ_CDN_URL?>ace/ace.js"></script>
|
||||
|
||||
<script src="<?php echo $OJ_CDN_URL?>ace/ext-language_tools.js"></script>
|
||||
<script src="include/vditor-adapter.js"></script>
|
||||
|
||||
<script>
|
||||
ace.require("<?php echo $OJ_CDN_URL?>ace/ext/language_tools");
|
||||
var editor = ace.edit("source");
|
||||
editor.setTheme("ace/theme/chrome");
|
||||
var editor = HustOJVditor.createDeferredCodeEditor({
|
||||
container: "source",
|
||||
hiddenField: "hide_source",
|
||||
theme: "ace/theme/chrome",
|
||||
fontSize: 20
|
||||
});
|
||||
switchLang(<?php echo isset($lastlang)?$lastlang:0 ; ?>);
|
||||
editor.setOptions({
|
||||
enableBasicAutocompletion: true,
|
||||
enableSnippets: true,
|
||||
enableLiveAutocompletion: false,
|
||||
//fontFamily: "Consolas",
|
||||
fontSize: "20px"
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -7,11 +7,8 @@
|
||||
$("#csrf").load("<?php echo $path_fix ?>csrf.php");
|
||||
</script>
|
||||
|
||||
<!-- WangEditor编辑器文件-->
|
||||
<script src="./template/bshark/wangEditor/wangEditor.min.js"></script>
|
||||
|
||||
<?php if (isset($OJ_MARKDOWN) && $OJ_MARKDOWN) { ?>
|
||||
<script src="<?php echo $OJ_CDN_URL . $path_fix . "template/$OJ_TEMPLATE/" ?>marked.min.js"></script>
|
||||
<script src="include/vditor-adapter.js"></script>
|
||||
<?php } ?>
|
||||
|
||||
<!-- 主题核心js -->
|
||||
|
||||
@@ -208,26 +208,40 @@ a:hover {
|
||||
</div>
|
||||
<?php require("./template/bshark/footer.php");?>
|
||||
<?php require("./template/bshark/footer-files.php");?>
|
||||
<script src="include/vditor-adapter.js"></script>
|
||||
<script type="text/javascript">
|
||||
var E = window.wangEditor
|
||||
var editor = new E('#editor')
|
||||
|
||||
editor.customConfig.zIndex = 0
|
||||
editor.customConfig.menus = [
|
||||
//'head',
|
||||
'bold',
|
||||
//'italic',
|
||||
//'underline',
|
||||
'link',
|
||||
//'list',
|
||||
//'quote',
|
||||
//'table',
|
||||
'image',
|
||||
'emoticon',
|
||||
'code'
|
||||
]
|
||||
// 或者 var editor = new E( document.getElementById('editor') )
|
||||
editor.create()
|
||||
var editor = {
|
||||
txt: {
|
||||
html: function () {
|
||||
return $("#aa").val();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
HustOJVditor.createRichTextEditor({
|
||||
container: '#editor',
|
||||
hiddenField: '#aa',
|
||||
mode: 'wysiwyg',
|
||||
minHeight: 180,
|
||||
toolbar: [
|
||||
'bold',
|
||||
'italic',
|
||||
'strike',
|
||||
'|',
|
||||
'link',
|
||||
'emoji',
|
||||
'code',
|
||||
'|',
|
||||
'undo',
|
||||
'redo',
|
||||
'|',
|
||||
'fullscreen'
|
||||
]
|
||||
}).then(function (instance) {
|
||||
editor = instance;
|
||||
}).catch(function (error) {
|
||||
console.error('Failed to initialize Vditor mail editor.', error);
|
||||
});
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
var div = document.getElementById('infos');
|
||||
|
||||
6
web/template/bshark/marked.min.js
vendored
6
web/template/bshark/marked.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -212,12 +212,19 @@
|
||||
});
|
||||
}
|
||||
|
||||
function renderProblemMarkdown() {
|
||||
<?php if (isset($OJ_MARKDOWN) && $OJ_MARKDOWN) { ?>
|
||||
return HustOJVditor.renderMarkdownBlocks('div.md');
|
||||
<?php } ?>
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
|
||||
window.renderProblemMarkdown = renderProblemMarkdown;
|
||||
|
||||
$(document).ready(function () {
|
||||
<?php if (isset($OJ_MARKDOWN) && $OJ_MARKDOWN) { ?>
|
||||
$("div.md").each(function () {
|
||||
$(this).html(marked.parse($(this).html()));
|
||||
});
|
||||
<?php } ?>
|
||||
renderProblemMarkdown().catch(function (error) {
|
||||
console.error('Failed to render problem markdown.', error);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -59,83 +59,79 @@
|
||||
explain();
|
||||
</script>
|
||||
<?php if(isset($OJ_MARKDOWN)&&$OJ_MARKDOWN){ ?>
|
||||
<script src="<?php echo $OJ_CDN_URL.$path_fix."template/bs3/"?>marked.min.js"></script>
|
||||
<script src="include/vditor-adapter.js"></script>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
marked.use({
|
||||
// 开启异步渲染
|
||||
async: true,
|
||||
pedantic: false,
|
||||
gfm: true,
|
||||
mangle: false,
|
||||
headerIds: false
|
||||
HustOJVditor.renderMarkdownBlocks('#errtxt', {
|
||||
getSource: function (element) {
|
||||
var pre = element.querySelector ? element.querySelector('pre') : null;
|
||||
return pre ? pre.textContent : element.textContent || '';
|
||||
}
|
||||
}).then(function () {
|
||||
for(let i=1;i<10;i++){
|
||||
$(".language-input"+i).parent().before("<div><?php echo $MSG_Input?>"+i+":</div>");
|
||||
$(".language-output"+i).parent().before("<div><?php echo $MSG_Output?>"+i+":</div>");
|
||||
}
|
||||
|
||||
|
||||
$("#errtxt table").addClass("ui mini-table cell striped");
|
||||
$("#errtxt table tr:odd td").css({
|
||||
"border": "1px solid grey",
|
||||
"text-align": "center",
|
||||
"width": "200px",
|
||||
"background-color": "#8521d022",
|
||||
"height": "30px"
|
||||
});
|
||||
$("#errtxt table tr:even td").css({
|
||||
"border": "1px solid grey",
|
||||
"text-align": "center",
|
||||
"width": "200px",
|
||||
"background-color": "#2185d022",
|
||||
"height": "30px"
|
||||
});
|
||||
$("#errtxt table th").css({
|
||||
"border": "1px solid grey",
|
||||
"width": "200px",
|
||||
"height": "30px",
|
||||
"background-color": "#2185d088",
|
||||
"text-align": "center"
|
||||
});
|
||||
<?php
|
||||
if(isset($OJ_DOWNLOAD)&&$OJ_DOWNLOAD){
|
||||
if(isset($OJ_DL_1ST_WA_ONLY) && $OJ_DL_1ST_WA_ONLY){
|
||||
?>
|
||||
let down=$($("#errtxt").find("h2")[0]);
|
||||
let filename=down.text();
|
||||
down.html("<a href='download.php?sid=<?php echo $id?>&name=" + filename+ "'>" + filename+ "</a>");
|
||||
<?php
|
||||
}else{
|
||||
?>
|
||||
$("#errtxt").find("h2").each(function(){
|
||||
let down=$(this);
|
||||
let filename=down.text();
|
||||
console.log(filename);
|
||||
down.html("<a href='download.php?sid=<?php echo $id?>&name=" + filename+ "'>" + filename+ "</a>");
|
||||
});
|
||||
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
$("th").each(function(){
|
||||
let html=$(this).html();
|
||||
html=html.replace("Expected","<?php echo $MSG_EXPECTED ?>");
|
||||
html=html.replace("Yours","<?php echo $MSG_YOURS ?>");
|
||||
html=html.replace("filename","<?php echo $MSG_FILENAME ?>");
|
||||
html=html.replace("size","<?php echo $MSG_SIZE ?>");
|
||||
html=html.replace("result","<?php echo $MSG_RESULT ?>");
|
||||
html=html.replace("memory","<?php echo $MSG_MEMORY?>");
|
||||
html=html.replace("time","<?php echo $MSG_TIME ?>");
|
||||
$(this).html(html);
|
||||
|
||||
});
|
||||
}).catch(function (error) {
|
||||
console.error('Failed to render reinfo markdown.', error);
|
||||
});
|
||||
$("#errtxt").each(function(){
|
||||
$(this).html(marked.parse($(this).html()));
|
||||
});
|
||||
// adding note for ```input1 ```output1 in description
|
||||
for(let i=1;i<10;i++){
|
||||
$(".language-input"+i).parent().before("<div><?php echo $MSG_Input?>"+i+":</div>");
|
||||
$(".language-output"+i).parent().before("<div><?php echo $MSG_Output?>"+i+":</div>");
|
||||
}
|
||||
|
||||
|
||||
$("#errtxt table").addClass("ui mini-table cell striped");
|
||||
$("#errtxt table tr:odd td").css({
|
||||
"border": "1px solid grey",
|
||||
"text-align": "center",
|
||||
"width": "200px",
|
||||
"background-color": "#8521d022",
|
||||
"height": "30px"
|
||||
});
|
||||
$("#errtxt table tr:even td").css({
|
||||
"border": "1px solid grey",
|
||||
"text-align": "center",
|
||||
"width": "200px",
|
||||
"background-color": "#2185d022",
|
||||
"height": "30px"
|
||||
});
|
||||
$("#errtxt table th").css({
|
||||
"border": "1px solid grey",
|
||||
"width": "200px",
|
||||
"height": "30px",
|
||||
"background-color": "#2185d088",
|
||||
"text-align": "center"
|
||||
});
|
||||
<?php
|
||||
if(isset($OJ_DOWNLOAD)&&$OJ_DOWNLOAD){
|
||||
if(isset($OJ_DL_1ST_WA_ONLY) && $OJ_DL_1ST_WA_ONLY){
|
||||
?>
|
||||
let down=$($("#errtxt").find("h2")[0]);
|
||||
let filename=down.text();
|
||||
down.html("<a href='download.php?sid=<?php echo $id?>&name=" + filename+ "'>" + filename+ "</a>");
|
||||
<?php
|
||||
}else{
|
||||
?>
|
||||
$("#errtxt").find("h2").each(function(){
|
||||
let down=$(this);
|
||||
let filename=down.text();
|
||||
console.log(filename);
|
||||
down.html("<a href='download.php?sid=<?php echo $id?>&name=" + filename+ "'>" + filename+ "</a>");
|
||||
});
|
||||
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
$("th").each(function(){
|
||||
let html=$(this).html();
|
||||
html=html.replace("Expected","<?php echo $MSG_EXPECTED ?>");
|
||||
html=html.replace("Yours","<?php echo $MSG_YOURS ?>");
|
||||
html=html.replace("filename","<?php echo $MSG_FILENAME ?>");
|
||||
html=html.replace("size","<?php echo $MSG_SIZE ?>");
|
||||
html=html.replace("result","<?php echo $MSG_RESULT ?>");
|
||||
html=html.replace("memory","<?php echo $MSG_MEMORY?>");
|
||||
html=html.replace("time","<?php echo $MSG_TIME ?>");
|
||||
$(this).html(html);
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
@@ -404,12 +404,14 @@
|
||||
</script>
|
||||
<script language="Javascript" type="text/javascript" src="include/base64.js"></script>
|
||||
<?php if ($OJ_ACE_EDITOR) { ?>
|
||||
<script src="ace/ace.js"></script>
|
||||
<script src="ace/ext-language_tools.js"></script>
|
||||
<script src="include/vditor-adapter.js"></script>
|
||||
<script>
|
||||
ace.require("ace/ext/language_tools");
|
||||
var editor = ace.edit("source");
|
||||
editor.setTheme("ace/theme/chrome");
|
||||
var editor = HustOJVditor.createDeferredCodeEditor({
|
||||
container: "source",
|
||||
hiddenField: "hide_source",
|
||||
theme: "ace/theme/chrome",
|
||||
fontSize: 20
|
||||
});
|
||||
switchLang(<?php echo $lastlang ?>);
|
||||
editor.setOptions({
|
||||
enableBasicAutocompletion: true,
|
||||
|
||||
@@ -58,27 +58,21 @@
|
||||
explain();
|
||||
</script>
|
||||
<?php if(isset($OJ_MARKDOWN)&&$OJ_MARKDOWN){ ?>
|
||||
<script src="<?php echo $OJ_CDN_URL.$path_fix."template/bs3/"?>marked.min.js"></script>
|
||||
<script src="include/vditor-adapter.js"></script>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
marked.use({
|
||||
// 开启异步渲染
|
||||
async: true,
|
||||
pedantic: false,
|
||||
gfm: true,
|
||||
mangle: false,
|
||||
headerIds: false
|
||||
});
|
||||
$("#errtxt").each(function(){
|
||||
$(this).html(marked.parse($(this).html()));
|
||||
});
|
||||
// adding note for ```input1 ```output1 in description
|
||||
for(let i=1;i<10;i++){
|
||||
$(".language-input"+i).parent().before("<div><?php echo $MSG_Input?>"+i+":</div>");
|
||||
$(".language-output"+i).parent().before("<div><?php echo $MSG_Output?>"+i+":</div>");
|
||||
}
|
||||
|
||||
|
||||
HustOJVditor.renderMarkdownBlocks('#errtxt', {
|
||||
getSource: function (element) {
|
||||
var pre = element.querySelector ? element.querySelector('pre') : null;
|
||||
return pre ? pre.textContent : element.textContent || '';
|
||||
}
|
||||
}).then(function () {
|
||||
for(let i=1;i<10;i++){
|
||||
$(".language-input"+i).parent().before("<div><?php echo $MSG_Input?>"+i+":</div>");
|
||||
$(".language-output"+i).parent().before("<div><?php echo $MSG_Output?>"+i+":</div>");
|
||||
}
|
||||
|
||||
|
||||
$("#errtxt table").addClass("ui mini-table cell striped");
|
||||
$("#errtxt table tr:odd td").css({
|
||||
"border": "1px solid grey",
|
||||
@@ -112,29 +106,31 @@
|
||||
}else{
|
||||
?>
|
||||
$("#errtxt").find("h2").each(function(){
|
||||
let down=$(this);
|
||||
let filename=down.text();
|
||||
console.log(filename);
|
||||
down.html("<a href='download.php?sid=<?php echo $id?>&name=" + filename+ "'>" + filename+ "</a>");
|
||||
let down=$(this);
|
||||
let filename=down.text();
|
||||
console.log(filename);
|
||||
down.html("<a href='download.php?sid=<?php echo $id?>&name=" + filename+ "'>" + filename+ "</a>");
|
||||
});
|
||||
|
||||
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
$("th").each(function(){
|
||||
let html=$(this).html();
|
||||
html=html.replace("Expected","<?php echo $MSG_EXPECTED ?>");
|
||||
html=html.replace("Yours","<?php echo $MSG_YOURS ?>");
|
||||
html=html.replace("filename","<?php echo $MSG_FILENAME ?>");
|
||||
html=html.replace("size","<?php echo $MSG_SIZE ?>");
|
||||
html=html.replace("result","<?php echo $MSG_RESULT ?>");
|
||||
html=html.replace("memory","<?php echo $MSG_MEMORY?>");
|
||||
html=html.replace("time","<?php echo $MSG_TIME ?>");
|
||||
$(this).html(html);
|
||||
|
||||
let html=$(this).html();
|
||||
html=html.replace("Expected","<?php echo $MSG_EXPECTED ?>");
|
||||
html=html.replace("Yours","<?php echo $MSG_YOURS ?>");
|
||||
html=html.replace("filename","<?php echo $MSG_FILENAME ?>");
|
||||
html=html.replace("size","<?php echo $MSG_SIZE ?>");
|
||||
html=html.replace("result","<?php echo $MSG_RESULT ?>");
|
||||
html=html.replace("memory","<?php echo $MSG_MEMORY?>");
|
||||
html=html.replace("time","<?php echo $MSG_TIME ?>");
|
||||
$(this).html(html);
|
||||
|
||||
});
|
||||
|
||||
}).catch(function (error) {
|
||||
console.error('Failed to render reinfo markdown.', error);
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
@@ -70,30 +70,25 @@
|
||||
<!-- Placed at the end of the document so the pages load faster -->
|
||||
<?php include("template/$OJ_TEMPLATE/js.php");?>
|
||||
|
||||
<script src="ace/ace.js"></script>
|
||||
<script src="ace/ext-language_tools.js"></script>
|
||||
<script src="include/vditor-adapter.js"></script>
|
||||
<script>
|
||||
$("#language").on("change",changeLanguage);
|
||||
//初始化对象
|
||||
editor = ace.edit("code");
|
||||
editor = HustOJVditor.createDeferredCodeEditor({
|
||||
container: "code",
|
||||
sourceField: "source",
|
||||
readOnly: <?php echo $readOnly ?>,
|
||||
theme: "ace/theme/clouds",
|
||||
fontSize: 18
|
||||
});
|
||||
|
||||
//设置风格和语言(更多风格和语言,请到github上相应目录查看)
|
||||
theme = "clouds"
|
||||
language = "c_cpp"
|
||||
editor.setTheme("ace/theme/" + theme);
|
||||
editor.session.setMode("ace/mode/" + language);
|
||||
|
||||
//字体大小
|
||||
editor.setFontSize(18);
|
||||
|
||||
//设置只读(true时只读,用于展示代码)
|
||||
editor.setReadOnly(<?php echo $readOnly ?>);
|
||||
|
||||
//自动换行,设置为off关闭
|
||||
editor.setOption("wrap", "free")
|
||||
|
||||
//启用提示菜单
|
||||
ace.require("ace/ext/language_tools");
|
||||
editor.setOptions({
|
||||
enableBasicAutocompletion: true,
|
||||
enableSnippets: true,
|
||||
|
||||
@@ -397,23 +397,14 @@
|
||||
<script language="Javascript" type="text/javascript" src="include/base64.js"></script>
|
||||
|
||||
<?php if($OJ_ACE_EDITOR){ ?>
|
||||
<?php if(isset($MDUI_OFFLINE) && $MDUI_OFFLINE) { ?>
|
||||
<script src="<?php echo $OJ_CDN_URL.$path_fix."/"; ?>/ace/ace.min.js"></script>
|
||||
<script src="<?php echo $OJ_CDN_URL.$path_fix."/"; ?>/ace/ext-language_tools.min.js"></script>
|
||||
<script>
|
||||
ace.config.set('basePath', '<?php echo $OJ_CDN_URL.$path_fix."template/$OJ_TEMPLATE"; ?>/assets/ace/');
|
||||
</script>
|
||||
<?php } else { ?>
|
||||
<script src="https://cdn.jsdelivr.net/npm/ace-builds@1.4.12/src-noconflict/ace.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/ace-builds@1.4.12/src-noconflict/ext-language_tools.min.js"></script>
|
||||
<script>
|
||||
ace.config.set('basePath', 'https://cdn.jsdelivr.net/npm/ace-builds@1.4.12/src-min-noconflict/');
|
||||
</script>
|
||||
<?php } ?>
|
||||
<script src="include/vditor-adapter.js"></script>
|
||||
<script>
|
||||
ace.require("ace/ext/language_tools");
|
||||
var editor = ace.edit("source");
|
||||
editor.setTheme("ace/theme/chrome");
|
||||
var editor = HustOJVditor.createDeferredCodeEditor({
|
||||
container: "source",
|
||||
hiddenField: "hide_source",
|
||||
theme: "ace/theme/chrome",
|
||||
fontSize: 20
|
||||
});
|
||||
switchLang(<?php echo isset($lastlang) ? $lastlang : 0 ; ?>);
|
||||
editor.setOptions({
|
||||
enableBasicAutocompletion: true,
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
?>
|
||||
<?php include("template/$OJ_TEMPLATE/header.php");?>
|
||||
<?php include("include/bbcode.php");?>
|
||||
<script src="<?php echo "template/bs3/"?>marked.min.js"></script>
|
||||
<script src="include/vditor-adapter.js"></script>
|
||||
<div class="padding">
|
||||
<h1><?php echo $news_title ?></h1>
|
||||
<div class="ui existing segment">
|
||||
@@ -15,37 +15,47 @@
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
marked.use({
|
||||
// 开启异步渲染
|
||||
async: true,
|
||||
pedantic: false,
|
||||
gfm: true,
|
||||
mangle: false,
|
||||
headerIds: false
|
||||
});
|
||||
$(".md").each(function(){
|
||||
$(this).html(marked.parse($(this).text()));
|
||||
});
|
||||
// adding note for ```input1 ```output1 in description
|
||||
for(let i=1;i<10;i++){
|
||||
$(".language-input"+i).parent().before("<div><?php echo $MSG_Input?>"+i+":</div>");
|
||||
$(".language-output"+i).parent().before("<div><?php echo $MSG_Output?>"+i+":</div>");
|
||||
}
|
||||
$(".md table tr td").css({
|
||||
"border": "1px solid grey",
|
||||
"text-align": "center",
|
||||
"width": "200px",
|
||||
"height": "30px"
|
||||
});
|
||||
function addMarkdownInputOutputLabels() {
|
||||
for(let i=1;i<10;i++){
|
||||
$(".language-input"+i).parent().each(function(){
|
||||
if ($(this).prev('.hustoj-md-io-label').length === 0) {
|
||||
$(this).before("<div class='hustoj-md-io-label'><?php echo $MSG_Input?>"+i+":</div>");
|
||||
}
|
||||
});
|
||||
$(".language-output"+i).parent().each(function(){
|
||||
if ($(this).prev('.hustoj-md-io-label').length === 0) {
|
||||
$(this).before("<div class='hustoj-md-io-label'><?php echo $MSG_Output?>"+i+":</div>");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
$(".md table th").css({
|
||||
"border": "1px solid grey",
|
||||
"width": "200px",
|
||||
"height": "30px",
|
||||
"background-color": "#9e9e9ea1",
|
||||
"text-align": "center"
|
||||
});
|
||||
function styleMarkdownTables() {
|
||||
$(".md table tr td").css({
|
||||
"border": "1px solid grey",
|
||||
"text-align": "center",
|
||||
"width": "200px",
|
||||
"height": "30px"
|
||||
});
|
||||
|
||||
$(".md table th").css({
|
||||
"border": "1px solid grey",
|
||||
"width": "200px",
|
||||
"height": "30px",
|
||||
"background-color": "#9e9e9ea1",
|
||||
"text-align": "center"
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
HustOJVditor.renderMarkdownBlocks('.md', {
|
||||
useTextContent: true
|
||||
}).then(function () {
|
||||
addMarkdownInputOutputLabels();
|
||||
styleMarkdownTables();
|
||||
}).catch(function (error) {
|
||||
console.error('Failed to render discuss markdown.', error);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php include("template/$OJ_TEMPLATE/footer.php");?>
|
||||
|
||||
2
web/template/sidebar/js/markdown-it.min.js
vendored
2
web/template/sidebar/js/markdown-it.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -33,8 +33,7 @@ div[class*=ace_br] {
|
||||
}
|
||||
</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/bs3/"?>marked.min.js"></script>
|
||||
<script src="<?php echo $OJ_CDN_URL.$path_fix."template/syzoj/js/"?>markdown-it.min.js"></script>
|
||||
<script src="include/vditor-adapter.js"></script>
|
||||
|
||||
<div class="padding ">
|
||||
<div class="ui center aligned grid">
|
||||
@@ -399,154 +398,172 @@ function phpfm(pid){
|
||||
}
|
||||
});
|
||||
}
|
||||
function getFrameSourceValue(frameWindow){
|
||||
if(frameWindow.editor && typeof frameWindow.editor.getValue === "function"){
|
||||
return frameWindow.editor.getValue();
|
||||
}
|
||||
return frameWindow.$("#source").text();
|
||||
}
|
||||
function setFrameSourceValue(frameWindow, value){
|
||||
if(frameWindow.editor && typeof frameWindow.editor.setValue === "function"){
|
||||
frameWindow.editor.setValue(value);
|
||||
return;
|
||||
}
|
||||
frameWindow.$("#source").text(value);
|
||||
}
|
||||
function selectOne( num, answer){
|
||||
let editor = $("iframe")[0].contentWindow.$("#source");
|
||||
let old=editor.text();
|
||||
let frameWindow = $("iframe")[0].contentWindow;
|
||||
let old=getFrameSourceValue(frameWindow);
|
||||
let key= num+".*";
|
||||
console.log(key);
|
||||
let rep=old.replace(new RegExp(key),num+" "+answer);
|
||||
editor.text(rep);
|
||||
setFrameSourceValue(frameWindow, rep);
|
||||
}
|
||||
function selectMulti( num, answer){
|
||||
let editor = $("iframe")[0].contentWindow.$("#source");
|
||||
let old=editor.text();
|
||||
let frameWindow = $("iframe")[0].contentWindow;
|
||||
let old=getFrameSourceValue(frameWindow);
|
||||
let key= num+".*";
|
||||
console.log(key);
|
||||
let rep=old.replace(new RegExp(key),num+" "+answer);
|
||||
editor.text(rep);
|
||||
setFrameSourceValue(frameWindow, rep);
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
$("#creator").load("problem-ajax.php?pid=<?php echo $id?>");
|
||||
<?php if(isset($OJ_MARKDOWN)&&$OJ_MARKDOWN){ ?>
|
||||
marked.use({
|
||||
// 开启异步渲染
|
||||
async: true,
|
||||
pedantic: false,
|
||||
gfm: true,
|
||||
mangle: false,
|
||||
headerIds: false
|
||||
});
|
||||
|
||||
$(".md").each(function(){
|
||||
<?php if ($OJ_MARKDOWN && $OJ_MARKDOWN=="marked.js") {?>
|
||||
$(this).html(marked.parse($(this).html()));
|
||||
<?php }else if ($OJ_MARKDOWN && $OJ_MARKDOWN=="markdown-it") {?>
|
||||
const md = window.markdownit();
|
||||
$(this).html(md.render($(this).text()));
|
||||
<?php } ?>
|
||||
});
|
||||
// adding note for ```input1 ```output1 in description
|
||||
for(let i=1;i<10;i++){
|
||||
$(".language-input"+i).parent().before("<div><?php echo $MSG_Input?>"+i+":</div>");
|
||||
$(".language-output"+i).parent().before("<div><?php echo $MSG_Output?>"+i+":</div>");
|
||||
}
|
||||
|
||||
|
||||
$(".md table tr td").css({
|
||||
"border": "1px solid grey",
|
||||
"text-align": "center",
|
||||
"width": "200px",
|
||||
"height": "30px"
|
||||
function addMarkdownInputOutputLabels() {
|
||||
for (let i = 1; i < 10; i++) {
|
||||
$(".language-input" + i).parent().each(function(){
|
||||
if ($(this).prev('.hustoj-md-io-label').length === 0) {
|
||||
$(this).before("<div class='hustoj-md-io-label'><?php echo $MSG_Input?>" + i + ":</div>");
|
||||
}
|
||||
});
|
||||
|
||||
$(".md table th").css({
|
||||
"border": "1px solid grey",
|
||||
"width": "200px",
|
||||
"height": "30px",
|
||||
"background-color": "#9e9e9ea1",
|
||||
"text-align": "center"
|
||||
$(".language-output" + i).parent().each(function(){
|
||||
if ($(this).prev('.hustoj-md-io-label').length === 0) {
|
||||
$(this).before("<div class='hustoj-md-io-label'><?php echo $MSG_Output?>" + i + ":</div>");
|
||||
}
|
||||
});
|
||||
|
||||
<?php } ?>
|
||||
//单纯文本1. A. B. C. D. 自动变控件
|
||||
$('span[class=auto_select]').each(function(){
|
||||
let i=1;
|
||||
let start=0;
|
||||
let next=0;
|
||||
let raw=$(this).html();
|
||||
let options=['A','B','C','D'];
|
||||
console.log("scanning...");
|
||||
while(start>=0){
|
||||
start=raw.indexOf("\n"+i+".",start);
|
||||
if(start<0) break;
|
||||
let end=start;
|
||||
let type="radio"
|
||||
for(let j=0;j<4;j++){
|
||||
let option=options[j];
|
||||
end=raw.indexOf(option+".",start);
|
||||
next=raw.indexOf("\n"+(i+1)+".",start);
|
||||
console.log("["+raw.substring(start,end)+"]");
|
||||
if ( end<0 || ( end > next && next > 0 )) {
|
||||
console.log("i:"+i+" j:"+option+" end:"+end+" next:"+next);
|
||||
end=start;
|
||||
break;
|
||||
}
|
||||
if(j==0&&raw.substring(start,end).indexOf("多选")>0) type="checkbox";
|
||||
let disp="<input type=\""+type+"\" name=\""+i+"\" value=\""+option+"\" />"+option+".";
|
||||
//console.log(disp);
|
||||
raw= raw.substring(0,end-1)+disp+raw.substring(end+2);
|
||||
start+=disp.length;
|
||||
}
|
||||
start=end+1;
|
||||
i++;
|
||||
}
|
||||
//console.log(raw);
|
||||
$(this).html(raw);
|
||||
}
|
||||
}
|
||||
|
||||
function styleMarkdownTables() {
|
||||
$(".md table tr td").css({
|
||||
"border": "1px solid grey",
|
||||
"text-align": "center",
|
||||
"width": "200px",
|
||||
"height": "30px"
|
||||
});
|
||||
|
||||
$(".md table th").css({
|
||||
"border": "1px solid grey",
|
||||
"width": "200px",
|
||||
"height": "30px",
|
||||
"background-color": "#9e9e9ea1",
|
||||
"text-align": "center"
|
||||
});
|
||||
}
|
||||
|
||||
function renderProblemMarkdown() {
|
||||
<?php if(isset($OJ_MARKDOWN)&&$OJ_MARKDOWN){ ?>
|
||||
return HustOJVditor.renderMarkdownBlocks('.md').then(function () {
|
||||
addMarkdownInputOutputLabels();
|
||||
styleMarkdownTables();
|
||||
});
|
||||
<?php } ?>
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
|
||||
function initializeProblemChoices() {
|
||||
$('span[class=auto_select]').each(function(){
|
||||
let i=1;
|
||||
let start=0;
|
||||
let next=0;
|
||||
let raw=$(this).html();
|
||||
let options=['A','B','C','D'];
|
||||
console.log("scanning...");
|
||||
while(start>=0){
|
||||
start=raw.indexOf("\n"+i+".",start);
|
||||
if(start<0) break;
|
||||
let end=start;
|
||||
let type="radio"
|
||||
for(let j=0;j<4;j++){
|
||||
let option=options[j];
|
||||
end=raw.indexOf(option+".",start);
|
||||
next=raw.indexOf("\n"+(i+1)+".",start);
|
||||
console.log("["+raw.substring(start,end)+"]");
|
||||
if ( end<0 || ( end > next && next > 0 )) {
|
||||
console.log("i:"+i+" j:"+option+" end:"+end+" next:"+next);
|
||||
end=start;
|
||||
break;
|
||||
}
|
||||
if(j==0&&raw.substring(start,end).indexOf("多选")>0) type="checkbox";
|
||||
let disp="<input type=\""+type+"\" name=\""+i+"\" value=\""+option+"\" />"+option+".";
|
||||
raw= raw.substring(0,end-1)+disp+raw.substring(end+2);
|
||||
start+=disp.length;
|
||||
}
|
||||
start=end+1;
|
||||
i++;
|
||||
}
|
||||
$(this).html(raw);
|
||||
});
|
||||
|
||||
$('span[class="md auto_select"]').each(function(){
|
||||
let i=1;
|
||||
let options=['A','B','C','D','E','F','G'];
|
||||
$(this).find("ul").each(function(){
|
||||
let type="radio";
|
||||
let ol=$(this).prev("ol");
|
||||
if(ol!=undefined && ol.attr("start")!=undefined) i=ol.attr("start");
|
||||
console.log("id["+i+"]");
|
||||
if($(this).html().indexOf("多选")>0|| (ol!=undefined && ol.html()!=undefined && ol.html().indexOf("multiselect")>0)) type="checkbox";
|
||||
let j=0;
|
||||
$(this).find("li").each(function(){
|
||||
let option=options[j];
|
||||
let disp="<input type=\""+type+"\" name=\""+i+"\" value=\""+option+"\" />"+option+".";
|
||||
$(this).prepend(disp);
|
||||
j++;
|
||||
});
|
||||
i++;
|
||||
});
|
||||
let html=$(this).html();
|
||||
for(;i>0;i--){
|
||||
console.log("searching..."+i);
|
||||
html=html.replace("{{ input("+i+") }}","<input type='text' size=5 name='"+i+"' placeholder='第"+i+"题' ><br>");
|
||||
}
|
||||
html=html.replaceAll("<","<");
|
||||
html=html.replaceAll(">",">");
|
||||
$(this).html(html);
|
||||
});
|
||||
|
||||
// subjective problems from hydroOJ markdown and embeded marks
|
||||
$('span[class="md auto_select"]').each(function(){
|
||||
let i=1;
|
||||
let options=['A','B','C','D','E','F','G'];
|
||||
$(this).find("ul").each(function(){
|
||||
let type="radio";
|
||||
let ol=$(this).prev("ol");
|
||||
if(ol!=undefined && ol.attr("start")!=undefined) i=ol.attr("start");
|
||||
console.log("id["+i+"]");
|
||||
if($(this).html().indexOf("多选")>0|| (ol!=undefined && ol.html()!=undefined && ol.html().indexOf("multiselect")>0)) type="checkbox";
|
||||
let j=0;
|
||||
$(this).find("li").each(function(){
|
||||
let option=options[j];
|
||||
let disp="<input type=\""+type+"\" name=\""+i+"\" value=\""+option+"\" />"+option+".";
|
||||
$(this).prepend(disp);
|
||||
//console.log(options[j]);
|
||||
j++;
|
||||
});
|
||||
i++;
|
||||
});
|
||||
let html=$(this).html();
|
||||
for(;i>0;i--){
|
||||
console.log("searching..."+i);
|
||||
html=html.replace("{{ input("+i+") }}","<input type='text' size=5 name='"+i+"' placeholder='第"+i+"题' ><br>");
|
||||
}
|
||||
html=html.replaceAll("<","<");
|
||||
html=html.replaceAll(">",">");
|
||||
$(this).html(html);
|
||||
$(".auto_select").find('input[type="text"]').change(function(){
|
||||
selectOne($(this).attr("name"),$(this).val());
|
||||
});
|
||||
|
||||
$('input[type="radio"]').click(function(){
|
||||
if ($(this).is(':checked'))
|
||||
selectOne($(this).attr("name"),$(this).val());
|
||||
}).css("width","24px").css("height","21px");
|
||||
$('input[type="checkbox"]').click(function(){
|
||||
let num=$(this).attr("name");
|
||||
let answer="";
|
||||
$("input[type=checkbox][name="+num+"]").each(function(){
|
||||
if ($(this).is(':checked'))
|
||||
answer+=$(this).val();
|
||||
});
|
||||
selectMulti(num,answer);
|
||||
}).css("width","24px").css("height","21px");
|
||||
<?php if ($row['spj']>1 || isset($_GET['sid']) || (isset($OJ_AUTO_SHOW_OFF)&&$OJ_AUTO_SHOW_OFF)){?>
|
||||
transform();
|
||||
<?php }?>
|
||||
}
|
||||
|
||||
window.renderProblemMarkdown = renderProblemMarkdown;
|
||||
|
||||
$(".auto_select").find('input[type="text"]').change(function(){
|
||||
selectOne($(this).attr("name"),$(this).val());
|
||||
});
|
||||
|
||||
|
||||
$('input[type="radio"]').click(function(){
|
||||
if ($(this).is(':checked'))
|
||||
selectOne($(this).attr("name"),$(this).val());
|
||||
}).css("width","24px").css("height","21px");
|
||||
$('input[type="checkbox"]').click(function(){
|
||||
let num=$(this).attr("name");
|
||||
let answer="";
|
||||
$("input[type=checkbox][name="+num+"]").each(function(){
|
||||
if ($(this).is(':checked'))
|
||||
answer+=$(this).val();
|
||||
});
|
||||
selectMulti(num,answer);
|
||||
}).css("width","24px").css("height","21px");
|
||||
<?php if ($row['spj']>1 || isset($_GET['sid']) || (isset($OJ_AUTO_SHOW_OFF)&&$OJ_AUTO_SHOW_OFF)){?>
|
||||
transform();
|
||||
<?php }?>
|
||||
renderProblemMarkdown().catch(function (error) {
|
||||
console.error('Failed to render problem markdown.', error);
|
||||
}).then(function () {
|
||||
initializeProblemChoices();
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php $show_title=$id." - $MSG_ERROR_INFO - $OJ_NAME"; ?>
|
||||
<?php include("template/$OJ_TEMPLATE/header.php");?>
|
||||
|
||||
<script src="<?php echo "template/bs3/"?>marked.min.js"></script>
|
||||
<script src="include/vditor-adapter.js"></script>
|
||||
<script src="template/<?php echo $OJ_TEMPLATE?>/js/textFit.min.js"></script>
|
||||
<style>
|
||||
.single-subtask {
|
||||
@@ -92,83 +92,78 @@
|
||||
</script>
|
||||
|
||||
<?php if(isset($OJ_MARKDOWN)&&$OJ_MARKDOWN){ ?>
|
||||
<script src="<?php echo $OJ_CDN_URL.$path_fix."template/bs3/"?>marked.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
marked.use({
|
||||
// 开启异步渲染
|
||||
async: true,
|
||||
pedantic: false,
|
||||
gfm: true,
|
||||
mangle: false,
|
||||
headerIds: false
|
||||
});
|
||||
$("#errtxt").each(function(){
|
||||
$(this).html(marked.parse($(this).html()));
|
||||
});
|
||||
// adding note for ```input1 ```output1 in description
|
||||
for(let i=1;i<10;i++){
|
||||
$(".language-input"+i).parent().before("<div><?php echo $MSG_Input?>"+i+":</div>");
|
||||
$(".language-output"+i).parent().before("<div><?php echo $MSG_Output?>"+i+":</div>");
|
||||
}
|
||||
HustOJVditor.renderMarkdownBlocks('#errtxt', {
|
||||
getSource: function (element) {
|
||||
var pre = element.querySelector ? element.querySelector('pre') : null;
|
||||
return pre ? pre.textContent : element.textContent || '';
|
||||
}
|
||||
}).then(function () {
|
||||
for(let i=1;i<10;i++){
|
||||
$(".language-input"+i).parent().before("<div><?php echo $MSG_Input?>"+i+":</div>");
|
||||
$(".language-output"+i).parent().before("<div><?php echo $MSG_Output?>"+i+":</div>");
|
||||
}
|
||||
|
||||
|
||||
$("#errtxt table").addClass("ui mini-table cell striped");
|
||||
$("#errtxt table tr:odd td").css({
|
||||
"border": "1px solid grey",
|
||||
"text-align": "center",
|
||||
"width": "200px",
|
||||
"background-color": "#8521d022",
|
||||
"height": "30px"
|
||||
});
|
||||
$("#errtxt table tr:even td").css({
|
||||
"border": "1px solid grey",
|
||||
"text-align": "center",
|
||||
"width": "200px",
|
||||
"background-color": "#2185d022",
|
||||
"height": "30px"
|
||||
});
|
||||
$("#errtxt table th").css({
|
||||
"border": "1px solid grey",
|
||||
"width": "200px",
|
||||
"height": "30px",
|
||||
"background-color": "#2185d088",
|
||||
"text-align": "center"
|
||||
});
|
||||
<?php
|
||||
if(isset($OJ_DOWNLOAD)&&$OJ_DOWNLOAD){
|
||||
if(isset($OJ_DL_1ST_WA_ONLY) && $OJ_DL_1ST_WA_ONLY){
|
||||
?>
|
||||
let down=$($("#errtxt").find("h2")[0]);
|
||||
let filename=down.text();
|
||||
down.html("<a href='download.php?sid=<?php echo $id?>&name=" + filename+ "'>" + filename+ "</a>");
|
||||
<?php
|
||||
}else{
|
||||
?>
|
||||
$("#errtxt").find("h2").each(function(){
|
||||
let down=$(this);
|
||||
let filename=down.text();
|
||||
console.log(filename);
|
||||
down.html("<a href='download.php?sid=<?php echo $id?>&name=" + filename+ "'>" + filename+ "</a>");
|
||||
});
|
||||
$("#errtxt table").addClass("ui mini-table cell striped");
|
||||
$("#errtxt table tr:odd td").css({
|
||||
"border": "1px solid grey",
|
||||
"text-align": "center",
|
||||
"width": "200px",
|
||||
"background-color": "#8521d022",
|
||||
"height": "30px"
|
||||
});
|
||||
$("#errtxt table tr:even td").css({
|
||||
"border": "1px solid grey",
|
||||
"text-align": "center",
|
||||
"width": "200px",
|
||||
"background-color": "#2185d022",
|
||||
"height": "30px"
|
||||
});
|
||||
$("#errtxt table th").css({
|
||||
"border": "1px solid grey",
|
||||
"width": "200px",
|
||||
"height": "30px",
|
||||
"background-color": "#2185d088",
|
||||
"text-align": "center"
|
||||
});
|
||||
<?php
|
||||
if(isset($OJ_DOWNLOAD)&&$OJ_DOWNLOAD){
|
||||
if(isset($OJ_DL_1ST_WA_ONLY) && $OJ_DL_1ST_WA_ONLY){
|
||||
?>
|
||||
let down=$($("#errtxt").find("h2")[0]);
|
||||
let filename=down.text();
|
||||
down.html("<a href='download.php?sid=<?php echo $id?>&name=" + filename+ "'>" + filename+ "</a>");
|
||||
<?php
|
||||
}else{
|
||||
?>
|
||||
$("#errtxt").find("h2").each(function(){
|
||||
let down=$(this);
|
||||
let filename=down.text();
|
||||
console.log(filename);
|
||||
down.html("<a href='download.php?sid=<?php echo $id?>&name=" + filename+ "'>" + filename+ "</a>");
|
||||
});
|
||||
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
$("th").each(function(){
|
||||
let html=$(this).html();
|
||||
html=html.replace("Expected","<?php echo $MSG_EXPECTED ?>");
|
||||
html=html.replace("Yours","<?php echo $MSG_YOURS ?>");
|
||||
html=html.replace("filename","<?php echo $MSG_FILENAME ?>");
|
||||
html=html.replace("size","<?php echo $MSG_SIZE ?>");
|
||||
html=html.replace("result","<?php echo $MSG_RESULT ?>");
|
||||
html=html.replace("memory","<?php echo $MSG_MEMORY?>");
|
||||
html=html.replace("time","<?php echo $MSG_TIME ?>");
|
||||
$(this).html(html);
|
||||
|
||||
});
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
$("th").each(function(){
|
||||
let html=$(this).html();
|
||||
html=html.replace("Expected","<?php echo $MSG_EXPECTED ?>");
|
||||
html=html.replace("Yours","<?php echo $MSG_YOURS ?>");
|
||||
html=html.replace("filename","<?php echo $MSG_FILENAME ?>");
|
||||
html=html.replace("size","<?php echo $MSG_SIZE ?>");
|
||||
html=html.replace("result","<?php echo $MSG_RESULT ?>");
|
||||
html=html.replace("memory","<?php echo $MSG_MEMORY?>");
|
||||
html=html.replace("time","<?php echo $MSG_TIME ?>");
|
||||
$(this).html(html);
|
||||
|
||||
});
|
||||
}).catch(function (error) {
|
||||
console.error('Failed to render reinfo markdown.', error);
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
@@ -423,19 +423,19 @@ function loadFromBlockly(){
|
||||
}
|
||||
?>
|
||||
<?php if($OJ_ACE_EDITOR){ ?>
|
||||
<script src="<?php echo $OJ_CDN_URL?>ace/ace.js"></script>
|
||||
<script src="<?php echo $OJ_CDN_URL?>ace/ext-language_tools.js"></script>
|
||||
<script src="include/vditor-adapter.js"></script>
|
||||
<script>
|
||||
ace.require("ace/ext/language_tools");
|
||||
var editor = ace.edit("source");
|
||||
editor.setTheme("ace/theme/xcode");
|
||||
var editor = HustOJVditor.createDeferredCodeEditor({
|
||||
container: "source",
|
||||
hiddenField: "hide_source",
|
||||
theme: "ace/theme/xcode",
|
||||
fontSize: 18
|
||||
});
|
||||
switchLang(<?php echo $lastlang ?>);
|
||||
editor.setOptions({
|
||||
enableBasicAutocompletion: true,
|
||||
enableSnippets: true,
|
||||
enableLiveAutocompletion: true, //改为true,打开自动补齐功能,改为false关闭
|
||||
// fontFamily: "Consolas", // MacOS missing align
|
||||
// theme: "ace/theme/ambiance", // Black theme
|
||||
enableLiveAutocompletion: true,
|
||||
fontSize: "18px"
|
||||
});
|
||||
reloadtemplate($("#language").val());
|
||||
|
||||
@@ -77,83 +77,79 @@
|
||||
</script>
|
||||
|
||||
<?php if(isset($OJ_MARKDOWN)&&$OJ_MARKDOWN){ ?>
|
||||
<script src="<?php echo $OJ_CDN_URL.$path_fix."template/bs3/"?>marked.min.js"></script>
|
||||
<script src="include/vditor-adapter.js"></script>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
marked.use({
|
||||
// 开启异步渲染
|
||||
async: true,
|
||||
pedantic: false,
|
||||
gfm: true,
|
||||
mangle: false,
|
||||
headerIds: false
|
||||
});
|
||||
$("#errtxt").each(function(){
|
||||
$(this).html(marked.parse($(this).html()));
|
||||
});
|
||||
// adding note for ```input1 ```output1 in description
|
||||
for(let i=1;i<10;i++){
|
||||
$(".language-input"+i).parent().before("<div><?php echo $MSG_Input?>"+i+":</div>");
|
||||
$(".language-output"+i).parent().before("<div><?php echo $MSG_Output?>"+i+":</div>");
|
||||
}
|
||||
|
||||
|
||||
$("#errtxt table").addClass("ui mini-table cell striped");
|
||||
$("#errtxt table tr:odd td").css({
|
||||
"border": "1px solid grey",
|
||||
"text-align": "center",
|
||||
"width": "200px",
|
||||
"background-color": "#8521d022",
|
||||
"height": "30px"
|
||||
});
|
||||
$("#errtxt table tr:even td").css({
|
||||
"border": "1px solid grey",
|
||||
"text-align": "center",
|
||||
"width": "200px",
|
||||
"background-color": "#2185d022",
|
||||
"height": "30px"
|
||||
});
|
||||
$("#errtxt table th").css({
|
||||
"border": "1px solid grey",
|
||||
"width": "200px",
|
||||
"height": "30px",
|
||||
"background-color": "#2185d088",
|
||||
"text-align": "center"
|
||||
});
|
||||
<?php
|
||||
if(isset($OJ_DOWNLOAD)&&$OJ_DOWNLOAD){
|
||||
if(isset($OJ_DL_1ST_WA_ONLY) && $OJ_DL_1ST_WA_ONLY){
|
||||
?>
|
||||
let down=$($("#errtxt").find("h2")[0]);
|
||||
let filename=down.text();
|
||||
down.html("<a href='download.php?sid=<?php echo $id?>&name=" + filename+ "'>" + filename+ "</a>");
|
||||
<?php
|
||||
}else{
|
||||
?>
|
||||
$("#errtxt").find("h2").each(function(){
|
||||
let down=$(this);
|
||||
let filename=down.text();
|
||||
console.log(filename);
|
||||
down.html("<a href='download.php?sid=<?php echo $id?>&name=" + filename+ "'>" + filename+ "</a>");
|
||||
});
|
||||
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
$("th").each(function(){
|
||||
let html=$(this).html();
|
||||
html=html.replace("Expected","<?php echo $MSG_EXPECTED ?>");
|
||||
html=html.replace("Yours","<?php echo $MSG_YOURS ?>");
|
||||
html=html.replace("filename","<?php echo $MSG_FILENAME ?>");
|
||||
html=html.replace("size","<?php echo $MSG_SIZE ?>");
|
||||
html=html.replace("result","<?php echo $MSG_RESULT ?>");
|
||||
html=html.replace("memory","<?php echo $MSG_MEMORY?>");
|
||||
html=html.replace("time","<?php echo $MSG_TIME ?>");
|
||||
$(this).html(html);
|
||||
|
||||
});
|
||||
|
||||
HustOJVditor.renderMarkdownBlocks('#errtxt', {
|
||||
getSource: function (element) {
|
||||
var pre = element.querySelector ? element.querySelector('pre') : null;
|
||||
return pre ? pre.textContent : element.textContent || '';
|
||||
}
|
||||
}).then(function () {
|
||||
for(let i=1;i<10;i++){
|
||||
$(".language-input"+i).parent().before("<div><?php echo $MSG_Input?>"+i+":</div>");
|
||||
$(".language-output"+i).parent().before("<div><?php echo $MSG_Output?>"+i+":</div>");
|
||||
}
|
||||
|
||||
|
||||
$("#errtxt table").addClass("ui mini-table cell striped");
|
||||
$("#errtxt table tr:odd td").css({
|
||||
"border": "1px solid grey",
|
||||
"text-align": "center",
|
||||
"width": "200px",
|
||||
"background-color": "#8521d022",
|
||||
"height": "30px"
|
||||
});
|
||||
$("#errtxt table tr:even td").css({
|
||||
"border": "1px solid grey",
|
||||
"text-align": "center",
|
||||
"width": "200px",
|
||||
"background-color": "#2185d022",
|
||||
"height": "30px"
|
||||
});
|
||||
$("#errtxt table th").css({
|
||||
"border": "1px solid grey",
|
||||
"width": "200px",
|
||||
"height": "30px",
|
||||
"background-color": "#2185d088",
|
||||
"text-align": "center"
|
||||
});
|
||||
<?php
|
||||
if(isset($OJ_DOWNLOAD)&&$OJ_DOWNLOAD){
|
||||
if(isset($OJ_DL_1ST_WA_ONLY) && $OJ_DL_1ST_WA_ONLY){
|
||||
?>
|
||||
let down=$($("#errtxt").find("h2")[0]);
|
||||
let filename=down.text();
|
||||
down.html("<a href='download.php?sid=<?php echo $id?>&name=" + filename+ "'>" + filename+ "</a>");
|
||||
<?php
|
||||
}else{
|
||||
?>
|
||||
$("#errtxt").find("h2").each(function(){
|
||||
let down=$(this);
|
||||
let filename=down.text();
|
||||
console.log(filename);
|
||||
down.html("<a href='download.php?sid=<?php echo $id?>&name=" + filename+ "'>" + filename+ "</a>");
|
||||
});
|
||||
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
$("th").each(function(){
|
||||
let html=$(this).html();
|
||||
html=html.replace("Expected","<?php echo $MSG_EXPECTED ?>");
|
||||
html=html.replace("Yours","<?php echo $MSG_YOURS ?>");
|
||||
html=html.replace("filename","<?php echo $MSG_FILENAME ?>");
|
||||
html=html.replace("size","<?php echo $MSG_SIZE ?>");
|
||||
html=html.replace("result","<?php echo $MSG_RESULT ?>");
|
||||
html=html.replace("memory","<?php echo $MSG_MEMORY?>");
|
||||
html=html.replace("time","<?php echo $MSG_TIME ?>");
|
||||
$(this).html(html);
|
||||
|
||||
});
|
||||
}).catch(function (error) {
|
||||
console.error('Failed to render reinfo markdown.', error);
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
@@ -328,20 +328,22 @@ function loadFromBlockly(){
|
||||
</script>
|
||||
<script language="Javascript" type="text/javascript" src="include/base64.js"></script>
|
||||
<?php if($OJ_ACE_EDITOR){ ?>
|
||||
<script src="ace/ace.js"></script>
|
||||
<script src="ace/ext-language_tools.js"></script>
|
||||
<script src="include/vditor-adapter.js"></script>
|
||||
<script>
|
||||
ace.require("ace/ext/language_tools");
|
||||
var editor = ace.edit("source");
|
||||
editor.setTheme("ace/theme/chrome");
|
||||
switchLang(<?php echo $lastlang ?>);
|
||||
editor.setOptions({
|
||||
var editor = HustOJVditor.createDeferredCodeEditor({
|
||||
container: "source",
|
||||
hiddenField: "hide_source",
|
||||
theme: "ace/theme/chrome",
|
||||
fontSize: 20
|
||||
});
|
||||
switchLang(<?php echo $lastlang ?>);
|
||||
editor.setOptions({
|
||||
enableBasicAutocompletion: true,
|
||||
enableSnippets: true,
|
||||
enableLiveAutocompletion: false,
|
||||
fontFamily: "Consolas",
|
||||
fontSize: "20px"
|
||||
});
|
||||
enableSnippets: true,
|
||||
enableLiveAutocompletion: false,
|
||||
fontFamily: "Consolas",
|
||||
fontSize: "20px"
|
||||
});
|
||||
reloadtemplate($("#language").val());
|
||||
|
||||
</script>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
?>
|
||||
<?php include("template/$OJ_TEMPLATE/header.php");?>
|
||||
<?php include("include/bbcode.php");?>
|
||||
<script src="<?php echo "template/bs3/"?>marked.min.js"></script>
|
||||
<script src="include/vditor-adapter.js"></script>
|
||||
<div class="padding">
|
||||
<h1><?php echo $news_title ?></h1>
|
||||
<div class="ui existing segment">
|
||||
@@ -15,37 +15,47 @@
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
marked.use({
|
||||
// 开启异步渲染
|
||||
async: true,
|
||||
pedantic: false,
|
||||
gfm: true,
|
||||
mangle: false,
|
||||
headerIds: false
|
||||
});
|
||||
$(".md").each(function(){
|
||||
$(this).html(marked.parse($(this).text()));
|
||||
});
|
||||
// adding note for ```input1 ```output1 in description
|
||||
for(let i=1;i<10;i++){
|
||||
$(".language-input"+i).parent().before("<div><?php echo $MSG_Input?>"+i+":</div>");
|
||||
$(".language-output"+i).parent().before("<div><?php echo $MSG_Output?>"+i+":</div>");
|
||||
}
|
||||
$(".md table tr td").css({
|
||||
"border": "1px solid grey",
|
||||
"text-align": "center",
|
||||
"width": "200px",
|
||||
"height": "30px"
|
||||
});
|
||||
function addMarkdownInputOutputLabels() {
|
||||
for(let i=1;i<10;i++){
|
||||
$(".language-input"+i).parent().each(function(){
|
||||
if ($(this).prev('.hustoj-md-io-label').length === 0) {
|
||||
$(this).before("<div class='hustoj-md-io-label'><?php echo $MSG_Input?>"+i+":</div>");
|
||||
}
|
||||
});
|
||||
$(".language-output"+i).parent().each(function(){
|
||||
if ($(this).prev('.hustoj-md-io-label').length === 0) {
|
||||
$(this).before("<div class='hustoj-md-io-label'><?php echo $MSG_Output?>"+i+":</div>");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
$(".md table th").css({
|
||||
"border": "1px solid grey",
|
||||
"width": "200px",
|
||||
"height": "30px",
|
||||
"background-color": "#9e9e9ea1",
|
||||
"text-align": "center"
|
||||
});
|
||||
function styleMarkdownTables() {
|
||||
$(".md table tr td").css({
|
||||
"border": "1px solid grey",
|
||||
"text-align": "center",
|
||||
"width": "200px",
|
||||
"height": "30px"
|
||||
});
|
||||
|
||||
$(".md table th").css({
|
||||
"border": "1px solid grey",
|
||||
"width": "200px",
|
||||
"height": "30px",
|
||||
"background-color": "#9e9e9ea1",
|
||||
"text-align": "center"
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
HustOJVditor.renderMarkdownBlocks('.md', {
|
||||
useTextContent: true
|
||||
}).then(function () {
|
||||
addMarkdownInputOutputLabels();
|
||||
styleMarkdownTables();
|
||||
}).catch(function (error) {
|
||||
console.error('Failed to render discuss markdown.', error);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php include("template/$OJ_TEMPLATE/footer.php");?>
|
||||
|
||||
2
web/template/syzoj/js/markdown-it.min.js
vendored
2
web/template/syzoj/js/markdown-it.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -58,8 +58,7 @@ if ($pr_flag) {
|
||||
}
|
||||
</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/bs3/" ?>marked.min.js"></script>
|
||||
<script src="<?php echo $OJ_CDN_URL . $path_fix . "template/syzoj/js/" ?>markdown-it.min.js"></script>
|
||||
<script src="include/vditor-adapter.js"></script>
|
||||
|
||||
<div class="padding ">
|
||||
<div class="ui center aligned grid">
|
||||
@@ -505,21 +504,34 @@ if ($pr_flag) {
|
||||
}
|
||||
});
|
||||
}
|
||||
function getFrameSourceValue(frameWindow) {
|
||||
if (frameWindow.editor && typeof frameWindow.editor.getValue === 'function') {
|
||||
return frameWindow.editor.getValue();
|
||||
}
|
||||
return frameWindow.$("#source").text();
|
||||
}
|
||||
function setFrameSourceValue(frameWindow, value) {
|
||||
if (frameWindow.editor && typeof frameWindow.editor.setValue === 'function') {
|
||||
frameWindow.editor.setValue(value);
|
||||
return;
|
||||
}
|
||||
frameWindow.$("#source").text(value);
|
||||
}
|
||||
function selectOne(num, answer) {
|
||||
let editor = $("iframe")[0].contentWindow.$("#source");
|
||||
let old = editor.text();
|
||||
let frameWindow = $("iframe")[0].contentWindow;
|
||||
let old = getFrameSourceValue(frameWindow);
|
||||
let key = num + ".*";
|
||||
console.log(key);
|
||||
let rep = old.replace(new RegExp(key), num + " " + answer);
|
||||
editor.text(rep);
|
||||
setFrameSourceValue(frameWindow, rep);
|
||||
}
|
||||
function selectMulti(num, answer) {
|
||||
let editor = $("iframe")[0].contentWindow.$("#source");
|
||||
let old = editor.text();
|
||||
let frameWindow = $("iframe")[0].contentWindow;
|
||||
let old = getFrameSourceValue(frameWindow);
|
||||
let key = num + ".*";
|
||||
console.log(key);
|
||||
let rep = old.replace(new RegExp(key), num + " " + answer);
|
||||
editor.text(rep);
|
||||
setFrameSourceValue(frameWindow, rep);
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
@@ -574,47 +586,22 @@ if ($pr_flag) {
|
||||
});
|
||||
}
|
||||
|
||||
<?php if (isset($OJ_MARKDOWN) && $OJ_MARKDOWN) { ?>
|
||||
marked.use({
|
||||
// 开启异步渲染
|
||||
async: true,
|
||||
pedantic: false,
|
||||
gfm: true,
|
||||
mangle: false,
|
||||
headerIds: false
|
||||
});
|
||||
|
||||
// Helper function to decode HTML entities from Markdown source
|
||||
function decodeHtmlEntities(text) {
|
||||
var textArea = document.createElement('textarea');
|
||||
textArea.innerHTML = text;
|
||||
return textArea.value;
|
||||
}
|
||||
|
||||
$(".md").each(function () {
|
||||
let raw_markdown_source = $(this).html();
|
||||
let decoded_markdown_source = decodeHtmlEntities(raw_markdown_source);
|
||||
|
||||
<?php if ( $OJ_MARKDOWN == "marked.js") { ?>
|
||||
let markdown_content = marked.parse(decoded_markdown_source);
|
||||
<?php } else if ($OJ_MARKDOWN == "markdown-it") { ?>
|
||||
const md = window.markdownit();
|
||||
md.set({
|
||||
html: true,
|
||||
linkify: true,
|
||||
typographer: true,
|
||||
});
|
||||
let markdown_content = md.render(decoded_markdown_source);
|
||||
<?php } ?>
|
||||
$(this).html(markdown_content);
|
||||
});
|
||||
// adding note for ```input1 ```output1 in description
|
||||
function addMarkdownInputOutputLabels() {
|
||||
for (let i = 1; i < 10; i++) {
|
||||
$(".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-input" + i).parent().each(function () {
|
||||
if ($(this).prev('.hustoj-md-io-label').length === 0) {
|
||||
$(this).before("<div class='hustoj-md-io-label'><?php echo $MSG_Input ?>" + i + ":</div>");
|
||||
}
|
||||
});
|
||||
$(".language-output" + i).parent().each(function () {
|
||||
if ($(this).prev('.hustoj-md-io-label').length === 0) {
|
||||
$(this).before("<div class='hustoj-md-io-label'><?php echo $MSG_Output ?>" + i + ":</div>");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function styleMarkdownTables() {
|
||||
$(".md table tr td").css({
|
||||
"border": "1px solid grey",
|
||||
"text-align": "center",
|
||||
@@ -629,98 +616,110 @@ if ($pr_flag) {
|
||||
"background-color": "#9e9e9ea1",
|
||||
"text-align": "center"
|
||||
});
|
||||
}
|
||||
|
||||
initMarkdownCodeCopy();
|
||||
|
||||
function renderProblemMarkdown() {
|
||||
<?php if (isset($OJ_MARKDOWN) && $OJ_MARKDOWN) { ?>
|
||||
return HustOJVditor.renderMarkdownBlocks('.md').then(function () {
|
||||
addMarkdownInputOutputLabels();
|
||||
styleMarkdownTables();
|
||||
initMarkdownCodeCopy();
|
||||
});
|
||||
<?php } ?>
|
||||
//单纯文本1. A. B. C. D. 自动变控件
|
||||
$('span[class=auto_select]').each(function () {
|
||||
let i = 1;
|
||||
let start = 0;
|
||||
let next = 0;
|
||||
let raw = $(this).html();
|
||||
let options = ['A', 'B', 'C', 'D'];
|
||||
console.log("scanning...");
|
||||
while (start >= 0) {
|
||||
start = raw.indexOf("\n" + i + ".", start);
|
||||
if (start < 0) break;
|
||||
let end = start;
|
||||
let type = "radio"
|
||||
for (let j = 0; j < 4; j++) {
|
||||
let option = options[j];
|
||||
end = raw.indexOf(option + ".", start);
|
||||
next = raw.indexOf("\n" + (i + 1) + ".", start);
|
||||
console.log("[" + raw.substring(start, end) + "]");
|
||||
if (end < 0 || (end > next && next > 0)) {
|
||||
console.log("i:" + i + " j:" + option + " end:" + end + " next:" + next);
|
||||
end = start;
|
||||
break;
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
|
||||
function initializeProblemChoices() {
|
||||
$('span[class=auto_select]').each(function () {
|
||||
let i = 1;
|
||||
let start = 0;
|
||||
let next = 0;
|
||||
let raw = $(this).html();
|
||||
let options = ['A', 'B', 'C', 'D'];
|
||||
console.log("scanning...");
|
||||
while (start >= 0) {
|
||||
start = raw.indexOf("\n" + i + ".", start);
|
||||
if (start < 0) break;
|
||||
let end = start;
|
||||
let type = "radio"
|
||||
for (let j = 0; j < 4; j++) {
|
||||
let option = options[j];
|
||||
end = raw.indexOf(option + ".", start);
|
||||
next = raw.indexOf("\n" + (i + 1) + ".", start);
|
||||
console.log("[" + raw.substring(start, end) + "]");
|
||||
if (end < 0 || (end > next && next > 0)) {
|
||||
console.log("i:" + i + " j:" + option + " end:" + end + " next:" + next);
|
||||
end = start;
|
||||
break;
|
||||
}
|
||||
if (j == 0 && raw.substring(start, end).indexOf("多选") > 0) type = "checkbox";
|
||||
let disp = "<input type=\"" + type + "\" name=\"" + i + "\" value=\"" + option + "\" />" + option + ".";
|
||||
raw = raw.substring(0, end - 1) + disp + raw.substring(end + 2);
|
||||
start += disp.length;
|
||||
}
|
||||
if (j == 0 && raw.substring(start, end).indexOf("多选") > 0) type = "checkbox";
|
||||
let disp = "<input type=\"" + type + "\" name=\"" + i + "\" value=\"" + option + "\" />" + option + ".";
|
||||
//console.log(disp);
|
||||
raw = raw.substring(0, end - 1) + disp + raw.substring(end + 2);
|
||||
start += disp.length;
|
||||
start = end + 1;
|
||||
i++;
|
||||
}
|
||||
start = end + 1;
|
||||
i++;
|
||||
}
|
||||
//console.log(raw);
|
||||
$(this).html(raw);
|
||||
});
|
||||
$(this).html(raw);
|
||||
});
|
||||
|
||||
// subjective problems from hydroOJ markdown and embeded marks
|
||||
$('span[class="md auto_select"]').each(function () {
|
||||
let i = 1;
|
||||
let options = ['A', 'B', 'C', 'D', 'E', 'F', 'G'];
|
||||
$(this).find("ul").each(function () {
|
||||
let type = "radio";
|
||||
let ol = $(this).prev("ol");
|
||||
if (ol != undefined && ol.attr("start") != undefined) i = ol.attr("start");
|
||||
console.log("id[" + i + "]");
|
||||
if ($(this).html().indexOf("多选") > 0 || (ol != undefined && ol.html() != undefined && ol.html().indexOf("multiselect") > 0)) type = "checkbox";
|
||||
let j = 0;
|
||||
$(this).find("li").each(function () {
|
||||
let option = options[j];
|
||||
let disp = "<input type=\"" + type + "\" name=\"" + i + "\" value=\"" + option + "\" />" + option + ".";
|
||||
$(this).prepend(disp);
|
||||
//console.log(options[j]);
|
||||
j++;
|
||||
$('span[class="md auto_select"]').each(function () {
|
||||
let i = 1;
|
||||
let options = ['A', 'B', 'C', 'D', 'E', 'F', 'G'];
|
||||
$(this).find("ul").each(function () {
|
||||
let type = "radio";
|
||||
let ol = $(this).prev("ol");
|
||||
if (ol != undefined && ol.attr("start") != undefined) i = ol.attr("start");
|
||||
console.log("id[" + i + "]");
|
||||
if ($(this).html().indexOf("多选") > 0 || (ol != undefined && ol.html() != undefined && ol.html().indexOf("multiselect") > 0)) type = "checkbox";
|
||||
let j = 0;
|
||||
$(this).find("li").each(function () {
|
||||
let option = options[j];
|
||||
let disp = "<input type=\"" + type + "\" name=\"" + i + "\" value=\"" + option + "\" />" + option + ".";
|
||||
$(this).prepend(disp);
|
||||
j++;
|
||||
});
|
||||
i++;
|
||||
});
|
||||
i++;
|
||||
let html = $(this).html();
|
||||
for (; i > 0; i--) {
|
||||
console.log("searching..." + i);
|
||||
html = html.replace("{{ input(" + i + ") }}", "<input type='text' size=5 name='" + i + "' placeholder='第" + i + "题' ><br>");
|
||||
}
|
||||
html = html.replaceAll("<", "<");
|
||||
html = html.replaceAll(">", ">");
|
||||
$(this).html(html);
|
||||
});
|
||||
let html = $(this).html();
|
||||
for (; i > 0; i--) {
|
||||
console.log("searching..." + i);
|
||||
html = html.replace("{{ input(" + i + ") }}", "<input type='text' size=5 name='" + i + "' placeholder='第" + i + "题' ><br>");
|
||||
}
|
||||
html = html.replaceAll("<", "<");
|
||||
html = html.replaceAll(">", ">");
|
||||
$(this).html(html);
|
||||
});
|
||||
|
||||
|
||||
$(".auto_select").find('input[type="text"]').change(function () {
|
||||
selectOne($(this).attr("name"), $(this).val());
|
||||
});
|
||||
|
||||
|
||||
$('input[type="radio"]').click(function () {
|
||||
if ($(this).is(':checked'))
|
||||
$(".auto_select").find('input[type="text"]').change(function () {
|
||||
selectOne($(this).attr("name"), $(this).val());
|
||||
}).css("width", "24px").css("height", "21px");
|
||||
$('input[type="checkbox"]').click(function () {
|
||||
let num = $(this).attr("name");
|
||||
let answer = "";
|
||||
$("input[type=checkbox][name=" + num + "]").each(function () {
|
||||
if ($(this).is(':checked'))
|
||||
answer += $(this).val();
|
||||
});
|
||||
selectMulti(num, answer);
|
||||
}).css("width", "24px").css("height", "21px");
|
||||
|
||||
$('input[type="radio"]').click(function () {
|
||||
if ($(this).is(':checked'))
|
||||
selectOne($(this).attr("name"), $(this).val());
|
||||
}).css("width", "24px").css("height", "21px");
|
||||
$('input[type="checkbox"]').click(function () {
|
||||
let num = $(this).attr("name");
|
||||
let answer = "";
|
||||
$("input[type=checkbox][name=" + num + "]").each(function () {
|
||||
if ($(this).is(':checked'))
|
||||
answer += $(this).val();
|
||||
});
|
||||
selectMulti(num, answer);
|
||||
}).css("width", "24px").css("height", "21px");
|
||||
<?php if ($row['spj'] > 1 || isset($_GET['sid']) || (isset($OJ_AUTO_SHOW_OFF) && $OJ_AUTO_SHOW_OFF)) { ?>
|
||||
transform();
|
||||
<?php } ?>
|
||||
}
|
||||
|
||||
window.renderProblemMarkdown = renderProblemMarkdown;
|
||||
|
||||
renderProblemMarkdown().catch(function (error) {
|
||||
console.error('Failed to render problem markdown.', error);
|
||||
}).then(function () {
|
||||
initializeProblemChoices();
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php $show_title=$id." - $MSG_ERROR_INFO - $OJ_NAME"; ?>
|
||||
<?php include("template/$OJ_TEMPLATE/header.php");?>
|
||||
|
||||
<script src="<?php echo "template/bs3/"?>marked.min.js"></script>
|
||||
<script src="include/vditor-adapter.js"></script>
|
||||
<script src="template/<?php echo $OJ_TEMPLATE?>/js/textFit.min.js"></script>
|
||||
<style>
|
||||
.single-subtask {
|
||||
@@ -98,82 +98,78 @@
|
||||
</script>
|
||||
|
||||
<?php if(isset($OJ_MARKDOWN)&&$OJ_MARKDOWN){ ?>
|
||||
<script src="<?php echo $OJ_CDN_URL.$path_fix."template/bs3/"?>marked.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
marked.use({
|
||||
// 开启异步渲染
|
||||
async: true,
|
||||
pedantic: false,
|
||||
gfm: true,
|
||||
mangle: false,
|
||||
headerIds: false
|
||||
});
|
||||
$("#errtxt").each(function(){
|
||||
// $(this).html(marked.parse($(this).html()));
|
||||
});
|
||||
// adding note for ```input1 ```output1 in description
|
||||
for(let i=1;i<10;i++){
|
||||
$(".language-input"+i).parent().before("<div><?php echo $MSG_Input?>"+i+":</div>");
|
||||
$(".language-output"+i).parent().before("<div><?php echo $MSG_Output?>"+i+":</div>");
|
||||
}
|
||||
|
||||
|
||||
$("#errtxt table").addClass("ui mini-table cell striped");
|
||||
$("#errtxt table tr:odd td").css({
|
||||
"border": "1px solid grey",
|
||||
"text-align": "center",
|
||||
"width": "200px",
|
||||
"background-color": "#8521d022",
|
||||
"height": "30px"
|
||||
});
|
||||
$("#errtxt table tr:even td").css({
|
||||
"border": "1px solid grey",
|
||||
"text-align": "center",
|
||||
"width": "200px",
|
||||
"background-color": "#2185d022",
|
||||
"height": "30px"
|
||||
});
|
||||
$("#errtxt table th").css({
|
||||
"border": "1px solid grey",
|
||||
"width": "200px",
|
||||
"height": "30px",
|
||||
"background-color": "#2185d088",
|
||||
"text-align": "center"
|
||||
});
|
||||
<?php
|
||||
if(isset($OJ_DOWNLOAD)&&$OJ_DOWNLOAD){
|
||||
if(isset($OJ_DL_1ST_WA_ONLY) && $OJ_DL_1ST_WA_ONLY){
|
||||
?>
|
||||
let down=$($("#errtxt").find("h2")[0]);
|
||||
let filename=down.text();
|
||||
down.html("<a href='download.php?sid=<?php echo $id?>&name=" + filename+ "'>" + filename+ "</a>");
|
||||
<?php
|
||||
}else{
|
||||
?>
|
||||
$("#errtxt").find("h2").each(function(){
|
||||
let down=$(this);
|
||||
let filename=down.text();
|
||||
console.log(filename);
|
||||
down.html("<a href='download.php?sid=<?php echo $id?>&name=" + filename+ "'>" + filename+ "</a>");
|
||||
});
|
||||
|
||||
<?php
|
||||
HustOJVditor.renderMarkdownBlocks('#errtxt', {
|
||||
getSource: function (element) {
|
||||
var pre = element.querySelector ? element.querySelector('pre') : null;
|
||||
return pre ? pre.textContent : element.textContent || '';
|
||||
}
|
||||
}).then(function () {
|
||||
for(let i=1;i<10;i++){
|
||||
$(".language-input"+i).parent().before("<div><?php echo $MSG_Input?>"+i+":</div>");
|
||||
$(".language-output"+i).parent().before("<div><?php echo $MSG_Output?>"+i+":</div>");
|
||||
}
|
||||
}
|
||||
?>
|
||||
$("th").each(function(){
|
||||
let html=$(this).html();
|
||||
html=html.replace("Expected","<?php echo $MSG_EXPECTED ?>");
|
||||
html=html.replace("Yours","<?php echo $MSG_YOURS ?>");
|
||||
html=html.replace("filename","<?php echo $MSG_FILENAME ?>");
|
||||
html=html.replace("size","<?php echo $MSG_SIZE ?>");
|
||||
html=html.replace("result","<?php echo $MSG_RESULT ?>");
|
||||
html=html.replace("memory","<?php echo $MSG_MEMORY?>");
|
||||
html=html.replace("time","<?php echo $MSG_TIME ?>");
|
||||
$(this).html(html);
|
||||
|
||||
});
|
||||
|
||||
$("#errtxt table").addClass("ui mini-table cell striped");
|
||||
$("#errtxt table tr:odd td").css({
|
||||
"border": "1px solid grey",
|
||||
"text-align": "center",
|
||||
"width": "200px",
|
||||
"background-color": "#8521d022",
|
||||
"height": "30px"
|
||||
});
|
||||
$("#errtxt table tr:even td").css({
|
||||
"border": "1px solid grey",
|
||||
"text-align": "center",
|
||||
"width": "200px",
|
||||
"background-color": "#2185d022",
|
||||
"height": "30px"
|
||||
});
|
||||
$("#errtxt table th").css({
|
||||
"border": "1px solid grey",
|
||||
"width": "200px",
|
||||
"height": "30px",
|
||||
"background-color": "#2185d088",
|
||||
"text-align": "center"
|
||||
});
|
||||
<?php
|
||||
if(isset($OJ_DOWNLOAD)&&$OJ_DOWNLOAD){
|
||||
if(isset($OJ_DL_1ST_WA_ONLY) && $OJ_DL_1ST_WA_ONLY){
|
||||
?>
|
||||
let down=$($("#errtxt").find("h2")[0]);
|
||||
let filename=down.text();
|
||||
down.html("<a href='download.php?sid=<?php echo $id?>&name=" + filename+ "'>" + filename+ "</a>");
|
||||
<?php
|
||||
}else{
|
||||
?>
|
||||
$("#errtxt").find("h2").each(function(){
|
||||
let down=$(this);
|
||||
let filename=down.text();
|
||||
console.log(filename);
|
||||
down.html("<a href='download.php?sid=<?php echo $id?>&name=" + filename+ "'>" + filename+ "</a>");
|
||||
});
|
||||
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
$("th").each(function(){
|
||||
let html=$(this).html();
|
||||
html=html.replace("Expected","<?php echo $MSG_EXPECTED ?>");
|
||||
html=html.replace("Yours","<?php echo $MSG_YOURS ?>");
|
||||
html=html.replace("filename","<?php echo $MSG_FILENAME ?>");
|
||||
html=html.replace("size","<?php echo $MSG_SIZE ?>");
|
||||
html=html.replace("result","<?php echo $MSG_RESULT ?>");
|
||||
html=html.replace("memory","<?php echo $MSG_MEMORY?>");
|
||||
html=html.replace("time","<?php echo $MSG_TIME ?>");
|
||||
$(this).html(html);
|
||||
|
||||
});
|
||||
}).catch(function (error) {
|
||||
console.error('Failed to render reinfo markdown.', error);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -423,19 +423,19 @@ function loadFromBlockly(){
|
||||
}
|
||||
?>
|
||||
<?php if($OJ_ACE_EDITOR){ ?>
|
||||
<script src="<?php echo $OJ_CDN_URL?>ace/ace.js"></script>
|
||||
<script src="<?php echo $OJ_CDN_URL?>ace/ext-language_tools.js"></script>
|
||||
<script src="include/vditor-adapter.js"></script>
|
||||
<script>
|
||||
ace.require("ace/ext/language_tools");
|
||||
var editor = ace.edit("source");
|
||||
editor.setTheme("ace/theme/xcode");
|
||||
var editor = HustOJVditor.createDeferredCodeEditor({
|
||||
container: "source",
|
||||
hiddenField: "hide_source",
|
||||
theme: "ace/theme/xcode",
|
||||
fontSize: 18
|
||||
});
|
||||
switchLang(<?php echo $lastlang ?>);
|
||||
editor.setOptions({
|
||||
enableBasicAutocompletion: true,
|
||||
enableSnippets: true,
|
||||
enableLiveAutocompletion: true, //改为true,打开自动补齐功能,改为false关闭
|
||||
// fontFamily: "Consolas", // MacOS missing align
|
||||
// theme: "ace/theme/ambiance", // Black theme
|
||||
enableLiveAutocompletion: true,
|
||||
fontSize: "18px"
|
||||
});
|
||||
reloadtemplate($("#language").val());
|
||||
|
||||
Reference in New Issue
Block a user