mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
ui: remove babel
This commit is contained in:
1 parent
ff943b620e
commit
c7c70a6abb
23 files changed
+466
-606
No files matched your search
@@ -279,7 +279,7 @@ export default class Calendar {
|
||||
for (; vIndex < vIndexMax; ++vIndex) {
|
||||
if (_.every(_
|
||||
.range(beginDay, endDay + 1)
|
||||
.map((day) => !dayBitmap[day][vIndex]) // eslint-disable-line no-loop-func
|
||||
.map((day) => !dayBitmap[day][vIndex]), // eslint-disable-line no-loop-func
|
||||
)) { // eslint-disable-line function-paren-newline
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -5,20 +5,20 @@ import request from 'vj/utils/request';
|
||||
import Notification from 'vj/components/notification';
|
||||
|
||||
const contestPage = new AutoloadPage('contestPage', () => {
|
||||
$('[data-contest-code]').on('click', (ev) => {
|
||||
ev.preventDefault();
|
||||
// eslint-disable-next-line no-alert
|
||||
const code = prompt(i18n('Invitation code:'));
|
||||
request.post('', {
|
||||
operation: 'attend',
|
||||
code,
|
||||
}).then(() => {
|
||||
Notification.success(i18n('Successfully attended'));
|
||||
delay(1000).then(() => window.location.reload());
|
||||
}).catch((e) => {
|
||||
Notification.error(e.message || e);
|
||||
});
|
||||
$('[data-contest-code]').on('click', (ev) => {
|
||||
ev.preventDefault();
|
||||
// eslint-disable-next-line no-alert
|
||||
const code = prompt(i18n('Invitation code:'));
|
||||
request.post('', {
|
||||
operation: 'attend',
|
||||
code,
|
||||
}).then(() => {
|
||||
Notification.success(i18n('Successfully attended'));
|
||||
delay(1000).then(() => window.location.reload());
|
||||
}).catch((e) => {
|
||||
Notification.error(e.message || e);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
export default contestPage;
|
||||
@@ -42,7 +42,7 @@ export default class DomDialog extends DOMAttachedObject {
|
||||
{
|
||||
duration: 100,
|
||||
easing: 'easeOutCubic',
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
const $dgContent = this.$dom.find('.dialog__content');
|
||||
|
||||
@@ -2,42 +2,42 @@ import { AutoloadPage } from 'vj/misc/Page';
|
||||
import request from 'vj/utils/request';
|
||||
|
||||
export default new AutoloadPage('media', async () => {
|
||||
async function parseMedia($dom = $(document.body)) {
|
||||
const items = [];
|
||||
const resolvers = [];
|
||||
const users = $dom.find('div[data-user]');
|
||||
const resolve = (ele, item) => {
|
||||
items.push(item);
|
||||
resolvers.push((html) => html && $(ele).replaceWith($(html)));
|
||||
};
|
||||
users.get().forEach((ele) => resolve(ele, { type: 'user', id: +$(ele).text() }));
|
||||
$dom.find('.typo').get().forEach((el) => {
|
||||
$(el).find('a[href]').get().forEach((ele) => {
|
||||
if ($(ele).parent().hasClass('user-profile-link')) return;
|
||||
let target = $(ele).attr('href');
|
||||
let { domainId } = UiContext;
|
||||
if (target.startsWith(UiContext.url_prefix)) {
|
||||
target.replace(UiContext.url_prefix, '');
|
||||
if (!target.startsWith('/')) target = `/${target}`;
|
||||
}
|
||||
if (!target.startsWith('/') || target.startsWith('//')) return;
|
||||
if (target.startsWith('/d/')) {
|
||||
const [, , domain, ...extra] = target.split('/');
|
||||
domainId = domain;
|
||||
target = `/${extra.join('/')}`;
|
||||
}
|
||||
const [, category, data, extra] = target.split('/');
|
||||
if (!data) return;
|
||||
if (category === 'user' && Number.isInteger(+data) && !extra) resolve(ele, { type: 'user', id: +data });
|
||||
if (category === 'p' && !extra) resolve(ele, { type: 'problem', id: data, domainId });
|
||||
if (category === 'contest' && !extra) resolve(ele, { type: 'contest', id: data, domainId });
|
||||
});
|
||||
});
|
||||
if (!items.length) return;
|
||||
const res = await request.post(`/d/${UiContext.domainId}/media`, { items });
|
||||
for (let i = 0; i < res.length; i++) resolvers[i](res[i]);
|
||||
}
|
||||
async function parseMedia($dom = $(document.body)) {
|
||||
const items = [];
|
||||
const resolvers = [];
|
||||
const users = $dom.find('div[data-user]');
|
||||
const resolve = (ele, item) => {
|
||||
items.push(item);
|
||||
resolvers.push((html) => html && $(ele).replaceWith($(html)));
|
||||
};
|
||||
users.get().forEach((ele) => resolve(ele, { type: 'user', id: +$(ele).text() }));
|
||||
$dom.find('.typo').get().forEach((el) => {
|
||||
$(el).find('a[href]').get().forEach((ele) => {
|
||||
if ($(ele).parent().hasClass('user-profile-link')) return;
|
||||
let target = $(ele).attr('href');
|
||||
let { domainId } = UiContext;
|
||||
if (target.startsWith(UiContext.url_prefix)) {
|
||||
target.replace(UiContext.url_prefix, '');
|
||||
if (!target.startsWith('/')) target = `/${target}`;
|
||||
}
|
||||
if (!target.startsWith('/') || target.startsWith('//')) return;
|
||||
if (target.startsWith('/d/')) {
|
||||
const [, , domain, ...extra] = target.split('/');
|
||||
domainId = domain;
|
||||
target = `/${extra.join('/')}`;
|
||||
}
|
||||
const [, category, data, extra] = target.split('/');
|
||||
if (!data) return;
|
||||
if (category === 'user' && Number.isInteger(+data) && !extra) resolve(ele, { type: 'user', id: +data });
|
||||
if (category === 'p' && !extra) resolve(ele, { type: 'problem', id: data, domainId });
|
||||
if (category === 'contest' && !extra) resolve(ele, { type: 'contest', id: data, domainId });
|
||||
});
|
||||
});
|
||||
if (!items.length) return;
|
||||
const res = await request.post(`/d/${UiContext.domainId}/media`, { items });
|
||||
for (let i = 0; i < res.length; i++) resolvers[i](res[i]);
|
||||
}
|
||||
|
||||
await parseMedia();
|
||||
$(document).on('vjContentNew', (e) => parseMedia($(e.target)));
|
||||
await parseMedia();
|
||||
$(document).on('vjContentNew', (e) => parseMedia($(e.target)));
|
||||
});
|
||||
@@ -3,12 +3,12 @@ import Notification from 'vj/components/notification/index';
|
||||
import i18n from 'vj/utils/i18n';
|
||||
|
||||
export default new AutoloadPage('notificationPage', (pagename) => {
|
||||
const message = i18n(`Hint::Page::${pagename}`);
|
||||
const item = localStorage.getItem(`hint.${message}`);
|
||||
if (message !== `Hint::Page::${pagename}` && !item) {
|
||||
Notification.info(message, message.length * 500);
|
||||
localStorage.setItem(`hint.${message}`, true);
|
||||
}
|
||||
const text = new URL(window.location.href).searchParams.get('notification');
|
||||
if (text) Notification.success(text);
|
||||
const message = i18n(`Hint::Page::${pagename}`);
|
||||
const item = localStorage.getItem(`hint.${message}`);
|
||||
if (message !== `Hint::Page::${pagename}` && !item) {
|
||||
Notification.info(message, message.length * 500);
|
||||
localStorage.setItem(`hint.${message}`, true);
|
||||
}
|
||||
const text = new URL(window.location.href).searchParams.get('notification');
|
||||
if (text) Notification.success(text);
|
||||
});
|
||||
@@ -1,8 +1,8 @@
|
||||
import { AutoloadPage } from 'vj/misc/Page';
|
||||
|
||||
export default new AutoloadPage('problemListPage', () => {
|
||||
$('.col--problem-name>a').attr('target', '_blank');
|
||||
$(document).on('vjContentNew', () => {
|
||||
$('.col--problem-name>a').attr('target', '_blank');
|
||||
$(document).on('vjContentNew', () => {
|
||||
$('.col--problem-name>a').attr('target', '_blank');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -3,20 +3,20 @@ export default function reducer(state = {
|
||||
code: localStorage.getItem(`${UserContext._id}/${UiContext.pdoc.domainId}/${UiContext.pdoc.docId}`) || UiContext.codeTemplate,
|
||||
}, action) {
|
||||
switch (action.type) {
|
||||
case 'SCRATCHPAD_EDITOR_UPDATE_CODE': {
|
||||
localStorage.setItem(`${UserContext._id}/${UiContext.pdoc.domainId}/${UiContext.pdoc.docId}`, action.payload);
|
||||
return {
|
||||
...state,
|
||||
code: action.payload,
|
||||
};
|
||||
}
|
||||
case 'SCRATCHPAD_EDITOR_SET_LANG': {
|
||||
return {
|
||||
...state,
|
||||
lang: action.payload,
|
||||
};
|
||||
}
|
||||
default:
|
||||
return state;
|
||||
case 'SCRATCHPAD_EDITOR_UPDATE_CODE': {
|
||||
localStorage.setItem(`${UserContext._id}/${UiContext.pdoc.domainId}/${UiContext.pdoc.docId}`, action.payload);
|
||||
return {
|
||||
...state,
|
||||
code: action.payload,
|
||||
};
|
||||
}
|
||||
case 'SCRATCHPAD_EDITOR_SET_LANG': {
|
||||
return {
|
||||
...state,
|
||||
lang: action.payload,
|
||||
};
|
||||
}
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
@@ -17,88 +17,88 @@ export default function reducer(state = {
|
||||
isPosting: false,
|
||||
}, action) {
|
||||
switch (action.type) {
|
||||
case 'SCRATCHPAD_UI_CHANGE_SIZE': {
|
||||
const { uiElement, size } = action.payload;
|
||||
return {
|
||||
...state,
|
||||
[uiElement]: {
|
||||
...state[uiElement],
|
||||
size,
|
||||
},
|
||||
};
|
||||
}
|
||||
case 'SCRATCHPAD_UI_SET_VISIBILITY': {
|
||||
const { uiElement, visibility } = action.payload;
|
||||
return {
|
||||
...state,
|
||||
[uiElement]: {
|
||||
...state[uiElement],
|
||||
visible: visibility,
|
||||
},
|
||||
};
|
||||
}
|
||||
case 'SCRATCHPAD_UI_TOGGLE_VISIBILITY': {
|
||||
const { uiElement } = action.payload;
|
||||
return {
|
||||
...state,
|
||||
[uiElement]: {
|
||||
...state[uiElement],
|
||||
visible: !state[uiElement].visible,
|
||||
},
|
||||
};
|
||||
}
|
||||
case 'SCRATCHPAD_POST_PRETEST_PENDING':
|
||||
case 'SCRATCHPAD_POST_SUBMIT_PENDING': {
|
||||
return {
|
||||
...state,
|
||||
isPosting: true,
|
||||
};
|
||||
}
|
||||
case 'SCRATCHPAD_POST_PRETEST_FULFILLED':
|
||||
case 'SCRATCHPAD_POST_SUBMIT_FULFILLED': {
|
||||
Notification.success(i18n('Submitted.'));
|
||||
return {
|
||||
...state,
|
||||
isPosting: false,
|
||||
};
|
||||
}
|
||||
case 'SCRATCHPAD_POST_PRETEST_REJECTED':
|
||||
case 'SCRATCHPAD_POST_SUBMIT_REJECTED': {
|
||||
Notification.error(action.payload.message);
|
||||
return {
|
||||
...state,
|
||||
isPosting: false,
|
||||
};
|
||||
}
|
||||
case 'SCRATCHPAD_RECORDS_LOAD_SUBMISSIONS_PENDING': {
|
||||
return {
|
||||
...state,
|
||||
records: {
|
||||
...state.records,
|
||||
isLoading: true,
|
||||
},
|
||||
};
|
||||
}
|
||||
case 'SCRATCHPAD_RECORDS_LOAD_SUBMISSIONS_REJECTED': {
|
||||
Notification.error(action.payload.message);
|
||||
return {
|
||||
...state,
|
||||
records: {
|
||||
...state.records,
|
||||
isLoading: false,
|
||||
},
|
||||
};
|
||||
}
|
||||
case 'SCRATCHPAD_RECORDS_LOAD_SUBMISSIONS_FULFILLED': {
|
||||
return {
|
||||
...state,
|
||||
records: {
|
||||
...state.records,
|
||||
isLoading: false,
|
||||
},
|
||||
};
|
||||
}
|
||||
default:
|
||||
return state;
|
||||
case 'SCRATCHPAD_UI_CHANGE_SIZE': {
|
||||
const { uiElement, size } = action.payload;
|
||||
return {
|
||||
...state,
|
||||
[uiElement]: {
|
||||
...state[uiElement],
|
||||
size,
|
||||
},
|
||||
};
|
||||
}
|
||||
case 'SCRATCHPAD_UI_SET_VISIBILITY': {
|
||||
const { uiElement, visibility } = action.payload;
|
||||
return {
|
||||
...state,
|
||||
[uiElement]: {
|
||||
...state[uiElement],
|
||||
visible: visibility,
|
||||
},
|
||||
};
|
||||
}
|
||||
case 'SCRATCHPAD_UI_TOGGLE_VISIBILITY': {
|
||||
const { uiElement } = action.payload;
|
||||
return {
|
||||
...state,
|
||||
[uiElement]: {
|
||||
...state[uiElement],
|
||||
visible: !state[uiElement].visible,
|
||||
},
|
||||
};
|
||||
}
|
||||
case 'SCRATCHPAD_POST_PRETEST_PENDING':
|
||||
case 'SCRATCHPAD_POST_SUBMIT_PENDING': {
|
||||
return {
|
||||
...state,
|
||||
isPosting: true,
|
||||
};
|
||||
}
|
||||
case 'SCRATCHPAD_POST_PRETEST_FULFILLED':
|
||||
case 'SCRATCHPAD_POST_SUBMIT_FULFILLED': {
|
||||
Notification.success(i18n('Submitted.'));
|
||||
return {
|
||||
...state,
|
||||
isPosting: false,
|
||||
};
|
||||
}
|
||||
case 'SCRATCHPAD_POST_PRETEST_REJECTED':
|
||||
case 'SCRATCHPAD_POST_SUBMIT_REJECTED': {
|
||||
Notification.error(action.payload.message);
|
||||
return {
|
||||
...state,
|
||||
isPosting: false,
|
||||
};
|
||||
}
|
||||
case 'SCRATCHPAD_RECORDS_LOAD_SUBMISSIONS_PENDING': {
|
||||
return {
|
||||
...state,
|
||||
records: {
|
||||
...state.records,
|
||||
isLoading: true,
|
||||
},
|
||||
};
|
||||
}
|
||||
case 'SCRATCHPAD_RECORDS_LOAD_SUBMISSIONS_REJECTED': {
|
||||
Notification.error(action.payload.message);
|
||||
return {
|
||||
...state,
|
||||
records: {
|
||||
...state.records,
|
||||
isLoading: false,
|
||||
},
|
||||
};
|
||||
}
|
||||
case 'SCRATCHPAD_RECORDS_LOAD_SUBMISSIONS_FULFILLED': {
|
||||
return {
|
||||
...state,
|
||||
records: {
|
||||
...state.records,
|
||||
isLoading: false,
|
||||
},
|
||||
};
|
||||
}
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
@@ -66,7 +66,7 @@ export default class Tab extends DOMAttachedObject {
|
||||
{
|
||||
duration: TAB_TRANSITION_DURATION,
|
||||
easing: 'linear',
|
||||
}
|
||||
},
|
||||
);
|
||||
$newTab
|
||||
.transition(
|
||||
@@ -74,7 +74,7 @@ export default class Tab extends DOMAttachedObject {
|
||||
{
|
||||
duration: TAB_TRANSITION_DURATION,
|
||||
easing: 'linear',
|
||||
}
|
||||
},
|
||||
);
|
||||
await this.$content
|
||||
.transition({
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import astyleBinaryUrl from 'wastyle/dist/astyle-optimize-size.wasm';
|
||||
|
||||
export default async function load() {
|
||||
const { init, format } = await import('wastyle');
|
||||
try {
|
||||
await init(astyleBinaryUrl);
|
||||
console.log('WAstyle is ready!');
|
||||
const formatter = (code, options) => {
|
||||
const [success, result] = format(code, options);
|
||||
return [success, (result || '').replace(/^#(include|import)[\t ]*(<|")/gm, (match, p1, p2) => `#${p1} ${p2}`)];
|
||||
};
|
||||
return [true, formatter];
|
||||
} catch (e) {
|
||||
return [false, e.message];
|
||||
}
|
||||
const { init, format } = await import('wastyle');
|
||||
try {
|
||||
await init(astyleBinaryUrl);
|
||||
console.log('WAstyle is ready!');
|
||||
const formatter = (code, options) => {
|
||||
const [success, result] = format(code, options);
|
||||
return [success, (result || '').replace(/^#(include|import)[\t ]*(<|")/gm, (match, p1, p2) => `#${p1} ${p2}`)];
|
||||
};
|
||||
return [true, formatter];
|
||||
} catch (e) {
|
||||
return [false, e.message];
|
||||
}
|
||||
}
|
||||
@@ -86,7 +86,7 @@ export async function downloadProblemSet(pids, name = 'Export') {
|
||||
});
|
||||
let { links } = await request.post(
|
||||
`/d/${UiContext.domainId}/p/${pid}/files`,
|
||||
{ operation: 'get_links', files: (pdoc.data || []).map((i) => i.name), type: 'testdata' }
|
||||
{ operation: 'get_links', files: (pdoc.data || []).map((i) => i.name), type: 'testdata' },
|
||||
);
|
||||
for (const filename of Object.keys(links)) {
|
||||
targets.push({ filename: `${pid}/testdata/${filename}`, url: links[filename] });
|
||||
|
||||
Reference in new issue
Block a user