How to reset a slide to it's initial state using Javascript

Nov 02, 2023

Hi there

I have been trying to implement Dark Mode in my course and have managed to set all the objects / slides the course to switch to their "Dark Mode" states when the timeline starts. 

 

I have also managed to create a custom player tab which toggles the variable "DarkMode" when clicked.  Can you get it to also restart the current slide's timeline?

Here is the current code I have which doesn't work after the if statement:

var player = GetPlayer();
let darkMode = player.GetVar("DarkMode");

if (darkMode == true) {
    player.SetVar("DarkMode", false);
} else { 
    player.SetVar("DarkMode", true);
}

var slideNumber = player.GetVar("cpInfoCurrentSlide"); // Get the current slide number
player.GetPlayer().GetSlideById(slideNumber).GetTimeline().StartTimeline("Slide.ElapsedTime");

TIA

 

Carrie 

3 Replies