Merge pull request #20 from codegaze/navfeature

Guideline navigation with arrow keys
This commit is contained in:
Richard Rutter
2015-09-14 09:23:33 +01:00
2 changed files with 21 additions and 3 deletions

View File

@@ -58,10 +58,10 @@ if (isset($keys[array_search($item_num, $keys)-1])) {
<ul id="nextprev">
<?php
if ($next_num) {
echo "<li><span>&#8594;</span><a href='/$next_num' title='Read next guideline'>$next_item</a></li>";
echo "<li><span>&#8594;</span><a href='/$next_num' title='Read next guideline' id='next_guideline'>$next_item</a></li>";
}
if ($prev_num) {
echo "<li><span>&#8592;</span><a href='/$prev_num' title='Read previous guideline'>$prev_item</a></li>";
echo "<li><span>&#8592;</span><a href='/$prev_num' title='Read previous guideline' id='previous_guideline'>$prev_item</a></li>";
}
?>
</ul>
@@ -74,5 +74,6 @@ include($dr . "book.inc.php");
<?php include($dr . "footer.inc.php") ?>
<script src="/js/global.js"></script>
</body>
</html>

View File

@@ -1 +1,18 @@
/* No JS required any more */
/* No JS required any more */
document.onkeydown = function (e) {
switch (e.keyCode) {
case 37:
if (document.getElementById('previous_guideline') !== null)
window.location = document.getElementById('previous_guideline').href;
break;
case 39:
if (document.getElementById('next_guideline') !== null)
window.location = document.getElementById('next_guideline').href;
break;
default:
return; // Do nothing for the rest
}
};