You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

head_script.tmpl 2.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. {{/*
  2. ==== DO NOT EDIT ====
  3. If you are customizing Gitea, please do not change this file.
  4. If you introduce mistakes in it, Gitea JavaScript code wouldn't run correctly.
  5. */}}
  6. <script>
  7. {{/* before our JS code gets loaded, use arrays to store errors, then the arrays will be switched to our error handler later */}}
  8. window.addEventListener('error', function(e) {window._globalHandlerErrors=window._globalHandlerErrors||[]; window._globalHandlerErrors.push(e);});
  9. window.addEventListener('unhandledrejection', function(e) {window._globalHandlerErrors=window._globalHandlerErrors||[]; window._globalHandlerErrors.push(e);});
  10. window.config = {
  11. appUrl: '{{AppUrl}}',
  12. appSubUrl: '{{AppSubUrl}}',
  13. assetVersionEncoded: encodeURIComponent('{{AssetVersion}}'), // will be used in URL construction directly
  14. assetUrlPrefix: '{{AssetUrlPrefix}}',
  15. runModeIsProd: {{.RunModeIsProd}},
  16. customEmojis: {{CustomEmojis}},
  17. csrfToken: '{{.CsrfToken}}',
  18. pageData: {{.PageData}},
  19. notificationSettings: {{NotificationSettings}}, {{/*a map provided by NewFuncMap in helper.go*/}}
  20. enableTimeTracking: {{EnableTimetracking}},
  21. {{if or .Participants .Assignees .MentionableTeams}}
  22. mentionValues: Array.from(new Map([
  23. {{- range .Participants -}}
  24. ['{{.Name}}', {key: '{{.Name}} {{.FullName}}', value: '{{.Name}}', name: '{{.Name}}', fullname: '{{.FullName}}', avatar: '{{.AvatarLink $.Context}}'}],
  25. {{- end -}}
  26. {{- range .Assignees -}}
  27. ['{{.Name}}', {key: '{{.Name}} {{.FullName}}', value: '{{.Name}}', name: '{{.Name}}', fullname: '{{.FullName}}', avatar: '{{.AvatarLink $.Context}}'}],
  28. {{- end -}}
  29. {{- range .MentionableTeams -}}
  30. ['{{$.MentionableTeamsOrg}}/{{.Name}}', {key: '{{$.MentionableTeamsOrg}}/{{.Name}}', value: '{{$.MentionableTeamsOrg}}/{{.Name}}', name: '{{$.MentionableTeamsOrg}}/{{.Name}}', avatar: '{{$.MentionableTeamsOrgAvatar}}'}],
  31. {{- end -}}
  32. ]).values()),
  33. {{end}}
  34. mermaidMaxSourceCharacters: {{MermaidMaxSourceCharacters}},
  35. {{/* 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 */}}
  36. i18n: {
  37. copy_success: {{ctx.Locale.Tr "copy_success"}},
  38. copy_error: {{ctx.Locale.Tr "copy_error"}},
  39. error_occurred: {{ctx.Locale.Tr "error.occurred"}},
  40. network_error: {{ctx.Locale.Tr "error.network_error"}},
  41. remove_label_str: {{ctx.Locale.Tr "remove_label_str"}},
  42. modal_confirm: {{ctx.Locale.Tr "modal.confirm"}},
  43. modal_cancel: {{ctx.Locale.Tr "modal.cancel"}},
  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/webcomponents.js?v={{AssetVersion}}"></script>