// Shared initializer for pages that include pichat.js and render a chat UI. // Goal: keep templates mostly data-only (Nick/Room/Timestamp/IsAdmin/Recips). (function($){ function defaultShowAlert() { alert(window.Nick ? 'MUST LOGIN' : 'Join dump.fm @ /register'); } function defaultPop(url) { var newwindow = window.open( url, 'name', 'height=50,width=400,left=20,top=20,location=0,status=0,scrollbar=0,resizable=0' ); if (window.focus && newwindow) { newwindow.focus(); } return newwindow; } if (typeof window.showAlert !== 'function') { window.showAlert = defaultShowAlert; } if (typeof window.pop !== 'function') { window.pop = defaultPop; } $(function(){ if (typeof window.Recips === 'undefined') { window.Recips = []; } var hasMessageList = document.getElementById('messageList') !== null; var hasChatInput = document.getElementById('msgInput') !== null; if (hasMessageList && hasChatInput && typeof window.initChat === 'function') { window.initChat(); } if (hasMessageList && hasChatInput && typeof window.initChatMsgs === 'function') { window.initChatMsgs(); } // Some room pages render dumps in `.logged-dump` containers without the full chat UI. // In that case, run the log initializer so URLs become hotlinked images. if (!hasChatInput && typeof window.initLog === 'function' && jQuery('.logged-dump .content').length) { window.initLog(window.Recips); } if (typeof window.Away !== 'undefined' && typeof window.Away.startTitleUpdater === 'function') { window.Away.startTitleUpdater(); } if (window.Nick && typeof window.setupUpload === 'function' && typeof window.Room !== 'undefined') { window.setupUpload('upload', window.Room); } }); })(jQuery);