From c366daa6943d0f715875e6aebb7f393dda2b78e2 Mon Sep 17 00:00:00 2001 From: rsesek Date: Sun, 21 Aug 2005 04:25:00 +0000 Subject: [PATCH] Some interesting keycode stuff, but we're not going to use it anymore git-svn-id: svn://depot/macosx/trunk/RGB_Converter@9 ad1dcce9-c9fe-0310-b82b-83ea1733dbb0 --- RGB_Converter.wdgt/Widget.html | 6 +-- RGB_Converter.wdgt/Widget.js | 97 ++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+), 3 deletions(-) diff --git a/RGB_Converter.wdgt/Widget.html b/RGB_Converter.wdgt/Widget.html index df553f9..761b627 100644 --- a/RGB_Converter.wdgt/Widget.html +++ b/RGB_Converter.wdgt/Widget.html @@ -28,9 +28,9 @@
-
-
-
+
+
+
diff --git a/RGB_Converter.wdgt/Widget.js b/RGB_Converter.wdgt/Widget.js index 1f08bde..7591682 100644 --- a/RGB_Converter.wdgt/Widget.js +++ b/RGB_Converter.wdgt/Widget.js @@ -9,7 +9,104 @@ || ################################################################### || \*=====================================================================*/ +var fields = { + red : '', + green : '', + blue : '', + hex : '' +}; + // ################################################################### +// watches the three RGB fields to make sure they don't go over the limites +function rgbwatcher(colour) +{ + keycode = event.keyCode; + field = document.getElementById(colour + "inputf"); + + if ((keycode >= 48 && keycode <= 57) || (keycode >= 96 && keycode <= 105)) + { + fields[colour] = intval(fields[colour].toString() + intval(fetch_keycode_val(keycode))); + } + // backspace + else if (keycode == 8) + { + fields[colour] = fields[colour].toString().substr(0, fields[colour].toString().length - 1); + field.value = fields[colour]; + } + else + { + //alert("bad key: " + keycode); + field.value = fields[colour]; + } + + //alert(window.event.keycode); + + + //alert(field.value); +} + +// ################################################################### +// fetches the integer value +function intval(aval) +{ + return aval - 0; +} + +// ################################################################### +// lookup keycode +function fetch_keycode_val(keycode) +{ + switch (keycode) + { + case 48: + case 96: + val = 0; + break; + case 49: + case 97: + val = 1; + break; + case 50: + case 98: + val = 2; + break; + case 51: + case 99: + val = 3; + break; + case 52: + case 100: + val = 4; + break; + case 53: + case 101: + val = 5; + break; + case 54: + case 102: + val = 6; + break; + case 55: + case 103: + val = 7; + break; + case 56: + case 104: + val = 8; + break; + case 57: + case 105: + val = 9; + break; + } + + return val; +} + +// ################################################################### +// ################################################################### +// ################################################################### + // flip data function show_back() -- 2.43.5