Archive for August 2009

Forums Added to Site

Not that there’s much to talk about here yet, but I added some forums to the site.  Hopefully things will get a bit more interesting around here when I announce my next project…

Leapster Crisis

The Leapster 2 is a great hand held electronic game designed for preschoolers.  My 3 year old son loves his – he can operate it by himself, including changing the cartridges.  We had a bit of a crisis when the touch screen mysteriously stopped working.  Fortunately, it turned out that the touch screen just needed to be recalibrated. To recalibrate the touch screen on a Leapster 2, just use the following steps:

  1. Ensure that a cartridge is not inserted into the Leapster.
  2. Hold down the Hint button (labelled with a “?”) while powering on the Leapster. This will bring up a menu of options.
  3. Press A (”Touch Calib”) this will start the touch screen calibration process. “Starting touch calibration” will appear on the screen briefly followed by a black screen with a white cross in the upper left corner.
  4. Touch the cross that appears with the stylus pen. When you touch it, the cross will change to 4 dots and then a new cross will appear on the screen. Repeat this process for 5 crosses total – one in each corner and one in the middle.
  5. Turn the Leapster off and back on again. The touch screen should now be working again.

Installing and Running the eHow Earnings Tracker

To install the eHow Earnings Tracker, click on this link.  That will take you to the following page:

install1

Because the add-on hasn’t yet gone through the approval process to make it public, you need to check the box next to “Let me install this experimental add-on”.  That will enable the “Add to Firefox” button:

let me install

Click on “Add to Firefox” and you will be taken to the “please donate” page:

roadblock

Once again, click on the checkbox and then “Add to Firefox”.  That will take you to the end user license agreement:

license agreement

Click on “Accept and Install” and you will get the Software Installation dialog:

install dialog

Click on “Install Now” and the tracker will be installed.  After installation, you will be prompted to restart Firefox:

restart

Click on “Restart Firefox”.  After Firefox restarts, you should see a dialog box telling you that the tracker was installed:

add on has been installed

The eHow Earnings Tracker has now been installed, so close the dialog box show above and log onto your eHow account.  Go to “My Profile” and then click on the “Articles” tab:

ehow page

Now you can run the tracker by going to Tools – eHow Earnings Tracker – Update Earnings or by right-clicking somewhere on the page:

tracker menu

You should see the screen flash a few times as the tracker navigates through your article library.  When the tracker is finished, it will open a new window with your earnings data in it:

tracker run

eHow Earnings Tracker Version 1.0.1 Available

Version 1.0.1 of the eHow Earnings Tracker is available on the downloads page.  This version has all of the major functionality that I had planned.

Changes since 0.4.0:

*==> Version 1.0.1 (August 5, 2009)

* Fixed bug with Tracker not working if the Windows user name had an apostrophe in it

*==> Version 1.0.0 (August 3, 2009)

* Added ability to toggle table display between earnings and views

*==> Version 0.6.0 (August 2, 2009)

* Added column sorting
* View table still gone, will be coming back soon!

*==> Version 0.5.0 (July 30, 2009)

* Added ability to select a date range
* Views table is gone, will return next version

Using the JavaScript Date Object

Since this is my first JavaScript blog post, I need to take a moment to recommend this book:

As far as I’m concerned, this is the JavaScript book to get.  It explains the language at a level of detail that you simply won’t find reading online tutorials and samples.  It covers everything from basic language syntax to AJAX.  It has sections on regular expressions, XML, DOM scripting, and client-side graphics.  It also has great reference sections for the various JavaScript objects: Date, Array, Number, etc.  I am constantly referring to it whenever I’m programming in JavaScript.

Anyway, the purpose of this post is to show a couple of neat things that I discovered about the JavaScript Date object that aren’t readily apparent from most of the samples and tutorials that you’ll find.  w3schools.com has a pretty good Date object reference if you need one.

One thing that you need to keep in mind when dealing with the JavaScript Date object is that the integer value for months is 0 based, not 1 based.  This means that January = 0, February = 1, etc.  For example, the following code:

var today = new Date();  // Creates a date object set to the current date and time
alert( today.toDateString() + "\nMonth integer = " + today.getMonth());

Will show the following message:

dateinteger

What’s really cool about the JavaScript Date object is that it does date math for you.  For example, we could set a date object to be January 1, 2009 and subtract 7 days from it:

var jan1_2009 = new Date(2009, 0, 1);  // Creates a date object set to the January 1, 2009
var oneWeekBefore = new Date(2009, 0, 1 - 7);  // Creates a date object set to the January 1, 2009 minus 7 days

alert("One week before " + jan1_2009.toDateString() + " is " + oneWeekBefore.toDateString());

var oneWeekBefore2 = new Date(2009, 0, 1);  // Creates a date object set to the January 1, 2009
oneWeekBefore2.setDate( oneWeekBefore2.getDate() - 7);  // Subtract 7 days

alert("One week before " + jan1_2009.toDateString() + " is " + oneWeekBefore.toDateString());

Both alerts in the code above would show the following:

oneweekdate

You can also use the Date object to figure out how many days are in a given month.  This is particularly useful for determining how many days are in February for a given year.  When you create a Date object with a year, month, and a day of 0 then Date object automatically sets itself to the last day of the previous month.  Remembering that month integers are zero based:

var day = new Date(2009, 2, 0);  // Sets the date to the 0th day in March, which is the last day in February.

alert(day.toDateString() + " : February of 2009 has " + day.getDate() + " days.");

This will display:

daysinmonth