Archive for March, 2006
AJAXing with Dojo, Part One
Introduction
Over the past few months, I’ve been reading up a lot on “AJAX“, Asynchronous JavaScript And XML, which initially I just thought was the latest buzzword for the egregious use of JavaScript. Well, it is and it isn’t. I ordered the O’Reilly JavaScript book, read a good deal of it, and started adding cool client-side JS tricks to my web apps. Unfortunately the book doesn’t touch on XMLHttpRequest() at all, which is really the crux of AJAX.
There is a lot of information on XMLHttpRequest() and AJAX out there on the ‘net, so I wasn’t that concerned about its lack of coverage in O’Reilly’s so-called Definitive Guide. I needed a book about the JavaScript fundamentals, and that was my main reason for buying it.
My first real-world use of AJAX-like techniques was in an application where I used a lot of tags, with onclick="doThis(bar)" JavaScript event thingies. (Yes, thingies is a technical term). The event handlers that I set up used the innerHTML property to dynamically change the content of the page in the browser. It worked, its really neat, and its heading in the right direction — but its not really what AJAX is all about.
The XML in AJAX is really very important to the system. Its use, together with the DOM, allows you to leave the onclick thingies out of your HTML and the innerHTML properties out of your JavaScript. You assign custom event handlers to the nodes of your DOM, and send XML-formatted replies back from your server-side script in order to affect real-time changes to the document loaded in your browser. It sounds complicated, and it is a bit, but the good news is that there are a lot of very clever people who have created tools to simplify the process.
One of those tools, or toolkits, is called Dojo. While Dojo is an ingenious toolkit, the documentation is sparse and highly technical, and it seems to assume a lot of prior knowledge. So while I try to hunt down the information that I need to get started with using Dojo, I’ll chart my progress here on my blog, in the hopes that others will find it useful.
Down to Business
At the top of my HTML, I include what I hope is the necessary Dojo files, plus my own js file, “mycode.js”:
...
I don’t have good reasons for choosing the dojo.require() bits that I did – I’m just hoping that it adds the very basic functions that need for now, and I’ll learn as I go about what modules contain which parts and functions that will be useful for me.
I’m going to start with something extremely basic: executing a function when a user clicks on a checkbox. Here’s the part of my HTML to which I’ll be assigning a JavaScript function:
Look Mom! No “onclick()”!
Now for my JavaScript code in the included “mycode.js” file. I really struggled with an error that I kept getting:
Error: bad srcObj for srcFunc: onclick
Dojo even spit this error out, prefixed with the word FATAL. I couldn’t see why, and going back to my old “onclick(myfunction())” in the tag fixed the problem. The solution was given to me by some kind folks in #dojo on IRC.
The problem was that the global javascript code was being loaded by the browser before the HTML, and it referenced objects that the browser didn’t yet know about. One solution — for now — is to use another javascript function, onLoad(), to load my code after the page is done loading. So here is the working code with Dojo’s built-in onLoad function:
dojo.addOnLoad( function() {
/* When user clicks the "register"
* checkbox, do something, anything!
*/
dojo.event.connect( dojo.byId("register_checkbox"),
"onclick",
function() {
var O = dojo.byId("register_checkbox");
alert("Have an object:" + O + "!");
});
});
Not a very useful set of anonymous functions! It is however my first baby steps towards working with Dojo to assign JavaScript functions to HTML elements. When I click on the checkbox identified by the id=”register_checkbox”, I get a pop-up message that says:
Have an object:[object HTMLInputElement]!
The thing to note here is the 3 arguments passed to dojo.event.connect() – one an HTML element, the second the javascript event, and the last is an anonymous function which could actually be the name of a separate function. If you do use a separate, named function, be sure to put it in double quotes, and do not use (). So for example, another way of writing it would be:
function Bar() {
var O = dojo.byId("register_checkbox");
alert("Have an object:" + O + "!");
}
dojo.event.connect( dojo.byId("register_checkbox"),
"onclick', "Bar" );
Part 2, coming soon.
Want on board the iPhone Gold Rush?
Click Here.
How Yahoo! Can Monetize Flickr
One of the podcasts that I listen to on a regular basis is This Week in Tech. In this week’s edition, they covered the issue of Yahoo! loosing a lot of money on their recent Web 2.0 acquisition, the photo hosting/sharing site, Flickr. Flickr uses a lot of resources, and presently their only way of making money from it is to charge for prints and DVDs of their photos. About 80 people per week, out of about 10 million subscribers, actually use these services. I believe that they also charge for other things too, like more disk space and such, but anyways the issue is that they are loosing a lot of cash on it.
John Dvorak claimed on the program that Flickr is not a monetizable system, then turned around and suggested that they could take advantage of their advertising program by putting ads on the site in conjunction with their Tags — it is the tags that make Flickr unique, it would be simple to integrate tag searches with their “adsense-like” Yahoo! Ads.
I think that they could take that a step further, and integrate tagged Flickr photos into their advertising program via search results, in conjunction with a better print ordering system that would reward the photographers with a revenue stream.

Here’s what I have in mind. When people type in a search term on Yahoo!’s search, a few Flickr photos would appear in the side bar of the search results, photos that have tags which match the search keywords. This would draw traffic to Flickr. It might be relevant traffic too: if I’m searching for “lamas”, I might be interested in seeing a picture of one. The hosted Flickr image might also have ways of contacting the photo’s author so that I could ask questions, etc..
When the search user clicks on one of the thumbnails in the search results, they would go to a larger version of the image on the Flickr site, which would have Yahoo! ads for more advertising exposure. If the user clicks on those ads, the ones around the photo, the “author” of the photo, the photographer, would get a cut of the ad revenue. Also, the search user would have the option of ordering a high-quality copy of the image, and of course the photographer would also get a cut of that revenue. This way advertisers get exposure to the 10 million Flickr users, and the Flickr users (who sign up for the program) have a chance to make a bit of money from their photography skills, at the same time expanding Yahoo!’s advertising empire.
This scheme has the added benefit of proliferating the relevance of tags on the ‘net, which is said to be one of the main features of the next generation of the web, “2.0″. The downside would be the risk of the business community flooding Flickr with stupid product pictures — there would have to be some policing for that.
5 commentsSunshine’s Massive Terrain
Its amazing how much terrain that you can cover in a morning at Sunshine. We started off yesterday by skinning out to Wawa Ridge. The travel conditions were good, but the snow at the ridge was very skied out from the past few days, with a mixed condition sun crust that was quite difficult to ski.
Back to the subject of massive terrain, from wawa I took a photo of the Delirium Dive area, and then from Delirium Dive took a photo of Wawa, to illustrate how much area we covered in only 3 hours. The red squares in the photos indicate the locations from which I took the shots. Here is Delirium Dive, shot from Wawa Ridge:
The conditions in the Dive were pretty good in general, considering the lack of snow over the past few days. There was about 15cm of loose snow at the very top, then some difficult crust closer to the first set of rock-bands, followed by packed powder that made for some nice turns. We took a skier’s right at the bottom and skied Fat Boy, where there was about 20cm of nice loose snow on top of a soft crust; IMO the best skiing in the whole area.
Here is Wawa Ridge, as seen from the top of Galaxy 1 chute in Delirium Dive; the red square indicates the area that the above shot was taken from:
The Wawa-Delirium circuit provides a nice little mini-adventure that, with the appropriate gear, can be easily covered in a morning.
1 commentGreat Conditions at Lake Louise
It was a particularly gorgeous morning at Lake Louise yesterday. With clouds flowing low through the Bow Valley like a river, the upper elevations at the resort had breath-taking views:
There was 5-10cm of new snow, which had formed a surface hoar that made for fantastic skiing. The places to be, IMO, were in the back-bowls, A-H gullies. However, even the often-icey front-side offered packed powder and pockets of loose snow, so it was generally good all-around.
No commentsHot Peppers Kill Prostate Cancer Cells?
News headlines today are burning up with the release of new research from the University of California that shows that capsaicin, the active ingredient in hot peppers, kills human prostate cancer cells. Unfortunately, thats not what the researchers actually said. At least, not according to New Scientist:
But Koeffler says that men concerned about prostate cancer should not interpret these findings as a reason to up their consumption of hot peppers. He stresses that the compound has not been shown to prevent prostate cancer but instead simply slows its growth. And he adds that he hopes to see human trials in the next two years assessing capsaicin’s effect on prostate cancer.
I love spicy food, but on the other hand, even the most extreme hot pepper nuts that I know couldn’t ingest the kind of heat that Koeffler’s mice were subjected to. According to New Scientist, a 200lb person would need to consume ten fresh habañera peppers per week, which is roughly the heat-equivalent of eating eighty jalapeños in order to attain the cancer-slowing effect that was observed by Koeffler and his colleagues. I find that one jalapeño per meal is spicy enough; hard to imagine over eleven per day. Imagine how the mice felt!
Whither privacy?
Is privacy becoming a passé topic in the new century? Government wiretapping, satelite spying, police video surveillance, RFID tags and GPS-enabled devices are proliferating, usually on the heels of arguments for crime and terrorism prevention. Web 2.0, the next generation of the world wide web, is quickly filling up with online replacements for your desktop applications, and more-open-than-ever communications software. Google and Yahoo! are taking the lead by either building their own online personal apps or by purchasing companies who already have. Google has created Gmail, the forthcoming Google Calendar, and has recently purchased the online word processor, Writely. Yahoo! purchased the extremely popular photo-sharing site, Flickr, as well as the pioneering social bookmarking site, del.icio.us, and has its own email and calendar services. People enter and discuss their personal goals and dreams on 43Things.com, manage their to-do lists on Backpack, and individuals and companies manage their projects with the online project manager, Basecamp. All of these services remove aspects of private lives from personal computers, and put them in the hands of either public companies or the public at large.
Granted, one need not use real names for any of these services, so that one can remain at least superficially anonymous.
However, anyone with technical know-how and sufficient resources could probably put the pieces together to discover your real identity, if they were so inclined. In the real world, though, people use these services quite openly with their real names and fill them up with their real personal correspondence and so forth, so the anonymity issue is somewhat moot.
The relevant issue is — does anyone care? Do you? Even more pertinent — should anyone care?
There are strong arguments on either side. The recent media ruckus over the NSA wiretapping story in the United States is testament to the fact that privacy is still a big concern to many Americans. However, given the deep resentment that many of them have towards their current government, it is hard to say how many of the dissenters are actually just acting out of spite. One could argue that the stronger privacy laws that have been implemented in Canada and European nations is evidence for the concern that people have over privacy. Then again, the actions of states do not always reflect the attitudes of the majority of their citizens. Their actions as individuals, surely, speak louder than the words of their politicians.
On the opposite side of the issue, a strong case — and a hilarious one — is made by comedian Bill Maher, on his HBO show, Real Time:
http://www.funnypix.ca/d/3906-2/privacy.avi (~20MB)
Maher’s point is that people want attention far more than they want privacy, and that the security benefits of state monitoring outweigh privacy concerns by a great deal. He is speaking about, and for the most part on behalf of, Americans, but most western countries are loosely following suit when it comes to the rampant attention-getting schemes inherent in communications technologies.
The idea that state monitoring is an effective tool to combat terrorism is highly contentious. Skeptics argue that data mining would be ineffective due to the raw volume and randomness of communications data, that the number of false positives would both waste law enforcement resources and impinge on the rights of innocent citizens. The vast network of video cameras installed on the streets of England did nothing to prevent terrorist attacks on the London transit system; it seems that such technology is useful only after the fact. Identification systems, likewise, are useful forensic tools in the wake of a crime, but in the case of suicidal terrorists, surveillance is practically useless.
On the other hand, exactly how well do surveillance critics understand classified electronic snooping systems? Is it possible to gauge the effectiveness of a technology or system without a full understanding of it? Since signals intelligence is so highly secretive, we the public can’t have a full understanding of the programs and technologies in place. Maybe the number of false positives is actually quite tolerable, and relevant interceptions are commonplace and cost-effective. Critics opinions are based upon their understanding of how currently available public technology works, not the classified private systems in use by intelligence agencies.
Maybe the government shouldn’t be so secretive about their information gathering programs. It would certainly be easier to trust them if they were transparent about their activities (unless, of course, they are abusing their power!). In fact, with feedback from the public and the scientific community, monitoring systems would likely be improved, so that there are less false-positives and mistakes. The idea of openness is antithetical to the military mindset, however, so unless some radical government takes power and upsets the current paradigm, the public will likely remain in the dark.
Government snooping aside, privacy advocates also worry about industry and malicious private citizens. And with good reason: identity theft is a major issue today, and aggressive advertising such as spamming is clogging everyone’s inboxes. There have been tens of millions of victims of identity theft, and I’m sure that almost all of them thought, “it won’t happen to me.” Billions dollars have been lost, and a lot of personal hardship had due to identity theft crimes.
Many people believe that the solution to identity theft is to lock information up tight, hide your personal identity and become anonymous, and implement privacy policies that keep the world out of your life to the maximum extent possible. Or maybe it is this type of behavior which has created a world in which identity theft is rampant.
Consider a small town, before the Internet and sprawling cities, where everyone knows something about everyone else, either by association, reputation or by direct relationship. In that type of circumstance, identity theft is practically impossible, since personal identities are rarely if ever in question, and if they were, it would be easy to verify via trusted second opinions.
In such a town, there would be less personal privacy than one gets in a modern city. Gossip abounds, and people are nosy. However, because of that, I would guess that the townsfolk are less likely to behave in socially unacceptable ways. Like stealing each other’s things. On the down-side, in some towns, people could be encouraged to behave in socially unacceptable ways, like be racists. The big can of worms is the meaning of “socially acceptable”. So without going further astray from the main issue, privacy, I’ll leave the issue of social norms at that. The point of this paragraph is that when identity is not so much in question, there is probably a greater tendency towards good behavior. Maybe I’m wrong.
If I’m not, then it seems that some major problems could be solved by improving identification systems. Instead of people carrying around easily fake-able cards, or remembering passwords to identify themselves, bio-metric authentication is based on something that people are. Examples include retina-scans, finger print scans, hand geometry scans, DNA samples, or some combination of them.
It seems almost paradoxical that biometrics could be a solution to what many people view as a privacy problem. However, identity theft exploits the fact that peoples identities are unknown; if identities were more certain, then falsely assuming them would be much more difficult. If everyone knows you, it is much harder for criminals to “steal” your identity. However, in a world of millions of people behind computer screens connected to each other via networks of networks, how possible is it to achieve secure identification?
I would like to note that the possibility of anonymity is essential in a free and just society. It is not only important for whistle-blowers, exposing crimes or what have you, but it also engenders a certain sense of security and freedom that we should never give up.
Not finished this article yet … I will continue with Part II at a later date…
No commentsNew Photos Section Added
I had planned on integrating Gallery 2 into this blog, using the WordPress Gallery Plugin, but I had some difficulties installing Gallery2. There is a bug in PHP’s __FILE__ variable when used on FreeBSD, in my environment. Anyways it turned out well because I discovered Plogger, which I like better now anyways.
So I integrated Plogger with WordPress, and it now appears embedded in my Photos page. In addition, I setup a Feedburner feed and called it a Photocast, since it appears to work as such in iPhoto fairly well. Any RSS feed would probably work this way, but some blogger somewhere had recommended it, so I thought I’d give it a try. Maybe it will save me some bandwidth too.
I may code my own photocast add-on to Plogger, since I know PHP fairly well and there seems to be adequate information on the web as to the hacks that Apple made to RSS for this feature. For now though, my Mac-using friends and family can enjoy automatic photo updates via the Feedburner link.
No comments






