topical media & game development

talk show tell print

graphic-javascript-effect-style-assist-effect.htm / htm



  
  <!-- TWO STEPS TO INSTALL COLORASSIST:
  
    1.  Copy the coding into the HEAD of your HTML document
    2.  Add the last code into the BODY of your HTML document  -->
  
  <!-- STEP ONE: Paste this code into the HEAD of your HTML document  -->
  
  <HEAD>
  
  <SCRIPT LANGUAGE="JavaScript">
  
  <!-- This script and many more are available free online at -->
  <!-- The JavaScript Source!! http://javascript.internet.com -->
  <!-- Original:  Ryan Sokol (apps@logicode.net) -->
  <!-- Web Site:  http://www.logicode.net -->
  
  <!-- Begin
  function showBGColor()
  {
    if(document.clrForm.bgRandom.checked == true)
      document.bgColor = document.clrForm.bgColor.value = getRandom();
    else
    {
      if(document.clrForm.bgColor.value.search(/^#[a-f0-9]{6}/ig) == -1)
        alert('Invalid background color');
      else
        document.bgColor = document.clrForm.bgColor.value;
    }
  }
  function showTXTColor()
  {
    if(document.clrForm.txtRandom.checked == true)
      txtChg.style.color = document.clrForm.txtColor.value = getRandom();
    else
    {
      if(document.clrForm.txtColor.value.search(/^#[a-f0-9]{6}/ig) == -1)
        alert('Invalid font color');
      else
        txtChg.style.color = document.clrForm.txtColor.value;
    }
  }
  var pool = new Array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F");
  function getRandom()
  {
    var clr = '';
    for(i=0; i<6; i++)
    {
      num = Math.round(Math.random() * (pool.length-1));
      clr += pool[num];
    }
    return '#'+ clr;
  }
  function saveColor(field)
  {
    if(field == "bgColor")  // bgColor field
      opt = document.clrForm.bgColor.value.toUpperCase();
    else // txtColor field
      opt = document.clrForm.txtColor.value.toUpperCase();
    if(opt != '')
    {
      i = document.clrForm.saveList.options.length;
      for(j=0; j < i; j++)
      {
        if(document.clrForm.saveList.options[j].value == opt)
          return;
      }
      document.clrForm.saveList.options[i] = new Option(opt, opt);
      document.clrForm.saveList.selectedIndex = i;
    }
  }
  function putColor(field)
  {
    if(field == "bgColor")  // bgColor field
    {
      if(document.clrForm.saveList.selectedIndex >= 0)
      {
        document.clrForm.bgRandom.checked = false;
        document.clrForm.bgColor.value = document.clrForm.saveList.options[document.clrForm.saveList.selectedIndex].value;
        showBGColor();
      }
    }
    else // txtColor field
    {
      if(document.clrForm.saveList.selectedIndex >= 0)
      {
        document.clrForm.txtRandom.checked = false;
        document.clrForm.txtColor.value = document.clrForm.saveList.options[document.clrForm.saveList.selectedIndex].value;
        showTXTColor();
      }
    }
  }
  //  End -->
  </script>
  
  </HEAD>
  
  <!-- STEP TWO: Copy this code into the BODY of your HTML document  -->
  
  <BODY>
  
  <div align="center">
  <form name="clrForm">
  <table bgcolor="white" border="1">
  <tr>
    <td align="left" valign="top"><font face="verdana" size="-1">
      <b>Background Color:</b><br>
      <input type="text" name="bgColor" value="#FFFFFF" size="8" maxlength="7" onkeyup="document.clrForm.bgRandom.checked=false;">
      <input type="button" name="addBG" value="save ->" onclick="saveColor('bgColor');"><br>
      <input type="checkbox" name="bgRandom"> random<br>
      <input type="button" value="Display" onclick="showBGColor()">
      </font>
    </td>
    <td align="center" valign="top"><font face="verdana" size="-1">
      <b>Saved List:</b><br>
      <select name="saveList" size="2">
      </select><br>
      <input type="button" name="fillBG" value="<- put" onclick="putColor('bgColor');">
      <input type="button" name="fillTXT" value="put ->" onclick="putColor('txtColor');">
      </font>
    </td>
    <td align="right" valign="top"><font face="verdana" size="-1">
      <b>Font Color:</b><br>
      <input type="button" name="addTXT" value="<- save" onclick="saveColor('txtColor');">
      <input type="text" name="txtColor" value="#000000" size="8" maxlength="7" onkeyup="document.clrForm.txtRandom.checked=false;"><br>
      <input type="checkbox" name="txtRandom"> random<br>
      <input type="button" value="Display" onclick="showTXTColor()">
      </font>
    </td>
  </tr>
  </table>
  <h2 id=txtChg align=center>Make your choices above</h2>
  </form>
  </div>
  
  <p><center>
  <font face="arial, helvetica" size"-2">Free JavaScripts provided<br>
  by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
  </center><p>
  
  <!-- Script Size:  4.57 KB -->
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.