ssb: Alt+up/down to cycle through channels.
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 18m53s
All checks were successful
Build Tilde Friends / Build-All (push) Successful in 18m53s
This commit is contained in:
parent
83e025d0bb
commit
ee20b87ee2
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"type": "tildefriends-app",
|
"type": "tildefriends-app",
|
||||||
"emoji": "🐌",
|
"emoji": "🐌",
|
||||||
"previous": "&hWgKPOx3M3T7BufeywObcOCHvsdRfVAoZ9LErkPhJPE=.sha256"
|
"previous": "&tkrwd7UkPaWUk9189g3D08N44EjT0AJOlDLw6oMfbpY=.sha256"
|
||||||
}
|
}
|
||||||
|
@ -97,6 +97,36 @@ class TfElement extends LitElement {
|
|||||||
this.channels = Object.keys(channel_map).sort();
|
this.channels = Object.keys(channel_map).sort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
connectedCallback() {
|
||||||
|
super.connectedCallback();
|
||||||
|
this._keydown = this.keydown.bind(this);
|
||||||
|
window.addEventListener('keydown', this._keydown);
|
||||||
|
}
|
||||||
|
|
||||||
|
disconnectedCallback() {
|
||||||
|
super.disconnectedCallback();
|
||||||
|
window.removeEventListener('keydown', this._keydown);
|
||||||
|
}
|
||||||
|
|
||||||
|
keydown(event) {
|
||||||
|
if (event.altKey && event.key == 'ArrowUp') {
|
||||||
|
this.next_channel(1);
|
||||||
|
event.preventDefault();
|
||||||
|
} else if (event.altKey && event.key == 'ArrowDown') {
|
||||||
|
this.next_channel(-1);
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
next_channel(delta) {
|
||||||
|
let channel_names = ['', '@'].concat(this.channels);
|
||||||
|
let index = channel_names.indexOf(this.hash.substring(1));
|
||||||
|
if (index != -1) {
|
||||||
|
index += delta;
|
||||||
|
this.set_hash('#' + encodeURIComponent(channel_names[(index + channel_names.length) % channel_names.length]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
set_hash(hash) {
|
set_hash(hash) {
|
||||||
this.hash = decodeURIComponent(hash || '#');
|
this.hash = decodeURIComponent(hash || '#');
|
||||||
if (this.hash.startsWith('#q=')) {
|
if (this.hash.startsWith('#q=')) {
|
||||||
|
Loading…
Reference in New Issue
Block a user