Diff for /books/www/chapters/ch05.html between versions 1.4 and 1.5

version 1.4, 2002/10/03 19:20:52 version 1.5, 2002/11/27 12:53:31
Line 146  document.getElementsByTagName('box')[2]; Line 146  document.getElementsByTagName('box')[2];
 <P>box[0], the first object in the returned array, is a XUL box.  <P>box[0], the first object in the returned array, is a XUL box.
 <P>To see the number of boxes on a page, you can use the <TT>length</TT> property of an array:  <P>To see the number of boxes on a page, you can use the <TT>length</TT> property of an array:
 <PRE>var len = document.getElementsByTagName('box').length;  <PRE>var len = document.getElementsByTagName('box').length;
dump(l+'\n');dump(len+'\n');
 console output: 3</PRE>  console output: 3</PRE>
 <P>To output the <TT>id</TT> of the box:  <P>To output the <TT>id</TT> of the box:
 <PRE>&lt;box id="box-one" /&gt;  <PRE>&lt;box id="box-one" /&gt;
Line 634  generateGetTargetsBoundCallback( ));</PR Line 634  generateGetTargetsBoundCallback( ));</PR
 <P>These two common processes-getting a component and selecting one of its interfaces to assign to an object-can also be separated into two different statements:  <P>These two common processes-getting a component and selecting one of its interfaces to assign to an object-can also be separated into two different statements:
 <PRE>// get the ldap connection component  <PRE>// get the ldap connection component
 var connection = Components.classes  var connection = Components.classes
["@mozilla.org/network/ldap-connection;1";["@mozilla.org/network/ldap-connection;1"];
 // create an object from the nsILDAPConnection interface;  // create an object from the nsILDAPConnection interface;
 connection.createInstance(Components.interfaces.nsILDAPConnection);  connection.createInstance(Components.interfaces.nsILDAPConnection);
 // call the init( ) method on that object  // call the init( ) method on that object
Line 714  JSLib -->  <!--INDEX application program Line 714  JSLib -->  <!--INDEX application program
   
 <P><I>Table 5-1: <A NAME="77010"></A></I>  <P><I>Table 5-1: <A NAME="77010"></A></I>
 <I>JSLib classes</I>  <I>JSLib classes</I>
<P><TABLE WIDTH=100% BORDER=1><TR><TD><B>  Class / (filename)</B></TD> <TD><B>  Description</B></TD></TR><p><i>Table 5-1: <a name="77010"></a></i><i>JSLib classes</i></p>
<TR><TD>  File / (</TD><I>file.js</I>)      <TD>  Contains most routines associated with the File object (implementing </TD><TT>nsIFile</TT>). The library is part of the jslib I/O module.</TR><p>
<TR><TD>  FileUtils / (</TD><I>fileUtils.js</I>)     <TD>  The chrome registry to local file path conversion, file metadata, etc.</TD></TR><table width="100%" border="1">
<TR><TD>  Dir / (</TD><I>dir.js</I>)     <TD>  Directory creation; variations of directory listings.</TD></TR>  <tbody>
<TR><TD>  DirUtils / (</TD><I>dirUtils.js</I>)     <TD>  Paths to useful Mozilla directories and files such as </TD><I>chrome</I>, <I>prefs</I>, <I>bookmarks</I>, <I>localstore</I>, etc.</TR></TABLE><P>    <tr>
       <td><b>  Class / (filename)</b></td>
         <td><b>  Description</b></td>
 
     </tr>
     <tr>
       <td>  File / (<i>file.js</i>)      </td>
          <td>Contains most routines associated with the File object (implementing
       <tt>nsIFile</tt>). The library is part of the jslib I/O module.   
   </td>
    </tr>
 
     <tr>
       <td>  FileUtils / (<i>fileUtils.js</i>)</td>
         <td>The chrome registry to local file path conversion, file metadata,
 etc.</td>
     </tr>
     <tr>
       <td>  Dir / (<i>dir.js</i>)</td>
 
        <td>Directory creation; variations of directory listings.</td>
     </tr>
     <tr>
       <td>  DirUtils / (<i>dirUtils.js</i>)</td>
          <td>Paths to useful Mozilla directories and files such as      
      <i>chrome</i>, <i>prefs</i>, <i>bookmarks</i>, <i>localstore</i>, etc.</td>
 
      </tr>
   </tbody>
 </table>
 </p>
   
 <H4><A NAME="77074"></A> Using the File class</H4>  <H4><A NAME="77074"></A> Using the File class</H4>
 <P>The JSLib <TT>File</TT>  <!--INDEX classes:JSLib:File -->  <!--INDEX File class, JSLib -->  <!--INDEX JSLib libraries:File class -->  <!--INDEX JavaScript:application programming:JSLib File class -->  <!--INDEX application programming, JavaScript:JSLib File class --> class exposes most local file routines from the <I>nsIFile</I> interface. The <TT>File</TT> class is part of the JSLib I/O module, and is defined in <I>jslib/io/file.js</I>. Here is how you load the library from xpcshell:  <P>The JSLib <TT>File</TT>  <!--INDEX classes:JSLib:File -->  <!--INDEX File class, JSLib -->  <!--INDEX JSLib libraries:File class -->  <!--INDEX JavaScript:application programming:JSLib File class -->  <!--INDEX application programming, JavaScript:JSLib File class --> class exposes most local file routines from the <I>nsIFile</I> interface. The <TT>File</TT> class is part of the JSLib I/O module, and is defined in <I>jslib/io/file.js</I>. Here is how you load the library from xpcshell:
 <PRE>$ ./run-mozilla.sh ./xpcshell -w -s  <PRE>$ ./run-mozilla.sh ./xpcshell -w -s
js&gt; load(`chrome/jslib/jslib.js');js&gt; load('chrome/jslib/jslib.js');
 *********************  *********************
 JS_LIB DEBUG IS ON  JS_LIB DEBUG IS ON
 *********************  *********************
Line 867  This book does not pretend Line 897  This book does not pretend
 to give a complete overview of JavaScript. You  to give a complete overview of JavaScript. You
 can view the full JavaScript 1.5 reference online  can view the full JavaScript 1.5 reference online
 at  at
<I><A HREF="http://developer.netscape.com/docs/manuals/js/">http://developer.netscape.com/docs/manuals/js/</A></I><I><A HREF="http://developer.netscape.com/docs/manuals/index.html?content=javascript.html ">http://developer.netscape.com/docs/manuals/index.html?content=javascript.html </A></I>
 core/jsref15/contents.html.  core/jsref15/contents.html.
 <HR><A NAME="261"></A><A HREF="#b261">[Back]</A>  <HR><A NAME="261"></A><A HREF="#b261">[Back]</A>
 <A NAME="77035"></A>  <A NAME="77035"></A>

Removed from v.1.4  
changed lines
  Added in v.1.5


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>