mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
ui: problem_detail: add clear answers button
This commit is contained in:
2 files changed
+19
-1
No files matched your search
@@ -84,6 +84,7 @@ Add User: 添加用户
|
||||
Add: 添加
|
||||
additional_file: 附加文件
|
||||
All {0} Contests: 所有 {0} 比赛
|
||||
All changes will be lost. Are you sure to clear all answers?: 所有更改将会丢失。您确定要清除所有答案吗?
|
||||
All Contests: 所有比赛
|
||||
All Homeworks: 所有作业
|
||||
All Languages: 所有语言
|
||||
@@ -161,6 +162,7 @@ Choose the background image in your profile page.: 选择您资料页面的背
|
||||
Claim homework: 认领作业
|
||||
Claim Homework: 认领作业
|
||||
Claimed: 已认领
|
||||
Clear answers: 清除答案
|
||||
Clear Marks: 清除标记
|
||||
Click here to chat with me: 点击这里与我聊天
|
||||
click to add: 点击添加
|
||||
|
||||
@@ -2,6 +2,7 @@ import $ from 'jquery';
|
||||
import yaml from 'js-yaml';
|
||||
import React from 'react';
|
||||
import { createRoot } from 'react-dom/client';
|
||||
import { ConfirmDialog } from 'vj/components/dialog';
|
||||
import Notification from 'vj/components/notification';
|
||||
import { downloadProblemSet } from 'vj/components/zipDownloader';
|
||||
import { NamedPage } from 'vj/misc/Page';
|
||||
@@ -246,6 +247,10 @@ const page = new NamedPage(['problem_detail', 'contest_detail_problem', 'homewor
|
||||
localStorage.setItem(`${cacheKey}#objective`, JSON.stringify(ans));
|
||||
setUpdate?.((i) => i + 1);
|
||||
}
|
||||
function clearAns() {
|
||||
localStorage.removeItem(`${cacheKey}#objective`);
|
||||
window.location.reload();
|
||||
}
|
||||
function loadAns() {
|
||||
const saved = localStorage.getItem(`${cacheKey}#objective`);
|
||||
if (saved) {
|
||||
@@ -296,9 +301,20 @@ const page = new NamedPage(['problem_detail', 'contest_detail_problem', 'homewor
|
||||
Notification.error(err.message);
|
||||
});
|
||||
});
|
||||
$('.section--problem-sidebar ol.menu').prepend(tpl(<li className="menu__item" id="clearAnswers">
|
||||
<a className="menu__link" href="javascript:;">
|
||||
<span className="icon icon-erase" /> {i18n('Clear answers')}
|
||||
</a>
|
||||
</li>));
|
||||
$(document).on('click', '#clearAnswers', async () => {
|
||||
const result = await new ConfirmDialog({
|
||||
$body: tpl.typoMsg('All changes will be lost. Are you sure to clear all answers?'),
|
||||
}).open();
|
||||
if (result === 'yes') clearAns();
|
||||
});
|
||||
}
|
||||
const ele = document.createElement('div');
|
||||
$(ele).insertBefore($('.scratchpad--hide').get(0));
|
||||
$('.section--problem-sidebar ol.menu').prepend(ele);
|
||||
createRoot(ele).render(<ProblemNavigation />);
|
||||
$('.non-scratchpad--hide').hide();
|
||||
$('.scratchpad--hide').hide();
|
||||
|
||||
Reference in new issue
Block a user