summaryrefslogtreecommitdiff
path: root/static/js/pages/chat_init.js
diff options
context:
space:
mode:
Diffstat (limited to 'static/js/pages/chat_init.js')
-rw-r--r--static/js/pages/chat_init.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/static/js/pages/chat_init.js b/static/js/pages/chat_init.js
new file mode 100644
index 0000000..58dba07
--- /dev/null
+++ b/static/js/pages/chat_init.js
@@ -0,0 +1,36 @@
+// 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;
+
+ if (hasMessageList && typeof window.initChat === 'function') { window.initChat(); }
+ if (hasMessageList && typeof window.initChatMsgs === 'function') { window.initChatMsgs(); }
+ 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);
+