gregdoolittle.com

alpha transparency

January 25th, 2007

i learned a neat CSS workaround at work the other day. no more fudging it with PNG’s that don’t even work on IE6… thanks justine!

.transparent {
	opacity: 0.8; /* CSS3 */
	-moz-opacity:0.8; /* Firefox */
	filter:alpha(opacity=80);  /* IE6 */
}

then apply it to whatever you want:

<h1 class="transparent">this text will be big and transparent!

<img src=”./images/overlay.gif” class=”transparent” />

happy css-ing!

with great power, comes great responsibility

January 24th, 2007

i would like to take this moment to say 2 things:

1. my new job is sweet, but far away (i’ll elaborate on this later).
2. google images just adopted a really dumb use of Ajax. go to images.google.com, and search for something, anything…

recently, they decided to take away all the meta-data that was formerly returned to you as part of your search results. it’s so annoying. now, you only see the pixel dimensions and image source of each image, only when your mouse hovers over. previously, this information was statically displayed under each image. they forgot to ask themselves: is this an improvement over thee olde way of doing things? is the value of saving a minuscule amount of bandwidth and screen space worth the hassle that this Ajax implementation causes? i think not. just make the information available in the standard result page!

this use of Ajax is pointless, accomplishes nothing other than dumbing down the page, and making it a hair or two more fun. it’s not that there’s anything wrong with fun, it’s just annoying that they made a whole lot of useful information inaccessible. this isn’t the google i know… reckless traitors!!! i give them two weeks max before they change it back.

with great power, comes great responsibility; let’s not do a 1996 to our new friend Ajax, and be wise about where it gets used…

on my first day of school, i…

January 21st, 2007

Tomorrow’s my first day at my new job (CMP Technology). Wish me luck!

Ace + Jack = Ajax (Chapter 2)

January 21st, 2007

Head Rush Ajax Chapter 2 covers onreadystatechange, readystate, status, responseText, server errors, callback functions, a simple IE/Opera hack…

onreadystatechange is a property of the Ajax request object. basically, you use this property to tell your browser what to do once the Ajax object has received its request from the server. In the following example, the browser will run updatePage() after the server has finished executing and delivering the request.

request.onreadystatechange = updatePage;


Notice that updatePage() is a function, yet there are no parentheses when we assign the function to the property. When updatePage() is used in this way, it’s called a “callback function”.

readystate is another property of the Ajax request object. The readystate is a number from 0 to 4 and represents a the current state of the request: 0. uninitialized, 1. initialized (request has been made received), 2. server is locating the file or process, 3. server is executing the script or process, 4. the server has finished and the request object is ready.

status is the condition of a request. A status value of 200 represents a successful execution of a script. 404 is an error message, and means the file was not found. 403 is another error message, meaning that access to the desired file or process has been denied. There is a complete list of the HTTP error codes available here.

responseText is the text returned from a PHP script sent through a request object. If we run the script “example.php?id=00001″, and the content of the output of the script is “Homer Simpson”, then responseText will store the string “Homer Simpson”.

var newText = request.responseText;

Finally, a simple IE / Opera hack is necessary because these browsers try to cache entire webpages. If you’re accessing a script that should return a new value each time it’s called, you’ll have to go a step further for these browsers. You can append an otherwise superfluous variable to make the browser go get the new data each time the script is called.
By adding a random modifier we can trick the browser into thinking it is accessing a new URL:

var url = "getUpdatedBoardSales-ajax.php?date="+ escape(Date());
request.open("GET", url, true);

The browser will then go look for the following unique URL:

getUpdatedBoardSales-ajax.php?date=Sun%20Jan%2021%20...


Remember, this is only necessary when the browser is accessing a script that gets updated every time the script is called. There are several instances where having a cached page will improve the agility of the script.

When I finish the homework scripts from this chapter I will post a link to them in this entry.

chronicling the fate of a warrior: Ajax the Great

January 19th, 2007

I bought my text book for my Ajax class (I also bought my book for my Database class, but hey, that’s just not exciting!). I hope to document my experience learning Ajax in this blog. The class doesn’t begin until March 21st, but I’m planning to work through as much of the material as I can before then, so I can apply it to my new job.

