gitea源码

head_script.tmpl 2.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. {{/* ==== DO NOT EDIT ====
  2. If you are customizing Gitea, please do not change this file.
  3. If you introduce mistakes in it, Gitea JavaScript code wouldn't run correctly.
  4. */}}
  5. <script>
  6. {{/* before our JS code gets loaded, use arrays to store errors, then the arrays will be switched to our error handler later */}}
  7. window.addEventListener('error', function(e) {window._globalHandlerErrors=window._globalHandlerErrors||[]; window._globalHandlerErrors.push(e);});
  8. window.addEventListener('unhandledrejection', function(e) {window._globalHandlerErrors=window._globalHandlerErrors||[]; window._globalHandlerErrors.push(e);});
  9. window.config = {
  10. appUrl: '{{AppUrl}}',
  11. appSubUrl: '{{AppSubUrl}}',
  12. assetVersionEncoded: encodeURIComponent('{{AssetVersion}}'), // will be used in URL construction directly
  13. assetUrlPrefix: '{{AssetUrlPrefix}}',
  14. runModeIsProd: {{.RunModeIsProd}},
  15. customEmojis: {{CustomEmojis}},
  16. csrfToken: '{{.CsrfToken}}',
  17. pageData: {{.PageData}},
  18. notificationSettings: {{NotificationSettings}}, {{/*a map provided by NewFuncMap in helper.go*/}}
  19. enableTimeTracking: {{EnableTimetracking}},
  20. {{if or .Participants .Assignees .MentionableTeams}}
  21. mentionValues: Array.from(new Map([
  22. {{- range .Participants -}}
  23. ['{{.Name}}', {key: '{{.Name}} {{.FullName}}', value: '{{.Name}}', name: '{{.Name}}', fullname: '{{.FullName}}', avatar: '{{.AvatarLink ctx}}'}],
  24. {{- end -}}
  25. {{- range .Assignees -}}
  26. ['{{.Name}}', {key: '{{.Name}} {{.FullName}}', value: '{{.Name}}', name: '{{.Name}}', fullname: '{{.FullName}}', avatar: '{{.AvatarLink ctx}}'}],
  27. {{- end -}}
  28. {{- range .MentionableTeams -}}
  29. ['{{$.MentionableTeamsOrg}}/{{.Name}}', {key: '{{$.MentionableTeamsOrg}}/{{.Name}}', value: '{{$.MentionableTeamsOrg}}/{{.Name}}', name: '{{$.MentionableTeamsOrg}}/{{.Name}}', avatar: '{{$.MentionableTeamsOrgAvatar}}'}],
  30. {{- end -}}
  31. ]).values()),
  32. {{end}}
  33. mermaidMaxSourceCharacters: {{MermaidMaxSourceCharacters}},
  34. {{/* this global i18n object should only contain general texts. for specialized texts, it should be provided inside the related modules by: (1) API response (2) HTML data-attribute (3) PageData */}}
  35. i18n: {
  36. copy_success: {{ctx.Locale.Tr "copy_success"}},
  37. copy_error: {{ctx.Locale.Tr "copy_error"}},
  38. error_occurred: {{ctx.Locale.Tr "error.occurred"}},
  39. network_error: {{ctx.Locale.Tr "error.network_error"}},
  40. remove_label_str: {{ctx.Locale.Tr "remove_label_str"}},
  41. modal_confirm: {{ctx.Locale.Tr "modal.confirm"}},
  42. modal_cancel: {{ctx.Locale.Tr "modal.cancel"}},
  43. more_items: {{ctx.Locale.Tr "more_items"}},
  44. },
  45. };
  46. {{/* in case some pages don't render the pageData, we make sure it is an object to prevent null access */}}
  47. window.config.pageData = window.config.pageData || {};
  48. </script>
  49. <script src="{{AssetUrlPrefix}}/js/index.js?v={{AssetVersion}}" onerror="alert('Failed to load asset files from ' + this.src + '. Please make sure the asset files can be accessed.')"></script>