// What XML generators are currently available on PerlMonks? https://perlmonks.org/?node_id=72241 // PerlMonks Related Scripts https://perlmonks.org/?node_id=26649 // REQUIRES he.js "use strict"; // throw("Not ready to be incurring load from regular visits"); jQuery(function($) { let $currentMsg = $(".cb_msg"); setTimeout(function(){ $currentMsg.fadeOut(function(){ $(this).remove() }) }, 500000); //
'); let intID; let chatURI = document.location.origin + "/bare/"; // .cb_table // Timer, interval, like gmail; check frequently if there are a lot of current messages. // Less and less frequently when there is none. // getCB // displayCB function getCB ( arg ) { if ( ! arg ) arg = { timeout: 5000 }; if ( arg.timeout < 500000 ) arg.timeout += 10000; // maybe 10% of current instead? let queryData = { "node_id":207304 // hardcode node… ,"xmlstyle":"modern" } // Get the parsed->rendered messages. $.ajax({ method: "GET" ,url: chatURI ,data: queryData ,dataType: "xml" }) .fail(function(jqXHR, textStatus, errorThrown){ console.log(jqXHR); console.log([textStatus, errorThrown || "unknown"].join(": ")); console.log('setTimeout( getCB, ' + arg.timeout + ', arg );'); intID = setTimeout( getCB, arg.timeout, arg ); }) .done(function( xml, textStatus, jqXHR ) { console.log("Received…", xml); if ( ! xml ) { console.log('setTimeout( getCB, ' + arg.timeout + ', arg );'); intID = setTimeout( getCB, arg.timeout, arg ); return false; } // Getting null sometimes. let messages = xml.getElementsByTagName("message"); if ( ! messages.length ) { console.log('setTimeout( getCB, ' + arg.timeout + ', arg );'); intID = setTimeout( getCB, arg.timeout, arg ); return false; } let $CBtable = $("table.cb_table"); if ( ! $CBtable.length ) { // No messages in the page currently… $CBtable = $(' $("table.cb_table").css({margin:"1ex 0", fontSize:"1.4rem"}); // Dup. let $CBform = $("input[type='submit'][name='message_send']").closest("form"); $CBform.find("input[name='message']").css({width:"100%",border:"1px solid gray",borderRadius:"2px"}); $CBform.find("input[name='message_send']").hide(); $CBform.parent().find("hr, input[type='checkbox']").remove(); $CBform.find("label, span.msg, span.cb_more_messages").delay(15000).slideUp(1000, function(){ $CBform.parent().find("br").remove() }); //span.cb_more_messages $CBform.parent().css({padding:0}); // Needs some click animation- $("input[type='submit']").css({border:"1px solid gray",borderRadius:"2px",margin:"2px 3px"}); $("i.cb_quiet").wrap('