Talking about functions as far as understandable

We had to look at another script, which was playing with colors. In a textbox you type a 6 character hexadecimal value of a color and it calculates the inverse of that color. Although it was looking very scary at the first time and I got frustrated I tried to look at the code every day as also talked a lot about. So step by step help I could notice more what the functions are doing. When I typed it first time by myself I really did a mess. So it is good to always have some copies from the script as one can go back again lol...

well here comes the box:

 

Let's talk about. function inverse (the String) is clear. So one has to put into the textfield 6 numbers. If less than 6 or more than 6 the alert box is poping up.

The following a, b, c can also have another name..it is a variable for the 6 places in the string...means first two characters, middle two characters and the two at the end...the a.slice, giv hex bla bla bla I have tried to understand but at the moment it's still confusing. I know it is talking about the colors to change from hex characters to decimal value. But to be honest I have to look more at it to clear in my mind lol.

newColor=DecToHex(255-a)+""+DecToHex(255-b)+""+DecToHex(255-c) now here is talked about to reverse the color

stat.innerHTML=myText this is needed to bring all the html and table and colors inside the body part. so one has to set inside the body a tag with the <DIV id=stat>

var hexbase="0123456789ABCDEF"; is the string with all the hex characters. 

function DecToHex(number) means to convert a decimal (0 to 255) to a hex (0 to FF)

return hexbase.charAt((number>> 4)& 0xf)+ hexbase.charAt(number& 0xf); waaaaa I don't understand anything!!!

function giveHex(s){
s=s.toUpperCase();
staturs=status+s+" "+parseint(s,16)+"  ||| "
return parseint(s,16); 
          is talking about the statusbar...not sure what it means, even I can watch it in the statusbar :)

 

In the form we have a form name what we have declared in the script at the beginning document.rin.reset();        <FORM name=rin>

In the form there is an event handler named onclick...the input name is Luc

 

If you look at the source code here you will not find the names I referred and explained here by talking about, as by trying to understand a bit more I changed some variable names to German ones.

         
back