summaryrefslogtreecommitdiffstats
path: root/web_src/js/features
diff options
context:
space:
mode:
authorGusted <williamzijl7@hotmail.com>2022-06-12 14:08:23 +0200
committerGitHub <noreply@github.com>2022-06-12 20:08:23 +0800
commit796c4eca0bacf67c186768de66fcfee21867045f (patch)
tree3fc7947372c955953c0c6d443b05d3585a6ce300 /web_src/js/features
parent0097fbc2ac153a686b68af43e791704e9b5cf74b (diff)
downloadgitea-796c4eca0bacf67c186768de66fcfee21867045f.tar.gz
gitea-796c4eca0bacf67c186768de66fcfee21867045f.zip
Prettify number of issues (#17760)
* Prettify number of issues - Use the PrettyNumber function to add commas in large amount of issues. * Use client-side formatting * prettify on both server and client * remove unused i18n entries * handle more cases, support other int types in PrettyNumber * specify locale to avoid issues with node default locale * remove superfluos argument * introduce template helper, octicon tweaks, js refactor * Update modules/templates/helper.go * Apply some suggestions. * Add comment * Update templates/user/dashboard/issues.tmpl Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'web_src/js/features')
-rw-r--r--web_src/js/features/formatting.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/web_src/js/features/formatting.js b/web_src/js/features/formatting.js
new file mode 100644
index 0000000000..a7ee7ec3cf
--- /dev/null
+++ b/web_src/js/features/formatting.js
@@ -0,0 +1,14 @@
+import {prettyNumber} from '../utils.js';
+
+const {lang} = document.documentElement;
+
+export function initFormattingReplacements() {
+ // replace english formatted numbers with locale-specific separators
+ for (const el of document.getElementsByClassName('js-pretty-number')) {
+ const num = Number(el.getAttribute('data-value'));
+ const formatted = prettyNumber(num, lang);
+ if (formatted && formatted !== el.textContent) {
+ el.textContent = formatted;
+ }
+ }
+}