From 4fd9e0421934284e9bcb3467732650aabf70dbb6 Mon Sep 17 00:00:00 2001 From: Jan <83405332+hoppjan@users.noreply.github.com> Date: Thu, 1 Aug 2024 15:35:36 +0200 Subject: [PATCH] Allow hex input value to have '0x' prefix --- js/uihex.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/js/uihex.js b/js/uihex.js index 4cd93ec..a43b2f2 100644 --- a/js/uihex.js +++ b/js/uihex.js @@ -11,14 +11,14 @@ $(document).ready(function() { }); function processValue(value) { - const hexWithoutHash = (value[0] == '#') ? value.substring(1) : value; + const hexWithoutPrefix = (value[0] == '#') ? value.substring(1) : value[1] == 'x' ? value.substring(2) : value; - if (!validateHexLength(hexWithoutHash)) { + if (!validateHexLength(hexWithoutPrefix)) { clearResults(); return; } - const hexLowercased = hexWithoutHash.toLowerCase(); + const hexLowercased = hexWithoutPrefix.toLowerCase(); const hexFullLength = fullLengthValueForAnalyzing(hexLowercased); const hexFullLengthForDisplay = hexLowercased; @@ -118,4 +118,4 @@ function getColorInt(hex) { const colorValueFractionRounded = Math.round(colorValueFraction * 1000) / 1000; return colorValueFractionRounded; -} \ No newline at end of file +}