Mercurial > hg > index.fcgi > www > www-1
changeset 25:8314130afe1d
add javascript to handle next/prev/up shortcut keys
author | paulo@twcdns.fastsearch.net |
---|---|
date | Tue, 26 Apr 2011 00:18:06 -0700 |
parents | 8689ba61e0e0 |
children | 56bb0cbf5385 |
files | pics/browse.php pics/common.php pics/np_keys.js |
diffstat | 3 files changed, 27 insertions(+), 3 deletions(-) [+] |
line diff
1.1 --- a/pics/browse.php Mon Mar 07 20:45:39 2011 -0800 1.2 +++ b/pics/browse.php Tue Apr 26 00:18:06 2011 -0700 1.3 @@ -2,6 +2,7 @@ 1.4 <HTML> 1.5 <HEAD> 1.6 <META NAME="generator" CONTENT="http://txt2tags.sf.net"> 1.7 +<SCRIPT TYPE="text/javascript" SRC="../np_keys.js"></SCRIPT> 1.8 <LINK REL="stylesheet" TYPE="text/css" HREF="index.css"> 1.9 <?php $title = basename(getcwd()) ?> 1.10 <TITLE><?php echo $title ?></TITLE>
2.1 --- a/pics/common.php Mon Mar 07 20:45:39 2011 -0800 2.2 +++ b/pics/common.php Tue Apr 26 00:18:06 2011 -0700 2.3 @@ -47,17 +47,17 @@ 2.4 for ($i = 0, $size = sizeof($files); $i < $size; $i++) { 2.5 if ($files[$i] == $getValue) { 2.6 if ($i > 0) { 2.7 - echo '<A HREF="browse.php?id=' . $files[$i - 1] . '" accesskey="p">'; 2.8 + echo '<A HREF="browse.php?id=' . $files[$i - 1] . '" ID="prev" accesskey="p">'; 2.9 echo '<IMG SRC="' . $thumbs_dir . $files[$i - 1] . '">'; 2.10 echo '</A>' . "\n"; 2.11 } 2.12 if ($i < $size - 1) { 2.13 - echo '<A HREF="browse.php?id=' . $files[$i + 1] . '" accesskey="n">'; 2.14 + echo '<A HREF="browse.php?id=' . $files[$i + 1] . '" ID="next" accesskey="n">'; 2.15 echo '<IMG SRC="' . $thumbs_dir . $files[$i + 1] . '">'; 2.16 echo '</A>' . "\n"; 2.17 } 2.18 echo '<br>' . "\n"; 2.19 - echo '<A HREF="./index.php#' . $files[$i] . '">'; 2.20 + echo '<A HREF="./index.php#' . $files[$i] . '" ID="up" accesskey="u">'; 2.21 echo '<IMG SRC="' . $browse_dir . $files[$i] . '"> '; 2.22 echo '</A>' . "\n"; 2.23
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/pics/np_keys.js Tue Apr 26 00:18:06 2011 -0700 3.3 @@ -0,0 +1,23 @@ 3.4 +function getKeypress(e) { 3.5 + c = null 3.6 + 3.7 + if (e.which == null) 3.8 + c = String.fromCharCode(e.keyCode); // IE 3.9 + else if (e.which != 0 && e.charCode != 0) 3.10 + c = String.fromCharCode(e.which); // All others 3.11 + 3.12 + if (c != null) { 3.13 + if (c == 'n') 3.14 + goHref('next'); 3.15 + else if (c == 'p') 3.16 + goHref('prev'); 3.17 + else if (c == 'u') 3.18 + goHref('up'); 3.19 + } 3.20 +} 3.21 + 3.22 +function goHref(id) { 3.23 + window.location.href = document.getElementById(id).href; 3.24 +} 3.25 + 3.26 +document.onkeypress = getKeypress