Category Archives: web-x.0

Be the Google

Would you like 500mb of web hosting, plus Python, plus Django, plus a lot of Google database and application goodies? Would you like it for free? Then, my friend, what you need is Google App Engine. No mention yet of what the pricing is like after you hit your 5 million hits per month. But trust me, if you’re at 5 million hits per month, you don’t care.

Sorry Amazon S3, but you can basically suck it.

Update: um, yeah, it’s wait-listed. Though if you have Google Apps, you’re probably in.

Dynamically Adding Option Elements to Select Objects… The Real Story

I don’t normally blog about pure code subjects, so this is going to be way too technical/boring for the general readership of this blog. However, I wasn’t able to find the definitive answer to this question after searching around with Google, so I figured I’d contribute a little. This is also a wiki-style reminder to myself the next time I need to do this.

Mostly you’ll be interested in this post if you’re trying to programmatically add options to a select list using JavaScript. Of all the ways to do this, there are a few that work and many that don’t. The catch seems to be that IE is picky about how and when the data “inside” the option tag (the visible text in the option list) is set. According to the documentation there should be any number of ways to set this–.text, .innerHTML, .innerText. Of those, the only one that seems to be broadly compatible is .text. .innerText is IE-only, so it’s right out. .innerHTML is valid across platforms, but it messes with the object model in IE6 and IE7 (and IE8 beta 1, now that I look) in such a way that if you use it, you have to add the option element to the select element before setting the .innerHTML property. See below for a breakdown of the methods, plus test code. Blogger might break this, so be sure to look at the plain test page (“view source” is going to be a lot friendlier on that page as well).

In any case, here’s the take-away when adding options to select elements:

  • Always use the .text property of the newly-created option object to set the visible text for the option.
  • As a precaution, add the new option object to the select object’s options collection before setting other properties of the option.

create option, set .value, set .text, add to options list (generally compatible)


function createSetTextAddOption(selectEl,val,displayText) {
var o = document.createElement("OPTION");
o.value = val;
o.text = displayText;
selectEl.options.add(o);
return false;
}


create option, set .value, set .innerHTML, add to options list (fails IE6, IE7, IE8-‘invalid argument’)


function createSetInnerHTMLAddOption(selectEl,val,displayText) {
var o = document.createElement("OPTION");
o.value = val;
o.innerHTML = displayText;
selectEl.options.add(o);
return false;
}


create option, add option to list, set .value, set .innerHTML (generally compatible)


function createAddOptionSetInnerHTML(selectEl,val,displayText) {
var o = document.createElement("OPTION");
o.value = val;
selectEl.options.add(o);
o.innerHTML = displayText;
return false;
}


create option, add option to list, set .value, set .text (generally compatible)


function createAddOptionSetText(selectEl,val,displayText) {
var o = document.createElement("OPTION");
o.value = val;
selectEl.options.add(o);
o.text = displayText;
return false;
}


Attempt to add new options/selects inline (option 2 and select 2 fail in IE, either silently or with the “invalid argument” error)

According to the Microsoft documentation, this shouldn’t work at all. Here’s what they say about the option.add() method:

This method can be used to add elements only after the page loads.

If the method is applied inline, a run-time error occurs.

And yet, it mostly does work, aside from the innerHTML limitation…


// generally compatible inline adds
createSetTextAddOption(document.getElementById('sel5'),'1','added value 1');
createAddOptionSetInnerHTML(document.getElementById('sel5'),'3','added value 3');
createAddOptionSetText(document.getElementById('sel5'),'4','added value 4');

addNewSelect(document.getElementById('sel5'),'1','added value 1',createSetTextAddOption);
addNewSelect(document.getElementById('sel5'),'1','added value 3',createAddOptionSetInnerHTML);
addNewSelect(document.getElementById('sel5'),'1','added value 4',createAddOptionSetText);

// these two fail in IE6, IE7, IE8
createSetInnerHTMLAddOption(document.getElementById('sel5'),'2','added value 2');
addNewSelect(document.getElementById('sel5'),'1','added value 2',createSetInnerHTMLAddOption);

