ui: 修复部分情况下提交语言显示异常的问题

This commit is contained in:
undefined committed 2021-05-27 00:08:03 +08:00
1 parent 0925113e39
commit c09b4acfd5
3 files changed
+14 -10

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@hydrooj/ui-default",
"version": "4.10.4",
"version": "4.10.5",
"author": "undefined <i@undefined.moe>",
"license": "AGPL-3.0",
"main": "hydro.js",
@@ -94,7 +94,8 @@ const page = new NamedPage('home_preference', async () => {
.hide()
.after($el);
$('#codelang-main-select').on('change', function () {
function onChangeMain() {
console.log(this.value, window.LANGS);
const options = {};
for (const key in window.LANGS) {
if (key.startsWith(`${this.value}.`) && key !== this.value) options[key] = window.LANGS[key].display;
@@ -107,7 +108,8 @@ const page = new NamedPage('home_preference', async () => {
$('#codelang-sub-container').hide();
$('[name="codeLang"]').val(this.value);
}
});
}
$('#codelang-main-select').on('change', onChangeMain);
$('#codelang-sub-select').on('change', function () {
$('[name="codeLang"]').val(this.value);
});
@@ -118,9 +120,10 @@ const page = new NamedPage('home_preference', async () => {
setOptions($('#codelang-main-select'), main);
const current = $('[name="codeLang"]').val();
if (current.includes('.')) {
const [m, s] = current.split('.');
const [m] = current.split('.');
$('#codelang-main-select').val(m);
$('#codelang-sub-select').val(s).show();
onChangeMain.call({ value: $('#codelang-main-select').val() });
$('#codelang-sub-select').val(current);
} else $('#codelang-main-select').val(current);
if (success) {
@@ -12,7 +12,7 @@ const page = new NamedPage(['problem_submit', 'contest_detail_problem_submit', '
$(ev.currentTarget).hide();
$('[name="problem-sidebar__categories"]').show();
});
$('#codelang-main-select').on('change', function () {
function onChangeMain() {
const options = {};
for (const key in window.LANGS) {
if (UiContext.pdocConfig.langs && !UiContext.pdocConfig.langs.includes(key)) continue;
@@ -26,7 +26,8 @@ const page = new NamedPage(['problem_submit', 'contest_detail_problem_submit', '
$('#codelang-sub-container').hide();
$('[name="lang"]').val(this.value);
}
});
}
$('#codelang-main-select').on('change', onChangeMain);
$('#codelang-sub-select').on('change', function () {
$('[name="lang"]').val(this.value);
});
@@ -38,10 +39,10 @@ const page = new NamedPage(['problem_submit', 'contest_detail_problem_submit', '
setOptions($('#codelang-main-select'), main);
const current = $('[name="lang"]').val();
if (current.includes('.')) {
const [m, s] = current.split('.');
const [m] = current.split('.');
$('#codelang-main-select').val(m);
$('#codelang-sub-select').val(s);
$('#codelang-sub-container').show();
onChangeMain.call({ value: $('#codelang-main-select').val() });
$('#codelang-sub-select').val(current);
} else $('#codelang-main-select').val(current);
});