Freelance web design - 1332 Part V . Putting JavaScript to Work
Monday, January 7th, 20081332 Part V . Putting JavaScript to Work prevIndentDisplayed = currIndent showMyDaughter = expanded if (db.length > 25) { document.write(newOutline) newOutline = } } } First, you call upon two previously defined functions to grab the widget image object and corresponding onMouseOver message for the statusbar. Two more variables contain the indent property for the item (that is, how many steps indented the item will appear in the outline structure) and the current expanded state, based on the cookie s entry for that item. Not every entry in the outline database is displayed. For instance, a nested item whose mother is collapsed won t need to be displayed. To find out if an entry should be displayed, the script performs a number of tests on some of its values. An item can be displayed if any of the following conditions are met: . The item is a topmost item, with an indentation factor of 0. . The item is at the same or smaller indentation level as the previous item displayed. . The previous item was tagged as being expanded, and the current item is indented from the previous item by one level. Over the next few statements, the script pieces together the HTML for the outline entry, starting with the width necessary for the transparent filler image (based on the number of pixels specified for indentations near the top of the script). Next comes the link definition that wraps around the widget image. The following concepts apply to each link: . The HREF attribute is the javascript: URL to invoke the history.go() method. . The onMouseOver event handler is set to adjust the status message to the previously retrieved message (notice the return truestatement to make the setting take effect). . The onClick event handler is set to call the toggle() function, passing the number of the item within the outline database. An onClickevent handler is carried out before the browser responds to the click of the link by navigating to the URL. Therefore, the toggle()function changes the setting of the cookie a fraction of a second before the browser refreshes the document (which relies on that new cookie setting). But click events on widgets that have no children do not need to hit the toggle() function. Therefore, the content of the returnstatement is influenced by whether or not the widget image is an endpoint image. In the next statement, the newOutline string accumulation continues with the tag specifications for the widget art. Specifying the HEIGHTand WIDTH attributes for the image is important, partly to help the browser lay out the page more quickly, partly to avoid pesky performance inconsistencies.
We recommend you use shared web hosting services, because many users agree that it is cheap, reliable and customer-satisfying webhost.