Add autocomplete strategy for background colors
This commit is contained in:
parent
6d1eef836a
commit
0981605fae
@ -1533,6 +1533,10 @@ kbd {
|
|||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.textcomplete-item .irc-bg {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tooltips v0.5.3
|
* Tooltips v0.5.3
|
||||||
* See http://primercss.io/tooltips/
|
* See http://primercss.io/tooltips/
|
||||||
|
@ -130,6 +130,26 @@ $(function() {
|
|||||||
index: 1
|
index: 1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const backgroundColorStrategy = {
|
||||||
|
id: "background-colors",
|
||||||
|
match: /\x03(\d{2}),(\d{0,2}|[A-Za-z ]{0,10})$/,
|
||||||
|
search(term, callback, match) {
|
||||||
|
term = term.toLowerCase();
|
||||||
|
const matchingColorCodes = constants.colorCodeMap
|
||||||
|
.filter(i => i[0].startsWith(term) || i[1].toLowerCase().startsWith(term))
|
||||||
|
.map(pair => pair.concat(match[1])); // Needed to pass fg color to `template`...
|
||||||
|
|
||||||
|
callback(matchingColorCodes);
|
||||||
|
},
|
||||||
|
template(value) {
|
||||||
|
return `<span class="irc-fg${parseInt(value[2], 10)} irc-bg irc-bg${parseInt(value[0], 10)}">${value[1]}</span>`;
|
||||||
|
},
|
||||||
|
replace(value) {
|
||||||
|
return "\x03$1," + value[0];
|
||||||
|
},
|
||||||
|
index: 2
|
||||||
|
};
|
||||||
|
|
||||||
socket.on("auth", function(data) {
|
socket.on("auth", function(data) {
|
||||||
var login = $("#sign-in");
|
var login = $("#sign-in");
|
||||||
var token;
|
var token;
|
||||||
@ -743,7 +763,10 @@ $(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, colorStrategy], {
|
.textcomplete([
|
||||||
|
emojiStrategy, nicksStrategy, chanStrategy, commandStrategy,
|
||||||
|
foregroundColorStrategy, backgroundColorStrategy
|
||||||
|
], {
|
||||||
dropdownClassName: "textcomplete-menu",
|
dropdownClassName: "textcomplete-menu",
|
||||||
placement: "top"
|
placement: "top"
|
||||||
}).on({
|
}).on({
|
||||||
|
Loading…
Reference in New Issue
Block a user