<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://wbex.ru/index.php?action=history&amp;feed=atom&amp;title=JavaScript_DHTML%2FPage_Components%2FTable_Of_Content</id>
		<title>JavaScript DHTML/Page Components/Table Of Content - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://wbex.ru/index.php?action=history&amp;feed=atom&amp;title=JavaScript_DHTML%2FPage_Components%2FTable_Of_Content"/>
		<link rel="alternate" type="text/html" href="http://wbex.ru/index.php?title=JavaScript_DHTML/Page_Components/Table_Of_Content&amp;action=history"/>
		<updated>2026-04-05T02:40:38Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://wbex.ru/index.php?title=JavaScript_DHTML/Page_Components/Table_Of_Content&amp;diff=3568&amp;oldid=prev</id>
		<title> в 10:00, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://wbex.ru/index.php?title=JavaScript_DHTML/Page_Components/Table_Of_Content&amp;diff=3568&amp;oldid=prev"/>
				<updated>2010-05-26T10:00:10Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 10:00, 26 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://wbex.ru/index.php?title=JavaScript_DHTML/Page_Components/Table_Of_Content&amp;diff=3569&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://wbex.ru/index.php?title=JavaScript_DHTML/Page_Components/Table_Of_Content&amp;diff=3569&amp;oldid=prev"/>
				<updated>2010-05-26T07:26:26Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Create a table of contents(TOC) for this document==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
Examples From&lt;br /&gt;
JavaScript: The Definitive Guide, Fourth Edition&lt;br /&gt;
Legal matters: these files were created by David Flanagan, and are&lt;br /&gt;
Copyright (c) 2001 by David Flanagan.  You may use, study, modify, and&lt;br /&gt;
distribute them for any purpose.  Please note that these examples are&lt;br /&gt;
provided &amp;quot;as-is&amp;quot; and come with no warranty of any kind.&lt;br /&gt;
David Flanagan&lt;br /&gt;
*/&lt;br /&gt;
/**&lt;br /&gt;
 * Create a table of contents for this document, and insert the TOC into&lt;br /&gt;
 * the document by replacing the node specified by the replace argument.&lt;br /&gt;
 **/&lt;br /&gt;
