Edit File by line
/home/barbar84/public_h.../wp-conte.../themes/twentytw.../assets/js
File: customize-helpers.js
/**
[0] Fix | Delete
* Get luminance from a HEX color.
[1] Fix | Delete
*
[2] Fix | Delete
* @param {string} hex - The hex color.
[3] Fix | Delete
*
[4] Fix | Delete
* @return {number} - Returns the luminance, number between 0 and 255.
[5] Fix | Delete
*/
[6] Fix | Delete
function twentytwentyoneGetHexLum( hex ) { // jshint ignore:line
[7] Fix | Delete
var rgb = twentytwentyoneGetRgbFromHex( hex );
[8] Fix | Delete
return Math.round( ( 0.2126 * rgb.r ) + ( 0.7152 * rgb.g ) + ( 0.0722 * rgb.b ) );
[9] Fix | Delete
}
[10] Fix | Delete
[11] Fix | Delete
/**
[12] Fix | Delete
* Get RGB from HEX.
[13] Fix | Delete
*
[14] Fix | Delete
* @param {string} hex - The hex color.
[15] Fix | Delete
*
[16] Fix | Delete
* @return {Object} - Returns an object {r, g, b}
[17] Fix | Delete
*/
[18] Fix | Delete
function twentytwentyoneGetRgbFromHex( hex ) {
[19] Fix | Delete
var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i,
[20] Fix | Delete
result;
[21] Fix | Delete
[22] Fix | Delete
// Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF").
[23] Fix | Delete
hex = hex.replace( shorthandRegex, function( m, r, g, b ) {
[24] Fix | Delete
return r.toString() + r.toString() + g.toString() + g.toString() + b.toString() + b.toString();
[25] Fix | Delete
} );
[26] Fix | Delete
[27] Fix | Delete
result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec( hex );
[28] Fix | Delete
return result ? {
[29] Fix | Delete
r: parseInt( result[1], 16 ),
[30] Fix | Delete
g: parseInt( result[2], 16 ),
[31] Fix | Delete
b: parseInt( result[3], 16 )
[32] Fix | Delete
} : null;
[33] Fix | Delete
}
[34] Fix | Delete
[35] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function