basic arrow up/down

This commit is contained in:
Martijn Voncken 2008-06-24 19:36:30 +00:00
parent 76a19a7d5a
commit a58b26c550
2 changed files with 59 additions and 3 deletions

View File

@ -106,6 +106,7 @@ on_click_action = on_click_do_nothing;
/*toobar buttons, */ /*toobar buttons, */
function toolbar_post(url, selected) { function toolbar_post(url, selected) {
if ((!selected) || (state.selected_rows.length > 0)) { if ((!selected) || (state.selected_rows.length > 0)) {
var ids = state.selected_rows.join(',');
var ids = state.selected_rows.join(','); var ids = state.selected_rows.join(',');
var form = $('toolbar_form'); var form = $('toolbar_form');
form.action = url +ids; form.action = url +ids;
@ -125,6 +126,38 @@ function toolbar_get(url , selected) {
return false; return false;
} }
/*arrow-navigation*/
torrent_table = {}
torrent_table.select_prev = function () {
//torrent_tab
var prev_id = state.selected_rows[0];
var i = torrent_table.torrents.indexOf(prev_id);
var id = torrent_table.torrents[i - 1];
deselect_all_rows();
select_row(id);
open_inner_details(id);
}
torrent_table.select_next = function () {
var prev_id = state.selected_rows[0];
var i = torrent_table.torrents.indexOf(prev_id);
var id = torrent_table.torrents[i + 1];
deselect_all_rows();
select_row(id);
open_inner_details(id);
}
torrent_table.keydown = function (oEvent) {
switch(oEvent.keyCode) {
case 38: //up arrow
torrent_table.select_prev();
break;
case 40: //down arrow
torrent_table.select_next();
break;
}
};
/*stuff copied from various places:*/ /*stuff copied from various places:*/
/*http://www.w3schools.com/js/js_cookies.asp*/ /*http://www.w3schools.com/js/js_cookies.asp*/
function setCookie(c_name,value,expiredays) function setCookie(c_name,value,expiredays)
@ -150,3 +183,22 @@ if (document.cookie.length>0)
} }
return "" return ""
} }

View File

@ -2,16 +2,20 @@ $def with (torrent_list, organize_filters)
<script language="javascript"> <script language="javascript">
/*for select_all shortcut/button*/ /*for select_all shortcut/button*/
var all_torrents = [ torrent_table.torrents = [
$for t in torrent_list: $for t in torrent_list:
"$t.id", "$t.id",
] ]
state.base_url = '$base'; state.base_url = '$base';
document.onkeydown = torrent_table.keydown;
</script> </script>
<table class="torrent_list" id="torrent_table" border=0 cellspacing=0 cellpadding=2 id="torrent_list" > <table class="torrent_list" id="torrent_table" border=0 cellspacing=0 cellpadding=2 id="torrent_list">
<thead class="fixedHeader"> <thead class="fixedHeader">
<tr> <tr>
$:(sort_head('state', 'S')) $:(sort_head('state', 'S'))