Monday, September 23, 2013

Rock, Paper, Scissors, Lizard, Spock is live!

I just posted my RPSLS game on my site at www.alexismy.name.

Blogger won't let you run live scripts, so I hosted it myself. It's written in HTML, jQuery and CSS. I'm new to jQuery but so far it's amazingly powerful.

Here some of the things that I learned along the way:

jQuery
$("#foo").text("<span>Text goes here!</span>");
This result in that exact text being entered into the element with ID foo, the html tags won't be read as html, just printed as text. Not good. The .append( ) method didn't seem to help either.

To get HTML tags to render properly you need to use the .html( ) method, like so.
$("#foo").html("<span>Text goes here!</span>");
This got me part of the way there, but i didn't want to replace everything.

One thing to be aware of is the .html( ) method will replace all of the HTML in an element. This is fine if all you want to do is update the element. If you want to add to the existing HTML you'll need to retrieve the existing html, add you new code and then feed it back into the element.

var existingText = $("#foo").html();
$("#foo").html(existingText + "<span>Text goes here!</span>");
This will append your HTML to the existing html.

CSS

When users click a button to select a choice, the border changes to blue. The computer choice is indicated in red.
.choice .selected {
color:grey;
background-color:white;
border:solid 2px blue;
}
.choice .comp {
color:grey;
background-color:white;
border:solid 2px red;
}

But if there's a tie I wanted a different boarder, green in this case. If you want multiple selectors at the same level the following doesn't work.

.choice .comp .selected {
background-color:yellow;
border:solid 2px green;
}
This looks for the "choice" class, moves down one level and looks for the "comp" class, moves down another level and looks for the "selected" class. The problem is the "comp" and "selected" classes are both direct children of the "choice" class. Here's how it's solved.

.choice .comp.selected {
background-color:yellow;
border:solid 2px green;
Remove the space between ".comp" and  ".selected", this tells CSS (and jQuery) that they are on the same DOM level.

A simple game, but jQuery is outstanding. I'll finish up the try.jQuery.com prep-work today. The next step will be to dig into C# and the .Net framework.

T-minus 26 days

Here's the game in case you missed it the first time.

Monday, September 16, 2013

Web Pre-Work

I gave my notice today. Sad to go, but excited to see what's next and take on a new challenge. My nerves are starting to pick up a little bit.

I've finished the HTML and CSS courses on CodeAcademy. I've done some web design so it was a nice review. It filled in some gaps regarding tables. I like that HTML5 has simplified the DOCTYPE declaration.

I'm about half-way through with the JavaScript section. I've never worked in JavaScript before, it's syntax feels a lot like PHP.

I'm excited to get to jQuery. I'd like to write a simple rock, paper, scissors, lizard, Spock game with clickable icons and a score board. I need the DOM manipulation in jQuery to manipulate the HTML to get this going.

Haven't started the C# yet. My books should arrive from Amazon tomorrow. 6 hours on a plane this Friday to get started working through them. Fingers crossed for an in-seat power plug.

T-minus 34 days

-Alex


Friday, September 13, 2013

I'm in! Let the building begin!

It's time to get started. There are things to build, code to write, and bugs to fix.

The transition will be bitter sweet. I'll be leaving many wonderful and inspiring people at my current job. It's time to move forward though.

There are several projects I've been working that are the start of a portfolio. I'll provide updates as I formalize it and I have more completed to show.

Portfolio
The first project is a reminder program for professional licenses.

The program downloads a CSV file from the web and checks it against an internal database. If changes have been made the internal database is updated and an email is sent congratulating them on renewing. If they need to renew but haven't it sends several reminder emails. I think 30, 10, 5 and 2 days are appropriate. Also an expiration notice email will go out.

Learning the tools
I need to transition over to the tools I'll be working with at camp. I've installed Visual Studio but I need to get comfortable with C# and moving around in my dev environment before camp. Let the refactoring begin!

I have a functioning (early) alpha written in Ruby. My internal 'database' is another CSV at this point. I'll eventually transition that over to SQL. Since I'll be working in C# I'm going to refactor the code as is into C#.

T-minus 37 days!