This is a prototype implementing the 'next' and 'previous' slide for the 
Logitech 
R400 presenter tool <https://derickrethans.nl/logitech-r400.html> using 
Mojolicious and jQuery. Really nice being able to insert perl code in the 
jQuery script! 

#!/usr/bin/env perl
use Mojolicious::Lite; 

get '/' => sub { shift->redirect_to('slide/1') };
get '/slide/:number' => sub {
my $c = shift;
my $number = $c->param('number');
$c->render ( number => $number );
} => 'slide'; 

app->start; 

__DATA__ 

@@ slide.html.ep
% title "slide $number";
% layout 'next_slide';
%= t p => "Slide $number"
<script>
$(document).ready(function(){
   $(document).keydown(function(e) {
if ( e.which === 33 ) {
window.location.href = '/slide/*<%= $number - 1 %>*';        
} else if ( e.which === 34 ) {
window.location.href = '/slide/*<%= $number + 1 %>*'; 
}
    });
});
</script> 

@@ layouts/next_slide.html.ep
<head>
<script 
src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js";></script>
</head>
<body>
<h2>Press 'page-up' for previous slide, 'page-down' for next slide</h2>
%= content
</body>


-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to