Just finished the Chapter 1 tutorial. Some points to remember:

•The main goal of using Ajax: to reduce the need for data transfer within a web page, therefore increasing your site’s ability to react quickly to user activity.
•Ajax should be able to function in every JavaScript-enabled browser.
•The Ajax request object has not been standardized among browsers. In Firefox/Safari/Opera/IE7, you use the XMLHttpRequest object. In IE6 you use ActiveXObject(”Msxm12.XMLHTTP”). And in IE5 and earlier you use ActiveXObject(”Microsoft.XMLHTTP”). You should account for this every time you create an Ajax request object.
•An Ajax-script is usually called by an event handler (onClick, onChange, onMouseOver, onBlur, onKeyUp, etc.).
•The browser keeps track of a request’s “ready state”. When the ready state is equal to “4″, it means the request is done retrieving information. The DOM aspect of the script must wait until this ready state is achieved. Otherwise, the script will finish running before the information is available.

Every Ajax script will require an object to hold the request, followed a bit of browser-sniffing to apply the appropriate type of Ajax object:

var request = null;
 try {
  request = new XMLHttpRequest();
 } catch (trymicrosoft) {
  try {
   request = new ActiveXObject("Msxml12.XMLHTTP");
   } catch (othermicrosoft) {
    try {
     request = new ActiveXObject("Microsoft.XMLHTTP");
     } catch (failed) {
      request = null;
     }
   }
 }
 if (request == null)
  alert("Error creating request object!");

Usually followed by these lines of code:

var url = "example.php";
request.open("GET", url, true); // true means this is an asynchronous request
request.onreadystatechange = updatePage; /* updatePage() is a function that will use DOM
methods to alter the page hierarchy */
request.send(null); // the request.

If you’d like to see my first, and very dorky, Ajax “application”, you can get to it here (update 01/21/07: just added a random parameter to the URL of the request object, which fixes a bug in IE and Opera). In this case the amount of data transfer saved by using Ajax (as opposed to requesting an entire HTML file) is so minimal that it hardly justifies the time spent constructing the Ajax script. But imagine that this feature was part of a page that did have a lot of elements (say, a couple of 8MB image objects). In that case, using Ajax for such a minute section of a page would be worthwhile, because it would avoid reloading the large amounts of data sitting around elsewhere on the page.

VoIP/MobileWeb Conferences…

January 10th, 2007

part of my new job is maintaining websites for conferences centered around VoIP as well as the Mobile Web. yesterday i was looking for info on apple’s new iphone, and i found a great reference blog that covers exactly these two topics. only today did i see apple’s website which officially introduces the iphone. if anyone reading this has other good references for VoIP or mobile phone technology, please let me know.

given apple’s success with the ipod, i’m sure they’ll do just fine stepping into the mobile hardware market. the question will be how well they can integrate their product with the current MVNO’s, and whether they’ll find a solid way to leverage their product over Samsung, HP, and other other rivals’ equivalents. regardless of how slick an phone-ported version of OSX looks, plenty of people will go for it only because they’re hooked on apple, not because of how well it integrates with the current GSM networks (another good mobile phone resource: gsmworld.com). if i was looking for a phone right now, i would be very tempted to hold out for the iphone. The google phone doesn’t really seem relevant… because if you can download the gmail client into apple’s iphone, there’s really no advantage of using a “google phone”.

must… get… iphone…

javascript gallery

January 8th, 2007

i just added new javascript/ajax interface to my photo gallery, which you can see here. it’s written by Lokesh Dhakar at huddletogether.com, i just downloaded the scripts and installed them. you can get them right here. the reason i give them the forsaken buzz-word term “ajax”, is that the gallery only loads each image as it’s needed, instead of loading them all at once. it’s not really ajax because there’s no xml, no innerHTML, and no XMLHttpRequest/ActiveXObject classes, but it’s a step in the right direction.

while i have no ajax experience myself, i hope to learn a little before my first day at my new job, as a PHP/JavaScript/XML Developer. hopefully i can catalog my findings closely enough in this blog to teach anybody reading this what i learn.

Powered by WordPress