Posts Tagged ‘ajax’

Safari 2 XML parsing

Wednesday, October 3rd, 2007

My head blows up, had been “optimizing” code for Safari all day long (will do all week long at least). Somewhat fun, am masochistic, you know… Anyway. Safari 1.x had a problem with parsing XML with namespaces (rss xml from feedburner for example) – now I know (thx to Alex), the same happens with Safari 2.x; cool.

Task: fix things on Safari without touching the original code. Ended up using extend-like wrapping/emulation á la Prototype.js (as Toxin concluded).

safariXMLNode = function(node) { this.node = node; }
safariXMLNode.prototype.getElementsByTagName = function ( tag )
{
var list = this.node.getElementsByTagName(tag);
if (!list.length) list = this.node.getElementsByTagNameNS("*", tag);
var r = new Array();
for (var i = 0; i < litem =" list[i];" tmpnode =" new" firstchild =" lItem.firstChild;" nodevalue =" lItem.firstChild.nodeValue;">

Yes I know this is pretty raw and not yet perfect, but the code I had to repair used getElementsByTagName, firstchild+nodevalue only, and I don’t code for fun (read: time is money). Okay, I’ll convert it to our inhouse framework, but that’s it.

Usage: when you parse the xml (probably from ajax response using responseXML) use the wrapper to emulate things. No, redefining the original getElementsByTagName on HTMLElement is a no go for Safari 2; sorry, but good idea :)

parseRSS: function(xml) {
if (safari) { xml = new safariXMLNode(xml); }

Ajax hype

Saturday, March 31st, 2007

I usually check out Ajaxian’s posts and I click on all those fancy web 2.0 samples: while Ajax around here seems to be a magical word, I’m just getting tired of all things asynchronous. People say “Ajax” and whoosh, some cloudy haze comes and miracles happen.

No freaking way. While I consider myself a person who is capable of developing complex ajax controls and pages, no matter how hard I look, ajax controls:

  1. are easy to break (yes, even Yui or Dojo!) and of course not flexible enough
  2. are too messy to work with (even with javascript frameworks! hey, people, it’s javascript, we are “pretending” to be nice and oop and stuff) – and hence hard to maintain
  3. are inaccesible for screen readers (and of course, without permalinks, they are accessibility nightmares)
  4. are clunky (not just those canvas related techs, but “simple” ajax controls too)
  5. are quite vulnerable out of the box

Damn, I had the opportunity to develop some desktop apps myself (besides, reading good literature of course) and the tools of the web simply suck. We sacrifice so much for portability, I wonder if it worth it.

Okay, enough of this rant; finally we are moving slowly to our new home – or at least I move, since my darling is off to Potsdam for university studies… wish this half a year would fly away!