﻿﻿﻿﻿$(document).ready(function(){
              $.ajax({
	            //提交数据的类型 POST GET
	            type:"POST",
	            //提交的网址/jeeadmin/jeecms
	            url :"../getLatest.jspx",//
	            //提交的数据
	            data:{keywords:''},
	            //返回数据的格式
	            datatype: "html",//"xml", "html", "script", "json", "jsonp", "text".
	            //在请求之前调用的函数
	            beforeSend:function(){//alert("before--")
		            },
	            //成功返回之后调用的函数            
	            success:function(data){
		      try{
                                  if(data==null||data==''){
                    	  $("#xkDyn").html('<li style="width:370px"></li><li>暂无动态信息</li>');
                    	  return false; 
                      }
                                               
					      var jn='{root:'+data+'}';
					      var pl='';
					      var len=55;
					      var dataObj=eval("("+jn+")");//转换为json对象
					         //alert(dataObj.root.length);//输出root的子对象数量
					      
					      var color_num = 0;
					      $.each(dataObj.root,function(idx,item){
					        	var msg = item.msg;
                                                       var uname= item.username;
                                                       var flag=false;
                           if(typeof(msg) != "undefined"){
					        	   msg = msg.replace(/<[^>].*?>/g,"");   
					        	   if(msg.length>=len) {
					        		 msg = msg.substr(0,len) + '……';
					        	   } 
                           }else{
                                 msg='';  
                           }
                           if(typeof(uname) != "undefined"){
                            if(msg.indexOf(uname)!=-1){
                              msg=msg.replace(uname,"<a href="+INDEX_SERVICE_URL+"/online/space/index.html?uid="+item.userid+" style='text-decoration:none;padding:0px;color:#00BDBD'>"+uname+"</a>");
                              flag=true; 
                           }
                          }

                           		var list_colors = ["yellow","blue","red"];
                           		if(color_num >=3 || color_num < 0){
                           			color_num = 0;
                           		}
					              pl=pl+'<li><a href='+INDEX_SERVICE_URL+'/online/space/index.html?uid='+item.userid+'> <img src="'+INDEX_SERVICE_URL+'/online/getFace.jpg?personPhrCode='+item.userid+'&type=1" alt="" /></a><p class="'+list_colors[color_num]+'">'+item.time+'<br/>';
                                                        if(!flag){
                                                             pl=pl+"会员<a href="+INDEX_SERVICE_URL+"/online/space/index.html?uid="+item.userid+" style='text-decoration:none;padding:0px'color:#00BDBD>"+uname+"</a>";
                                                         }
                                                        pl=pl+msg+'</span></p></li>';  
					               color_num++;
					         }); 
					$("#xkDyn").html(pl);        
                              if(dataObj.root.length==0){
                            	   $("#xkDyn").html('<li style="width:370px"></li><li>暂无动态信息</li>'); 
                              }

                      }catch(e){
                       }       
                          		 		           		            		          		  
	            }   ,
	            //调用执行后调用的函数
	            complete: function(XMLHttpRequest, textStatus){
	              // alert(XMLHttpRequest.responseText);
	               //alert(textStatus);
	                //HideLoading();
	            },
	            //调用出错执行的函数
	            error: function(){
	                //请求出错处理
	               // alert("error");
	            }        
	});

  });
