diff --git a/web/admin/kindeditor.php b/web/admin/kindeditor.php index 97bd164..ced2656 100644 --- a/web/admin/kindeditor.php +++ b/web/admin/kindeditor.php @@ -1,48 +1,25 @@ - - - - - + diff --git a/web/admin/problem_add_page.php b/web/admin/problem_add_page.php index c314990..8b7ab1c 100644 --- a/web/admin/problem_add_page.php +++ b/web/admin/problem_add_page.php @@ -113,8 +113,35 @@ if (!(isset($_SESSION[$OJ_NAME . '_' . 'administrator']) || isset($_SESSION[$OJ_ - - - - - - + diff --git a/web/include/db_info.inc.php b/web/include/db_info.inc.php index 01954b8..ec88c6d 100644 --- a/web/include/db_info.inc.php +++ b/web/include/db_info.inc.php @@ -85,7 +85,7 @@ static $OJ_RANK_HIDDEN="'admin','super','szx','sen'"; // 管理员不显示在 static $OJ_FRIENDLY_LEVEL=0; //系统友好级别,暂定0-9级,级别越高越傻瓜,系统易用度高的同时将降低安全性,仅供非专业用途,造成泄题、抄袭概不负责。 static $OJ_FREE_PRACTICE=true; //自由练习,不受比赛作业用题限制 static $OJ_SUBMIT_COOLDOWN_TIME=1; //提交冷却时间,连续两次提交的最小间隔,单位秒。 -static $OJ_MARKDOWN='markdown-it'; // 开启MARKDOWN,开启后在后台编辑题目时默认为源码模式,用[md] # Markdown [/md] 格式插入markdown代码, 如果需要用到[]也可以用
'+(n?r:W(r,!0))+"\n":""+(n?r:W(r,!0))+"\n"}blockquote({tokens:e}){return`\n${this.parser.parse(e)}\n`}html({text:e}){return e}heading({tokens:e,depth:t}){return`
${this.parser.parseInline(e)}
\n`}table(e){let t="",n="";for(let t=0;t${W(e,!0)}`}br(e){return"An error occurred:
"+W(n.message+"",!0)+"";return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}}const he=new ce;function pe(e,t){return he.parse(e,t)}pe.options=pe.setOptions=function(e){return he.setOptions(e),pe.defaults=he.defaults,n(pe.defaults),pe},pe.getDefaults=t,pe.defaults=e.defaults,pe.use=function(...e){return he.use(...e),pe.defaults=he.defaults,n(pe.defaults),pe},pe.walkTokens=function(e,t){return he.walkTokens(e,t)},pe.parseInline=he.parseInline,pe.Parser=oe,pe.parser=oe.parse,pe.Renderer=ie,pe.TextRenderer=le,pe.Lexer=re,pe.lexer=re.lex,pe.Tokenizer=se,pe.Hooks=ae,pe.parse=pe;const ue=pe.options,ge=pe.setOptions,ke=pe.use,de=pe.walkTokens,fe=pe.parseInline,xe=pe,be=oe.parse,me=re.lex;e.Hooks=ae,e.Lexer=re,e.Marked=ce,e.Parser=oe,e.Renderer=ie,e.TextRenderer=le,e.Tokenizer=se,e.getDefaults=t,e.lexer=me,e.marked=pe,e.options=ue,e.parse=xe,e.parseInline=fe,e.parser=be,e.setOptions=ge,e.use=ke,e.walkTokens=de})); \ No newline at end of file diff --git a/web/template/bs3/problem.php b/web/template/bs3/problem.php index e932ba9..bc650df 100644 --- a/web/template/bs3/problem.php +++ b/web/template/bs3/problem.php @@ -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() { + + return HustOJVditor.renderMarkdownBlocks('.md'); + + 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=""+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); + }); + 1 || isset($_GET['sid']) || (isset($OJ_AUTO_SHOW_OFF)&&$OJ_AUTO_SHOW_OFF)){ ?> + transform(); + + } + window.renderProblemMarkdown = renderProblemMarkdown; $( document ).ready( function () { $( "#creator" ).load( "problem-ajax.php?pid=" ); - - $(".md").each(function(){ - $(this).html(marked.parse($(this).html())); - }); - - //单纯文本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=""+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); - }); -1 || isset($_GET['sid']) || (isset($OJ_AUTO_SHOW_OFF)&&$OJ_AUTO_SHOW_OFF)){ ?> - transform(); - + renderProblemMarkdown().catch(function (error) { + console.error('Failed to render problem markdown.', error); + }).then(function () { + initializeProblemChoices(); + }); } ); diff --git a/web/template/bs3/reinfo.php b/web/template/bs3/reinfo.php index fa449d2..793fed3 100644 --- a/web/template/bs3/reinfo.php +++ b/web/template/bs3/reinfo.php @@ -39,83 +39,78 @@ - diff --git a/web/template/bs3/sharecodepage.php b/web/template/bs3/sharecodepage.php index 01703d3..6aec8f4 100644 --- a/web/template/bs3/sharecodepage.php +++ b/web/template/bs3/sharecodepage.php @@ -65,30 +65,25 @@ - - + - - - + diff --git a/web/template/bshark/footer-files.php b/web/template/bshark/footer-files.php index 9555f83..b815796 100644 --- a/web/template/bshark/footer-files.php +++ b/web/template/bshark/footer-files.php @@ -7,11 +7,8 @@ $("#csrf").load("csrf.php"); - - - - + diff --git a/web/template/bshark/mail.php b/web/template/bshark/mail.php index 8792a1e..907235f 100644 --- a/web/template/bshark/mail.php +++ b/web/template/bshark/mail.php @@ -208,26 +208,40 @@ a:hover { + - + diff --git a/web/template/bshark/submitpage.php b/web/template/bshark/submitpage.php index 15f3271..3ec1375 100644 --- a/web/template/bshark/submitpage.php +++ b/web/template/bshark/submitpage.php @@ -404,12 +404,14 @@ - - + - + diff --git a/web/template/mdui/sharecodepage.php b/web/template/mdui/sharecodepage.php index fe239a3..42b120f 100644 --- a/web/template/mdui/sharecodepage.php +++ b/web/template/mdui/sharecodepage.php @@ -70,30 +70,25 @@ - - + - - - - - - - - - + +
"+rt(t[e].content)+"\n"},pt.fence=function(t,e,r,n,s){const i=t[e],o=i.info?X(i.info).trim():"";let u,c="",a="";if(o){const t=o.split(/(\s+)/g);c=t[0],a=t.slice(2).join("")}if(u=r.highlight&&r.highlight(i.content,c,a)||rt(i.content),0===u.indexOf("${u}\n`}return`${u}\n`},pt.image=function(t,e,r,n,s){const i=t[e];return i.attrs[i.attrIndex("alt")][1]=s.renderInlineAsText(i.children,r,n),s.renderToken(t,e,r)},pt.hardbreak=function(t,e,r){return r.xhtmlOut?"=p)return!1;for(a=i,u=t.md.helpers.parseLinkDestination(t.src,i,t.posMax),u.ok&&(l=t.md.normalizeLink(u.str),t.md.validateLink(l)?i=u.pos:l=""),a=i;i
=p||41!==t.src.charCodeAt(i))return t.pos=h,!1;i++}else{if(void 0===t.env.references)return!1;if(i
=0?s=t.src.slice(a,i++):i=d+1):i=d+1,s||(s=t.src.slice(f,d)),o=t.env.references[ct(s)],!o)return t.pos=h,!1;l=o.href,c=o.title}if(!e){n=t.src.slice(f,d);const e=[];t.md.inline.parse(n,t.md,t.env,e);const r=t.push("image","img",0),s=[["src",l],["alt",""]];r.attrs=s,r.children=e,r.content=n,c&&s.push(["title",c])}return t.pos=i,t.posMax=p,!0}],["autolink",function(t,e){let r=t.pos;if(60!==t.src.charCodeAt(r))return!1;const n=t.pos,s=t.posMax;for(;;){if(++r>=s)return!1;const e=t.src.charCodeAt(r);if(60===e)return!1;if(62===e)break}const i=t.src.slice(n+1,r);if(ee.test(i)){const r=t.md.normalizeLink(i);if(!t.md.validateLink(r))return!1;if(!e){const e=t.push("link_open","a",1);e.attrs=[["href",r]],e.markup="autolink",e.info="auto";t.push("text","",0).content=t.md.normalizeLinkText(i);const n=t.push("link_close","a",-1);n.markup="autolink",n.info="auto"}return t.pos+=i.length+2,!0}if(te.test(i)){const r=t.md.normalizeLink("mailto:"+i);if(!t.md.validateLink(r))return!1;if(!e){const e=t.push("link_open","a",1);e.attrs=[["href",r]],e.markup="autolink",e.info="auto";t.push("text","",0).content=t.md.normalizeLinkText(i);const n=t.push("link_close","a",-1);n.markup="autolink",n.info="auto"}return t.pos+=i.length+2,!0}return!1}],["html_inline",function(t,e){if(!t.md.options.html)return!1;const r=t.posMax,n=t.pos;if(60!==t.src.charCodeAt(n)||n+2>=r)return!1;const s=t.src.charCodeAt(n+1);if(33!==s&&63!==s&&47!==s&&!function(t){const e=32|t;return e>=97&&e<=122}(s))return!1;const i=t.src.slice(n).match(jt);if(!i)return!1;if(!e){const e=t.push("html_inline","",0);e.content=i[0],o=e.content,/^\s]/i.test(o)&&t.linkLevel++,function(t){return/^<\/a\s*>/i.test(t)}(e.content)&&t.linkLevel--}var o;return t.pos+=i[0].length,!0}],["entity",function(t,e){const r=t.pos,n=t.posMax;if(38!==t.src.charCodeAt(r))return!1;if(r+1>=n)return!1;if(35===t.src.charCodeAt(r+1)){const n=t.src.slice(r).match(re);if(n){if(!e){const e="x"===n[1][0].toLowerCase()?parseInt(n[1].slice(1),16):parseInt(n[1],10),r=t.push("text_special","",0);r.content=V(e)?G(e):G(65533),r.markup=n[0],r.info="entity"}return t.pos+=n[0].length,!0}}else{const n=t.src.slice(r).match(ne);if(n){const r=j(n[0]);if(r!==n[0]){if(!e){const e=t.push("text_special","",0);e.content=r,e.markup=n[0],e.info="entity"}return t.pos+=n[0].length,!0}}}return!1}]],oe=[["balance_pairs",function(t){const e=t.tokens_meta,r=t.tokens_meta.length;se(t.delimiters);for(let t=0;t
");
+ }
+ 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=""+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+") }}","
");
- }
- 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");
+ 1 || isset($_GET['sid']) || (isset($OJ_AUTO_SHOW_OFF)&&$OJ_AUTO_SHOW_OFF)){?>
+ transform();
+
+ }
+ 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");
- 1 || isset($_GET['sid']) || (isset($OJ_AUTO_SHOW_OFF)&&$OJ_AUTO_SHOW_OFF)){?>
- transform();
-
+ renderProblemMarkdown().catch(function (error) {
+ console.error('Failed to render problem markdown.', error);
+ }).then(function () {
+ initializeProblemChoices();
+ });
});
diff --git a/web/template/sidebar/reinfo.php b/web/template/sidebar/reinfo.php
index bbc14bf..6e7dc08 100644
--- a/web/template/sidebar/reinfo.php
+++ b/web/template/sidebar/reinfo.php
@@ -1,7 +1,7 @@
-
+
-
-
+
");
+ }
+ 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 + ") }}", "
");
- }
- 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");
1 || isset($_GET['sid']) || (isset($OJ_AUTO_SHOW_OFF) && $OJ_AUTO_SHOW_OFF)) { ?>
transform();
+ }
+
+ window.renderProblemMarkdown = renderProblemMarkdown;
+
+ renderProblemMarkdown().catch(function (error) {
+ console.error('Failed to render problem markdown.', error);
+ }).then(function () {
+ initializeProblemChoices();
+ });
});
diff --git a/web/template/syzoj/reinfo.php b/web/template/syzoj/reinfo.php
index d640821..cf19225 100644
--- a/web/template/syzoj/reinfo.php
+++ b/web/template/syzoj/reinfo.php
@@ -1,7 +1,7 @@
-
+