Skip to main content
Participating Frequently
April 20, 2018
Answered

Using External Javascript libraries in Adobe Captivate

  • April 20, 2018
  • 3 replies
  • 3591 views

I am creating Adobe Captivate simulations of a dental software. There are many instances where it would be useful to display a date based off of todays date.  For example, tomorrow's date (today's date + 1 day) or a month ago (today's date - 1 month).

I see that there are libraries out there which can simplify creating variables and populating them with calculated dates (www.datejs.com or www.momentjs.com are two I have looked at, I would welcome other recommendations on this too).

I am unsure how to incorporate these external libraries into my Adobe Captivate projects. One resource I looked at said to find the standard.js file (which I found at C:\Program Files\Adobe\Adobe Captivate 2017 x64\Templates\Publish) and add the text into the existing file. I have done that but don't seem to be getting anywhere with the custom commands these libraries offer.

Using Adobe Captivate 2017 (10.0.0.192) and Windows 10 Enterprise version 1709. I would classify myself as a beginner, but fast learner, in the world of JavaScript.

Thank you in advance for your help!

This topic has been closed for replies.
Correct answer TLCMediaDesign

The standards.js is a file used for swf output.

To use an external ibrary, you just need to place the *.js file in a location relative to your index.html file. I put mine in the assets/js/ folder.

Then you need to put an include in the head of the html file:

<script src="assets/js/yourJSfile.js" type="text/javascript"></script>

The script below creates a past date: If you create a vraible called pastDate it will populate it. You would need to change the milliseconds to correspond to the amount of days you want to go back. There are calculators o the internet to figure out the milliseconds for you.

var d = new Date();

var t = d.getTime();

var nd = new Date(t - 1209600000);

so if you have a variable in Captivate call pastDate, execute this JS

var d = new Date();

var t = d.getTime();

window.pastDate = new Date(t - 1209600000);

3 replies

Inspiring
November 24, 2018

Thanks, David. This works, but are you manually putting this external js file into the published folder? I'm using a file named utils.js.   If so, isn't utils.js deleted (or attempted delete) each time you publish after that? Therefore, you have to copy the external js file into the published folder every time you publish, right?

Is it possible to put the external js file in a location where does not have to be copied over each time you publish?  I notice that Cp2017 does not have a js folder in its install location (under html/assets). 

Here is what I tried for a solution:

I created a js folder in the assets folder inside the html folder at the program file location.  Then, I put the following line after the head tag in the index.html template file:  Program Files/Adobe/ Adobe Captivate 2017/HTML: <script src="assets/js/cputils.js"></script>

This seems to work, just wanted to check with an expert to see if I'm doing it right.

TLCMediaDesign
Inspiring
November 26, 2018

You can create the JS folder and edit the template file to have the JS include statement in it.

Inspiring
November 27, 2018

That works, thanks, David.

Stagprime2687219
Legend
April 20, 2018

Not sure if this will be helpful or not but it would not require any external libraries - just a little javascript on your buttons.

I have a variable called days.

A variable called todayDate

and a variable called calcDate

Then I have a button that does two things.

1. increments the variable days by 1

2. calculates the new date

The code on the button looks like this.

days=(++days);

calcDate=new Date(new Date().getTime()+(days*24*60*60*1000));

Then I have a shape to show the variable for todayDate and one for the calcDate

Each click of the button results in the calcDate increasing by one day.

It may not match what you are looking for exactly but maybe some food for thought.

RodWard
Community Expert
Community Expert
April 21, 2018

Some information here about how to set this up using only User Variables and Advanced Actions:

http://www.infosemantics.com.au/adobe-captivate/template/02-dynamic-date-functions

TLCMediaDesign
TLCMediaDesignCorrect answer
Inspiring
April 20, 2018

The standards.js is a file used for swf output.

To use an external ibrary, you just need to place the *.js file in a location relative to your index.html file. I put mine in the assets/js/ folder.

Then you need to put an include in the head of the html file:

<script src="assets/js/yourJSfile.js" type="text/javascript"></script>

The script below creates a past date: If you create a vraible called pastDate it will populate it. You would need to change the milliseconds to correspond to the amount of days you want to go back. There are calculators o the internet to figure out the milliseconds for you.

var d = new Date();

var t = d.getTime();

var nd = new Date(t - 1209600000);

so if you have a variable in Captivate call pastDate, execute this JS

var d = new Date();

var t = d.getTime();

window.pastDate = new Date(t - 1209600000);

Known Participant
September 24, 2019
Does an external library do the same as placing the Javascript on a Captivate slide using the script window? I tried an external Javascript library using script src, but it does not work. Thanks for any assistance