Forum Discussion
Help - Calling all Javascript experts!
Hello,
Appreciate this post is quite old, but hope someone is looking and can help!!
I have used this method to create a PDF certificate, however, on the certificate, the name is the wrong way round. The actual Storyline variable is the correct way around - just not on the PDF.
On the slide:
On the PDF:
Code on Slide Master:
$(".top-ui-bg").css("background-color", "#54565B");
$(".area-primary").css("background-color", "#54565B");
$(".cs-slide-container").css("background-color", "#54565B")
$(".sidebar-contents").css("background-color", "#54565B")
$(".cs-glossary").css("background-color", "#54565B")
$(".panel-content-menu").css("background-color", "#54565B")
var player = GetPlayer();
function findLMSAPI(win) {
if (win.hasOwnProperty("GetStudentID")) return win;
else if (win.parent == win) return null;
else return findLMSAPI(win.parent);
}
var lmsAPI = findLMSAPI(this);
var myName = lmsAPI.GetStudentName();
var array = myName.split(',');
var newName = array[1] + ' ' + array[0];
player.SetVar("newName", newName);
Code on the actual slide:
var player = GetPlayer();
if (typeof GetStudentName == "function") {
var myName = GetStudentName();
localStorage.setItem("g_certificate",myName)}else{
localStorage.setItem("g_certificate", player.GetVar("newName"));
}
Code on Click here for PDF button:
var g = window.open("./pdf_cert/index.html");
I haven't changed anything else to do with the certificate or the pdf_cert folder that you copy into the output file.
Please help!!
Also - As long as it displays firstname lastname (no comma) on the certificate, we don't have to have it on the slide (if it makes it easier).
Cheers, Laura
PS - using 360 and publishing in HTML only