Skip to content

Commit

Permalink
Allow in-/decreasing playback speed of tutorial hints
Browse files Browse the repository at this point in the history
  • Loading branch information
bkimminich committed Apr 11, 2022
1 parent 9d8f193 commit 89fd86b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
2 changes: 2 additions & 0 deletions config.schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ hackingInstructor:
type: boolean
avatarImage:
type: string
hintPlaybackSpeed:
type: string
products:
-
name:
Expand Down
5 changes: 3 additions & 2 deletions config/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ challenges:
hackingInstructor:
isEnabled: true
avatarImage: JuicyBot_MedicalMask.png
hintPlaybackSpeed: normal # Options: faster fast normal slow slower
products:
-
name: 'Apple Juice (1000ml)'
Expand Down Expand Up @@ -360,7 +361,7 @@ products:
price: 9999.99
quantity: 1
limitPerUser: 1
image: permafrost.jpg
image: permafrost.jpg
reviews:
- { text: "🧊 Let it go, let it go 🎶 Can't hold it back anymore 🎶 Let it go, let it go 🎶 Turn away and slam the door ❄️", author: rapper }
-
Expand Down Expand Up @@ -400,7 +401,7 @@ memories:
caption: 'My rare collectors item! [̲̅$̲̅(̲̅ ͡° ͜ʖ ͡°̲̅)̲̅$̲̅]'
user: bjoernGoogle
-
image: 'favorite-hiking-place.png'
image: 'favorite-hiking-place.png'
caption: 'I love going hiking here...'
geoStalkingMetaSecurityQuestion: 14
geoStalkingMetaSecurityAnswer: 'Daniel Boone National Forest'
Expand Down
18 changes: 17 additions & 1 deletion frontend/src/hacking-instructor/helpers/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
*/

let config
const playbackDelays = {
faster: 0.5,
fast: 0.75,
normal: 1.0,
slow: 1.25,
slower: 1.5
}

export async function sleep (timeInMs: number): Promise<void> {
return await new Promise((resolve) => {
Expand Down Expand Up @@ -124,7 +131,16 @@ export function waitForElementsInnerHtmlToBe (elementSelector: string, value: St
}

export function waitInMs (timeInMs: number) {
return async () => await sleep(timeInMs)
return async () => {
if (!config) {
const res = await fetch('/rest/admin/application-configuration')
const json = await res.json()
config = json.config
}
let delay = playbackDelays[config.hackingInstructor.hintPlaybackSpeed]
delay ??= 1.0
await sleep(timeInMs * delay)
}
}

export function waitForAngularRouteToBeVisited (route: string) {
Expand Down

0 comments on commit 89fd86b

Please sign in to comment.