Đang chuẩn bị liên kết để tải về tài liệu:
JavaScript Bible, Gold Edition part 158

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

JavaScript Bible, Gold Edition part 158. This book will bring programmers and non-technical professionals, including casual programmers and scripters, painlessly up to speed on all aspects of mastering JavaScript. Key topics include programming fundamentals, JavaScript language elements and how to use them effectively, and how to easily and efficiently add powerful new functionality to HTML documents and Java applets. | 1418 Part V Putting JavaScript to Work colors aren t easily distinguishable in Figure 57-1 but if you open the actual example listing in IE5 Windows on your computer you will see the coloration. Implementation Plan Clearly all the data needed for numerous sorted and ordered views arrives in one batch in the XML island. Despite the element and node referencing properties and methods of the W3C DOM trying to use the XML elements as the sole data store for scripts to sort the data each time would be impractical. For one thing none of the elements have ID attributes there s no need for it in the XML stored on the server database. And even if they did have IDs how would scripts that you desire to write for generalizability make use of them unless the IDs were generated in a well-known sequence Moreover after a sales rep s record is rendered in the table how easy would it be to dive back into that record and drill down for further information such as the name of a representative s manager A solution that can empower the page author in this case is to use the nodewalking properties and methods of the W3C DOM to assemble a JavaScript-structured database while the page loads. In other words the conversion is performed just once during page loading and the JavaScript version is preserved in an array of XML records in this case as a global variable. Any transformations on the data can be done from the JavaScript database with the help of additional powers of the language. Given that route the basic operation of the scripting of the page is schematically simple 1. Convert the XML into an array of objects at load time. 2. Predefine all necessary sorting functions based on properties of those objects. 3. Provide a function that rebuilds the HTML table each time data is sorted. With this sequence in mind now look into the code that does the job. The Code Rather than work through the long document in source code order the following descriptions follow a more functional order. You