Skip navigation.

Posts tagged with "javascript"

A CMS to avoid?

, , , ...

I just had to write about this CMS I just bumped into: Zimplit. It seems to be very, very new. It also has probably the easiest install of any CMS - just copy two files onto your web server.

The reason it's that easy is simple - most of the complexity is handled via off-site JavaScript. The single PHP file is simply the conduit to access your web site files.

Zimplit needs no database - it creates standard HTML pages. Templating consists of you creating your own HTML file. New pages start off as copies of existing pages. It is really very basic. No blog support, no gallery support.

None of that is what prompted me to write this post, though. No, the reason is that I'm sad. It's the Javascript code that's making me sad. You see, Opera is blocked from the WYSIWYG editing features - only IE and Firefox are supported. And I mean Firefox. Seamonkey and any other non-Firefox Gecko browser is also blocked. So is any Webkit-based browser like Safari and Chrome. BTW, an "IE" browser is any browser that claims support for "document.all".

Yep, it's crappy browser sniffing time again. :frown: Anyone who promotes the idea of feature detection instead of browser sniffing would be running around in little circles screaming and pulling their hair out right about now.

There are at least two WYSIWYG editors around that are much better - TinyMCE and FCKeditor. Why the Zimplit guys felt they had to reinvent the wheel and then make such a hash of it I don't know.

Apart from all that, what kills Zimplit for me is the dependency on the off-site JS and images. An international communications glitch would leave me unable to edit my site. Or the company could disappear.

Zimplit has too much going wrong now, and potentially far too much going wrong in the future. One to avoid, I think.

Poor Javascript Coding Quality

, , ,

What is it with Javascript programmers these days? Doesn't anybody know how to program?

I was investigating why tinyMCE 2 (.1.3) is failing in Opera in some circumstances, and what did I find?

Exhibit 1:
if (tos.getEditorTemplate) editorTemplate = tos.getEditorTemplate(this.settings, this.editorId);
deltaWidth = editorTemplate.delta_width ? editorTemplate.delta_width: 0;
The if statement is there for a reason - to initialize editorTemplate to something useful - but what happens if the statement is false? editorTemplate does not get initialized. Look at the following statement - the potentially uninitialized editorTemplate is used! That would generate an error in any browser.

Exhibit 2:
getRng: function() {
  var s = this.getSel();
  if (s == null) return null;
  if (tinyMCE.isRealIE) return s.createRange();
  if (tinyMCE.isSafari && !s.getRangeAt) return '' + window.getSelection();
  if (s.rangeCount > 0) return s.getRangeAt(0);
  return null
},
isCollapsed: function() {
  var r = this.getRng();
  if (r.item) return false;
  return r.boundingWidth == 0 || this.getSel().isCollapsed
},
getRng is obviously capable of returning null. The very next function, isCollapsed, calls it and immediately uses the returned value without checking for null. That will generate an error in any browser.

It doesn't matter how other browsers somehow manage to avoid these obvious bugs - this is just plain crappy coding.

The worst thing is, this is typical of the sort of code that makes the web go. It's a wonder it works at all.

Opera 10 is too old!

, , ,

Not that Opera have released version 10 (yet!), but it looks like at least one site is going to reject Opera when they do. And where there's one site, no doubt there's hundreds of others :frown: Thankfully, a quick search doesn't quickly turn up anything similar, although there are plenty of other bad examples.

Anyway, here's the problem code:
if (navigator.userAgent.toLowerCase().indexOf("opera") != -1)
{
   isOpera = true;
   i = navigator.userAgent.indexOf("Opera") + 6;
   v = parseInt(navigator.userAgent.substring(i, i+1));
   if(v < 7)
      isOperaOld = true;
}
Need a clue? The substring will return exactly one character - the first digit of the version. Still need help? Version 10 will be identified as version 1.

If you're one of those people irritated at how poorly Opera appears to handle web site scripting - this is one of the bigger reasons. It's straight-out careless programming without thought.

I'll mention that the site in question isn't delivering bugs to just Opera. Their corresponding IE code had the exact same problem, except that IE is quite a bit further away from version 10 than Opera.

The problem remains for Opera:
  1. Opera release version 10.
  2. Web sites stop working in Opera, all other browsers work fine.
  3. "Opera is a crappy browser, never works!"
Yet, where is the bug? What should Opera do about it? Never release a browser with a version where the first digit is between zero and six inclusive? Will the Opera after 9.5 be 70.0? :insane:

UPDATE: Bit late, but Hallvord has blogged on this too: 10 is the one.

The fastest browser!

, , ,

I just bumped into a comparison of Javascript CSS selector libraries at http://extjs.com/blog/2007/07/10/css-selectors-speed-myths/ . The whole point of the article wasn't to compare browsers, but to compare the speed of various library implementations in different browsers, and to determine which library was fastest overall.

As I read the article, one browser was mentioned several times - Firefox. No other browser was mentioned, other than by phrases like "Performance in other browsers drops significantly".

At the end is a table cross-referencing library runtimes and browsers. One browser was consistently the fastest among all other browsers. This fastest browser wasn't even mentioned once in an article devoted to analysing how fast libraries and browsers are.

That fastest browser was Opera! :D

Head-smacking sniffing stupidity

, , ,

I'm feeling a bit like Hallvord right now :rolleyes:

While doing some web site troubleshooting, I bumped into the following code at Olive Software:
var Mac  =  (navigator.userAgent.indexOf("mac")!=-1)  || (navigator.userAgent.indexOf("Mac")!=-1);
var opnew = (navigator.userAgent.indexOf('Opera 7')!=-1);
var opold = (navigator.userAgent.indexOf('Opera')!=-1);
var msie  =  (navigator.userAgent.indexOf('MSIE')!=-1);
var moz  =  (navigator.userAgent.indexOf('Gecko')!=-1);
var NS6  =  (navigator.userAgent.indexOf('Netscape')!=-1 && navigator.userAgent.indexOf('Gecko')!=-1);
var Nav4  = (document.layers);
var konq = (navigator.userAgent.indexOf('Konqueror')!=-1);
if (opold && msie || opold){var opold=1; msie=0;}
if (msie && !opold){msie=1;}
if(opnew && opold){opold=0;}
if(msie || moz || opnew){var dom = 1;}

Whoever coded that was obviously having a really bad day. Maybe their cat had died, but it must have been something seriously distracting.

I mean, translate their "opnew" into English: "It's a new version of the Opera browser if it's version 7 and identifying itself as IE or Mozilla". That's right, any later versions (like 8 or 9) are old versions, and even version 7 identifying as itself is old!

And people wonder why Opera appears to have a hard time handling web sites?
Download Opera, the fastest and most secure browser
November 2009
S M T W T F S
October 2009December 2009
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30