mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
ui: fix problem_submit page language selection
This commit is contained in:
1 parent
fa5b2e8fee
commit
d5e86d6bdb
2 files changed
+11
-10
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/ui-default",
|
"name": "@hydrooj/ui-default",
|
||||||
"version": "4.11.26",
|
"version": "4.11.27",
|
||||||
"author": "undefined <i@undefined.moe>",
|
"author": "undefined <i@undefined.moe>",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"main": "hydro.js",
|
"main": "hydro.js",
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ const page = new NamedPage(['problem_submit', 'contest_detail_problem_submit', '
|
|||||||
$(ev.currentTarget).hide();
|
$(ev.currentTarget).hide();
|
||||||
$('[name="problem-sidebar__categories"]').show();
|
$('[name="problem-sidebar__categories"]').show();
|
||||||
});
|
});
|
||||||
function onChangeMain() {
|
function onChangeMain(update = true) {
|
||||||
const options = {};
|
const options = {};
|
||||||
for (const key in window.LANGS) {
|
for (const key in window.LANGS) {
|
||||||
if (UiContext.pdocConfig.langs && !UiContext.pdocConfig.langs.includes(key)) continue;
|
if (UiContext.pdocConfig.langs && !UiContext.pdocConfig.langs.includes(key)) continue;
|
||||||
@@ -21,16 +21,12 @@ const page = new NamedPage(['problem_submit', 'contest_detail_problem_submit', '
|
|||||||
if (Object.keys(options).length > 1) {
|
if (Object.keys(options).length > 1) {
|
||||||
setOptions($('#codelang-sub-select'), options);
|
setOptions($('#codelang-sub-select'), options);
|
||||||
$('#codelang-sub-container').show();
|
$('#codelang-sub-container').show();
|
||||||
$('[name="lang"]').val($('#codelang-sub-select').val());
|
if (update) $('[name="lang"]').val($('#codelang-sub-select').val());
|
||||||
} else {
|
} else {
|
||||||
$('#codelang-sub-container').hide();
|
$('#codelang-sub-container').hide();
|
||||||
$('[name="lang"]').val(this.value);
|
if (update) $('[name="lang"]').val(this.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$('#codelang-main-select').on('change', onChangeMain);
|
|
||||||
$('#codelang-sub-select').on('change', function () {
|
|
||||||
$('[name="lang"]').val(this.value);
|
|
||||||
});
|
|
||||||
const main = {};
|
const main = {};
|
||||||
const prefix = new Set(Object.keys(window.LANGS).filter((i) => i.includes('.')).map((i) => i.split('.')[0]));
|
const prefix = new Set(Object.keys(window.LANGS).filter((i) => i.includes('.')).map((i) => i.split('.')[0]));
|
||||||
for (const key in window.LANGS) {
|
for (const key in window.LANGS) {
|
||||||
@@ -38,14 +34,19 @@ const page = new NamedPage(['problem_submit', 'contest_detail_problem_submit', '
|
|||||||
if (!key.includes('.')) main[key] = window.LANGS[key].display;
|
if (!key.includes('.')) main[key] = window.LANGS[key].display;
|
||||||
}
|
}
|
||||||
setOptions($('#codelang-main-select'), main);
|
setOptions($('#codelang-main-select'), main);
|
||||||
|
|
||||||
const current = $('[name="lang"]').val();
|
const current = $('[name="lang"]').val();
|
||||||
if (current.includes('.')) {
|
if (current.includes('.')) {
|
||||||
const [m] = current.split('.');
|
const [m] = current.split('.');
|
||||||
$('#codelang-main-select').val(m);
|
$('#codelang-main-select').val(m);
|
||||||
onChangeMain.call({ value: $('#codelang-main-select').val() });
|
onChangeMain.call({ value: m }, false);
|
||||||
$('#codelang-sub-select').val(current);
|
$('#codelang-sub-select').val(current);
|
||||||
$('[name="lang"]').val(current);
|
|
||||||
} else $('#codelang-main-select').val(current);
|
} else $('#codelang-main-select').val(current);
|
||||||
|
|
||||||
|
$('#codelang-main-select').on('change', onChangeMain);
|
||||||
|
$('#codelang-sub-select').on('change', function () {
|
||||||
|
$('[name="lang"]').val(this.value);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
export default page;
|
export default page;
|
||||||
Reference in new issue
Block a user