1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-09-17 02:16:54 +00:00

3.5.373. Fix global emotes bug. Fix API stupidity with not passing all attributes of emotes/emote sets/badges. Add badge click_action function. Add support for target-msg-id CLEARMESSAGE tag. Add alternate mode tab-completion handling. Also older changes because I'm bad at commiting. Closes #55

This commit is contained in:
SirStendec 2016-11-19 01:59:03 -05:00
parent 791fcab2d2
commit cc5aec5591
12 changed files with 203 additions and 142 deletions

View file

@ -204,6 +204,18 @@ FFZ.settings_info.input_complete_emotes = {
}
FFZ.settings_info.input_complete_keys = {
type: "boolean",
value: false,
category: "Chat Input",
no_bttv: true,
name: "Tab-Complete Alternate Input",
help: "When this is enabled, Tab and Shift-Tab will cycle through possible values and Space will insert the value."
}
FFZ.settings_info.input_complete_commands = {
type: "boolean",
value: true,
@ -619,7 +631,7 @@ FFZ.prototype.modify_chat_input = function(component) {
}.observes('suggestions'),
ffzCompleteSuggestion: function(item) {
ffzCompleteSuggestion: function(item, add_space) {
if ( ! item ) {
var suggestions = this.get('ffz_sorted_suggestions'),
current = this.get('ffz_current_suggestion');
@ -628,8 +640,6 @@ FFZ.prototype.modify_chat_input = function(component) {
}
this.ffzHideSuggestions();
if ( ! item )
return;
var t = this,
ind = this.get('ffz_partial_word_start'),
@ -638,18 +648,30 @@ FFZ.prototype.modify_chat_input = function(component) {
first_char = text.charAt(0),
is_cmd = first_char === '/' || first_char === '.',
content = ((f.settings.input_complete_name_at && ! is_cmd && item.type === 'user' && this.get('ffz_partial_word').charAt(0) === '@') ? '@' : '') +
((item.command_content && is_cmd ?
item.command_content : item.content) || item.label),
trail, prefix;
trail = text.substr(ind + this.get('ffz_partial_word').length),
prefix = text.substr(0, ind) + content + (trail ? '' : ' ');
if ( item ) {
var content = ((f.settings.input_complete_name_at && ! is_cmd && item.type === 'user' && this.get('ffz_partial_word').charAt(0) === '@') ? '@' : '') +
((item.command_content && is_cmd ?
item.command_content : item.content) || item.label);
prefix = text.substr(0, ind) + content;
trail = text.substr(ind + this.get('ffz_partial_word').length);
} else {
var area = this.get('chatTextArea'),
ind = selection_start(area);
prefix = text.substr(0, ind);
trail = text.substr(ind);
}
prefix += !add_space && trail ? '' : ' ';
this.set('textareaValue', prefix + trail);
this.set('ffz_partial_word', '');
this.set('ffz_partial_word_start', -1);
this.trackSuggestionsCompleted();
if ( item )
this.trackSuggestionsCompleted();
Ember.run.next(function() {
var area = t.get('chatTextArea');
move_selection(area, prefix.length);
@ -821,7 +843,7 @@ FFZ.prototype.modify_chat_input = function(component) {
// It's a sub emote, so try splitting off the end of the code.
// It's a bit weird, but people might like it. Also, make sure
// we aren't just grabbing an initial capital.
var unprefixed = code.substr(1).match(/[A-Z](?:.+)?$/);
var unprefixed = code.substr(1).match(/[A-Z0-9](?:.+)?$/);
unprefixed = unprefixed ? unprefixed[0] : null;
if ( unprefixed )
emotes.push({
@ -1283,21 +1305,38 @@ FFZ.prototype.modify_chat_input = function(component) {
if ( text.length === 0 )
break;
if ( text.charAt(0) !== '/' ) {
var parts = text.split(' ');
if ( parts[parts.length - 1].length === 0 )
if ( text.charAt(0) !== '/' || f.settings.input_complete_name_require_at ) {
var ind = selection_start(this.get('chatTextArea')),
part = text.substr(ind > 0 ? ind - 1 : 0),
match = /^[^ ]+/.exec(part);
if ( ! match || match[0].length === 0 )
break;
}
// If suggestions aren't visible... show them. And set that we
// triggered the suggestions with tab.
if ( ! this.get('ffz_suggestions_visible') ) {
f.log("Showing Suggestions from Tab");
this.ffzFetchNameSuggestions();
this.set('ffz_suggestions_visible', true);
this.ffzSetPartialWord();
this.trackSuggestions("Tab");
// If suggestions *are* visible, enter a suggestion.
// If suggestions are visible, tab through the possibilities.
} else if ( f.settings.input_complete_keys ) {
var suggestions = this.get('ffz_sorted_suggestions'),
current = this.get('ffz_current_suggestion') + ((e.shiftKey || e.shiftLeft) ? -1 : 1);
if ( current < 0 )
current = suggestions.length - 1;
else if ( current >= suggestions.length )
current = 0;
this.set('ffz_freeze_suggestions', -1);
this.set('ffz_current_suggestion', current);
// Otherwise, complete the suggestion.
} else
this.ffzCompleteSuggestion();
@ -1381,7 +1420,11 @@ FFZ.prototype.modify_chat_input = function(component) {
case KEYCODES.SPACE:
// First things first, if we're currently showing suggestions, get rid of them.
if ( this.get('ffz_suggestions_visible') )
this.ffzHideSuggestions();
if ( f.settings.input_complete_keys ) {
this.ffzCompleteSuggestion(null, true);
e.preventDefault();
} else
this.ffzHideSuggestions();
// After pressing space, if we're entering a command, do stuff!
// TODO: Better support for commands.

View file

@ -522,7 +522,7 @@ FFZ.settings_info.chat_font_family = {
var span = document.createElement('span');
span.style.fontFamily = val;
css = ".timestamp-line,.conversation-chat-line,.conversation-system-messages,.chat-history,.ember-chat .chat-messages {" + span.style.cssText + "}";
css = ".pinned-cheers .chat-line,.timestamp-line,.conversation-chat-line,.conversation-system-messages,.chat-history,.ember-chat .chat-messages {" + span.style.cssText + "}";
}
utils.update_css(this._chat_style, "chat_font_family", css);
@ -570,9 +570,9 @@ FFZ.settings_info.chat_font_size = {
else {
var lh = Math.max(20, Math.round((20/12)*val)),
pd = Math.floor((lh - 20) / 2);
css = ".timestamp-line,.conversation-chat-line,.conversation-system-messages,.chat-history .chat-line,.ember-chat .chat-messages .chat-line { font-size: " + val + "px !important; line-height: " + lh + "px !important; }";
css = ".pinned-cheers .chat-line,.timestamp-line,.conversation-chat-line,.conversation-system-messages,.chat-history .chat-line,.ember-chat .chat-messages .chat-line { font-size: " + val + "px !important; line-height: " + lh + "px !important; }";
if ( pd )
css += ".ember-chat .chat-messages .chat-line .mod-icons, .ember-chat .chat-messages .chat-line .badges { padding-top: " + pd + "px; }";
css += ".pinned-cheers .chat-line,.ember-chat .chat-messages .chat-line .mod-icons, .ember-chat .chat-messages .chat-line .badges { padding-top: " + pd + "px; }";
}
utils.update_css(this._chat_style, "chat_font_size", css);
@ -1199,7 +1199,12 @@ FFZ.prototype._modify_chat_subline = function(component) {
}
} else if ( cl.contains('badge') ) {
if ( cl.contains('click_url') )
if ( cl.contains('click_action') ) {
var badge = f.badges && f.badges[e.target.getAttribute('data-badge-id')];
if ( badge.click_action )
badge.click_action.call(f, this.get('msgObject'), e);
} else if ( cl.contains('click_url') )
window.open(e.target.getAttribute('data-url'), "_blank");
else if ( cl.contains('turbo') )

View file

@ -1470,7 +1470,7 @@ FFZ.prototype._modify_room = function(room) {
var duration = Infinity,
reason = undefined,
moderator = undefined,
msg_id = undefined,
msg_id = tags && tags['target-msg-id'],
current_user = f.get_user(),
is_me = current_user && current_user.login === user;
@ -1491,7 +1491,7 @@ FFZ.prototype._modify_room = function(room) {
moderator = tags['ban-moderator'];
// Is there a UUID on the end of the ban reason?
if ( reason ) {
if ( ! msg_id && reason ) {
var match = constants.UUID_TEST.exec(reason);
if ( match ) {
msg_id = match[1];