Add autocomplete strategy for foreground colors
This commit is contained in:
parent
45b23f73cf
commit
6d1eef836a
@ -1,5 +1,24 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
const colorCodeMap = [
|
||||||
|
["00", "White"],
|
||||||
|
["01", "Black"],
|
||||||
|
["02", "Blue"],
|
||||||
|
["03", "Green"],
|
||||||
|
["04", "Red"],
|
||||||
|
["05", "Brown"],
|
||||||
|
["06", "Magenta"],
|
||||||
|
["07", "Orange"],
|
||||||
|
["08", "Yellow"],
|
||||||
|
["09", "Light Green"],
|
||||||
|
["10", "Cyan"],
|
||||||
|
["11", "Light Cyan"],
|
||||||
|
["12", "Light Blue"],
|
||||||
|
["13", "Pink"],
|
||||||
|
["14", "Grey"],
|
||||||
|
["15", "Light Grey"],
|
||||||
|
];
|
||||||
|
|
||||||
const commands = [
|
const commands = [
|
||||||
"/away",
|
"/away",
|
||||||
"/back",
|
"/back",
|
||||||
@ -35,5 +54,6 @@ const commands = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
colorCodeMap: colorCodeMap,
|
||||||
commands: commands
|
commands: commands
|
||||||
};
|
};
|
||||||
|
@ -111,6 +111,25 @@ $(function() {
|
|||||||
index: 1
|
index: 1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const foregroundColorStrategy = {
|
||||||
|
id: "foreground-colors",
|
||||||
|
match: /\x03(\d{0,2}|[A-Za-z ]{0,10})$/,
|
||||||
|
search(term, callback) {
|
||||||
|
term = term.toLowerCase();
|
||||||
|
const matchingColorCodes = constants.colorCodeMap
|
||||||
|
.filter(i => i[0].startsWith(term) || i[1].toLowerCase().startsWith(term));
|
||||||
|
|
||||||
|
callback(matchingColorCodes);
|
||||||
|
},
|
||||||
|
template(value) {
|
||||||
|
return `<span class="irc-fg${parseInt(value[0], 10)}">${value[1]}</span>`;
|
||||||
|
},
|
||||||
|
replace(value) {
|
||||||
|
return "\x03" + value[0];
|
||||||
|
},
|
||||||
|
index: 1
|
||||||
|
};
|
||||||
|
|
||||||
socket.on("auth", function(data) {
|
socket.on("auth", function(data) {
|
||||||
var login = $("#sign-in");
|
var login = $("#sign-in");
|
||||||
var token;
|
var token;
|
||||||
@ -724,7 +743,7 @@ $(function() {
|
|||||||
chat.find(".chan.active .chat").trigger("msg.sticky"); // fix growing
|
chat.find(".chan.active .chat").trigger("msg.sticky"); // fix growing
|
||||||
})
|
})
|
||||||
.tab(completeNicks, {hint: false})
|
.tab(completeNicks, {hint: false})
|
||||||
.textcomplete([emojiStrategy, nicksStrategy, chanStrategy, commandStrategy], {
|
.textcomplete([emojiStrategy, nicksStrategy, chanStrategy, commandStrategy, colorStrategy], {
|
||||||
dropdownClassName: "textcomplete-menu",
|
dropdownClassName: "textcomplete-menu",
|
||||||
placement: "top"
|
placement: "top"
|
||||||
}).on({
|
}).on({
|
||||||
|
Loading…
Reference in New Issue
Block a user