@shzlx/ui-default 4.58.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/api.ts +61 -0
- package/backendlib/builder.ts +182 -0
- package/backendlib/markdown-it-imsize.ts +235 -0
- package/backendlib/markdown-it-katex.ts +139 -0
- package/backendlib/markdown-it-media.ts +163 -0
- package/backendlib/markdown-it-xss.ts +200 -0
- package/backendlib/markdown.js +64 -0
- package/backendlib/misc.ts +54 -0
- package/backendlib/template.ts +279 -0
- package/breakpoints.json +5 -0
- package/components/DOMAttachedObject.ts +128 -0
- package/components/autocomplete/AssignSelectAutoComplete.tsx +22 -0
- package/components/autocomplete/CustomSelectAutoComplete.tsx +23 -0
- package/components/autocomplete/DomainSelectAutoComplete.tsx +18 -0
- package/components/autocomplete/FileSelectAutoComplete.tsx +26 -0
- package/components/autocomplete/LanguageSelectAutoComplete.tsx +24 -0
- package/components/autocomplete/ProblemSelectAutoComplete.tsx +18 -0
- package/components/autocomplete/UserSelectAutoComplete.tsx +23 -0
- package/components/autocomplete/components/AssignSelectAutoComplete.tsx +118 -0
- package/components/autocomplete/components/DomainSelectAutoComplete.tsx +53 -0
- package/components/autocomplete/components/FileSelectAutoComplete.tsx +50 -0
- package/components/autocomplete/components/LanguageSelectAutoComplete.tsx +48 -0
- package/components/autocomplete/components/ProblemSelectAutoComplete.tsx +54 -0
- package/components/autocomplete/components/UserSelectAutoComplete.tsx +54 -0
- package/components/autocomplete/domainselectautocomplete.page.styl +6 -0
- package/components/autocomplete/index.tsx +110 -0
- package/components/autocomplete/problemselectautocomplete.page.styl +6 -0
- package/components/autocomplete/userselectautocomplete.page.styl +6 -0
- package/components/browser-update.page.ts +27 -0
- package/components/calendar/calendar.page.styl +129 -0
- package/components/calendar/index.js +367 -0
- package/components/clipboard.page.ts +23 -0
- package/components/contest/contest.page.styl +119 -0
- package/components/contest/contest.page.ts +23 -0
- package/components/contest/contest_sidebar.page.styl +21 -0
- package/components/contest/problem-contest-bg.png +0 -0
- package/components/contest/problem-contest-bg@2x.png +0 -0
- package/components/customFont.page.tsx +90 -0
- package/components/datepicker/datepicker.page.tsx +94 -0
- package/components/dialog/DomDialog.ts +145 -0
- package/components/dialog/dialog.page.styl +40 -0
- package/components/dialog/index.tsx +285 -0
- package/components/discussion/CommentBox.js +103 -0
- package/components/discussion/collapsible.page.styl +40 -0
- package/components/discussion/collapsible.page.tsx +62 -0
- package/components/discussion/comments.page.styl +142 -0
- package/components/discussion/comments.page.tsx +192 -0
- package/components/discussion/discussion.page.styl +17 -0
- package/components/discussion/history.page.tsx +81 -0
- package/components/discussion/reaction.page.styl +30 -0
- package/components/discussion/reaction.page.tsx +103 -0
- package/components/drop/drop.page.styl +40 -0
- package/components/dropdown/Dropdown.js +50 -0
- package/components/dropdown/dropdown.page.styl +33 -0
- package/components/dropdown/dropdown.page.ts +8 -0
- package/components/editor/cmeditor.page.ts +23 -0
- package/components/editor/cmeditor.styl +10 -0
- package/components/editor/index.tsx +293 -0
- package/components/editor/mdeditor.ts +60 -0
- package/components/editor/textareaHandler.ts +29 -0
- package/components/footer/footer.page.styl +94 -0
- package/components/footer/footer.page.ts +26 -0
- package/components/form/button.page.default.styl +59 -0
- package/components/form/button.page.styl +36 -0
- package/components/form/checkbox.page.styl +89 -0
- package/components/form/form.page.styl +200 -0
- package/components/form/form.page.ts +20 -0
- package/components/form/multiSelectCheckbox.page.js +46 -0
- package/components/form/radiobox.page.styl +62 -0
- package/components/form/select.page.styl +29 -0
- package/components/form/textbox.page.styl +79 -0
- package/components/form/textbox.page.ts +21 -0
- package/components/form/var.inc.styl +14 -0
- package/components/header/header.page.styl +79 -0
- package/components/highlighter/code-example.js +111 -0
- package/components/highlighter/highlighter.page.styl +99 -0
- package/components/highlighter/highlighter.page.ts +72 -0
- package/components/highlighter/meta.js +15 -0
- package/components/highlighter/prismjs.js +122 -0
- package/components/hint.page.styl +9 -0
- package/components/hint.ts +19 -0
- package/components/hitokoto/index.page.js +21 -0
- package/components/hotkey/hotkey.page.js +83 -0
- package/components/katex/katex.page.js +26 -0
- package/components/katex/katex.page.styl +2 -0
- package/components/languageselect.tsx +94 -0
- package/components/loader/loader.page.styl +40 -0
- package/components/mantine.page.tsx +39 -0
- package/components/marker/Marker.js +192 -0
- package/components/marker/MarkerReactive.js +55 -0
- package/components/marker/marker.page.js +8 -0
- package/components/marker/marker.page.styl +57 -0
- package/components/media/media.page.js +46 -0
- package/components/menu/menu-heading.page.js +28 -0
- package/components/menu/menu.page.js +18 -0
- package/components/menu/menu.page.styl +68 -0
- package/components/message/index.page.ts +166 -0
- package/components/message/worker.ts +110 -0
- package/components/messagepad/DialogueListItem.page.styl +28 -0
- package/components/messagepad/DialogueListItemComponent.jsx +39 -0
- package/components/messagepad/Message.page.styl +64 -0
- package/components/messagepad/MessageComponent.jsx +33 -0
- package/components/messagepad/MessagePad.page.styl +99 -0
- package/components/messagepad/MessagePadDialogueContentContainer.jsx +104 -0
- package/components/messagepad/MessagePadDialogueListContainer.jsx +49 -0
- package/components/messagepad/MessagePadInputContainer.jsx +100 -0
- package/components/messagepad/index.jsx +49 -0
- package/components/messagepad/reducers/activeId.ts +36 -0
- package/components/messagepad/reducers/dialogues.js +53 -0
- package/components/messagepad/reducers/index.ts +14 -0
- package/components/messagepad/reducers/inputs.js +43 -0
- package/components/messagepad/reducers/isPosting.ts +49 -0
- package/components/monaco/index.ts +178 -0
- package/components/monaco/languages/markdown.ts +97 -0
- package/components/monaco/languages/typescript.ts +45 -0
- package/components/monaco/languages/yaml.ts +22 -0
- package/components/monaco/loader.ts +96 -0
- package/components/monaco/monaco.styl +30 -0
- package/components/monaco/nls.js +31 -0
- package/components/monaco/schema/problemconfig.ts +123 -0
- package/components/navigation/hamburgers.page.styl +87 -0
- package/components/navigation/nav-logo-small_dark.png +0 -0
- package/components/navigation/navigation.page.js +203 -0
- package/components/navigation/navigation.page.styl +211 -0
- package/components/notification/index.ts +105 -0
- package/components/notification/notification.page.js +14 -0
- package/components/notification/notification.page.styl +84 -0
- package/components/nprogress.page.styl +50 -0
- package/components/omnisearch/index.page.tsx +124 -0
- package/components/omnisearch/omnibar.page.styl +138 -0
- package/components/pager/pager.page.styl +57 -0
- package/components/preview/preview.page.ts +187 -0
- package/components/problem/create.page.js +12 -0
- package/components/problem/list.page.js +9 -0
- package/components/problem/rp.page.styl +4 -0
- package/components/problem/tag.page.styl +84 -0
- package/components/problemconfig/BasicForm.tsx +92 -0
- package/components/problemconfig/ProblemConfigEditor.tsx +170 -0
- package/components/problemconfig/ProblemConfigForm.tsx +140 -0
- package/components/problemconfig/ProblemConfigTree.tsx +163 -0
- package/components/problemconfig/ProblemType.tsx +165 -0
- package/components/problemconfig/index.tsx +91 -0
- package/components/problemconfig/reducer/config.ts +173 -0
- package/components/problemconfig/reducer/index.ts +11 -0
- package/components/problemconfig/reducer/testdata.ts +16 -0
- package/components/problemconfig/tree/AddTestcase.tsx +137 -0
- package/components/problemconfig/tree/SelectionManager.tsx +140 -0
- package/components/problemconfig/tree/SubtaskSettings.tsx +180 -0
- package/components/problemconfig/tree/Testcase.tsx +98 -0
- package/components/profile/backgrounds/1.jpg +0 -0
- package/components/profile/backgrounds/10.jpg +0 -0
- package/components/profile/backgrounds/11.jpg +0 -0
- package/components/profile/backgrounds/12.jpg +0 -0
- package/components/profile/backgrounds/13.jpg +0 -0
- package/components/profile/backgrounds/14.jpg +0 -0
- package/components/profile/backgrounds/15.jpg +0 -0
- package/components/profile/backgrounds/16.jpg +0 -0
- package/components/profile/backgrounds/17.jpg +0 -0
- package/components/profile/backgrounds/18.jpg +0 -0
- package/components/profile/backgrounds/19.jpg +0 -0
- package/components/profile/backgrounds/2.jpg +0 -0
- package/components/profile/backgrounds/20.jpg +0 -0
- package/components/profile/backgrounds/21.jpg +0 -0
- package/components/profile/backgrounds/3.jpg +0 -0
- package/components/profile/backgrounds/4.jpg +0 -0
- package/components/profile/backgrounds/5.jpg +0 -0
- package/components/profile/backgrounds/6.jpg +0 -0
- package/components/profile/backgrounds/7.jpg +0 -0
- package/components/profile/backgrounds/8.jpg +0 -0
- package/components/profile/backgrounds/9.jpg +0 -0
- package/components/profile/backgrounds/gen_thumbnails.sh +7 -0
- package/components/profile/backgrounds/thumbnail/1.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/10.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/11.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/12.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/13.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/14.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/15.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/16.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/17.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/18.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/19.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/2.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/20.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/21.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/3.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/4.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/5.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/6.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/7.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/8.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/9.jpg +0 -0
- package/components/profile/profile.page.styl +23 -0
- package/components/react/DomComponent.tsx +14 -0
- package/components/react/IconComponent.tsx +20 -0
- package/components/record/record.page.styl +26 -0
- package/components/rotator/index.js +75 -0
- package/components/rotator/rotator.page.styl +20 -0
- package/components/scratchpad/DataInput.page.styl +17 -0
- package/components/scratchpad/DataInputComponent.jsx +45 -0
- package/components/scratchpad/Editor.page.styl +13 -0
- package/components/scratchpad/Panel.page.styl +18 -0
- package/components/scratchpad/PanelButton.page.styl +15 -0
- package/components/scratchpad/PanelButtonComponent.jsx +19 -0
- package/components/scratchpad/PanelComponent.jsx +25 -0
- package/components/scratchpad/ScratchpadEditorContainer.tsx +137 -0
- package/components/scratchpad/ScratchpadPretestContainer.jsx +57 -0
- package/components/scratchpad/ScratchpadRecordsContainer.jsx +45 -0
- package/components/scratchpad/ScratchpadRecordsRowContainer.jsx +83 -0
- package/components/scratchpad/ScratchpadSettings.tsx +48 -0
- package/components/scratchpad/ScratchpadToolbarContainer.jsx +190 -0
- package/components/scratchpad/Tab.page.styl +24 -0
- package/components/scratchpad/Toolbar.page.styl +53 -0
- package/components/scratchpad/ToolbarComponent.jsx +85 -0
- package/components/scratchpad/index.tsx +132 -0
- package/components/scratchpad/reducers/editor.ts +24 -0
- package/components/scratchpad/reducers/index.ts +17 -0
- package/components/scratchpad/reducers/pretest.ts +34 -0
- package/components/scratchpad/reducers/records.ts +40 -0
- package/components/scratchpad/reducers/state.ts +10 -0
- package/components/scratchpad/reducers/ui.ts +152 -0
- package/components/scratchpad/scratchpad.page.styl +55 -0
- package/components/scratchpad/var.inc.styl +2 -0
- package/components/selectUser.tsx +16 -0
- package/components/signin/signInDialog.page.js +84 -0
- package/components/signin/signin_dialog.page.styl +57 -0
- package/components/smoothscroll/smoothscroll.page.js +44 -0
- package/components/socket/index.ts +68 -0
- package/components/star/star.page.styl +20 -0
- package/components/star/star.page.ts +58 -0
- package/components/sticky/sticky.page.js +66 -0
- package/components/tab/Tab.js +168 -0
- package/components/tab/tab.page.js +9 -0
- package/components/tab/tab.page.styl +105 -0
- package/components/tab/var.inc.styl +3 -0
- package/components/table/StyledTable.js +51 -0
- package/components/table/styledTable.page.js +8 -0
- package/components/table/table.page.styl +73 -0
- package/components/time/time.page.js +47 -0
- package/components/tooltip/Tooltip.js +49 -0
- package/components/tooltip/tooltip.page.js +29 -0
- package/components/tooltip/tooltip.page.styl +69 -0
- package/components/training/training.page.styl +25 -0
- package/components/upload.tsx +103 -0
- package/components/vote/vote.page.js +43 -0
- package/components/zipDownloader/index.ts +157 -0
- package/constant/domain.js +21 -0
- package/constant/message.js +5 -0
- package/constant/record.js +52 -0
- package/context.ts +11 -0
- package/entry.js +72 -0
- package/hydro.ts +112 -0
- package/index.ts +226 -0
- package/lazyload.ts +69 -0
- package/locales/en.yaml +71 -0
- package/locales/ko.yaml +823 -0
- package/locales/zh.yaml +1137 -0
- package/locales/zh_TW.yaml +1133 -0
- package/misc/Page.ts +49 -0
- package/misc/PageLoader.js +31 -0
- package/misc/float.styl +14 -0
- package/misc/grid.styl +1048 -0
- package/misc/immersive-background.jpg +0 -0
- package/misc/immersive-background@2x.jpg +0 -0
- package/misc/immersive.styl +23 -0
- package/misc/nothing.styl +13 -0
- package/misc/puzzled_twd2.svg +1 -0
- package/misc/section.styl +105 -0
- package/misc/slideout.styl +46 -0
- package/misc/structure.styl +158 -0
- package/misc/textalign.styl +11 -0
- package/misc/typography.styl +485 -0
- package/package.json +148 -0
- package/polyfill.ts +90 -0
- package/postcss.config.js +15 -0
- package/sentry.ts +26 -0
- package/service-worker.ts +265 -0
- package/setting.yaml +98 -0
- package/templates/about.html +14 -0
- package/templates/bsod.html +35 -0
- package/templates/components/comments_discussion.html +165 -0
- package/templates/components/comments_solution.html +171 -0
- package/templates/components/contest.html +12 -0
- package/templates/components/form.html +214 -0
- package/templates/components/home.html +20 -0
- package/templates/components/homework.html +8 -0
- package/templates/components/md_hint.html +39 -0
- package/templates/components/noscript_note.html +15 -0
- package/templates/components/nothing.html +6 -0
- package/templates/components/paginator.html +25 -0
- package/templates/components/problem.html +33 -0
- package/templates/components/record.html +21 -0
- package/templates/components/sidemenu.html +11 -0
- package/templates/components/user.html +49 -0
- package/templates/contest_balloon.html +48 -0
- package/templates/contest_clarification.html +103 -0
- package/templates/contest_detail.html +56 -0
- package/templates/contest_edit.html +259 -0
- package/templates/contest_main.html +146 -0
- package/templates/contest_manage.html +80 -0
- package/templates/contest_print.html +27 -0
- package/templates/contest_problemlist.html +231 -0
- package/templates/contest_scoreboard.html +46 -0
- package/templates/contest_scoreboard_download_html.html +71 -0
- package/templates/contest_user.html +47 -0
- package/templates/discussion_create.html +28 -0
- package/templates/discussion_detail.html +149 -0
- package/templates/discussion_edit.html +30 -0
- package/templates/discussion_main_or_node.html +47 -0
- package/templates/domain_base.html +26 -0
- package/templates/domain_create.html +55 -0
- package/templates/domain_dashboard.html +45 -0
- package/templates/domain_edit.html +6 -0
- package/templates/domain_group.html +51 -0
- package/templates/domain_join.html +47 -0
- package/templates/domain_join_applications.html +67 -0
- package/templates/domain_permission.html +66 -0
- package/templates/domain_role.html +71 -0
- package/templates/domain_user.html +86 -0
- package/templates/domain_user_raw.html +5 -0
- package/templates/error.html +25 -0
- package/templates/home_domain.html +64 -0
- package/templates/home_files.html +16 -0
- package/templates/home_messages.html +9 -0
- package/templates/home_security.html +224 -0
- package/templates/home_settings.html +21 -0
- package/templates/homework_detail.html +82 -0
- package/templates/homework_edit.html +138 -0
- package/templates/homework_files.html +24 -0
- package/templates/homework_main.html +76 -0
- package/templates/layout/basic.html +27 -0
- package/templates/layout/home_base.html +13 -0
- package/templates/layout/html5.html +74 -0
- package/templates/layout/immersive.html +22 -0
- package/templates/layout/mail.html +31 -0
- package/templates/layout/simple.html +4 -0
- package/templates/layout/wiki_base.html +16 -0
- package/templates/main.html +22 -0
- package/templates/manage_base.html +24 -0
- package/templates/manage_config.html +6 -0
- package/templates/manage_dashboard.html +27 -0
- package/templates/manage_script.html +56 -0
- package/templates/manage_setting.html +6 -0
- package/templates/manage_user_import.html +23 -0
- package/templates/manage_user_priv.html +76 -0
- package/templates/partials/category.html +19 -0
- package/templates/partials/contest.html +3 -0
- package/templates/partials/contest_balloon.html +37 -0
- package/templates/partials/contest_sidebar.html +150 -0
- package/templates/partials/contest_sidebar_management.html +56 -0
- package/templates/partials/contest_user.html +19 -0
- package/templates/partials/discussion_edit_form.html +45 -0
- package/templates/partials/discussion_list.html +50 -0
- package/templates/partials/discussion_nodes_widget.html +17 -0
- package/templates/partials/files.html +49 -0
- package/templates/partials/footer.html +108 -0
- package/templates/partials/hamburger.html +7 -0
- package/templates/partials/header_mobile.html +12 -0
- package/templates/partials/homepage/bulletin.html +7 -0
- package/templates/partials/homepage/contest.html +48 -0
- package/templates/partials/homepage/discussion.html +13 -0
- package/templates/partials/homepage/discussion_nodes.html +4 -0
- package/templates/partials/homepage/error.html +5 -0
- package/templates/partials/homepage/hitokoto.html +6 -0
- package/templates/partials/homepage/homework.html +45 -0
- package/templates/partials/homepage/problem_search.html +13 -0
- package/templates/partials/homepage/ranking.html +39 -0
- package/templates/partials/homepage/recent_problems.html +17 -0
- package/templates/partials/homepage/starred_problems.html +15 -0
- package/templates/partials/homepage/suggestion.html +34 -0
- package/templates/partials/homepage/training.html +50 -0
- package/templates/partials/homework.html +3 -0
- package/templates/partials/homework_default_penalty_rules.yaml +6 -0
- package/templates/partials/homework_sidebar.html +93 -0
- package/templates/partials/login_dialog.html +56 -0
- package/templates/partials/manage_user_priv.html +78 -0
- package/templates/partials/nav.html +138 -0
- package/templates/partials/problem-sidebar-information.html +25 -0
- package/templates/partials/problem.html +2 -0
- package/templates/partials/problem_category_dialog.html +43 -0
- package/templates/partials/problem_default.md +26 -0
- package/templates/partials/problem_description.html +33 -0
- package/templates/partials/problem_files.html +63 -0
- package/templates/partials/problem_list.html +68 -0
- package/templates/partials/problem_lucky.html +10 -0
- package/templates/partials/problem_sidebar.html +14 -0
- package/templates/partials/problem_sidebar_contest.html +43 -0
- package/templates/partials/problem_sidebar_homework.html +42 -0
- package/templates/partials/problem_sidebar_normal.html +152 -0
- package/templates/partials/problem_stat.html +3 -0
- package/templates/partials/scoreboard.html +79 -0
- package/templates/partials/setting.html +92 -0
- package/templates/partials/training_default.json +14 -0
- package/templates/partials/training_detail.html +153 -0
- package/templates/partials/user.html +2 -0
- package/templates/partials/user_detail/activity.html +18 -0
- package/templates/partials/user_detail/solution.html +29 -0
- package/templates/problem_config.html +39 -0
- package/templates/problem_detail.html +150 -0
- package/templates/problem_edit.html +111 -0
- package/templates/problem_files.html +91 -0
- package/templates/problem_hack.html +41 -0
- package/templates/problem_import.html +58 -0
- package/templates/problem_main.html +100 -0
- package/templates/problem_solution.html +55 -0
- package/templates/problem_statistics.html +96 -0
- package/templates/problem_submit.html +40 -0
- package/templates/ranking.html +81 -0
- package/templates/record_detail.html +134 -0
- package/templates/record_detail_status.html +93 -0
- package/templates/record_detail_summary.html +19 -0
- package/templates/record_main.html +142 -0
- package/templates/record_main_tr.html +35 -0
- package/templates/status.html +75 -0
- package/templates/training_detail.html +120 -0
- package/templates/training_edit.html +68 -0
- package/templates/training_files.html +64 -0
- package/templates/training_main.html +107 -0
- package/templates/user_changemail_mail.html +6 -0
- package/templates/user_changemail_mail_sent.html +9 -0
- package/templates/user_delete_pending.html +10 -0
- package/templates/user_detail.html +181 -0
- package/templates/user_login.html +46 -0
- package/templates/user_logout.html +13 -0
- package/templates/user_lostpass.html +27 -0
- package/templates/user_lostpass_mail.html +6 -0
- package/templates/user_lostpass_mail_sent.html +9 -0
- package/templates/user_lostpass_with_code.html +29 -0
- package/templates/user_register.html +22 -0
- package/templates/user_register_mail.html +6 -0
- package/templates/user_register_mail_sent.html +9 -0
- package/templates/user_register_with_code.html +35 -0
- package/templates/user_sudo.html +54 -0
- package/templates/user_sudo_redirect.html +18 -0
- package/templates/wiki_help.html +189 -0
- package/theme/bp6-compat.css +48 -0
- package/theme/dark.styl +397 -0
- package/theme/default.js +33 -0
- package/typed.d.ts +20 -0
- package/utils/base.ts +209 -0
- package/utils/base64.js +104 -0
- package/utils/db.ts +32 -0
- package/utils/index.ts +73 -0
- package/utils/loadReactRedux.ts +32 -0
- package/utils/mediaQuery.ts +13 -0
- package/utils/pjax.js +148 -0
- package/utils/slide.ts +57 -0
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
/* eslint-disable no-lone-blocks */
|
|
2
|
+
import $ from 'jquery';
|
|
3
|
+
import _ from 'lodash';
|
|
4
|
+
import moment from 'moment';
|
|
5
|
+
import { tpl } from 'vj/utils';
|
|
6
|
+
|
|
7
|
+
export default class Calendar {
|
|
8
|
+
constructor(events) {
|
|
9
|
+
this.$dom = $(tpl`
|
|
10
|
+
<div class="calendar">
|
|
11
|
+
<div class="calendar__header">
|
|
12
|
+
<button name="prev"><span class="icon icon-chevron_left"></span></button>
|
|
13
|
+
<h1 class="calendar__header__title"></h1>
|
|
14
|
+
<button name="next"><span class="icon icon-chevron_right"></span></button>
|
|
15
|
+
</div>
|
|
16
|
+
<div class="calendar__week-title">
|
|
17
|
+
<table>
|
|
18
|
+
<thead><tr>
|
|
19
|
+
<th>SUN</th>
|
|
20
|
+
<th>MON</th>
|
|
21
|
+
<th>TUE</th>
|
|
22
|
+
<th>WED</th>
|
|
23
|
+
<th>THU</th>
|
|
24
|
+
<th>FRI</th>
|
|
25
|
+
<th>SAT</th>
|
|
26
|
+
</tr></thead>
|
|
27
|
+
</table>
|
|
28
|
+
</div>
|
|
29
|
+
<div class="calendar__body-container"></div>
|
|
30
|
+
</div>
|
|
31
|
+
`);
|
|
32
|
+
this.events = events.map((ev) => ({
|
|
33
|
+
...ev,
|
|
34
|
+
beginAt: moment(ev.beginAt),
|
|
35
|
+
endAt: moment(ev.endAt),
|
|
36
|
+
maskFrom: ev.maskFrom ? moment(ev.maskFrom) : null,
|
|
37
|
+
}));
|
|
38
|
+
this.$dom.find('[name="prev"]').click(() => this.navToPrev());
|
|
39
|
+
this.$dom.find('[name="next"]').click(() => this.navToNext());
|
|
40
|
+
this.$lastBody = null;
|
|
41
|
+
this.navToToday();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
getDom() {
|
|
45
|
+
return this.$dom;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
navToToday() {
|
|
49
|
+
if (this.animating) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
this.current = moment().date(1);
|
|
53
|
+
this.update();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
navToNext() {
|
|
57
|
+
if (this.animating) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
this.current.add('months', 1);
|
|
61
|
+
this.update(1);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
navToPrev() {
|
|
65
|
+
if (this.animating) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
this.current.subtract('months', 1);
|
|
69
|
+
this.update(-1);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
update(direction = 0) {
|
|
73
|
+
this.updateHeader();
|
|
74
|
+
this.updateBody(direction);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
updateHeader() {
|
|
78
|
+
this.$dom.find('.calendar__header__title').text(this.current.format('MMMM YYYY'));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
async updateBody(direction) {
|
|
82
|
+
this.animating = true;
|
|
83
|
+
const $newBody = this.buildBody();
|
|
84
|
+
$newBody.appendTo(this.$dom.find('.calendar__body-container'));
|
|
85
|
+
if (this.$lastBody !== null) {
|
|
86
|
+
this.$lastBody
|
|
87
|
+
.addClass('exit')
|
|
88
|
+
.transition({
|
|
89
|
+
y: direction * 100,
|
|
90
|
+
opacity: 0,
|
|
91
|
+
}, {
|
|
92
|
+
duration: 500,
|
|
93
|
+
easing: 'easeOutCubic',
|
|
94
|
+
});
|
|
95
|
+
await $newBody
|
|
96
|
+
.css({
|
|
97
|
+
y: -direction * 100,
|
|
98
|
+
opacity: 0,
|
|
99
|
+
})
|
|
100
|
+
.transition({
|
|
101
|
+
y: 0,
|
|
102
|
+
opacity: 1,
|
|
103
|
+
}, {
|
|
104
|
+
duration: 500,
|
|
105
|
+
easing: 'easeOutCubic',
|
|
106
|
+
})
|
|
107
|
+
.promise();
|
|
108
|
+
this.$lastBody.remove();
|
|
109
|
+
}
|
|
110
|
+
this.$lastBody = $newBody;
|
|
111
|
+
this.animating = false;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
buildBody() {
|
|
115
|
+
const data = this.buildBodyData();
|
|
116
|
+
const $body = $('<div class="calendar__body"></div>');
|
|
117
|
+
data.forEach((week) => {
|
|
118
|
+
const $row = $(tpl`<div class="calendar__row">
|
|
119
|
+
<div class="calendar__row__bg"><table><tbody><tr></tr></tbody></table></div>
|
|
120
|
+
<div class="calendar__row__content"><table><thead><tr></tr></thead><tbody></tbody></table></div>
|
|
121
|
+
</div>`);
|
|
122
|
+
const $bgContainer = $row.find('.calendar__row__bg tr');
|
|
123
|
+
const $numContainer = $row.find('.calendar__row__content thead tr');
|
|
124
|
+
const $bannerContainer = $row.find('.calendar__row__content tbody');
|
|
125
|
+
week.days.forEach((day) => {
|
|
126
|
+
const isInactive = day.active ? '' : 'is-inactive';
|
|
127
|
+
const isCurrentDay = day.current ? 'is-current-day' : '';
|
|
128
|
+
const today = day.current ? ' (TODAY)' : '';
|
|
129
|
+
$bgContainer.append($('<td></td>').addClass(isInactive).addClass(isCurrentDay));
|
|
130
|
+
$numContainer.append($(tpl`<th>${day.date.format('D')}${today}</th>`).addClass(isInactive).addClass(isCurrentDay));
|
|
131
|
+
});
|
|
132
|
+
week.banners.forEach((banners) => {
|
|
133
|
+
const $tr = $('<tr/>');
|
|
134
|
+
banners.forEach((bannerSpan) => {
|
|
135
|
+
if (!bannerSpan.banner) {
|
|
136
|
+
$tr.append(tpl`<td colspan="${bannerSpan.span}"></td>`);
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const $cell = $(tpl`<td colspan="${bannerSpan.span}"></td>`);
|
|
140
|
+
const $banner = $(tpl`
|
|
141
|
+
<a
|
|
142
|
+
href="${bannerSpan.banner.event.link}"
|
|
143
|
+
class="calendar__banner color-${bannerSpan.banner.event.colorIndex}"
|
|
144
|
+
>${bannerSpan.banner.mask ? bannerSpan.banner.event.maskTitle : bannerSpan.banner.event.title}</a>
|
|
145
|
+
`);
|
|
146
|
+
if (bannerSpan.banner.mask) {
|
|
147
|
+
$banner.addClass('is-masked');
|
|
148
|
+
}
|
|
149
|
+
if (bannerSpan.banner.beginTrunc) {
|
|
150
|
+
$banner.addClass('is-trunc-begin');
|
|
151
|
+
} else if (bannerSpan.banner.beginSnap) {
|
|
152
|
+
$banner.addClass('is-snap-begin');
|
|
153
|
+
}
|
|
154
|
+
if (bannerSpan.banner.endTrunc) {
|
|
155
|
+
$banner.addClass('is-trunc-end');
|
|
156
|
+
} else if (bannerSpan.banner.endSnap) {
|
|
157
|
+
$banner.addClass('is-snap-end');
|
|
158
|
+
}
|
|
159
|
+
$cell.append($banner);
|
|
160
|
+
$tr.append($cell);
|
|
161
|
+
});
|
|
162
|
+
$bannerContainer.append($tr);
|
|
163
|
+
});
|
|
164
|
+
$body.append($row);
|
|
165
|
+
});
|
|
166
|
+
return $body;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
buildBodyData() {
|
|
170
|
+
const days = [];
|
|
171
|
+
{
|
|
172
|
+
// back fill
|
|
173
|
+
const base = this.current.clone();
|
|
174
|
+
const dayOfWeek = base.day();
|
|
175
|
+
if (dayOfWeek > 0) {
|
|
176
|
+
base.subtract(dayOfWeek + 1, 'days');
|
|
177
|
+
for (let i = dayOfWeek; i > 0; --i) {
|
|
178
|
+
days.push({
|
|
179
|
+
active: false,
|
|
180
|
+
date: base.add(1, 'days').clone(),
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
{
|
|
186
|
+
// current month
|
|
187
|
+
const base = this.current.clone();
|
|
188
|
+
while (base.month() === this.current.month()) {
|
|
189
|
+
days.push({
|
|
190
|
+
active: true,
|
|
191
|
+
date: base.clone(),
|
|
192
|
+
});
|
|
193
|
+
base.add(1, 'days');
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
{
|
|
197
|
+
// forward fill
|
|
198
|
+
const base = this.current.clone().add(1, 'months').subtract(1, 'days');
|
|
199
|
+
const dayOfWeek = base.day();
|
|
200
|
+
if (dayOfWeek < 6) {
|
|
201
|
+
for (let i = dayOfWeek; i < 6; ++i) {
|
|
202
|
+
days.push({
|
|
203
|
+
active: false,
|
|
204
|
+
date: base.add(1, 'days').clone(),
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const now = moment();
|
|
211
|
+
days.forEach((day) => {
|
|
212
|
+
day.current = day.date.isSame(now, 'day');
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
const daysByWeek = _.chunk(days, 7);
|
|
216
|
+
|
|
217
|
+
const numberOfWeeks = days.length / 7;
|
|
218
|
+
const bannersByWeek = _.fill(Array.from({ length: numberOfWeeks }), 1).map(() => []);
|
|
219
|
+
const beginDate = days[0].date.clone();
|
|
220
|
+
const endDate = _.last(days).date.clone();
|
|
221
|
+
|
|
222
|
+
// cut events by week to banners
|
|
223
|
+
this.events.forEach((ev) => {
|
|
224
|
+
if (ev.endAt.isBefore(ev.beginAt, 'day')) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
if (ev.endAt.isBefore(beginDate, 'day') || ev.beginAt.isAfter(endDate, 'day')) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
if (ev.beginAt.hour() >= 22) {
|
|
231
|
+
ev.beginAt.add(1, 'day').startOf('day');
|
|
232
|
+
}
|
|
233
|
+
if (ev.endAt.hour() <= 2) {
|
|
234
|
+
ev.endAt.subtract(1, 'day').endOf('day');
|
|
235
|
+
}
|
|
236
|
+
let [bannerBegin, bannerBeginTruncated] = [ev.beginAt.clone(), false];
|
|
237
|
+
if (bannerBegin.isBefore(beginDate, 'day')) {
|
|
238
|
+
[bannerBegin, bannerBeginTruncated] = [beginDate.clone(), true];
|
|
239
|
+
}
|
|
240
|
+
do {
|
|
241
|
+
const bannerEndMax = bannerBegin.clone().endOf('week');
|
|
242
|
+
let [bannerEnd, bannerEndTruncated] = [ev.endAt.clone(), false];
|
|
243
|
+
if (bannerEnd.isAfter(bannerEndMax, 'day')) {
|
|
244
|
+
[bannerEnd, bannerEndTruncated] = [bannerEndMax, true];
|
|
245
|
+
}
|
|
246
|
+
const weekIndex = bannerBegin.clone().startOf('day').diff(beginDate.clone().startOf('day'), 'week');
|
|
247
|
+
bannersByWeek[weekIndex].push({
|
|
248
|
+
beginAt: bannerBegin.startOf('day'),
|
|
249
|
+
beginTrunc: bannerBeginTruncated,
|
|
250
|
+
endAt: bannerEnd.endOf('day'),
|
|
251
|
+
endTrunc: bannerEndTruncated,
|
|
252
|
+
event: ev,
|
|
253
|
+
});
|
|
254
|
+
if (!bannerEndTruncated) {
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
[bannerBegin, bannerBeginTruncated] = [bannerEnd.clone().add(1, 'day'), true];
|
|
258
|
+
} while (!bannerBegin.isAfter(endDate, 'day'));
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
// layout banners
|
|
262
|
+
const layout = bannersByWeek
|
|
263
|
+
.map((banners) => _
|
|
264
|
+
.sortBy(banners, [
|
|
265
|
+
(banner) => banner.beginAt.valueOf(),
|
|
266
|
+
(banner) => (banner.beginTrunc ? 0 : 1), // truncated events first
|
|
267
|
+
(banner) => -banner.endAt.valueOf(), // long events first
|
|
268
|
+
]))
|
|
269
|
+
.map((banners) => {
|
|
270
|
+
const dayBitmap = _
|
|
271
|
+
.fill(Array.from({ length: 7 }), 1)
|
|
272
|
+
.map(() => []);
|
|
273
|
+
banners.forEach((banner) => {
|
|
274
|
+
const beginDay = banner.beginAt.day();
|
|
275
|
+
const endDay = banner.endAt.day();
|
|
276
|
+
// find available space
|
|
277
|
+
const vIndexMax = _.max(_
|
|
278
|
+
.range(beginDay, endDay + 1)
|
|
279
|
+
.map((day) => dayBitmap[day].length));
|
|
280
|
+
let vIndex = 0;
|
|
281
|
+
for (; vIndex < vIndexMax; ++vIndex) {
|
|
282
|
+
if (_.every(_
|
|
283
|
+
.range(beginDay, endDay + 1)
|
|
284
|
+
.map((day) => !dayBitmap[day][vIndex]), // eslint-disable-line
|
|
285
|
+
)) break;
|
|
286
|
+
}
|
|
287
|
+
// fill space
|
|
288
|
+
for (let i = beginDay; i <= endDay; ++i) {
|
|
289
|
+
dayBitmap[i][vIndex] = banner;
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
// merge adjacent cells and arrange banners by vertical index
|
|
293
|
+
const vMaxLength = _.max(_.range(0, 7).map((day) => dayBitmap[day].length));
|
|
294
|
+
const weekBanners = _
|
|
295
|
+
.fill(Array.from({ length: vMaxLength }), 1)
|
|
296
|
+
.map(() => []);
|
|
297
|
+
for (let vIndex = 0; vIndex < vMaxLength; ++vIndex) {
|
|
298
|
+
let last = { span: 1, banner: dayBitmap[0][vIndex] };
|
|
299
|
+
weekBanners[vIndex].push(last);
|
|
300
|
+
for (let day = 1; day < 7; ++day) {
|
|
301
|
+
const banner = dayBitmap[day][vIndex];
|
|
302
|
+
if (banner !== last.banner) {
|
|
303
|
+
last = { span: 1, banner };
|
|
304
|
+
weekBanners[vIndex].push(last);
|
|
305
|
+
} else {
|
|
306
|
+
last.span++;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
// cut banners by masked areas, scanning from left to right
|
|
311
|
+
weekBanners.forEach((bannerSpans) => {
|
|
312
|
+
for (let i = 0; i < bannerSpans.length; ++i) {
|
|
313
|
+
const { banner } = bannerSpans[i];
|
|
314
|
+
if (!banner) {
|
|
315
|
+
continue;
|
|
316
|
+
}
|
|
317
|
+
if (banner.mask) {
|
|
318
|
+
continue;
|
|
319
|
+
}
|
|
320
|
+
if (!banner.event.maskFrom) {
|
|
321
|
+
continue;
|
|
322
|
+
}
|
|
323
|
+
if (banner.event.maskFrom.isSame(banner.event.endAt)) {
|
|
324
|
+
// do not show masks if maskFrom === endAt
|
|
325
|
+
continue;
|
|
326
|
+
}
|
|
327
|
+
if (banner.event.endAt.isSame(banner.event.beginAt, 'day')) {
|
|
328
|
+
// do not show masks if endAt - beginAt <= 1 day
|
|
329
|
+
continue;
|
|
330
|
+
}
|
|
331
|
+
if (banner.event.maskFrom.isAfter(banner.endAt, 'day')) {
|
|
332
|
+
// we are not in the time region for masking
|
|
333
|
+
continue;
|
|
334
|
+
}
|
|
335
|
+
if (banner.event.maskFrom.isSameOrBefore(banner.beginAt, 'day')) {
|
|
336
|
+
// mask begins before this banner: replace current banner with masked banner
|
|
337
|
+
banner.mask = true;
|
|
338
|
+
} else {
|
|
339
|
+
// mask begins during this banner: cut current banner into two pieces
|
|
340
|
+
const newBanner = {
|
|
341
|
+
...banner,
|
|
342
|
+
beginAt: banner.event.maskFrom.clone(),
|
|
343
|
+
beginSnap: true,
|
|
344
|
+
beginTrunc: false,
|
|
345
|
+
mask: true,
|
|
346
|
+
};
|
|
347
|
+
const newBannerSpan = {
|
|
348
|
+
span: newBanner.endAt.day() - newBanner.beginAt.day() + 1,
|
|
349
|
+
banner: newBanner,
|
|
350
|
+
};
|
|
351
|
+
banner.endAt = banner.event.maskFrom.clone().subtract(1, 'day');
|
|
352
|
+
banner.endSnap = true;
|
|
353
|
+
bannerSpans[i].span -= newBannerSpan.span;
|
|
354
|
+
bannerSpans.splice(i + 1, 0, newBannerSpan);
|
|
355
|
+
i++;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
return weekBanners;
|
|
360
|
+
});
|
|
361
|
+
return daysByWeek
|
|
362
|
+
.map((daysInWeek, weekIndex) => ({
|
|
363
|
+
days: daysInWeek,
|
|
364
|
+
banners: layout[weekIndex],
|
|
365
|
+
}));
|
|
366
|
+
}
|
|
367
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import Clipboard from 'clipboard';
|
|
2
|
+
import Notification from 'vj/components/notification';
|
|
3
|
+
import { AutoloadPage } from 'vj/misc/Page';
|
|
4
|
+
import { base64, i18n, substitute } from 'vj/utils';
|
|
5
|
+
|
|
6
|
+
export default new AutoloadPage('clipboard', () => {
|
|
7
|
+
$('[data-copy]').get().forEach((el) => {
|
|
8
|
+
const data = $(el).attr('data-copy');
|
|
9
|
+
const decoded = base64.decode(data);
|
|
10
|
+
const clip = new Clipboard(el, { text: () => decoded });
|
|
11
|
+
clip.on('success', () => {
|
|
12
|
+
Notification.success(substitute(i18n('"{data}" copied to clipboard!'), { data: decoded }), 2000);
|
|
13
|
+
});
|
|
14
|
+
clip.on('error', () => {
|
|
15
|
+
Notification.error(substitute(i18n('Copy "{data}" failed :('), { data: decoded }));
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
$('[data-copylink]').each(function () {
|
|
19
|
+
const clip = new Clipboard(this, { text: () => new URL(this.dataset.copylink, document.location.href).toString() });
|
|
20
|
+
clip.on('success', () => Notification.success(i18n('Link copied to clipboard!')));
|
|
21
|
+
clip.on('error', () => Notification.error(i18n('Copy failed :(')));
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
.contest-type-tag
|
|
2
|
+
.contest-tag
|
|
3
|
+
.contest-tag-rated
|
|
4
|
+
font-size: rem($font-size-small)
|
|
5
|
+
display: inline-block
|
|
6
|
+
line-height: rem(22px)
|
|
7
|
+
padding: rem(0 10px)
|
|
8
|
+
vertical-align: middle
|
|
9
|
+
border-radius: rem(12px)
|
|
10
|
+
|
|
11
|
+
&:hover
|
|
12
|
+
text-decoration: none
|
|
13
|
+
color: #FFF !important
|
|
14
|
+
|
|
15
|
+
.contest-tag-rated
|
|
16
|
+
background: orange
|
|
17
|
+
color: #FFF
|
|
18
|
+
|
|
19
|
+
.icon
|
|
20
|
+
margin-right: rem(5px)
|
|
21
|
+
|
|
22
|
+
.contest-type-tag
|
|
23
|
+
&, &:visited
|
|
24
|
+
&, .supplementary &
|
|
25
|
+
color: #FFF
|
|
26
|
+
|
|
27
|
+
.icon
|
|
28
|
+
margin-right: rem(5px)
|
|
29
|
+
|
|
30
|
+
for key, value in $contest-color
|
|
31
|
+
.contest-type--{key} .contest-type-tag
|
|
32
|
+
background: value
|
|
33
|
+
|
|
34
|
+
&:hover
|
|
35
|
+
background: lighten(value, 20%)
|
|
36
|
+
|
|
37
|
+
.contest-tag
|
|
38
|
+
border: 1px solid $supplementary-border-color
|
|
39
|
+
|
|
40
|
+
&:hover
|
|
41
|
+
background: $primary-color
|
|
42
|
+
border-color: $primary-color
|
|
43
|
+
|
|
44
|
+
.contest-timer
|
|
45
|
+
position: fixed;
|
|
46
|
+
left: 0;
|
|
47
|
+
top: 48px;
|
|
48
|
+
z-index: 10000;
|
|
49
|
+
+mobile()
|
|
50
|
+
visibility: hidden !important;
|
|
51
|
+
|
|
52
|
+
.contest-problems
|
|
53
|
+
font-size: 0.9375rem;
|
|
54
|
+
font-weight: 400;
|
|
55
|
+
line-height: 1.375rem;
|
|
56
|
+
text-align: left;
|
|
57
|
+
box-sizing: border-box;
|
|
58
|
+
font-variant-ligatures: none!important;
|
|
59
|
+
display: grid;
|
|
60
|
+
grid-template-columns: repeat(auto-fit,minmax(1.5rem,1fr));
|
|
61
|
+
justify-content: center;
|
|
62
|
+
row-gap: 0.75rem;
|
|
63
|
+
column-gap: 0.5rem;
|
|
64
|
+
padding-bottom: 0.5rem;
|
|
65
|
+
width: rem(180px);
|
|
66
|
+
|
|
67
|
+
+mobile()
|
|
68
|
+
display: none;
|
|
69
|
+
|
|
70
|
+
> a
|
|
71
|
+
text-decoration: none;
|
|
72
|
+
background-color: transparent;
|
|
73
|
+
cursor: pointer;
|
|
74
|
+
display: flex;
|
|
75
|
+
height: 1.5rem;
|
|
76
|
+
width: 1.5rem;
|
|
77
|
+
align-items: center;
|
|
78
|
+
justify-content: space-around;
|
|
79
|
+
border-radius: 0.375rem;
|
|
80
|
+
position: relative;
|
|
81
|
+
transition: opacity 0.2s;
|
|
82
|
+
color: grey;
|
|
83
|
+
&.pass
|
|
84
|
+
color: green;
|
|
85
|
+
&:before
|
|
86
|
+
background: green;
|
|
87
|
+
&.fail
|
|
88
|
+
color: red;
|
|
89
|
+
&:before
|
|
90
|
+
background: red;
|
|
91
|
+
&.pending
|
|
92
|
+
color: cyan;
|
|
93
|
+
&:before
|
|
94
|
+
background: cyan;
|
|
95
|
+
|
|
96
|
+
&:after
|
|
97
|
+
content: '';
|
|
98
|
+
position: absolute;
|
|
99
|
+
top: 0;
|
|
100
|
+
right: 0;
|
|
101
|
+
bottom: 0;
|
|
102
|
+
left: 0;
|
|
103
|
+
box-sizing: border-box;
|
|
104
|
+
border: 2px solid currentColor;
|
|
105
|
+
border-radius: 6px;
|
|
106
|
+
opacity: 0.3;
|
|
107
|
+
|
|
108
|
+
&.active:after
|
|
109
|
+
border: 3px solid cyan;
|
|
110
|
+
|
|
111
|
+
&:before
|
|
112
|
+
opacity: 0.5;
|
|
113
|
+
|
|
114
|
+
&.pass, &.fail
|
|
115
|
+
&:not(:hover) .id
|
|
116
|
+
display: none;
|
|
117
|
+
|
|
118
|
+
&:hover .icon
|
|
119
|
+
display: none;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import $ from 'jquery';
|
|
2
|
+
import Notification from 'vj/components/notification';
|
|
3
|
+
import { AutoloadPage } from 'vj/misc/Page';
|
|
4
|
+
import { delay, i18n, request } from 'vj/utils';
|
|
5
|
+
|
|
6
|
+
const contestPage = new AutoloadPage('contestPage', () => {
|
|
7
|
+
$('[data-contest-code]').on('click', (ev) => {
|
|
8
|
+
ev.preventDefault();
|
|
9
|
+
// eslint-disable-next-line no-alert
|
|
10
|
+
const code = prompt(i18n('Invitation code:'));
|
|
11
|
+
request.post('', {
|
|
12
|
+
operation: 'attend',
|
|
13
|
+
code,
|
|
14
|
+
}).then(() => {
|
|
15
|
+
Notification.success(i18n('Successfully attended'));
|
|
16
|
+
delay(1000).then(() => window.location.reload());
|
|
17
|
+
}).catch((e) => {
|
|
18
|
+
Notification.error(e.message || e);
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export default contestPage;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
.contest-sidebar__bg
|
|
2
|
+
display: block
|
|
3
|
+
background: #67AABB url(problem-contest-bg.png) right top no-repeat
|
|
4
|
+
color: #FFF !important
|
|
5
|
+
font-size: rem($font-size)
|
|
6
|
+
padding: rem(20px 0)
|
|
7
|
+
|
|
8
|
+
+retina()
|
|
9
|
+
background-image: url(problem-contest-bg@2x.png)
|
|
10
|
+
background-size: 131px 150px
|
|
11
|
+
|
|
12
|
+
h1
|
|
13
|
+
font-size: rem($font-size-title)
|
|
14
|
+
color: #FFF
|
|
15
|
+
text-shadow: 0 1px 3px rgba(#000, 0.5)
|
|
16
|
+
|
|
17
|
+
&:hover
|
|
18
|
+
text-decoration: none
|
|
19
|
+
|
|
20
|
+
.contest-sidebar__status
|
|
21
|
+
margin-top: rem(20px)
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { CustomSelectAutoComplete } from '@hydrooj/components';
|
|
2
|
+
import $ from 'jquery';
|
|
3
|
+
import { AutoloadPage } from 'vj/misc/Page';
|
|
4
|
+
import { i18n, tpl } from 'vj/utils';
|
|
5
|
+
import { ActionDialog } from './dialog';
|
|
6
|
+
|
|
7
|
+
async function getAvailableFonts() {
|
|
8
|
+
const fonts = await (window as any).queryLocalFonts();
|
|
9
|
+
const result = {};
|
|
10
|
+
for (const font of fonts) result[font.family] ||= font.fullName;
|
|
11
|
+
return Object.entries(result).map(([family, fullName]) => ({
|
|
12
|
+
id: family,
|
|
13
|
+
name: family === fullName ? family : `${fullName} (${family})`,
|
|
14
|
+
fullName,
|
|
15
|
+
}));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const customFont = localStorage.getItem('customFont');
|
|
19
|
+
const customCodeFont = localStorage.getItem('customCodeFont');
|
|
20
|
+
|
|
21
|
+
export default new AutoloadPage('customFont', (pageName) => {
|
|
22
|
+
let dialog;
|
|
23
|
+
let selection = '';
|
|
24
|
+
let handle = null;
|
|
25
|
+
|
|
26
|
+
async function showDialog(saveKey: string) {
|
|
27
|
+
if (!dialog) {
|
|
28
|
+
const fonts = await getAvailableFonts();
|
|
29
|
+
dialog = new ActionDialog({
|
|
30
|
+
$body: $(tpl(
|
|
31
|
+
<CustomSelectAutoComplete
|
|
32
|
+
ref={(el) => { handle = el; }}
|
|
33
|
+
allowEmptyQuery={false}
|
|
34
|
+
data={fonts}
|
|
35
|
+
renderItem={(item) => <div style={{ fontFamily: item.id }}>{item.name}</div>}
|
|
36
|
+
/>, true,
|
|
37
|
+
)),
|
|
38
|
+
onDispatch: (action) => {
|
|
39
|
+
selection = handle.getSelectedItems()?.[0]?.id;
|
|
40
|
+
return action !== 'ok' || selection;
|
|
41
|
+
},
|
|
42
|
+
cancelByEsc: false,
|
|
43
|
+
cancelByClickingBack: false,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
dialog.open().then((action) => {
|
|
47
|
+
console.log(action, saveKey, selection);
|
|
48
|
+
if (action === 'ok' && selection) {
|
|
49
|
+
localStorage.setItem(saveKey, selection);
|
|
50
|
+
window.location.reload();
|
|
51
|
+
} else {
|
|
52
|
+
localStorage.removeItem(saveKey);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function FontSelectButton(props: { saveKey: string, label: string, value: string }) {
|
|
58
|
+
return <div className="medium-6 columns"><label>
|
|
59
|
+
{i18n(props.label)}
|
|
60
|
+
<div><button className="button inline" data-show-font-dialog={props.saveKey}>
|
|
61
|
+
{props.value ? i18n('Using custom font: {0}', props.value) : i18n('Find custom font')}
|
|
62
|
+
</button></div>
|
|
63
|
+
</label></div>;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (pageName === 'home_preference' && 'queryLocalFonts' in window) {
|
|
67
|
+
$('[name="form_item_fontFamily"]').parent().parent().parent().append($(tpl(
|
|
68
|
+
<FontSelectButton saveKey="customFont" label="Select Custom Font" value={customFont} />,
|
|
69
|
+
)));
|
|
70
|
+
$('[name="form_item_codeFontFamily"]').parent().parent().parent().append($(tpl(
|
|
71
|
+
<FontSelectButton saveKey="customCodeFont" label="Select Custom Code Font" value={customCodeFont} />,
|
|
72
|
+
)));
|
|
73
|
+
$(document).on('click', '[data-show-font-dialog]', (ev) => {
|
|
74
|
+
ev.preventDefault();
|
|
75
|
+
showDialog(ev.target.dataset.showFontDialog);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}, () => {
|
|
79
|
+
const fontBlock = Array.from(document.head.children).find((el) => el.tagName === 'STYLE' && el.textContent?.includes('--code-font-family'));
|
|
80
|
+
if (fontBlock) {
|
|
81
|
+
if (customFont) {
|
|
82
|
+
fontBlock.textContent = fontBlock.textContent?.replace(/--font-family:/, `--font-family: "${customFont}", `);
|
|
83
|
+
}
|
|
84
|
+
if (customCodeFont) {
|
|
85
|
+
fontBlock.textContent = fontBlock.textContent?.replace(/--code-font-family:/, `--code-font-family: "${customCodeFont}", `);
|
|
86
|
+
}
|
|
87
|
+
} else {
|
|
88
|
+
console.warn('No font style block found');
|
|
89
|
+
}
|
|
90
|
+
});
|