2015-05-17 19:02:57 -04:00
var FFZ = window . FrankerFaceZ ,
2015-02-10 01:34:23 -05:00
utils = require ( "../utils" ) ,
2016-09-30 13:09:03 -04:00
constants = require ( "../constants" ) ,
2016-12-14 02:40:18 -05:00
TB _TOOLTIP = '<hr>This message was flagged by AutoMod. Should it be allowed?' ,
2016-11-08 16:43:02 -05:00
2016-12-14 02:40:18 -05:00
BAN _SPLIT = /[\/\.](?:ban ([^ ]+)|timeout ([^ ]+)(?: (\d+))?|timeout_message ([^ ]+) ([^ ]+)(?: (\d+))?)(?: (.*))?$/ ;
2015-02-08 02:01:09 -05:00
2015-05-17 19:02:57 -04:00
// ---------------------
// Settings
// ---------------------
2016-03-23 19:28:22 -04:00
FFZ . settings _info . alias _italics = {
type : "boolean" ,
value : true ,
category : "Chat Appearance" ,
2016-07-13 02:31:26 -04:00
no _bttv : true ,
2016-03-23 19:28:22 -04:00
2016-07-13 02:31:26 -04:00
name : "Display Aliases in Italics" ,
help : "Format the names of users that have aliases with italics to make it obvious at a glance that they have been renamed." ,
2016-03-23 19:28:22 -04:00
on _update : function ( val ) {
2016-07-13 02:31:26 -04:00
document . body . classList . toggle ( 'ffz-alias-italics' , val ) ;
}
2016-07-13 02:06:50 -04:00
} ;
2016-03-23 19:28:22 -04:00
2016-09-09 17:34:20 -04:00
FFZ . settings _info . username _display = {
type : "select" ,
options : {
0 : "Username Only" ,
1 : "Capitalization Only" ,
2 : "Display Name Only" ,
3 : "Username in Parenthesis" ,
4 : "Username in Tooltip"
} ,
category : "Chat Appearance" ,
no _bttv : true ,
name : "Username Display" ,
help : "How a user's name should be rendered when their display name differs from the username." ,
value : 3 ,
2016-10-01 14:11:49 -04:00
process _value : utils . process _int ( 3 ) ,
2016-09-09 17:34:20 -04:00
on _update : function ( val ) {
var CL = utils . ember _resolve ( 'component:chat/chat-line' ) ,
views = CL ? utils . ember _views ( ) : [ ] ;
for ( var vid in views ) {
var view = views [ vid ] ;
if ( view instanceof CL && view . buildFromHTML ) {
view . $ ( '.from' ) . replaceWith ( view . buildFromHTML ( ) ) ;
if ( view . get ( 'msgObject.to' ) )
view . $ ( '.to' ) . replaceWith ( view . buildFromHTML ( true ) ) ;
}
}
}
}
2015-07-06 00:09:21 -04:00
FFZ . settings _info . room _status = {
type : "boolean" ,
value : true ,
2015-07-13 21:52:44 -04:00
category : "Chat Appearance" ,
2015-07-06 00:09:21 -04:00
no _bttv : true ,
name : "Room Status Indicators" ,
help : "Display the current room state (slow mode, sub mode, and r9k mode) next to the Chat button." ,
on _update : function ( ) {
2016-07-13 02:31:26 -04:00
if ( this . _roomv )
this . _roomv . ffzUpdateStatus ( ) ;
}
2016-07-13 02:06:50 -04:00
} ;
2015-07-06 00:09:21 -04:00
FFZ . settings _info . replace _bad _emotes = {
type : "boolean" ,
value : true ,
2015-08-02 02:41:03 -04:00
2015-07-13 21:52:44 -04:00
category : "Chat Appearance" ,
2016-03-23 19:28:22 -04:00
warn _bttv : "Only affects Whispers when BetterTTV is enabled." ,
2015-08-02 02:41:03 -04:00
2015-07-06 00:09:21 -04:00
name : "Fix Low Quality Twitch Global Emoticons" ,
help : "Replace emoticons such as DansGame and RedCoat with cleaned up versions that don't have pixels around the edges or white backgrounds for nicer display on dark chat."
2016-07-13 02:06:50 -04:00
} ;
2016-10-18 00:35:31 -04:00
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."
}
2016-07-13 02:06:50 -04:00
FFZ . settings _info . parse _emoticons = {
2016-07-13 02:31:26 -04:00
type : "boolean" ,
value : true ,
2016-07-13 02:06:50 -04:00
2016-07-13 02:31:26 -04:00
category : "Chat Appearance" ,
no _bttv : true ,
2016-07-13 02:06:50 -04:00
2016-07-13 02:31:26 -04:00
name : "Display Emoticons" ,
help : "Display emoticons in chat messages rather than just text."
2016-07-13 02:06:50 -04:00
} ;
2015-08-04 01:43:08 -04:00
2015-07-06 00:09:21 -04:00
2015-07-04 17:06:36 -04:00
FFZ . settings _info . parse _emoji = {
2015-08-28 22:54:12 -04:00
type : "select" ,
options : {
0 : "No Images / Font Only" ,
1 : "Twitter Emoji Images" ,
2016-03-23 19:28:22 -04:00
2 : "Google Noto Images" ,
2016-07-13 02:31:26 -04:00
3 : "EmojiOne Images"
2015-08-28 22:54:12 -04:00
} ,
value : 1 ,
2016-10-01 14:11:49 -04:00
process _value : utils . process _int ( 1 , 0 , 1 ) ,
2015-07-04 17:06:36 -04:00
2015-07-13 21:52:44 -04:00
category : "Chat Appearance" ,
2015-07-04 17:06:36 -04:00
2016-07-13 02:06:50 -04:00
name : "Display Emoji" ,
2015-08-28 22:54:12 -04:00
help : "Replace emoji in chat messages with nicer looking images from either Twitter or Google."
2016-07-13 02:06:50 -04:00
} ;
2015-07-04 17:06:36 -04:00
FFZ . settings _info . scrollback _length = {
type : "button" ,
value : 150 ,
2015-07-13 21:52:44 -04:00
category : "Chat Appearance" ,
2015-07-04 17:06:36 -04:00
no _bttv : true ,
name : "Scrollback Length" ,
help : "Set the maximum number of lines to keep in chat." ,
method : function ( ) {
2016-07-13 02:31:26 -04:00
var f = this ;
utils . prompt (
"Scrollback Length" ,
"Please enter a new maximum length for the chat scrollback. Please note that setting this too high may cause your computer to begin lagging as chat messages accumulate.</p><p><b>Default:</b> 150" ,
this . settings . scrollback _length ,
function ( new _val ) {
if ( new _val === null || new _val === undefined )
return ;
new _val = parseInt ( new _val ) ;
if ( Number . isNaN ( new _val ) || ! Number . isFinite ( new _val ) )
new _val = 150 ;
new _val = Math . max ( 10 , new _val ) ;
f . settings . set ( "scrollback_length" , new _val ) ;
// Update our everything.
var Chat = utils . ember _lookup ( 'controller:chat' ) ,
current _id = Chat && Chat . get ( 'currentRoom.id' ) ;
for ( var room _id in f . rooms ) {
var room = f . rooms [ room _id ] ;
room . room && room . room . set ( 'messageBufferSize' , new _val + ( ( f . _roomv && ! f . _roomv . get ( 'stuckToBottom' ) && current _id === room _id ) ? 150 : 0 ) ) ;
}
} ) ;
2015-07-04 17:06:36 -04:00
}
} ;
2015-07-29 01:03:10 -04:00
FFZ . settings _info . hosted _sub _notices = {
type : "boolean" ,
value : true ,
category : "Chat Filtering" ,
no _bttv : true ,
name : "Show Hosted Channel Subscriber Notices" ,
2016-03-23 19:28:22 -04:00
help : "Display (or more specifically <i>hides</i> when disabled) notices in chat when someone subscribes to the hosted channel."
2015-07-29 01:03:10 -04:00
} ;
2016-03-23 19:28:22 -04:00
FFZ . settings _info . filter _whispered _links = {
2015-08-21 19:00:48 -04:00
type : "boolean" ,
value : true ,
category : "Chat Filtering" ,
2016-07-13 02:31:26 -04:00
warn _bttv : "Only affects Whispers when BetterTTV is enabled." ,
2015-08-21 19:00:48 -04:00
2016-03-23 19:28:22 -04:00
name : "Auto-Hide Potentially Dangerous Whispered Links" ,
help : "Removes whispered links and displays a placeholder, with a warning that the link has not been approved by moderation or staff. Links remain accessible with an additional click."
2015-08-21 19:00:48 -04:00
} ;
2015-02-24 00:33:29 -05:00
FFZ . settings _info . banned _words = {
type : "button" ,
value : [ ] ,
2015-07-13 21:52:44 -04:00
category : "Chat Filtering" ,
2016-03-23 19:28:22 -04:00
warn _bttv : "Only affects Whispers when BetterTTV is enabled." ,
2015-02-24 00:33:29 -05:00
name : "Banned Words" ,
help : "Set a list of words that will be locally removed from chat messages." ,
2016-09-30 13:09:03 -04:00
method : function ( e , from _basic ) {
2016-03-23 19:28:22 -04:00
var f = this ,
2016-09-30 13:09:03 -04:00
old _val = this . settings . banned _words . join ( "\n" ) ,
input = utils . createElement ( 'textarea' ) ;
input . style . marginBottom = "20px" ;
2015-02-24 00:33:29 -05:00
2016-07-13 02:31:26 -04:00
utils . prompt (
"Banned Words" ,
2016-09-30 13:09:03 -04:00
"Please enter a list of words or phrases that you would like to have removed from chat messages. One item per line." + ( from _basic ? "" : "<hr><strong>Advanced Stuff:</strong> If you know regex, you can use regular expressions to match too! Start a line with <code>regex:</code> to trigger that behavior.<br><div class=\"small\">(Note: Your expression is wrapped in a capture group and may be joined with other expressions within that group via <code>|</code>. All regular expressions are executed with the flags <code>ig</code>.)</div>" ) ,
2016-07-13 02:31:26 -04:00
old _val ,
function ( new _val ) {
if ( new _val === null || new _val === undefined )
return ;
2015-02-24 00:33:29 -05:00
2016-09-30 13:09:03 -04:00
var vals = new _val . trim ( ) . split ( /\s*\n\s*/g ) ,
i = vals . length ;
2015-02-24 00:33:29 -05:00
2016-09-30 13:09:03 -04:00
while ( i -- )
if ( vals [ i ] . length === 0 )
vals . splice ( i , 1 ) ;
2015-02-24 00:33:29 -05:00
2016-07-13 02:31:26 -04:00
f . settings . set ( "banned_words" , vals ) ;
2016-09-30 13:09:03 -04:00
} ,
600 , input ) ;
2015-02-24 00:33:29 -05:00
}
} ;
2015-02-08 02:01:09 -05:00
FFZ . settings _info . keywords = {
type : "button" ,
value : [ ] ,
2015-07-13 21:52:44 -04:00
category : "Chat Filtering" ,
2016-03-23 19:28:22 -04:00
2016-07-13 02:31:26 -04:00
warn _bttv : "Only affects Whispers when BetterTTV is enabled." ,
2015-02-08 02:01:09 -05:00
name : "Highlight Keywords" ,
help : "Set additional keywords that will be highlighted in chat." ,
2016-09-30 13:09:03 -04:00
method : function ( e , from _basic ) {
2016-03-23 19:28:22 -04:00
var f = this ,
2016-09-30 13:09:03 -04:00
old _val = this . settings . keywords . join ( "\n" ) ,
input = utils . createElement ( 'textarea' ) ;
input . style . marginBottom = "20px" ;
2015-02-08 02:01:09 -05:00
2016-07-13 02:31:26 -04:00
utils . prompt (
"Highlight Keywords" ,
2016-09-30 13:09:03 -04:00
"Please enter a list of words or phrases that you would like to be highlighted in chat. One item per line." + ( from _basic ? "" : "<hr><strong>Advanced Stuff:</strong> If you know regex, you can use regular expressions to match too! Start a line with <code>regex:</code> to trigger that behavior.<br><div class=\"small\">(Note: Your expression is wrapped in a capture group and may be joined with other expressions within that group via <code>|</code>. All regular expressions are executed with the flags <code>ig</code>.)</div>" ) ,
2016-07-13 02:31:26 -04:00
old _val ,
function ( new _val ) {
if ( new _val === null || new _val === undefined )
return ;
2015-02-08 02:01:09 -05:00
2016-07-13 02:31:26 -04:00
// Split them up.
2016-09-30 13:09:03 -04:00
var vals = new _val . trim ( ) . split ( /\s*\n\s*/g ) ,
i = vals . length ;
2015-02-24 00:33:29 -05:00
2016-09-30 13:09:03 -04:00
while ( i -- )
if ( vals [ i ] . length === 0 )
vals . splice ( i , 1 ) ;
2015-02-08 02:01:09 -05:00
2016-07-13 02:31:26 -04:00
f . settings . set ( "keywords" , vals ) ;
2016-09-30 13:09:03 -04:00
} ,
600 , input ) ;
2015-02-08 02:01:09 -05:00
}
} ;
2015-07-31 17:44:20 -04:00
FFZ . settings _info . clickable _emoticons = {
type : "boolean" ,
value : false ,
category : "Chat Tooltips" ,
2016-03-23 19:28:22 -04:00
warn _bttv : "Only affects Whispers when BetterTTV is enabled." ,
2015-07-31 17:44:20 -04:00
no _mobile : true ,
name : "Emoticon Information Pages" ,
help : "When enabled, holding shift and clicking on an emoticon will open it on the FrankerFaceZ website or Twitch Emotes."
} ;
2015-07-18 21:10:27 -04:00
FFZ . settings _info . link _info = {
2015-02-10 01:34:23 -05:00
type : "boolean" ,
2015-02-26 00:42:11 -05:00
value : true ,
2015-02-10 01:34:23 -05:00
2015-07-18 21:10:27 -04:00
category : "Chat Tooltips" ,
2015-05-17 19:02:57 -04:00
no _bttv : true ,
2015-02-10 01:34:23 -05:00
2015-07-18 21:10:27 -04:00
name : "Link Information <span>Beta</span>" ,
help : "Check links against known bad websites, unshorten URLs, and show YouTube info."
2015-02-10 01:34:23 -05:00
} ;
2015-07-18 21:10:27 -04:00
FFZ . settings _info . link _image _hover = {
2015-05-17 19:02:57 -04:00
type : "boolean" ,
2015-07-18 21:10:27 -04:00
value : false ,
2015-05-17 19:02:57 -04:00
2015-07-18 21:10:27 -04:00
category : "Chat Tooltips" ,
2015-05-17 19:02:57 -04:00
no _bttv : true ,
2015-07-18 21:10:27 -04:00
no _mobile : true ,
2015-05-17 19:02:57 -04:00
2015-07-18 21:10:27 -04:00
name : "Image Preview" ,
help : "Display image thumbnails for links to Imgur and YouTube."
} ;
2015-11-14 23:52:49 -05:00
FFZ . settings _info . emote _image _hover = {
type : "boolean" ,
value : false ,
category : "Chat Tooltips" ,
no _mobile : true ,
name : "Emote Preview" ,
help : "Display scaled up high-DPI emoticon images in tooltips to help see details on low-resolution monitors." ,
on _update : function ( val ) {
this . _reset _tooltips ( ) ;
}
} ;
2015-07-18 21:10:27 -04:00
FFZ . settings _info . image _hover _all _domains = {
type : "boolean" ,
value : false ,
2015-08-02 02:41:03 -04:00
2015-07-18 21:10:27 -04:00
category : "Chat Tooltips" ,
no _bttv : true ,
no _mobile : true ,
2015-08-02 02:41:03 -04:00
2015-07-18 21:10:27 -04:00
name : "Image Preview - All Domains" ,
help : "<i>Requires Image Preview.</i> Attempt to show an image preview for any URL ending in the appropriate extension. <b>Warning: This may be used to leak your IP address to malicious users.</b>"
2015-05-17 19:02:57 -04:00
} ;
2015-02-08 02:01:09 -05:00
FFZ . settings _info . chat _rows = {
type : "boolean" ,
value : false ,
2015-07-13 21:52:44 -04:00
category : "Chat Appearance" ,
2015-05-17 19:02:57 -04:00
no _bttv : true ,
2015-02-08 02:01:09 -05:00
name : "Chat Line Backgrounds" ,
help : "Display alternating background colors for lines in chat." ,
2015-11-11 02:06:02 -05:00
on _update : function ( val ) {
2016-12-23 13:40:05 -05:00
this . toggle _style ( 'chat-background' , ! this . has _bttv && val ) ;
}
} ;
2015-07-13 21:52:44 -04:00
FFZ . settings _info . chat _separators = {
2015-07-18 21:10:27 -04:00
type : "select" ,
options : {
0 : "Disabled" ,
1 : "Basic Line (1px solid)" ,
2015-10-17 18:05:44 -04:00
2 : "3D Line (2px groove)" ,
3 : "3D Line (2px groove inset)" ,
4 : "Wide Line (2px solid)"
2015-07-18 21:10:27 -04:00
} ,
2016-10-01 14:11:49 -04:00
2015-10-17 18:05:44 -04:00
value : 0 ,
2016-10-01 14:11:49 -04:00
process _value : utils . process _int ( 0 , 0 , 1 ) ,
2015-07-13 21:52:44 -04:00
no _bttv : true ,
2015-08-02 02:41:03 -04:00
2016-10-01 14:11:49 -04:00
category : "Chat Appearance" ,
2015-07-13 21:52:44 -04:00
name : "Chat Line Separators" ,
help : "Display thin lines between chat messages for further visual separation." ,
2015-07-18 21:10:27 -04:00
on _update : function ( val ) {
2016-12-23 13:40:05 -05:00
this . toggle _style ( 'chat-separator' , ! this . has _bttv && val ) ;
this . toggle _style ( 'chat-separator-3d' , ! this . has _bttv && val === 2 ) ;
this . toggle _style ( 'chat-separator-3d-inset' , ! this . has _bttv && val === 3 ) ;
this . toggle _style ( 'chat-separator-wide' , ! this . has _bttv && val === 4 ) ;
}
} ;
2015-08-02 02:41:03 -04:00
2016-06-22 14:23:03 -04:00
FFZ . settings _info . old _sub _notices = {
2016-07-13 02:31:26 -04:00
type : "boolean" ,
value : false ,
2016-06-22 14:23:03 -04:00
2016-07-13 02:31:26 -04:00
category : "Chat Appearance" ,
no _bttv : true ,
2016-06-22 14:23:03 -04:00
2016-07-13 02:31:26 -04:00
name : "Old-Style Subscriber Notices" ,
help : "Display the old style subscriber notices, with the message on a separate line."
2016-06-22 14:23:03 -04:00
} ;
2016-07-13 02:06:50 -04:00
FFZ . settings _info . emote _alignment = {
2016-10-20 16:41:04 -04:00
type : "select" ,
options : {
0 : "Standard" ,
1 : "Padded" ,
2 : "Baseline (BTTV-Like)" ,
} ,
value : 0 ,
process _value : utils . process _int ( 0 , 0 , 2 ) ,
2016-07-13 02:06:50 -04:00
2016-07-13 02:31:26 -04:00
category : "Chat Appearance" ,
no _bttv : true ,
2016-07-13 02:06:50 -04:00
2016-10-20 16:41:04 -04:00
name : "Emoticon Alignment" ,
help : "Change how emotes are aligned and padded in chat, making messages taller but preventing emotes from overlapping." ,
2016-07-13 02:06:50 -04:00
2016-10-20 16:41:04 -04:00
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 ) ;
}
2016-07-13 02:06:50 -04:00
} ;
2015-07-13 21:52:44 -04:00
FFZ . settings _info . chat _padding = {
type : "boolean" ,
value : false ,
category : "Chat Appearance" ,
no _bttv : true ,
name : "Reduced Chat Line Padding" ,
help : "Reduce the amount of padding around chat messages to fit more on-screen at once." ,
2015-11-11 02:06:02 -05:00
on _update : function ( val ) { this . toggle _style ( 'chat-padding' , ! this . has _bttv && val ) ; }
2016-12-23 13:40:05 -05:00
} ;
2015-07-13 21:52:44 -04:00
FFZ . settings _info . high _contrast _chat = {
2015-07-31 17:44:20 -04:00
type : "select" ,
options : {
'222' : "Disabled" ,
'212' : "Bold" ,
'221' : "Text" ,
'211' : "Text + Bold" ,
'122' : "Background" ,
'121' : "Background + Text" ,
'112' : "Background + Bold" ,
'111' : 'All'
} ,
2015-07-13 21:52:44 -04:00
2016-10-01 14:11:49 -04:00
value : '222' ,
2015-07-31 17:44:20 -04:00
process _value : function ( val ) {
if ( val === false )
2015-08-04 01:43:08 -04:00
return '222' ;
2015-07-31 17:44:20 -04:00
else if ( val === true )
return '111' ;
return val ;
} ,
2016-10-01 14:11:49 -04:00
category : "Chat Appearance" ,
name : "High Contrast" ,
help : "Display chat using white and black for maximum contrast. This is suitable for capturing and chroma keying chat to display on stream." ,
2015-07-31 17:44:20 -04:00
on _update : function ( val ) {
2016-05-20 17:30:34 -04:00
this . toggle _style ( 'chat-hc-text' , val [ 2 ] === '1' ) ;
this . toggle _style ( 'chat-hc-bold' , val [ 1 ] === '1' ) ;
this . toggle _style ( 'chat-hc-background' , val [ 0 ] === '1' ) ;
2015-07-31 17:44:20 -04:00
}
2015-07-13 21:52:44 -04:00
} ;
2015-08-28 22:54:12 -04:00
FFZ . settings _info . chat _font _family = {
type : "button" ,
value : null ,
category : "Chat Appearance" ,
no _bttv : true ,
name : "Font Family" ,
help : "Change the font used for rendering chat messages." ,
method : function ( ) {
2016-07-13 02:31:26 -04:00
var f = this ,
old _val = this . settings . chat _font _family || "" ;
utils . prompt (
"Chat Font Family" ,
"Please enter a font family to use rendering chat. Leave this blank to use the default." ,
old _val ,
function ( new _val ) {
if ( new _val === null || new _val === undefined )
return ;
// Should we wrap this with quotes?
if ( ! new _val )
new _val = null ;
f . settings . set ( "chat_font_family" , new _val ) ;
} ) ;
2015-08-28 22:54:12 -04:00
} ,
on _update : function ( val ) {
if ( this . has _bttv || ! this . _chat _style )
return ;
var css ;
if ( ! val )
css = "" ;
else {
// Let's escape this to avoid goofing anything up if there's bad user input.
if ( val . indexOf ( ' ' ) !== - 1 && val . indexOf ( ',' ) === - 1 && val . indexOf ( '"' ) === - 1 && val . indexOf ( "'" ) === - 1 )
val = '"' + val + '"' ;
var span = document . createElement ( 'span' ) ;
span . style . fontFamily = val ;
2016-11-19 01:59:03 -05:00
css = ".pinned-cheers .chat-line,.timestamp-line,.conversation-chat-line,.conversation-system-messages,.chat-history,.ember-chat .chat-messages {" + span . style . cssText + "}" ;
2015-08-28 22:54:12 -04:00
}
utils . update _css ( this . _chat _style , "chat_font_family" , css ) ;
}
} ;
2015-07-13 21:52:44 -04:00
FFZ . settings _info . chat _font _size = {
type : "button" ,
value : 12 ,
category : "Chat Appearance" ,
no _bttv : true ,
name : "Font Size" ,
help : "Make the chat font bigger or smaller." ,
method : function ( ) {
2016-07-13 02:31:26 -04:00
var f = this ,
old _val = this . settings . chat _font _size ;
utils . prompt (
"Chat Font Size" ,
"Please enter a new size for the chat font.</p><p><b>Default:</b> 12" ,
old _val ,
function ( new _val ) {
if ( new _val === null || new _val === undefined )
return ;
var parsed = parseInt ( new _val ) ;
if ( ! parsed || Number . isNaN ( parsed ) || parsed < 1 )
parsed = 12 ;
f . settings . set ( "chat_font_size" , parsed ) ;
} ) ;
2015-07-13 21:52:44 -04:00
} ,
on _update : function ( val ) {
if ( this . has _bttv || ! this . _chat _style )
return ;
var css ;
2015-07-29 01:03:10 -04:00
if ( val === 12 || ! val )
2015-07-13 21:52:44 -04:00
css = "" ;
else {
var lh = Math . max ( 20 , Math . round ( ( 20 / 12 ) * val ) ) ,
pd = Math . floor ( ( lh - 20 ) / 2 ) ;
2016-11-19 01:59:03 -05:00
css = ".pinned-cheers .chat-line,.timestamp-line,.conversation-chat-line,.conversation-system-messages,.chat-history .chat-line,.ember-chat .chat-messages .chat-line { font-size: " + val + "px !important; line-height: " + lh + "px !important; }" ;
2015-07-13 21:52:44 -04:00
if ( pd )
2016-11-19 01:59:03 -05:00
css += ".pinned-cheers .chat-line,.ember-chat .chat-messages .chat-line .mod-icons, .ember-chat .chat-messages .chat-line .badges { padding-top: " + pd + "px; }" ;
2015-07-13 21:52:44 -04:00
}
utils . update _css ( this . _chat _style , "chat_font_size" , css ) ;
2016-03-23 19:28:22 -04:00
FFZ . settings _info . chat _ts _size . on _update . call ( this , this . settings . chat _ts _size ) ;
2015-07-18 21:10:27 -04:00
}
} ;
FFZ . settings _info . chat _ts _size = {
type : "button" ,
value : null ,
category : "Chat Appearance" ,
no _bttv : true ,
name : "Timestamp Font Size" ,
help : "Make the chat timestamp font bigger or smaller." ,
method : function ( ) {
2016-07-13 02:31:26 -04:00
var f = this ,
old _val = this . settings . chat _ts _size ;
2015-08-02 02:41:03 -04:00
2015-07-29 01:03:10 -04:00
if ( ! old _val )
2015-07-18 21:10:27 -04:00
old _val = this . settings . chat _font _size ;
2015-08-02 02:41:03 -04:00
2016-07-13 02:31:26 -04:00
utils . prompt (
"Chat Timestamp Font Size" ,
"Please enter a new size for the chat timestamp font. The default is to match the regular chat font size." ,
old _val ,
function ( new _val ) {
if ( new _val === null || new _val === undefined )
return ;
2015-07-18 21:10:27 -04:00
2016-07-13 02:31:26 -04:00
var parsed = parseInt ( new _val ) ;
if ( parsed < 1 || Number . isNaN ( parsed ) || ! Number . isFinite ( parsed ) )
parsed = null ;
2015-07-18 21:10:27 -04:00
2016-07-13 02:31:26 -04:00
f . settings . set ( "chat_ts_size" , parsed ) ;
} ) ;
2015-07-18 21:10:27 -04:00
} ,
on _update : function ( val ) {
if ( this . has _bttv || ! this . _chat _style )
return ;
var css ;
if ( val === null )
css = "" ;
else {
var lh = Math . max ( 20 , Math . round ( ( 20 / 12 ) * val ) , Math . round ( ( 20 / 12 ) * this . settings . chat _font _size ) ) ;
2015-11-19 02:45:56 -05:00
css = ".ember-chat .chat-messages .timestamp { font-size: " + val + "px !important; line-height: " + lh + "px !important; }" ;
2015-07-18 21:10:27 -04:00
}
utils . update _css ( this . _chat _style , "chat_ts_font_size" , css ) ;
2015-02-08 02:01:09 -05:00
}
} ;
2015-01-20 01:53:18 -05:00
// ---------------------
// Initialization
// ---------------------
FFZ . prototype . setup _line = function ( ) {
2015-07-13 21:52:44 -04:00
// Tipsy Handler
jQuery ( document . body ) . on ( "mouseleave" , ".tipsy" , function ( ) {
this . parentElement . removeChild ( this ) ;
} ) ;
2015-08-02 02:41:03 -04:00
2015-07-29 01:03:10 -04:00
// Aliases
try {
this . aliases = JSON . parse ( localStorage . ffz _aliases || '{}' ) ;
} catch ( err ) {
this . log ( "Error Loading Aliases: " + err ) ;
this . aliases = { } ;
}
2015-08-02 02:41:03 -04:00
2015-07-13 21:52:44 -04:00
// Chat Style
var s = this . _chat _style = document . createElement ( 'style' ) ;
s . id = "ffz-style-chat" ;
s . type = 'text/css' ;
2015-08-02 02:41:03 -04:00
document . head . appendChild ( s ) ;
2015-07-13 21:52:44 -04:00
// Initial calculation.
2016-03-23 19:28:22 -04:00
FFZ . settings _info . chat _font _size . on _update . call ( this , this . settings . chat _font _size ) ;
FFZ . settings _info . chat _font _family . on _update . call ( this , this . settings . chat _font _family ) ;
2015-07-18 21:10:27 -04:00
2015-08-02 02:41:03 -04:00
2015-02-10 01:34:23 -05:00
// Chat Enhancements
2016-10-20 16:41:04 -04:00
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 ) ;
2016-03-23 19:28:22 -04:00
2015-11-11 02:06:02 -05:00
this . toggle _style ( 'chat-padding' , ! this . has _bttv && this . settings . chat _padding ) ;
this . toggle _style ( 'chat-background' , ! this . has _bttv && this . settings . chat _rows ) ;
2015-08-02 02:41:03 -04:00
2015-11-11 02:06:02 -05:00
this . toggle _style ( 'chat-separator' , ! this . has _bttv && this . settings . chat _separators ) ;
this . toggle _style ( 'chat-separator-3d' , ! this . has _bttv && this . settings . chat _separators === 2 ) ;
this . toggle _style ( 'chat-separator-3d-inset' , ! this . has _bttv && this . settings . chat _separators === 3 ) ;
this . toggle _style ( 'chat-separator-wide' , ! this . has _bttv && this . settings . chat _separators === 4 ) ;
2015-08-02 02:41:03 -04:00
2016-05-20 17:30:34 -04:00
this . toggle _style ( 'chat-hc-text' , this . settings . high _contrast _chat [ 2 ] === '1' ) ;
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' ) ;
2015-02-10 01:34:23 -05:00
2016-12-19 21:33:45 -05:00
var f = this ;
2016-11-02 01:22:23 -04:00
this . update _views ( 'component:video/rechat/chat-message' , this . _modify _vod _line ) ;
2016-10-07 18:11:05 -04:00
this . update _views ( 'component:chat/message-line' , this . _modify _chat _subline ) ;
2016-12-19 21:33:45 -05:00
this . update _views ( 'component:chat/whisper-line' , function ( x ) { return f . _modify _chat _subline ( x , true ) } ) ;
2017-01-20 21:20:45 -05:00
this . update _views ( 'component:bits/pinned-cheers/top-cheer-line' , this . _modify _top _cheer _line ) ;
this . update _views ( 'component:bits/pinned-cheers/top-cheer' , this . _modify _top _cheer ) ;
2016-03-24 14:48:53 -04:00
2015-06-10 18:46:04 -04:00
// Store the capitalization of our own name.
var user = this . get _user ( ) ;
if ( user && user . name )
FFZ . capitalization [ user . login ] = [ user . name , Date . now ( ) ] ;
}
2015-07-29 01:03:10 -04:00
FFZ . prototype . save _aliases = function ( ) {
this . log ( "Saving " + Object . keys ( this . aliases ) . length + " aliases to local storage." ) ;
localStorage . ffz _aliases = JSON . stringify ( this . aliases ) ;
}
2017-01-20 21:20:45 -05:00
FFZ . prototype . _modify _top _cheer = function ( component ) {
var f = this ;
utils . ember _reopen _view ( component , {
ffz _init : function ( ) {
var PinnedCheers = utils . ember _lookup ( 'service:bits-pinned-cheers' ) ,
el = this . get ( 'element' ) ,
container = el && el . querySelector ( '.pinned-cheer__top-bar' ) ;
if ( ! PinnedCheers || ! container )
return ;
var btn _dismiss = utils . createElement ( 'a' , 'mod-icon html-tooltip pc-dismiss-local' , 'Dismiss' ) ,
mod _icons = utils . createElement ( 'div' , 'mod-icons' , btn _dismiss ) ;
btn _dismiss . title = 'Dismiss' ;
container . insertBefore ( mod _icons , container . firstElementChild ) ;
btn _dismiss . addEventListener ( 'click' , function ( ) {
PinnedCheers . dismissLocalMessage ( ) ;
} ) ;
}
} ) ;
}
FFZ . prototype . _modify _top _cheer _line = function ( component ) {
var f = this ;
component . reopen ( {
ffzRender : function ( ) {
var el = this . get ( 'element' ) ;
el . innerHTML = this . buildFromHTML ( ) + '<span class="colon">:</span> ' ;
}
} )
}
2016-03-23 19:28:22 -04:00
FFZ . prototype . _modify _chat _line = function ( component , is _vod ) {
2016-07-13 02:31:26 -04:00
var f = this ,
Layout = utils . ember _lookup ( 'service:layout' ) ,
2016-11-09 22:19:37 -05:00
Chat = utils . ember _lookup ( 'controller:chat' ) ,
PinnedCheers = utils . ember _lookup ( 'service:bits-pinned-cheers' ) ,
2016-09-30 13:09:03 -04:00
Settings = utils . ember _settings ( ) ;
2015-11-07 22:56:15 -05:00
2016-07-13 02:31:26 -04:00
component . reopen ( {
2016-08-09 20:45:28 -04:00
/ * t o k e n i z e d M e s s a g e : f u n c t i o n ( ) {
return [ { type : 'text' , text : 'hi' } ] ;
} . property ( 'msgObject.message' ) , * /
2016-06-02 20:04:40 -04:00
2016-10-12 16:42:43 -04:00
ffz _modified : true ,
2016-07-13 02:31:26 -04:00
ffzTokenizedMessage : function ( ) {
2015-11-07 22:56:15 -05:00
try {
return f . tokenize _chat _line ( this . get ( 'msgObject' ) ) ;
} catch ( err ) {
f . error ( "chat-line tokenizedMessage: " + err ) ;
2016-11-09 22:19:37 -05:00
return this . get ( 'tokenizedMessage' ) ;
2015-11-07 22:56:15 -05:00
}
2015-06-05 03:59:28 -04:00
} . property ( "msgObject.message" , "isChannelLinksDisabled" , "currentUserNick" , "msgObject.from" , "msgObject.tags.emotes" ) ,
2015-01-20 01:53:18 -05:00
2016-11-08 16:43:02 -05:00
lineChanged : Ember . observer ( "msgObject.deleted" , "isModeratorOrHigher" , "msgObject.ffz_old_messages" , "ffzTokenizedMessage" , "hasClickedFlaggedMessage" , function ( ) {
2016-07-13 02:31:26 -04:00
this . $ ( ".mod-icons" ) . replaceWith ( this . buildModIconsHTML ( ) ) ;
if ( this . get ( "msgObject.deleted" ) ) {
this . $ ( ".message" ) . replaceWith ( this . buildDeletedMessageHTML ( ) ) ;
} else
this . $ ( ".deleted,.message" ) . replaceWith ( this . buildMessageHTML ( ) ) ;
} ) ,
2015-08-02 02:41:03 -04:00
2016-07-13 02:31:26 -04:00
ffzUpdateBadges : function ( ) {
this . $ ( ".badges" ) . html ( f . render _badges ( f . get _line _badges ( this . get ( 'msgObject' ) ) ) ) ;
} ,
2016-06-05 22:12:54 -04:00
2017-01-20 21:20:45 -05:00
ffzPinnedParent : function ( ) {
var is _pinned _cheer = this . get ( 'msgObject.is_pinned_cheer' ) ;
return is _pinned _cheer === 2 ? this . get ( 'parentView.parentView.parentView.parentView.parentView' ) : this . get ( 'parentView' ) ;
} . property ( 'msgObject.is_pinned_cheer' ) ,
2016-07-13 02:31:26 -04:00
ffzUserLevel : function ( ) {
2015-07-29 01:03:10 -04:00
if ( this . get ( 'isStaff' ) )
return 5 ;
else if ( this . get ( 'isAdmin' ) )
return 4 ;
else if ( this . get ( 'isBroadcaster' ) )
return 3 ;
2015-10-17 18:05:44 -04:00
else if ( this . get ( 'isGlobalMod' ) )
2015-07-29 01:03:10 -04:00
return 2 ;
else if ( this . get ( 'isModerator' ) )
return 1 ;
return 0 ;
} . property ( 'msgObject.labels.[]' ) ,
2015-08-02 02:41:03 -04:00
2016-07-13 02:31:26 -04:00
buildModIconsHTML : function ( ) {
var user = this . get ( 'msgObject.from' ) ,
2016-11-09 22:19:37 -05:00
is _tb = this . get ( 'msgObject.twitchBotRejected' ) ,
2017-01-20 21:20:45 -05:00
is _pinned _cheer = this . get ( 'msgObject.is_pinned_cheer' ) ,
2016-11-09 22:19:37 -05:00
2017-01-20 21:20:45 -05:00
room _id = this . get ( 'msgObject.room' ) ,
2016-07-13 02:31:26 -04:00
room = f . rooms && f . rooms [ room _id ] ,
2015-08-02 02:41:03 -04:00
2016-07-13 02:31:26 -04:00
deleted = this . get ( 'msgObject.deleted' ) ,
2015-08-02 02:41:03 -04:00
2016-07-13 02:31:26 -04:00
recipient = this . get ( 'msgObject.to' ) ,
is _whisper = recipient && recipient . length ,
2015-08-02 02:41:03 -04:00
2016-07-13 02:31:26 -04:00
this _ul = this . get ( 'ffzUserLevel' ) ,
other _ul = room && room . room && room . room . get ( 'ffzUserLevel' ) || 0 ,
2015-05-17 19:02:57 -04:00
2016-12-19 21:33:45 -05:00
shouldnt _show = is _whisper || this _ul >= other _ul || ( f . settings . mod _buttons . length === 0 && ! is _tb ) ,
2016-07-13 02:31:26 -04:00
output ;
2015-08-02 02:41:03 -04:00
2016-11-09 22:19:37 -05:00
if ( ! is _pinned _cheer && shouldnt _show )
2016-07-13 02:31:26 -04:00
return '' ;
2015-07-31 17:44:20 -04:00
2016-10-20 16:41:04 -04:00
output = [ '<span class="mod-icons">' ] ;
2016-11-08 16:43:02 -05:00
if ( is _tb && ! this . get ( 'hasClickedFlaggedMessage' ) ) {
output . push ( '<a class="mod-icon html-tooltip tb-reject" title="Not Allowed' + TB _TOOLTIP + '">Not Allowed</a>' ) ;
output . push ( '<a class="mod-icon html-tooltip tb-allow" title="Allowed' + TB _TOOLTIP + '">Allowed</a>' ) ;
2016-10-20 16:41:04 -04:00
}
2015-02-24 00:33:29 -05:00
2016-11-09 22:19:37 -05:00
if ( is _pinned _cheer ) {
2017-01-20 21:20:45 -05:00
var parent = this . get ( 'ffzPinnedParent' ) ;
if ( parent && PinnedCheers && PinnedCheers . canDismissPinnedCheer ( parent . get ( 'userData.id' ) , parent . get ( 'isViewerModeratorOrHigher' ) ) )
2016-11-09 22:19:37 -05:00
output . push ( '<a class="mod-icon html-tooltip pc-dismiss" title="Dismiss for Everyone">Dismiss</a>' ) ;
2017-01-20 21:20:45 -05:00
if ( is _pinned _cheer !== 2 )
output . push ( '<a class="mod-icon html-tooltip pc-dismiss-local" title="Dismiss">Dismiss</a>' ) ;
2016-11-09 22:19:37 -05:00
}
if ( ! shouldnt _show )
for ( var i = 0 , l = f . settings . mod _buttons . length ; i < l ; i ++ ) {
var pair = f . settings . mod _buttons [ i ] ,
prefix = pair [ 0 ] , btn = pair [ 1 ] , had _label = pair [ 2 ] , is _emoji = pair [ 3 ] ,
cmd , tip ;
if ( is _emoji ) {
var setting = f . settings . parse _emoji ,
token = f . emoji _data [ is _emoji ] ,
url = null ;
if ( token ) {
if ( setting === 1 && token . tw )
url = token . tw _src ;
else if ( setting === 2 && token . noto )
url = token . noto _src ;
else if ( setting === 3 && token . one )
url = token . one _src ;
if ( url )
prefix = '<img class="mod-icon-emoji" src="' + utils . quote _attr ( url ) + '">' ;
}
2016-09-30 13:09:03 -04:00
}
2016-11-09 22:19:37 -05:00
if ( btn === false ) {
if ( deleted )
output . push ( '<a class="mod-icon html-tooltip unban" title="Unban User" href="#">Unban</a>' ) ;
else
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 . 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" ) {
cmd = utils . replace _cmd _variables ( btn , { name : user } , room && room . room , this . get ( 'msgObject' ) ) . replace ( /\s*<LINE>\s*/g , '\n' ) ;
tip = "Custom Command" + ( cmd . indexOf ( "\n" ) !== - 1 ? 's' : '' ) + '<br>' + utils . quote _san ( cmd ) . replace ( '\n' , '<br>' ) ;
} else {
cmd = "/timeout " + user + " " + btn ;
tip = "Timeout User (" + utils . duration _string ( btn ) + ")" ;
}
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>' ) ;
2016-07-13 02:31:26 -04:00
}
}
2016-10-20 16:41:04 -04:00
return output . join ( '' ) + '</span>' ;
2016-07-13 02:31:26 -04:00
} ,
2015-10-17 18:05:44 -04:00
2016-09-09 17:34:20 -04:00
buildFromHTML : function ( is _recipient ) {
var username = this . get ( is _recipient ? 'msgObject.to' : 'msgObject.from' ) ,
raw _display = this . get ( is _recipient ? 'msgObject.tags.recipient-display-name' : 'msgObject.tags.display-name' ) ,
alias = f . aliases [ username ] ,
2015-10-17 18:05:44 -04:00
2016-09-09 17:34:20 -04:00
raw _color = this . get ( is _recipient ? 'msgObject.toColor' : 'msgObject.color' ) ,
2015-10-17 18:05:44 -04:00
2016-09-30 13:09:03 -04:00
is _dark = ( Layout && Layout . get ( 'isTheatreMode' ) ) || ( is _replay ? f . settings . dark _twitch : ( Settings && Settings . get ( 'darkMode' ) ) ) ,
2016-07-13 02:31:26 -04:00
is _replay = this . get ( 'ffz_is_replay' ) ,
2016-03-23 19:28:22 -04:00
2016-07-13 02:31:26 -04:00
colors = raw _color && f . _handle _color ( raw _color ) ,
2016-09-09 17:34:20 -04:00
style = colors ? 'color:' + ( is _dark ? colors [ 1 ] : colors [ 0 ] ) : '' ,
colored = colors ? ' has-color' + ( is _replay ? ' replay-color' : '' ) : '' ,
2016-03-23 19:28:22 -04:00
2016-09-09 17:34:20 -04:00
results = f . format _display _name ( raw _display , username ) ;
2016-03-23 19:28:22 -04:00
2016-09-09 17:34:20 -04:00
return '<span class="' + ( is _recipient ? 'to' : 'from' ) + ( alias ? ' ffz-alias' : '' ) + ( results [ 1 ] ? ' html-tooltip' : '' ) + colored + '" style="' + style + ( colors ? '" data-color="' + raw _color : '' ) + ( results [ 1 ] ? '" title="' + utils . quote _attr ( results [ 1 ] ) : '' ) + '">' + results [ 0 ] + '</span>' ;
} ,
2016-10-04 14:10:59 -04:00
buildSystemMessageHTML : function ( ) {
return this . get ( 'hasSystemMsg' ) ?
'<div class="system-msg">' + utils . sanitize ( this . get ( 'systemMsg' ) ) + '</div>' :
'' ;
} ,
2016-03-23 19:28:22 -04:00
2016-10-05 23:07:10 -04:00
buildBadgesHTML : function ( ) {
2016-11-09 22:19:37 -05:00
if ( ! this . get ( 'msgObject.room' ) && this . get ( 'msgObject.payday_timestamp' ) )
this . set ( 'msgObject.room' , Chat . get ( 'currentRoom.id' ) ) ;
2016-10-05 23:07:10 -04:00
return '<span class="badges">' + f . render _badges ( f . get _line _badges ( this . get ( 'msgObject' ) ) ) + '</span>' ;
} ,
2016-10-04 14:10:59 -04:00
buildSenderHTML : function ( ) {
var output = '' ;
2016-03-23 19:28:22 -04:00
2016-07-13 02:31:26 -04:00
// Timestamp
2016-09-30 13:09:03 -04:00
var timestamp = this . get ( 'timestamp' ) ;
if ( timestamp )
output += '<span class="timestamp">' + timestamp + '</span> ' ;
2016-06-22 14:23:03 -04:00
2016-07-13 02:31:26 -04:00
// Moderator Actions
output += this . buildModIconsHTML ( ) ;
2016-03-23 19:28:22 -04:00
2016-07-13 02:31:26 -04:00
// Badges
2016-10-05 23:07:10 -04:00
output += this . buildBadgesHTML ( ) ;
2016-03-23 19:28:22 -04:00
2016-09-09 17:34:20 -04:00
// From!
output += this . buildFromHTML ( ) ;
2016-03-23 19:28:22 -04:00
2016-09-09 17:34:20 -04:00
if ( this . get ( 'msgObject.to' ) ) {
output += "<svg class='svg-whisper-arrow' height='10px' version='1.1' width='16px'><polyline points='6 2, 10 6, 6 10, 6 2' /></svg>" ;
output += this . buildFromHTML ( true ) ;
2016-07-13 02:31:26 -04:00
}
2016-03-23 19:28:22 -04:00
2016-09-09 17:34:20 -04:00
return output + '<span class="colon">:</span> ' ;
2016-07-13 02:31:26 -04:00
} ,
2016-03-23 19:28:22 -04:00
2016-07-13 02:31:26 -04:00
buildDeletedMessageHTML : function ( ) {
return '<span class="deleted"><a class="undelete" href=#"><message deleted></a></span>' ;
} ,
2016-03-23 19:28:22 -04:00
2016-07-13 02:31:26 -04:00
buildMessageHTML : function ( ) {
var output ,
recipient = this . get ( 'msgObject.to' ) ,
is _whisper = recipient && recipient . length ;
2016-03-23 19:28:22 -04:00
2016-07-13 02:31:26 -04:00
if ( this . get ( 'msgObject.style' ) === 'action' ) {
var raw _color = this . get ( 'msgObject.color' ) ,
colors = raw _color && f . _handle _color ( raw _color ) ,
is _replay = this . get ( 'ffz_is_replay' ) ,
2016-09-30 13:09:03 -04:00
is _dark = ( Layout && Layout . get ( 'isTheatreMode' ) ) || ( is _replay ? f . settings . dark _twitch : ( Settings && Settings . get ( 'darkMode' ) ) ) ;
2016-03-23 19:28:22 -04:00
2016-07-13 02:31:26 -04:00
if ( raw _color )
output = '<span class="message has-color' + ( is _replay ? ' replay-color' : '' ) + '" style="color:' + ( is _dark ? colors [ 1 ] : colors [ 0 ] ) + '" data-color="' + raw _color + '">' ;
else
output = '<span class="message">' ;
} else
output = '<span class="message">' ;
2016-03-23 19:28:22 -04:00
2016-09-30 13:09:03 -04:00
var body = f . render _tokens ( this . get ( 'ffzTokenizedMessage' ) , true , is _whisper && f . settings . filter _whispered _links && this . get ( "ffzUserLevel" ) < 4 , this . get ( 'isBitsEnabled' ) ) ;
if ( this . get ( 'msgObject.ffz_line_returns' ) )
body = body . replace ( /\n/g , '<br>' ) ;
output += body ;
2016-03-24 14:48:53 -04:00
2016-10-05 01:31:10 -04:00
/ * v a r o l d _ m e s s a g e s = t h i s . g e t ( ' m s g O b j e c t . f f z _ o l d _ m e s s a g e s ' ) ;
2016-07-13 02:31:26 -04:00
if ( old _messages && old _messages . length )
2016-10-05 01:31:10 -04:00
output += '<div class="button primary float-right ffz-old-messages">Show ' + utils . number _commas ( old _messages . length ) + ' Old</div>' ; * /
2016-03-24 14:48:53 -04:00
2016-07-13 02:31:26 -04:00
return output + '</span>' ;
} ,
2016-03-23 19:28:22 -04:00
2016-07-13 02:31:26 -04:00
ffzRender : function ( ) {
var el = this . get ( 'element' ) ,
2016-10-04 14:10:59 -04:00
output = '<div class="indicator"></div>' ;
2016-07-13 02:06:50 -04:00
2016-10-04 14:10:59 -04:00
output += this . buildSystemMessageHTML ( ) ;
if ( this . get ( 'ffzShouldRenderMessageBody' ) ) {
output += this . buildSenderHTML ( ) ;
output += this . get ( 'msgObject.deleted' ) ?
2016-10-04 15:06:45 -04:00
this . buildDeletedMessageHTML ( ) : this . buildMessageHTML ( ) ;
2016-10-04 14:10:59 -04:00
}
2016-03-23 19:28:22 -04:00
2016-07-13 02:31:26 -04:00
el . innerHTML = output ;
} ,
2016-10-05 01:31:10 -04:00
systemMsg : function ( ) {
return this . get ( 'msgObject.tags.system-msg' )
} . property ( 'msgObject.tags.system-msg' ) ,
2016-07-13 02:31:26 -04:00
ffzShouldRenderMessageBody : function ( ) {
2016-10-05 01:31:10 -04:00
return ! this . get ( 'hasSystemMsg' ) || this . get ( 'hasMessageBody' ) ;
2016-07-13 02:31:26 -04:00
} . property ( 'hasSystemMsg' , 'hasMessageBody' ) ,
2016-10-04 14:10:59 -04:00
hasSystemMsg : function ( ) {
var msg = this . get ( 'msgObject.tags.system-msg' ) ;
return msg && msg . length > 0 ;
2016-10-04 12:06:49 -04:00
} . property ( 'msgObject.tags.system-msg' ) ,
2016-10-04 14:10:59 -04:00
shouldRenderMessageBody : function ( ) {
return false ;
} . property ( ) ,
2016-07-13 02:31:26 -04:00
2017-01-27 23:28:30 -05:00
ffzIsSpecialMessage : function ( ) {
return this . get ( 'hasSystemMsg' ) || this . get ( 'msgObject.from' ) === 'twitchnotify' ;
} . property ( 'hasSystemMsg' , 'msgObject.from' ) ,
2016-07-13 02:31:26 -04:00
ffzWasDeleted : function ( ) {
return f . settings . prevent _clear && this . get ( "msgObject.ffz_deleted" )
} . property ( "msgObject.ffz_deleted" ) ,
ffzHasOldMessages : function ( ) {
var old _messages = this . get ( "msgObject.ffz_old_messages" ) ;
return old _messages && old _messages . length ;
} . property ( "msgObject.ffz_old_messages" )
} ) ;
2016-03-24 23:04:11 -04:00
}
2016-12-19 21:33:45 -05:00
FFZ . prototype . _modify _chat _subline = function ( component , is _whisper ) {
2016-11-09 22:19:37 -05:00
var f = this ,
PinnedCheers = utils . ember _lookup ( 'service:bits-pinned-cheers' ) ;
2016-03-24 23:04:11 -04:00
2016-07-13 02:31:26 -04:00
this . _modify _chat _line ( component ) ;
2016-03-24 23:04:11 -04:00
2016-07-13 02:31:26 -04:00
component . reopen ( {
2016-12-19 21:33:45 -05:00
classNameBindings : is _whisper ?
[ ':whisper-line' , ':chat-line' , 'isReceivedWhisper:whisper-incoming:whisper-outgoing' ] :
2017-01-27 23:28:30 -05:00
[ "msgObject.isModerationMessage:moderation-message" , "msgObject.ffz_has_mention:ffz-mentioned" , "ffzIsSpecialMessage:special-message" , "ffzWasDeleted:ffz-deleted" , "ffzHasOldMessages:clearfix" , "ffzHasOldMessages:ffz-has-deleted" ] ,
2016-12-19 21:33:45 -05:00
attributeBindings : is _whisper ?
[ 'msgObject.nonce:data-nonce' , 'msgObject.tags.id:data-id' , 'msgObject.from:data-sender' ] :
[ "msgObject.tags.id:data-id" , "msgObject.room:data-room" , "msgObject.from:data-sender" , "msgObject.deleted:data-deleted" ] ,
2016-03-24 23:04:11 -04:00
2016-07-13 02:31:26 -04:00
didInsertElement : function ( ) {
2016-11-09 22:19:37 -05:00
if ( this . get ( 'msgObject' ) ) {
this . set ( 'msgObject._line' , this ) ;
this . ffzRender ( ) ;
}
2016-07-13 02:31:26 -04:00
} ,
2016-05-13 23:56:59 -04:00
2016-10-11 21:41:35 -04:00
ffz _update : function ( ) {
2016-11-09 22:19:37 -05:00
if ( this . get ( 'msgObject' ) ) {
this . set ( 'msgObject._line' , this ) ;
this . ffzRender ( ) ;
}
2016-10-11 21:41:35 -04:00
} ,
2016-07-13 02:31:26 -04:00
willClearRender : function ( ) {
2016-11-09 22:19:37 -05:00
if ( this . get ( 'msgObject' ) )
this . set ( 'msgObject._line' , null ) ;
2016-07-13 02:31:26 -04:00
} ,
2016-05-13 23:56:59 -04:00
2016-07-13 02:31:26 -04:00
//didUpdate: function() { this.ffzRender(); },
2016-03-23 19:28:22 -04:00
2016-09-30 13:09:03 -04:00
ffzBuildModMenu : function ( el ) {
var t = this ,
setting = f . settings . mod _button _context ,
cl = el . classList ,
from = this . get ( "msgObject.from" ) ,
cmd = el . getAttribute ( 'data-cmd' ) ,
trail = '' ;
if ( ! cmd && cl . contains ( 'ban' ) )
cmd = "/ban " + from ;
else if ( ! cmd && cl . contains ( 'timeout' ) )
cmd = "/timeout " + from + " 600" ;
else if ( ! cmd || cl . contains ( 'unban' ) )
return ; // We can't send mod reasons for unbans and we need a command.
else {
var lines = cmd . split ( "\n" ) ,
first _line = lines . shift ( ) ,
trail = lines . length ? "\n" + lines . join ( "\n" ) : "" ,
match = BAN _SPLIT . exec ( first _line ) ;
// If the line didn't match this, it's invalid.
if ( ! match )
return ;
2016-12-14 02:40:18 -05:00
cmd = match [ 1 ] ? '/ban ' + match [ 1 ] :
match [ 2 ] ? '/timeout ' + match [ 2 ] + ' ' + ( match [ 3 ] || '600' ) :
'/timeout_message ' + match [ 4 ] + ' ' + match [ 5 ] + ' ' + ( match [ 6 ] || '600' ) ;
if ( match [ 7 ] )
trail = match [ 7 ] = trail ;
2016-09-30 13:09:03 -04:00
}
var bl = utils . createElement ( 'ul' , 'balloon__list' ) ,
balloon = utils . createElement ( 'div' , 'balloon balloon--dropmenu ffz-mod-balloon' , bl ) ,
bc = utils . createElement ( 'div' , 'balloon-wrapper' , balloon ) ,
has _items = false ,
is _ban = cmd . substr ( 1 , 4 ) === 'ban ' ,
2016-12-14 02:40:18 -05:00
is _timeout = cmd . substr ( 1 , 8 ) === 'timeout ' ,
2016-09-30 13:09:03 -04:00
title = utils . createElement ( 'li' , 'ffz-title' ) ;
2016-12-14 02:40:18 -05:00
title . textContent = ( is _ban ? 'Ban ' : ( is _timeout ? 'Timeout ' : 'Remove Message and Timeout ' ) ) + from + ' for...' ;
2016-09-30 13:09:03 -04:00
bl . appendChild ( title ) ;
bl . appendChild ( utils . createElement ( 'li' , 'balloon__stroke' ) ) ;
var btn _click = function ( reason , e ) {
if ( e . button !== 0 )
return ;
var room _id = t . get ( 'msgObject.room' ) ,
room = room _id && f . rooms [ room _id ] && f . rooms [ room _id ] . room ;
if ( room ) {
cmd = cmd + ' ' + reason + ( trail ? ( trail [ 0 ] === '\n' ? '' : ' ' ) + trail : '' ) ;
var lines = cmd . split ( "\n" ) ;
for ( var i = 0 ; i < lines . length ; i ++ )
room . send ( lines [ i ] , true ) ;
if ( cl . contains ( 'is-timeout' ) )
room . clearMessages ( from , null , true ) ;
}
f . close _popup ( ) ;
e . stopImmediatePropagation ( ) ;
e . preventDefault ( ) ;
return false ;
} ;
if ( setting & 1 )
for ( var i = 0 ; i < f . settings . mod _card _reasons . length ; i ++ ) {
var btn = utils . createElement ( 'div' , 'balloon__link ellipsis' ) ,
line = utils . createElement ( 'li' , '' , btn ) ,
reason = f . settings . mod _card _reasons [ i ] ;
btn . textContent = btn . title = reason ;
btn . addEventListener ( 'click' , btn _click . bind ( btn , reason ) ) ;
bl . appendChild ( line ) ;
has _items = true ;
}
if ( setting & 2 ) {
var room _id = t . get ( 'msgObject.room' ) ,
room = room _id && f . rooms [ room _id ] && f . rooms [ room _id ] . room ,
rules = room && room . get ( 'roomProperties.chat_rules' ) ;
if ( rules && rules . length ) {
if ( has _items )
bl . appendChild ( utils . createElement ( 'li' , 'balloon__stroke' ) ) ;
for ( var i = 0 ; i < rules . length ; i ++ ) {
var btn = utils . createElement ( 'div' , 'balloon__link ellipsis' ) ,
line = utils . createElement ( 'li' , '' , btn ) ,
reason = rules [ i ] ;
btn . textContent = btn . title = reason ;
btn . addEventListener ( 'click' , btn _click . bind ( btn , reason ) ) ;
bl . appendChild ( line ) ;
has _items = true ;
}
}
}
if ( ! has _items )
return false ;
var rect = el . getBoundingClientRect ( ) ,
is _bottom = rect . top > ( window . innerHeight / 2 ) ,
position = [ rect . left , ( is _bottom ? rect . top : rect . bottom ) ] ;
balloon . classList . add ( 'balloon--' + ( is _bottom ? 'up' : 'down' ) ) ;
f . show _popup ( bc , position , utils . find _parent ( this . get ( 'element' ) , 'chat-messages' ) ) ;
return true ;
} ,
contextMenu : function ( e ) {
if ( ! e . target )
return ;
var cl = e . target . classList ,
from = this . get ( "msgObject.from" ) ,
abort = false ;
// We only want to show a context menu for mod icons right now.
if ( cl . contains ( 'mod-icon' ) )
abort |= this . ffzBuildModMenu ( e . target ) ;
if ( abort ) {
e . stopImmediatePropagation ( ) ;
e . preventDefault ( ) ;
}
} ,
2016-07-13 02:31:26 -04:00
click : function ( e ) {
if ( ! e . target )
return ;
2016-03-23 19:28:22 -04:00
2016-07-13 02:31:26 -04:00
var cl = e . target . classList ,
from = this . get ( "msgObject.from" ) ;
2016-03-23 19:28:22 -04:00
2016-10-05 01:31:10 -04:00
/ * i f ( c l . c o n t a i n s ( ' f f z - o l d - m e s s a g e s ' ) )
return f . _show _deleted ( this . get ( 'msgObject.room' ) ) ; * /
2016-03-23 19:28:22 -04:00
2016-10-05 01:31:10 -04:00
if ( cl . contains ( 'deleted-word' ) ) {
2016-07-13 02:31:26 -04:00
jQuery ( e . target ) . trigger ( 'mouseout' ) ;
e . target . outerHTML = e . target . getAttribute ( 'data-text' ) ;
2016-03-23 19:28:22 -04:00
2016-07-13 02:31:26 -04:00
} else if ( cl . contains ( 'deleted-link' ) )
return f . _deleted _link _click . call ( e . target , e ) ;
2016-03-23 19:28:22 -04:00
2016-07-13 02:31:26 -04:00
else if ( cl . contains ( 'mod-icon' ) ) {
2016-11-20 13:43:12 -05:00
2016-07-13 02:31:26 -04:00
jQuery ( e . target ) . trigger ( 'mouseout' ) ;
e . preventDefault ( ) ;
2016-03-23 19:28:22 -04:00
2016-11-09 22:19:37 -05:00
if ( cl . contains ( 'pc-dismiss-local' ) )
PinnedCheers . dismissLocalMessage ( ) ;
else if ( cl . contains ( 'pc-dismiss' ) )
2017-01-20 21:20:45 -05:00
PinnedCheers . dismissMessage (
this . get ( 'ffzPinnedParent.userData.id' ) ,
this . get ( 'msgObject.is_pinned_cheer' ) === '2' ? 'top' : 'recent'
) ;
2016-11-09 22:19:37 -05:00
else if ( cl . contains ( 'tb-reject' ) )
2016-11-08 16:43:02 -05:00
this . actions . clickedTwitchBotResponse . call ( this , this . get ( 'msgObject.tags.id' ) , 'no' ) ;
2016-10-20 16:41:04 -04:00
else if ( cl . contains ( 'tb-allow' ) )
2016-11-08 16:43:02 -05:00
this . actions . clickedTwitchBotResponse . call ( this , this . get ( 'msgObject.tags.id' ) , 'yes' ) ;
2016-10-20 16:41:04 -04:00
2016-11-20 13:43:12 -05:00
else if ( ! from )
return ;
2016-10-20 16:41:04 -04:00
else if ( cl . contains ( 'ban' ) )
2016-09-30 13:09:03 -04:00
this . sendAction ( "banUser" , { user : from } ) ;
else if ( cl . contains ( 'unban' ) )
this . sendAction ( "unbanUser" , { user : from } ) ;
else if ( cl . contains ( 'timeout' ) )
this . sendAction ( "timeoutUser" , { user : from } ) ;
else if ( cl . contains ( 'custom' ) ) {
2016-03-23 19:28:22 -04:00
var room _id = this . get ( 'msgObject.room' ) ,
room = room _id && f . rooms [ room _id ] && f . rooms [ room _id ] . room ,
cmd = e . target . getAttribute ( 'data-cmd' ) ;
if ( room ) {
var lines = cmd . split ( "\n" ) ;
for ( var i = 0 ; i < lines . length ; i ++ )
room . send ( lines [ i ] , true ) ;
if ( cl . contains ( 'is-timeout' ) )
2016-05-13 23:56:59 -04:00
room . clearMessages ( from , null , true ) ;
2015-10-17 18:05:44 -04:00
}
2016-03-23 19:28:22 -04:00
return ;
2015-08-02 02:41:03 -04:00
2016-09-30 13:09:03 -04:00
}
2015-08-02 02:41:03 -04:00
2016-07-13 02:31:26 -04:00
} else if ( cl . contains ( 'badge' ) ) {
2016-11-19 01:59:03 -05:00
if ( cl . contains ( 'click_action' ) ) {
var badge = f . badges && f . badges [ e . target . getAttribute ( 'data-badge-id' ) ] ;
if ( badge . click _action )
badge . click _action . call ( f , this . get ( 'msgObject' ) , e ) ;
} else if ( cl . contains ( 'click_url' ) )
2016-07-13 02:31:26 -04:00
window . open ( e . target . getAttribute ( 'data-url' ) , "_blank" ) ;
2016-06-05 22:12:54 -04:00
2016-07-13 02:31:26 -04:00
else if ( cl . contains ( 'turbo' ) )
window . open ( "/products/turbo?ref=chat_badge" , "_blank" ) ;
2015-07-04 17:06:36 -04:00
2016-07-13 02:31:26 -04:00
else if ( cl . contains ( 'subscriber' ) )
this . sendAction ( "clickSubscriber" ) ;
2015-08-02 02:41:03 -04:00
2016-07-13 02:31:26 -04:00
} else if ( f . _click _emote ( e . target , e ) )
return ;
2015-11-19 02:45:56 -05:00
2016-11-28 17:00:27 -05:00
else if ( ( f . settings . clickable _mentions && cl . contains ( 'user-token' ) ) || cl . contains ( 'from' ) || cl . contains ( 'to' ) || e . target . parentElement . classList . contains ( 'from' ) || e . target . parentElement . classList . contains ( 'to' ) ) {
var target = cl . contains ( 'user-token' ) ?
2016-10-14 20:43:34 -04:00
e . target . getAttribute ( 'data-user' ) :
( cl . contains ( 'from' ) || e . target . parentElement . classList . contains ( 'from' ) ) ?
from :
this . get ( 'msgObject.to' ) ;
2015-02-24 00:33:29 -05:00
2016-11-20 13:43:12 -05:00
if ( ! target )
return ;
2016-09-09 17:34:20 -04:00
var n = this . get ( 'element' ) ,
bounds = n && n . getBoundingClientRect ( ) || document . body . getBoundingClientRect ( ) ,
x = 0 , right ;
if ( bounds . left > 400 )
right = bounds . left - 40 ;
this . sendAction ( "showModOverlay" , {
left : bounds . left ,
right : right ,
top : bounds . top + bounds . height ,
real _top : bounds . top ,
2016-10-14 20:43:34 -04:00
sender : target
2016-09-09 17:34:20 -04:00
} ) ;
2016-10-14 20:43:34 -04:00
} else if ( cl . contains ( 'undelete' ) ) {
2016-07-13 02:31:26 -04:00
e . preventDefault ( ) ;
this . set ( "msgObject.deleted" , false ) ;
}
}
} ) ;
2016-03-25 18:32:35 -04:00
2016-07-13 02:31:26 -04:00
try {
component . create ( ) . destroy ( )
} catch ( err ) { }
2016-03-23 19:28:22 -04:00
}
2015-02-24 00:33:29 -05:00
2015-11-19 02:45:56 -05:00
2016-03-23 19:28:22 -04:00
FFZ . prototype . _modify _vod _line = function ( component ) {
2016-07-13 02:31:26 -04:00
var f = this ;
// We need to override a few things.
this . _modify _chat _line ( component , true ) ;
2016-03-23 19:28:22 -04:00
2016-07-13 02:31:26 -04:00
component . reopen ( {
ffz _is _replay : true ,
2016-03-23 19:28:22 -04:00
2016-07-13 02:31:26 -04:00
/ * l i n e C h a n g e d : E m b e r . o b s e r v e r ( " m s g O b j e c t . d e l e t e d " , " i s M o d e r a t o r O r H i g h e r " , f u n c t i o n ( ) {
this . $ ( ".mod-icons" ) . replaceWith ( this . buildModIconsHTML ( ) ) ;
if ( this . get ( "msgObject.deleted" ) )
this . $ ( ".message" ) . replaceWith ( this . buildMessageHTML ( ) ) ;
else
this . $ ( ".deleted" ) . replaceWith ( this . buildMessageHTML ( ) ) ;
} ) , * /
2016-03-23 19:28:22 -04:00
2016-07-13 02:31:26 -04:00
classNameBindings : [ "msgObject.ffz_has_mention:ffz-mentioned" ] ,
attributeBindings : [ "msgObject.room:data-room" , "msgObject.from:data-sender" , "msgObject.deleted:data-deleted" ] ,
2016-03-24 23:04:11 -04:00
2016-07-13 02:31:26 -04:00
tokenizedMessage : function ( ) {
return [ ] ;
} . property ( 'msgObject.message' ) ,
2016-06-02 20:04:40 -04:00
2016-07-13 02:31:26 -04:00
ffzTokenizedMessage : function ( ) {
2016-03-24 15:30:43 -04:00
try {
2016-07-13 02:31:26 -04:00
return f . tokenize _vod _line ( this . get ( 'msgObject' ) , ! ( this . get ( 'enableLinkification' ) || this . get ( 'isModeratorOrHigher' ) ) ) ;
2016-03-24 15:30:43 -04:00
} catch ( err ) {
f . error ( "vod-chat-line tokenizedMessage: " + err ) ;
return this . _super ( ) ;
}
} . property ( "msgObject.message" , "currentUserNick" , "msgObject.from" , "msgObject.tags.emotes" ) ,
2016-07-13 02:31:26 -04:00
buildHorizontalLineHTML : function ( ) {
return '<div class="horizontal-line"><span>' + this . get ( 'msgObject.timestamp' ) + '</span></div>' ;
} ,
buildModIconsHTML : function ( ) {
if ( ! this . get ( "isViewerModeratorOrHigher" ) || this . get ( "isModeratorOrHigher" ) )
return "" ;
return '<span class="mod-icons">' +
( this . get ( 'msgObject.deleted' ) ?
'<em class="mod-icon unban"></em>' :
'<a class="mod-icon html-tooltip delete" title="Delete Message" href="#">Delete</a>' ) + '</span>' ;
} ,
buildDeletedMesageHTML : function ( ) {
return '<span clas="deleted"><message deleted></span>' ;
} ,
//didUpdate: function() { this.ffzRender() },
didInsertElement : function ( ) { this . ffzRender ( ) } ,
ffzRender : function ( ) {
var el = this . get ( 'element' ) , output ;
if ( this . get ( 'msgObject.isHorizontalLine' ) )
output = this . buildHorizontalLineHTML ( ) ;
else {
output = this . buildSenderHTML ( ) ;
if ( this . get ( 'msgObject.deleted' ) )
output += this . buildDeletedMessageHTML ( )
else
output += this . buildMessageHTML ( ) ;
}
el . innerHTML = output ;
} ,
click : function ( e ) {
var cl = e . target . classList ;
if ( cl . contains ( 'badge' ) ) {
if ( cl . contains ( 'click_url' ) )
window . open ( e . target . getAttribute ( 'data-url' ) , "_blank" ) ;
else if ( cl . contains ( 'turbo' ) )
window . open ( "/products/turbo?ref=chat_badge" , "_blank" ) ;
else if ( cl . contains ( 'subscriber' ) )
this . sendAction ( "clickSubscriber" ) ;
} else if ( cl . contains ( 'delete' ) ) {
e . preventDefault ( ) ;
this . sendAction ( "timeoutUser" , this . get ( "msgObject.id" ) ) ;
}
}
} ) ;
try {
component . create ( ) . destroy ( )
} catch ( err ) { }
2016-03-23 19:28:22 -04:00
}
2015-08-02 02:41:03 -04:00
2015-01-20 01:53:18 -05:00
// ---------------------
// Capitalization
// ---------------------
FFZ . capitalization = { } ;
FFZ . _cap _fetching = 0 ;
2016-05-06 02:23:12 -04:00
FFZ . _cap _waiting = { } ;
2015-01-20 01:53:18 -05:00
FFZ . get _capitalization = function ( name , callback ) {
2015-02-08 02:59:20 -05:00
if ( ! name )
return name ;
2015-01-20 01:53:18 -05:00
name = name . toLowerCase ( ) ;
if ( name == "jtv" || name == "twitchnotify" )
return name ;
var old _data = FFZ . capitalization [ name ] ;
if ( old _data ) {
if ( Date . now ( ) - old _data [ 1 ] < 3600000 )
return old _data [ 0 ] ;
}
2016-07-13 02:31:26 -04:00
if ( FFZ . _cap _waiting [ name ] )
FFZ . _cap _waiting [ name ] . push ( callback ) ;
2016-05-06 02:23:12 -04:00
else if ( FFZ . _cap _fetching < 25 ) {
2015-01-20 01:53:18 -05:00
FFZ . _cap _fetching ++ ;
2016-07-13 02:31:26 -04:00
FFZ . _cap _waiting [ name ] = [ callback ] ;
2016-05-06 02:23:12 -04:00
2016-07-13 02:31:26 -04:00
FFZ . get ( ) . ws _send ( "get_display_name" , name , function ( success , data ) {
2016-05-06 02:23:12 -04:00
var cap _name = success ? data : name ,
2016-07-13 02:31:26 -04:00
waiting = FFZ . _cap _waiting [ name ] ;
2016-05-06 02:23:12 -04:00
2015-02-24 00:33:29 -05:00
FFZ . capitalization [ name ] = [ cap _name , Date . now ( ) ] ;
FFZ . _cap _fetching -- ;
2016-07-13 02:31:26 -04:00
FFZ . _cap _waiting [ name ] = false ;
2016-05-06 02:23:12 -04:00
2016-07-13 02:31:26 -04:00
for ( var i = 0 ; i < waiting . length ; i ++ )
try {
typeof waiting [ i ] === "function" && waiting [ i ] ( cap _name ) ;
} catch ( err ) { }
2015-02-24 00:33:29 -05:00
} ) ;
2015-01-20 01:53:18 -05:00
}
return old _data ? old _data [ 0 ] : name ;
}
2015-02-24 00:33:29 -05:00
// ---------------------
// Banned Words
// ---------------------
FFZ . prototype . _remove _banned = function ( tokens ) {
2016-03-23 19:28:22 -04:00
var banned _words = this . settings . banned _words ;
if ( ! banned _words || ! banned _words . length )
2015-02-24 00:33:29 -05:00
return tokens ;
if ( typeof tokens == "string" )
tokens = [ tokens ] ;
var regex = FFZ . _words _to _regex ( banned _words ) ,
new _tokens = [ ] ;
2015-08-21 19:00:48 -04:00
for ( var i = 0 , l = tokens . length ; i < l ; i ++ ) {
2015-02-24 00:33:29 -05:00
var token = tokens [ i ] ;
2016-07-13 02:31:26 -04:00
if ( typeof token === "string" )
token = { type : "text" , text : token } ;
if ( token . type === "text" && regex . test ( token . text ) ) {
token = token . text . replace ( regex , function ( all , prefix , match ) {
if ( prefix . length )
new _tokens . push ( { type : "text" , text : prefix } ) ;
new _tokens . push ( {
type : "deleted" ,
length : match . length ,
text : match
} ) ;
return "" ;
} ) ;
if ( token )
new _tokens . push ( { type : "text" , text : token } ) ;
} else if ( token . type === "emoticon" && regex . test ( token . altText ) ) {
token = token . altText . replace ( regex , function ( all , prefix , match ) {
if ( prefix . length )
new _tokens . push ( { type : "text" , text : prefix } ) ;
new _tokens . push ( {
type : "deleted" ,
length : match . length ,
text : match
} ) ;
return "" ;
} ) ;
if ( token )
new _tokens . push ( { type : "text" , text : token } ) ;
} else if ( token . type === "link" && regex . test ( token . text ) )
new _tokens . push ( {
type : "link" ,
isDeleted : true ,
isMailTo : token . isMailTo ,
isLong : false ,
length : token . text . length ,
censoredLink : token . text . replace ( regex , "$1***" ) ,
link : token . link ,
text : token . text
} ) ;
else
new _tokens . push ( token ) ;
2015-02-24 00:33:29 -05:00
}
return new _tokens ;
2015-01-20 20:25:26 -05:00
}
2015-01-20 01:53:18 -05:00
// ---------------------
// Emoticon Replacement
// ---------------------
2015-06-05 03:59:28 -04:00
FFZ . prototype . _emoticonize = function ( component , tokens ) {
2015-06-10 18:46:04 -04:00
var room _id = component . get ( "msgObject.room" ) ,
2015-06-05 03:59:28 -04:00
user _id = component . get ( "msgObject.from" ) ;
2015-01-20 01:53:18 -05:00
2015-06-05 03:59:28 -04:00
return this . tokenize _emotes ( user _id , room _id , tokens ) ;
2015-01-12 17:58:07 -05:00
}