From fa9c8051d76faecd466ec1629772da34713a90f7 Mon Sep 17 00:00:00 2001 From: Kubat <mael.martin31@gmail.com> Date: Fri, 12 Feb 2021 17:42:26 +0100 Subject: [PATCH] Add shortcut to scroll to the current kara in queue --- instance/main.js | 24 ++++++++++++++++++++++-- instance/views/kara.ejs | 2 +- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/instance/main.js b/instance/main.js index c0f47c3..ead4ab6 100644 --- a/instance/main.js +++ b/instance/main.js @@ -104,8 +104,28 @@ window.onload = () => { 'keydown', e => { if (e.ctrlKey && e.keyCode == 70) { + /* ctrl + F */ logger.debug('instance', 'Focus find bar'); $('#filterInput').focus(); + } else if (e.ctrlKey && e.keyCode == 67) { + /* ctrl + C */ + logger.debug('instance', `Focus current kara in queue, id is "#pos-${currentSong + 1}"`); + $('#panelRight').animate( + { + scrollTop: 0, + }, + 0 + ); + var offset = $(window).height() / 2; + $('#panelRight').animate( + { + scrollTop: + $(`#pos-${currentSong + 1}`) + .parent() + .offset().top - offset, + }, + 0 + ); } }, false @@ -221,13 +241,13 @@ ipcRenderer.on('send-song-time-data', (event, timeData) => { } document.getElementsByClassName('karaQueue')[timeData.song].style.background = '#6b7d8e'; } else { - if (document.getElementsByClassName('karaQueue')[timeData.song]) + if (document.getElementsByClassName('karaQueue')[timeData.song]) { document.getElementsByClassName('karaQueue')[timeData.song].style.background = '#4e5d6c'; + } } }); ipcRenderer.on('send-runnings', (event, arg) => { - logger.debug('instance', `lektord: ${arg.lektord}, klkt: ${arg.klkt}`); $('#running-lektord').prop('checked', arg.lektord); $('#running-klkt').prop('checked', arg.klkt); }); diff --git a/instance/views/kara.ejs b/instance/views/kara.ejs index cba6f72..d02ed28 100644 --- a/instance/views/kara.ejs +++ b/instance/views/kara.ejs @@ -5,5 +5,5 @@ <%= kara.type %> - <b><%= kara.title %></b> <i>[<%= kara.author %>]</i> </span> <% if (kara.hasOwnProperty('position')) { %> - <span class="karaElement p-3 bd-highlight karaPosition"><b><%= kara.position %></b></span> + <span id="pos-<%= kara.position %>" class="karaElement p-3 bd-highlight karaPosition"><b><%= kara.position %></b></span> <% } %> -- GitLab