Fix Javascript bug in colour palette

This commit is contained in:
Talia 2020-09-29 16:47:58 +02:00
parent 3b21844d74
commit a4ac07de22

View file

@ -205,7 +205,7 @@
window.addEventListener("load", function() { window.addEventListener("load", function() {
document.querySelectorAll('div.colors span').forEach(function(span) { document.querySelectorAll('div.colors span').forEach(function(span) {
span.addEventListener('click', function(event) { span.addEventListener('click', function(event) {
let prop = name => getComputedStyle(event.target).getPropertyValue(name) let prop = name => getComputedStyle(event.target).getPropertyValue(name).replace(/^ *| *$/g, "")
let hsla = `hsla(${prop("--hue")}, ${prop("--saturation")}, ${prop("--lightness")}, 1)` let hsla = `hsla(${prop("--hue")}, ${prop("--saturation")}, ${prop("--lightness")}, 1)`
navigator.clipboard.writeText(hsla).then(function() { navigator.clipboard.writeText(hsla).then(function() {
show_message(`Copied to Clipboard:<br>${hsla}`, hsla, event.clientX, event.clientY); show_message(`Copied to Clipboard:<br>${hsla}`, hsla, event.clientX, event.clientY);