1 <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
4 <meta http-equiv=
"content-type" content=
"text/html; charset=utf-8" />
6 <script type=
"text/ecmascript" defer=
"defer">
8 //Appending new content to the message view
9 function appendMessage(html) {
10 shouldScroll = nearBottom();
12 //Remove any existing insertion point
13 insert = document.getElementById(
"insert");
14 if(insert) insert.parentNode.removeChild(insert);
16 //Append the new message to the bottom of our chat block
17 chat = document.getElementById(
"Chat");
18 range = document.createRange();
19 range.selectNode(chat);
20 documentFragment = range.createContextualFragment(html);
21 chat.appendChild(documentFragment);
23 alignChat(shouldScroll);
25 function appendMessageNoScroll(html) {
26 //Remove any existing insertion point
27 insert = document.getElementById(
"insert");
28 if(insert) insert.parentNode.removeChild(insert);
30 //Append the new message to the bottom of our chat block
31 chat = document.getElementById(
"Chat");
32 range = document.createRange();
33 range.selectNode(chat);
34 documentFragment = range.createContextualFragment(html);
35 chat.appendChild(documentFragment);
37 function appendNextMessage(html){
38 shouldScroll = nearBottom();
40 //Locate the insertion point
41 insert = document.getElementById(
"insert");
44 range = document.createRange();
45 range.selectNode(insert.parentNode);
46 newNode = range.createContextualFragment(html);
49 insert.parentNode.replaceChild(newNode,insert);
51 alignChat(shouldScroll);
53 function appendNextMessageNoScroll(html){
54 //Locate the insertion point
55 insert = document.getElementById(
"insert");
58 range = document.createRange();
59 range.selectNode(insert.parentNode);
60 newNode = range.createContextualFragment(html);
63 insert.parentNode.replaceChild(newNode,insert);
66 //Auto-scroll to bottom. Use nearBottom to determine if a scrollToBottom is desired.
67 function nearBottom() {
68 return ( document.body.scrollTop
>= ( document.body.offsetHeight - ( window.innerHeight *
1.2 ) ) );
70 function scrollToBottom() {
71 document.body.scrollTop = document.body.offsetHeight;
74 //Dynamically exchange the active stylesheet
75 function setStylesheet( id, url ) {
76 code =
"<style id=\"" + id + "\
" type=\"text/css\
" media=\"screen,print\
">";
77 if( url.length ) code +=
"@import url( \"" + url + "\
" );";
79 range = document.createRange();
80 head = document.getElementsByTagName(
"head" ).item(
0);
81 range.selectNode( head );
82 documentFragment = range.createContextualFragment( code );
83 head.removeChild( document.getElementById( id ) );
84 head.appendChild( documentFragment );
87 //Swap an image with its alt-tag text on click, or expand/unexpand an attached image
88 document.onclick = imageCheck;
89 function imageCheck() {
91 if(node.tagName == 'IMG' && !client.zoomImage(node) && node.alt) {
92 a = document.createElement('a');
93 a.setAttribute('onclick', 'imageSwap(this)');
94 a.setAttribute('src', node.getAttribute('src'));
95 a.className = node.className;
96 text = document.createTextNode(node.alt);
98 node.parentNode.replaceChild(a, node);
102 function imageSwap(node) {
103 shouldScroll = nearBottom();
105 //Swap the image/text
106 img = document.createElement('img');
107 img.setAttribute('src', node.getAttribute('src'));
108 img.setAttribute('alt', node.firstChild.nodeValue);
109 img.className = node.className;
110 node.parentNode.replaceChild(img, node);
112 alignChat(shouldScroll);
115 //Align our chat to the bottom of the window. If true is passed, view will also be scrolled down
116 function alignChat(shouldScroll) {
117 var windowHeight = window.innerHeight;
119 if (windowHeight
> 0) {
120 var contentElement = document.getElementById('Chat');
121 var contentHeight = contentElement.offsetHeight;
122 if (windowHeight - contentHeight
> 0) {
123 contentElement.style.position = 'relative';
124 contentElement.style.top = (windowHeight - contentHeight) + 'px';
126 contentElement.style.position = 'static';
130 if (shouldScroll) scrollToBottom();
133 function windowDidResize(){
134 alignChat(true/*nearBottom()*/); //nearBottom buggy with inactive tabs
137 window.onresize = windowDidResize;
140 <!-- This style is shared by all variants. !-->
141 <style id=
"baseStyle" type=
"text/css" media=
"screen,print">
143 *{ word-wrap:break-word; }
144 img.scaledToFitImage { height:auto; width:
100%; }
147 <!-- Although we call this mainStyle for legacy reasons, it's actually the variant style !-->
148 <style id=
"mainStyle" type=
"text/css" media=
"screen,print">
153 <body onload=
"alignChat(true);" style=
"==bodyBackground==">