Skip to content

Commit

Permalink
Allow hex input value to have '0x' prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
hoppjan authored Aug 1, 2024
1 parent c97e8e4 commit 4fd9e04
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions js/uihex.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -118,4 +118,4 @@ function getColorInt(hex) {
const colorValueFractionRounded = Math.round(colorValueFraction * 1000) / 1000;

return colorValueFractionRounded;
}
}

0 comments on commit 4fd9e04

Please sign in to comment.