Gets the name of a number, even if it's stupidly big. Supersedes TheoryOfNekomata/number-name.
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 

78 wiersze
1.7 KiB

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>@modal-sh/numerica-core</title>
  6. <style>
  7. .main-form {
  8. position: fixed;
  9. top: 0;
  10. left: 0;
  11. width: 100%;
  12. height: 100%;
  13. display: flex;
  14. flex-direction: column;
  15. align-items: stretch;
  16. }
  17. .main-form > textarea {
  18. flex: auto;
  19. width: 100%;
  20. height: 0;
  21. font-size: 2rem;
  22. padding: 1rem;
  23. border: 0;
  24. outline: 0;
  25. resize: none;
  26. box-sizing: border-box;
  27. }
  28. @media (min-width: 1080px) {
  29. .main-form {
  30. flex-direction: row;
  31. }
  32. .main-form > textarea {
  33. width: 0;
  34. height: 100%;
  35. }
  36. }
  37. </style>
  38. </head>
  39. <body>
  40. <form id="mainForm">
  41. <textarea aria-label="Number" name="number" placeholder="123"></textarea>
  42. <textarea aria-label="Name" name="name" placeholder="one hundred twenty three"></textarea>
  43. </form>
  44. <script type="module">
  45. import { stringify, parse } from './numerica.js';
  46. function MainForm(el) {
  47. const numberInput = el.querySelector('[name="number"]');
  48. const nameInput = el.querySelector('[name="name"]');
  49. numberInput.addEventListener('input', (e) => {
  50. nameInput.value = '';
  51. if (e.currentTarget.value === '') {
  52. return;
  53. }
  54. nameInput.value = stringify(e.currentTarget.value);
  55. });
  56. nameInput.addEventListener('input', (e) => {
  57. numberInput.value = '';
  58. if (e.currentTarget.value === '') {
  59. return;
  60. }
  61. numberInput.value = Number(parse(e.currentTarget.value)).toString();
  62. });
  63. el.classList.add('main-form');
  64. }
  65. const mainForm = window.document.getElementById('mainForm');
  66. new MainForm(mainForm);
  67. </script>
  68. </body>
  69. </html>