• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Help with JS code that will show a button if closed captioning exists, or hide it if it doesn't

Community Beginner ,
May 18, 2022 May 18, 2022

Copy link to clipboard

Copied

Hello, I have a branching course with an intro slide containing slide video, a section made up of 20 slides with slide video, and then 2 other sections with no audio or video. I will be making a series of these courses and each one will have the same format but depending on the content, a different number of slides in each section. Currently, I am manually creating a button to show the CC only on the slides that have them (the intro and the 20 slides with video), however since every other course will be different, I really don't want to have to create those buttons on every single course.

 

What I would like is a button that I add to the first slide that displays for the entire project, but only appears when there are closed captions to display, otherwise it remains hidden so people don't try to click it expecting it to do something.

 

I asked on a different forum and someone supplied the follow JS script, but it doesn't work.

 

var getSlides = cp.model.data.project_main.slides.split( ',' );
var getCC = cp.model.data[ getSlides[ window.cpInfoCurrentSlide - 1 ] ].audCC.length;
if (getCC !== 0 )
{
cp.show("cc_button");
}
else
{
cp.hide("cc_button")
}
 
It appears the script is trying to create a variable to track whether or not closed captions exists on the current slide or not (var getCC = cp.model.data[ getSlides[ window.cpInfoCurrentSlide - 1 ] ].audCC.length;) and then show or hide the button (cc_button) based on that, which makes total sense. However, I don't understand where the "audCC.length" is coming from? I can't find any resources anywhere that describe anything related to CC in Captivate at all besides "cpCmndCC" so this piece of code seems sort of... made up? Granted I don't know a lot about JS so that could be totally normal. Is there a way to track if CCs exist on a slide at all? If not, I guess I am stuck just adding the button to each slide. Thanks!

Views

440

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 26, 2022 May 26, 2022

Copy link to clipboard

Copied

That's what I have been doing actually, previewing in HTML5 with no luck.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Help resources