From 6eaba79357d780e703192fb8a73c117987365ad5 Mon Sep 17 00:00:00 2001 From: rsesek Date: Wed, 14 Mar 2007 23:58:28 +0000 Subject: [PATCH] Allow RGB triads to be pasted in any of the R-G-B fields git-svn-id: svn://depot/macosx/RGBConverter/trunk@621 ad1dcce9-c9fe-0310-b82b-83ea1733dbb0 --- RGB Converter.wdgt/Widget.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/RGB Converter.wdgt/Widget.js b/RGB Converter.wdgt/Widget.js index 57e95db..3319f34 100644 --- a/RGB Converter.wdgt/Widget.js +++ b/RGB Converter.wdgt/Widget.js @@ -39,6 +39,19 @@ function rgbwatcher(colour) { field = document.getElementById(colour + "inputf"); + // handle RGB triads + if (triad = field.value.match(/(rgb)?\(([0-9]{1,3}),\s?([0-9]{1,3}),\s?([0-9]{1,3})\)/)) + { + document.getElementById("redinputf").value = triad[2]; + document.getElementById("greeninputf").value = triad[3]; + document.getElementById("blueinputf").value = triad[4]; + + rgbwatcher("red"); + rgbwatcher("green"); + rgbwatcher("blue"); + return; + } + // sanitize the number var newval = field.value.replace(/[^0-9\-\.]*/g, ""); newval = Math.floor(newval); -- 2.43.5