Compare commits
2 Commits
ca43dafd6a
...
96fa327425
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
96fa327425 | ||
|
|
1076cd2895 |
16
ReadMe.md
16
ReadMe.md
|
|
@ -5,8 +5,7 @@ formatting numbers manually.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
- Host the script somewhere on your system.
|
- Host the script somewhere on your system.
|
||||||
- Ensure you set the language for your HTML\
|
- Ensure you set the language for your HTML element
|
||||||
(this will be essential with the first official release.)
|
|
||||||
- Add a script tag to your document head that has the `src` set to this script.\
|
- Add a script tag to your document head that has the `src` set to this script.\
|
||||||
The script tag must also be set to defer
|
The script tag must also be set to defer
|
||||||
- Surround any numbers you want formatting with `<num> .. </num>` tags.\
|
- Surround any numbers you want formatting with `<num> .. </num>` tags.\
|
||||||
|
|
@ -42,14 +41,25 @@ formatting numbers manually.
|
||||||
|
|
||||||
## TODO:
|
## TODO:
|
||||||
- Add support for currency formatting
|
- Add support for currency formatting
|
||||||
- Change language/locale to use document language tag.
|
|
||||||
- Check for optimisations
|
- Check for optimisations
|
||||||
- If this becomes popular host to a CDN
|
- If this becomes popular host to a CDN
|
||||||
|
- Change custom element\
|
||||||
|
Technically the WHATWG specifies that custom elements should be in
|
||||||
|
kebab case.
|
||||||
|
|
||||||
|
## MightDO:
|
||||||
|
- Allow for setting locale for individual numbers.
|
||||||
- Automate releases that include a minified version\
|
- Automate releases that include a minified version\
|
||||||
I personally don't care for minified JS but some people love it\
|
I personally don't care for minified JS but some people love it\
|
||||||
This is an extremely low-priority task.
|
This is an extremely low-priority task.
|
||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
|
- 2022-10-08\
|
||||||
|
Get language from DOM
|
||||||
|
Robert Morrison \<sherlock5512\>
|
||||||
|
- 2022-10-07{2}\
|
||||||
|
Add Logo\
|
||||||
|
Robert Morrison \<sherlock5512\>
|
||||||
- 2022-10-07\
|
- 2022-10-07\
|
||||||
Initial Upload of basic script\
|
Initial Upload of basic script\
|
||||||
Robert Morrison \<sherlock5512\>
|
Robert Morrison \<sherlock5512\>
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,11 @@
|
||||||
// GNU won't support my choice of browser so I won't support their tool
|
// GNU won't support my choice of browser so I won't support their tool
|
||||||
|
|
||||||
function formatNumbers() {
|
function formatNumbers() {
|
||||||
|
|
||||||
const numbers = document.getElementsByTagName("num");
|
const numbers = document.getElementsByTagName("num");
|
||||||
const formatter = Intl.NumberFormat(navigator.language);
|
const documentLanguage = document.documentElement.lang;
|
||||||
|
const formatter = Intl.NumberFormat(documentLanguage);
|
||||||
|
|
||||||
for (let num of numbers) {
|
for (let num of numbers) {
|
||||||
var number = parseFloat(num.innerHTML);
|
var number = parseFloat(num.innerHTML);
|
||||||
if (isNaN(number)) {
|
if (isNaN(number)) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user