(text, typingOn = true)
| 397 | } |
| 398 | |
| 399 | async function createText(text, typingOn = true) { |
| 400 | const p = document.createElement("p"); |
| 401 | app.appendChild(p); |
| 402 | p.scrollIntoView({ behavior: 'smooth' }); |
| 403 | |
| 404 | const typing = localStorage.getItem("typing"); |
| 405 | |
| 406 | if (!typingOn || (typing && typing === "off")) { |
| 407 | p.innerHTML = text; |
| 408 | return; |
| 409 | } |
| 410 | |
| 411 | const typingSpeed = localStorage.getItem("typingSpeed") || 20; |
| 412 | |
| 413 | let index = 0; |
| 414 | async function writeText() { |
| 415 | while (index < text.length) { |
| 416 | p.innerHTML += text[index++]; |
| 417 | await new Promise((writeText) => setTimeout(writeText, typingSpeed)); |
| 418 | } |
| 419 | return; |
| 420 | } |
| 421 | |
| 422 | await writeText(); |
| 423 | |
| 424 | } |
| 425 | |
| 426 | async function createCode(code, text, typingOn = true) { |
| 427 | const p = document.createElement("p"); |
no test coverage detected