function maketoc(replace) {&lt;br /&gt;
    // Create a &amp;lt;div&amp;gt; element that is the root of the TOC tree&lt;br /&gt;
    var toc = document.createElement(&amp;quot;div&amp;quot;);&lt;br /&gt;
    // Set a background color and font for the TOC.  We&amp;quot;ll learn about&lt;br /&gt;
    // the style property in the next chapter&lt;br /&gt;
    toc.style.backgroundColor = &amp;quot;white&amp;quot;;&lt;br /&gt;
    toc.style.fontFamily = &amp;quot;sans-serif&amp;quot;;&lt;br /&gt;
    // Start the TOC with an anchor so we can link back to it.&lt;br /&gt;
    var anchor = document.createElement(&amp;quot;a&amp;quot;);  // Create an &amp;lt;a&amp;gt; node&lt;br /&gt;
    anchor.setAttribute(&amp;quot;name&amp;quot;, &amp;quot;TOC&amp;quot;);        // Give it a name&lt;br /&gt;
    toc.appendChild(anchor);                   // And insert it&lt;br /&gt;
    // Make the body of the anchor the title of the TOC&lt;br /&gt;
    anchor.appendChild(document.createTextNode(&amp;quot;Table Of Contents&amp;quot;));&lt;br /&gt;
    // Create a &amp;lt;table&amp;gt; element that will hold the TOC and add it &lt;br /&gt;
    var table = document.createElement(&amp;quot;table&amp;quot;);&lt;br /&gt;
    toc.appendChild(table);&lt;br /&gt;
    // Create a &amp;lt;tbody&amp;gt; element that holds the rows of the TOC&lt;br /&gt;
    var tbody = document.createElement(&amp;quot;tbody&amp;quot;);&lt;br /&gt;
    table.appendChild(tbody);&lt;br /&gt;
    // Initialize an array that keeps track of section numbers&lt;br /&gt;
    var sectionNumbers = [0,0,0,0,0,0];&lt;br /&gt;
    // Recursively traverse the body of the document, looking for sections&lt;br /&gt;
    // marked with &amp;lt;h1&amp;gt;, &amp;lt;h2&amp;gt;, ... tags, and use them to create the TOC&lt;br /&gt;
    // by adding rows to the table.&lt;br /&gt;
    addSections(document.body, tbody, sectionNumbers);&lt;br /&gt;
    // Finally, insert the TOC into the document by replacing the node&lt;br /&gt;
    // specified by the replace argument with the TOC sub-tree&lt;br /&gt;
    replace.parentNode.replaceChild(toc, replace);&lt;br /&gt;
    // This method recursively traverses the tree rooted at node n, looking&lt;br /&gt;
    // for &amp;lt;h1&amp;gt; through &amp;lt;h6&amp;gt; tags and uses the content of these tags to build&lt;br /&gt;
    // the table of contents by adding rows to the HTML table specified by the&lt;br /&gt;
    // toc argument.  It uses the sectionNumbers array to keep track of the&lt;br /&gt;
    // current section number.&lt;br /&gt;
    // This function is defined inside of maketoc() so that it is not&lt;br /&gt;
    // visible from the outside.  maketoc() is the only function&lt;br /&gt;
    // exported by this JavaScript module.&lt;br /&gt;
    function addSections(n, toc, sectionNumbers) {&lt;br /&gt;
        // Loop through all the children of n&lt;br /&gt;
        for(var m = n.firstChild; m != null; m = m.nextSibling) {&lt;br /&gt;
      // Check whether m is a heading element.  It would be nice if we&lt;br /&gt;
            // could just use (m instanceof HTMLHeadingElement), but this is&lt;br /&gt;
            // not required by the specification and it does not work in IE.&lt;br /&gt;
            // Therefore we&amp;quot;ve got to check the tagname to see if it is H1-H6.&lt;br /&gt;
            if ((m.nodeType == 1) &amp;amp;&amp;amp;  /* Node.ELEMENT_NODE */ &lt;br /&gt;
                (m.tagName.length == 2) &amp;amp;&amp;amp; (m.tagName.charAt(0) == &amp;quot;H&amp;quot;)) {&lt;br /&gt;
    // Figure out what level heading it is&lt;br /&gt;
                var level = parseInt(m.tagName.charAt(1));&lt;br /&gt;
                if (!isNaN(level) &amp;amp;&amp;amp; (level &amp;gt;= 1) &amp;amp;&amp;amp; (level &amp;lt;= 6)) {&lt;br /&gt;
        // Increment the section number for this heading level&lt;br /&gt;
        sectionNumbers[level-1]++;&lt;br /&gt;
        // And reset all lower heading level numbers to zero&lt;br /&gt;
        for(var i = level; i &amp;lt; 6; i++) sectionNumbers[i] = 0;&lt;br /&gt;
        // Now combine section numbers for all heading levels&lt;br /&gt;
        // to produce a section number like 2.3.1&lt;br /&gt;
        var sectionNumber = &amp;quot;&amp;quot;;&lt;br /&gt;
        for(var i = 0; i &amp;lt; level; i++) {&lt;br /&gt;
      sectionNumber += sectionNumbers[i];&lt;br /&gt;
      if (i &amp;lt; level-1) sectionNumber += &amp;quot;.&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
        // Create an anchor to mark the beginning of this section.&lt;br /&gt;
        // This will be the target of a link we add to the TOC.&lt;br /&gt;
        var anchor = document.createElement(&amp;quot;a&amp;quot;);&lt;br /&gt;
        anchor.setAttribute(&amp;quot;name&amp;quot;, &amp;quot;SECT&amp;quot;+sectionNumber);&lt;br /&gt;
        // Create a link back to the TOC and make it a&lt;br /&gt;
        // child of the anchor&lt;br /&gt;
        var backlink = document.createElement(&amp;quot;a&amp;quot;);&lt;br /&gt;
        backlink.setAttribute(&amp;quot;href&amp;quot;, &amp;quot;#TOC&amp;quot;);&lt;br /&gt;
        backlink.appendChild(document.createTextNode(&amp;quot;Contents&amp;quot;));&lt;br /&gt;
        anchor.appendChild(backlink);&lt;br /&gt;
        // Insert the anchor into the document right before the&lt;br /&gt;
        // section header&lt;br /&gt;
        n.insertBefore(anchor, m);&lt;br /&gt;
        // Now create a link to this section.  It will be added&lt;br /&gt;
        // to the TOC below.&lt;br /&gt;
        var link = document.createElement(&amp;quot;a&amp;quot;);&lt;br /&gt;
        link.setAttribute(&amp;quot;href&amp;quot;, &amp;quot;#SECT&amp;quot; + sectionNumber);&lt;br /&gt;
        // Get the heading text using a function defined below&lt;br /&gt;
        var sectionTitle = getTextContent(m);&lt;br /&gt;
        // Use the heading text as the content of the link.&lt;br /&gt;
        link.appendChild(document.createTextNode(sectionTitle));&lt;br /&gt;
        // Create a new row for the TOC&lt;br /&gt;
        var row = document.createElement(&amp;quot;tr&amp;quot;);&lt;br /&gt;
        // Create two columns for the row&lt;br /&gt;
        var col1 = document.createElement(&amp;quot;td&amp;quot;);&lt;br /&gt;
        var col2 = document.createElement(&amp;quot;td&amp;quot;);&lt;br /&gt;
        // Make the first column right-aligned and put the section&lt;br /&gt;
        // number in it&lt;br /&gt;
        col1.setAttribute(&amp;quot;align&amp;quot;, &amp;quot;right&amp;quot;);&lt;br /&gt;
        col1.appendChild(document.createTextNode(sectionNumber));&lt;br /&gt;
        // Put a link to the section in the second column&lt;br /&gt;
        col2.appendChild(link);&lt;br /&gt;
        // Add the columns to the row, and the row to the table&lt;br /&gt;
        row.appendChild(col1);&lt;br /&gt;
        row.appendChild(col2);&lt;br /&gt;
        toc.appendChild(row);&lt;br /&gt;
        // Modify the section header element itself to add&lt;br /&gt;
        // the section number as part of the section title&lt;br /&gt;
        m.insertBefore(document.createTextNode(sectionNumber+&amp;quot;: &amp;quot;),&lt;br /&gt;
           m.firstChild);&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
      else { // Otherwise, this is not a heading element, so recurse&lt;br /&gt;
    addSections(m, toc, sectionNumbers);&lt;br /&gt;
      }&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    // This utility function traverses the node n, returning the content of&lt;br /&gt;
    // all text nodes found, and discarding any HTML tags.  This is also&lt;br /&gt;
    // defined as a nested function so that it is private to this module.&lt;br /&gt;
    function getTextContent(n) {&lt;br /&gt;
        var s = &amp;quot;&amp;quot;;&lt;br /&gt;
        var children = n.childNodes;&lt;br /&gt;
        for(var i = 0; i &amp;lt; children.length; i++) {&lt;br /&gt;
            var child = children[i];&lt;br /&gt;
            if (child.nodeType == 3 /*Node.TEXT_NODE*/) s += child.data;&lt;br /&gt;
            else s += getTextContent(child);&lt;br /&gt;
        }&lt;br /&gt;
        return s;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>