|
||||
About the material:
First of all I need to make perfectly clear that I do not own nor make any claim to the material presented in my "You Might Be A Redneck If..." page! This material is copyrighted by Mr. Jeff Foxworthy (visit his web site). The material contained in these scripts was taken from "Jeff Foxworthy's Year 2000 Laugh-a-Day Calendar", published by Longstreet Press, Inc. (full info below). Not one word has been omitted or changed! I took the slight liberty of using this material for the purpose of improving my skills in creating JavaScript code, and I needed something to work with... I had received a copy of Mr. Foxworthy's desktop calendar as a Christmas present and felt it provided an excellent source of quotes I could use to create a "quote-a-day" script as well as one for a "randomly chosen quote". There's also the undeniable appeal of Mr. Foxworthy's excellent humor, and the fact that "You might be a Redneck if..." has practically become a national catch-phrase. I would like to further point out that this was not done for profit or monetary gain in any way whatsoever! I received no pay for creating these scripts, nor are they being presented here with the intention of making money from them. The scripts and the site they are part of is purely personal and non-commercial in nature. About the scripts: There are currently two separate scripts running on the "Y.M.B.A.R.I..." page to generate it's content (though there may be other scripts running which perform different tasks). Both scripts make use of JavaScript "arrays" to hold Jeff's quotes, and these arrays can act like simplified databases. The "Quote-of-the-Day" script uses JavaScript to "get" the current date from your computer's clock. After the script determines the date, it selects the corresponding array from a group of 12 arrays (one for each month), and then selects the corresponding day of that month. The quote for that particular month/day combination is then displayed under the "Jeff Foxworthy's You Might Be A Redneck If..." graphic using the document.write() statement. It then goes one step further by using another document.write() statement to write out the date it based it's selection on as "Jeff's quote for Day name + Month name + Day of the month + Year". Once again, this is based on YOUR computer's clock, so if it's showing you the wrong date, check your clock! (Or maybe you just think the date is wrong - in which case, check your head.) Also note that even though these quotes came from a calendar for the year 2000, it really makes no difference since the quotes are not really "date-specific" - references to holidays such as Thanksgiving and Christmas still fall within the appropriate month. So all that's required for having a different quote for each day of the year is that you have 366 of them. That's right - this script is Leap-Year compliant! Every four years you'll see a quote for February 29th! The random quote script uses the same type of array to hold a second set of Jeff's 366 quotes, though this time they are all contained in a single array instead of divided into a separate array for each month. It starts by generating a random number based on the length of the array, which in this case would be a number between 1 and 366. Then of course it selects the array entry which corresponds to the random number and uses the document.write() statement to display it under the "Jeff Foxworthy's Random Redneckisms" graphic. (I made that phrase up, and you're more than welcome to it, Jeff!). Each time the page loads it will choose a random quote again. Of course it's possible to have the same quote appear twice (or more) in a row, but the odds are certainly against it! Clicking your browser's Reload or Refresh button will do this, but so does my nifty little button labeled "Get Another Quote!" ... this button simply calls another small script into play which causes the entire page to reload. (The "Back" button at the bottom of this page works in a similar way, calling a function which employs the JavaScript location.replace() object.) None of these scripts are "intrusive" in anyway - though they may fetch the time/date from your computer's clock, they have no ability to change the clock or anything else on your machine! Nor do they put any extra burden on the server they reside on - since JavaScript is a type of "client-side" scripting, the code is only executed "locally" on your machine after the page has loaded into your browser. (JavaScript enabled browsers such as Internet Explorer and Netscape contain special "engines" for interpreting and executing JavaScript, much in the same way the they interpret the HTML code that makes up the rest of the page.)
If you would like to see the code I wrote in plain-text format you can view the source-code in the following way: If you would like to learn more about JavaScript and how to write it, I recommend Danny Goodman's excellent "JavaScript Bible", now in it's fourth edition. Also try these great links below:
Now, go have some fun - you REDNECK!
Mark Corder
Publishing Notes: The following information is from "Jeff Foxworthy's Year 2000 Laugh-a-Day Calendar"
Published by LONGSTREET PRESS, INC. Copyright ©1999 by Jeff Foxworthy ISBN: 1-56352-561-5 The original calendar contained a number of small cartoon illustrations by David Boyd - these have not been included on this web site.
|