12 Sep
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:
-
<script type="text/javascript">
-
-
// Object that handles response from XmlHttpRequest
-
var responseObj = {
-
success: function (o) {
-
YAHOO.util.Dom.setStyle("progress", "visibility", "hidden");
-
YAHOO.util.Dom.setStyle("hiddenDIV", "visibility", "visible");
-
response = o.responseText;
-
YAHOO.util.Dom.get ("hiddenDIV").innerHTML = response;
-
},
-
-
failure: function (o) {
-
alert ("ERROR -- Could not get data for your report!");
-
}
-
}
-
-
// process request to get page views information
-
-
function getpageviews(field, start_date, finish_date) {
-
YAHOO.util.Dom.setStyle("hiddenDIV", "visibility", "hidden");
-
YAHOO.util.Dom.setStyle("progress", "visibility", "visible");
-
YAHOO.util.Connect.asyncRequest('GET', "/verticalscope_stats/reports/getpageviews/" + field + "/" + start_date + "/" + finish_date, responseObj);
-
}
-
-
YAHOO.util.Dom.setStyle('progress", "visibility", "visible");
-
getpageviews("page_views", "<?php echo $start_date ?>", "<?php echo $finish_date ?>");
-
-
</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.

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 ; ).