mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-06-29 23:58:31 +00:00
3.5.16. Made hiding of shortened links an option. Added option to disable all FFZ notifications. Fixed deleted links from mods when links are disabled.
This commit is contained in:
parent
56392cd879
commit
3238fbcd68
10 changed files with 230 additions and 66 deletions
|
@ -17,8 +17,9 @@ FFZ.basic_settings.delayed_chat = {
|
|||
},
|
||||
|
||||
category: "Chat",
|
||||
no_bttv: true,
|
||||
|
||||
name: "Delayed Chat",
|
||||
name: "Delay and Filter Chat",
|
||||
help: "Delay the appearance of chat messages to allow time for moderation and completely hide removed messages.",
|
||||
|
||||
get: function() {
|
||||
|
@ -89,6 +90,8 @@ FFZ.settings_info.chat_delay = {
|
|||
value: 0,
|
||||
|
||||
category: "Chat Appearance",
|
||||
no_bttv: true,
|
||||
|
||||
name: "Artificial Chat Delay",
|
||||
help: "Delay the appearance of chat messages to allow for moderation before you see them.",
|
||||
|
||||
|
@ -156,6 +159,8 @@ FFZ.settings_info.remove_bot_ban_notices = {
|
|||
type: "boolean",
|
||||
value: false,
|
||||
|
||||
no_bttv: true,
|
||||
|
||||
category: "Chat Filtering",
|
||||
name: "Remove Bot Ban Notices",
|
||||
help: "Remove messages from bots announcing who was banned for what reason and for how long.",
|
||||
|
|
|
@ -134,6 +134,18 @@ FFZ.settings_info.hosted_sub_notices = {
|
|||
};
|
||||
|
||||
|
||||
FFZ.settings_info.filter_bad_shorteners = {
|
||||
type: "boolean",
|
||||
value: true,
|
||||
|
||||
category: "Chat Filtering",
|
||||
no_bttv: true,
|
||||
|
||||
name: "Auto-Hide Potentially Dangerous Shortened Links",
|
||||
help: "Replace potentially dangerous shortened links. Links are still accessible, but require an extra click to access."
|
||||
};
|
||||
|
||||
|
||||
FFZ.settings_info.banned_words = {
|
||||
type: "button",
|
||||
value: [],
|
||||
|
@ -825,7 +837,7 @@ FFZ.get_capitalization = function(name, callback) {
|
|||
|
||||
FFZ.prototype._remove_banned = function(tokens) {
|
||||
var banned_words = this.settings.banned_words,
|
||||
banned_links = ['j.mp', 'bit.ly'],
|
||||
banned_links = this.settings.filter_bad_shorteners ? ['goo.gl', 'j.mp', 'bit.ly'] : null,
|
||||
|
||||
has_banned_words = banned_words && banned_words.length;
|
||||
|
||||
|
@ -836,10 +848,10 @@ FFZ.prototype._remove_banned = function(tokens) {
|
|||
tokens = [tokens];
|
||||
|
||||
var regex = FFZ._words_to_regex(banned_words),
|
||||
link_regex = FFZ._words_to_regex(banned_links),
|
||||
link_regex = this.settings.filter_bad_shorteners && FFZ._words_to_regex(banned_links),
|
||||
new_tokens = [];
|
||||
|
||||
for(var i=0; i < tokens.length; i++) {
|
||||
for(var i=0, l = tokens.length; i < l; i++) {
|
||||
var token = tokens[i];
|
||||
if ( ! _.isString(token ) ) {
|
||||
if ( token.emoticonSrc && has_banned_words && regex.test(token.altText) )
|
||||
|
@ -852,13 +864,13 @@ FFZ.prototype._remove_banned = function(tokens) {
|
|||
isLong: false,
|
||||
censoredHref: token.href.replace(regex, "$1***")
|
||||
});
|
||||
else if ( token.isLink && link_regex.test(token.href) )
|
||||
else if ( token.isLink && this.settings.filter_bad_shorteners && link_regex.test(token.href) )
|
||||
new_tokens.push({
|
||||
isLink: true,
|
||||
href: token.href,
|
||||
isDeleted: true,
|
||||
isLong: false,
|
||||
censoredHref: token.href.replace(link_regex, "$1***")
|
||||
isShortened: true
|
||||
});
|
||||
else
|
||||
new_tokens.push(token);
|
||||
|
|
|
@ -1102,6 +1102,14 @@ FFZ.prototype._modify_room = function(room) {
|
|||
if ( ! is_whisper )
|
||||
msg.room = this.get('id');
|
||||
|
||||
// Look up color and labels.
|
||||
if ( this.tmiRoom && msg.from ) {
|
||||
if ( ! msg.color )
|
||||
msg.color = msg.tags && msg.tags.color ? msg.tags.color : this.tmiSession.getColor(msg.from.toLowerCase());
|
||||
if ( ! msg.labels )
|
||||
msg.labels = this.tmiRoom.getLabels(msg.from);
|
||||
}
|
||||
|
||||
// Tokenization
|
||||
f.tokenize_chat_line(msg, false, this.get('roomProperties.hide_chat_links'));
|
||||
|
||||
|
@ -1144,13 +1152,12 @@ FFZ.prototype._modify_room = function(room) {
|
|||
this.ffzUpdateChatters(msg.from);
|
||||
}
|
||||
|
||||
var out = this._super(msg);
|
||||
|
||||
// Color processing.
|
||||
if ( msg.color )
|
||||
f._handle_color(msg.color);
|
||||
|
||||
return out;
|
||||
// Add the message.
|
||||
return this._super(msg);
|
||||
},
|
||||
|
||||
setHostMode: function(e) {
|
||||
|
|
|
@ -21,7 +21,7 @@ FFZ.get = function() { return FFZ.instance; }
|
|||
|
||||
// Version
|
||||
var VER = FFZ.version_info = {
|
||||
major: 3, minor: 5, revision: 14,
|
||||
major: 3, minor: 5, revision: 16,
|
||||
toString: function() {
|
||||
return [VER.major, VER.minor, VER.revision].join(".") + (VER.extra || "");
|
||||
}
|
||||
|
@ -343,6 +343,7 @@ FFZ.prototype.init_ember = function(delay) {
|
|||
this.find_bttv(10);
|
||||
this.find_emote_menu(10);
|
||||
|
||||
//this.check_news();
|
||||
this.check_ff();
|
||||
|
||||
var end = (window.performance && performance.now) ? performance.now() : Date.now(),
|
||||
|
|
|
@ -4,6 +4,8 @@ var FFZ = window.FrankerFaceZ,
|
|||
TWITCH_BASE = "http://static-cdn.jtvnw.net/emoticons/v1/",
|
||||
helpers,
|
||||
|
||||
EXPLANATION_TRAIL = '<hr>FFZ is hiding this link because this url shortener is known to be used by Twitch spam bots posting malicious links. Please use caution when visiting shortened links.',
|
||||
|
||||
SRCSETS = {};
|
||||
build_srcset = function(id) {
|
||||
if ( SRCSETS[id] )
|
||||
|
@ -65,7 +67,7 @@ var FFZ = window.FrankerFaceZ,
|
|||
var images = document.querySelectorAll('img[data-emote="' + id + '"]');
|
||||
for(var x=0; x < images.length; x++)
|
||||
images[x].title = tooltip;
|
||||
|
||||
|
||||
return tooltip;
|
||||
},
|
||||
|
||||
|
@ -79,13 +81,13 @@ var FFZ = window.FrankerFaceZ,
|
|||
SEPARATORS = "[\\s`~<>!-#%-\\x2A,-/:;\\x3F@\\x5B-\\x5D_\\x7B}\\u00A1\\u00A7\\u00AB\\u00B6\\u00B7\\u00BB\\u00BF\\u037E\\u0387\\u055A-\\u055F\\u0589\\u058A\\u05BE\\u05C0\\u05C3\\u05C6\\u05F3\\u05F4\\u0609\\u060A\\u060C\\u060D\\u061B\\u061E\\u061F\\u066A-\\u066D\\u06D4\\u0700-\\u070D\\u07F7-\\u07F9\\u0830-\\u083E\\u085E\\u0964\\u0965\\u0970\\u0AF0\\u0DF4\\u0E4F\\u0E5A\\u0E5B\\u0F04-\\u0F12\\u0F14\\u0F3A-\\u0F3D\\u0F85\\u0FD0-\\u0FD4\\u0FD9\\u0FDA\\u104A-\\u104F\\u10FB\\u1360-\\u1368\\u1400\\u166D\\u166E\\u169B\\u169C\\u16EB-\\u16ED\\u1735\\u1736\\u17D4-\\u17D6\\u17D8-\\u17DA\\u1800-\\u180A\\u1944\\u1945\\u1A1E\\u1A1F\\u1AA0-\\u1AA6\\u1AA8-\\u1AAD\\u1B5A-\\u1B60\\u1BFC-\\u1BFF\\u1C3B-\\u1C3F\\u1C7E\\u1C7F\\u1CC0-\\u1CC7\\u1CD3\\u2010-\\u2027\\u2030-\\u2043\\u2045-\\u2051\\u2053-\\u205E\\u207D\\u207E\\u208D\\u208E\\u2329\\u232A\\u2768-\\u2775\\u27C5\\u27C6\\u27E6-\\u27EF\\u2983-\\u2998\\u29D8-\\u29DB\\u29FC\\u29FD\\u2CF9-\\u2CFC\\u2CFE\\u2CFF\\u2D70\\u2E00-\\u2E2E\\u2E30-\\u2E3B\\u3001-\\u3003\\u3008-\\u3011\\u3014-\\u301F\\u3030\\u303D\\u30A0\\u30FB\\uA4FE\\uA4FF\\uA60D-\\uA60F\\uA673\\uA67E\\uA6F2-\\uA6F7\\uA874-\\uA877\\uA8CE\\uA8CF\\uA8F8-\\uA8FA\\uA92E\\uA92F\\uA95F\\uA9C1-\\uA9CD\\uA9DE\\uA9DF\\uAA5C-\\uAA5F\\uAADE\\uAADF\\uAAF0\\uAAF1\\uABEB\\uFD3E\\uFD3F\\uFE10-\\uFE19\\uFE30-\\uFE52\\uFE54-\\uFE61\\uFE63\\uFE68\\uFE6A\\uFE6B\\uFF01-\\uFF03\\uFF05-\\uFF0A\\uFF0C-\\uFF0F\\uFF1A\\uFF1B\\uFF1F\\uFF20\\uFF3B-\\uFF3D\\uFF3F\\uFF5B\\uFF5D\\uFF5F-\\uFF65]",
|
||||
SPLITTER = new RegExp(SEPARATORS + "*," + SEPARATORS + "*"),
|
||||
|
||||
|
||||
|
||||
LINK_SPLIT = /^(?:(https?):\/\/)?(?:(.*?)@)?([^\/:]+)(?::(\d+))?(.*?)(?:\?(.*?))?(?:\#(.*?))?$/,
|
||||
YOUTUBE_CHECK = /^(?:https?:\/\/)?(?:m\.|www\.)?youtu(?:be\.com|\.be)\/(?:v\/|watch\/|.*?(?:embed|watch).*?v=)?([a-zA-Z0-9\-_]+)$/,
|
||||
IMGUR_PATH = /^\/(?:gallery\/)?[A-Za-z0-9]+(?:\.(?:png|jpg|jpeg|gif|gifv|bmp))?$/,
|
||||
IMAGE_EXT = /\.(?:png|jpg|jpeg|gif|bmp)$/i,
|
||||
IMAGE_DOMAINS = [],
|
||||
|
||||
|
||||
is_image = function(href, any_domain) {
|
||||
var match = href.match(LINK_SPLIT);
|
||||
if ( ! match )
|
||||
|
@ -102,9 +104,9 @@ var FFZ = window.FrankerFaceZ,
|
|||
if ( domain === 'i.imgur.com' || domain === 'imgur.com' || domain === 'www.imgur.com' || domain === 'm.imgur.com' )
|
||||
return IMGUR_PATH.test(path);
|
||||
|
||||
return any_domain ? IMAGE_EXT.test(path) : IMAGE_DOMAINS.indexOf(domain) !== -1;
|
||||
return any_domain ? IMAGE_EXT.test(path) : IMAGE_DOMAINS.indexOf(domain) !== -1;
|
||||
}
|
||||
|
||||
|
||||
image_iframe = function(href, extra_class) {
|
||||
return '<iframe class="ffz-image-hover' + (extra_class ? ' ' + extra_class : '') + '" allowtransparency="true" src="' + constants.SERVER + 'script/image-proxy.html?' + utils.quote_attr(href) + '"></iframe>';
|
||||
},
|
||||
|
@ -112,14 +114,15 @@ var FFZ = window.FrankerFaceZ,
|
|||
|
||||
build_link_tooltip = function(href) {
|
||||
var link_data = this._link_data[href],
|
||||
|
||||
tooltip;
|
||||
|
||||
if ( link_data && link_data.tooltip )
|
||||
return link_data.tooltip;
|
||||
|
||||
if ( ! link_data )
|
||||
return "";
|
||||
|
||||
if ( link_data.tooltip )
|
||||
return link_data.tooltip;
|
||||
|
||||
if ( link_data.type == "youtube" ) {
|
||||
tooltip = this.settings.link_image_hover ? image_iframe(link_data.full || href, 'ffz-yt-thumb') : '';
|
||||
tooltip += "<b>YouTube: " + utils.sanitize(link_data.title) + "</b><hr>";
|
||||
|
@ -277,17 +280,17 @@ FFZ.prototype.setup_tokenization = function() {
|
|||
this._twitch_emote_to_set = {};
|
||||
this._twitch_set_to_channel = {};
|
||||
this._link_data = {};
|
||||
|
||||
|
||||
this.load_twitch_emote_data();
|
||||
|
||||
|
||||
helpers = window.require && window.require("ember-twitch-chat/helpers/chat-line-helpers");
|
||||
if ( ! helpers )
|
||||
return this.log("Unable to get chat helper functions.");
|
||||
|
||||
|
||||
this.log("Hooking Ember chat line helpers.");
|
||||
|
||||
var f = this;
|
||||
|
||||
|
||||
// Timestamp Display
|
||||
helpers.getTime = function(e) {
|
||||
if ( e === undefined || e === null )
|
||||
|
@ -295,12 +298,12 @@ FFZ.prototype.setup_tokenization = function() {
|
|||
|
||||
var hours = e.getHours(),
|
||||
minutes = e.getMinutes();
|
||||
|
||||
|
||||
if ( hours > 12 && ! f.settings.twenty_four_timestamps )
|
||||
hours -= 12;
|
||||
else if ( hours === 0 && ! f.settings.twenty_four_timestamps )
|
||||
hours = 12;
|
||||
|
||||
|
||||
return hours + ':' + (minutes < 10 ? '0' : '') + minutes;
|
||||
};
|
||||
|
||||
|
@ -308,22 +311,21 @@ FFZ.prototype.setup_tokenization = function() {
|
|||
// Linkify Messages
|
||||
helpers.linkifyMessage = function(tokens, delete_links) {
|
||||
var show_deleted = f.settings.show_deleted_links;
|
||||
|
||||
|
||||
return _.chain(tokens).map(function(token) {
|
||||
if ( ! _.isString(token) )
|
||||
return token;
|
||||
|
||||
|
||||
var matches = token.match(LINK);
|
||||
if ( ! matches || ! matches.length )
|
||||
return [token];
|
||||
|
||||
|
||||
return _.zip(
|
||||
token.split(LINK),
|
||||
_.map(matches, function(e) {
|
||||
var long = e.length > 255;
|
||||
if ( ! show_deleted && (delete_links || long) )
|
||||
return {isLink: true, isDeleted: true, isLong: long, href: e};
|
||||
//return {mentionedUser: '</span><a class="deleted-link" title="' + utils.quote_attr(e) + '" data-url="' + utils.quote_attr(e) + '" href="#"><' + (e.length > 255 ? 'long link' : 'deleted link') + '></a><span class="mentioning">', own: true}
|
||||
return {isLink: true, href: e};
|
||||
})
|
||||
);
|
||||
|
@ -348,7 +350,7 @@ FFZ.prototype.load_twitch_emote_data = function(tries) {
|
|||
for(var i=0, l = set.emotes.length; i < l; i++)
|
||||
this._twitch_emote_to_set[set.emotes[i]] = set_id;
|
||||
}
|
||||
|
||||
|
||||
this._twitch_set_to_channel[0] = "--global--";
|
||||
this._twitch_set_to_channel[33] = "--turbo-faces--";
|
||||
this._twitch_set_to_channel[42] = "--turbo-faces--";
|
||||
|
@ -356,7 +358,7 @@ FFZ.prototype.load_twitch_emote_data = function(tries) {
|
|||
}).fail(function(data) {
|
||||
if ( data.status === 404 )
|
||||
return;
|
||||
|
||||
|
||||
tries = (tries || 0) + 1;
|
||||
if ( tries < 10 )
|
||||
setTimeout(this.load_twitch_emote_data.bind(this, tries), 1000);
|
||||
|
@ -382,17 +384,17 @@ FFZ.prototype.tokenize_chat_line = function(msgObject, prevent_notification, del
|
|||
|
||||
// Standard tokenization
|
||||
if ( helpers && helpers.linkifyMessage ) {
|
||||
var labels = msg.labels || [],
|
||||
var labels = msgObject.labels || [],
|
||||
mod_or_higher = labels.indexOf("owner") !== -1 ||
|
||||
labels.indexOf("staff") !== -1 ||
|
||||
labels.indexOf("admin") !== -1 ||
|
||||
labels.indexOf("global_mod") !== -1 ||
|
||||
labels.indexOf("mod") !== -1 ||
|
||||
msg.style === 'admin';
|
||||
msgObject.style === 'admin';
|
||||
|
||||
tokens = helpers.linkifyMessage(tokens, delete_links && !mod_or_higher);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ( user && user.login && helpers && helpers.mentionizeMessage )
|
||||
tokens = helpers.mentionizeMessage(tokens, user.login, from_me);
|
||||
|
@ -448,14 +450,14 @@ FFZ.prototype.tokenize_chat_line = function(msgObject, prevent_notification, del
|
|||
room_name = room.get('tmiRoom.displayName');
|
||||
else
|
||||
room_name = FFZ.get_capitalization(room_id);
|
||||
|
||||
|
||||
display = display || Twitch.display.capitalize(msgObject.from);
|
||||
|
||||
|
||||
if ( msgObject.style === 'action' )
|
||||
msg = '* ' + display + ' ' + msg;
|
||||
else
|
||||
msg = display + ': ' + msg;
|
||||
|
||||
|
||||
var f = this;
|
||||
if ( msgObject.style === 'whisper' )
|
||||
this.show_notification(
|
||||
|
@ -573,42 +575,42 @@ FFZ.prototype.render_tokens = function(tokens, render_links) {
|
|||
}
|
||||
|
||||
if ( token.isLink ) {
|
||||
var text = token.title || (token.isLong && '<long link>') || (token.isDeleted && '<deleted link>') || token.href;
|
||||
|
||||
var text = token.title || (token.isLong && '<long link>') || (token.isShortened && '<shortened link>') || (token.isDeleted && '<deleted link>') || token.href;
|
||||
|
||||
if ( ! render_links && render_links !== undefined )
|
||||
return utils.sanitize(text);
|
||||
|
||||
var href = token.href,
|
||||
tooltip, cls = '',
|
||||
|
||||
|
||||
ind_at = href.indexOf("@"),
|
||||
ind_sl = href.indexOf("/");
|
||||
|
||||
|
||||
if ( ind_at !== -1 && (ind_sl === -1 || ind_at < ind_sl) ) {
|
||||
// E-Mail Link
|
||||
cls = 'email-link';
|
||||
|
||||
|
||||
if ( f.settings.link_info ) {
|
||||
cls += ' tooltip';
|
||||
tooltip = 'E-Mail ' + href;
|
||||
}
|
||||
|
||||
|
||||
href = 'mailto:' + href;
|
||||
|
||||
|
||||
} else {
|
||||
// Web Link
|
||||
if ( ! href.match(/^https?:\/\//) )
|
||||
href = 'http://' + href;
|
||||
|
||||
href = 'http://' + href;
|
||||
|
||||
if ( f.settings.link_info ) {
|
||||
cls = 'html-tooltip';
|
||||
|
||||
|
||||
var data = f._link_data && f._link_data[href];
|
||||
if ( data ) {
|
||||
tooltip = data.tooltip;
|
||||
if ( data.unsafe )
|
||||
cls += ' unsafe-link';
|
||||
|
||||
|
||||
} else {
|
||||
f._link_data = f._link_data || {};
|
||||
f._link_data[href] = true;
|
||||
|
@ -616,24 +618,29 @@ FFZ.prototype.render_tokens = function(tokens, render_links) {
|
|||
if ( f.settings.link_image_hover && is_image(href, f.settings.image_hover_all_domains) )
|
||||
tooltip = image_iframe(href);
|
||||
}
|
||||
|
||||
|
||||
} else if ( f.settings.link_image_hover ) {
|
||||
cls = 'html-tooltip';
|
||||
if ( is_image(href, f.settings.image_hover_all_domains) )
|
||||
tooltip = image_iframe(href);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Deleted Links
|
||||
var actual_href = href;
|
||||
if ( token.isDeleted ) {
|
||||
if ( token.isShortened ) {
|
||||
cls = 'shortened-link deleted-link ' + cls;
|
||||
tooltip = utils.sanitize(token.href) + EXPLANATION_TRAIL;
|
||||
href = '#';
|
||||
|
||||
} else if ( token.isDeleted ) {
|
||||
cls = 'deleted-link ' + cls;
|
||||
tooltip = utils.sanitize(token.censoredHref || token.href);
|
||||
href = '#';
|
||||
}
|
||||
|
||||
return '<a class="' + cls + '" data-url="' + utils.quote_attr(actual_href) + '" href="' + utils.quote_attr(href || '#') + '" title="' + utils.quote_attr(tooltip || '') + '" target="_blank">' + utils.sanitize(text) + '</a>';
|
||||
|
||||
return '<a class="' + cls + '" data-original-url="' + utils.quote_attr(token.href) + '" data-url="' + utils.quote_attr(actual_href) + '" href="' + utils.quote_attr(href || '#') + '" title="' + utils.quote_attr(tooltip || '') + '" target="_blank">' + utils.sanitize(text) + '</a>';
|
||||
}
|
||||
|
||||
if ( token.mentionedUser )
|
||||
|
@ -670,7 +677,7 @@ FFZ.prototype.tokenize_replace_emotes = function(tokens) {
|
|||
token.emoticonSrc = constants.EMOTE_REPLACEMENT_BASE + constants.EMOTE_REPLACEMENTS[emote_id];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return tokens;
|
||||
}
|
||||
|
||||
|
@ -947,7 +954,7 @@ FFZ.prototype._deleted_link_click = function(e) {
|
|||
|
||||
// Get the URL
|
||||
var href = this.getAttribute('data-url'),
|
||||
link = href,
|
||||
link = this.getAttribute('data-original-url') || href,
|
||||
f = FrankerFaceZ.get();
|
||||
|
||||
// Delete Old Stuff
|
||||
|
@ -968,7 +975,7 @@ FFZ.prototype._deleted_link_click = function(e) {
|
|||
this.textContent = link;
|
||||
|
||||
// Now, check for a tooltip.
|
||||
var link_data = f._link_data[link];
|
||||
var link_data = f._link_data[href];
|
||||
if ( link_data && typeof link_data != "boolean" ) {
|
||||
this.title = link_data.tooltip;
|
||||
if ( link_data.unsafe )
|
||||
|
|
|
@ -2,6 +2,44 @@ var FFZ = window.FrankerFaceZ,
|
|||
constants = require("../constants");
|
||||
|
||||
|
||||
// -------------------
|
||||
// Initialization
|
||||
// -------------------
|
||||
|
||||
FFZ.prototype._has_news = false;
|
||||
FFZ.prototype._news_id = 0;
|
||||
|
||||
FFZ.prototype.check_news = function(tries) {
|
||||
jQuery.ajax(constants.SERVER + "script/news.json", {cache: false, dataType: "json", context: this})
|
||||
.done(function(data) {
|
||||
FFZ.ws_commands.update_news.bind(this)(data.id);
|
||||
}).fail(function(data) {
|
||||
if ( data.status === 404 )
|
||||
return;
|
||||
|
||||
tries = (tries || 0) + 1;
|
||||
if ( tries < 10 )
|
||||
setTimeout(this.check_news.bind(this, tries), Math.floor(Math.random()*5)*1000);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
FFZ.ws_commands.update_news = function(version) {
|
||||
var old_version = parseInt(localStorage.ffzLastNewsId || "0") || 0;
|
||||
if ( ! old_version || old_version === NaN || old_version < 0 )
|
||||
old_version = 0;
|
||||
|
||||
if ( version <= old_version ) {
|
||||
this._news_id = old_version;
|
||||
return;
|
||||
}
|
||||
|
||||
this._has_news = true;
|
||||
this._news_id = version;
|
||||
this.update_ui_link();
|
||||
}
|
||||
|
||||
|
||||
// -------------------
|
||||
// About Page
|
||||
// -------------------
|
||||
|
@ -10,18 +48,18 @@ FFZ.menu_pages.about_changelog = {
|
|||
name: "Changelog",
|
||||
visible: false,
|
||||
wide: true,
|
||||
|
||||
|
||||
render: function(view, container) {
|
||||
var heading = document.createElement('div');
|
||||
|
||||
heading.className = 'chat-menu-content center';
|
||||
heading.innerHTML = '<h1>FrankerFaceZ</h1><div class="ffz-about-subheading">change log</div>';
|
||||
|
||||
|
||||
jQuery.ajax(constants.SERVER + "script/changelog.html", {cache: false, context: this})
|
||||
.done(function(data) {
|
||||
container.appendChild(heading);
|
||||
container.innerHTML += data;
|
||||
|
||||
|
||||
}).fail(function(data) {
|
||||
var content = document.createElement('div');
|
||||
content.className = 'chat-menu-content menu-side-padding';
|
||||
|
@ -34,6 +72,42 @@ FFZ.menu_pages.about_changelog = {
|
|||
};
|
||||
|
||||
|
||||
FFZ.menu_pages.about_news = {
|
||||
name: "News",
|
||||
visible: false,
|
||||
wide: true,
|
||||
|
||||
render: function(view, container) {
|
||||
// Handle the news state.
|
||||
if ( this._has_news ) {
|
||||
this._has_news = false;
|
||||
localStorage.ffzLastNewsId = this._news_id;
|
||||
this.update_ui_link();
|
||||
}
|
||||
|
||||
|
||||
var heading = document.createElement('div');
|
||||
|
||||
heading.className = 'chat-menu-content center';
|
||||
heading.innerHTML = '<h1>FrankerFaceZ</h1><div class="ffz-about-subheading">announcements and news</div>';
|
||||
|
||||
jQuery.ajax(constants.SERVER + "script/news.html", {cache: false, context: this})
|
||||
.done(function(data) {
|
||||
container.appendChild(heading);
|
||||
container.innerHTML += data;
|
||||
|
||||
}).fail(function(data) {
|
||||
var content = document.createElement('div');
|
||||
content.className = 'chat-menu-content menu-side-padding';
|
||||
content.textContent = 'There was an error loading the announcements from the server.';
|
||||
|
||||
container.appendChild(heading);
|
||||
container.appendChild(content);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
FFZ.menu_pages.about = {
|
||||
name: "About",
|
||||
icon: constants.HEART,
|
||||
|
@ -74,11 +148,29 @@ FFZ.menu_pages.about = {
|
|||
});
|
||||
|
||||
|
||||
// Advertising
|
||||
// Button Stuff
|
||||
var btn_container = document.createElement('div'),
|
||||
ad_button = document.createElement('a'),
|
||||
news_button = document.createElement('a'),
|
||||
donate_button = document.createElement('a'),
|
||||
message = "To use custom emoticons in " + (has_emotes ? "this channel" : "tons of channels") + ", get FrankerFaceZ from http://www.frankerfacez.com";
|
||||
|
||||
|
||||
// News
|
||||
/*news_button.className = 'button ffz-news';
|
||||
news_button.innerHTML = 'Announcements and News';
|
||||
news_button.addEventListener('click', function() {
|
||||
f._ui_change_page(view, inner, menu, container, 'about_news');
|
||||
});
|
||||
|
||||
btn_container.appendChild(news_button);
|
||||
btn_container.className = 'chat-menu-content center';
|
||||
container.appendChild(btn_container);
|
||||
btn_container = document.createElement('div');*/
|
||||
|
||||
|
||||
// Advertising
|
||||
|
||||
ad_button.className = 'button primary';
|
||||
ad_button.innerHTML = "Advertise in Chat";
|
||||
ad_button.addEventListener('click', this._add_emote.bind(this, view, message));
|
||||
|
@ -86,7 +178,6 @@ FFZ.menu_pages.about = {
|
|||
btn_container.appendChild(ad_button);
|
||||
|
||||
// Donate
|
||||
var donate_button = document.createElement('a');
|
||||
|
||||
donate_button.className = 'button ffz-donate';
|
||||
donate_button.href = "https://www.frankerfacez.com/donate";
|
||||
|
@ -97,6 +188,7 @@ FFZ.menu_pages.about = {
|
|||
btn_container.className = 'chat-menu-content center';
|
||||
container.appendChild(btn_container);
|
||||
|
||||
|
||||
// Credits
|
||||
var credits = document.createElement('div');
|
||||
|
||||
|
|
|
@ -321,9 +321,19 @@ FFZ.prototype.build_ui_popup = function(view) {
|
|||
menu.appendChild(el);
|
||||
}
|
||||
|
||||
// Render Current Page
|
||||
|
||||
var page = (this._last_page || "channel").split("_", 1)[0];
|
||||
this._ui_change_page(view, inner, menu, sub_container, page);
|
||||
|
||||
// Do we have news?
|
||||
if ( this._has_news ) {
|
||||
// Render news, then set the page back so our default doesn't change.
|
||||
this._ui_change_page(view, inner, menu, sub_container, 'about_news');
|
||||
this._last_page = page;
|
||||
|
||||
} else
|
||||
// Render Current Page
|
||||
this._ui_change_page(view, inner, menu, sub_container, page);
|
||||
|
||||
|
||||
// Add the menu to the DOM.
|
||||
this._popup = container;
|
||||
|
|
|
@ -43,4 +43,5 @@ FFZ.prototype.update_ui_link = function(link) {
|
|||
link.classList.toggle('live', live);
|
||||
link.classList.toggle('dark', dark);
|
||||
link.classList.toggle('blue', blue);
|
||||
link.classList.toggle('news', this._has_news);
|
||||
}
|
|
@ -27,6 +27,16 @@ FFZ.prototype.setup_notifications = function() {
|
|||
// Settings
|
||||
// ---------------------
|
||||
|
||||
FFZ.settings_info.server_messages = {
|
||||
type: "boolean",
|
||||
value: true,
|
||||
|
||||
category: "Appearance",
|
||||
name: "Server Notifications",
|
||||
help: "Display global FrankerFaceZ notifications."
|
||||
};
|
||||
|
||||
|
||||
FFZ.settings_info.highlight_notifications = {
|
||||
type: "boolean",
|
||||
value: false,
|
||||
|
@ -96,6 +106,9 @@ FFZ.settings_info.notification_timeout = {
|
|||
// ---------------------
|
||||
|
||||
FFZ.ws_commands.message = function(message) {
|
||||
if ( ! this.settings.server_messages )
|
||||
return;
|
||||
|
||||
this.show_message(message);
|
||||
}
|
||||
|
||||
|
|
24
style.css
24
style.css
|
@ -64,6 +64,17 @@ body:not(.ffz-minimal-chat):not(.ffz-menu-replace) .emoticon-selector-toggle + s
|
|||
.ffz-ui-toggle.blue.live svg.svg-emoticons path { fill: rgba(47,88,185,0.5); }
|
||||
.ffz-ui-toggle.blue.live:hover svg.svg-emoticons path { fill: rgba(47,88,185,1); }
|
||||
|
||||
.ember-chat-container.dark .ffz-ui-toggle.news svg.svg-emoticons path,
|
||||
.app-main.theatre .ffz-ui-toggle.news svg.svg-emoticons path,
|
||||
.chat-container.dark .ffz-ui-toggle.news svg.svg-emoticons path,
|
||||
.ember-chat .chat-interface .textarea-contain .ffz-ui-toggle.dark.news svg.svg-emoticons path,
|
||||
.ffz-ui-toggle.news svg.svg-emoticons path { fill: rgba(117, 80, 0, 0.5); }
|
||||
|
||||
.ember-chat-container.dark .ffz-ui-toggle.news:hover svg.svg-emoticons path,
|
||||
.app-main.theatre .ffz-ui-toggle.news:hover svg.svg-emoticons path,
|
||||
.chat-container.dark .ffz-ui-toggle.news:hover svg.svg-emoticons path,
|
||||
.ember-chat .chat-interface .textarea-contain .ffz-ui-toggle.dark.news:hover svg.svg-emoticons path,
|
||||
.ffz-ui-toggle.news:hover svg.svg-emoticons path { fill: rgba(117, 80, 0, 0.8); }
|
||||
|
||||
.ember-chat-container.dark .ffz-ui-toggle.no-emotes svg.svg-emoticons path,
|
||||
.app-main.theatre .ffz-ui-toggle.no-emotes svg.svg-emoticons path,
|
||||
|
@ -443,6 +454,8 @@ body:not(.ffz-minimal-chat):not(.ffz-menu-replace) .emoticon-selector-toggle + s
|
|||
position: relative;
|
||||
}
|
||||
|
||||
.list-header span.right { float: right; }
|
||||
|
||||
.chat-menu-content.collapsable .heading span.right {
|
||||
padding-right: 15px;
|
||||
}
|
||||
|
@ -1244,17 +1257,20 @@ body:not(.ffz-chat-purge-icon) .ember-chat .mod-icons .purge { display: none; }
|
|||
margin: -5px 0 5px;
|
||||
}
|
||||
|
||||
.button.ffz-news,
|
||||
.button.ffz-donate {
|
||||
margin-left: 10px;
|
||||
background: #00b132;
|
||||
color: #fff !important;
|
||||
padding: 0 10px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.button.ffz-donate:not(.disabled):hover {
|
||||
background: #08c43d;
|
||||
}
|
||||
.button.ffz-donate { background: #00b132; }
|
||||
.button.ffz-donate:not(.disabled):hover { background: #08c43d; }
|
||||
|
||||
.button.ffz-news { background: #755000; }
|
||||
.button.ffz-news:not(.disabled):hover { background: #8a5f03; }
|
||||
|
||||
|
||||
/* Dumb Fixes */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue