@todojs/

03-random-lorem-ipsum

HTML, CSS, JS

No description

fork
loading
Files
  • index.html

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.8728354239675629","path":"index.html","file":{"path":"index.html","content":{"asEncoding":{"base64":"PCFET0NUWVBFIGh0bWw+CjxodG1sIGxhbmc9ImVuIj4KPGhlYWQ+CiAgPG1ldGEgY2hhcnNldD0iVVRGLTgiPgogIDx0aXRsZT5MaWdodCBET008L3RpdGxlPgo8L2hlYWQ+Cjxib2R5Pgo8YnV0dG9uIGlkPSJnZXRUZXh0Ij5SYW5kb20gTG9yZW0gSXBzdW08L2J1dHRvbj4KPHdjLXdvcmRzPjwvd2Mtd29yZHM+CjxzY3JpcHQ+CiAgZG9jdW1lbnQucXVlcnlTZWxlY3RvciAoJyNnZXRUZXh0JykuYWRkRXZlbnRMaXN0ZW5lciAoJ2NsaWNrJywgZnVuY3Rpb24gKCkgewogICAgY29uc3Qgd29yZHMgICAgICA9IHBhcnNlSW50IChNYXRoLnJhbmRvbSAoKSAqIDIwMCk7CiAgICBjb25zdCBwYXJhZ3JhcGhzID0gcGFyc2VJbnQgKHdvcmRzIC8gMjApOwogICAgZmV0Y2ggKCdodHRwczovL3d3dy5yYW5kb210ZXh0Lm1lL2FwaS9sb3JlbS9wLScgKyBwYXJhZ3JhcGhzICsgJy8xLScgKyB3b3JkcykKICAgICAgLnRoZW4gKGZ1bmN0aW9uIChyZXNwb25zZSkgewogICAgICAgIGlmIChyZXNwb25zZS5zdGF0dXMgPT09IDIwMCkgewogICAgICAgICAgcmV0dXJuIHJlc3BvbnNlLmpzb24gKCk7CiAgICAgICAgfQogICAgICB9KS50aGVuIChmdW5jdGlvbiAoZGF0YSkgewogICAgICBkb2N1bWVudC5xdWVyeVNlbGVjdG9yICgnd2Mtd29yZHMnKS5pbm5lckhUTUwgPSBkYXRhLnRleHRfb3V0OwogICAgfSk7CiAgfSk7CgogIGN1c3RvbUVsZW1lbnRzLmRlZmluZSAoJ3djLXdvcmRzJywgY2xhc3MgZXh0ZW5kcyBIVE1MRWxlbWVudCB7CiAgfSk7Cjwvc2NyaXB0Pgo8L2JvZHk+CjwvaHRtbD4="},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Light DOM</title>
</head>
<body>
<button id="getText">Random Lorem Ipsum</button>
<wc-words></wc-words>
<script>
  document.querySelector ('#getText').addEventListener ('click', function () {
    const words      = parseInt (Math.random () * 200);
    const paragraphs = parseInt (words / 20);
    fetch ('https://www.randomtext.me/api/lorem/p-' + paragraphs + '/1-' + words)
      .then (function (response) {
        if (response.status === 200) {
          return response.json ();
        }
      }).then (function (data) {
      document.querySelector ('wc-words').innerHTML = data.text_out;
    });
  });

  customElements.define ('wc-words', class extends HTMLElement {
  });
</script>
</body>
</html>
result
console