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