JavaScript

JavaScript is not related to the Java language. It some ways, it has more similarities to other shell scripts like POSIX Shell and BASH. It falls into the interpreted languages group. This page will have the following sections:

  1. Imbedded in HTML
  2. Shell Script JavaScript
  3. React JavaScript Library

The Standalone section will double as the Eclipse JavaScript section.

Imbedded in HTML

JavaScript is the default scripting language of HTML. If there is something that you want an item to do on an html page, then you use JavaScript. For example, changing the text color for a button label.

The color being displayed is represented by the following number:

#000000

The code for this is as follows (as a side note, if you are using a WordPress editor, once you have scripts or example scripts like what follows, DO NOT switch back to Visual mode from Text mode, or else all your indent formatting will be lost and the function in the “script” will be all condensed into a single line. Also, when I did this the JavaScript call was deleted from the button description. It is hard to do any maintenance on the code then):

<input id="changeColor" type="button" value="Change Color" onclick="setButtonColor();" />

The color being displayed is represented by the following number:

<a id="demo">#000000</a>
<script>
function setButtonColor() {
    var color=0;
    switch (Math.floor((Math.random() * 6) + 1)) {
      case 1:
        color='#FF0000';
        break;
      case 2:
        color='#00DD00';
        break;
      case 3:
        color='#0000DD';
        break;
      case 4:
        color='#DDDD00';
        break;
      case 5:
        color='#00FFFF';
        break;
      case 6:
        color='#000000';
        break;
}
document.getElementById("changeColor").style.color = color;
document.getElementById("demo").innerHTML = color;
}
</script>

Shell Script JavaScript

I am using Eclipse to create these examples. I will be using this section to both discuss stand-alone scripts and the Eclipse Development Environment.

React JavaScript Library

React is one of the more commonly used JavaScript Libraries. As I learn it, I will add more information here.