1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-09-16 18:06:55 +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:
SirStendec 2017-01-18 18:33:56 -05:00
parent 6b13ac3265
commit 03c825c398
13 changed files with 465 additions and 175 deletions

View file

@ -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();

View file

@ -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,*/

View file

@ -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();
}
}
}

View file

@ -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);

View file

@ -599,10 +599,14 @@ API.prototype.user_remove_set = function(username, set_id) {
}
API.prototype.retokenize_messages = function(room, user, max_age) {
var rooms = room ? [room] : Object.keys(this.ffz.rooms);
for(var i=0; i < rooms.length; i++)
rooms[i] && rooms[i].room && rooms[i].room.ffzRetokenizeUser(user, max_age);
API.prototype.retokenize_messages = function(room, user, max_age, update_badges) {
var rooms = room ? [room] : Object.keys(this.ffz.rooms),
ffz_rooms = this.ffz && this.ffz.rooms || {};
for(var i=0; i < rooms.length; i++) {
var room_id = rooms[i],
room = ffz_rooms[room_id];
room && room.room && room.room.ffzRetokenizeUser(user, max_age, update_badges);
}
}

View file

@ -61,7 +61,7 @@ FFZ.channel_metadata = {};
// Version
var VER = FFZ.version_info = {
major: 3, minor: 5, revision: 409,
major: 3, minor: 5, revision: 418,
toString: function() {
return [VER.major, VER.minor, VER.revision].join(".") + (VER.extra || "");
}
@ -145,7 +145,7 @@ FFZ.prototype._pastebin = function(data) {
// -------------------
FFZ.prototype.get_user = function(force_reload) {
if ( ! force_reload && this.__user )
if ( ! force_reload && this.__user && this.__user.chat_oauth_token )
return this.__user;
var LC = FFZ.utils.ember_lookup('service:login'),
@ -257,6 +257,7 @@ require('./ui/following-count');
require('./ui/races');
require('./ui/my_emotes');
require('./ui/about_page');
require('./ui/schedule');
require('./commands');
require('./ext/api');

View file

@ -213,7 +213,10 @@ FFZ.prototype.setup_tokenization = function() {
this.error("Unable to get bits tokenizer.", err);
}
bits_service = utils.ember_lookup('service:bits-rendering-config');
bits_service = utils.ember_lookup('service:bits-emotes');
if ( ! bits_service )
bits_service = utils.ember_lookup('service:bits-rendering-config');
bits_tags = utils.ember_lookup('service:bits-tags');
try {
@ -388,7 +391,7 @@ FFZ.prototype.render_tooltip = function(el) {
out = utils.number_commas(amount) + ' Bit' + utils.pluralize(amount);
if ( f.settings.emote_image_hover )
preview_url = bits_service.ffz_get_preview(tier[1]);
preview_url = bits_service.ffz_get_preview(prefix, amount); //tier[1]);
if ( individuals && individuals.length > 1 ) {
out += '<br>';

View file

@ -204,7 +204,7 @@ FFZ.channel_metadata.following = {
button: true,
static_label: constants.HEART,
label: function(data) {
if ( ! data || ! data.length )
if ( ! this.settings.follow_buttons || ! data || ! data.length )
return null;
return 'Featured';
@ -294,7 +294,7 @@ FFZ.channel_metadata.following = {
is_notified = notice;
update();
return utils.api.put("users/:login/follows/channels/" + user_id, {notifications: notice})
return utils.api.put("users/:login/follows/channels/" + user_id, {notifications: notice}, undefined, user.chat_oauth_token)
.fail(check_following);
};
@ -307,7 +307,7 @@ FFZ.channel_metadata.following = {
if ( is_following )
do_follow();
else
utils.api.del("users/:login/follows/channels/" + user_id)
utils.api.del("users/:login/follows/channels/" + user_id, undefined, undefined, user.chat_oauth_token)
.fail(check_following);
});
@ -322,8 +322,11 @@ FFZ.channel_metadata.following = {
el.appendChild(avatar);
el.appendChild(name_el);
el.appendChild(btn_follow);
el.appendChild(sw_notif);
if ( user ) {
el.appendChild(btn_follow);
el.appendChild(sw_notif);
} else
this.log("No User", user);
container.appendChild(el);
check_following();

View file

@ -57,6 +57,33 @@ var createElement = function(tag, className, content) {
return parts.join(".");
},
human_time = function(elapsed, factor) {
factor = factor || 1;
elapsed = Math.floor(elapsed);
var years = Math.floor((elapsed*factor) / 31536000) / factor;
if ( years >= 1 )
return years + ' year' + pluralize(years);
var days = Math.floor((elapsed %= 31536000) / 86400);
if ( days >= 1 )
return days + ' day' + pluralize(days);
var hours = Math.floor((elapsed %= 86400) / 3600);
if ( hours >= 1 )
return hours + ' hour' + pluralize(hours);
var minutes = Math.floor((elapsed %= 3600) / 60);
if ( minutes >= 1 )
return minutes + ' minute' + pluralize(minutes);
var seconds = elapsed % 60;
if ( seconds >= 1 )
return seconds + ' second' + pluralize(seconds);
return 'less than a second';
},
pluralize = function(value, singular, plural) {
plural = plural || 's';
singular = singular || '';
@ -918,31 +945,20 @@ module.exports = FFZ.utils = {
return HUMAN_NUMBERS[value] || number_commas(value);
},
human_time: function(elapsed, factor) {
factor = factor || 1;
elapsed = Math.floor(elapsed);
human_time: human_time,
full_human_time: function(elapsed, factor) {
var before = elapsed >= 0,
output = human_time(Math.abs(elapsed), factor);
var years = Math.floor((elapsed*factor) / 31536000) / factor;
if ( years >= 1 )
return years + ' year' + pluralize(years);
return before ? output + ' ago' : 'in ' + output;
},
var days = Math.floor((elapsed %= 31536000) / 86400);
if ( days >= 1 )
return days + ' day' + pluralize(days);
var hours = Math.floor((elapsed %= 86400) / 3600);
if ( hours >= 1 )
return hours + ' hour' + pluralize(hours);
var minutes = Math.floor((elapsed %= 3600) / 60);
if ( minutes >= 1 )
return minutes + ' minute' + pluralize(minutes);
var seconds = elapsed % 60;
if ( seconds >= 1 )
return seconds + ' second' + pluralize(seconds);
return 'less than a second';
human_join: function(list) {
if ( list.length === 2 )
return list[0] + ' and ' + list[1];
else if ( list.length === 1 )
return list[0];
return list.slice(0, -1).join(', ') + ' and ' + list[list.length-1];
},
time_to_string: function(elapsed, separate_days, days_only, no_hours, no_seconds) {