Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wxiaoguang committed Jun 22, 2024
1 parent 1a811c0 commit c0f3a0c
Showing 1 changed file with 129 additions and 101 deletions.
230 changes: 129 additions & 101 deletions web_src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,110 +94,138 @@ import {
import {initGlobalDropzone} from './features/dropzone.js';
import {initGlobalEnterQuickSubmit, initGlobalFormDirtyLeaveConfirm} from './features/common-form.js';

// Init Gitea's Fomantic settings
initGiteaFomantic();
initDirAuto();
initSubmitEventPolyfill();

function callInitFunctions(functions) {
// Start performance trace by accessing a URL by "https://localhost/?_ui_performance_trace=1" or "https://localhost/?key=value&_ui_performance_trace=1"
// It is a quick check, no side effect so no need to do slow URL parsing.
const initStart = performance.now();
if (window.location.search.includes('_ui_performance_trace=1')) {
let results = [];
for (const func of functions) {
const start = performance.now();
func();
results.push({name: func.name, dur: performance.now() - start});
}
results = results.sort((a, b) => b.dur - a.dur);
for (let i = 0; i < 20 && i < results.length; i++) {
// eslint-disable-next-line no-console
console.log(`performance trace: ${results[i].name} ${results[i].dur.toFixed(3)}`);
}
} else {
for (const func of functions) {
func();
}
}
const initDur = performance.now() - initStart;
if (initDur > 500) {
console.error(`slow init functions took ${initDur.toFixed(3)}ms`);
}
}

onDomReady(() => {
initGlobalDropdown();
initGlobalTabularMenu();
initGlobalShowModal();
initGlobalFetchAction();
initGlobalTooltips();
initGlobalButtonClickOnEnter();
initGlobalButtons();
initGlobalCopyToClipboardListener();
initGlobalDropzone();
initGlobalEnterQuickSubmit();
initGlobalFormDirtyLeaveConfirm();
initGlobalDeleteButton();

initCommonOrganization();
initCommonIssueListQuickGoto();

initCompSearchUserBox();
initCompWebHookEditor();

initInstall();

initHeadNavbarContentToggle();
initFootLanguageMenu();

initCommentContent();
initContextPopups();
initHeatmap();
initImageDiff();
initMarkupAnchors();
initMarkupContent();
initSshKeyFormParser();
initStopwatch();
initTableSort();
initAutoFocusEnd();
initFindFileInRepo();
initCopyContent();

initAdminCommon();
initAdminEmails();
initAdminUserListSearchForm();
initAdminConfigs();
initAdminSelfCheck();

initDashboardRepoList();

initNotificationCount();
initNotificationsTable();

initOrgTeamSearchRepoBox();
initOrgTeamSettings();

initRepoActivityTopAuthorsChart();
initRepoArchiveLinks();
initRepoBranchButton();
initRepoCodeView();
initRepoCommentForm();
initRepoEllipsisButton();
initRepoDiffCommitBranchesAndTags();
initRepoEditor();
initRepoGraphGit();
initRepoIssueContentHistory();
initRepoIssueDue();
initRepoIssueList();
initRepoIssueSidebarList();
initArchivedLabelHandler();
initRepoIssueReferenceRepositorySearch();
initRepoIssueTimeTracking();
initRepoIssueWipTitle();
initRepoMigration();
initRepoMigrationStatusChecker();
initRepoProject();
initRepoPullRequestMergeInstruction();
initRepoPullRequestAllowMaintainerEdit();
initRepoPullRequestReview();
initRepoRelease();
initRepoReleaseNew();
initRepoSettingGitHook();
initRepoSettingSearchTeamBox();
initRepoSettingsCollaboration();
initRepoTemplateSearch();
initRepoTopicBar();
initRepoWikiForm();
initRepository();
initRepositoryActionView();
initRepositorySearch();
initRepoContributors();
initRepoCodeFrequency();
initRepoRecentCommits();

initCommitStatuses();
initCaptcha();

initUserAuthOauth2();
initUserAuthWebAuthn();
initUserAuthWebAuthnRegister();
initUserSettings();
initRepoDiffView();
initPdfViewer();
initScopedAccessTokenCategories();
initColorPickers();
callInitFunctions([
initGlobalDropdown,
initGlobalTabularMenu,
initGlobalShowModal,
initGlobalFetchAction,
initGlobalTooltips,
initGlobalButtonClickOnEnter,
initGlobalButtons,
initGlobalCopyToClipboardListener,
initGlobalDropzone,
initGlobalEnterQuickSubmit,
initGlobalFormDirtyLeaveConfirm,
initGlobalDeleteButton,

initCommonOrganization,
initCommonIssueListQuickGoto,

initCompSearchUserBox,
initCompWebHookEditor,

initInstall,

initHeadNavbarContentToggle,
initFootLanguageMenu,

initCommentContent,
initContextPopups,
initHeatmap,
initImageDiff,
initMarkupAnchors,
initMarkupContent,
initSshKeyFormParser,
initStopwatch,
initTableSort,
initAutoFocusEnd,
initFindFileInRepo,
initCopyContent,

initAdminCommon,
initAdminEmails,
initAdminUserListSearchForm,
initAdminConfigs,
initAdminSelfCheck,

initDashboardRepoList,

initNotificationCount,
initNotificationsTable,

initOrgTeamSearchRepoBox,
initOrgTeamSettings,

initRepoActivityTopAuthorsChart,
initRepoArchiveLinks,
initRepoBranchButton,
initRepoCodeView,
initRepoCommentForm,
initRepoEllipsisButton,
initRepoDiffCommitBranchesAndTags,
initRepoEditor,
initRepoGraphGit,
initRepoIssueContentHistory,
initRepoIssueDue,
initRepoIssueList,
initRepoIssueSidebarList,
initArchivedLabelHandler,
initRepoIssueReferenceRepositorySearch,
initRepoIssueTimeTracking,
initRepoIssueWipTitle,
initRepoMigration,
initRepoMigrationStatusChecker,
initRepoProject,
initRepoPullRequestMergeInstruction,
initRepoPullRequestAllowMaintainerEdit,
initRepoPullRequestReview,
initRepoRelease,
initRepoReleaseNew,
initRepoSettingGitHook,
initRepoSettingSearchTeamBox,
initRepoSettingsCollaboration,
initRepoTemplateSearch,
initRepoTopicBar,
initRepoWikiForm,
initRepository,
initRepositoryActionView,
initRepositorySearch,
initRepoContributors,
initRepoCodeFrequency,
initRepoRecentCommits,

initCommitStatuses,
initCaptcha,

initUserAuthOauth2,
initUserAuthWebAuthn,
initUserAuthWebAuthnRegister,
initUserSettings,
initRepoDiffView,
initPdfViewer,
initScopedAccessTokenCategories,
initColorPickers,
]);
});

0 comments on commit c0f3a0c

Please sign in to comment.