1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-08-01 07:28: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:
SirStendec 2015-03-15 21:24:22 -04:00
parent 0aec86a4d8
commit 45f82701c2
11 changed files with 216 additions and 51 deletions

View file

@ -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
// --------------------
@ -85,8 +110,25 @@ FFZ.prototype.bttv_badges = function(data) {
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(&quot;' + (badge.image || full_badge.image) + "&quot;)";
replaced = true;
break;
}
}
if ( replaced )
continue;
}
if ( badge.image )
style += 'background-image: url(\\"' + badge.image + '\\"); ';
style += 'background-image: url(&quot;' + badge.image + '&quot;); ';
if ( badge.color && ! alpha )
style += 'background-color: ' + badge.color + '; ';
@ -148,6 +190,7 @@ FFZ.prototype.render_badge = function(view) {
var el = badges[0].querySelector('.badge.' + full_badge.replaces);
if ( el ) {
el.style.backgroundImage = 'url("' + (badge.image || full_badge.image) + '")';
el.classList.add("ffz-badge-replacement");
el.title += ", " + (badge.title || full_badge.title);
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.known_bots = ["quoteconut", "quoconut", "zenwan", "triiharder", "wobblerbot", "theroflbotr", "acebot", "wooferedmilk"];
FFZ.prototype._legacy_add_donors = function(tries) {
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]));
FFZ.prototype._legacy_add_donors = function() {
// Developer Badge
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]));
// 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
this.badges[2] = {id: 2, title: "Bot", color: "#595959", image: "//cdn.frankerfacez.com/channel/global/boticon.png",
replaces: 'moderator',
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]));
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
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._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) {
this._legacy_parse_donors(data);
this._legacy_parse_badges(data, 0, 2);
}).fail(function(data) {
if ( data.status == 404 )
@ -224,12 +265,27 @@ FFZ.prototype._legacy_add_donors = function(tries) {
tries = (tries || 0) + 1;
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;
if ( data != null ) {
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] || {},
badges = user.badges = user.badges || {};
if ( badges[1] )
if ( badges[slot] )
continue;
badges[1] = {id:1};
badges[slot] = {id:badge_id};
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.");
}