1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-07-05 02:28:31 +00:00

3.5.343. More emote alignment options. API fix to prevent adding an emote set to a room multiple times. Minor badge change. Fix positioning of in-line mod icons.

This commit is contained in:
SirStendec 2016-10-20 16:41:04 -04:00
parent 76ff6e8c1a
commit b9fefe29d9
8 changed files with 108 additions and 121 deletions

View file

@ -1,3 +1,11 @@
<div class="list-header">3.5.343 <time datetime="2016-10-20">(2016-10-20)</time></div>
<ul class="chat-menu-content menu-side-padding">
<li>Added: More emoticon alignment options.</li>
<li>API Fixed: Only allow an emote set to be added to a room once.</li>
<li>Fixed: Some badges weren't properly clickable.</li>
<li>Fixed: In-line mod icons sometimes weren't positioned correctly.</li>
</ul>
<div class="list-header">3.5.342 <time datetime="2016-10-20">(2016-10-20)</time></div>
<ul class="chat-menu-content menu-side-padding">
<li>API Added: A flexible event system with <code>api.on(event, callback)</code>, <code>api.off(event, <em>callback</em>)</code>, and <code>api.trigger(event, <em>args...</em>)</code></li>

View file

@ -395,6 +395,7 @@ FFZ.prototype._get_badge_object = function(badge, full_badge) {
image: badge.image,
full_image: full_badge.image,
color: badge.color,
click_url: badge.click_url || full_badge.click_url,
no_invert: badge.no_invert || full_badge.no_invert,
no_color: badge.no_color || full_badge.no_color,
invert_invert: badge.invert_invert || full_badge.invert_invert,
@ -747,5 +748,8 @@ FFZ.prototype._load_badge_json = function(badge_id, data) {
if ( data.name === 'bot' )
data.visible = function(r,user) { return !(this.has_bttv && FFZ.bttv_known_bots.indexOf(user)!==-1); };
if ( data.name === 'developer' || data.name === 'supporter' )
data.click_url = 'https://www.frankerfacez.com/donate';
utils.update_css(this._badge_style, badge_id, utils.badge_css(data));
}

View file

@ -355,7 +355,7 @@ FFZ.settings_info.chat_rows = {
on_update: function(val) {
this.toggle_style('chat-background', !this.has_bttv && val);
this.toggle_style('chat-setup', !this.has_bttv && (val || this.settings.chat_separators || this.settings.highlight_messages_with_mod_card));
this._toggle_chat_setup_style();
}
};
@ -380,7 +380,7 @@ FFZ.settings_info.chat_separators = {
help: "Display thin lines between chat messages for further visual separation.",
on_update: function(val) {
this.toggle_style('chat-setup', !this.has_bttv && (val || this.settings.chat_rows || this.settings.highlight_messages_with_mod_card));
this._toggle_chat_setup_style();
this.toggle_style('chat-separator', !this.has_bttv && val);
this.toggle_style('chat-separator-3d', !this.has_bttv && val === 2);
@ -403,16 +403,28 @@ FFZ.settings_info.old_sub_notices = {
FFZ.settings_info.emote_alignment = {
type: "boolean",
value: false,
type: "select",
options: {
0: "Standard",
1: "Padded",
2: "Baseline (BTTV-Like)",
},
value: 0,
process_value: utils.process_int(0, 0, 2),
category: "Chat Appearance",
no_bttv: true,
name: "Baseline Emoticon Alignment",
help: "Align emotes on the text baseline, making messages taller but ensuring emotes don't overlap.",
name: "Emoticon Alignment",
help: "Change how emotes are aligned and padded in chat, making messages taller but preventing emotes from overlapping.",
on_update: function(val) { document.body.classList.toggle('ffz-baseline-emoticons', !this.has_bttv && val) }
on_update: function(val) {
if ( this.has_bttv )
return;
utils.toggle_cls('ffz-padded-emoticons')(val === 1);
utils.toggle_cls('ffz-baseline-emoticons')(val === 2);
}
};
FFZ.settings_info.chat_padding = {
@ -648,12 +660,12 @@ FFZ.prototype.setup_line = function() {
// Chat Enhancements
document.body.classList.toggle('ffz-alias-italics', this.settings.alias_italics);
document.body.classList.toggle('ffz-baseline-emoticons', !this.has_bttv && this.settings.emote_alignment);
utils.toggle_cls('ffz-alias-italics')(this.settings.alias_italics);
utils.toggle_cls('ffz-padded-emoticons')(!this.has_bttv && this.settings.emote_alignment === 1);
utils.toggle_cls('ffz-baseline-emoticons')(!this.has_bttv && this.settings.emote_alignment === 2);
this.toggle_style('chat-setup', !this.has_bttv && (this.settings.chat_rows || this.settings.chat_separators || this.settings.highlight_messages_with_mod_card));
this._toggle_chat_setup_style();
this.toggle_style('chat-padding', !this.has_bttv && this.settings.chat_padding);
this.toggle_style('chat-background', !this.has_bttv && this.settings.chat_rows);
this.toggle_style('chat-separator', !this.has_bttv && this.settings.chat_separators);
@ -665,41 +677,11 @@ FFZ.prototype.setup_line = function() {
this.toggle_style('chat-hc-bold', this.settings.high_contrast_chat[1] === '1');
this.toggle_style('chat-hc-background', this.settings.high_contrast_chat[0] === '1');
this._last_row = {};
/*this.log("Hooking the Ember Chat Line component.");
var Line = utils.ember_resolve('component:chat-line');
if ( Line )
this._modify_chat_line(Line);*/
this.update_views('component:vod-chat-line', this._modify_vod_line);
this.update_views('component:chat/message-line', this._modify_chat_subline);
this.update_views('component:chat/whisper-line', this._modify_chat_subline);
/*this.log("Hooking the Ember VOD Chat Line component.");
var VOD = utils.ember_resolve('component:vod-chat-line');
if ( VOD )
this._modify_vod_line(VOD);
else
this.log("Couldn't find VOD Chat Line component.");
this.log("Hooking the Ember Message Line component.");
var MLine = utils.ember_resolve('component:chat/message-line');
if ( MLine )
this._modify_chat_subline(MLine);
else
this.error("Couldn't find the Message Line component.");
this.log("Hooking the Ember Whisper Line component.");
var WLine = utils.ember_resolve('component:chat/whisper-line');
if ( WLine )
this._modify_chat_subline(WLine);
else
this.error("Couldn't find the Whisper Line component.");*/
// Store the capitalization of our own name.
var user = this.get_user();
@ -708,6 +690,15 @@ FFZ.prototype.setup_line = function() {
}
FFZ.prototype._toggle_chat_setup_style = function() {
this.toggle_style('chat-setup', !this.has_bttv && (
this.settings.chat_mod_icon_visibility > 1 ||
this.settings.chat_separators ||
this.settings.chat_rows ||
this.settings.highlight_messages_with_mod_card));
}
FFZ.prototype.save_aliases = function() {
this.log("Saving " + Object.keys(this.aliases).length + " aliases to local storage.");
localStorage.ffz_aliases = JSON.stringify(this.aliases);
@ -774,12 +765,19 @@ FFZ.prototype._modify_chat_line = function(component, is_vod) {
this_ul = this.get('ffzUserLevel'),
other_ul = room && room.room && room.room.get('ffzUserLevel') || 0,
is_tb = this.get('msgObject.twitchBotRejected'),
output;
if ( is_whisper || this_ul >= other_ul || f.settings.mod_buttons.length === 0 )
if ( is_whisper || this_ul >= other_ul || (f.settings.mod_buttons.length === 0 && ! is_tb) )
return '';
output = '<span class="mod-icons">';
output = ['<span class="mod-icons">'];
if ( is_tb ) {
output.push('<a class="mod-icon html-tooltip tb-reject" title="Not Allowed">Not Allowed</a>');
output.push('<a class="mod-icon html-tooltip tb-allow" title="Allowed">Allowed</a>');
}
for(var i=0, l = f.settings.mod_buttons.length; i < l; i++) {
var pair = f.settings.mod_buttons[i],
@ -806,12 +804,12 @@ FFZ.prototype._modify_chat_line = function(component, is_vod) {
if ( btn === false ) {
if ( deleted )
output += '<a class="mod-icon html-tooltip unban" title="Unban User" href="#">Unban</a>';
output.push('<a class="mod-icon html-tooltip unban" title="Unban User" href="#">Unban</a>');
else
output += '<a class="mod-icon html-tooltip ban' + (had_label ? ' custom' : '') + '" title="Ban User" href="#">' + (had_label ? prefix : 'Ban') + '</a>';
output.push('<a class="mod-icon html-tooltip ban' + (had_label ? ' custom' : '') + '" title="Ban User" href="#">' + (had_label ? prefix : 'Ban') + '</a>');
} else if ( btn === 600 )
output += '<a class="mod-icon html-tooltip timeout' + (had_label ? ' custom' : '') + '" title="Timeout User (10m)" href="#">' + ( had_label ? prefix : 'Timeout') + '</a>';
output.push('<a class="mod-icon html-tooltip timeout' + (had_label ? ' custom' : '') + '" title="Timeout User (10m)" href="#">' + ( had_label ? prefix : 'Timeout') + '</a>');
else {
if ( typeof btn === "string" ) {
@ -821,11 +819,11 @@ FFZ.prototype._modify_chat_line = function(component, is_vod) {
cmd = "/timeout " + user + " " + btn;
tip = "Timeout User (" + utils.duration_string(btn) + ")";
}
output += '<a class="mod-icon html-tooltip' + (cmd.substr(0,9) === '/timeout' ? ' is-timeout' : '') + ' custom" data-cmd="' + utils.quote_attr(cmd) + '" title="' + tip + '" href="#">' + prefix + '</a>';
output.push('<a class="mod-icon html-tooltip' + (cmd.substr(0,9) === '/timeout' ? ' is-timeout' : '') + ' custom" data-cmd="' + utils.quote_attr(cmd) + '" title="' + tip + '" href="#">' + prefix + '</a>');
}
}
return output + '</span>';
return output.join('') + '</span>';
},
buildFromHTML: function(is_recipient) {
@ -1136,7 +1134,13 @@ FFZ.prototype._modify_chat_subline = function(component) {
jQuery(e.target).trigger('mouseout');
e.preventDefault();
if ( cl.contains('ban') )
if ( cl.contains('tb-reject') )
this.sendAction("clickedTwitchBotNo", this.get('msgObject.tags.id'));
else if ( cl.contains('tb-allow') )
this.sendAction("clickedTwitchBotYes", this.get('msgObject.tags.id'));
else if ( cl.contains('ban') )
this.sendAction("banUser", {user:from});
else if ( cl.contains('unban') )

View file

@ -80,8 +80,7 @@ FFZ.settings_info.highlight_messages_with_mod_card = {
help: "Highlight a user's messages in chat when their moderation card is open.",
on_update: function(val) {
this.toggle_style('chat-setup', !this.has_bttv && (this.settings.chat_rows || this.settings.chat_separators || val));
this._toggle_chat_setup_style();
if ( ! this._mod_card )
return;
@ -129,6 +128,7 @@ FFZ.settings_info.chat_mod_icon_visibility = {
help: "Choose when you should see in-line moderation icons in chat.",
on_update: function(val) {
this._toggle_chat_setup_style();
var settings = utils.ember_settings();
if ( settings )
settings.set('showModIcons', val === 1);
@ -1510,7 +1510,7 @@ FFZ.prototype._build_mod_card_history = function(msg, modcard, show_from, ts_cli
// Line attributes and classes.
if ( msg.style )
l_el.classList.add(msg.style);
l_el.className += ' ' + msg.style;
if ( msg.original_sender )
l_el.classList.add('original-sender');
@ -1539,8 +1539,6 @@ FFZ.prototype._build_mod_card_history = function(msg, modcard, show_from, ts_cli
jQuery('.deleted-word', l_el).click(function(e) { jQuery(this).trigger('mouseout'); this.outerHTML = this.getAttribute('data-text'); });
jQuery('a.deleted-link', l_el).click(f._deleted_link_click);
jQuery('img.emoticon', l_el).click(function(e) { f._click_emote(this, e) });
//jQuery('.html-tooltip', l_el).tipsy({html:true, gravity: utils.tooltip_placement(2*constants.TOOLTIP_DISTANCE, 's')});
//jQuery('.ffz-tooltip', l_el).tipsy({live: true, html: true, title: f.render_tooltip(), gravity: utils.tooltip_placement(2*constants.TOOLTIP_DISTANCE, 's')});
if ( modcard ) {
modcard.get('cardInfo.user.id') !== msg.from && jQuery('span.from', l_el).click(function(e) {

View file

@ -875,46 +875,46 @@ FFZ.prototype._update_room_badge_css = function(room_id) {
}
FFZ.prototype.add_room = function(id, room) {
if ( this.rooms[id] )
return this.log("Tried to add existing room: " + id);
FFZ.prototype.add_room = function(room_id, room) {
if ( this.rooms[room_id] )
return this.log("Tried to add existing room: " + room_id);
this.log("Adding Room: " + id);
this.log("Adding Room: " + room_id);
// Create a basic data table for this room.
var data = this.rooms[id] = {id: id, room: room, sets: [], ext_sets: [], css: null, needs_history: false};
var data = this.rooms[room_id] = {id: room_id, room: room, sets: [], ext_sets: [], css: null, needs_history: false};
if ( this.follow_sets && this.follow_sets[id] ) {
data.extra_sets = this.follow_sets[id];
delete this.follow_sets[id];
if ( this.follow_sets && this.follow_sets[room_id] ) {
data.extra_sets = this.follow_sets[room_id];
delete this.follow_sets[room_id];
for(var i=0; i < data.extra_sets.length; i++) {
var sid = data.extra_sets[i],
set = this.emote_sets && this.emote_sets[sid];
if ( set ) {
if ( set.users.indexOf(id) === -1 )
set.users.push(id);
if ( set.users.indexOf(room_id) === -1 )
set.users.push(room_id);
continue;
}
this.load_set(sid, function(success, data) {
if ( success )
data.users.push(id);
data.users.push(room_id);
});
}
}
// Store the badges for this room now if we have them.
var bs = utils.ember_lookup('service:badges');
if ( bs && bs.badgeCollection && bs.badgeCollection.channel && bs.badgeCollection.channel.broadcasterName === id ) {
if ( bs && bs.badgeCollection && bs.badgeCollection.channel && bs.badgeCollection.channel.broadcasterName === room_id ) {
data.badges = bs.badgeCollection.channel;
this._update_room_badge_css(id);
this._update_room_badge_css(room_id);
}
// Look up if the room has moderation logs.
var f = this;
this.ws_send("has_logs", id, function(success, response) {
this.ws_send("has_logs", room_id, function(success, response) {
if ( ! success )
return;
@ -923,64 +923,54 @@ FFZ.prototype.add_room = function(id, room) {
}, true);
// Is the room important?
this.update_room_important(id);
this.update_room_important(room_id);
if ( data.important ) {
if ( data.important )
// Let the server know where we are.
this.ws_sub("room." + id);
this.ws_sub("room." + room_id);
// Do we want history?
/*if ( ! this.has_bttv && this.settings.chat_history && room && (room.get('messages.length') || 0) < 10 ) {
if ( ! this.ws_send("chat_history", [id,25], this._load_history.bind(this, id)) )
data.needs_history = true;
}*/
}
// Why don't we set the scrollback length, too?
room.set('messageBufferSize', this.settings.scrollback_length + ((this._roomv && !this._roomv.get('stuckToBottom') && this._roomv.get('controller.model.id') === id) ? 150 : 0));
room.set('messageBufferSize', this.settings.scrollback_length + ((this._roomv && !this._roomv.get('stuckToBottom') && this._roomv.get('controller.model.id') === room_id) ? 150 : 0));
// Load the room's data from the API.
this.load_room(id);
this.load_room(room_id);
// Announce this room to any extension callback functions.
this.api_trigger('room-add', id);
// Legacy announcement.
for(var api_id in this._apis) {
var api = this._apis[api_id];
api._room_callbacks(id, data);
}
this.api_trigger('room-add', room_id);
}
FFZ.prototype.remove_room = function(id) {
var room = this.rooms[id];
FFZ.prototype.remove_room = function(room_id) {
var room = this.rooms[room_id];
if ( ! room )
return;
this.log("Removing Room: " + id);
this.log("Removing Room: " + room_id);
// Remove the CSS
if ( room.css || room.moderator_badge )
utils.update_css(this._room_style, id, null);
utils.update_css(this._room_style, room_id, null);
// Let the server know we're gone and delete our data for this room.
this.ws_unsub("room." + id);
delete this.rooms[id];
this.ws_unsub("room." + room_id);
delete this.rooms[room_id];
// Clean up sets we aren't using any longer.
if ( id.charAt(0) === "_" )
return;
var set = this.emote_sets[room.set];
if ( set ) {
set.users.removeObject(id);
set.users.removeObject(room_id);
if ( ! this.global_sets.contains(room.set) && ! set.users.length )
this.unload_set(room.set);
}
this.api_trigger('room-remove', id);
this.api_trigger('room-remove', room_id);
}

View file

@ -72,7 +72,6 @@ var API = FFZ.API = function(instance, name, icon, version, name_key) {
this.badges = {};
this.users = {};
this.on_room_callbacks = [];
this.name = name || ("Extension#" + this.id);
this.name_key = name_key || this.name.replace(/[^A-Z0-9_\-]/g, '').toLowerCase();
@ -427,8 +426,10 @@ API.prototype.register_room_set = function(room_id, set_id, emote_set) {
this.ffz.emote_sets[exact_id] = emote_set;
// Register it on the room.
room.ext_sets && room.ext_sets.push(exact_id);
emote_set.users.push(room_id);
if ( room.ext_sets && room.ext_sets.indexOf(exact_id) === -1 )
room.ext_sets.push(exact_id);
if ( emote_set.users.indexOf(room_id) === -1 )
emote_set.users.push(room_id);
// Update tab completion.
if ( this.ffz._inputv )
@ -604,33 +605,10 @@ API.prototype.iterate_rooms = function(func) {
func(room_id);
}
API.prototype._room_callbacks = function(room_id, room, specific_func) {
var callback = this.register_room_set.bind(this, room_id);
if ( specific_func ) {
try {
specific_func(room_id, callback);
} catch(err) {
this.error("Error in On-Room Callback", err);
}
} else {
for(var i=0; i < this.on_room_callbacks.length; i++) {
var cb = this.on_room_callbacks[i];
try {
cb(room_id, callback);
} catch(err) {
this.error("Error in On-Room Callback", err);
}
}
}
}
API.prototype.register_on_room_callback = function(callback, dont_iterate) {
var a = this,
var cb = this.register_room_set.bind(this, room_id),
thing = function(room_id) {
callback(room_id, a.register_room_set.bind(a, room_id));
return callback(room_id, cb);
};
thing.original_func = callback;

View file

@ -61,7 +61,7 @@ FFZ.channel_metadata = {};
// Version
var VER = FFZ.version_info = {
major: 3, minor: 5, revision: 342,
major: 3, minor: 5, revision: 343,
toString: function() {
return [VER.major, VER.minor, VER.revision].join(".") + (VER.extra || "");
}

View file

@ -3492,6 +3492,11 @@ body.ffz-bttv #ffz-feed-tabs .tabs { margin-bottom: 0 }
margin: -1px 3px 0 0;
}
.ffz-padded-emoticons .activity-body .emoticon,
.ffz-padded-emoticons .chat-line .emoticon {
margin: -1px 0 0;
}
.ffz-baseline-emoticons .activity-body .emoticon,
.ffz-baseline-emoticons .chat-line .emoticon {
vertical-align: baseline;