input history
This commit is contained in:
parent
f05fcef7db
commit
4adfb7e79c
@ -654,6 +654,18 @@ body {
|
|||||||
.topicbar .irc-fg15 {
|
.topicbar .irc-fg15 {
|
||||||
color: #d3d3d3;
|
color: #d3d3d3;
|
||||||
}
|
}
|
||||||
|
.message .irc-bold,
|
||||||
|
.topicbar .irc-bold {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
.message .irc-italic,
|
||||||
|
.topicbar .irc-italic {
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
.message .irc-underline,
|
||||||
|
.topicbar .irc-underline {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
@media all and (max-width: 600px) {
|
@media all and (max-width: 600px) {
|
||||||
.vnicks .nicklist {
|
.vnicks .nicklist {
|
||||||
display: none !important;
|
display: none !important;
|
||||||
|
@ -957,6 +957,7 @@ class IRCConnector {
|
|||||||
class InputHandler {
|
class InputHandler {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.history = [];
|
this.history = [];
|
||||||
|
this.historyCaret = 0;
|
||||||
|
|
||||||
clientdom.input.onkeyup = (evt) => {
|
clientdom.input.onkeyup = (evt) => {
|
||||||
let key = evt.keyCode || evt.which || evt.charCode || 0;
|
let key = evt.keyCode || evt.which || evt.charCode || 0;
|
||||||
@ -965,6 +966,44 @@ class InputHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clientdom.input.onkeydown = (evt) => {
|
||||||
|
let key = evt.keyCode || evt.which || evt.charCode || 0;
|
||||||
|
if(key == 38) {
|
||||||
|
if(this.historyCaret <= 0) {
|
||||||
|
this.historyCaret = 0;
|
||||||
|
} else {
|
||||||
|
this.historyCaret -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
let selection = this.history[this.historyCaret];
|
||||||
|
|
||||||
|
if(selection) {
|
||||||
|
clientdom.input.value = selection;
|
||||||
|
clientdom.input.selectionStart = selection.length;
|
||||||
|
clientdom.input.selectionEnd = selection.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
} else if(key == 40) {
|
||||||
|
if(this.historyCaret >= this.history.length) {
|
||||||
|
this.historyCaret = this.history.length;
|
||||||
|
} else {
|
||||||
|
this.historyCaret += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
let selection = this.history[this.historyCaret]
|
||||||
|
|
||||||
|
if(!this.history[this.historyCaret])
|
||||||
|
selection = '';
|
||||||
|
|
||||||
|
clientdom.input.selectionStart = selection.length;
|
||||||
|
clientdom.input.selectionEnd = selection.length;
|
||||||
|
clientdom.input.value = selection;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
clientdom.send.onclick = (e) => {
|
clientdom.send.onclick = (e) => {
|
||||||
this.handleInput();
|
this.handleInput();
|
||||||
}
|
}
|
||||||
@ -1063,6 +1102,7 @@ class InputHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.history.push(inp);
|
this.history.push(inp);
|
||||||
|
this.historyCaret = this.history.length;
|
||||||
clientdom.input.value = "";
|
clientdom.input.value = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -472,6 +472,12 @@ body
|
|||||||
color: grey
|
color: grey
|
||||||
.irc-fg15
|
.irc-fg15
|
||||||
color: lightgrey
|
color: lightgrey
|
||||||
|
.irc-bold
|
||||||
|
font-weight: bold
|
||||||
|
.irc-italic
|
||||||
|
font-style: italic
|
||||||
|
.irc-underline
|
||||||
|
text-decoration: underline
|
||||||
|
|
||||||
@media all and (max-width: 600px)
|
@media all and (max-width: 600px)
|
||||||
.vnicks
|
.vnicks
|
||||||
|
Reference in New Issue
Block a user