473,799 Members | 3,329 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

My color selector.

Just about finished with an include modual that allows a user to select
a color. Completely dynamic. all you have to do is include the script and
run the main trigger script.

One problem with the event modual is the fact that it resets events for all
TD's. not sure how to specify to cascade down through just the created
table. Any ideas?

Feel free to use this where ever you wish as long as you give me credit.
this was a few weeks of work to tweek correctly. Hopefully this makes up for
my poor menu from earlier. lol!

URL: http://www.shadowdruid.com/colors.html

Matthew Hagston
Jul 23 '05 #1
15 2346
Ok, found the event problem and fixed / uploaded it. Still want to know
what you all think. Works in IE, NS7.2, and FireFox 0.9.3. Having an issue
with opera (of course). where it's not displaying the second "fine" selector
table. Bleh, always Opera.

-Matthew Hagston

<Ma************ @cox.net> wrote in message
news:Tzhhd.2703 $931.803@lakere ad01...
Just about finished with an include modual that allows a user to select
a color. Completely dynamic. all you have to do is include the script and
run the main trigger script.

One problem with the event modual is the fact that it resets events for
all TD's. not sure how to specify to cascade down through just the created
table. Any ideas?

Feel free to use this where ever you wish as long as you give me credit.
this was a few weeks of work to tweek correctly. Hopefully this makes up
for my poor menu from earlier. lol!

URL: http://www.shadowdruid.com/colors.html

Matthew Hagston

Jul 23 '05 #2
Ma************@ cox.net wrote:
Ok, found the event problem and fixed / uploaded it. Still want to know
what you all think. Works in IE, NS7.2, and FireFox 0.9.3. Having an issue
with opera (of course). where it's not displaying the second "fine" selector
table. Bleh, always Opera.


Move the div below the table, or, off to the side. It causes the page to
jump when the GO button is clicked.

Instead of the repeated lookups of the bgcolor, use a variable to hold
it and then use the variable. Its a very minor issue in that script but
as scripts get larger, it can become important.
--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq
Jul 23 '05 #3
Ma************@ cox.net wrote:
Ok, found the event problem and fixed / uploaded it. Still want to know
what you all think. Works in IE, NS7.2, and FireFox 0.9.3. Having an issue
with opera (of course). where it's not displaying the second "fine" selector
table. Bleh, always Opera.

[...]

You still have an issue with Safari too - I'm not sure what it is, I'll
let you know if I find out.

Fred.
Jul 23 '05 #4
rf
Ma************@ cox.net wrote:
URL: http://www.shadowdruid.com/colors.html


It seems a little, er, broken.

I select a nice shade of yellow on the left. The right bit changes (rightly)
to a luminance scale in that colour. When I click on the right I get a
colour. When I click on the right again, the right actually changes colour.

I expected it to remain the same but just give me different colours out of
the luminance scale with different click selections.

After several clicks all colour is gone, I am left with a greyscale.

Ah, I know... clicking on the right side causes another colour pick, which
rebulds the right, like this: click on a colour on the left. Click on the
right, either at the top or the bottom. Right changes.

--
Cheers
Richard.
Jul 23 '05 #5
Would be appriciated if ya get it working in Safari too. I don't have a
way to test it, have access to school computers but alas, no time working &
school both full time. Fixed the opera problem late last night. apparently
it wanted width & height declared. Next version will try to migrate most of
it into style sheets so that it can be changed/reformated easier. Oh, and
that div, should be gone. was just there for testing anways. Put the whole
table inside a div so that it could be moved, formated & hidden easily.
Don't think it was nessisary, but may make it easier for some to use.

Yes, if you keep clicking the right hand 'fine tuning' color bar it will
re-display itself. Still wondering if i should keep that in or not, But it
seems to be good for when you want to select a greyscale color as the main
color pallet the grey's are kind of hidden everywhere.

