✨ feat: 更新问题页面和提交页面,集成Vditor适配器,优化Markdown渲染
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user