Skip to content

Commit

Permalink
Merge branch 'master' into NewToastAction
Browse files Browse the repository at this point in the history
  • Loading branch information
gparant committed May 6, 2024
2 parents 89f9591 + 42e7186 commit aef382d
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 15 deletions.
85 changes: 73 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 14 additions & 1 deletion views/discussions/discussion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ document.addEventListener("DOMContentLoaded", () => {

// Discussion text
if (text) {
text.innerText = getText(urlParams.get('text'))
playText(text as HTMLParagraphElement, getText(urlParams.get('text')));
}

// Close button event
Expand All @@ -46,6 +46,19 @@ document.addEventListener("DOMContentLoaded", () => {
}).catch(e => console.error(e))
})

const playText = (textElement: HTMLParagraphElement, text: string) => {
const texts = text.split(" ");
playTexts(textElement, texts);
}
const playTexts = (textElement: HTMLParagraphElement, texts: string[], index = 0) => {
setTimeout(() => {
textElement.innerText += " " + texts[index];
if (index < texts.length - 1) {
playTexts(textElement, texts, index + 1);
}
}, 100);
}

export {
getTitle,
getText,
Expand Down
4 changes: 2 additions & 2 deletions views/discussionsv2/discussion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ document.addEventListener("DOMContentLoaded", () => {
})

const playText = (textElement: HTMLParagraphElement, text: string) => {
const texts = text.split(" ")
const texts = text.split(" ");
playTexts(textElement, texts);
}
const playTexts = (textElement: HTMLParagraphElement, texts: string[], index = 0) => {
setTimeout(() => {
textElement.innerText += " " + texts[index]
textElement.innerText += " " + texts[index];
if (index < texts.length - 1) {
playTexts(textElement, texts, index + 1);
}
Expand Down

0 comments on commit aef382d

Please sign in to comment.