Run-up To php|works and some AJAX fun

Ah, only one more day of work (today) then I'm off to php|works for three days, and hopefully not embarassing myself during my talk "What Can PHP Learn From Rails". I hope to run into some people I met before and make some new friends. It's weird going to a conference where you really don't know anyone and no co-workers are coming with you. Luckily I'm not shy, so I'm sure I'll make some friends while I'm there.

I spent some time yesterday adding some code to the stats reporting system I created for work to display an animated graphic (stolen from AjaxPatterns, a site I find myself going to more and more as I expand my l33t skillz to include practical Ajax stuff). Using the Yahoo YUI, here's all the javascript code I'm using to make it happen:

PHP:
  1. <script type="text/javascript">
  2.  
  3.     // Object that handles response from XmlHttpRequest
  4.     var responseObj = {
  5.         success: function (o) {
  6.             YAHOO.util.Dom.setStyle("progress", "visibility", "hidden");
  7.             YAHOO.util.Dom.setStyle("hiddenDIV", "visibility", "visible");
  8.             response = o.responseText;
  9.             YAHOO.util.Dom.get ("hiddenDIV").innerHTML = response;
  10.         },
  11.        
  12.         failure: function (o) {
  13.             alert ("ERROR -- Could not get data for your report!");
  14.         }
  15.     }
  16.    
  17.     // process request to get page views information
  18.        
  19.     function getpageviews(field, start_date, finish_date) {
  20.         YAHOO.util.Dom.setStyle("hiddenDIV", "visibility", "hidden");
  21.         YAHOO.util.Dom.setStyle("progress", "visibility", "visible");
  22.         YAHOO.util.Connect.asyncRequest('GET', "/verticalscope_stats/reports/getpageviews/" + field + "/" + start_date + "/" + finish_date, responseObj);
  23.     }
  24.    
  25.     YAHOO.util.Dom.setStyle('progress", "visibility", "visible");
  26.     getpageviews("page_views", "<?php echo $start_date ?>", "<?php echo $finish_date ?>");
  27.    
  28. </script>

This example is from a report that scrapes Google Analytics and then presents the data. I wish I could say I was smart enough to figure out the Google Analytics stuff on my own, but I wasn't. It's a made-for-CakePHP solution and you can find it here at ThinkingPHP. Man, I love it when people smarter than me have figured stuff out. ;)

One Response to this post.

  1. Felix Geisend?rfer's Gravatar

    Posted by Felix Geisend?rfer on 12.09.06 at 10:05 am

    Hey I just saw your pingback on my article - thanks for those kind words and best luck with your presentation, I wish I could come to Candada to hear your talk / see the conference, but it's quite a distance from Germany ; ).

Respond to this post

Want to advertise on this blog? Send email to chartjes@littlehart.net
GTcars Canadian Car Audio TurboDodge Audi Forum
Mustang Forum Dodge Intrepid Miata Turbo
GTscene Pontiac Bonneville