@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
package/utils/base64.js
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
const Base64 = {
|
|
2
|
+
_keyStr: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',
|
|
3
|
+
|
|
4
|
+
encode(input) {
|
|
5
|
+
let output = '';
|
|
6
|
+
let chr1;
|
|
7
|
+
let chr2;
|
|
8
|
+
let chr3;
|
|
9
|
+
let enc1;
|
|
10
|
+
let enc2;
|
|
11
|
+
let enc3;
|
|
12
|
+
let enc4;
|
|
13
|
+
let i = 0;
|
|
14
|
+
input = Base64._utf8Encode(input);
|
|
15
|
+
while (i < input.length) {
|
|
16
|
+
chr1 = input.charCodeAt(i++);
|
|
17
|
+
chr2 = input.charCodeAt(i++);
|
|
18
|
+
chr3 = input.charCodeAt(i++);
|
|
19
|
+
enc1 = chr1 >> 2;
|
|
20
|
+
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
|
|
21
|
+
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
|
|
22
|
+
enc4 = chr3 & 63;
|
|
23
|
+
if (Number.isNaN(chr2)) enc3 = enc4 = 64;
|
|
24
|
+
else if (Number.isNaN(chr3)) enc4 = 64;
|
|
25
|
+
output = output
|
|
26
|
+
+ this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2)
|
|
27
|
+
+ this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
|
|
28
|
+
}
|
|
29
|
+
return output;
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
decode(input) {
|
|
33
|
+
let output = '';
|
|
34
|
+
let chr1;
|
|
35
|
+
let chr2;
|
|
36
|
+
let chr3;
|
|
37
|
+
let enc1;
|
|
38
|
+
let enc2;
|
|
39
|
+
let enc3;
|
|
40
|
+
let enc4;
|
|
41
|
+
let i = 0;
|
|
42
|
+
input = input.replace(/[^A-Za-z0-9+/=]/g, '');
|
|
43
|
+
while (i < input.length) {
|
|
44
|
+
enc1 = this._keyStr.indexOf(input.charAt(i++));
|
|
45
|
+
enc2 = this._keyStr.indexOf(input.charAt(i++));
|
|
46
|
+
enc3 = this._keyStr.indexOf(input.charAt(i++));
|
|
47
|
+
enc4 = this._keyStr.indexOf(input.charAt(i++));
|
|
48
|
+
chr1 = (enc1 << 2) | (enc2 >> 4);
|
|
49
|
+
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
|
|
50
|
+
chr3 = ((enc3 & 3) << 6) | enc4;
|
|
51
|
+
output += String.fromCharCode(chr1);
|
|
52
|
+
if (enc3 !== 64) output += String.fromCharCode(chr2);
|
|
53
|
+
if (enc4 !== 64) output += String.fromCharCode(chr3);
|
|
54
|
+
}
|
|
55
|
+
output = Base64._utf8Decode(output);
|
|
56
|
+
return output;
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
_utf8Encode(string) {
|
|
60
|
+
string = string.replace(/\r\n/g, '\n');
|
|
61
|
+
let utftext = '';
|
|
62
|
+
for (let n = 0; n < string.length; n++) {
|
|
63
|
+
const c = string.charCodeAt(n);
|
|
64
|
+
if (c < 128) {
|
|
65
|
+
utftext += String.fromCharCode(c);
|
|
66
|
+
} else if ((c > 127) && (c < 2048)) {
|
|
67
|
+
utftext += String.fromCharCode((c >> 6) | 192);
|
|
68
|
+
utftext += String.fromCharCode((c & 63) | 128);
|
|
69
|
+
} else {
|
|
70
|
+
utftext += String.fromCharCode((c >> 12) | 224);
|
|
71
|
+
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
|
|
72
|
+
utftext += String.fromCharCode((c & 63) | 128);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return utftext;
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
_utf8Decode(utftext) {
|
|
79
|
+
let string = '';
|
|
80
|
+
let i = 0;
|
|
81
|
+
let c = 0;
|
|
82
|
+
let c2 = 0;
|
|
83
|
+
let c3 = 0;
|
|
84
|
+
while (i < utftext.length) {
|
|
85
|
+
c = utftext.charCodeAt(i);
|
|
86
|
+
if (c < 128) {
|
|
87
|
+
string += String.fromCharCode(c);
|
|
88
|
+
i++;
|
|
89
|
+
} else if ((c > 191) && (c < 224)) {
|
|
90
|
+
c2 = utftext.charCodeAt(i + 1);
|
|
91
|
+
string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
|
|
92
|
+
i += 2;
|
|
93
|
+
} else {
|
|
94
|
+
c2 = utftext.charCodeAt(i + 1);
|
|
95
|
+
c3 = utftext.charCodeAt(i + 2);
|
|
96
|
+
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
|
|
97
|
+
i += 3;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return string;
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export default Base64;
|
package/utils/db.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { openDB as _open } from 'idb';
|
|
2
|
+
import { alert } from 'vj/components/dialog';
|
|
3
|
+
|
|
4
|
+
export const openDB = _open('hydro', 1, {
|
|
5
|
+
upgrade(db, oldVersion) {
|
|
6
|
+
if (oldVersion < 1) {
|
|
7
|
+
const solutionStore = db.createObjectStore('solutions', { keyPath: 'id' });
|
|
8
|
+
db.createObjectStore('scoreboard-star', { keyPath: 'id' });
|
|
9
|
+
const keys = Object.keys(localStorage);
|
|
10
|
+
for (const key of keys) {
|
|
11
|
+
if (key.endsWith('#objective')) {
|
|
12
|
+
const value = localStorage.getItem(key);
|
|
13
|
+
if (value) solutionStore.put({ id: key, value });
|
|
14
|
+
localStorage.removeItem(key);
|
|
15
|
+
}
|
|
16
|
+
if (key.startsWith('scoreboard-star/')) localStorage.removeItem(key);
|
|
17
|
+
if (/^0\.\d+$/.test(key)) localStorage.removeItem(key);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
blocked(currentVersion, blockedVersion) {
|
|
22
|
+
console.error('IDB Blocked by version', blockedVersion, 'want', currentVersion);
|
|
23
|
+
alert('Some other opened tabs locked the database. Please close them.');
|
|
24
|
+
},
|
|
25
|
+
blocking(currentVersion, blockedVersion) {
|
|
26
|
+
console.error('IDB Blocking version', blockedVersion);
|
|
27
|
+
alert('Please close or refresh this tab to perform the upgrade.');
|
|
28
|
+
},
|
|
29
|
+
terminated() {
|
|
30
|
+
console.error('IDB Terminated');
|
|
31
|
+
},
|
|
32
|
+
});
|
package/utils/index.ts
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import 'streamsaver/examples/zip-stream';
|
|
2
|
+
|
|
3
|
+
import { request } from './base';
|
|
4
|
+
|
|
5
|
+
export async function api(method: string, args: Record<string, any>, projection: any) {
|
|
6
|
+
const res = await request.post(`/d/${UiContext.domainId}/api/${encodeURIComponent(method)}`, { args, projection });
|
|
7
|
+
if (res.error) throw new Error(res.error);
|
|
8
|
+
return res;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function getAvailableLangs(langsList?: string[]) {
|
|
12
|
+
const prefixes = new Set(Object.keys(window.LANGS).filter((i) => i.includes('.')).map((i) => i.split('.')[0]));
|
|
13
|
+
const Langs = {};
|
|
14
|
+
for (const key in window.LANGS) {
|
|
15
|
+
if (prefixes.has(key)) continue;
|
|
16
|
+
if ((langsList instanceof Array) && !langsList.includes(key)) continue;
|
|
17
|
+
if (window.LANGS[key].hidden && !langsList?.includes(key)) continue;
|
|
18
|
+
if (window.LANGS[key].disabled) continue;
|
|
19
|
+
Langs[key] = window.LANGS[key];
|
|
20
|
+
}
|
|
21
|
+
return Langs;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const createZipStream = (window as any).ZIP;
|
|
25
|
+
|
|
26
|
+
export function createZipBlob(underlyingSource) {
|
|
27
|
+
return new Response(createZipStream(underlyingSource)).blob();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export async function pipeStream(read, write, abort) {
|
|
31
|
+
if (window.WritableStream && read.pipeTo) {
|
|
32
|
+
const abortController = new AbortController();
|
|
33
|
+
if (abort) abort.abort = abortController.abort.bind(abortController);
|
|
34
|
+
await read.pipeTo(write, abortController);
|
|
35
|
+
} else {
|
|
36
|
+
const writer = write.getWriter();
|
|
37
|
+
if (abort) abort.abort = writer.abort.bind(writer);
|
|
38
|
+
const reader = read.getReader();
|
|
39
|
+
while (1) {
|
|
40
|
+
const readResult = await reader.read();
|
|
41
|
+
if (readResult.done) {
|
|
42
|
+
writer.close();
|
|
43
|
+
break;
|
|
44
|
+
} else writer.write(readResult.value);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// https://github.com/andrasq/node-mongoid-js/blob/master/mongoid.js
|
|
50
|
+
export function mongoId(idstring: string) {
|
|
51
|
+
if (typeof idstring !== 'string') idstring = String(idstring);
|
|
52
|
+
return {
|
|
53
|
+
timestamp: Number.parseInt(idstring.slice(0, 0 + 8), 16),
|
|
54
|
+
machineid: Number.parseInt(idstring.slice(8, 8 + 6), 16),
|
|
55
|
+
pid: Number.parseInt(idstring.slice(14, 14 + 4), 16),
|
|
56
|
+
sequence: Number.parseInt(idstring.slice(18, 18 + 6), 16),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function emulateAnchorClick(ev: KeyboardEvent, targetUrl: string, alwaysOpenInNewWindow = false) {
|
|
61
|
+
let openInNewWindow;
|
|
62
|
+
if (alwaysOpenInNewWindow) openInNewWindow = true;
|
|
63
|
+
else openInNewWindow = (ev.ctrlKey || ev.shiftKey || ev.metaKey);
|
|
64
|
+
if (openInNewWindow) window.open(targetUrl);
|
|
65
|
+
else window.location.href = targetUrl;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export * from './base';
|
|
69
|
+
export { default as base64 } from './base64';
|
|
70
|
+
export { default as loadReactRedux } from './loadReactRedux';
|
|
71
|
+
export * as mediaQuery from './mediaQuery';
|
|
72
|
+
export { default as pjax } from './pjax';
|
|
73
|
+
export * from './slide';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { createRoot } from 'react-dom/client';
|
|
3
|
+
import type { Action, Reducer, UnknownAction } from 'redux';
|
|
4
|
+
|
|
5
|
+
export default async function loadReactRedux<S, A extends Action = UnknownAction>(storeReducer: Reducer<S, A>) {
|
|
6
|
+
const [{ Provider }, { createStore, applyMiddleware }, { thunk: reduxThunk }, { default: reduxPromise }] = await Promise.all([
|
|
7
|
+
import('react-redux'),
|
|
8
|
+
import('redux'),
|
|
9
|
+
import('redux-thunk'),
|
|
10
|
+
import('redux-promise-middleware'),
|
|
11
|
+
]);
|
|
12
|
+
const reduxMiddlewares = [];
|
|
13
|
+
reduxMiddlewares.push(reduxThunk);
|
|
14
|
+
reduxMiddlewares.push(reduxPromise);
|
|
15
|
+
|
|
16
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
17
|
+
const { createLogger } = await import('redux-logger');
|
|
18
|
+
reduxMiddlewares.push(createLogger({
|
|
19
|
+
collapsed: true,
|
|
20
|
+
duration: true,
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const store = createStore(storeReducer, applyMiddleware(...reduxMiddlewares));
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
React,
|
|
28
|
+
createRoot,
|
|
29
|
+
Provider,
|
|
30
|
+
store,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function isAbove(width) {
|
|
2
|
+
if (window.matchMedia) {
|
|
3
|
+
return window.matchMedia(`(min-width: ${width}px)`).matches;
|
|
4
|
+
}
|
|
5
|
+
return window.innerWidth >= width;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function isBelow(width) {
|
|
9
|
+
if (window.matchMedia) {
|
|
10
|
+
return window.matchMedia(`(max-width: ${width}px)`).matches;
|
|
11
|
+
}
|
|
12
|
+
return window.innerWidth <= width;
|
|
13
|
+
}
|
package/utils/pjax.js
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
// Modified from jquery-pjax to support multiple fragments and jQuery 3.0
|
|
2
|
+
// https://github.com/defunkt/jquery-pjax/blob/master/jquery.pjax.js
|
|
3
|
+
|
|
4
|
+
import $ from 'jquery';
|
|
5
|
+
import { nanoid } from 'nanoid';
|
|
6
|
+
import NProgress from 'nprogress';
|
|
7
|
+
import Notification from 'vj/components/notification';
|
|
8
|
+
import { request, withTransitionCallback } from './base';
|
|
9
|
+
|
|
10
|
+
const pjax = {};
|
|
11
|
+
|
|
12
|
+
let currentState = null;
|
|
13
|
+
let currentXHR = null;
|
|
14
|
+
let inProgress = 0;
|
|
15
|
+
|
|
16
|
+
function cancelLastXHR() {
|
|
17
|
+
if (currentXHR && currentXHR.readyState < 4) {
|
|
18
|
+
currentXHR.abort();
|
|
19
|
+
currentXHR = null;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function canonicalizeUrl(url) {
|
|
24
|
+
const a = document.createElement('a');
|
|
25
|
+
a.href = url;
|
|
26
|
+
return a.href;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function extractMetaData(requestOption, response) {
|
|
30
|
+
const metaData = {
|
|
31
|
+
title: response.title ? response.title : document.title,
|
|
32
|
+
url: response.url ? response.url : requestOption.url,
|
|
33
|
+
};
|
|
34
|
+
metaData.url = canonicalizeUrl(metaData.url);
|
|
35
|
+
return metaData;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function incProgress() {
|
|
39
|
+
inProgress++;
|
|
40
|
+
NProgress.done();
|
|
41
|
+
NProgress.start();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function decProgress() {
|
|
45
|
+
inProgress--;
|
|
46
|
+
if (inProgress === 0) {
|
|
47
|
+
NProgress.done();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
pjax.request = async (opt) => {
|
|
52
|
+
if (typeof opt === 'string') opt = { url: opt };
|
|
53
|
+
const options = {
|
|
54
|
+
method: 'get',
|
|
55
|
+
push: true,
|
|
56
|
+
...opt,
|
|
57
|
+
};
|
|
58
|
+
if (!currentState) {
|
|
59
|
+
// create initial state
|
|
60
|
+
currentState = {
|
|
61
|
+
id: nanoid(),
|
|
62
|
+
options: {
|
|
63
|
+
url: window.location.href,
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
window.history.replaceState(currentState, null);
|
|
67
|
+
}
|
|
68
|
+
cancelLastXHR();
|
|
69
|
+
if (options.push) {
|
|
70
|
+
// in popstate, options.push === false
|
|
71
|
+
window.history.pushState(null, null, options.url);
|
|
72
|
+
}
|
|
73
|
+
incProgress();
|
|
74
|
+
try {
|
|
75
|
+
const params = {
|
|
76
|
+
beforeSend(xhr) {
|
|
77
|
+
currentXHR = xhr;
|
|
78
|
+
},
|
|
79
|
+
...options,
|
|
80
|
+
};
|
|
81
|
+
if (params.url && params.url.includes('?')) params.url += '&pjax=1';
|
|
82
|
+
else params.url = `${params.url || ''}?pjax=1`;
|
|
83
|
+
const data = await request.ajax(params);
|
|
84
|
+
const meta = extractMetaData(options, data);
|
|
85
|
+
currentState = {
|
|
86
|
+
id: nanoid(),
|
|
87
|
+
options: opt,
|
|
88
|
+
};
|
|
89
|
+
if (options.push) {
|
|
90
|
+
window.history.replaceState(currentState, null, meta.url);
|
|
91
|
+
}
|
|
92
|
+
if (meta.title) document.title = meta.title;
|
|
93
|
+
for (const fragment of data.fragments) {
|
|
94
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
95
|
+
if (fragment.html === undefined) {
|
|
96
|
+
throw new Error("Fragement should contain 'html'");
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const $el = $(fragment.html.trim());
|
|
100
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
101
|
+
if ($el.length === 0) {
|
|
102
|
+
throw new Error("Unable to build elements from fragment 'html'");
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
const fragmentId = $el.attr('data-fragment-id');
|
|
106
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
107
|
+
if (!fragmentId) {
|
|
108
|
+
throw new Error("Unable to extract fragment id from fragment 'html'");
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const $target = $(`[data-fragment-id="${fragmentId}"]`);
|
|
112
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
113
|
+
if ($target.length === 0) {
|
|
114
|
+
throw new Error('Unable to get target fragment from fragment id');
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
$target.trigger('vjContentRemove');
|
|
118
|
+
await withTransitionCallback(() => {
|
|
119
|
+
$target.replaceWith($el);
|
|
120
|
+
$el.trigger('vjContentNew');
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
} catch (err) {
|
|
124
|
+
if (!err.aborted) {
|
|
125
|
+
Notification.error(err.message);
|
|
126
|
+
console.error(err);
|
|
127
|
+
}
|
|
128
|
+
} finally {
|
|
129
|
+
decProgress();
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
function handlePopState(ev) {
|
|
134
|
+
if (!ev.originalEvent) return;
|
|
135
|
+
const { state } = ev.originalEvent;
|
|
136
|
+
if (!state) return;
|
|
137
|
+
if (!state.id || (currentState && state.id === currentState.id)) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
pjax.request({
|
|
141
|
+
...state.options,
|
|
142
|
+
push: false,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
$(window).on('popstate', handlePopState);
|
|
147
|
+
|
|
148
|
+
export default pjax;
|
package/utils/slide.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import 'jquery.easing';
|
|
2
|
+
|
|
3
|
+
export async function slideDown($element, duration, fromCss = {}, toCss = {}) {
|
|
4
|
+
const originalStyl = $element.attr('style') || '';
|
|
5
|
+
$element.css({
|
|
6
|
+
position: 'absolute',
|
|
7
|
+
visibility: 'none',
|
|
8
|
+
display: 'block',
|
|
9
|
+
});
|
|
10
|
+
const height = $element.outerHeight();
|
|
11
|
+
$element.attr('style', originalStyl);
|
|
12
|
+
$element.css({
|
|
13
|
+
height: 0,
|
|
14
|
+
overflow: 'hidden',
|
|
15
|
+
display: 'block',
|
|
16
|
+
...fromCss,
|
|
17
|
+
});
|
|
18
|
+
$element.height();
|
|
19
|
+
await $element
|
|
20
|
+
.transition({
|
|
21
|
+
height,
|
|
22
|
+
...toCss,
|
|
23
|
+
}, {
|
|
24
|
+
duration,
|
|
25
|
+
easing: 'easeOutCubic',
|
|
26
|
+
})
|
|
27
|
+
.promise();
|
|
28
|
+
$element.attr('style', originalStyl);
|
|
29
|
+
$element.css({
|
|
30
|
+
display: 'block',
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export async function slideUp($element, duration, fromCss = {}, toCss = {}) {
|
|
35
|
+
const originalStyl = $element.attr('style') || '';
|
|
36
|
+
const height = $element.outerHeight();
|
|
37
|
+
$element.css({
|
|
38
|
+
height,
|
|
39
|
+
overflow: 'hidden',
|
|
40
|
+
display: 'block',
|
|
41
|
+
...fromCss,
|
|
42
|
+
});
|
|
43
|
+
$element.height();
|
|
44
|
+
await $element
|
|
45
|
+
.transition({
|
|
46
|
+
height: 0,
|
|
47
|
+
...toCss,
|
|
48
|
+
}, {
|
|
49
|
+
duration,
|
|
50
|
+
easing: 'easeOutCubic',
|
|
51
|
+
})
|
|
52
|
+
.promise();
|
|
53
|
+
$element.attr('style', originalStyl);
|
|
54
|
+
$element.css({
|
|
55
|
+
display: 'none',
|
|
56
|
+
});
|
|
57
|
+
}
|