Greetings.
I am still learning javascript and have been trying for some time to figure out where / what is missing in the following. This is code attached to a password submit button that Mark Hunte posted and I have been trying to modify (with a lot of his gracious time and assistance).
My challenge is I can not figure out the last few lines of code and how/what is being processed. I need to add a statement that will take any incorrect password entry for current scene “Starlight Question” (including someone who may just click the submit button without entering any password), and send it to scene “Starlight Denied”.
Right now it goes to “Promo”.
And the same for current scene “Mission Restart”. It should go to scene “Mission Command” on incorrect password or submit button. However, it also goes to “Promo”.
I managed (by dumb luck) to get it to go to “Mission Command” if there is no password entered and just the submit button is clicked, but that applies to both current scenes, which is not correct.
I do not understand the thisName value and proper command/syntax to get what I need. Any help would be appreciated.
var textAreas = $('*[class^="HYPE_element\ textArea"]') ;
var theClassName = textAreas[0].className.split("HYPE_element ")[1];
var thisName = $("." + theClassName).children()[0];
var currentScenName = hypeDocument.currentSceneName();
//var password = thisName.value;
var thePassword;
var jumpScene;
if (currentScenName == ‘Promo’){
thePassword = "dg"
jumpScene = ‘Mission Command’
}
if (currentScenName == ‘Starlight Question’){
thePassword = "23"
jumpScene = ‘Starlight Correct’
}
if (currentScenName == ‘Mission Restart’){
thePassword = "20"
jumpScene = ‘Mission Command’
}
{pwd = password = thisName.value;
if (pwd !== "") {
if (password == thePassword){
hypeDocument.showSceneNamed(jumpScene, hypeDocument.kSceneTransitionCrossfade, 1.1)
}
thisName.value = “”;
hypeDocument.showSceneNamed(“Promo”, hypeDocument.kSceneTransitionInstant);
} else {
thisName.value = “”;
hypeDocument.showSceneNamed(“MIssion Command”, hypeDocument.kSceneTransitionInstant);
}
}
A lot to follow, I know. But hopefully it makes sense to those who understand
Your time and feedback is greatly appreciated.
Thank You.
DG