mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-07-02 17:18:31 +00:00
Fixed UI for inviting user to chat in dark mode. Bot badges. Fixed mod badges not overriding in some cases. Other minor tweaks.
This commit is contained in:
parent
0aec86a4d8
commit
45f82701c2
11 changed files with 216 additions and 51 deletions
1
dark.css
1
dark.css
|
@ -117,6 +117,7 @@ border-color: rgba(255, 255, 255, 0.35) transparent transparent!important;;
|
||||||
.ffz-dark .card,
|
.ffz-dark .card,
|
||||||
.ffz-dark #flyout .content,
|
.ffz-dark #flyout .content,
|
||||||
.ffz-dark .dropmenu,
|
.ffz-dark .dropmenu,
|
||||||
|
.ffz-dark .top-dropdown,
|
||||||
.ffz-dark form.js-new_panel_form,
|
.ffz-dark form.js-new_panel_form,
|
||||||
.ffz-dark .js-new_panel_btn,
|
.ffz-dark .js-new_panel_btn,
|
||||||
.ffz-dark .manager .videos-grid .video .meta,
|
.ffz-dark .manager .videos-grid .video .meta,
|
||||||
|
|
130
script.js
130
script.js
|
@ -36,6 +36,31 @@ FFZ.prototype.setup_badges = function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// --------------------
|
||||||
|
// Reloading Badges
|
||||||
|
// --------------------
|
||||||
|
|
||||||
|
FFZ.ws_commands.reload_badges = function() {
|
||||||
|
this._legacy_load_bots();
|
||||||
|
this._legacy_load_donors();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
FFZ.ws_commands.set_badge = function(data) {
|
||||||
|
var user_id = data[0],
|
||||||
|
slot = data[1],
|
||||||
|
badge = data[2],
|
||||||
|
|
||||||
|
user = this.users[user_id] = this.users[user_id] || {},
|
||||||
|
badges = user.badges = user.badges || {};
|
||||||
|
|
||||||
|
if ( badge === undefined )
|
||||||
|
delete badges[slot];
|
||||||
|
else
|
||||||
|
badges[slot] = badge;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// --------------------
|
// --------------------
|
||||||
// Badge CSS
|
// Badge CSS
|
||||||
// --------------------
|
// --------------------
|
||||||
|
@ -86,8 +111,25 @@ FFZ.prototype.bttv_badges = function(data) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( full_badge.replaces ) {
|
||||||
|
var replaced = false;
|
||||||
|
for(var i=0; i < data.badges.length; i++) {
|
||||||
|
var b = data.badges[i];
|
||||||
|
if ( b.type == full_badge.replaces ) {
|
||||||
|
b.type = "ffz-badge-replacement " + b.type;
|
||||||
|
b.description += ", " + (badge.title || full_badge.title) +
|
||||||
|
'" style="background-image: url("' + (badge.image || full_badge.image) + "")";
|
||||||
|
replaced = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( replaced )
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if ( badge.image )
|
if ( badge.image )
|
||||||
style += 'background-image: url(\\"' + badge.image + '\\"); ';
|
style += 'background-image: url("' + badge.image + '"); ';
|
||||||
|
|
||||||
if ( badge.color && ! alpha )
|
if ( badge.color && ! alpha )
|
||||||
style += 'background-color: ' + badge.color + '; ';
|
style += 'background-color: ' + badge.color + '; ';
|
||||||
|
@ -149,6 +191,7 @@ FFZ.prototype.render_badge = function(view) {
|
||||||
var el = badges[0].querySelector('.badge.' + full_badge.replaces);
|
var el = badges[0].querySelector('.badge.' + full_badge.replaces);
|
||||||
if ( el ) {
|
if ( el ) {
|
||||||
el.style.backgroundImage = 'url("' + (badge.image || full_badge.image) + '")';
|
el.style.backgroundImage = 'url("' + (badge.image || full_badge.image) + '")';
|
||||||
|
el.classList.add("ffz-badge-replacement");
|
||||||
el.title += ", " + (badge.title || full_badge.title);
|
el.title += ", " + (badge.title || full_badge.title);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -187,37 +230,35 @@ FFZ.prototype.render_badge = function(view) {
|
||||||
// --------------------
|
// --------------------
|
||||||
|
|
||||||
FFZ.bttv_known_bots = ["nightbot","moobot","sourbot","xanbot","manabot","mtgbot","ackbot","baconrobot","tardisbot","deejbot","valuebot","stahpbot"];
|
FFZ.bttv_known_bots = ["nightbot","moobot","sourbot","xanbot","manabot","mtgbot","ackbot","baconrobot","tardisbot","deejbot","valuebot","stahpbot"];
|
||||||
FFZ.known_bots = ["quoteconut", "quoconut", "zenwan", "triiharder", "wobblerbot", "theroflbotr", "acebot", "wooferedmilk"];
|
|
||||||
|
|
||||||
|
|
||||||
FFZ.prototype._legacy_add_donors = function(tries) {
|
FFZ.prototype._legacy_add_donors = function() {
|
||||||
this.badges[1] = {id: 1, title: "FFZ Donor", color: "#755000", image: "//cdn.frankerfacez.com/channel/global/donoricon.png"};
|
|
||||||
utils.update_css(this._badge_style, 1, badge_css(this.badges[1]));
|
|
||||||
|
|
||||||
// Developer Badge
|
// Developer Badge
|
||||||
this.badges[0] = {id: 0, title: "FFZ Developer", color: "#FAAF19", image: "//cdn.frankerfacez.com/channel/global/devicon.png"};
|
this.badges[0] = {id: 0, title: "FFZ Developer", color: "#FAAF19", image: "//cdn.frankerfacez.com/channel/global/devicon.png"};
|
||||||
utils.update_css(this._badge_style, 0, badge_css(this.badges[0]));
|
utils.update_css(this._badge_style, 0, badge_css(this.badges[0]));
|
||||||
|
|
||||||
|
// Donor Badge
|
||||||
|
this.badges[1] = {id: 1, title: "FFZ Donor", color: "#755000", image: "//cdn.frankerfacez.com/channel/global/donoricon.png"};
|
||||||
|
utils.update_css(this._badge_style, 1, badge_css(this.badges[1]));
|
||||||
|
|
||||||
// Bot Badge
|
// Bot Badge
|
||||||
this.badges[2] = {id: 2, title: "Bot", color: "#595959", image: "//cdn.frankerfacez.com/channel/global/boticon.png",
|
this.badges[2] = {id: 2, title: "Bot", color: "#595959", image: "//cdn.frankerfacez.com/channel/global/boticon.png",
|
||||||
replaces: 'moderator',
|
replaces: 'moderator',
|
||||||
visible: function(r,user) { return this.settings.bot_badges && !(this.has_bttv && FFZ.bttv_known_bots.indexOf(user)!==-1); }};
|
visible: function(r,user) { return this.settings.bot_badges && !(this.has_bttv && FFZ.bttv_known_bots.indexOf(user)!==-1); }};
|
||||||
utils.update_css(this._badge_style, 2, badge_css(this.badges[2]));
|
utils.update_css(this._badge_style, 2, badge_css(this.badges[2]));
|
||||||
|
|
||||||
for(var i=0;i<FFZ.bttv_known_bots.length;i++)
|
|
||||||
this.users[FFZ.bttv_known_bots[i]] = {badges: {0: {id:2}}};
|
|
||||||
|
|
||||||
for(var i=0;i<FFZ.known_bots.length;i++)
|
|
||||||
this.users[FFZ.known_bots[i]] = {badges: {0: {id:2}}};
|
|
||||||
|
|
||||||
// Special Badges
|
// Special Badges
|
||||||
this.users.sirstendec = {badges: {1: {id:0}}};
|
this.users.sirstendec = {badges: {1: {id:0}}};
|
||||||
this.users.zenwan = {badges: {0: {id:2, image: "//cdn.frankerfacez.com/channel/global/momiglee_badge.png", title: "WAN"}}};
|
this.users.zenwan = {badges: {0: {id:2, image: "//cdn.frankerfacez.com/channel/global/momiglee_badge.png", title: "WAN"}}};
|
||||||
|
|
||||||
|
this._legacy_load_bots();
|
||||||
|
this._legacy_load_donors();
|
||||||
|
}
|
||||||
|
|
||||||
jQuery.ajax(constants.SERVER + "script/donors.txt", {cache: false, context: this})
|
FFZ.prototype._legacy_load_bots = function(tries) {
|
||||||
|
jQuery.ajax(constants.SERVER + "script/bots.txt", {cache: false, context: this})
|
||||||
.done(function(data) {
|
.done(function(data) {
|
||||||
this._legacy_parse_donors(data);
|
this._legacy_parse_badges(data, 0, 2);
|
||||||
|
|
||||||
}).fail(function(data) {
|
}).fail(function(data) {
|
||||||
if ( data.status == 404 )
|
if ( data.status == 404 )
|
||||||
|
@ -225,12 +266,27 @@ FFZ.prototype._legacy_add_donors = function(tries) {
|
||||||
|
|
||||||
tries = (tries || 0) + 1;
|
tries = (tries || 0) + 1;
|
||||||
if ( tries < 10 )
|
if ( tries < 10 )
|
||||||
return this._legacy_add_donors(tries);
|
this._legacy_load_bots(tries);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
FFZ.prototype._legacy_load_donors = function(tries) {
|
||||||
|
jQuery.ajax(constants.SERVER + "script/donors.txt", {cache: false, context: this})
|
||||||
|
.done(function(data) {
|
||||||
|
this._legacy_parse_badges(data, 1, 1);
|
||||||
|
|
||||||
|
}).fail(function(data) {
|
||||||
|
if ( data.status == 404 )
|
||||||
|
return;
|
||||||
|
|
||||||
|
tries = (tries || 0) + 1;
|
||||||
|
if ( tries < 10 )
|
||||||
|
return this._legacy_load_donors(tries);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FFZ.prototype._legacy_parse_donors = function(data) {
|
FFZ.prototype._legacy_parse_badges = function(data, slot, badge_id) {
|
||||||
var count = 0;
|
var count = 0;
|
||||||
if ( data != null ) {
|
if ( data != null ) {
|
||||||
var lines = data.trim().split(/\W+/);
|
var lines = data.trim().split(/\W+/);
|
||||||
|
@ -239,15 +295,16 @@ FFZ.prototype._legacy_parse_donors = function(data) {
|
||||||
user = this.users[user_id] = this.users[user_id] || {},
|
user = this.users[user_id] = this.users[user_id] || {},
|
||||||
badges = user.badges = user.badges || {};
|
badges = user.badges = user.badges || {};
|
||||||
|
|
||||||
if ( badges[1] )
|
if ( badges[slot] )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
badges[1] = {id:1};
|
badges[slot] = {id:badge_id};
|
||||||
count += 1;
|
count += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.log("Added donor badge to " + utils.number_commas(count) + " users.");
|
var title = this.badges[badge_id].title;
|
||||||
|
this.log('Added "' + title + '" badge to ' + utils.number_commas(count) + " users.");
|
||||||
}
|
}
|
||||||
},{"./constants":3,"./utils":27}],2:[function(require,module,exports){
|
},{"./constants":3,"./utils":27}],2:[function(require,module,exports){
|
||||||
var FFZ = window.FrankerFaceZ;
|
var FFZ = window.FrankerFaceZ;
|
||||||
|
@ -740,6 +797,7 @@ FFZ.prototype.setup_line = function() {
|
||||||
// Basic Data
|
// Basic Data
|
||||||
el.setAttribute('data-room', room);
|
el.setAttribute('data-room', room);
|
||||||
el.setAttribute('data-sender', user);
|
el.setAttribute('data-sender', user);
|
||||||
|
el.setAttribute('data-deleted', controller.get('model.deleted'));
|
||||||
|
|
||||||
|
|
||||||
// Badge
|
// Badge
|
||||||
|
@ -1440,7 +1498,7 @@ var FFZ = window.FrankerFaceZ,
|
||||||
if ( ! room.moderator_badge )
|
if ( ! room.moderator_badge )
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
return '.chat-line[data-room="' + room.id + '"] .badges .moderator { background-image:url("' + room.moderator_badge + '"); }';
|
return '.chat-line[data-room="' + room.id + '"] .badges .moderator:not(.ffz-badge-replacement) { background-image:url("' + room.moderator_badge + '") !important; }';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2333,7 +2391,7 @@ FFZ.get = function() { return FFZ.instance; }
|
||||||
|
|
||||||
// Version
|
// Version
|
||||||
var VER = FFZ.version_info = {
|
var VER = FFZ.version_info = {
|
||||||
major: 3, minor: 2, revision: 3,
|
major: 3, minor: 2, revision: 4,
|
||||||
toString: function() {
|
toString: function() {
|
||||||
return [VER.major, VER.minor, VER.revision].join(".") + (VER.extra || "");
|
return [VER.major, VER.minor, VER.revision].join(".") + (VER.extra || "");
|
||||||
}
|
}
|
||||||
|
@ -3056,7 +3114,7 @@ FFZ.prototype.ws_create = function() {
|
||||||
f.log("Error on Socket Close Callback: " + err);
|
f.log("Error on Socket Close Callback: " + err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We never ever want to not have a socket.
|
// We never ever want to not have a socket.
|
||||||
if ( f._ws_delay < 60000 )
|
if ( f._ws_delay < 60000 )
|
||||||
f._ws_delay += 5000;
|
f._ws_delay += 5000;
|
||||||
|
@ -3384,6 +3442,7 @@ FFZ.prototype.build_ui_popup = function(view) {
|
||||||
// Menu Container
|
// Menu Container
|
||||||
var sub_container = document.createElement('div');
|
var sub_container = document.createElement('div');
|
||||||
sub_container.className = 'ffz-ui-menu-page';
|
sub_container.className = 'ffz-ui-menu-page';
|
||||||
|
|
||||||
inner.appendChild(sub_container);
|
inner.appendChild(sub_container);
|
||||||
|
|
||||||
// Render Menu Tabs
|
// Render Menu Tabs
|
||||||
|
@ -4248,10 +4307,13 @@ FFZ.settings_info.srl_races = {
|
||||||
// ---------------
|
// ---------------
|
||||||
|
|
||||||
FFZ.ws_on_close.push(function() {
|
FFZ.ws_on_close.push(function() {
|
||||||
var controller = App.__container__.lookup('controller:channel'),
|
var controller = window.App && App.__container__.lookup('controller:channel'),
|
||||||
current_id = controller.get('id'),
|
current_id = controller && controller.get('id'),
|
||||||
need_update = false;
|
need_update = false;
|
||||||
|
|
||||||
|
if ( ! controller )
|
||||||
|
return;
|
||||||
|
|
||||||
for(var chan in this.srl_races) {
|
for(var chan in this.srl_races) {
|
||||||
delete this.srl_races[chan];
|
delete this.srl_races[chan];
|
||||||
if ( chan == current_id )
|
if ( chan == current_id )
|
||||||
|
@ -4624,6 +4686,24 @@ var sanitize_cache = {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (0.2126 * rgb[0]) + (0.7152 * rgb[1]) + (0.0722 * rgb[2]);
|
return (0.2126 * rgb[0]) + (0.7152 * rgb[1]) + (0.0722 * rgb[2]);
|
||||||
|
},
|
||||||
|
|
||||||
|
date_regex = /^(\d{4}|\+\d{6})(?:-?(\d{2})(?:-?(\d{2})(?:T(\d{2})(?::?(\d{2})(?::?(\d{2})(?:(?:\.|,)(\d{1,}))?)?)?(Z|([\-+])(\d{2})(?::?(\d{2}))?)?)?)?)?$/,
|
||||||
|
|
||||||
|
parse_date = function(str) {
|
||||||
|
var parts = str.match(date_regex);
|
||||||
|
if ( ! parts )
|
||||||
|
return null;
|
||||||
|
|
||||||
|
var unix = Date.UTC(parts[1], parts[2] - 1, parts[3], parts[4], parts[5], parts[6], parts[7] || 0);
|
||||||
|
|
||||||
|
// Check Offset
|
||||||
|
if ( parts[9] ) {
|
||||||
|
var offset = (parts[9] == "-" ? 1 : -1) * 60000 * (60*parts[10] + 1*parts[11]);
|
||||||
|
unix += offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Date(unix);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -4653,6 +4733,8 @@ module.exports = {
|
||||||
darken: darken,
|
darken: darken,
|
||||||
rgb_to_css: rgb_to_css,
|
rgb_to_css: rgb_to_css,
|
||||||
|
|
||||||
|
parse_date: parse_date,
|
||||||
|
|
||||||
number_commas: function(x) {
|
number_commas: function(x) {
|
||||||
var parts = x.toString().split(".");
|
var parts = x.toString().split(".");
|
||||||
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
||||||
|
|
6
script.min.js
vendored
6
script.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -35,6 +35,31 @@ FFZ.prototype.setup_badges = function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// --------------------
|
||||||
|
// Reloading Badges
|
||||||
|
// --------------------
|
||||||
|
|
||||||
|
FFZ.ws_commands.reload_badges = function() {
|
||||||
|
this._legacy_load_bots();
|
||||||
|
this._legacy_load_donors();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
FFZ.ws_commands.set_badge = function(data) {
|
||||||
|
var user_id = data[0],
|
||||||
|
slot = data[1],
|
||||||
|
badge = data[2],
|
||||||
|
|
||||||
|
user = this.users[user_id] = this.users[user_id] || {},
|
||||||
|
badges = user.badges = user.badges || {};
|
||||||
|
|
||||||
|
if ( badge === undefined )
|
||||||
|
delete badges[slot];
|
||||||
|
else
|
||||||
|
badges[slot] = badge;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// --------------------
|
// --------------------
|
||||||
// Badge CSS
|
// Badge CSS
|
||||||
// --------------------
|
// --------------------
|
||||||
|
@ -85,8 +110,25 @@ FFZ.prototype.bttv_badges = function(data) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( full_badge.replaces ) {
|
||||||
|
var replaced = false;
|
||||||
|
for(var i=0; i < data.badges.length; i++) {
|
||||||
|
var b = data.badges[i];
|
||||||
|
if ( b.type == full_badge.replaces ) {
|
||||||
|
b.type = "ffz-badge-replacement " + b.type;
|
||||||
|
b.description += ", " + (badge.title || full_badge.title) +
|
||||||
|
'" style="background-image: url("' + (badge.image || full_badge.image) + "")";
|
||||||
|
replaced = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( replaced )
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if ( badge.image )
|
if ( badge.image )
|
||||||
style += 'background-image: url(\\"' + badge.image + '\\"); ';
|
style += 'background-image: url("' + badge.image + '"); ';
|
||||||
|
|
||||||
if ( badge.color && ! alpha )
|
if ( badge.color && ! alpha )
|
||||||
style += 'background-color: ' + badge.color + '; ';
|
style += 'background-color: ' + badge.color + '; ';
|
||||||
|
@ -148,6 +190,7 @@ FFZ.prototype.render_badge = function(view) {
|
||||||
var el = badges[0].querySelector('.badge.' + full_badge.replaces);
|
var el = badges[0].querySelector('.badge.' + full_badge.replaces);
|
||||||
if ( el ) {
|
if ( el ) {
|
||||||
el.style.backgroundImage = 'url("' + (badge.image || full_badge.image) + '")';
|
el.style.backgroundImage = 'url("' + (badge.image || full_badge.image) + '")';
|
||||||
|
el.classList.add("ffz-badge-replacement");
|
||||||
el.title += ", " + (badge.title || full_badge.title);
|
el.title += ", " + (badge.title || full_badge.title);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -186,37 +229,35 @@ FFZ.prototype.render_badge = function(view) {
|
||||||
// --------------------
|
// --------------------
|
||||||
|
|
||||||
FFZ.bttv_known_bots = ["nightbot","moobot","sourbot","xanbot","manabot","mtgbot","ackbot","baconrobot","tardisbot","deejbot","valuebot","stahpbot"];
|
FFZ.bttv_known_bots = ["nightbot","moobot","sourbot","xanbot","manabot","mtgbot","ackbot","baconrobot","tardisbot","deejbot","valuebot","stahpbot"];
|
||||||
FFZ.known_bots = ["quoteconut", "quoconut", "zenwan", "triiharder", "wobblerbot", "theroflbotr", "acebot", "wooferedmilk"];
|
|
||||||
|
|
||||||
|
|
||||||
FFZ.prototype._legacy_add_donors = function(tries) {
|
FFZ.prototype._legacy_add_donors = function() {
|
||||||
this.badges[1] = {id: 1, title: "FFZ Donor", color: "#755000", image: "//cdn.frankerfacez.com/channel/global/donoricon.png"};
|
|
||||||
utils.update_css(this._badge_style, 1, badge_css(this.badges[1]));
|
|
||||||
|
|
||||||
// Developer Badge
|
// Developer Badge
|
||||||
this.badges[0] = {id: 0, title: "FFZ Developer", color: "#FAAF19", image: "//cdn.frankerfacez.com/channel/global/devicon.png"};
|
this.badges[0] = {id: 0, title: "FFZ Developer", color: "#FAAF19", image: "//cdn.frankerfacez.com/channel/global/devicon.png"};
|
||||||
utils.update_css(this._badge_style, 0, badge_css(this.badges[0]));
|
utils.update_css(this._badge_style, 0, badge_css(this.badges[0]));
|
||||||
|
|
||||||
|
// Donor Badge
|
||||||
|
this.badges[1] = {id: 1, title: "FFZ Donor", color: "#755000", image: "//cdn.frankerfacez.com/channel/global/donoricon.png"};
|
||||||
|
utils.update_css(this._badge_style, 1, badge_css(this.badges[1]));
|
||||||
|
|
||||||
// Bot Badge
|
// Bot Badge
|
||||||
this.badges[2] = {id: 2, title: "Bot", color: "#595959", image: "//cdn.frankerfacez.com/channel/global/boticon.png",
|
this.badges[2] = {id: 2, title: "Bot", color: "#595959", image: "//cdn.frankerfacez.com/channel/global/boticon.png",
|
||||||
replaces: 'moderator',
|
replaces: 'moderator',
|
||||||
visible: function(r,user) { return this.settings.bot_badges && !(this.has_bttv && FFZ.bttv_known_bots.indexOf(user)!==-1); }};
|
visible: function(r,user) { return this.settings.bot_badges && !(this.has_bttv && FFZ.bttv_known_bots.indexOf(user)!==-1); }};
|
||||||
utils.update_css(this._badge_style, 2, badge_css(this.badges[2]));
|
utils.update_css(this._badge_style, 2, badge_css(this.badges[2]));
|
||||||
|
|
||||||
for(var i=0;i<FFZ.bttv_known_bots.length;i++)
|
|
||||||
this.users[FFZ.bttv_known_bots[i]] = {badges: {0: {id:2}}};
|
|
||||||
|
|
||||||
for(var i=0;i<FFZ.known_bots.length;i++)
|
|
||||||
this.users[FFZ.known_bots[i]] = {badges: {0: {id:2}}};
|
|
||||||
|
|
||||||
// Special Badges
|
// Special Badges
|
||||||
this.users.sirstendec = {badges: {1: {id:0}}};
|
this.users.sirstendec = {badges: {1: {id:0}}};
|
||||||
this.users.zenwan = {badges: {0: {id:2, image: "//cdn.frankerfacez.com/channel/global/momiglee_badge.png", title: "WAN"}}};
|
this.users.zenwan = {badges: {0: {id:2, image: "//cdn.frankerfacez.com/channel/global/momiglee_badge.png", title: "WAN"}}};
|
||||||
|
|
||||||
|
this._legacy_load_bots();
|
||||||
|
this._legacy_load_donors();
|
||||||
|
}
|
||||||
|
|
||||||
jQuery.ajax(constants.SERVER + "script/donors.txt", {cache: false, context: this})
|
FFZ.prototype._legacy_load_bots = function(tries) {
|
||||||
|
jQuery.ajax(constants.SERVER + "script/bots.txt", {cache: false, context: this})
|
||||||
.done(function(data) {
|
.done(function(data) {
|
||||||
this._legacy_parse_donors(data);
|
this._legacy_parse_badges(data, 0, 2);
|
||||||
|
|
||||||
}).fail(function(data) {
|
}).fail(function(data) {
|
||||||
if ( data.status == 404 )
|
if ( data.status == 404 )
|
||||||
|
@ -224,12 +265,27 @@ FFZ.prototype._legacy_add_donors = function(tries) {
|
||||||
|
|
||||||
tries = (tries || 0) + 1;
|
tries = (tries || 0) + 1;
|
||||||
if ( tries < 10 )
|
if ( tries < 10 )
|
||||||
return this._legacy_add_donors(tries);
|
this._legacy_load_bots(tries);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
FFZ.prototype._legacy_load_donors = function(tries) {
|
||||||
|
jQuery.ajax(constants.SERVER + "script/donors.txt", {cache: false, context: this})
|
||||||
|
.done(function(data) {
|
||||||
|
this._legacy_parse_badges(data, 1, 1);
|
||||||
|
|
||||||
|
}).fail(function(data) {
|
||||||
|
if ( data.status == 404 )
|
||||||
|
return;
|
||||||
|
|
||||||
|
tries = (tries || 0) + 1;
|
||||||
|
if ( tries < 10 )
|
||||||
|
return this._legacy_load_donors(tries);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FFZ.prototype._legacy_parse_donors = function(data) {
|
FFZ.prototype._legacy_parse_badges = function(data, slot, badge_id) {
|
||||||
var count = 0;
|
var count = 0;
|
||||||
if ( data != null ) {
|
if ( data != null ) {
|
||||||
var lines = data.trim().split(/\W+/);
|
var lines = data.trim().split(/\W+/);
|
||||||
|
@ -238,13 +294,14 @@ FFZ.prototype._legacy_parse_donors = function(data) {
|
||||||
user = this.users[user_id] = this.users[user_id] || {},
|
user = this.users[user_id] = this.users[user_id] || {},
|
||||||
badges = user.badges = user.badges || {};
|
badges = user.badges = user.badges || {};
|
||||||
|
|
||||||
if ( badges[1] )
|
if ( badges[slot] )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
badges[1] = {id:1};
|
badges[slot] = {id:badge_id};
|
||||||
count += 1;
|
count += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.log("Added donor badge to " + utils.number_commas(count) + " users.");
|
var title = this.badges[badge_id].title;
|
||||||
|
this.log('Added "' + title + '" badge to ' + utils.number_commas(count) + " users.");
|
||||||
}
|
}
|
|
@ -283,6 +283,7 @@ FFZ.prototype.setup_line = function() {
|
||||||
// Basic Data
|
// Basic Data
|
||||||
el.setAttribute('data-room', room);
|
el.setAttribute('data-room', room);
|
||||||
el.setAttribute('data-sender', user);
|
el.setAttribute('data-sender', user);
|
||||||
|
el.setAttribute('data-deleted', controller.get('model.deleted'));
|
||||||
|
|
||||||
|
|
||||||
// Badge
|
// Badge
|
||||||
|
|
|
@ -10,7 +10,7 @@ var FFZ = window.FrankerFaceZ,
|
||||||
if ( ! room.moderator_badge )
|
if ( ! room.moderator_badge )
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
return '.chat-line[data-room="' + room.id + '"] .badges .moderator { background-image:url("' + room.moderator_badge + '"); }';
|
return '.chat-line[data-room="' + room.id + '"] .badges .moderator:not(.ffz-badge-replacement) { background-image:url("' + room.moderator_badge + '") !important; }';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ FFZ.get = function() { return FFZ.instance; }
|
||||||
|
|
||||||
// Version
|
// Version
|
||||||
var VER = FFZ.version_info = {
|
var VER = FFZ.version_info = {
|
||||||
major: 3, minor: 2, revision: 3,
|
major: 3, minor: 2, revision: 4,
|
||||||
toString: function() {
|
toString: function() {
|
||||||
return [VER.major, VER.minor, VER.revision].join(".") + (VER.extra || "");
|
return [VER.major, VER.minor, VER.revision].join(".") + (VER.extra || "");
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ FFZ.prototype.ws_create = function() {
|
||||||
f.log("Error on Socket Close Callback: " + err);
|
f.log("Error on Socket Close Callback: " + err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We never ever want to not have a socket.
|
// We never ever want to not have a socket.
|
||||||
if ( f._ws_delay < 60000 )
|
if ( f._ws_delay < 60000 )
|
||||||
f._ws_delay += 5000;
|
f._ws_delay += 5000;
|
||||||
|
|
|
@ -59,6 +59,7 @@ FFZ.prototype.build_ui_popup = function(view) {
|
||||||
// Menu Container
|
// Menu Container
|
||||||
var sub_container = document.createElement('div');
|
var sub_container = document.createElement('div');
|
||||||
sub_container.className = 'ffz-ui-menu-page';
|
sub_container.className = 'ffz-ui-menu-page';
|
||||||
|
|
||||||
inner.appendChild(sub_container);
|
inner.appendChild(sub_container);
|
||||||
|
|
||||||
// Render Menu Tabs
|
// Render Menu Tabs
|
||||||
|
|
|
@ -34,10 +34,13 @@ FFZ.settings_info.srl_races = {
|
||||||
// ---------------
|
// ---------------
|
||||||
|
|
||||||
FFZ.ws_on_close.push(function() {
|
FFZ.ws_on_close.push(function() {
|
||||||
var controller = App.__container__.lookup('controller:channel'),
|
var controller = window.App && App.__container__.lookup('controller:channel'),
|
||||||
current_id = controller.get('id'),
|
current_id = controller && controller.get('id'),
|
||||||
need_update = false;
|
need_update = false;
|
||||||
|
|
||||||
|
if ( ! controller )
|
||||||
|
return;
|
||||||
|
|
||||||
for(var chan in this.srl_races) {
|
for(var chan in this.srl_races) {
|
||||||
delete this.srl_races[chan];
|
delete this.srl_races[chan];
|
||||||
if ( chan == current_id )
|
if ( chan == current_id )
|
||||||
|
|
20
src/utils.js
20
src/utils.js
|
@ -43,6 +43,24 @@ var sanitize_cache = {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (0.2126 * rgb[0]) + (0.7152 * rgb[1]) + (0.0722 * rgb[2]);
|
return (0.2126 * rgb[0]) + (0.7152 * rgb[1]) + (0.0722 * rgb[2]);
|
||||||
|
},
|
||||||
|
|
||||||
|
date_regex = /^(\d{4}|\+\d{6})(?:-?(\d{2})(?:-?(\d{2})(?:T(\d{2})(?::?(\d{2})(?::?(\d{2})(?:(?:\.|,)(\d{1,}))?)?)?(Z|([\-+])(\d{2})(?::?(\d{2}))?)?)?)?)?$/,
|
||||||
|
|
||||||
|
parse_date = function(str) {
|
||||||
|
var parts = str.match(date_regex);
|
||||||
|
if ( ! parts )
|
||||||
|
return null;
|
||||||
|
|
||||||
|
var unix = Date.UTC(parts[1], parts[2] - 1, parts[3], parts[4], parts[5], parts[6], parts[7] || 0);
|
||||||
|
|
||||||
|
// Check Offset
|
||||||
|
if ( parts[9] ) {
|
||||||
|
var offset = (parts[9] == "-" ? 1 : -1) * 60000 * (60*parts[10] + 1*parts[11]);
|
||||||
|
unix += offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Date(unix);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -72,6 +90,8 @@ module.exports = {
|
||||||
darken: darken,
|
darken: darken,
|
||||||
rgb_to_css: rgb_to_css,
|
rgb_to_css: rgb_to_css,
|
||||||
|
|
||||||
|
parse_date: parse_date,
|
||||||
|
|
||||||
number_commas: function(x) {
|
number_commas: function(x) {
|
||||||
var parts = x.toString().split(".");
|
var parts = x.toString().split(".");
|
||||||
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue