Explore the community Forums Lectora Tips and tricks Navigation with java Script and variables

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #396433 Score: 0
    Profile photo of Benjamin chamish
    Benjamin chamish
    Member
    beginner
    intermediate
    friend finder
    Group Member
    wise owl
    picture perfect
    curious george
    @bchamish3198

    I have button called Responsibilities Summary, it branches to a section within my title, it has 4 pages in the section.  The users don’t have to view these page at all or can look at all of them. The Responsibilities Summary button is on every page in my title.

    I created a variable SummaryGoBack. I added an action to the Responsibilities Summary button to modify SummaryGoBack and sets it equal to VAR(CurrentPageName) and also to go to the Responsibilities Summary section.

    My goal is, on the Responsibilities Summary section pages to have a button on each page that will take you back to the page you left from.

    Is Var(CurrentPageName) okay (all my pages have unique names) or is there a better locator I should be using, and what would the java scrip be I would need to put on the “Back to course” button on the Responsibilities Summary section pages?

    thanks in advance for any help!

    #401432 Score: 0
    Profile photo of Math Notermans
    Math Notermans
    Member
    contributor
    intermediate
    advanced
    friend finder
    junior moderator
    advocate
    LUC16 Attendee
    LUC16
    wise owl
    curious george
    117 pts
    @mnotermans5114

    Hi Benjamin, Trying to make something like this work i notice a few things to be aware of.
    For example… if you use Chapters and Sections… well the html-name of your page will have those included.
    For example i have a Chapter named ‘Dragged and drop with Javascript’ in which i now have 1 page called ‘Simple sample’. If i set the variable to CurrentPageName, it will be simply ‘Simple sample’  If i use that in the summary to get back to…well it fails..the page cannot be found…

    I got a getBack(); function in my scripts that returns indeed to the proper last page visited.

    function getBack(){
    lastPageVisited = VarSummaryGoBack.getValue();
    trivExitPage(lastPageVisited ,true);
    }

    Like this it will not work, trying to go back to the real name of the page… Simple sample in my example.
    Taking however into account the Chapter and possibly Section your page is in it will work.
    And as a extra from Trivantis…all uppercast characters will be converted to undercast and all spaces to _
    So if your page is in a Chapter called ‘Drag and drop with Javascript’ and the page is called ‘Simple sample’
    then the function below will get it back to that page.

    function getBack(){
    lastPageVisited = VarSummaryGoBack.getValue();
    var test = “drag_and_drop_with_javascript_simple_sample.html”;
    trivExitPage(test,true);
    }

    So what we need to do to get this working, is getting the proper name including chapters and sections and convert uppercast to undercast and replace spaces by _

    I am working on a sample of this in Lectora Online, when its working i export a package and add it here.

    Kind regards,
    Math

    PS. there is also a variable called CurrentPageId.. gonna check what that one does…if there is some array of all pages, then i do think the CurrentPageId might get to the actual pagename…

    #401434 Score: 0
    Profile photo of Math Notermans
    Math Notermans
    Member
    contributor
    intermediate
    advanced
    friend finder
    junior moderator
    advocate
    LUC16 Attendee
    LUC16
    wise owl
    curious george
    117 pts
    @mnotermans5114

    Basically this function now works with a few caveats i have to fix somehow.

    function createLastPageName(){
    lastPageVisited = VarSummaryGoBack.getValue().toLowerCase().replace(/\s+/g, ‘_’);
    //lastSectionVisited = VarLastSectionName.getValue().toLowerCase().replace(/\s+/g, ‘_’);
    lastChapterVisited = VarLastChapterName.getValue().toLowerCase().replace(/\s+/g, ‘_’);
    constructedPageName = lastChapterVisited+”_”+lastPageVisited+”.html”;
    console.log(“createLastPageName: “+constructedPageName);
    trivExitPage(constructedPageName,true);
    }

    I only have Chapters in my title, so no need for the Sections.
    In any Chapters or Sections you need to have an action setting the LastChapter/LastSection variable.

    Issues i would need to solve.
    – When you have pages outside Chapters and Sections i do have to find a solution for that. Probably nulling it.
    – When using shortnames when publishing, i dont have a clue about the pageNames, have to test that… and figure out how to check and process that.
    – Not sure how Tests are working. Would need to check that.
    – All now in Lectora Online, have to see if there is a difference when using it in Inspire or Publisher

    Quickly did a testrun with publishing as Short-ID named, and that looked promising. I do think Lectora uses the earlier mentioned CurrentPageId to create names for the pages. Something like pageCurrentPageId. So setting your publishing to Short-ID probably simplifies things…no need for worrying about Chapters and Sections..just add the CurrentPageId and your good..

    Testing that now.

    #401437 Score: 0
    Profile photo of Math Notermans
    Math Notermans
    Member
    contributor
    intermediate
    advanced
    friend finder
    junior moderator
    advocate
    LUC16 Attendee
    LUC16
    wise owl
    curious george
    117 pts
    @mnotermans5114

    Yes that works way better. No worry about Chapters and Sections. You just have to ensure a variable for LastPageId is updated on every page… and publish with this option checked: Convert Page Names to short ID-based Names
    And then with this function you can go back to your last stored page..

    function getBackPageId(){
    lastPageId = VarLastPageId.getValue();
    var test = “page”+lastPageId+”.html”;
    console.log(“page: “+test);
    trivExitPage(test,true);
    }

    Make sure your summary pages dont inherit any code storing the IDs and all will work fine.

    Kind regards,

    Math

    #401518 Score: 0
    Profile photo of Benjamin chamish
    Benjamin chamish
    Member
    beginner
    intermediate
    friend finder
    Group Member
    wise owl
    picture perfect
    curious george
    @bchamish3198

    Wow Math, nicely done.  Thanks for building this, I’ll try it out.

    One other question for  you regarding Lectora Online.  Is there any big difference between it and Inspire.  I have a coworker and it seems like online would help us work together a lot better, right now we store titles on google drive and some titles have gotten mixed up when someone had it opened and someone else went in and starting saving. We have to build our titles to 508 compliance and I wasn’t sure if inspire and online had the same functionality.

    Thanks again!

    #401532 Score: 0
    Profile photo of Math Notermans
    Math Notermans
    Member
    contributor
    intermediate
    advanced
    friend finder
    junior moderator
    advocate
    LUC16 Attendee
    LUC16
    wise owl
    curious george
    117 pts
    @mnotermans5114

    Yes. If cooperation and teamwork is important, go for Online. There are differences for sure, but if you work in a team Online for sure beats Inspire. The biggest differences between Inspire and Online are in working with Javascript. When Online came out i was a beta-tester, and then i didnot like Online and kept working in Inspire. Last half year i got projects with teams that work in Online only…and went on a journey discovering how to work with Javascript in Online, and i am quite enthusiast now about Online. Main functionality is the same as Inspire, bonuspoints for Online when working in a team ( although not perfect for sure, but the development is quite active ). Only working with Javascript has its hurdles, cause there are some changes under the hood that are quite different. I do suspect that Lectora Inspire 18 will have similar changes…

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.