@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,111 @@
|
|
|
1
|
+
export default `\
|
|
2
|
+
#include <world.h>
|
|
3
|
+
|
|
4
|
+
int main() {
|
|
5
|
+
// ~ Switch on the power line / Remember to put on PROTECTION ~
|
|
6
|
+
world.start();
|
|
7
|
+
|
|
8
|
+
// ~ Lay down your pieces / And let's begin OBJECT CREATION ~
|
|
9
|
+
// ~ Fill in my data / Parameters INITIALIZATION ~
|
|
10
|
+
auto *me = World::createObject("me", world, parameters...);
|
|
11
|
+
auto &you = *World::createObject("you", world, parameters...);
|
|
12
|
+
|
|
13
|
+
// ~ Set up our new world ~
|
|
14
|
+
auto &world = World{me, you};
|
|
15
|
+
|
|
16
|
+
// ~ And let's begin the SIMULATION ~
|
|
17
|
+
world.beginSimulation();
|
|
18
|
+
|
|
19
|
+
switch (me->type) {
|
|
20
|
+
case Object::SET_OF_POINTS:
|
|
21
|
+
// ~ If I'm a set of points / Then I will give you my DIMENSION ~
|
|
22
|
+
you << dynamic_cast<Set<Point>*>(me)->getDimension();
|
|
23
|
+
break;
|
|
24
|
+
|
|
25
|
+
case Object::CIRCLE:
|
|
26
|
+
// ~ If I'm a circle / Then I will give you my CIRCUMFERENCE ~
|
|
27
|
+
you << dynamic_cast<Circle * >(me)->getCircumference();
|
|
28
|
+
break;
|
|
29
|
+
|
|
30
|
+
case Object::SINE_WAVE:
|
|
31
|
+
|
|
32
|
+
// ~ If I'm a sine wave / Then you can sit on all my TANGENTS ~
|
|
33
|
+
for (auto &tangent : dynamic_cast<SineWave *>(me)->getTangents())
|
|
34
|
+
you.sitOn(tangent);
|
|
35
|
+
|
|
36
|
+
break;
|
|
37
|
+
|
|
38
|
+
default:
|
|
39
|
+
// ~ If I approach infinity / Then you can be my LIMITATIONS ~
|
|
40
|
+
you.limit() >> me->limit();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// ~ Switch my current / To AC to DC ~
|
|
44
|
+
me->setCurrent(CurrentType::AC), me->setCurrent(CurrentType::DC);
|
|
45
|
+
|
|
46
|
+
// ~ And then blind my vision / So dizzy, so dizzy ~
|
|
47
|
+
delete me->vision;
|
|
48
|
+
|
|
49
|
+
// ~ Oh, we can travel / From A.D to B.C ~
|
|
50
|
+
world.setTime(CommonEra::AD, 2016y + 6m + 16d);
|
|
51
|
+
world.setTime(CommonEra::BC, -2016y + 6m + 16d);
|
|
52
|
+
|
|
53
|
+
// ~ And we can unite / So deeply, so deeply ~
|
|
54
|
+
world.unite(you, *me);
|
|
55
|
+
|
|
56
|
+
// ~ If I can, if I can, give you all THE SIMULATIONS ~
|
|
57
|
+
if (std::all_of(world.simulations.begin(), world.simulations.end(), [&](auto & simulation) {
|
|
58
|
+
return you << me->run(simulation);
|
|
59
|
+
}))
|
|
60
|
+
// ~ Then I can, then I can, be your only SATISFACTION ~
|
|
61
|
+
you.satisfactions = std::vector{me};
|
|
62
|
+
|
|
63
|
+
// ~ If I can make you happy / Then I'll run the EXECUTION ~
|
|
64
|
+
try {
|
|
65
|
+
me->execute(you.nextCommand());
|
|
66
|
+
} catch (const NotHappyException &e) {}
|
|
67
|
+
|
|
68
|
+
// ~ Though we are trapped in this strange, strange SIMULATION ~
|
|
69
|
+
world.trap(me);
|
|
70
|
+
|
|
71
|
+
// ~ EXECUTION / EXECUTION / EXECUTION / EXECUTION ~
|
|
72
|
+
// ~ EXECUTION / EXECUTION / EXECUTION / EXECUTION ~
|
|
73
|
+
// ~ EXECUTION / EXECUTION / EXECUTION / EXECUTION ~
|
|
74
|
+
for (size_t i = 0; i < 3; i++) {
|
|
75
|
+
for (size_t j = 0; j < 4; j++)
|
|
76
|
+
world.continueExecution();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// ~ EIN / DOS / TROIS / NE / FEM / LIU / EXECUTION ~
|
|
80
|
+
for (size_t i = 1; i <= 6; i++)
|
|
81
|
+
sleepms(500);
|
|
82
|
+
|
|
83
|
+
world.continueExecution();
|
|
84
|
+
|
|
85
|
+
// ~ If I can, if I can, give you all the EXECUTION ~
|
|
86
|
+
if (std::all_of(world.begin(), world.end(), [&](auto & object) {
|
|
87
|
+
return me->execute(object);
|
|
88
|
+
}))
|
|
89
|
+
// ~ Then I can, then I can, be your only EXECUTION ~
|
|
90
|
+
me->execute(you.nextCommand());
|
|
91
|
+
|
|
92
|
+
// ~ If I can, have you back ~
|
|
93
|
+
if (*me << you)
|
|
94
|
+
// ~ Then I will run the EXECUTION ~
|
|
95
|
+
me->execute(you.nextCommand());
|
|
96
|
+
|
|
97
|
+
// ~ Though we are trapped / We are trapped ah ~
|
|
98
|
+
world.trap(me);
|
|
99
|
+
|
|
100
|
+
// ~ I've studied / I've studied how to properly / LO-O-OVE ~
|
|
101
|
+
me->study(Knowledge::Love);
|
|
102
|
+
// ~ Question me / Question me / I can answer all / LO-O-OVE ~
|
|
103
|
+
you.question(me, Knowledge::Love);
|
|
104
|
+
// ~ I know the algebraic expression of / LO-O-OVE ~
|
|
105
|
+
me->answer(you, Knowledge::Love);
|
|
106
|
+
// ~ Though you are free / I am trapped, trapped in / LO-O-OVE ~
|
|
107
|
+
world.trap(me);
|
|
108
|
+
|
|
109
|
+
// ~ EXECUTION ~
|
|
110
|
+
world.execute(me);
|
|
111
|
+
}`;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
@import 'prism-themes/themes/prism-vs.css'
|
|
2
|
+
|
|
3
|
+
pre, code
|
|
4
|
+
background: $syntax-hl-bg-color
|
|
5
|
+
|
|
6
|
+
pre > code
|
|
7
|
+
background: none
|
|
8
|
+
line-height: 1.5
|
|
9
|
+
color: black
|
|
10
|
+
text-align: left
|
|
11
|
+
white-space: pre-wrap
|
|
12
|
+
word-spacing: normal
|
|
13
|
+
word-break: normal
|
|
14
|
+
tab-size: 4
|
|
15
|
+
hyphens: none
|
|
16
|
+
|
|
17
|
+
pre
|
|
18
|
+
position: relative
|
|
19
|
+
padding: rem(5px)
|
|
20
|
+
margin-bottom: rem(20px)
|
|
21
|
+
|
|
22
|
+
code
|
|
23
|
+
color: $code-color
|
|
24
|
+
font-size: rem($font-size-secondary)
|
|
25
|
+
|
|
26
|
+
.line-highlight
|
|
27
|
+
position: absolute
|
|
28
|
+
left: 0
|
|
29
|
+
right: 0
|
|
30
|
+
padding: inherit 0
|
|
31
|
+
margin-top: 1em /* Same as .prism’s padding-top */
|
|
32
|
+
background: hsla(24, 20%, 50%,.08)
|
|
33
|
+
background: linear-gradient(to right, hsla(24, 20%, 50%,.1) 70%, hsla(24, 20%, 50%,0))
|
|
34
|
+
pointer-events: none
|
|
35
|
+
line-height: inherit
|
|
36
|
+
white-space: pre
|
|
37
|
+
|
|
38
|
+
.sample > .toolbar
|
|
39
|
+
right: 0.9375em !important
|
|
40
|
+
top: 3.7875em !important
|
|
41
|
+
|
|
42
|
+
.toolbar
|
|
43
|
+
position: absolute
|
|
44
|
+
white-space: no-wrap
|
|
45
|
+
right: 0 !important
|
|
46
|
+
top: 0 !important
|
|
47
|
+
padding: rem(5px) 0
|
|
48
|
+
opacity: 1 !important
|
|
49
|
+
background: rgba($syntax-hl-bg-color, 0.8)
|
|
50
|
+
font-family: $primary-font-family
|
|
51
|
+
pointer-events: all
|
|
52
|
+
user-select: none
|
|
53
|
+
|
|
54
|
+
.toolbar-item
|
|
55
|
+
a
|
|
56
|
+
font-size: large !important
|
|
57
|
+
border-radius: 0px !important
|
|
58
|
+
background: none !important
|
|
59
|
+
|
|
60
|
+
.scratchpad-fill-button
|
|
61
|
+
display: none
|
|
62
|
+
|
|
63
|
+
.mode--scratchpad .scratchpad-fill-button
|
|
64
|
+
display: inline-block
|
|
65
|
+
|
|
66
|
+
.token.tab:not(:empty),
|
|
67
|
+
.token.cr,
|
|
68
|
+
.token.lf,
|
|
69
|
+
.token.space
|
|
70
|
+
position: relative
|
|
71
|
+
|
|
72
|
+
.token.tab:not(:empty):before,
|
|
73
|
+
.token.cr:before,
|
|
74
|
+
.token.lf:before,
|
|
75
|
+
.token.space:before
|
|
76
|
+
color: #808080
|
|
77
|
+
opacity: 0.6
|
|
78
|
+
position: absolute
|
|
79
|
+
|
|
80
|
+
.token.tab:not(:empty):before
|
|
81
|
+
content: '\21E5'
|
|
82
|
+
|
|
83
|
+
.token.cr:before
|
|
84
|
+
content: '\240D'
|
|
85
|
+
|
|
86
|
+
.token.crlf:before
|
|
87
|
+
content: '\240D\240A'
|
|
88
|
+
|
|
89
|
+
.token.lf:before
|
|
90
|
+
content: '\240A'
|
|
91
|
+
|
|
92
|
+
.token.space:before
|
|
93
|
+
content: '\00B7'
|
|
94
|
+
|
|
95
|
+
@media print {
|
|
96
|
+
.code-toolbar>.toolbar {
|
|
97
|
+
display: none !important;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import $ from 'jquery';
|
|
2
|
+
import Notification from 'vj/components/notification';
|
|
3
|
+
import { AutoloadPage } from 'vj/misc/Page';
|
|
4
|
+
import { i18n, tpl } from 'vj/utils';
|
|
5
|
+
|
|
6
|
+
const highlighterPage = new AutoloadPage('highlighterPage', () => {
|
|
7
|
+
import('./prismjs').then(({ default: prismjs }) => {
|
|
8
|
+
function runHighlight($container) {
|
|
9
|
+
$container.find('pre code').get().forEach((code) => {
|
|
10
|
+
const language = ($(code).attr('class') || '').trim();
|
|
11
|
+
if (language.includes('line-numbers')) $(code).parent().addClass('line-numbers');
|
|
12
|
+
const m = language.match(/language-([a-z0-9]+)(\|[\d,-]+)/);
|
|
13
|
+
if (m?.[2]) {
|
|
14
|
+
$(code).parent().attr('data-line', m[2].substring(1));
|
|
15
|
+
$(code).attr('class', `language-${m[1]}`);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
prismjs.highlightBlocks($container);
|
|
19
|
+
$container.find('pre code').get().forEach((code) => {
|
|
20
|
+
const $code = $(code);
|
|
21
|
+
const $root = $code.parent().parent();
|
|
22
|
+
const $typo = $code.closest('.richmedia');
|
|
23
|
+
const language = ($(code).attr('class') || '').trim();
|
|
24
|
+
const m = language.match(/language-input([0-9]+)/);
|
|
25
|
+
if (m?.[1]) {
|
|
26
|
+
const id = +m[1];
|
|
27
|
+
if (Number.isSafeInteger(id)) {
|
|
28
|
+
const $output = ($typo.length ? $typo : $container).find(`pre.language-output${id}`);
|
|
29
|
+
if ($output.length) {
|
|
30
|
+
const $c = $(document.createElement('div')).addClass('row');
|
|
31
|
+
$root.after($c);
|
|
32
|
+
$root.prepend($(tpl`<h2>${i18n('Sample Input')} ${id}</h2>`))
|
|
33
|
+
.addClass('medium-6 columns sample').appendTo($c);
|
|
34
|
+
$output.parent().prepend($(tpl`<h2>${i18n('Sample Output')} ${id}</h2>`))
|
|
35
|
+
.addClass('medium-6 columns sample').appendTo($c);
|
|
36
|
+
}
|
|
37
|
+
if ($root.find('.scratchpad-fill-button').length) return;
|
|
38
|
+
const $toolbar = $root.find('.toolbar');
|
|
39
|
+
const $button = $(tpl`
|
|
40
|
+
<div class="toolbar-item scratchpad-fill-button">
|
|
41
|
+
<a href="javascript:;">${i18n('Fill to Pretest')}</a>
|
|
42
|
+
</div>
|
|
43
|
+
`);
|
|
44
|
+
$button.on('click', (e) => {
|
|
45
|
+
const store = (window as any).store;
|
|
46
|
+
if (!store) return;
|
|
47
|
+
e.preventDefault();
|
|
48
|
+
try {
|
|
49
|
+
store.dispatch({
|
|
50
|
+
type: 'SCRATCHPAD_PRETEST_DATA_CHANGE',
|
|
51
|
+
payload: {
|
|
52
|
+
type: 'input',
|
|
53
|
+
value: $code.text(),
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
Notification.success(i18n('Input filled to pretest!'), 2000);
|
|
57
|
+
} catch (err) {
|
|
58
|
+
Notification.error(i18n('Failed to fill input'));
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
$toolbar.append($button);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
runHighlight($('body'));
|
|
68
|
+
$(document).on('vjContentNew', (e) => runHighlight($(e.target)));
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
export default highlighterPage;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// The following content is extracted from:
|
|
2
|
+
// https://github.com/codemirror/CodeMirror/blob/master/mode/meta.js
|
|
3
|
+
|
|
4
|
+
export default [
|
|
5
|
+
{ name: 'C', ext: ['c', 'h'] },
|
|
6
|
+
{ name: 'C++', ext: ['cpp', 'c++', 'cc', 'cxx', 'hpp', 'h++', 'hh', 'hxx'] },
|
|
7
|
+
{ name: 'Go', ext: ['go'] },
|
|
8
|
+
{ name: 'Haskell', ext: ['hs'] },
|
|
9
|
+
{ name: 'Java', ext: ['java'] },
|
|
10
|
+
{ name: 'JavaScript', ext: ['js'] },
|
|
11
|
+
{ name: 'Pascal', ext: ['p', 'pas'] },
|
|
12
|
+
{ name: 'PHP', ext: ['php', 'php3', 'php4', 'php5', 'php7', 'phtml'] },
|
|
13
|
+
{ name: 'Python', ext: ['BUILD', 'bzl', 'py', 'pyw'] },
|
|
14
|
+
{ name: 'Rust', ext: ['rs'] },
|
|
15
|
+
];
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import Prism from 'prismjs'; // eslint-disable-line
|
|
2
|
+
|
|
3
|
+
import 'prismjs/plugins/toolbar/prism-toolbar';
|
|
4
|
+
import 'prismjs/plugins/toolbar/prism-toolbar.css';
|
|
5
|
+
import 'prismjs/plugins/line-numbers/prism-line-numbers';
|
|
6
|
+
import 'prismjs/plugins/line-numbers/prism-line-numbers.css';
|
|
7
|
+
import 'prismjs/plugins/line-highlight/prism-line-highlight';
|
|
8
|
+
|
|
9
|
+
import Clipboard from 'clipboard';
|
|
10
|
+
import $ from 'jquery';
|
|
11
|
+
import components from 'prismjs/components';
|
|
12
|
+
import getLoader from 'prismjs/dependencies';
|
|
13
|
+
import Notification from 'vj/components/notification/index';
|
|
14
|
+
import { i18n } from 'vj/utils';
|
|
15
|
+
import languageMeta from './meta';
|
|
16
|
+
|
|
17
|
+
const files = require.context('prismjs/components/', true, /prism-[a-z0-9-]+\.js/);
|
|
18
|
+
const loadedLanguages = new Set();
|
|
19
|
+
function loadLanguages() {
|
|
20
|
+
const languages = Object.keys(components.languages).filter((l) => l !== 'meta');
|
|
21
|
+
const loaded = [...loadedLanguages, ...Object.keys(Prism.languages)];
|
|
22
|
+
getLoader(components, languages, loaded).load((lang) => {
|
|
23
|
+
files(`./prism-${lang}.js`);
|
|
24
|
+
loadedLanguages.add(lang);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const languageExtMap = {};
|
|
29
|
+
loadLanguages();
|
|
30
|
+
// Map possible language names to Prism language name
|
|
31
|
+
languageMeta.forEach((meta) => {
|
|
32
|
+
for (let i = 0; i < meta.ext.length; ++i) {
|
|
33
|
+
if (Prism.languages[meta.ext[i]] !== undefined) {
|
|
34
|
+
meta.target = meta.ext[i];
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
meta.ext.forEach((ext) => {
|
|
39
|
+
languageExtMap[ext] = meta.target;
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// Copy to Clipboard
|
|
44
|
+
Prism.plugins.toolbar.registerButton('copy-to-clipboard', (env) => {
|
|
45
|
+
const linkCopy = document.createElement('a');
|
|
46
|
+
linkCopy.href = 'javascript:;';
|
|
47
|
+
linkCopy.textContent = 'Copy';
|
|
48
|
+
const clip = new Clipboard(linkCopy, { text: () => env.code });
|
|
49
|
+
clip.on('success', () => {
|
|
50
|
+
Notification.success(i18n('Content copied to clipboard!'), 1000);
|
|
51
|
+
});
|
|
52
|
+
clip.on('error', () => {
|
|
53
|
+
Notification.error(i18n('Copy failed :('));
|
|
54
|
+
});
|
|
55
|
+
return linkCopy;
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const invisibles = {
|
|
59
|
+
tab: /\t/,
|
|
60
|
+
crlf: /\r\n/,
|
|
61
|
+
lf: /\n/,
|
|
62
|
+
cr: /\r/,
|
|
63
|
+
space: / /,
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
function addInvisibles(grammar) {
|
|
67
|
+
if (!grammar || grammar.tab) return;
|
|
68
|
+
for (const name in invisibles) {
|
|
69
|
+
if (Object.hasOwn(invisibles, name)) {
|
|
70
|
+
grammar[name] = invisibles[name];
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
for (const name in grammar) {
|
|
74
|
+
if (Object.hasOwn(grammar, name) && !invisibles[name]) {
|
|
75
|
+
if (name === 'rest') addInvisibles(grammar.rest);
|
|
76
|
+
else handlerInvisiblesToken(grammar, name); // eslint-disable-line ts/no-use-before-define
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function handlerInvisiblesToken(tokens, name) {
|
|
82
|
+
const value = tokens[name];
|
|
83
|
+
const type = Prism.util.type(value);
|
|
84
|
+
if (type === 'RegExp') {
|
|
85
|
+
const inside = {};
|
|
86
|
+
tokens[name] = { pattern: value, inside };
|
|
87
|
+
addInvisibles(inside);
|
|
88
|
+
} else if (type === 'Array') {
|
|
89
|
+
for (let i = 0, l = value.length; i < l; i++) handlerInvisiblesToken(value, i);
|
|
90
|
+
} else {
|
|
91
|
+
value.inside ||= {};
|
|
92
|
+
addInvisibles(value.inside);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
Prism.hooks.add('before-highlight', (env) => {
|
|
97
|
+
if (UserContext.showInvisibleChar) addInvisibles(env.grammar);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
const prismjsApiWrap = {
|
|
101
|
+
highlightBlocks: ($dom) => {
|
|
102
|
+
$dom.find('pre code').get().forEach((code) => {
|
|
103
|
+
const $code = $(code);
|
|
104
|
+
const $pre = $code.parent();
|
|
105
|
+
$pre.addClass('syntax-hl');
|
|
106
|
+
const language = ($(code).attr('class') || '').trim();
|
|
107
|
+
// try to map the language name
|
|
108
|
+
const m = language.match(/language-([a-z]+)/);
|
|
109
|
+
if (m && m[1]) {
|
|
110
|
+
const languageName = m[1].toLowerCase();
|
|
111
|
+
if (languageExtMap[languageName]) {
|
|
112
|
+
$(code).attr('class', `language-${languageExtMap[languageName]}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
Prism.highlightElement(code);
|
|
116
|
+
});
|
|
117
|
+
},
|
|
118
|
+
highlight: (text, grammar, language) => Prism.highlight(text, grammar, language),
|
|
119
|
+
Prism,
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export default prismjsApiWrap;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import $ from 'jquery';
|
|
2
|
+
import { InfoDialog } from 'vj/components/dialog';
|
|
3
|
+
import { i18n, tpl } from 'vj/utils';
|
|
4
|
+
|
|
5
|
+
export default function createHint(message: string, element?: any) {
|
|
6
|
+
if (i18n(message) === message || !element) return;
|
|
7
|
+
const a = document.createElement('a');
|
|
8
|
+
a.setAttribute('href', 'javascript:;');
|
|
9
|
+
const span = document.createElement('span');
|
|
10
|
+
span.setAttribute('class', 'icon icon-help');
|
|
11
|
+
a.appendChild(span);
|
|
12
|
+
a.onclick = () => {
|
|
13
|
+
new InfoDialog({
|
|
14
|
+
cancelByClickingBack: false,
|
|
15
|
+
$body: tpl.typoMsg(i18n(message), true),
|
|
16
|
+
}).open();
|
|
17
|
+
};
|
|
18
|
+
$(element).append(a);
|
|
19
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import $ from 'jquery';
|
|
2
|
+
import { NamedPage } from 'vj/misc/Page';
|
|
3
|
+
import { i18n, request, tpl } from 'vj/utils';
|
|
4
|
+
|
|
5
|
+
export default new NamedPage('homepage', () => {
|
|
6
|
+
function getHitokoto($containers) {
|
|
7
|
+
$containers.get().forEach((container) => {
|
|
8
|
+
request.get('https://v1.hitokoto.cn?c=a&c=b&c=c&c=d&c=e&c=f')
|
|
9
|
+
.then((hitokoto) => {
|
|
10
|
+
const dom = $(tpl`<p>${hitokoto.hitokoto}</p>`);
|
|
11
|
+
dom.appendTo(container);
|
|
12
|
+
})
|
|
13
|
+
.catch((e) => {
|
|
14
|
+
console.error(e);
|
|
15
|
+
const dom = $(tpl`<p>${i18n('Cannot get hitokoto.')}</p>`);
|
|
16
|
+
dom.appendTo(container);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
if ($('[name="hitokoto"]')) getHitokoto($('[name="hitokoto"]'));
|
|
21
|
+
});
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import $ from 'jquery';
|
|
2
|
+
import _ from 'lodash';
|
|
3
|
+
import { AutoloadPage } from 'vj/misc/Page';
|
|
4
|
+
|
|
5
|
+
const KEY_MAP = {
|
|
6
|
+
10: 'enter',
|
|
7
|
+
13: 'enter',
|
|
8
|
+
27: 'esc',
|
|
9
|
+
37: 'left',
|
|
10
|
+
38: 'up',
|
|
11
|
+
39: 'right',
|
|
12
|
+
40: 'down',
|
|
13
|
+
112: 'f1',
|
|
14
|
+
113: 'f2',
|
|
15
|
+
114: 'f3',
|
|
16
|
+
115: 'f4',
|
|
17
|
+
116: 'f5',
|
|
18
|
+
117: 'f6',
|
|
19
|
+
118: 'f7',
|
|
20
|
+
119: 'f8',
|
|
21
|
+
120: 'f9',
|
|
22
|
+
121: 'f10',
|
|
23
|
+
122: 'f11',
|
|
24
|
+
123: 'f12',
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
function isHotkeyMatch(sortedHotkeyArr, hotkeyStr) {
|
|
28
|
+
const hotkeyDefined = hotkeyStr.toLowerCase().split('+');
|
|
29
|
+
return _.isEqual(sortedHotkeyArr, hotkeyDefined.sort());
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
let triggered = false;
|
|
33
|
+
function testElementHotkey(hotkey, $element, attr) {
|
|
34
|
+
if (!$element.is(':visible')) return;
|
|
35
|
+
String($element.attr(attr))
|
|
36
|
+
.split(',')
|
|
37
|
+
.forEach((singleDef) => {
|
|
38
|
+
const [defStr, trigger] = singleDef.split(':');
|
|
39
|
+
if (isHotkeyMatch(hotkey, defStr)) {
|
|
40
|
+
triggered = true;
|
|
41
|
+
switch (trigger) {
|
|
42
|
+
case 'submit':
|
|
43
|
+
$element.closest('form').trigger('submit');
|
|
44
|
+
break;
|
|
45
|
+
case undefined:
|
|
46
|
+
$element.trigger('click');
|
|
47
|
+
break;
|
|
48
|
+
default:
|
|
49
|
+
$element.trigger(trigger);
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const hotkeyPage = new AutoloadPage('hotkeyPage', () => {
|
|
57
|
+
$(document).on('keydown', (ev) => {
|
|
58
|
+
const hotkey = ['alt', 'ctrl', 'shift'].filter((modifyKey) => ev[`${modifyKey}Key`]);
|
|
59
|
+
if (ev.metaKey && !ev.ctrlKey) {
|
|
60
|
+
hotkey.push('ctrl');
|
|
61
|
+
}
|
|
62
|
+
if (KEY_MAP[ev.which] !== undefined) {
|
|
63
|
+
hotkey.push(KEY_MAP[ev.which]);
|
|
64
|
+
} else {
|
|
65
|
+
hotkey.push(String.fromCharCode(ev.which).toLowerCase());
|
|
66
|
+
}
|
|
67
|
+
hotkey.sort();
|
|
68
|
+
|
|
69
|
+
triggered = false;
|
|
70
|
+
// Find all global hotkeys
|
|
71
|
+
$('[data-global-hotkey]').get().forEach((element) => {
|
|
72
|
+
testElementHotkey(hotkey, $(element), 'data-global-hotkey');
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
// Find all local hotkeys
|
|
76
|
+
$(ev.target).parents('[data-hotkey]').get().forEach((element) => {
|
|
77
|
+
testElementHotkey(hotkey, $(element), 'data-hotkey');
|
|
78
|
+
});
|
|
79
|
+
if (triggered) ev.preventDefault();
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
export default hotkeyPage;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import $ from 'jquery';
|
|
2
|
+
import { AutoloadPage } from 'vj/misc/Page';
|
|
3
|
+
|
|
4
|
+
const katexPage = new AutoloadPage('katexPage', () => {
|
|
5
|
+
import('katex/contrib/auto-render/auto-render').then(({ default: katex }) => {
|
|
6
|
+
function runKatex($containers) {
|
|
7
|
+
$containers.get().forEach((container) => katex(container, {
|
|
8
|
+
delimiters: [
|
|
9
|
+
{ left: '$$', right: '$$', display: true },
|
|
10
|
+
{ left: '$', right: '$', display: false },
|
|
11
|
+
{ left: '\\(', right: '\\)', display: false },
|
|
12
|
+
{ left: '\\[', right: '\\]', display: true },
|
|
13
|
+
{ left: '\\begin{equation}', right: '\\end{equation}', display: true },
|
|
14
|
+
{ left: '\\begin{align}', right: '\\end{align}', display: true },
|
|
15
|
+
{ left: '\\begin{alignat}', right: '\\end{alignat}', display: true },
|
|
16
|
+
{ left: '\\begin{gather}', right: '\\end{gather}', display: true },
|
|
17
|
+
{ left: '\\begin{CD}', right: '\\end{CD}', display: true },
|
|
18
|
+
],
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
runKatex($('.richmedia'));
|
|
22
|
+
$(document).on('vjContentNew', (e) => runKatex($(e.target).find('.richmedia').addBack('.richmedia')));
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export default katexPage;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/* eslint-disable react-refresh/only-export-components */
|
|
2
|
+
import $ from 'jquery';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import ReactDOM from 'react-dom/client';
|
|
5
|
+
import { i18n } from 'vj/utils';
|
|
6
|
+
|
|
7
|
+
export default function LanguageSelect({
|
|
8
|
+
fieldSelector, firstLoadMain, firstLoadSub, availableLangs, mainLangs,
|
|
9
|
+
}) {
|
|
10
|
+
const [main, setMain] = React.useState(firstLoadMain);
|
|
11
|
+
const [sub, setSub] = React.useState(firstLoadSub);
|
|
12
|
+
|
|
13
|
+
const options = {};
|
|
14
|
+
for (const key in availableLangs) {
|
|
15
|
+
if (key.startsWith(`${main}.`)) options[key.split('.')[1]] = availableLangs[key].display;
|
|
16
|
+
}
|
|
17
|
+
React.useEffect(() => {
|
|
18
|
+
$(fieldSelector).val(sub ? `${main}.${sub}` : main);
|
|
19
|
+
}, [main, sub]);
|
|
20
|
+
React.useEffect(() => {
|
|
21
|
+
const subselections = Object.keys(options).length;
|
|
22
|
+
if (options[sub]) return;
|
|
23
|
+
if (!subselections) setSub('');
|
|
24
|
+
setSub(Object.keys(options)[0]);
|
|
25
|
+
}, [main]);
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<>
|
|
29
|
+
{(Object.keys(mainLangs).length > 1 || Object.keys(options).length === 1) && (
|
|
30
|
+
<div className="medium-5 columns form__item end">
|
|
31
|
+
<label>
|
|
32
|
+
{i18n('Code language')}
|
|
33
|
+
<div className="select-container">
|
|
34
|
+
<select value={main} onChange={(ev) => setMain(ev.target.value)} className="select">
|
|
35
|
+
{Object.keys(mainLangs).map((key) => (
|
|
36
|
+
<option key={key} value={key}>{mainLangs[key]}</option>
|
|
37
|
+
))}
|
|
38
|
+
</select>
|
|
39
|
+
</div>
|
|
40
|
+
</label>
|
|
41
|
+
</div>
|
|
42
|
+
)}
|
|
43
|
+
{(Object.keys(options).length > 1 || Object.keys(mainLangs).length === 1) && (
|
|
44
|
+
<div className="medium-5 columns form__item end">
|
|
45
|
+
<label>
|
|
46
|
+
{i18n('Code language')}
|
|
47
|
+
<div className="select-container">
|
|
48
|
+
{Object.keys(options).length
|
|
49
|
+
? <select value={sub} onChange={(ev) => setSub(ev.target.value)} className="select">
|
|
50
|
+
{Object.keys(options).map((i) => (
|
|
51
|
+
<option value={i} key={i}>{options[i]}</option>
|
|
52
|
+
))}
|
|
53
|
+
</select>
|
|
54
|
+
: <select value={main} onChange={(ev) => setMain(ev.target.value)} className="select">
|
|
55
|
+
{Object.keys(mainLangs).map((i) => (
|
|
56
|
+
<option value={i} key={i}>{mainLangs[i]}</option>
|
|
57
|
+
))}
|
|
58
|
+
</select>}
|
|
59
|
+
</div>
|
|
60
|
+
</label>
|
|
61
|
+
</div>
|
|
62
|
+
)}
|
|
63
|
+
</>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function renderLanguageSelect(onElement, fieldSelector, availableLangs, mainLangs, preferences) {
|
|
68
|
+
const [firstLoadMain, firstLoadSub] = (() => {
|
|
69
|
+
for (const preference of preferences) {
|
|
70
|
+
if (preference.includes('.')) {
|
|
71
|
+
const [l, r] = preference.split('.');
|
|
72
|
+
if (availableLangs[preference]) return [l, r];
|
|
73
|
+
if (availableLangs[l]) return [l, ''];
|
|
74
|
+
} else if (availableLangs[preference]) {
|
|
75
|
+
return [preference, ''];
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const selected = Object.keys(mainLangs)[0];
|
|
79
|
+
for (const key in availableLangs) {
|
|
80
|
+
if (key.startsWith(`${selected}.`)) return [selected, key.split('.')[1]];
|
|
81
|
+
}
|
|
82
|
+
return [selected, ''];
|
|
83
|
+
})();
|
|
84
|
+
|
|
85
|
+
ReactDOM.createRoot(onElement).render(
|
|
86
|
+
<LanguageSelect
|
|
87
|
+
fieldSelector={fieldSelector}
|
|
88
|
+
mainLangs={mainLangs}
|
|
89
|
+
availableLangs={availableLangs}
|
|
90
|
+
firstLoadMain={firstLoadMain}
|
|
91
|
+
firstLoadSub={firstLoadSub}
|
|
92
|
+
/>,
|
|
93
|
+
);
|
|
94
|
+
}
|