From ee26ebe43d89016c3014e030041e363e337f4ff5 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sun, 1 Sep 2013 16:16:02 -0400 Subject: [PATCH] controls: add shortcut keys for a bunch of items --- main.html | 2 +- main.js | 29 +++++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/main.html b/main.html index 89489d8..90e2182 100644 --- a/main.html +++ b/main.html @@ -69,7 +69,7 @@ div#footer {
- + diff --git a/main.js b/main.js index 9155650..aa4c7bd 100644 --- a/main.js +++ b/main.js @@ -56,6 +56,23 @@ window.onload = function() { }); }; +window.onkeypress = function(e) { + switch (e.keyCode) { + case 49: // 1 + show_page('controls'); + break; + case 50: // 1 + show_page('metadata'); + break; + case 51: // 1 + show_page('playlist'); + break; + case 52: // 1 + show_page('options'); + break; + } +}; + function mpc_refresh() { mpc.status(); } @@ -191,11 +208,17 @@ function update_sync_settings() { } function init_ui(local_keys, sync_keys, options) { + var ele, i; + /* Setup footer */ + i = 1; [ - 'controls', 'metadata', 'options', 'playlist', + 'controls', 'metadata', 'playlist', 'options', ].forEach(function(id) { - document.getElementById('tab.' + id).onclick = show_page; + var ele = document.getElementById('tab.' + id); + ele.onclick = show_page; + ele.title = id + ' [' + i + ']'; + ++i; }); /* Setup control tab */ @@ -207,6 +230,8 @@ function init_ui(local_keys, sync_keys, options) { var ele = window['ui_mpc_' + id] = document.getElementById(id); ele.onchange = ele.onclick = window['tramp_mpc_' + id]; ele.title = id; + if (ele.accessKey) + ele.title += ' [' + ele.accessKey + ']' }); window['ui_mpc_currtime'] = document.getElementById('currtime'); -- 2.39.5