MCPcopy Index your code
hub / github.com/TechSpiritSS/Terminal-Portfolio / createCode

Function createCode

scripts/functions.js:426–466  ·  view source on GitHub ↗
(code, text, typingOn = true)

Source from the content-addressed store, hash-verified

424}
425
426async function createCode(code, text, typingOn = true) {
427 const p = document.createElement("p");
428 app.appendChild(p);
429
430 const typing = localStorage.getItem("typing");
431
432 if (!typingOn || (typing && typing === "off")) {
433 p.innerHTML = `<span class="code">${code} =></span> ${text}`;
434 return;
435 }
436
437 const typingSpeed = localStorage.getItem("typingSpeed") || 20;
438
439 const span = document.createElement("span");
440 span.className = "code"
441 p.appendChild(span);
442 p.scrollIntoView({ behavior: 'smooth' });
443 let index = 0;
444 async function writeCode() {
445 while (index < code.length) {
446 span.innerHTML += code[index++];
447 await new Promise((writeCode) => setTimeout(writeCode, typingSpeed));
448 }
449 return;
450 }
451 await writeCode();
452
453 p.innerHTML += " "
454
455 index = 0;
456 async function writeText() {
457 while (index < text.length) {
458 p.innerHTML += text[index++];
459 await new Promise((writeText) => setTimeout(writeText, typingSpeed));
460 }
461 return;
462 }
463
464 await writeText();
465
466}
467
468function downloadFile() {
469 let link = document.createElement("a");

Callers 1

openTerminalFunction · 0.90

Calls 2

writeCodeFunction · 0.85
writeTextFunction · 0.85

Tested by

no test coverage detected