Looking for someone with javascript experience

Jan 25, 2018

I need to add some javascript to my SL course and am looking for someone with experience. 

11 Replies
Robert DeSimone

Hi Owen! 

Here's some more info. Let me know if you have any other questions.

The user’s email needs to get added to the URL so they are directed to the correct simulation. Here’s the URL with email address noted as %emailAddress%:

http://mdt.mentorlearn.com/AppStreaDemo.html?userID=%emailAddress%&simTypeID=4&moduleID=35&caseID=1

On the screen to launch the simulation, we want a text entry field for the user to enter their email. Then they would press a button to launch the URL and the URL with the email address would need to be used. 

The user supplied variable will come from the SL file.

 

OWEN HOLT

In StoryLine, create 3 text variables:
URLPart1 with the default value of http://mdt.mentorlearn.com/AppStreaDemo.html?userID=
URLPart2 which will store the user's email address
URLPart 3 with the default value of &simTypeID=4&moduleID=35&caseID=1

You will need an input field for the user to provide their email address and it should be stored in the URLPart2 variable.

Next, you will need a trigger to execute your JS code. Here is your JavaScript code (untested):

//Make a call to the SL player
var player=GetPlayer();

//Access all 3 parts of the target URL
var urlPart1 = player.GetVar("URLPart1");
var urlPart2 = player.GetVar("URLPart2");
var urlPart3 = player.GetVar("URLPart3");

//Concatenate the URL
var targetURL = urlPart1+urlPart2+urlPart3;

//Open new window with the target url
myWindow = window.open(targetURL);
myWindow.focus();

See Demo

Let me know if that works for you.


OWEN HOLT

Thank you for your kind words!

What I know about JS, I learned primarily from this community, asking questions, challenging myself and googling for solutions. I'm only scratching the surface!

What I will tell anyone who will listen is this, don't let it intimidate you. You don't have to be "tech savvy" or a "programmer" to learn some basics and apply some code to your courses.  

I haven't developed any course work on JS (maybe I should) but I have presented some JS basics at learning conferences and Articulate Roadshows.  

Of course, I'm always happy to help out here as well.

Michael Anderson

There's a good free tutorial here to get you started with the syntax of javascript https://www.w3schools.com/Js/  I've learned a lot from looking at code that others have posted here. Also, if I'm trying to accomplish something in particular, a Google search usually lands me at the stackoverflow web site where you will find lots of sample code for doing different things in javascript.

This discussion is closed. You can start a new discussion or contact Articulate Support.