mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
ui: fix language selection
This commit is contained in:
1 parent
d989df2b85
commit
6e277e26dd
2 files changed
+8
-3
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/ui-default",
|
"name": "@hydrooj/ui-default",
|
||||||
"version": "4.14.10",
|
"version": "4.14.11",
|
||||||
"author": "undefined <i@undefined.moe>",
|
"author": "undefined <i@undefined.moe>",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"main": "hydro.js",
|
"main": "hydro.js",
|
||||||
|
|||||||
@@ -21,9 +21,10 @@ const page = new NamedPage(['problem_submit', 'contest_detail_problem_submit', '
|
|||||||
if (key.startsWith(`${this.value}.`) && key !== this.value) options[key] = window.LANGS[key].display;
|
if (key.startsWith(`${this.value}.`) && key !== this.value) options[key] = window.LANGS[key].display;
|
||||||
}
|
}
|
||||||
setOptions($('#codelang-sub-select'), options);
|
setOptions($('#codelang-sub-select'), options);
|
||||||
if (Object.keys(options).length > 1) $('#codelang-sub-container').show();
|
if (Object.keys(options).length) $('#codelang-sub-container').show();
|
||||||
else $('#codelang-sub-container').hide();
|
else $('#codelang-sub-container').hide();
|
||||||
if (update) $('[name="lang"]').val($('#codelang-sub-select').val());
|
if (update) $('[name="lang"]').val($('#codelang-sub-select').val());
|
||||||
|
return Object.keys(options)[0];
|
||||||
}
|
}
|
||||||
const main = {};
|
const main = {};
|
||||||
for (const key in window.LANGS) {
|
for (const key in window.LANGS) {
|
||||||
@@ -38,8 +39,12 @@ const page = new NamedPage(['problem_submit', 'contest_detail_problem_submit', '
|
|||||||
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: m }, false);
|
const fallback = onChangeMain.call({ value: m }, false);
|
||||||
$('#codelang-sub-select').val(current);
|
$('#codelang-sub-select').val(current);
|
||||||
|
if (!$('#codelang-sub-select').val()) {
|
||||||
|
$('#codelang-sub-select').val(fallback);
|
||||||
|
$('[name="lang"]').val(fallback);
|
||||||
|
}
|
||||||
} else $('#codelang-main-select').val(current);
|
} else $('#codelang-main-select').val(current);
|
||||||
|
|
||||||
$('#codelang-main-select').on('change', onChangeMain);
|
$('#codelang-main-select').on('change', onChangeMain);
|
||||||
|
|||||||
Reference in new issue
Block a user