Need to Work on Site Issues

I have now been informed twelve times in the past week that I either need to allow comments or have some sort of contact form.

Good news, soon there will probably be both (for sure one). I am working on a new table structure for my posts and into this I am going to add the ability to comment, of course there will be anti-spam measures. The contact form will probably be last because right now people can just e-mail me if they need to get in touch with me (s [at] badice [dot] com).

Grey’s Anatomy

Last night my friend Courtney and I watched Grey’s Anatomy and I have to say that I just might be hooked. There was plenty of humor yet it was serious enough to be considered a drama.

The cast includes Ellen Pompeo (Old School), Patrick Dempsey (Sweet Home Alabama), and Katherine Heigl (Wuthering Heights). Definitely check this show out (ABC on Sunday @ 9pm CST).

Firefox Wish

After using Safari and Firefox at the same I have a small wish for Firefox.

In Safari (and Camino) I am able to close a tab by simply clicking the “X” on that tab. However, in Firefox I have to go to the tab I want to close, select it, then go to the right of the tab bar and click the “X”. It seems counterintuitive and if Firefox had the method for closing tabs as Safari and Camino then I would probably use it more (that and the speed issues on this G4).

That is my one simple wish for Firefox.

My Mom

My mom is a funny person and she always gives me a good laugh (it’s true mom)…

Last night I get a voicemail that went something like this:

“Stephan, I think you should take that satellite photograph of our house off your website. I don’t like the idea of people knowing where we live. Anyway, that’s why I called. Bye”.

I laughed for about 10 minutes before finally deciding to call her back. I explained that there is no way for anyone to know where exactly my family lives by looking at a satellite photograph taken from 25 miles up… If anyone is good enough to figure that out then they deserve to know where we live.

Anyway, that was my priceless event for yesterday. Gotta love parents.

Google Maps Satellite Shot

I was able to get a screen capture of my neighborhood and house using the satellite features of Google Maps.

If you’d like to see the full screenshot with notes you can take a look here.

The satellite feature of Google Maps is very handy even though the maps are a little outdated. I was able to figure that the data in the maps was about 2-2 1/2 years old by looking at this map. It is a view of Texas Tech University, specifically the English, Philosophy, and Education building being built which occurred a few years ago. Still, the satellite view is very nice.

San Francisco to Regulate Blogging?

According to this San Fransisco may take steps to regulate blogging. The initiative would require local bloggers to register with the Ethics Commission and report all blogging costs that exceed $1,000. So they are making bloggers mean freelance journalists, seems kind of stupid if you ask me.

I guess the next logical question is the actual enforcement of something like this. How are they going to know if someone really is in San Fransisco? What is the fine if you do not register with the Ethics Commission?

I don’t think this will ever take off due to the fact that it will probably never gain legitimacy (the acceptance and backing of the people).

Simple XMLHttpRequest Code

I have been playing with XMLHttpRequest a bit more and have created a simple application that is available here. Using a free database of zip codes and their corresponding cities and latitudes and longitudes I created a simple application that calculates the distance between two zip codes.

Notice, the page does not reload when you click the “Calculate” button, it simply fills in the blank even though it is making a database call.

index.html:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head>

<mce:script language="javascript" type="text/javascript">

<!--
var url = "getDistance.php?";
function handleHTTPResponse(){
if(http.readyState == 4)
{
var xmlDocument = http.responseXML;
var distance = xmlDocument.getElementsByTagName('miles').item(0).firstChild.data;
document.getElementById('distance').value = distance;
//document.getElementById('url').value = url;
}
}

function updateDistance(){
url = "getDistance.php?";
var zip1 = document.getElementById("zip1").value;
var zip2 = document.getElementById("zip2").value;
url = url + "zip1=" + escape(zip1) + "&#038;zip2=" + escape(zip2);
http.open("GET", url, true);
http.onreadystatechange = handleHTTPResponse;
http.send(null);
}

function getHTTPObject()
{
var xmlhttp;
/*@cc_on
@if (@_jscript_version >= 5)
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
@else
xmlhttp = false;
@end @*/
if (!xmlhttp &#038;& typeof XMLHttpRequest != 'undefined') {
try {
xmlhttp = new XMLHttpRequest();
xmlhttp.overrideMimeType("text/xml");
} catch (e) {
xmlhttp = false;
}
}
return xmlhttp;
}
var http = getHTTPObject(); // We create the HTTP Object
// --></mce:script>
</head>
<body>

<form action="post">
<p>First Zip Code:</p> <input type="text" size="5" name="zip1" id="zip1" /> <p> Second Zip Code:</p> <input type="text" size="5" name="zip2" id="zip2"/> <p> Distance:</p> <input type="text" size="10" name="distance" id="distance"/> <input type="button" value="Get Distance" id="submit" onclick="updateDistance();"/> </form> </body></html>

In this code we are simply creating the Javascript objects that we’ll need to do the calculation. The updateDistance() function does a lot of the easy work, simply setting the values pulled from the form. handleHTTPResponse() does most of the heavy lifting, getting the values from the called PHP that returns a basic XML file.

PHP:

This PHP file does the actual work. It pulls the needed values from the database, then calculates the distance using the Great Circle Distnace formula. It then returns an XML file that is called by the above Javascript.

Generated XML file:

It’s a very simple XML file that returns the basic data needed. The most important field is the ‘miles’. It is a rounded distance returned by the distance formula.

So that’s that in a nutshell. It is a lot simplier than it looks and it gets the job done. Of course there are downsides to using XMLHttpRequest and you can do a search on Google for such reasons (maybe that will be my next post, “The downfalls of XMLHttpRequest”).

If you have any questions about how all of this works feel free to e-mail me at s [at] badice [dot] com.