<?xml version="1.0" encoding="windows-1252"?>
<node id="888694" title="Free nodelet hack: Auto-Fold threads in RAT for special browsers" created="2011-02-17 07:04:28" updated="2011-02-17 07:04:28">
<type id="1036">
monkdiscuss</type>
<author id="708738">
LanX</author>
<data>
<field name="doctext">
The following code expands [id://399316] in different aspects.&lt;P&gt;&lt;P&gt;

It checks if I'm surfing perlmonks with my (small screen) mobile (&lt;c&gt;appName=="Obigo"&lt;/c&gt;) and automatically collapses only root nodes of threads (&lt;c&gt;nnt-depth-1&lt;/c&gt;).&lt;P&gt;&lt;P&gt;

A link in the "Free Nodelet" allows to toggle the folding. &lt;P&gt;&lt;P&gt;

This code is a blueprint for customizing appearance and UI in different browsers. The navigator object provides more attributes to distinguish browser and OS.&lt;P&gt;&lt;P&gt;


Suggestions welcomed! :)&lt;P&gt;&lt;P&gt;

&lt;code&gt;
&lt;script language="javascript"&gt;&lt;!--
 var expandState="expanded";
 function toggle_threads(){
    expandState  = (expandState=='expanded')
                       ? 'collapsed'
                       : 'expanded'
                       ;
    var elements = document.getElementsByTagName('ul');
    var elnum;
    for( elnum=0; elnum&lt;elements.length; elnum++ ){
        var el = elements[elnum];
        if ( el.parentNode.className.match(/nnt-depth-1/) )
           el.className = expandState;
    }
 }
 
 if ( document.title=="Recently Active Threads" ) {
    document.writeln('&lt;a href="javascript:toggle_threads()"&gt;+/- Threads&lt;/a&gt;');
    if (navigator.appName=="Obigo")
       toggle_threads();
 }
//--&gt;&lt;/script&gt;
&lt;/code&gt;&lt;P&gt;&lt;P&gt;


&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-708738"&gt;
&lt;p&gt;Cheers Rolf
&lt;/div&gt;&lt;/div&gt;</field>
</data>
</node>