Again, I encourage you to view the plain test page to avoid any Blogger-induced weirdness.

This Meme Needs a Name

All of a sudden (though probably not–I’m just catching on) there’s a rash of services that crunch plain text or data keys and return parsed, formatted, drilled-down usable data. For example…

Tripit will digest all your travel confirmations and produce a rich itinerary.

Google SMS will take a zip code, flight number, etc., from your cell phone, and return a rich data node.

Opencalais is a platform for doing stuff like this.

So what do we call it?

On SNS Backlash and Opting Out

Following up on my post from yesterday, I was thinking about social networks in term of personal return on investment: for some of us there really isn’t any. It seems Dave Slusher has some of the same concerns, and cites a Scoble post for contributing to his opting out of the whole SNS thing. There’s wonderful symmetry here because it’s largely Scoble that got me even considering joining a SNS.

What I’ve decided is that SNS is a bad idea for me for the same reason it’s a good idea for Scoble. Scoble’s a pundit. His job is to connect to a lot of people, keep his eyes and ears open for the next new hotness, and then distribute that information via his various output channels. Nice work if you can get it. But it’s not my work. Trying to maintain even a single presence online for me is definitely more trouble than it’s “worth.” My ROI on this blog is certainly negative, both in the short term (hosting costs, opportunity costs for time spent on each post and tweak) and the long term (expressing my honest opinions will almost certainly cost me friends and business down the road, versus the relative safety of staying politely quiet or concentrating on a more traditional, less sincere “marketing strategy”).

From this perspective, if I join, I become basically a social network wage slave. I sacrifice my time, energy, privacy, etc. and contribute content to this “thing” that ultimately doesn’t benefit me, certainly not as much as it benefits the network itself, or power users in a certain niche, like Scoble. To be one of the mooing masses on a social network has exactly the same cost-benefit ratio of being a cow in any other sphere. The obvious argument against what I’m saying would be to contend that SNS is not a zero-sum game, that everyone gains and no one loses. I’m not buying it. Like Slusher, I don’t feel like there’s been one tangible benefit to me from SNS involvement, or for that matter from maintaining any kind of content-based online presence (most especially including this blog). And, like Slusher, I know there are a million better, more fulfilling things I could be doing with my time.

Web 2.0 Eats Its Own

If you’ve been waiting to find out what happens when big-name blogs collide in the most virtually violent fashion, you can now safely exhale. Uber-geek-cheerleader (is it sexist if you mean it flatteringly? Probably, and this becomes meaningful in a moment) Kathy Sierra and Chris “Clue Train Manifesto” Locke get into a comment troll-fueled feud over sexism and anonymous harassment on the Internet. Insults are exchanged, fingers are pointed, every skulking Gollum in the blogosphere shows up in the arena, death threats ensue, eventually the cops are called in and none other than Tim “I’m the only reason geeks ever meet in personO’Reilly has to broker a ceasefire. And one of the bloggers cancels speaking appearances, locks the doors and turns off her blog. Oh yeah, and it all comes to a head on April Fools’ Day, so maybe it’s all theater, you know, to “bring up an important issue.” You really have to hope so. But I doubt it. I mean, CNN bought it.

And speaking of CNN, of course they end with a wonderfully unintentional ironic twist:

Female Reporter: “Even Kathy Sierra, the target of these threats, says that freedom of speech is to be preserved… the alternative is to censor and that’s not the right solution…”

Male Reporter: “How can you threaten the ‘Cute Kitty?'”

Female Anchor: “Poor woman, so terrifying.”

Way to elevate the level of discourse, CNN! You have truly fulfilled your journalistic charter by diffusing my fear and outrage and letting me fall right back into my comfortable prejudices about the place of women in our society. Sexism in the blogosphere? Nothing can touch TV news.

Also, how creepy is it that CNN has these two bloggers, embroiled in a shitstorm of accusations of online harassment, sexual predation and death threats, meet for the first time in a generic hotel room! Internet, anonymity, sex, hotel room… yeah, that’s subtle.