]>
Dogcows Code - chaz/talk-event-driven-programming-in-perl/blob - js/common.js
3 * Create a shortcut on a number key to jump to a named slide.
5 * Using the hotkey on the target slide will go "back" to the slide that was active before jumping
8 * Example: Jump to the slide named "myslide" when the "1" key is pressed.
9 * createHotkey(1, 'myslide');
11 function createHotkey(key
, slideName
) {
12 var targetSlide
= slideshow
.getSlideByName(slideName
);
14 document
.addEventListener('keydown', function(e
) {
15 if (e
.which
=== key
+ 48) {
16 var currentNum
= slideshow
.getCurrentSlideIndex() + 1;
17 var targetNum
= targetSlide
.getSlideIndex() + 1;
18 if (currentNum
!== targetNum
) {
19 lastSlide
= currentNum
;
20 slideshow
.gotoSlide(targetNum
);
23 slideshow
.gotoSlide(lastSlide
);
30 * Set a hotkey "u" to navigate backwards in time.
32 * If you get on the wrong slide, this might be the easiest way to get back on track. This is what
33 * you might expect the browser's "Back" button to do if it worked.
38 slideshow
.on('hideSlide', function(slide
) {
43 history
.push(slide
.getSlideIndex() + 1);
45 document
.addEventListener('keydown', function(e
) {
46 if (e
.which
=== 85 /* [u]ndo */) {
47 var lastNum
= history
.pop();
50 slideshow
.gotoSlide(lastNum
);
This page took 0.043454 seconds and 5 git commands to generate.