Archive for the 'Coldfusion' Category

Free web host - 1338 Part V . Putting JavaScript to Work

Thursday, January 10th, 2008

1338 Part V . Putting JavaScript to Work if (document.styleSheets) { isCSS = true isNN4 = false } else { isCSS = false isNN4 = true } To each of the cookie storage functions from the original version, I add a branch to handle the storage and retrieval of state data for CSS browsers, simply setting and getting the global variable. This may seem to be more indirect than is necessary, but it is essential to allow the reuse of many functions in other parts of the code so that those areas don t have to worry about browser platform. Notice that the label for this outline s cookie is slightly different from that of the earlier version. This difference allows you to open both outliners with NN4 in the same session and not worry about one cookie value overlapping with the other. // ** functions that get and set persistent data ** // set persistent data function setCurrState(setting) { if (isNN4) { NN4Cookie = document.cookie = currState2= + escape(setting) } else { // for CSS, data is saved as a global variable instead of cookie CSScurrState = setting } } // retrieve persistent data function getCurrState() { if (isCSS) { // for CSS, data is in global var instead of cookie return CSScurrState } var label = currState2= var labelLen = label.length var cLen = NN4Cookie.length var i = 0 while (i < cLen) { var j = i + labelLen if (NN4Cookie.substring(i,j) == label) { var cEnd = NN4Cookie.indexOf( ; ,j) if (cEnd == -1) { cEnd = NN4Cookie.length } return unescape(NN4Cookie.substring(j,cEnd)) } i++ } return } The toggle() function is called by the onClick event handler of the links surrounding the widget icon art in the outline. A variable number of parameters are passed to this function, so that the parameters are extracted and analyzed via the arguments property of the function. Both browsers with only a few small
Go visit our java server pages services for a reliable, lowcost webhost to satisfy all your needs.

Windows 2003 server web - 1337Chapter 52 .Application: Outline-Style Table of Contents the

Wednesday, January 9th, 2008

1337Chapter 52 .Application: Outline-Style Table of Contents the page, but its appearance does not change; in both the IE4+ and W3C DOMs, the change is immediate, with the rest of the page reflowing to adjust to the change in the block s visibility and presence. Therefore, for NN4, the page still needs to reload itself and remember the state of the outline between reloads (via the same cookie mechanism used for the earlier version) so that the page can set the property value as the page loads. And except for only a couple of places in the code, both the IE4+ and W3C DOMs share positioning code. The CSS version uses the same cookie value (a sequence of 1 and 0values) to represent the visible or hidden state of each item as in the old version. To convey the change of state, however, the function called by the click of an icon widget must pass the index values of the child items affected by the expansion or collapse of a node. This means that more of the HTML in this case, the parameters of the functions has to be hard-wired to the structure of the outline, as you see shortly. Less of this would be necessary if NN4 s implementation of CSS offered the same level of scriptable introspection into HTML elements as IE4 s implementation: We d be able to employ the style property inheritance behavior to simplify the way blocks are shown and hidden. Because the two classes of browsers supported in this example are so different in this regard, the scripting reflects the lowest common denominator for controlling the toggle of expanded and collapsed states. The CSS code By putting so much of the content directly into HTML, the scripting component of the CSS outliner version is significantly smaller than the older version. Where possible, I stayed with the same function and variable naming schemes of the previous version. At the top of the document, I define three styles for the amount of indentation required by the three indentation levels of my sample outline. If the outline were to go to more levels, I would add styles accordingly. Scripting begins by setting some global variables. Browser-specific branching comes into play later, but in an effort to stamp out explicit version detection, the code here relies on object detection to set the requisite flags. Only browsers capable of the CSS style scripting needed here have a document.styleSheetsproperty, so flags are set for the two supported browser classes. These flags are set here primarily as a convenience for writing branching code later. Rather than constantly retesting for the presence of the property, the global flags are shorter and marginally faster. Two more variables hold their respective browser class state values, with the NN4 version maintaining a copy of the cookie as a variable for performance reasons. Now you can modify the two functions in the outliner page as follows: // ** functions that get and set state data ** // set cookie data var mycookie = document.cookie function setCurrState(setting) { mycookie = parent.outlineState = setting } // retrieve cookie data function getCurrState() { return parent.outlineState } Notice that there is no need for the label that has to be assigned to a cookie. The variable name keeps this data separate from the rest of the script space. The only downside to not using a cookie is that the outline state is not preserved if the frameset goes away. If the user revisits the frameset in the same session, the outline state will be reinitialized at its beginning state. Expanding/collapsing all at once If you have an extensive outline, you may want to provide a shortcut to the user to expand everything at once or close up the entire outline. Because the string of 1s and 0s maintains the state of the outline, you can use the dbarray to help you
We highly recommend you visit web and email hosting services if you need stable and cheap web hosting platform for your web applications.

1333Chapter 52 .Application: (Free web design) Outline-Style Table of Contents Next

Monday, January 7th, 2008

