ui: fix codeLang-sub-select

This commit is contained in:
undefined committed 2021-05-12 00:07:07 +08:00
1 parent 41f6149359
commit 5fad63a3e1
4 files changed
+9 -7

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@hydrooj/ui-default",
"version": "4.8.7",
"version": "4.8.8",
"author": "undefined <i@undefined.moe>",
"license": "AGPL-3.0",
"main": "hydro.js",
@@ -114,11 +114,10 @@ const page = new NamedPage('home_preference', async () => {
}
setOptions($('#codelang-main-select'), main);
const current = $('[name="codeLang"]').val();
console.log(current);
if (current.includes('.')) {
const [m, s] = current.split('.');
$('#codelang-main-select').val(m);
$('#codelang-sub-select').val(s);
$('#codelang-sub-select').val(s).show();
} else $('#codelang-main-select').val(current);
if (success) {
@@ -35,7 +35,7 @@ const page = new NamedPage('problem_submit', async () => {
if (current.includes('.')) {
const [m, s] = current.split('.');
$('#codelang-main-select').val(m);
$('#codelang-sub-select').val(s);
$('#codelang-sub-select').val(s).show();
} else $('#codelang-main-select').val(current);
});
+6 -3
View File
@@ -1,8 +1,11 @@
/**
* @param {string} str
* @param {any} obj
* @returns {string}
*/
export default function substitute(str, obj) {
return str.replace(/\{([^{}]+)\}/g, (match, key) => {
if (obj[key] !== undefined) {
return String(obj[key]);
}
if (obj[key] !== undefined) return obj[key].toString();
return `{${key}}`;
});
}