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

3.5.337. Chatter count on dashboard. Channel-specific badge fixes. Stuff.

This commit is contained in:
SirStendec 2016-10-18 00:35:31 -04:00
parent a89b71f0a2
commit f04edf7f54
10 changed files with 98 additions and 55 deletions

View file

@ -1,3 +1,21 @@
<div class="list-header">3.5.337 <time datetime="2016-10-17">(2016-10-17)</time></div>
<ul class="chat-menu-content menu-side-padding">
<li>Added: Show chatter count on the dashboard.</li>
<li>Fixed: Chat badges could be generated with the image <code>"null"</code> if they didn't have high-DPI images causing them to render as a blank for some users.</li>
<li>Fixed: Bug in logviewer handling code that would result in an endless UI loading state if no messages are returned.</li>
<li>Changed: Update BetterTTV support for a few minor changes in the extension.</li>
</ul>
<div class="list-header">3.5.336 <time datetime="2016-10-16">(2016-10-16)</time></div>
<ul class="chat-menu-content menu-side-padding">
<li>Fixed: Bug in moderation log handling that would show an unban as a ban.</li>
</ul>
<div class="list-header">3.5.335 <time datetime="2016-10-16">(2016-10-16)</time></div>
<ul class="chat-menu-content menu-side-padding">
<li>Added: Option to disable making links clickable in chat.</li>
</ul>
<div class="list-header">3.5.334 <time datetime="2016-10-16">(2016-10-16)</time></div>
<ul class="chat-menu-content menu-side-padding">
<li>Changed: Remove beta status from Logviewer Integration and enable it by default.</li>

View file

@ -480,7 +480,8 @@ FFZ.prototype.get_twitch_badges = function(badge_tag, room_id) {
if ( ! is_known && binfo ) {
badges[last_id].image = binfo.image_url_1x;
badges[last_id].srcSet = 'url("' + binfo.image_url_1x + '") 1x, url("' + binfo.image_url_2x + '") 2x, url("' + binfo.image_url_4x + '") 4x';
if ( binfo.image_url_2x || binfo.image_url_4x )
badges[last_id].srcSet = 'url("' + binfo.image_url_1x + '") 1x' + (binfo.image_url_2x ? ', url("' + binfo.image_url_2x + '") 2x' : '') + (binfo.image_url_4x ? ', url("' + binfo.image_url_4x + '") 4x' : '');
}
}

View file

