chẳng hạn như Tên và địa chỉ, sẽ không làm việc bởi vì bạn sẽ không biết thời gian phát triển những gì các trường để tìm kiếm. Đây là một công việc hoàn hảo cho composite. đầu vào, lựa chọn, và các thẻ textarea. | CHAPTER 11 THE ADAPTER PATTERN 155 id function msgObject var resp eval msgObject var details p strong From strong from br details strong Sent strong date p details p strong Message strong br details message p details resp Set up mail implementation. addEvent window load function var threads getElementsByClass thread a var messagePane message-pane for var i 0 len i len i addEvent threads i click formatMessage script head body div id doc h1 Email Application Interface h1 ul li a class thread href id msg-1 load message Sister Sonya a li li a class thread href id msg-2 load message Lindsey Simon a li li a class thread href id msg-3 load message Margaret Stoooart a li ul div id message-pane div div body html 156 CHAPTER 11 THE ADAPTER PATTERN Before going into more detail about the code here is a brief snapshot of the final output after clicking one of the message items. It should give you a better idea of what you ll be working with. The first thing you might notice is that the base set of utilities which includes getElementsByClass and addEvent is included. Next a few application utilities are added onto the namespace which will aid in the application development. The . substitute method basically allows you to substitute strings when supplied an object literal. Here is an example var substitutionobject name world place Google var text Hello name welcome to place var replacedText text substitutionObject replacedText produces Hello world welcome to Google The next utility function is an asyncRequest function that lets you make calls to the back end. Note also that a lazy loading technique is used that abstracts the XMLHttpRequest object by branching at load time to take care of browser differences. Then the getXHR function is reassigned after the first time it is called to get the XHR object. This will speed up the application tremendously by .