File view with blame information shown in the left gutter beside each line.

barerepo / server / internal/httpd/static/keys.js
21 lines · 786b · 133728eaa05486504991b230f9d4c7e986b7defc
log files threads runs releases config jump to file t
133728e barerepo 1mo
1
// The only script in the product, two shortcuts inside chapter 25's 2kb, and every page works without it.
133728e barerepo 1mo
2
(function () {
133728e barerepo 1mo
3
function typing(el) {
133728e barerepo 1mo
4
var t = el.tagName;
133728e barerepo 1mo
5
return t === 'INPUT' || t === 'TEXTAREA' || t === 'SELECT' || el.isContentEditable;
133728e barerepo 1mo
6
}
133728e barerepo 1mo
7
document.addEventListener('keydown', function (e) {
133728e barerepo 1mo
8
if (e.metaKey || e.ctrlKey || e.altKey || typing(e.target)) return;
133728e barerepo 1mo
9
133728e barerepo 1mo
10
if (e.key === '/') {
133728e barerepo 1mo
11
var box = document.querySelector('input[name=q]');
133728e barerepo 1mo
12
if (box) { box.focus(); box.select(); } else { location.href = '/search'; }
133728e barerepo 1mo
13
e.preventDefault();
133728e barerepo 1mo
14
return;
133728e barerepo 1mo
15
}
133728e barerepo 1mo
16
if (e.key === 't') {
133728e barerepo 1mo
17
var files = document.querySelector('a[data-files]');
133728e barerepo 1mo
18
if (files) { location.href = files.getAttribute('href'); e.preventDefault(); }
133728e barerepo 1mo
19
}
133728e barerepo 1mo
20
});
133728e barerepo 1mo
21
})();
history · rawbarerepo 0.1.0