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

Is there a way to hide the lowest numbered text caption on slide entry using Javascript?

Community Beginner ,
Aug 02, 2023 Aug 02, 2023

Copy link to clipboard

Copied

Hi, first of all thank you for any help provided. I have a simple show me, try me and test me project. I have 100 slides for show me all with one single text caption providing guidance. For test me I am providing one text caption for guidance and one hidden text caption accessed through a hint button for assistance. Instead of hiding each text caption manually is there a way to wildcard hide the lowest numbered caption using javascript  and then this can be set as the page enter action to the 100 try me slides. I could also use this on the hint button to show the hidden caption. Aware there may be slicker ways of working in terms of setup but as this is an established project I'm looking to align to the current practices. Thanks again in advance for any help. 

Views

279

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

correct answers 1 Correct answer

Advisor , Aug 02, 2023 Aug 02, 2023

What is tricky about this is that all of the objects on your stage are added to an array but not always in the same order or at the same index value... etc. That makes it tough to pinpoint.

 

I did a little work on something you could at least give a try.

The code will find the array of objects for the current slide and then separate out the captions to a new array.

Then the code will hide the first item in the array of captions. Hopefully it populates the new array in numerical order.

These are on t

...

Votes

Translate

Translate
Community Expert ,
Aug 02, 2023 Aug 02, 2023

Copy link to clipboard

Copied

You are asking for JS, so I will not propose a shared action.

However while you are waiting for a JS expert, it would be great to clarify some more:

  • You didn't use a Software simulation, or you would have those text captions automatically depending on the mode: Demo, Training, Assessment. You created it manually and added the text captions?
  • Or did you do a recording in one mode, and used that to create the other modes?
  • You talk about 'lowest number', probably referring to the generic name of the text captions. Why the lowest? The labels will be different on each slide, does the Hint caption's generic name always have a lower number than the other caption?

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
Community Beginner ,
Aug 02, 2023 Aug 02, 2023

Copy link to clipboard

Copied

Hi, thank you for the quick response. Answers below:

 

  • Software simulation not used as the content needs a large amount of manupulation in other packages (illustrator/photoshop) due to enviroment restrictions before bringing to captivate. All slides created manually.
  • No recordings used.
  • The hint caption is the orginal whereas the instruction which contains slightly amended text is the duplicate with the higher ID number eg hint Text_Caption_201 and the instruction will be Text_Caption_230 etc

Thanks again

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
Community Expert ,
Aug 02, 2023 Aug 02, 2023

Copy link to clipboard

Copied

It is a pity that you didn't use software simulation in the two or three modes. It is pretty easy to edit the captured backgrounds with roundtripping to PS from the project library.

Indeed, I warned Greg that you wouldn't change the workflow basically. I would look for a solution using CpExtra widget, but you probably do not have that widget. And it would mean that you have to rename all the captions. 

In the default software sims, the Hint caption appears as a Rollover. Did you ever think about that possibility? If you have shapes as text containers - which is possible although you always say 'caption' - it is easy to convert them to a Rollover shape. Probably too much work, because you need to define another shape to activate the rollover. But at this moment you also needed to have a button on each slide to activate the Hint, correct?

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
Advisor ,
Aug 02, 2023 Aug 02, 2023

Copy link to clipboard

Copied

I am not 100% sure of the plan here but from what I can tell - it sounds like we have two captions on a slide and want to hide one of them at the start with the ability to show it on the click of a button. Are these two separate smartshapes with text?

 

Here is what I might do using JavaScript - and it is best to implement this up front so that as you replicate the captions (smartshapes) you also replicate the JavaScript that is attached to them.

 

In essence - you make the caption a button with two states one blank (default) and one with the hint. Clicking the button will change the state but since the JavaScript is the exact same for all instances of the button - you don't have to do the little updates save for the change of the hint text itself.

 

Basically - this is the code 

 

var thisBox=$(event.target)[0].id;
cp.goToNextState(thisBox);

 

The nice part about this code is that it does not matter what the name of the object is. Clicking the button would grab the name of the object for you and then use that name to go to the next state of the button like a toggle.

 

Hopefully that helps somewhat. It is probably the least complicated JavaScript solution I can think of for this scenario.

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
Community Expert ,
Aug 02, 2023 Aug 02, 2023

Copy link to clipboard

Copied

@Stagprime Greg, I don't think the OP wants to change the workflow as he mentioned. Did you ever create a software sim in Show, Try, Test modes? Apparently OP has already added both text captions, and each slide has its set of two captions with unique IDs. And he wants an easy quick way to hide all the Hint captions on 100 slides, and later similar to show them. 

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
Community Beginner ,
Aug 02, 2023 Aug 02, 2023

Copy link to clipboard

