1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-08-01 07:28:31 +00:00

Modified how capitalization is handled. Added code to clean up localStorage of old script's remnants. Added sorting and capitalization of the viewer list.

This commit is contained in:
SirStendec 2015-01-15 16:42:21 -05:00
parent 1663b8e2ea
commit d961cb954f
5 changed files with 296 additions and 41 deletions

View file

@ -47,24 +47,36 @@ FFZ.prototype.setup_line = function() {
// ---------------------
FFZ.capitalization = {};
FFZ._cap_fetching = 0;
FFZ.prototype.capitalize = function(view, user) {
if ( FFZ.capitalization[user] )
return view.$('.from').text(FFZ.capitalization[user]);
FFZ.get_capitalization = function(name, callback) {
name = name.toLowerCase();
var old_data = FFZ.capitalization[name];
if ( old_data ) {
if ( Date.now() - old_data[1] < 3600000 )
return old_data[0];
}
var f = this;
jQuery.getJSON("https://api.twitch.tv/kraken/channels/" + user + "?callback=?")
.always(function(data) {
if ( data.display_name == undefined )
FFZ.capitalization[user] = user;
else
FFZ.capitalization[user] = data.display_name;
if ( FFZ._cap_fetching < 5 ) {
FFZ._cap_fetching++;
Twitch.api.get("users/" + name)
.always(function(data) {
var cap_name = data.display_name || name;
FFZ.capitalization[name] = [cap_name, Date.now()];
FFZ._cap_fetching--;
callback && callback(cap_name);
});
}
f.capitalize(view, user);
});
return old_data ? old_data[0] : name;
}
FFZ.prototype.capitalize = function(view, user) {
var name = FFZ.get_capitalization(user, this.capitalize.bind(this, view));
if ( name )
view.$('.from').text(name);
}
// ---------------------