--
Matthew Hagston
Hungates Creative Toys and Hobbies
ma************@ hungates.com ........ http://www.hungates.com
"Fred Oz" <oz****@iinet.n et.auau> wrote in message
news:41******** *************** @per-qv1-newsreader-01.iinet.net.au ...
Ma************@ cox.net wrote:
Ok, found the event problem and fixed / uploaded it. Still want to know what you all think. Works in IE, NS7.2, and FireFox 0.9.3. Having an issue with opera (of course). where it's not displaying the second "fine" selector table. Bleh, always Opera.

[...]

You still have an issue with Safari too - I'm not sure what it is, I'll
let you know if I find out.

Fred.

Jul 23 '05 #6
Matthew Hagston wrote:
Would be appriciated if ya get it working in Safari too. I don't have a

[...]

Hey, I solved the Safari issue and can offer a couple of
significant enhancements to reduce processor effort.

*The Safari Issue:*

When you create an empty TD in safari and attach a mouseover event,
the area over which you must hover is about 1px high and as wide as the
cell. It seems to be aligned about where the baseline for text would
be. If you put text into the cell, whenever you are over the text then
the TD onmouseover function will not work, so the area that reacts to
the onmouseover is reduced even further.

One issue I can't fix is that when putting the colour into the showClr
cell, I can't get it to reliably fill the cell when clicking on the
table, but when I click the "Go" button it works fine or if I do
anything to cause the window to re-draw - resize window but not scroll.

To make the onmouseover area inside a TD be the entire cell height,
put a div inside the cell the same size as the cell. I couldn't get
bgColor to work on the div, so I left it to color the cell, the result
is the same (a coloured in cell). The relevant part of your code
becomes something like:

oTd = document.create Element("TD");
oTd.width = "4px";
oTd.height = "4px";
oTd.bgColor = "#"+ tmpar1[y];
oTd.border = "0px";
oTd.padding = "0px";
oDiv = document.create Element("DIV");
oDiv.style.widt h = "4px";
oDiv.style.heig ht = "4px";
oDiv.id = tmpar1[y];
oTd.appendChild (oDiv);
oTr.appendChild (oTd);

Note you must use .style with the width and height, but not with the
TD (maybe someone else can answer that one). Also, the id gets put
onto the DIV so you can get the rgb (id) value from that, not the
bgColor.

You must attach the onmouseover to the DIV (the firstChild of the td):

x[i].firstChild.onm ouseover = color_over;
x[i].firstChild.onm ouseout = color_out;
x[i].firstChild.onc lick = ChangeColorSele ct;

Of course, all that may be too much effort...

One significant optimisation I can offer is in the way you get the id
of the cell for the onmouseover, onmouseout and onclick events:

e.g.

function color_over(e) {
targid = (ie)?window.eve nt.toElement.id :e.target.id;
clr = document.getEle mentById(targid ).bgColor;
clr = clr.substr(1);
document.getEle mentById('color sel').value = clr;
}

*Enhancement 1*
Can be signficantly enhanced by creating a global variable that refers
to 'colorsel', then you only have to get a reference for it once and do
not need to do getElementById every time the mouse enters a cell (an
increadible waste of processor power).

*Enhancement 2*
Probably greater enhancement is to change the way you use the reference
to the cell (e.target) to get the id, just so you can use
getElementById to get the reference to the cell that you already had!!

So do this:

// Just after calling InitColorPalett e();
// create a global ref to the colorsel text box

colorSel = document.getEle mentById('color sel');

// Then change color_over to:

function color_over(e) {
if (ie) {
// do whatever IE needs
} else {
colorSel.value = e.target.id;
}
}

Of course you still need to handle IE (maybe, I didn't test) but at
least for all other browsers the work is hugely reduced.

You can make similar changes to wherever you have used e.target then
getElementById.

That's it for me, I think there are a few bugs with Safari 1.0.3 (comes
with OS X 10.2.8), I'll leave it now until I can test the latest
version with OS X 10.4.

Cheers, Fred.



