Intro
Projects
Portfolio
Anyway, creating a random color generator took a little bit of actual programming to make. I stored all the hexadecimal values (letters A-F and numbers 0-9) in an array, and then created a loop that ran six times, each time generating a random number from 0-15 which drew that same-numbered element out of the array. A little concatenation later, and we have a random hexadecimal color. Here's the code:
var letters = ["A", "B", "C", "D", "E", "F", 1, 2, 3, 4, 5, 6, 7, 8, 9];
function getColor() { "use strict"; var j, first, newcolor = "#"; for (j = 0; j < 6; j++) { first = Math.floor(Math.random() * letters.length); newcolor += letters[first].toString(); } return newcolor;}It's pretty simple, and the
"use strict"; is a variant of JS that is used to restrict JS in the browser. It affects arguments, how variables are used, basic semantics, and converts mistakes (like mistyped variables) into errors in the IDE or browser. This method is called in the jQ file that changes backgrounds, borders, and displays when each of the buttons are clicked.Finally, a chance to mention Brackets - this is my IDE for JS, HTML, and CSS (I use TextPad and DrJava for Java). It's written in HTML and CSS, and offers a great deal of functionality. It has live editing, multiple file views, awesome plugins like JSLint, Emmet, Markdown editors (useful for Github; this editor also has Github flavored markdown as a language option), and tons of great themes that are readily available.
/rant
After all this, I wrote a bunch of jQ to make sure everything changed colors correctly, everything faded correctly, and (the best part) added animations to the hover menu. AND BUTTONS - a sexy amount of buttons.
The Date Time
switch() statement to assign each day or month name a time and place to change. Then, I wrote this little diddysetInterval(function () {getTime(); makeMonths(); }, 1000);which says that each method (which calculate the date/time from the
Date() object and displays it and the switch() for assigning days and months, respectively) will be called every second. This is only necessary for the getTime() function, as that's the only one that calculates seconds.This was a nice project to work on and really fun to do (albeit a bit tedious at times) and I'd do it again for something even cooler.