1333Chapter 52 .Application: Outline-Style Table of Contents Next comes a decision about whether to display the item text as a link or as plain text. The script inspects the db[i].URL property to see if it is empty. If so, that means no URL is specified for a link, and the item should be built as plain text. If a URL is specified for the item, the script instead constructs a link around the text. In this HTML assembly process, numerous calls to properties of the db array fetch properties of the entry for the URL, the statusbar message, and the text to display. Notice, too, that the link sets the target of the link to the frame name assigned to displayTarget near the top of the script. As you near the end of the loop, two variable values, prevIndentDisplayed and showMyDaughter, are updated with settings from the current traversal through the loop. These values influence the display of nested items for the next entry s journey through the loop. But before looping around again, the script inspects whether the outline is longer than 25 entries. If so, the script writes the outline entries that have accumulated so far, resetting the newOutlinevariable to empty for the next time through the loop. The reasoning behind this last routine is to help long outlines start to display their goods faster. I have seen Web site authors use this outline for literally hundreds of entries. At that quantity, the usually fast JavaScript begins to bog down a bit. By writing lines from a big outline to the page early, the user gets visual feedback that something is happening. Once outside the loop, the script writes whatever last items may have accumulated in the newOutline variable. For outlines with less than 25 items, the whole outline is written in one push; for longer outlines, the value is empty at this point, because the intermediate writings have completed the job. All that s left is to close up standard tags to finish the document definition: document.write(newOutline) // end –> Notice that the document.write()statement here is not followed by document.close(). Because this content is being written as the page loads, the output stream is closed at the end of the page s HTML. Customization possibilities Although this DHTML-free outliner is not the fanciest to be found on the Web, it is, nevertheless, quite popular probably due to its ease of customizability and backward compatibility to all but the earliest browsers (you can find the very original version at my Web site). Other page authors have pushed and pulled on this code to tailor it to a variety of special needs. Alternative displays At the root of almost all significant customization jobs lie modifications to the dbRecord object constructor near the beginning of the page and the HTML assembly portion in the Body. They work hand in hand. For example, one user wants different links in the outline to load pages into different targets. Most links are to load content into another frame of the same frameset, while others are to replace the frameset entirely. In the version provided previously, one target is assumed, and it is set as a global variable. But if you need to provide different targets for each item,
From our experience, we are can tell you that you can find a reliable and cheap webhost service at Java Web Hosting services.

Zeus web server - 1332 Part V . Putting JavaScript to Work

Monday, January 7th, 2008

1332 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 cheap and reliable webhost to host and run your web applications: Coldfusion Web Hosting services.

1331Chapter 52 .Application: Outline-Style Table of Contents Writing (Email web hosting)

Sunday, January 6th, 2008

1331Chapter 52 .Application: Outline-Style Table of Contents Writing the outline At last we reach the document Body, where the outline is assembled and written to the page. Script statements here are immediate, meaning that they execute while the page loads. I have you begin by initializing some variables that you will need in a moment. The most important variable is newOutline, which will be used to accumulate the contents of the outline for eventual writing to the page: Each of those 0s in the parameter to the setCurrState() function corresponds to a collapsed setting for an entry in the outline. In other words, the first time the outline appears, all items are in the collapsed mode. If you modify the outline for your own use by creating your own db array of data, the initial state of the cookie will be set for you automatically based on the length of the db array.
Note: If you are looking for cheap and reliable webhost to host and run your mysql application check mysql web server services.

Web hosting india - 1329Chapter 52 .Application: Outline-Style Table of Contents var

Saturday, January 5th, 2008

1329Chapter 52 .Application: Outline-Style Table of Contents var expanded = currState.charAt(n) // of clicked item newString += currState.substring(0,n) newString += expanded ^ 1 // Bitwise XOR clicked item newString += currState.substring(n+1,currState.length) setCurrState(newString) // write new state back to cookie } To make this happen, you must extract two pieces of information before any processing: the current state from the cookie and the current setting of the clicked item. The latter is saved in a local variable named expandedbecause its 0or 1 value represents the expanded state of that particular entry in the outline. With those information morsels in hand, the script starts building the new binary string that gets written back to the cookie. The new string consists of three pieces: the front part of the existing string up to (but not including) the digit representing the clicked item, the changed entry, and the rest of the original string. Changing the setting of the clicked item from a 0to a 1, or vice versa, is necessary. Although I can implement this task a few different ways (for example, using a conditional expression or an if…else construction), I thought I d exercise an operator that otherwise gets little use: the bitwise XOR operator (^). Because the values involved here are 0and 1, performing an XOR operation with the value of 1 inverts the original value: 0 ^ 1 = 1 1 ^ 1 = 0 Okay, perhaps using an XOR operator is showing off. But the experience forced me to understand a JavaScript power that may come in handy for the future. Selecting a widget image for an entry At this point, the script starts defining functions to help the script statements in the Body write the HTML for the new version of the outline. The getGIF()function determines which of the three widget image files needs to be specified for a particular entry in the outline. The function receives the index value to the dbarray of entries created earlier in the script. As the Body script assembles the HTML for the outline, it calls this function once for each item in the outline. In return, the function provides a reference to one of three Image objects created earlier: // **functions used in assembling updated outline** // returns the proper GIF file name for each entry s control function getGIF(n, currState) { var mom = db[n].mother // is entry a parent? var expanded = currState.charAt(n) // of clicked item if (!mom) { return endpointWidget } else { if (expanded == 1) { return expandedWidget } } return collapsedWidget }
Please visit Domain Name Hosting services for high quality webhost to host and run your jsp applications.