## $Header: /cvs/sakai2/legacy/tools/src/webapp/vm/chat/chef_chat-List.vm,v 1.5 2005/05/28 03:04:35 ggolden.umich.edu Exp $ 
## chef_chat-List.vm, use with org.chefproject.ChatAction.java
##     context: $chat_messages: iterator of ChatMessage
##              $message: String message
##              $display_date: Boolean, show dates if true
##              $display_time: Boolean, show time if true
##              $sound_alert: Boolean, beep for new messages if true
##				$color_mapper: Wrapper around hashtable that maps names to colors
##
	
## to prevent horiz scroll on IE
	<!--[if lte IE 6]>
		<script type="text/javascript" language="JavaScript">
			document.body.style.width='97%'
		</script>
	<![endif]--> 
## this is double deep
<script type="text/javascript" language="JavaScript">
doubleDeep = true;
// set for the chatscript.js
deleteUrl = '#toolLink($action "doConfirmDeleteMessage")&messageid=';
deleteMsg = "$tlang.getString('list.del')";
</script>

## appendMessage function comes from chatscript.js
	<script  type="text/javascript" language="JavaScript" src="#scriptLink('chatscript.js')">
	</script>
		#if ($alertMessage)<div class="alertMessage">$tlang.getString("gen.alert") $validator.escapeHtml($alertMessage)</div><div class="clear"></div>#end
		<ul id="chatList">
			#foreach ($item in $chat_messages)
				## new format with less space inside messages
				#set($name = $validator.escapeHtml($item.Header.From.DisplayName))
				#set($color = $color_mapper.getColor($item.header.from.id))		
				<li>
					<span  style="color: $color">$name</span>
					#if(!$item.properties.getProperty("deleted"))
						## Don't allow deleting a message that has already been deleted
						#if ($channel.allowRemoveMessage($item))
							## Only allow the user to see the delete message icon if they have sufficient permissions to delete the message
							<a href="#" onclick="location='#toolLink($action "doConfirmDeleteMessage")&messageid=$validator.escapeUrl($item.header.id)'; return false;" title="$tlang.getString('list.del')" >				
							<img src="#imageLink("sakai/delete.gif")" border="0" alt="$tlang.getString('list.del')" /></a>
						#end
					#end
					<span class="chatDate">#if($display_date && $display_time) ($item.Header.Date.toStringLocalFullZ())#elseif($display_date) ($item.Header.Date.toStringLocalDate())#elseif($display_time) ($item.Header.Date.toStringLocalTimeZ())#end</span>
					 $validator.escapeHtmlFormattedText($item.Body)
				</li>
			#end
		</ul>
	<script type="text/javascript" language="JavaScript">
		var Colors = [ #foreach($color in $color_mapper.colors)"$color"#if($velocityCount<$color_mapper.num_colors),#end #end];
	
		var numColors = $color_mapper.num_colors;
		var nextColor = $color_mapper.next;
	
		var ColorMap = new Object();
#foreach($key in $color_mapper.mapping.keySet())
		ColorMap["$key"] = "$color_mapper.getColor($key)";
#end
	
		var display_date = $display_date;
		var display_time = $display_time;
		var sound_alert = $sound_alert;
	
		var docbottom = 100000;
		
		// some of these can be eliminated after verifying that 
		// the browsers that are working now are not using them
		if(document.body.offsetHeight)
		{
			// MAC_IE MAC_MZ WIN_IE WIN_MZ WIN_NN
			docbottom = document.body.offsetHeight;
		}
		else if(document.offsetHeight)
		{
			docbottom = document.offsetHeight;
		}
		else if(document.height)
		{
			docbottom = document.height;
		}
		else if(document.body.scrollHeight)
		{
			docbottom = document.body.scrollHeight;
		}
		else if(document.clientHeight)
		{
			docbottom = document.clientHeight;
		}
		else if(document.clientHeight)
		{
			docbottom = document.clientHeight;
		}
		window.scrollTo(0, docbottom);
	</script>
