Reusable Calendar Project Update 4
Summary
Added the pre-Oct 1582 restriction on the reusable calendar. (Working version, Update 4 version)

Essentially, the addition from Update 3 is the function checkRestraint(), where it checks the date being dragged or clicked on to see if it should be set to Oct 1582 or let it be.
I also used the checkRestraint() function to make the cursor look normal when the mouse is over a date that should not be available, even though they can click on it, but it would just move to Oct 1582.
Check it out and let me know if it the functions don’t work properly or intuitively.
Read the rest of this entry »
Calendar Strips Drag on a Grid
Summary
I isolated the dragging portion of update 3 of the reusable calendar project to show what options under the draggable jQuery UI to use.

In the draggable() function, I used the grid: [0, 15] to restrict its movement to 15 px vertical, then I used containment: [0, y1, 0, y2], where y1 is the offsetTop value of the strip itself when it’s at the last month/digit, and y2 is at the first month/digit, to restrict its range so the strip won’t go past the first and last value.
Reusable Calendar Project Update 3
Summary
Adding more functionalities to the date display to the reusable calendar. Now you can click on the months or year digits, or you can drag the strips to change the date. (Before, you can only click on the arrows move forward or backward one month at a time.)

This dragging function was made easily possible by the jQuery UI. It takes a lot of the grunt work out of the process.
Notes
The current range is Jan 1000 to Dec 9999. But technically, the calendar doesn’t apply before October 15, 1582, since that’s when the Gregorian calendar was first adopted. So I will add that restriction in the next or upcoming updates.
Reusable Calendar Project Update 2
Summary
A work-in-progress update of the reusable calendar project I introduced last time where the frame that goes around the dates of the month moves instead having a different layout for each month.
In this update, the basic functions are added to the arrows. When the arrows are clicked, the script updates the new month and year in the background and updates the date display and calendar frame and cross-outs strips with jQuery animation.
Currently, the calendar can only move by pressing the arrows, month by month. The next stage will involve the ability to click on the month and year digits to jump to a different month, year, decade, century, or millennium.
Notes
I didn’t think the project would work so smoothly so far. I guess a lot of planning and thinking ahead pays off. But the next stage might be a bit tricky, since there will probably be a lot more things to manage with the individual month and year digits being clickable.
You may see the ongoing version that changes and is added upon as time goes on.
Reusable Calendar Project Update 1
I mentioned in my latest monthly update on Flush that I am working on a special calendar that I will hopefully display on the home page of the website when it’s all done. Here is a screenshot of the basic set up I have so far:

It might look a bit complicated, but the concept is delightfully simple (to me at least). I will probably explain more in detail later on, but basically, the idea is that with the set up on the left, you can generate any layout of the month we see in practically all calendars in the world.
Displaying Images from Any Directory
Summary
Use PHP to retrieve image files from a directory and display them without knowing what the image file names are. This builds on the getimagesize() function I demo’d before.
I’m doing this so I can place images in a directory from which I can pull out to display in a slideshow on the home page and maybe the Archives section.
The demo here is only for a more procedural method to do it; for practicality’s sake, I would merge the two steps into one and probably put all of it into a function so I can retrieve an array of image file names just by providing the directory I want the server to look in.
What I Learned
If the web page is not in the same directory of the images, the opendir(), filetype(), and getimagesize() functions take the address of the directory in the parameter with $_SERVER['DOCUMENT_ROOT'] and then the directory from your domain, and not the uri’s (which start with “http://”).
Site Header Defaults
Summary
Collecting and defining information about the user’s browser and operating system to streamline design and the code for the rest of the page.
Building the many section of this website, I found myself retrieving the same browser information to determine how the rest of the layout would be like. Importing this site header script allows me to organize and bring consistency to the variables I use for all the sections of the website.
Notes
I wanted to include determining whether the user is viewing the page with a mobile device, but the methods I’ve found out there involved comparing against a list of mobile device brand names, and I didn’t want to do that, for the brand names don’t necessarily mean it’s a mobile device. Also, for now, I wanted to find out if it’s a mobile device only for the sake of styling, and I could already do that with the <link> tag and @media rule.
iPhone Basic
Summary
Test out an iPhone-only stylesheet. The iPhone is special in that it doesn’t take “handheld” stylesheets, so it must be customed. A PHP script is perfect to adjust the display of the stylesheet on the server’s side so no JavaScript is involved.
PHP & Ajax
Summary
The next step of PHP self-teaching after PHP Basics. Learned to use Ajax by using PHP to receive information of an XML file, catalog.xml, and to instruct the display of data onto the original file.
Also added a cookie component so the visitors would not lose their place. Note: the cookie in this experiment expires very quickly so that the experiment can start over without manual deletion of the cookies from the browser.
PHP/Ajax – Address Change
Summary
An exercise to figure out how to change the address of a page without refreshing it. It’s supposed to look like a query address, but ultimately, the use of hash mark (#) did the trick.
This experiment was created for the portfolio page, whereby the page updates its navigation and content without refreshing.
getimagesize()
Summary
Learning the PHP function getimagesize(). Not only does this function get the size of an image, it gets the info of the file and of Flash files.
I used this function to set the layout of the images and Flash files on my portfolio site.