Forum Discussion
Scene Progress bars using javascript
- 4 months ago
Oops, you need to modify one additional line to make it work as intended.
const progress = "Topic1_Progress"; // PROGRESS VARIABLE (Case Sensitive).
For each version of the script (for each bar), assign a new variable name, if you want the bars to show different progress levels. Topic1..., Topic2..., etc.
I mocked up a quick demo slide with 3 bars. Click to ovals to move the bars.
Demo: https://360.articulate.com/review/content/727f8af0-8928-4cd0-8ef5-c1232f613ce8/review
I attached the .story file.
Note, there are a number of ways to improve this code to make it more flexible, and also make it so you only need one version on the master slide to handle any number of bars. Just switch out some of the static variables with Storyline variables and set those before triggering the script.
What does "nothing works" mean exactly. I haven't had time to test, but it may be because this is checking for an existing progress bar with the fixed ID of "pBar". Trying to use this code to add a second bar will still find the first bar with this ID label. You also have conflicting "bgBar" ids. Maybe try appending the data-model-id that you are specifying in the first line to the end of the "pBar" and "bgBar" strings, so it remains unique.
Try changing the beginning like this:
const id = "5xxf4t4A2ET"; // "data-model-id" OF SL RECTANGLE
const myDiv = document.querySelector('[data-model-id="' + id + '"]');
Then replace any "pBar" strings with "pBar-"+id
and "bgBar" with "bgBar-"+id
After that, you can change the id in line 1, and it will create unique pBar or bgBar ids
Keep in mind that the data-model-id may get changed internally due to a SL update or some other circumstance, which would break your code.