in

Emerald Hand

Emerald Hand, Inc. community home page.

This Blog

  • Home
  • Contact
  • About
  • Directory of Computers/Tech Blogs

Syndication

News

I'm back to blogging

Worm in liquid maze

Design and development of information management tools.

August 2006 - Posts

  • Regular expressions in JavaScript

    Don't forget to replace "\" character with "\\" when working with regular expressions in JavaScript and use new RegExp( "expression" ). Otherwise JS will assume you are trying to declare special symbols (such as "\n" for the new line). From time to time I forget about this, and then I need to spend extra time to figure this out all over again. Today is one of those days.

    Share this post: Email it! | bookmark it! | digg it! | reddit!
    Readability Stats: Word Count: 75; Sentence Count: 4; Grade Level: 8.4, more info...
  • Float jumps

    I recently had to deal with IE jumping floats bug and found an interesting solution. In IE static object located next to the floating object tends to jump down if it doesn't fit next to the floated object on the screen. The problem is very well documented at Curing Float Drops and Wraps. You can also see the problem here. Resize the IE window until the content won't fit on the screen.

    I encountered this problem while working with the Dojo tree widget. However, most people see it creating a multi-column layout using on the floats instead tables.

    I found a solution, but it's good only if you can live with fixed column width or white-space: nowrap style. I haven't found a good generic way to support text wrapping.

    The problem appears because IE tries to fit all content on the visible portion of the page and assumes the object fits better when it drops (moves bellow the float). The only way to prevent the drop is to trick IE into thinking there's enough space for the content.

    I found Fixing the PC IE "float drop" bug while I was doing research. It works well for the column layout, but it relies on hard-coded width. It uses MS proprietary expression style that dynamically inserts JS into CSS (very powerful. Too bad other browsers don't support this). However, I needed solution that would work with a large tree. It has many items and can expand/collapse, so it's width needs to change dynamically.

    At first I tried to set expression style for every node in the tree, but it resulted in too much overhead. When tree expanded or collapsed IE froze calculating width for each node.

    There can be only one expression applied to the whole tree. I needed to know current width of the tree dynamically to write one.

    Dojo tree is built on divs. By default they are width: 100% and there's no simple way to get the actual tree width. I found out if I wrap the tree in a table, the table collapses to the width of its content. If the window was too small elements would still jump, but it wouldn't grow in width to fill a maximized window. The table remains just wide enough for its content.

    I fixed the problem by wrapping the tree in a table and wrapping the table in a div with width: expression( firstChild.offsetWidth + 5 ); style. The table provides accurate tree width and div's expression doesn't allow the table to collapse, causing element drops.

    This solution has a serious flaw. The table width doesn't change with the body width; white space in the table content doesn't get wrapped when text doesn't fit. The table will expand or collapse only if the content width changes. The end result is white-space: nowrap style applied to the elements. If text doesn't have white-space: nowrap, its width is set depending on the window width and is frozen when the page loads. When nowrap style is applied there's some consistency, but very often the text is too wide to fit on one line without wrapping. As an alternative you could fix each column width to ensure layout is consistent, but this scales poorly for different page resolutions.

    This is an example of the fixed layout

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Fixed columns example</title> <style type="text/css"> * { white-space: nowrap; } .leftColumn { float: left; width: 200px; } .middleColumn { margin-left: 250px; } .layoutFixer { width: expression( firstChild.offsetWidth + 5 ); } div { border: solid black 1px; } </style> </head> <body> <div class="layoutFixer"> <table class="layoutTable"><tr><td> <div class="leftColumn" id="leftColumn">Left column<br /> Left column<br />Left column<br />Left column<br />Left column<br /> Left column<br />Left column<br />Left column<br />Left column<br /></div> <div class="middleColumn" id="middleColumn"> Middle column with loooooooooooooooong text................................................................<br /> Middle column with loooooooooooooooong text................................................................<br /> Middle column with loooooooooooooooong text................................................................<br /> Middle column with loooooooooooooooong text................................................................<br /> Middle column with loooooooooooooooong text................................................................<br /> Middle column with loooooooooooooooong text................................................................<br /> Middle column with loooooooooooooooong text................................................................<br /> Middle column with loooooooooooooooong text................................................................<br /> Middle column with loooooooooooooooong text................................................................<br /> Middle column with loooooooooooooooong text................................................................<br /></div> </td></tr></table></div> </body> </html>

    Try to remove nowrap style and reload the page several times with resized browser window to see the problem I'm talking about. You can see the working demo here.

    There might be a way to work around this fixed-width limitation, but I haven't found it yet.

    Share this post: Email it! | bookmark it! | digg it! | reddit!
    Readability Stats: Word Count: 864; Sentence Count: 690; Grade Level: K, more info...
  • Xelog

    Sider is not the only project I'm working on. I'm also occupied by Xelog (XML log), an application to help manage change log for software projects and shows it with different veiws (web page, text file, PDF, etc). I started wiki for the project and have online example.

    I started this project when I faced the problem of having a history of changes for JSForms. I was considering generating a change log from the history of SVN commits or from the fixed issues list, but I don't think it can be done in intelligent, simple manner. Change log is usually written for the user to show what's new and updated in the application. Source control and issues comments usually written for developers, to help understand the changes and remind about them when the code is read at a later date. In most cases the change log has to be written by hand.

    I decided that if I'm going to manually create and update a separate file just for capture history I want to have a standard, cansistent way of doing it. I figured XML is versatile and well suited for storing data, so I'm using it.

    Xelog XML schema describes the change log XML document structure. It's handy, since many XML editors can use it to provide auto-complete support.

    XSLT is used to have different views. At this moment there're two views (both show log in HTML) and there's no way to change the view. In time that will change.

    I also want to add support for writing the change log using browser instead of XML editors. It will abstract away the XML document from the author and simplify log management.

    The project is free and open source. Forum is open for discussion. You can also read issue tracker or project change log. I'm still working on the code and will to release it as soon as it's usable. If there will be people interested in contributing I'll set up an online SVN.

    Share this post: Email it! | bookmark it! | digg it! | reddit!
    Readability Stats: Word Count: 334; Sentence Count: 22; Grade Level: 7.4, more info...
    Posted Aug 08 2006, 12:52 PM by Ornus with 3 comment(s)
    Filed under:
  • ISP vs. Dojo

    I recently encountered a problem with the Dojo. My ISP refuses to allow access to the built dojo.js and dojo.js.uncompressed.js files. It seems their antivirus program thinks both of them could be mass-mailing worms. I can't access the files through the browser or open them for reading in an FTP client. I can only delete them.

    I investigated the problem and found out that the file is rejected because it contains "getNamespace" string. If I replace all occurrences of "getNamespace" with "getNS" the file can be accessed fine. To be frank, I was surprised that it is so easy to be classified as a virus.

    I'm not sure if the ISP can or will be willing to do anything about this. If not I will have to file a bug report for the Dojo and hope that developers will address it. In the worst case I might end up replacing the string manually when uploading a new Dojo version. I hope I won't have to do that, as there could be unforeseen side-effects.

    Share this post: Email it! | bookmark it! | digg it! | reddit!
    Readability Stats: Word Count: 179; Sentence Count: 16; Grade Level: 5.1, more info...
    Posted Aug 04 2006, 11:04 AM by Ornus with no comments
    Filed under:
Copyright © 2006-2007 EmeraldHand, Inc. All rights reserved.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems