02.06.2013 Views

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

Pro PHP and jQuery by Jason Lengstorf.pdf - Computer Science ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

146<br />

CHAPTER 4 ■ BUILD AN EVENTS CALENDAR<br />

Figure 4-4. The heading <strong>and</strong> weekday abbreviations<br />

Building the Calendar<br />

The next step is to build the actual calendar days. Several steps need to be completed for this to work<br />

out:<br />

1. Create a new unordered list.<br />

2. Set up a loop (with an iteration counter, a calendar date counter, today’s date,<br />

<strong>and</strong> the month <strong>and</strong> year stored as variables) that runs as long as the calendar<br />

date counter is less than the number of days in the month.<br />

3. Add a fill class to the days of the week that occur before the first.<br />

4. Add a today class if the current date is contained within the same month <strong>and</strong><br />

year <strong>and</strong> matches the date being generated.<br />

5. Create an opening <strong>and</strong> closing list item tag for each day.<br />

6. Check if the current calendar box falls within the current month, <strong>and</strong> add the<br />

date if so.<br />

7. Check if the current calendar box is a Saturday, <strong>and</strong> close the list <strong>and</strong> open a<br />

new one if so.<br />

8. Assemble the pieces of the list item <strong>and</strong> append them to the markup.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!