Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Free nodelet hack: Auto-Fold threads in RAT for special browsers

by LanX (Canon)
on Feb 17, 2011 at 12:04 UTC ( #888694=monkdiscuss: print w/ replies, xml ) Need Help??

The following code expands Free Nodelet Hack: RAT collapse all in different aspects.

It checks if I'm surfing perlmonks with my (small screen) mobile (appName=="Obigo") and automatically collapses only root nodes of threads (nnt-depth-1).

A link in the "Free Nodelet" allows to toggle the folding.

This code is a blueprint for customizing appearance and UI in different browsers. The navigator object provides more attributes to distinguish browser and OS.

Suggestions welcomed! :)

<script language="javascript"><!-- var expandState="expanded"; function toggle_threads(){ expandState = (expandState=='expanded') ? 'collapsed' : 'expanded' ; var elements = document.getElementsByTagName('ul'); var elnum; for( elnum=0; elnum<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('<a href="javascript:toggle_threads()">+/- Thread +s</a>'); if (navigator.appName=="Obigo") toggle_threads(); } //--></script>

Cheers Rolf

Comment on Free nodelet hack: Auto-Fold threads in RAT for special browsers
Select or Download Code
Replies are listed 'Best First'.
Re: Free nodelet hack: Auto-Fold threads in RAT
by LanX (Canon) on Jan 31, 2015 at 19:09 UTC
    NEW Feature:

    always collapse "+/- Legend" away!

    appName check disabled, just put your selective clients in there if you need it

    (AutoFolding of RAT head and foot unfortunately to difficult ATM)

    <script language="javascript"><!-- var expandState="expanded"; function toggle_threads(){ expandState = (expandState=='expanded') ? 'collapsed' : 'expanded' ; var elements = document.getElementsByTagName('ul'); var elnum; for( elnum=0; elnum<elements.length; elnum++ ){ var el = elements[elnum]; if ( el.parentNode.className.match(/nnt-depth-1/) ) el.className = expandState; if ( el.id == 'ul-legend') el.className = 'collapsed'; } } if ( document.title.match(/Recently Active Threads/) ) { document.writeln('<a href="javascript:toggle_threads()">+/- All Th +reads</a>'); // if (navigator.appName=="Obigo") toggle_threads(); // auto collapse at start } //--></script>

    Cheers Rolf

    PS: Je suis Charlie!

      more collapsing

      RAT head and foot now auto-collapsed. Headlines for manual unfolding added.

      <!-- ==================================================== COLLAPSING RAT VIEW 2.02 ==================================================== --> <style type="text/css"> <!-- p.collapsed, form.collapsed { display:none; } p.expanded, form.expanded { display:block; } --> </style> <script language="javascript"><!-- var expandState="expanded"; function toggle_threads(){ expandState = (expandState=='expanded') ? 'collapsed' : 'expanded' ; var elements = document.getElementsByTagName('ul'); var elnum; for( elnum=0; elnum<elements.length; elnum++ ){ var el = elements[elnum]; if ( el.parentNode.className.match(/nnt-depth-1/) ) el.className = expandState; if ( el.id == 'ul-legend') el.className = 'collapsed'; } } function collapse_RAT_head_n_foot() { // --- hide head var head_div = document.getElementById('nodethreads-head'); var head_p = head_div.children[0]; head_p.id = 'head-view'; head_p.className = 'collapsed'; var title_html = '<h3 onclick="toggleMenu(\'head-view\')"> +/- Vie +w </h3>'; head_div.innerHTML = title_html + head_div.innerHTML; // --- hide foot var config_form = document.forms[2]; var config_head = document.getElementsByName('nnt-config')[0]; config_form.id ='form-config'; config_form.className ='collapsed'; config_head.innerHTML = "+/- " + config_head.innerHTML; config_head.onclick = function () { toggleMenu('form-config') }; } if ( document.title.match(/Recently Active Threads/) ) { collapse_RAT_head_n_foot(); document.writeln('<a href="javascript:toggle_threads()">+/- Thread +s</a>'); // if (navigator.appName=="Obigo") toggle_threads(); } //--></script>

      update

      Todo:

    • global expand toggle: move from free nodelet to main pane
    • disable section title links , let collapse too
    • collapse top right navigation
    • shorten repeated parts in post titles per thread
    • +- toggle hard to click, click thread title instead
    • collapse nodelets
    • add icons for navigation
    • collapse posts text in full thread

      Cheers Rolf

      PS: /Je suis Charlie!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: monkdiscuss [id://888694]
Approved by Old_Gray_Bear
Front-paged by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (13)
As of 2015-09-04 23:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred temperature scale is:










    Results (150 votes), past polls