1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-06-28 15:27:43 +00:00

3.5.78 to 3.5.83. It's been so long since I've commited. I'm a bad person. Added grouping for hosted channels, and a menu to select which channel you visit. Added weights for selecting which socket server to use. Added server time offset calculations. Refactored a LOT of how chat badges and chat line rendering and history processing works behind the scenes. Removed a ton of duplicate code. Added basic adjacent chat message lookups. Need better server support.

This commit is contained in:
SirStendec 2015-11-19 02:45:56 -05:00
parent a050063c81
commit c167a8b626
28 changed files with 1501 additions and 538 deletions

View file

@ -25,6 +25,16 @@ var sanitize_el = document.createElement('span'),
return msg.replace(R_AMP, "&").replace(R_QUOTE, """).replace(R_SQUOTE, "'").replace(R_LT, "<").replace(R_GT, ">");
},
HUMAN_NUMBERS = [
"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"
],
number_commas = function(x) {
var parts = x.toString().split(".");
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
return parts.join(".");
},
pluralize = function(value, singular, plural) {
plural = plural || 's';
singular = singular || '';
@ -157,6 +167,37 @@ var sanitize_el = document.createElement('span'),
return tags;
},
uncompressEmotes = function(value) {
var output = {},
emotes = value.split("/"),
i = emotes.length;
while(i--) {
var parts = emotes[i].split(":");
if ( parts.length !== 3 )
return {};
var emote_id = parts[0],
length = parseInt(parts[1]),
positions = parts[2].split(","),
indices = output[emote_id] = output[emote_id] || [];
for(var j=0, jl = positions.length; j < jl; j++) {
var start = parseInt(positions[j]),
end = start + length;
for(var x=0, xl = indices.length; x < xl; x++) {
if ( start < indices[x][0] )
break;
}
indices.splice(x, 0, [start, end]);
}
}
return output;
},
EMOJI_CODEPOINTS = {},
emoji_to_codepoint = function(icon, variant) {
@ -316,16 +357,13 @@ module.exports = {
splitIRCMessage: splitIRCMessage,
parseIRCTags: parseIRCTags,
uncompressEmotes: uncompressEmotes,
emoji_to_codepoint: emoji_to_codepoint,
parse_date: parse_date,
number_commas: function(x) {
var parts = x.toString().split(".");
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
return parts.join(".");
},
number_commas: number_commas,
place_string: place_string,
@ -345,6 +383,10 @@ module.exports = {
pluralize: pluralize,
human_number: function(value) {
return HUMAN_NUMBERS[value] || number_commas(value);
},
human_time: function(elapsed, factor) {
factor = factor || 1;
elapsed = Math.floor(elapsed);