Supporting each other

Community forums

Welcome, Guest
Username: Password: Remember me
This is the place for questions about learning design and pedagogy; how to use different page types for different purposes.
  • Page:
  • 1
  • 2

TOPIC:

Navigation using page timers 9 years 8 months ago #2067

  • Mark7801
  • Mark7801's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
  • Posts: 42
  • Thank you received: 0
Hi all,
I would like to limit the view time of certain pages, like a Title page viewed only for a few seconds, then navigate automatically to the next page without user input. I know I can do this with navigate on narration but then I need to create timed blank sound files... or is there another way? This would be helpful for simple slide type presentations.
Regards,
Mark

Please Log in or Create an account to join the conversation.

Last edit: by Mark7801.

Navigation using page timers 3 years 10 months ago #6513

  • ForteanOrg
  • ForteanOrg's Avatar
  • Visitor
  • Visitor
Any updates on this one?

There seems to be some code in Xerte now that calls a function on each tick and one when the timer is zero, according to this change:
https: //github.com/thexerteproject/xerteonlinetoolkits/commit/e8f0abaca546a82b8c43f68f3ac157f6880c8534 (sorry that you have to cut-and-paste it, but "as a new user I'm not allowed to put in URL's " (sigh) - but I'm not sure if this is meant to be a hook into a user defined function (so: something you can write yourself and put in a 'script' container) or what? If so, any examples would be welcomed..

Any ideas, anybody?

Please Log in or Create an account to join the conversation.

Navigation using page timers 3 years 10 months ago #6514

  • jjs
  • jjs's Avatar
  • Offline
  • Platinum Member
  • Platinum Member
  • Posts: 397
  • Thank you received: 71
Hi again,

Yes you are correct that they are simply hooks that I added a while back for some reason (I recall adding them but not for what purpose or project)...

They are page level hooks, i.e. if you add a custom page then you have init, pageChanged, pageResized, onTimerTick and onTimerZero - however none of the current pages appear to use onTimerTick or onTimerZero... A timer can be added on any of the pages now (Page Timer in optional properties) but not sure which if any pages use the Page Timer onTimerZero is used in the Wordsearch page, within Games.

If you need to access the current page object in script then you can use:

window[x_pageInfo[x_currentPage].type]
and thus you could modify the page object in script by doing

window[x_pageInfo[x_currentPage].type].onTimerTick = function (timer) {
  console.log(timer);
}
Tick doesn't fire on zero so this will print numbers: ...,10, 9, 8, 7, 6, 5,4,3,2,1
If you want zero then wire up the zero hook

window[x_pageInfo[x_currentPage].type].onTimerZero = function () {
  console.log('Zero');
}
While it's possible to do this it is undocumented behaviour, could be deprecated or changed at any time and could make the learning object unstable.

Here be dragons...

Please Log in or Create an account to join the conversation.

Last edit: by jjs.

Navigation using page timers 3 years 10 months ago #6516

  • ForteanOrg
  • ForteanOrg's Avatar
  • Visitor
  • Visitor
Ah, yes, thank you, that works.

I had been fiddling around with something like you suggested and had put in some debugging code like this:
if (typeof window[x_pageInfo[x_currentPage].type].onTimerZero === "function") {
      alert("ja hoor het is een functie");
} else {
      alert ("Nee, het is "+typeof window[x_pageInfo[x_currentPage].type].onTimerZero+" op pagina "+x_currentPage);
}

(The comments are in Dutch, but you'll probably get their meaning..)

But somehow I could not get the corresponding function to work. But it works now (and the popup signals that indeed, the override worked). Thanks again, great help.

I don't think the code will be unstable. Yeah, you could remove these hooks, I guess, but you did put them in in 2016, so they are there for quite a while ... so I'm taking an educated guess they will remain there for a while (especially now you know at least ONE user is doing something with them :-) )

Thanks again, much appreciated.

Please Log in or Create an account to join the conversation.

Navigation using page timers 3 years 10 months ago #6517

  • ForteanOrg
  • ForteanOrg's Avatar
  • Visitor
  • Visitor
Just an addition, for those in search of this type of solution that might stumble across this later on.

The suggested method does not work for all page types. I tried this with the PDF page and it works. The hooks are checked and the functions are called - it works. You will have to switch the timer on and have it visible, or else it will not. The PDF page, BTW, does not do what I expected it to do, but that's another story, I will start a thread on that later on.

It does not work on a text page. Possibly not on other page types either, I haven't checked.

Please Log in or Create an account to join the conversation.

Last edit: by ForteanOrg. Reason: Typo

Navigation using page timers 3 years 10 months ago #6519

  • jjs
  • jjs's Avatar
  • Offline
  • Platinum Member
  • Platinum Member
  • Posts: 397
  • Thank you received: 71
Hi,

Ah, yes, well, em... I have to hold my hands up and say that is my fault regarding the timer not working on the text page... the issue is that the pageType comes from the node name in the xml which is fine but in javascript the attribute .text is reserved thus the text page is actually called simpleText...

What I should do and will fix at some point (you can modify your own copy in the meantime) is change the function x_countdownTicker (at around line 2280 in xenith.js):

var x_countdownTicker = function () {
        x_countdownTimer--;
        var pageType = x_pageInfo[x_currentPage].type;
        pageType = (pageType === 'text') ? 'simpleText' : pageType 
        if (x_countdownTimer > 0) {
            $("#x_footerBlock #x_pageTimer").html(x_timerLangInfo[0] + ": " + x_formatCountdownTimer());

         	// If page model wants timer tick to know then pass value
        	if (typeof window[ pageType ].onTimerTick === "function") window[ pageType ].onTimerTick(x_countdownTimer);
        }
        else {
            window.clearInterval(x_timer);
            $("#x_footerBlock #x_pageTimer").html(x_timerLangInfo[1]);

        	// If page model wants to know then pass event
        	if (typeof window[ pageType ].onTimerZero === "function") window[ pageType ].onTimerZero();
        }
    };

I should say that this is right off the top of my head and I have not tested this change yet!!

Yes, regarding the timer it has to be on and visible... perhaps i'll change that too when I next work on this... thanks for the heads up about the text page though that's useful.

Regards,

John

Please Log in or Create an account to join the conversation.

Last edit: by jjs.
  • Page:
  • 1
  • 2
Moderators: ingdon
Time to create page: 0.067 seconds
Copyright © 2024 The Xerte Project.
Xerte logo Apereo logo OSI Logo

Search