1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-09-15 17:46:55 +00:00

Pre dev stream

This commit is contained in:
SirStendec 2015-07-04 17:06:36 -04:00
parent b184fc74b2
commit 6a62804ec1
26 changed files with 4658 additions and 732 deletions

View file

@ -1,4 +1,6 @@
var FFZ = window.FrankerFaceZ,
constants = require('../constants'),
utils = require('../utils'),
SENDER_REGEX = /(\sdata-sender="[^"]*"(?=>))/;
@ -37,6 +39,16 @@ FFZ.prototype.setup_bttv = function(delay) {
this._chatv.ffzDisableTabs();
}
if ( this._roomv ) {
// Disable Chat Pause
if ( this.settings.chat_hover_pause )
this._roomv.ffzDisableFreeze();
// And hide the status
if ( this.settings.room_status )
this._roomv.ffzUpdateStatus();
}
// Disable other features too.
document.body.classList.remove("ffz-chat-colors");
document.body.classList.remove("ffz-chat-background");
@ -45,6 +57,7 @@ FFZ.prototype.setup_bttv = function(delay) {
if ( this.is_dashboard )
this._update_subscribers();
document.body.classList.add('ffz-bttv');
// Send Message Behavior
var original_send = BetterTTV.chat.helpers.sendMessage, f = this;
@ -91,6 +104,26 @@ FFZ.prototype.setup_bttv = function(delay) {
}
}
// Whispers too!
var original_whisper = BetterTTV.chat.templates.whisper;
BetterTTV.chat.templates.whisper = function(data) {
try {
// Handle badges.
f.bttv_badges(data);
// Now, do everything else manually because things are hard-coded.
return '<div class="chat-line whisper" data-sender="' + data.sender + '">' +
BetterTTV.chat.templates.timestamp(data.time) + ' ' +
(data.badges && data.badges.length ? BetterTTV.chat.templates.badges(data.badges) : '') +
BetterTTV.chat.templates.whisperName(data.sender, data.receiver, data.from, data.to, data.fromColor, data.toColor) +
BetterTTV.chat.templates.message(data.sender, data.message, data.emotes, false) +
'</div>';
} catch(err) {
f.log("Error: ", err);
return original_whisper(data);
}
}
// Message Renderer. I had to completely rewrite this method to get it to
// use my replacement emoticonizer.
var original_message = BetterTTV.chat.templates.message,
@ -151,46 +184,80 @@ FFZ.prototype.setup_bttv = function(delay) {
});
// Don't bother proceeding if we have no emotes.
if ( ! emotes.length )
return tokens;
if ( emotes.length ) {
// Why is emote parsing so bad? ;_;
_.each(emotes, function(emote) {
var tooltip = f._emote_tooltip(emote),
eo = ['<img class="emoticon" srcset="' + (emote.srcSet || "") + '" src="' + emote.urls[1] + '" alt="' + tooltip + '" title="' + tooltip + '" />'],
old_tokens = tokens;
// Why is emote parsing so bad? ;_;
_.each(emotes, function(emote) {
var tooltip = f._emote_tooltip(emote),
eo = ['<img class="emoticon" srcset="' + (emote.srcSet || "") + '" src="' + emote.urls[1] + '" alt="' + tooltip + '" title="' + tooltip + '" />'],
old_tokens = tokens;
tokens = [];
for(var i=0; i < old_tokens.length; i++) {
var token = old_tokens[i];
if ( typeof token != "string" ) {
tokens.push(token);
continue;
}
var tbits = token.split(emote.regex);
while(tbits.length) {
var bit = tbits.shift();
if ( tbits.length ) {
bit += tbits.shift();
if ( bit )
tokens.push(bit);
tbits.shift();
tokens.push(eo);
if ( mine && l_room )
f.add_usage(l_room, emote.id);
} else
tokens.push(bit);
}
}
});
}
// Sneak in Emojicon Processing
if ( f.settings.parse_emoji && f.emoji_data ) {
var old_tokens = tokens;
tokens = [];
if ( ! old_tokens || ! old_tokens.length )
return tokens;
for(var i=0; i < old_tokens.length; i++) {
var token = old_tokens[i];
if ( typeof token != "string" ) {
if ( typeof token !== "string" ) {
tokens.push(token);
continue;
}
var tbits = token.split(emote.regex);
var tbits = token.split(constants.EMOJI_REGEX);
while(tbits.length) {
var bit = tbits.shift();
bit && tokens.push(bit);
if ( tbits.length ) {
bit += tbits.shift();
if ( bit )
tokens.push(bit);
var match = tbits.shift(),
variant = tbits.shift();
tbits.shift();
tokens.push(eo);
if ( variant === '\uFE0E' )
bits.push(match);
else {
var eid = utils.emoji_to_codepoint(match, variant),
data = f.emoji_data[eid],
alt = match + (variant || "");
if ( mine && l_room )
f.add_usage(l_room, emote.id);
} else
tokens.push(bit);
if ( data ) {
tokens.push(['<img class="emoticon" height="18px" srcset="' + (data.srcSet || "") + '" src="' + data.src + '" alt="' + alt + '" title="Emoji: ' + alt + '\nName: ' + data.short_name + '">']);
} else
tokens.push(match + (variant || ""));
}
}
}
}
});
}
return tokens;
}