<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:series="http://unfoldingneurons.com/"
> <channel><title>Comments on: MooTools &amp; Printing &#8211; Creating a Links Table of&#160;Contents</title> <atom:link href="http://davidwalsh.name/mootools-print-links/feed" rel="self" type="application/rss+xml" /><link>http://davidwalsh.name/mootools-print-links</link> <description>Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞.</description> <lastBuildDate>Thu, 09 Feb 2012 09:55:41 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3</generator> <item><title>By: Sara</title><link>http://davidwalsh.name/mootools-print-links/comment-page-1#comment-13793</link> <dc:creator>Sara</dc:creator> <pubDate>Thu, 19 Nov 2009 21:26:58 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=1983#comment-13793</guid> <description>I came up with my own solution:/* when the dom is ready */
window.addEvent(&#039;domready&#039;,function() {
/* get the links */
var links = $$(&#039;#print-content-area a&#039;);
/* remove from the array named anchors lacking an &quot;href&quot; property */
function notNull(a) {
return(a.get(&#039;href&#039;) != undefined);
}
var filteredLinks = links.filter(notNull);/* if there are any */
if(filteredLinks.length) {
/* create toc list */
var container = new Element(&#039;ol&#039;,{
&#039;class&#039;: &#039;print-only toc-list&#039;
}).inject(document.body,&#039;bottom&#039;);
/* add a heading for the TOC */
var header = new Element(&#039;h2&#039;,{
text: &#039;Links In This Document&#039;
}).inject(container,&#039;top&#039;);
/* get links inside the content area */
filteredLinks.each(function(a,i) {
/* insert the span reference right after the link */
/*if(a.get(&#039;href&#039;) != undefined){*/
new Element(&#039;span&#039;,{
text: &#039;[&#039; + (i + 1) + &#039;]&#039;,
&#039;class&#039;: &#039;print-only&#039;
}).inject(a,&#039;after&#039;);
/* record anchor, put in list */
new Element(&#039;li&#039;,{
text: a.get(&#039;href&#039;)
}).inject(container,&#039;bottom&#039;);
/*}*/
});
}
}); </description> <content:encoded><![CDATA[<p>I came up with my own solution:</p><p>/* when the dom is ready */<br
/> window.addEvent(&#8216;domready&#8217;,function() {<br
/> /* get the links */<br
/> var links = $$(&#8216;#print-content-area a&#8217;);</p><p> /* remove from the array named anchors lacking an &#8220;href&#8221; property */<br
/> function notNull(a) {<br
/> return(a.get(&#8216;href&#8217;) != undefined);<br
/> }<br
/> var filteredLinks = links.filter(notNull);</p><p> /* if there are any */<br
/> if(filteredLinks.length) {<br
/> /* create toc list */<br
/> var container = new Element(&#8216;ol&#8217;,{<br
/> &#8216;class&#8217;: &#8216;print-only toc-list&#8217;<br
/> }).inject(document.body,&#8217;bottom&#8217;);<br
/> /* add a heading for the TOC */<br
/> var header = new Element(&#8216;h2&#8242;,{<br
/> text: &#8216;Links In This Document&#8217;<br
/> }).inject(container,&#8217;top&#8217;);<br
/> /* get links inside the content area */<br
/> filteredLinks.each(function(a,i) {<br
/> /* insert the span reference right after the link */<br
/> /*if(a.get(&#8216;href&#8217;) != undefined){*/<br
/> new Element(&#8216;span&#8217;,{<br
/> text: &#8216;[' + (i + 1) + ']&#8216;,<br
/> &#8216;class&#8217;: &#8216;print-only&#8217;<br
/> }).inject(a,&#8217;after&#8217;);<br
/> /* record anchor, put in list */<br
/> new Element(&#8216;li&#8217;,{<br
/> text: a.get(&#8216;href&#8217;)<br
/> }).inject(container,&#8217;bottom&#8217;);<br
/> /*}*/<br
/> });<br
/> }<br
/> });</p> ]]></content:encoded> </item> <item><title>By: Sara</title><link>http://davidwalsh.name/mootools-print-links/comment-page-1#comment-13788</link> <dc:creator>Sara</dc:creator> <pubDate>Thu, 19 Nov 2009 16:37:26 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=1983#comment-13788</guid> <description>This is great, except that the part of the page I want to show links from also includes some named anchors for internal page navigation. These show up as blanks in the list of links, since they lack the href attribute. Is there someway to prevent the inclusion of these named anchors in the list of links?</description> <content:encoded><![CDATA[<p>This is great, except that the part of the page I want to show links from also includes some named anchors for internal page navigation. These show up as blanks in the list of links, since they lack the href attribute. Is there someway to prevent the inclusion of these named anchors in the list of links?</p> ]]></content:encoded> </item> <item><title>By: Crispijn</title><link>http://davidwalsh.name/mootools-print-links/comment-page-1#comment-8514</link> <dc:creator>Crispijn</dc:creator> <pubDate>Wed, 01 Apr 2009 21:13:52 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=1983#comment-8514</guid> <description>Isn&#039;t it faster to create the link list via php? Just select the links with a preg&#095;match&#095;all and insert it at the bottom of the page... I&#039;ll make a quick example soon!</description> <content:encoded><![CDATA[<p>Isn&#8217;t it faster to create the link list via php? Just select the links with a preg&#95;match&#95;all and insert it at the bottom of the page&#8230; I&#8217;ll make a quick example soon!</p> ]]></content:encoded> </item> <item><title>By: deef</title><link>http://davidwalsh.name/mootools-print-links/comment-page-1#comment-8492</link> <dc:creator>deef</dc:creator> <pubDate>Wed, 01 Apr 2009 06:40:10 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=1983#comment-8492</guid> <description>Nice feature!David, your Sugar &amp; Style Ajax loader is driving me bananas... I keep waiting for it to load.</description> <content:encoded><![CDATA[<p>Nice feature!</p><p>David, your Sugar &amp; Style Ajax loader is driving me bananas&#8230; I keep waiting for it to load.</p> ]]></content:encoded> </item> <item><title>By: David Walsh</title><link>http://davidwalsh.name/mootools-print-links/comment-page-1#comment-8488</link> <dc:creator>David Walsh</dc:creator> <pubDate>Wed, 01 Apr 2009 02:23:57 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=1983#comment-8488</guid> <description>&lt;p&gt;Simple but highly useful!  I love it!  Oh wait...I wrote it.  David Walsh and MooTools FTW!&lt;/p&gt;</description> <content:encoded><![CDATA[<p>Simple but highly useful!  I love it!  Oh wait&#8230;I wrote it.  David Walsh and MooTools FTW!</p> ]]></content:encoded> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced (User agent is rejected)
Database Caching 1/12 queries in 0.007 seconds using disk: basic
Object Caching 540/541 objects using disk: basic

Served from: davidwalsh.name @ 2012-02-09 05:11:37 -->
