mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-08-07 14:50:56 +00:00
3.5.418. Bunch of changes made while I was away at AGDQ. Add a setting for using the mouse wheel to adjust player volume. Fix colors in vod chat when Twitch adds non-messages as messages. (CLEARCHAT go home you're drunk...)
This commit is contained in:
parent
6b13ac3265
commit
03c825c398
13 changed files with 465 additions and 175 deletions
|
@ -37,7 +37,8 @@ FFZ.settings_info.bits_animated = {
|
|||
help: "Display bits with animation.",
|
||||
|
||||
on_update: function() {
|
||||
var bits = utils.ember_lookup('service:bits-rendering-config');
|
||||
var bits = utils.ember_lookup('service:bits-emotes') ||
|
||||
utils.ember_lookup('service:bits-rendering-config');
|
||||
if ( bits && bits.ffz_has_css )
|
||||
bits.ffz_update_css();
|
||||
}
|
||||
|
@ -118,52 +119,15 @@ FFZ.prototype.setup_bits = function() {
|
|||
utils.toggle_cls('ffz-pinned-cheer-expand')(this.settings.bits_pinned_expand === 2);
|
||||
|
||||
var f = this,
|
||||
Service = utils.ember_lookup('service:bits-rendering-config');
|
||||
if ( ! Service )
|
||||
return this.error("Unable to locate the Ember service:bits-rendering-config");
|
||||
Service = utils.ember_lookup('service:bits-emotes'),
|
||||
|
||||
Service.reopen({
|
||||
ffz_has_css: false,
|
||||
|
||||
ffz_get_tier: function(prefix, amount) {
|
||||
if ( ! this.get('isLoaded') ) {
|
||||
this._actionPromiseCache = false;
|
||||
this.loadRenderConfig();
|
||||
} else if ( ! this.ffz_has_css )
|
||||
this.ffz_update_css();
|
||||
|
||||
var config = this._getConfigPrefix(prefix) || {},
|
||||
tiers = config.tiers || [],
|
||||
tier = null,
|
||||
index = null;
|
||||
|
||||
for(var i=0, l = tiers.length; i < l; i++) {
|
||||
var t = tiers[i];
|
||||
if ( amount < t.min_bits )
|
||||
break;
|
||||
|
||||
tier = t;
|
||||
index = i;
|
||||
}
|
||||
|
||||
return [index, tier];
|
||||
},
|
||||
|
||||
ffz_get_preview: function(tier) {
|
||||
return this._constructImageSrc([4], tier, {
|
||||
background: 'dark',
|
||||
scale: 4,
|
||||
state: f.settings.bits_animated ? 'animated' : 'static'
|
||||
}).src;
|
||||
},
|
||||
|
||||
_ffz_image_css: function(images) {
|
||||
image_css = function(images) {
|
||||
return 'background-image: url("' + images[1] + '");' +
|
||||
'background-image: ' + (constants.IS_WEBKIT ? ' -webkit-' : '') + 'image-set(' +
|
||||
'url("' + images[1] + '") 1x, url("' + images[2] + '") 2x, url("' + images[4] + '") 4x);';
|
||||
},
|
||||
|
||||
_ffz_tier_css: function(ind, prefix, tier) {
|
||||
tier_css = function(ind, prefix, tier) {
|
||||
var selector = '.ffz-bit.bit-prefix-' + prefix + '.bit-tier-' + ind,
|
||||
color = f._handle_color(tier.color),
|
||||
animated = f.settings.bits_animated,
|
||||
|
@ -178,32 +142,135 @@ FFZ.prototype.setup_bits = function() {
|
|||
'color: ' + color[1] + ';' +
|
||||
this._ffz_image_css(tier.images.dark[animated ? 'animated' : 'static']) +
|
||||
'}';
|
||||
},
|
||||
};
|
||||
|
||||
ffz_update_css: function() {
|
||||
var output = [],
|
||||
config = this.get('config') || {prefixes: []};
|
||||
if ( Service ) {
|
||||
Service.reopen({
|
||||
ffz_has_css: false,
|
||||
|
||||
for(var i=0; i < config.prefixes.length; i++) {
|
||||
var prefix = config.prefixes[i],
|
||||
data = this._getConfigPrefix(prefix),
|
||||
tiers = data && data.tiers || [];
|
||||
ffz_get_tier: function(prefix, amount) {
|
||||
if ( ! this.ffz_has_css )
|
||||
this.ffz_update_css();
|
||||
|
||||
for(var x=0; x < tiers.length; x++)
|
||||
output.push(this._ffz_tier_css(x, prefix, tiers[x]));
|
||||
var config = this.getPrefixData(prefix) || {},
|
||||
tiers = config.tiers || [],
|
||||
tier = null,
|
||||
index = null;
|
||||
|
||||
for(var i=0, l = tiers.length; i < l; i++) {
|
||||
var t = tiers[i];
|
||||
if ( amount < t.min_bits )
|
||||
break;
|
||||
|
||||
tier = t;
|
||||
index = i;
|
||||
}
|
||||
|
||||
return [index, tier];
|
||||
},
|
||||
|
||||
ffz_get_preview: function(prefix, amount) {
|
||||
return this.getImageSrc(amount, prefix, true, !f.settings.bits_animated, 4);
|
||||
},
|
||||
|
||||
_ffz_image_css: image_css,
|
||||
_ffz_tier_css: tier_css,
|
||||
|
||||
ffz_update_css: function() {
|
||||
var output = [],
|
||||
prefixes = _.map(this.get('regexes') || [], function(x) {
|
||||
return x && x.prefix || null;
|
||||
});
|
||||
|
||||
for(var i=0; i < prefixes.length; i++) {
|
||||
var prefix = prefixes[i],
|
||||
data = prefix && this.getPrefixData(prefix);
|
||||
|
||||
if ( ! data )
|
||||
continue;
|
||||
|
||||
var tiers = data && data.tiers || [];
|
||||
for(var x=0; x < tiers.length; x++)
|
||||
output.push(this._ffz_tier_css(x, prefix, tiers[x]));
|
||||
}
|
||||
|
||||
utils.update_css(f._chat_style, 'bit-styles', output.join(''));
|
||||
this.ffz_has_css = true;
|
||||
}.observes('emoteConfig', 'regexes')
|
||||
});
|
||||
|
||||
} else {
|
||||
this.log("Unable to find the Ember service:bits-emotes. Falling back...");
|
||||
|
||||
Service = utils.ember_lookup('service:bits-rendering-config');
|
||||
if ( ! Service )
|
||||
return this.error("Unable to locate the Ember service:bits-rendering-config");
|
||||
|
||||
Service.reopen({
|
||||
ffz_has_css: false,
|
||||
|
||||
ffz_get_tier: function(prefix, amount) {
|
||||
if ( ! this.get('isLoaded') ) {
|
||||
this._actionPromiseCache = false;
|
||||
this.loadRenderConfig();
|
||||
} else if ( ! this.ffz_has_css )
|
||||
this.ffz_update_css();
|
||||
|
||||
var config = this._getConfigPrefix(prefix) || {},
|
||||
tiers = config.tiers || [],
|
||||
tier = null,
|
||||
index = null;
|
||||
|
||||
for(var i=0, l = tiers.length; i < l; i++) {
|
||||
var t = tiers[i];
|
||||
if ( amount < t.min_bits )
|
||||
break;
|
||||
|
||||
tier = t;
|
||||
index = i;
|
||||
}
|
||||
|
||||
return [index, tier];
|
||||
},
|
||||
|
||||
ffz_get_preview: function(prefix, amount) {
|
||||
var data = this.ffz_get_tier(prefix, amount),
|
||||
tier = data && data[1];
|
||||
return tier ? this._constructImageSrc([4], tier, {
|
||||
background: 'dark',
|
||||
scale: 4,
|
||||
state: f.settings.bits_animated ? 'animated' : 'static'
|
||||
}).src : '';
|
||||
},
|
||||
|
||||
_ffz_image_css: image_css,
|
||||
_ffz_tier_css: tier_css,
|
||||
|
||||
ffz_update_css: function() {
|
||||
var output = [],
|
||||
config = this.get('config') || {prefixes: []};
|
||||
|
||||
for(var i=0; i < config.prefixes.length; i++) {
|
||||
var prefix = config.prefixes[i],
|
||||
data = this._getConfigPrefix(prefix),
|
||||
tiers = data && data.tiers || [];
|
||||
|
||||
for(var x=0; x < tiers.length; x++)
|
||||
output.push(this._ffz_tier_css(x, prefix, tiers[x]));
|
||||
}
|
||||
|
||||
utils.update_css(f._chat_style, 'bit-styles', output.join(''));
|
||||
this.ffz_has_css = true;
|
||||
}.observes('config'),
|
||||
|
||||
loadRenderConfig: function() {
|
||||
var out = this._super();
|
||||
if ( ! this.get('config') )
|
||||
this._actionPromiseCache = false;
|
||||
return out;
|
||||
}
|
||||
|
||||
utils.update_css(f._chat_style, 'bit-styles', output.join(''));
|
||||
this.ffz_has_css = true;
|
||||
}.observes('config'),
|
||||
|
||||
loadRenderConfig: function() {
|
||||
var out = this._super();
|
||||
if ( ! this.get('config') )
|
||||
this._actionPromiseCache = false;
|
||||
return out;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if ( Service.get('isLoaded') )
|
||||
Service.loadRenderConfig();
|
||||
|
|
|
@ -59,6 +59,18 @@ FFZ.settings_info.player_volume_bar = {
|
|||
};
|
||||
|
||||
|
||||
FFZ.settings_info.player_volume_scroll = {
|
||||
type: "boolean",
|
||||
value: false,
|
||||
no_mobile: true,
|
||||
|
||||
category: "Player",
|
||||
|
||||
name: "Adjust Volume by Scrolling",
|
||||
help: "Adjust the player's volume by scrolling up and down with your mouse wheel."
|
||||
};
|
||||
|
||||
|
||||
/*FFZ.settings_info.player_pause_hosts = {
|
||||
type: "select",
|
||||
options: {
|
||||
|
@ -89,6 +101,7 @@ FFZ.prototype.setup_player = function() {
|
|||
Layout.set('PLAYER_CONTROLS_HEIGHT', this.settings.classic_player ? 32 : 0);
|
||||
|
||||
this.update_views('component:twitch-player2', this.modify_twitch_player);
|
||||
this.update_views('component:persistent-player', this.modify_persistent_player);
|
||||
}
|
||||
|
||||
|
||||
|
@ -96,6 +109,32 @@ FFZ.prototype.setup_player = function() {
|
|||
// Component
|
||||
// ---------------
|
||||
|
||||
FFZ.prototype.modify_persistent_player = function(player) {
|
||||
var f = this;
|
||||
utils.ember_reopen_view(player, {
|
||||
ffz_init: function() {
|
||||
var t = this;
|
||||
this.$().off('mousewheel').on('mousewheel', function(event) {
|
||||
f.log("Player-Scroll", event);
|
||||
if ( ! f.settings.player_volume_scroll )
|
||||
return;
|
||||
|
||||
// I ain't about that life, jQuery.
|
||||
event = event.originalEvent || event;
|
||||
var delta = event.wheelDelta || -event.detail,
|
||||
player = t.childViews && t.childViews[0] && t.childViews[0].get('player');
|
||||
|
||||
if ( player )
|
||||
player.volume += delta > 0 ? .1 : -.1;
|
||||
|
||||
event.preventDefault();
|
||||
return false;
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
FFZ.prototype.modify_twitch_player = function(player) {
|
||||
var f = this;
|
||||
utils.ember_reopen_view(player, {
|
||||
|
@ -196,7 +235,7 @@ FFZ.prototype.modify_twitch_player = function(player) {
|
|||
}.observes('channel'),*/
|
||||
|
||||
ffzPostPlayer: function() {
|
||||
var f = this,
|
||||
var t = this,
|
||||
/*channel_id = this.get('hostChannel.name'),
|
||||
hosted_id = this.get('channel.name'),
|
||||
is_hosting = channel_id !== hosted_id,*/
|
||||
|
|
|
@ -1894,7 +1894,7 @@ FFZ.prototype._modify_room = function(room) {
|
|||
return f.settings.timeout_notices === 2 || (f.settings.timeout_notices === 1 && this.get('isModeratorOrHigher'));
|
||||
},
|
||||
|
||||
ffzRetokenizeUser: function(user, max_age) {
|
||||
ffzRetokenizeUser: function(user, max_age, update_badges) {
|
||||
// Retokenize all messages by a user, or just all messages.
|
||||
var messages = this.get('messages'),
|
||||
i = messages.length,
|
||||
|
@ -1909,8 +1909,11 @@ FFZ.prototype._modify_room = function(room) {
|
|||
|
||||
if ( ! user || msg.from === user ) {
|
||||
msg.cachedTokens = null;
|
||||
if ( msg._line )
|
||||
if ( msg._line ) {
|
||||
Ember.propertyDidChange(msg._line, 'ffzTokenizedMessage');
|
||||
if ( update_badges )
|
||||
msg._line.ffzUpdateBadges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,10 +25,16 @@ FFZ.prototype.setup_vod_chat = function() {
|
|||
var colors = this.get("colorSettings"),
|
||||
from = msg.get("from");
|
||||
|
||||
if ( ! colors.get(from) )
|
||||
colors.set(from, constants.CHAT_COLORS[Math.floor(Math.random() * constants.CHAT_COLORS.length)]);
|
||||
if ( from ) {
|
||||
var clr = colors.get(from);
|
||||
if ( ! clr ) {
|
||||
clr = constants.CHAT_COLORS[Math.floor(Math.random() * constants.CHAT_COLORS.length)];
|
||||
colors.set(from, clr);
|
||||
}
|
||||
|
||||
msg.set("color", colors.get(from));
|
||||
if ( typeof clr === 'string' )
|
||||
msg.set('color', clr);
|
||||
}
|
||||
}
|
||||
|
||||
this.get("messages").pushObject(msg);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue