var lvid = getParameter('lvid');
var sign = getParameter('sign');
var type = Number($('body').attr('type'));
var printDate = {
	lvid:lvid,
	sign:sign,
	noticemode:type,
	pageindex:1,
	pagesize:20
}

function goPage(num) {
   printDate['pageindex'] = num ++ ;
   verifyNotice();
}
function verifyNotice(){
	var html = '';
	$.ajax({
		url:requestUrlMap['noticeList']['url'],
		data:printDate,
		dataType:'jsonp',
		success:function(data){
			if (data.errorid != 0) {
				return;
			}
			if (data.zongcount == 0) {
				$('.cont').addClass('nothingbg');
				return;
			}
			$('.cont').removeClass('nothingbg');
			var pageTotal = Math.ceil(data.zongcount / 20);
			var json = data.noticelist.collearray;
			var msgObj='',tip;
			var userid = data.loginuserid;
			for(var i = 0;i<json.length;i++){
				msgObj = json[i];
				var user = msgObj.user;
				var userSend = msgObj.user;
				var notice = json[i].notice;
				var file = json[i].filechange;
				var time = $.formatDateStyle3(new Date(json[i].notice.createtime * 1000));
				var titleName = user.nickname.replaceAll('>', '&gt;');
				var sliceName = user.nickname.length > 10 ? user.nickname.slice(0,10) + '...' : user.nickname;
				var notice_verifymsg = decodeURIComponent(notice.verifymsg);
				html += '<li>';
				html += '<dt class="news_left clearfix">';
				html += 	'<p class="paper">';
				var operation = file.operatetype;
				var operationTxt;
				var operationPeo;
				switch (operation){
					case 1:
					operationTxt = '上传成功';
					operationPeo = '上传者：<b>'+file.operatenickname+'('+file.operatelvid+')</b>';
					break;
					case 2:
					operationTxt = '更新文件';
					operationPeo = '修改者：<b>'+file.operatenickname+'('+file.operatelvid+')</b>';
					break;
					case 3:
					operationTxt = '删除文件';
					operationPeo = '删除者：<b>'+file.operatenickname+'('+file.operatelvid+')</b>';
					break;
					case 4:
					operationTxt = '被'+file.operatenickname+'('+file.operatelvid+')评论';
					operationPeo = operationTxt;
					break;
					case 5:
					operationTxt = '创建成功';
					operationPeo = '创建者：<b>'+file.operatenickname+'('+file.operatelvid+')</b>';
					break;
				}
				var fname = file.filename ? file.filename : '';
				var adress = file.filepath + fname;
				html += 		'<a filepath='+file.filepath+' filename='+file.filename+' fileid='+file.fileid+' parentid='+file.parentid+' chilrdid='+file.groupid+' class="col" onclick="fileOpen(this)" href="javascript:">'+adress+'</a>';
				html += 	'</p><p class="time">'+time+'</p></dt>';
				html += '<dd>';
				html += '<span class="file">'+operationTxt+'</span>';
				html += '<span class="file">'+operationPeo+'</span>';
				html += '</dd>';
				html += '</li>';
			}
			$('.news').html(html)
			printPage(pageTotal);
		}
	})
}
function fileOpen(a){
	var filepath= $(a).attr('filepath');
	var filename = $(a).attr('filename');
	var fileid = $(a).attr('fileid');
	var parentid = $(a).attr('parentid');
	var chilrdid = $(a).attr('chilrdid');
	var params = "{command:9048,params:{filepath:'"+filepath+"',filename:'"+filename+"',fileid:'" + fileid + "',parentid:" + parentid + ",chilrdid:" + chilrdid + "}}";
	var resultS = sendCommand(params);
}
function addMyGroup(groupid) {
	var params = "{command:1005,params:{groupid:" + groupid + ",myuserid:" + userid + "}}";
	var resultS = sendCommand(params);
};

function lookUserView(lvid, userid) {
	var params = "{command:1003,params:{userid:" + userid + ",lvid:" + lvid + "}}";
	sendCommand(params);
};

function lookGroupView(groupid) {
	var params = "{command:3002,params:{groupid:" + groupid + "}}";
	sendCommand(params);
};

$(document).on('click','.verXuanze',function() {
	$(this).find(".verXuanze-popup").show();
});
$(document).ready(function(){
	verifyNotice();
})