// this moved to default javascript and retired 2010-10-07 --DonJaime
function replyToCB(s, onlineonly) {
var mbox = jQuery('#message')[0] ;
mbox.value = ( onlineonly ? '/msg? ' : '/msg ' ) + s + " ";
// move the cursor to the end of the text box
if (mbox.createTextRange) { // IE
var r = mbox.createTextRange();
r.moveStart('character', mbox.value.length);
r.select();
} else { // other, in particular webkit
mbox.focus();
if (mbox.setSelectionRange)
mbox.setSelectionRange(mbox.value.length, mbox.value.length);
}
}
// this moved to Everything2 ajax and retired 2010-10-07 --DonJaime
function autorefreshChatterbox(chatperiod, msgperiod){
chatperiod = chatperiod||11 ;
msgperiod = msgperiod||23 ;
var stopAfter = 1800/chatperiod; // 30 minutes
var chatUpdater = new e2.ajax.periodicalUpdater(
'(chatterbox_chatter):showchatter', chatperiod, stopAfter, inactive);
var msgUpdater = new e2.ajax.periodicalUpdater(
'(chatterbox_messages):showmessages', msgperiod, {before:checkCheckBoxes, after:checkHr});
var stopped;
function inactive(){
msgUpdater.stop();
jQuery('#message').before('<p><strong>Chatterbox auto-refresh stopped due to inactivity.</strong> ' +
'<button type="submit">Restart</button></p>');
stopped = true;
jQuery('#formcbox').bind('submit', reactivate);
}
function reactivate(){
if (stopped){
jQuery('message').focus();
stopped = false;
}
jQuery('#chatterbox')[0].unrefreshed = true;
chatUpdater.restart();
msgUpdater.restart();
}
function checkCheckBoxes(){
if (!jQuery('#chatterbox')[0].unrefreshed){
reactivate();
}
return jQuery("#chatterbox_messages input:checked").length == 0;
}
function checkHr(u){
if ( !/<\w/.test( jQuery('#chatterbox_messages')[0].innerHTML ) || jQuery('#formcbox hr').length )
return ;
jQuery('#chatterbox_chatter').before('<hr width="40%">');
}
}
if (/^chatterlight/.test(document.body.id)){
jQuery('#basesheet').before('<style type="text/css">#message {width: 97%;}</style>');
jQuery('#message').focus();
if (e2.ajax) {
autorefreshChatterbox() ;
new e2.ajax.periodicalUpdater( 'newwriteups:updateNodelet:New+Writeups' , 180 );
}
}
