BlogMatrix
 

Stars

edit David P. Janes 2006-11-18 09:22 UTC add comment  ·  ·

I've created a little Javascript demo with MochiKit allow one to select between 0 and 5 stars.

Attached Documents:

What's coming up in Firefox and Javascript

edit David P. Janes 2006-10-26 10:53 UTC add comment  ·

Here's a slideshow (mainly) on what's coming up in Javascript 1.7 and 2. Alas, of not too much use if the Internet Explorer don't sign on.

Update: there's Python-like Iterators, which is pretty cool.

Dojo 0.4 released

edit David P. Janes 2006-10-26 10:30 UTC add comment  ·  ·

Via Ajaxian, Dojo 0.4 (cross browser AJAX/Javascript libraries) has been released. I'll steal some of Ajaxian's point form list of updates:

  • dojo.charting: A charting engine to implement a variety of chart types using vector graphics
  • dojo.gfx: a 2D vector graphics API which renders natively to browsers as SVG or VML
  • dojo.i18n: a follow on to the translation support in 0.3.1, there is now build support for collecting localized resources in a single file as well as support for localized date and time formatting. More formatting types and more localization to come in 0.5.
  • dojo.widget: new widgets like Clock, FilteringTable, ProgressBar, plus enhancements to Editor2 and the AccordionContainer. Also localization of some widgets, such as DatePicker.

The charting and 2D stuff look really neat and useful.

Internet Explorer and dynamically changing img.src

edit David P. Janes 2006-10-15 07:30 UTC 8 comments  ·

We slipped a photo album extension into the product on Friday; you can see one right here. Unfortunately, it doesn't always work on Internet Explorer -- the image sometimes displays as blank.

The explaination is here:

The issue is that changing the 'src' attribute of an <image> tag, is making the image disappear, rather than change. Frustratingly, the problem only happens in IE; Gecko behaves as expected.

I have found two work arounds: one is to pop up an alert just after chainging 'src': the icon image correctly updates when the alert dialog is popped up (before dismissing it). The second is to use a callback with the 'setTimeout' method. The first is unacceptable, the second is, IMHO, simply ugly.

We went with the setTimeout method, obviously:

onclick : function(index, again) {
    if (document.all && !again) {
        window.setTimeout("i$(ID).onclick(" + index + ", 1)", 1)
    }

The need for speed; and the solution

edit David P. Janes 2006-08-07 20:44 UTC add comment  ·  ·  ·

I've got page loading time on this site -- for constructed pages1 -- down to near 1 second times. Most of this one second is coming from network and rendering delays, which I'll have to sort out later -- locally I can curl the page in 0.065 seconds!). As previously documented, I've already done the following:

After a lot of mulling today, I've made another big improvement. Formerly, we used to load information about the user's session from a URI called '/:admin/status/'. This returned three pieces of critical information: the IHOST, the USERID, and the HOME. The IHOST is the installation host (semantic.blogmatrix.com), the USERID is the user you are logged in as (or the empty string), and HOME is set only if you serve your pages from a different URI than the default2.

This caused rendering to pause for .75 to 1.5 seconds depending on how well the network was responding. Effectively, the made the site feel really sluggish.

We now do the following: IHOST is just built into the templates; USERID and HOME are loaded into Cookies when the user is logged in. When these values are needed, instead of taking them out of Javascript variables, we call functions that pull them out of Cookies.

Instant speed. 

1. We don't work under the same model as TypePad or Blogger. We only put a page together when we don't have it in cache. This could take several more seconds. Once a page is constructed, we'll always serve it from cache until the cache is invalidated (say, by a new post or comment being added).

2. For example, I serve my personal blog as http://blog.davidjanes.com even though deep down it's really http://davidjanes.semantic.blogmatrix.com!

Javascript debugging in Internet Explorer

edit David P. Janes 2006-08-07 20:28 UTC 1  comment  ·  ·

While attempting to debug a nasty session/cookie problem under FireFox I decided to give V10 a view under Internet Explorer. And immediately ran into a nasty Javascript compatibility problem.

IE's native Javascript debugging capabilities are pretty well non-existent. Fortunately, it's pretty easy to set up:

  • Install the Microsoft Script Debugger (you may have to go through the Windows Genuine Advantage process first)
  • In IE, do Tools > Internet Options; then under the Browsing section unselect the two Disable Javascript... items (about 4 items down)

Now when you get a Javascript error, it will prompt you to go into the debugger which in my case, brought me immediately to the error. What was the error? In JSON-style mapping datastructures, don't leave trailing commas. It no work.