Copied

Thank you. Yes, that is spot on. To give more detail the 100 slides for show me all have different instructions within the text captions. I have then duplicated the 100 slides for the try me. The text captions are then manually duplicated on each slide within the try me and a new style applied. As I'm duplicating the original text caption the duplicated caption always has the higher unique ID number. I was unsure if it was possible to due to the text caption IDs all starting with "Text_Caption" then the number eg 39 then 40 etc if they could be wildcard selected then put into a loop to find the lowest numbered caption and then the lowest hidden. Again thanks for any assitance provided. Happy to further clarify if required.

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
Community Beginner ,
Aug 02, 2023 Aug 02, 2023

Copy link to clipboard

Copied

Thank you. I can see Lilybiri has followed up below. Although this solution looks great it would involve a change to ways of working that can't be implemented at the moment but happy to explore for future revisions. Thanks for your help.

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
Advisor ,
Aug 02, 2023 Aug 02, 2023

Copy link to clipboard

Copied

What is tricky about this is that all of the objects on your stage are added to an array but not always in the same order or at the same index value... etc. That makes it tough to pinpoint.

 

I did a little work on something you could at least give a try.

The code will find the array of objects for the current slide and then separate out the captions to a new array.

Then the code will hide the first item in the array of captions. Hopefully it populates the new array in numerical order.

These are on timeouts as the first one needs to wait so the slide can be fully populated to grab the array and the second one needs to wait for the first array to be created. You can play with the timing and see how quick you can get away with.

This code would go on each slide as an onEnter JavaScript event.

setTimeout(function() {
slideID=$(".cp-frameset").attr("id"); 
myArray=cp.D[slideID].si; 
},500);

setTimeout(function() {
const filtered = (col) => myArray.filter(i => i.n.includes(col));
const output = filtered('Caption');
newArray=output;
cp.hide(newArray[0].n);
},1000);

 

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
Community Beginner ,
Aug 03, 2023 Aug 03, 2023

Copy link to clipboard

Copied

Thank you very much for your hard work, time and effort. This is exactly what I was looking for, and it worked flawlessly.Very much appreciated.

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
Advisor ,
Aug 03, 2023 Aug 03, 2023

Copy link to clipboard

Copied

Glad to hear that this worked for you. I appreciate the follow up.

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
Community Beginner ,
Aug 04, 2023 Aug 04, 2023

Copy link to clipboard

Copied

Apologies for the follow up. Just looking to tap into your expertise again if possible. Is there a way the above JavaScript can be extended to hide all the visible buttons on the same slide. One is a hint and the other is a home button. These are visible during the try me segment and I am using your JavaScript that is working great to hide the text caption but it would be fantastic if this extended to hiding the the visible buttons for test me. Currently removing them manually on every slide. Again thanks in advance for your great help. 

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
Advisor ,
Aug 04, 2023 Aug 04, 2023

Copy link to clipboard

Copied

Do you have a way to distinguish the buttons apart from other objects on the stage?

Like we had with "Caption"?

A regular smart shape and a smart shape turned into a button keep the same name so we cannot separate them based on ID unless you changed the names.

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
Community Beginner ,
Aug 04, 2023 Aug 04, 2023

Copy link to clipboard

Copied

Hi, thank you for the quick response. One is titled "Button_Hint_" and the other "Button_Home_". Both are followed by incremental numbering due to the repition throughout the slides.Thanks

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
Advisor ,
Aug 04, 2023 Aug 04, 2023

Copy link to clipboard

Copied

If you want to hide them both... and... there are no other objects on the stage with Button appearing in the name...

try this

You'll notice the first part is the same - to grab the current slide ID and array of objects.

What changes in the second part is that we filter for 'Button' instead of 'Caption'

Then - instead of simply hiding the first one (newArray[0]) - we cycle through the whole array and hide them all.

 

setTimeout(function() {
slideID=$(".cp-frameset").attr("id"); 
myArray=cp.D[slideID].si; 
},500);

setTimeout(function() {
const filtered = (col) => myArray.filter(i => i.n.includes(col));
const output = filtered('Button');
newArray=output;

for(i=0;i<newArray.length;i++) {
cp.hide(newArray[i].n);
}

},1000);

 

 

 

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
Community Beginner ,
Aug 04, 2023 Aug 04, 2023

Copy link to clipboard

Copied

That is brilliant. Thank you. Worked pefectly. Much appreciated.

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
Advisor ,
Aug 04, 2023 Aug 04, 2023

Copy link to clipboard

Copied

LATEST

Great news! Now to figure out what to do with your extra time on a Friday! 🙂

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
New Here ,
Aug 03, 2023 Aug 03, 2023

Copy link to clipboard

Copied

Thanks 

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