This is a first stab, not rigorously tested so it might have pitfalls but it seems to work and cover the correct bases. The layout could be used to restart the CB refresh (on a 10 second timer in the dummy code) as long as the user is interacting with the page; no clicky, no mousy, no chatty. If they go away for 2 hours, or 2 weeks for that matter, and come back it would start working again as soon as they triggered one of the bound events. Working sample to play with-

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US"> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <title>Body listener + timeOut test</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery. +js" type="text/javascript"></script> <script type="text/javascript">//<![CDATA[ // This would be the function that refreshes CB. function ohHaiCB () { $("body").prepend("<h1>It'll be just like starting over</h1>"); // Clear our place holder so any page even will restart // timeOut to call this function again. $(".myperfectlyuniqueid").remove(); } jQuery(function($) { // Bind to some interaction-y events. $("body").bind("focus resize scroll click mouseover keypress", function(evt){ $("body").prepend("<span> Got a " + evt.type + " </span>"); // We keep a placeholder element/node to know // if we're already in a setTimeOut. if ( $(".myperfectlyuniqueid").size() ) return true; // It wasn't there so refresh the CB. setTimeout(ohHaiCB, 10000); // Create our place holder element. // Why class instead of id? It's less likely to be // buggy x-browser which can do weird/different things // with DOM node removal. var placeHolder = $("<div class='myperfectlyuniqueid'/>"); // Hide it even though it's empty. placeHolder.hide(); // Tack it into the body. $("body").append(placeHolder); }); }); //]]> </script> </head> <body> <p>Something here to start.</p> </body></html>

To do the selectors for PM something like-

<script type="text/javascript">//<![CDATA[ jQuery(function($) { $("td.main_content, td.nodelets").bind("focus resize scroll click mo +useover keypress", function(){ // et cetera }); }); //]]> </script>

In reply to Re^5: Free Nodelet Hack: AJAX-enabled Chatterbox by Your Mother
in thread Free Nodelet Hack: AJAX-enabled Chatterbox by bellaire

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.