@ -88,6 +88,18 @@ FFZ.settings_info.replace_bad_emotes = {
};
FFZ.settings_info.parse_links = {
type: "boolean",
value: true,
category: "Chat Appearance",
no_bttv: true,
name: "Make Links Clickable",
help: "Display links as real, clickable hyperlinks rather than just text."
}
FFZ.settings_info.parse_emoticons = {
type: "boolean",
value: true,

View file

@ -176,7 +176,7 @@ FFZ.prototype.format_ban_notice = function(username, is_me, duration, count, rea
if ( ! Array.isArray(notice) )
notice = [notice];
var nd = notice[0] === -Infinity ? 'unban' : isFinite(notice[0]) ? utils.duration_string(notice[0], true) : 'ban';
var nd = (notice[0] === -Infinity || notice[0] === -1) ? 'unban' : (notice[0] !== null && isFinite(notice[0])) ? utils.duration_string(notice[0], true) : 'ban';
duration_tip.push(utils.sanitize(mod_id) + ' - ' + nd + (notice[1] ? ': ' + utils.sanitize(notice[1]) : ''));
}
@ -1213,7 +1213,7 @@ FFZ.prototype._modify_room = function(room) {
var msg_id,
reason = event.args[2],
duration = event.moderator_action === 'unban' ? -Infinity : event.args[1];
duration = event.moderation_action === 'unban' ? -Infinity : event.args[1];
if ( typeof duration === "string" )
duration = parseInt(duration);
@ -2141,7 +2141,7 @@ FFZ.prototype._modify_room = function(room) {
f._cindex.ffzUpdateMetadata('chatters');
if ( window !== window.parent && parent.postMessage )
parent.postMessage({from_ffz: true, command: 'chatter_count', data: Object.keys(this.get('ffz_chatters') || {}).length}, "*"); //location.protocol + "//www.twitch.tv/");
parent.postMessage({from_ffz: true, command: 'chatter_count', data: {room: this.get('id'), chatters: Object.keys(this.get('ffz_chatters') || {}).length}}, "*"); //location.protocol + "//www.twitch.tv/");
},

View file

@ -158,7 +158,7 @@ FFZ.prototype.setup_bttv = function(delay) {
f.bttv_badges(data);
// Now, do everything else manually because things are hard-coded.
return '<div class="chat-line'+(opts.highlight?' highlight':'')+(opts.action?' action':'')+(opts.server?' admin':'')+(opts.notice?' notice':'')+'" data-sender="'+(data.sender||"").toLowerCase()+'" data-room="'+received_room+'">'+
return '<div class="chat-line'+(opts.highlight?' highlight':'')+(opts.action?' action':'')+(opts.server?' admin':'')+(opts.notice?' notice':'')+'" data-id="' + data.id + '" data-sender="'+(data.sender||"").toLowerCase()+'" data-room="'+received_room+'">'+
BC.templates.timestamp(data.time)+' '+
(opts.isMod ? BC.templates.modicons():'')+' '+
BC.templates.badges(data.badges)+
@ -228,13 +228,7 @@ FFZ.prototype.setup_bttv = function(delay) {
message = tokenizedMessage.join(' ');
}
var spam = false;
if ( BetterTTV.settings.get('hideSpam') && BC.helpers.isSpammer(sender) && !BC.helpers.isModerator(sender) && !force) {
message = '<span class="deleted">&lt;spam deleted&gt;</span>';
spam = true;
}
return '<span class="message ' + (spam ? 'spam' : '') + '" ' + (colored ? 'style="color: ' + colored + '" ' : '') + 'data-raw="' + rawMessage + '" data-bits="' + (bits ? encodeURIComponent(JSON.stringify(bits)) : 'false') + '" data-emotes="' + (emotes ? encodeURIComponent(JSON.stringify(emotes)) : 'false') + '">' + message + '</span>';
return '<span class="message" ' + (colored ? 'style="color: ' + colored + '" ' : '') + 'data-raw="' + rawMessage + '" data-bits="' + (bits ? encodeURIComponent(JSON.stringify(bits)) : 'false') + '" data-emotes="' + (emotes ? encodeURIComponent(JSON.stringify(emotes)) : 'false') + '">' + message + '</span>';
} catch(err) {
f.log("Error: ", err);

View file

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

View file

@ -180,7 +180,7 @@ FFZ.settings_info.show_deleted_links = {
name: "Show Deleted Links",
help: "Do not delete links based on room settings or link length."
};
};
// ---------------------
@ -550,7 +550,7 @@ FFZ.prototype.tokenize_conversation_line = function(message, prevent_notificatio
emotes = emote_helpers(emotes);
// Standard Tokenization
if ( helpers && helpers.linkifyMessage )
if ( helpers && helpers.linkifyMessage && this.settings.parse_links )
tokens = helpers.linkifyMessage(tokens);
if ( user && user.login && helpers && helpers.mentionizeMessage ) {
@ -602,7 +602,7 @@ FFZ.prototype.tokenize_vod_line = function(msgObject, delete_links) {
tokens = [msg];
if ( helpers && helpers.linkifyMessage )
if ( helpers && helpers.linkifyMessage && this.settings.parse_links )
tokens = helpers.linkifyMessage(tokens, delete_links);
if ( user && user.login && helpers && helpers.mentionizeMessage ) {
@ -666,7 +666,7 @@ FFZ.prototype.tokenize_chat_line = function(msgObject, prevent_notification, del
//if ( helpers && helpers.tokenizeRichContent )
// tokens = helpers.tokenizeRichContent(tokens, tags.content, delete_links);
if ( helpers && helpers.linkifyMessage )
if ( helpers && helpers.linkifyMessage && this.settings.parse_links )
tokens = helpers.linkifyMessage(tokens, delete_links && ! tags.mod);

View file

@ -1,5 +1,6 @@
var FFZ = window.FrankerFaceZ,
utils = require('../utils'),
constants = require('../constants'),
update_viewer_count = function(text) {
var vc = jQuery("#channel_viewer_count");
@ -38,6 +39,37 @@ FFZ.msg_commands.chat_message = function(data) {
}
FFZ.msg_commands.chatter_count = function(data) {
if ( ! this.dashboard_channel || data.room !== this.dashboard_channel )
return;
var el = document.querySelector('#ffz-chatter-display span');
if ( ! this.settings.chatter_count || this.has_bttv || ! this.is_dashboard || ! data.chatters ) {
if ( el )
jQuery(el).parent().remove();
return;
}
if ( ! el ) {
var cont = document.querySelector('#stats');
if ( ! cont )
return;
var stat = utils.createElement('span', 'ffz stat', constants.ROOMS + ' ');
stat.id = 'ffz-chatter-display';
stat.title = 'Currently in Chat';
el = utils.createElement('span');
stat.appendChild(el);
cont.appendChild(stat);
jQuery(stat).tipsy({gravity: 's'});
}
el.textContent = utils.number_commas(data.chatters);
}
// -------------------
// Initialization
// -------------------

View file

@ -71,9 +71,13 @@ FFZ.prototype.lv_get_logs = function(room_id, user_id, ref_id, before_cnt, after
utils.logviewer.get("logs/" + room_id + "?" + args.join('&'), token)
.then(utils.json).then(function(data) {
// Parse every message immediately.
if ( data ) {
var bound = f.lv_parse_message.bind(f);
if ( data.before )
data.before = _.map(data.before, bound);
if ( data.after )
data.after = _.map(data.after, bound);
}
succeed(data);
});

View file

@ -8,44 +8,32 @@ var FFZ = window.FrankerFaceZ,
// -------------------
FFZ.prototype._update_subscribers = function() {
if ( this._update_subscribers_timer ) {
if ( this._update_subscribers_timer )
clearTimeout(this._update_subscribers_timer);
delete this._update_subscribers_timer;
}
var f = this,
user = this.get_user();
if ( this.has_bttv || ! user || ! user.login || this.dashboard_channel !== user.login )
return jQuery("#ffz-sub-display").remove();
// Schedule an update.
this._update_subscribers_timer = setTimeout(this._update_subscribers.bind(this), 60000);
var user = this.get_user(), f = this,
match = this.is_dashboard ? location.pathname.match(/\/([^\/]+)/) : undefined,
channel_id = this.is_dashboard && match && match[1];
if ( this.has_bttv || ! channel_id || channel_id !== user.login ) {
var el = document.querySelector("#ffz-sub-display");
if ( el )
el.parentElement.removeChild(el);
return;
}
// Spend a moment wishing we could just hit the subscribers API from the
// context of the web user.
// Get the count!
utils.api.get("/api/channels/" + channel_id + "/subscriber_count").done(function(data) {
utils.api.get("/api/channels/" + this.dashboard_channel + "/subscriber_count").done(function(data) {
var el, sub_count = data && data.count;
if ( typeof sub_count === "string" )
sub_count = parseInt(sub_count.replace(/[,\.]/g, ""));
if ( typeof sub_count !== "number" || sub_count === 0 || sub_count === NaN || sub_count === Infinity ) {
el = document.querySelector("#ffz-sub-display");
if ( el )
el.parentElement.removeChild(el);
if ( typeof sub_count !== "number" || ! sub_count || isNaN(sub_count) || ! isFinite(sub_count) ) {
jQuery("#ffz-sub-display").remove();
var failed = f._failed_sub_checks = (f._failed_sub_checks || 0) + 1;
if ( f._update_subscribers_timer && failed >= 5 ) {
f.log("Subscriber count failed 5 times. Giving up.");
clearTimeout(f._update_subscribers_timer);
delete f._update_subscribers_timer;
f._update_subscribers_timer = undefined;
}
return;
@ -63,18 +51,15 @@ FFZ.prototype._update_subscribers = function() {
el = document.querySelector('#ffz-sub-display span');
if ( ! el ) {
var cont = f.is_dashboard ? document.querySelector("#stats") : document.querySelector("#channel .stats-and-actions .channel-stats");
var cont = document.querySelector('#stats');
if ( ! cont )
return;
var stat = document.createElement('span');
stat.className = 'ffz stat';
var stat = utils.createElement('span', 'ffz stat', constants.STAR + ' ');
stat.id = 'ffz-sub-display';
stat.title = 'Subscribers';
stat.innerHTML = constants.STAR + ' ';
el = document.createElement('span');
el = utils.createElement('span');
stat.appendChild(el);
utils.api.get("chat/" + channel_id + "/badges", null, {version: 3})
@ -91,15 +76,12 @@ FFZ.prototype._update_subscribers = function() {
});
cont.appendChild(stat);
jQuery(stat).tipsy({gravity: f.is_dashboard ? "s" : utils.tooltip_placement(constants.TOOLTIP_DISTANCE, 'n')});
jQuery(stat).tipsy({gravity: 's'});
}
el.innerHTML = utils.number_commas(sub_count);
el.textContent = utils.number_commas(sub_count);
}).fail(function(){
var el = document.querySelector("#ffz-sub-display");
if ( el )
el.parentElement.removeChild(el);
return;
jQuery("#ffz-sub-display").remove();
});
}