Jul 23 '05 #7
Matthew Hagston wrote:
Would be appriciated if ya get it working in Safari too. I don't have a

[...]

It seems your .bgColor should be .style.backgrou ndColor - it certainly
works for Safari (scratch one maybe-bug). Check here:

<URL:http://www.mozilla.org/docs/dom/domref/dom_style_ref.h tml>
Jul 23 '05 #8

"Fred Oz" <oz****@iinet.n et.auau> wrote in message
news:41******** *************** @per-qv1-newsreader-01.iinet.net.au ...
Matthew Hagston wrote:
Would be appriciated if ya get it working in Safari too. I don't have
a [...]

It seems your .bgColor should be .style.backgrou ndColor - it certainly
works for Safari (scratch one maybe-bug). Check here:

For TD's I believe it should be bgColor. not referencing the style, just
the TD itself. Haven't checked that with w3c references yet though. putting
a DIV inside the TD to do the mouse-overs one would have to use
style.backgroun dColor anyways so one fix kind of self-corrects the next bug.
Don't have time to write the fix at the moment, have some other changes in
mind to do at the same time. Specifically something that allows you to show
less colors in the primary window. the 34x32 is kind of intensive for some
computers it seems.
<URL:http://www.mozilla.org/docs/dom/domref/dom_style_ref.h tml>

Jul 23 '05 #9
Matthew Hagston wrote:
Would be appriciated if ya get it working in Safari too. I don't have a

[...]

After quite a bit of playing, I can further recommend:

1. You use style.backgroun dColor everywhere instead of .bgColor

2. Set all backgrounds as rgb(r,g,b) values

3. You do not need to set or read the id of any table cells to get
their colour, just refer directly to style.backgroun dColor. You only
need the id of the cells that you want to write to, everything else
just grabs the backgroundColor . If you set the background using
rgb(...) IE will return rgb(...), Firefox will return rgb(...) whether
you use rgb(...) or #rrggbb.

4. Modify functions as follows:

colorSel = document.getEle mentById('color sel');

function color_over(e) {
colorSel.value = (ie)?
window.event.to Element.style.b ackgroundColor :
e.target.style. backgroundColor ;
}

function color_out(e) {
colorSel.value = "";
}

Do similar to all other places where you read the id to get the
background colour.

All tested in IE and Firefox. I can supply full working code if you
like, but I'll need a couple of hours to test in Safari first (and
re-apply the DIV fix if still needed).

Cheers, Fred.
Jul 23 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2117
by: John Rowe | last post by:
I run the web site for a University department. A few of my authors will carefully write: <h3>Title</h3> <p>Some text here.</p> <p>Second paragraph.</p> Most of us can't be bothered(!): <h3>Title</h3>
0
3646
by: Patrick | last post by:
I'm working on a contact management application, and need a hand with one aspect... Here's what I want to create: ------------------------------------ A form split into two parts. There is a datagrid on the left side that lists names and perhaps a couple of other key fields. The user can click on a record in the datagrid, which should automatically pull up details on that record in the various text boxes and other controls on the right...
8
2339
by: sajid | last post by:
The CSS 2.1 Specification describes how to sort a list of selectors in order of specificity, but it doesn't provide a method to calculate the specificity of a single selector in isolation. I've devised a method to do this, which I describe in the following article: http://calculating-css-selector-specificity.blogspot.com/ Comments and/or criticisms welcome.
3
1939
by: JakDaniel | last post by:
is it possible, create a selector as alias of another selector... (maybe) in another stylesheet file? ex: html page .... <link rel="stylesheet" type="text/css" href="style1.css" /> <link rel="stylesheet" type="text/css" href="style2.css" /> ....
3
2009
by: RobG | last post by:
The link below is to a CSS selector test suite that tests 6 popular libraries: <URL: http://ajaxian.com/archives/slickspeed-css-selector-testsuite It might be of interest to some. -- Rob
0
10485
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10231
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10027
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9073
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7565
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.