mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-06-28 15:27:43 +00:00
Refactored colors. Fixed scrolling on mobile. Added image preview on hover.
This commit is contained in:
parent
2bc2b7003b
commit
02b0a95bd0
22 changed files with 2121 additions and 425 deletions
46
src/utils.js
46
src/utils.js
|
@ -19,38 +19,6 @@ var sanitize_cache = {},
|
|||
return num + "th";
|
||||
},
|
||||
|
||||
brighten = function(rgb, amount) {
|
||||
amount = (amount === 0) ? 0 : (amount || 1);
|
||||
amount = Math.round(255 * -(amount / 100));
|
||||
|
||||
var r = Math.max(0, Math.min(255, rgb[0] - amount)),
|
||||
g = Math.max(0, Math.min(255, rgb[1] - amount)),
|
||||
b = Math.max(0, Math.min(255, rgb[2] - amount));
|
||||
|
||||
return [r,g,b];
|
||||
},
|
||||
|
||||
rgb_to_css = function(rgb) {
|
||||
return "rgb(" + rgb[0] + ", " + rgb[1] + ", " + rgb[2] + ")";
|
||||
},
|
||||
|
||||
darken = function(rgb, amount) {
|
||||
amount = (amount === 0) ? 0 : (amount || 1);
|
||||
return brighten(rgb, -amount);
|
||||
},
|
||||
|
||||
get_luminance = function(rgb) {
|
||||
rgb = [rgb[0]/255, rgb[1]/255, rgb[2]/255];
|
||||
for (var i =0; i<rgb.length; i++) {
|
||||
if (rgb[i] <= 0.03928) {
|
||||
rgb[i] = rgb[i] / 12.92;
|
||||
} else {
|
||||
rgb[i] = Math.pow( ((rgb[i]+0.055)/1.055), 2.4 );
|
||||
}
|
||||
}
|
||||
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) {
|
||||
|
@ -221,11 +189,6 @@ module.exports = {
|
|||
|
||||
emoji_to_codepoint: emoji_to_codepoint,
|
||||
|
||||
get_luminance: get_luminance,
|
||||
brighten: brighten,
|
||||
darken: darken,
|
||||
rgb_to_css: rgb_to_css,
|
||||
|
||||
parse_date: parse_date,
|
||||
|
||||
number_commas: function(x) {
|
||||
|
@ -252,6 +215,15 @@ module.exports = {
|
|||
}
|
||||
return m;
|
||||
},
|
||||
|
||||
quote_attr: function(attr) {
|
||||
return (attr + '')
|
||||
.replace(/&/g, "&")
|
||||
.replace(/'/g, "'")
|
||||
.replace(/"/g, """)
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">");
|
||||
},
|
||||
|
||||
date_string: function(date) {
|
||||
return date.getFullYear() + "-" + (date.getMonth()+1) + "-" + date.getDate();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue