summaryrefslogtreecommitdiffstats
path: root/web_src
diff options
context:
space:
mode:
Diffstat (limited to 'web_src')
-rw-r--r--web_src/js/webcomponents/GiteaLocaleNumber.js20
-rw-r--r--web_src/js/webcomponents/webcomponents.js1
2 files changed, 0 insertions, 21 deletions
diff --git a/web_src/js/webcomponents/GiteaLocaleNumber.js b/web_src/js/webcomponents/GiteaLocaleNumber.js
deleted file mode 100644
index 613aa67359..0000000000
--- a/web_src/js/webcomponents/GiteaLocaleNumber.js
+++ /dev/null
@@ -1,20 +0,0 @@
-// Convert a number to a locale string by data-number attribute.
-// Or add a tooltip by data-number-in-tooltip attribute. JSON: {message: "count: %s", number: 123}
-window.customElements.define('gitea-locale-number', class extends HTMLElement {
- connectedCallback() {
- // ideally, the number locale formatting and plural processing should be done by backend with translation strings.
- // if we have complete backend locale support (eg: Golang "x/text" package), we can drop this component.
- const number = this.getAttribute('data-number');
- if (number) {
- this.attachShadow({mode: 'open'});
- this.shadowRoot.textContent = new Intl.NumberFormat().format(Number(number));
- }
- const numberInTooltip = this.getAttribute('data-number-in-tooltip');
- if (numberInTooltip) {
- // TODO: only 2 usages of this, we can replace it with Golang's "x/text/number" package in the future
- const {message, number} = JSON.parse(numberInTooltip);
- const tooltipContent = message.replace(/%[ds]/, new Intl.NumberFormat().format(Number(number)));
- this.setAttribute('data-tooltip-content', tooltipContent);
- }
- }
-});
diff --git a/web_src/js/webcomponents/webcomponents.js b/web_src/js/webcomponents/webcomponents.js
index 7e8135aa00..123607282b 100644
--- a/web_src/js/webcomponents/webcomponents.js
+++ b/web_src/js/webcomponents/webcomponents.js
@@ -1,4 +1,3 @@
import '@webcomponents/custom-elements'; // polyfill for some browsers like Pale Moon
import '@github/relative-time-element';
-import './GiteaLocaleNumber.js';
import './GiteaOriginUrl.js';