I've implemented arrow key navigation on a nested pages template (it's for a comic, so you can navigate through the pages easier), using this script;
I don't really know javascript at all (really gotta learn it someday though
), I found this script and edited it to work with the couch template - and it works really well except for when you get to the first page and navigate back, or on the last page and navigate forward. Obviously there's no page beyond these and so you're taken to a null page. Not so good obviously.
I'd want to either disable forward navigation on the last page/backward navigation on the first page, OR make it return to the listview/archive page when there's no page to navigate to. Whichever is easier
- Code: Select all
<script type="text/javascript">
$(document).ready(function() {
document.onkeydown = function()
{
var j = event.keyIdentifier
if (j == "Right")
window.location = nextUrl
else if (j == "Left")
window.location = prevUrl
}
});
$(document).ready(function() {
var nextPage = $("#comic_next_page")
var prevPage = $("#comic_prev_page")
nextUrl = nextPage.attr("href")
prevUrl = prevPage.attr("href")
});
</script>
I don't really know javascript at all (really gotta learn it someday though

I'd want to either disable forward navigation on the last page/backward navigation on the first page, OR make it return to the listview/archive page when there's no page to navigate to. Whichever is easier
