<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<%@ include file="../../include/lib.jsp"%>

		<style type="text/css">
#homePageSave .content ul li a.update {
	cursor: default;
	background-position: right -24px;
}

#homePageSave .content ul li a .update {
	background-position: 0 -72px;
}
</style>
	</head>

	<body>
		<form id="homePageSave" method="post">
			<div class="content">
				<ul>
					<li>
						更新所有
					</li>
					<li>
						<a id="updateStart" href="javascript:void(0)"
							class="easyui-linkbutton confirm"
							onclick="submitForm()";
						>开始更新</a>
					</li>
				</ul>
				<input type="hidden" name="update" id="update" value="update" />
				<ul>
					<li>
						进行状态
						<div id="progress" class="easyui-progressbar"
							style="width: 400px;"></div>
					</li>
				</ul>
			</div>
		</form>
	</body>

	<script type="text/javascript">
	$('#progress').progressbar( {
		onChange : function(value) {
		}
	});

	//进度条
	function start() {
		var value = $('#progress').progressbar('getValue');
		if (value < 100) {
			value += Math.floor(Math.random() * 5);
			$('#progress').progressbar('setValue', value);
			setTimeout(arguments.callee, 400);
		} else if(value ==100){
			$("#updateStart").attr("onclick","submitForm()");
			$("#updateStart").removeClass("update");
			$("#updateStart .l-btn-left").removeClass("update");
		}
	}

	//提交
	function submitForm() {
		$("#updateStart").attr("onclick","");
		$('#progress').progressbar('setValue',0);
		start();
		$("#updateStart").addClass("update");
		$("#updateStart .l-btn-left").addClass("update");
		var update = $('#update').val();
		$.ajax( {
			type : "post",
			url : "${base_url}admin/updateWeb",
			dataType : "json",
			data : "update=" + update,
			success : function(data) {
				if (data.code!= 8) {
					$("#updateStart").attr("onclick","submitForm()");
					$("#updateStart").removeClass("update");
					$("#updateStart .l-btn-left").removeClass("update");
				}
			}
		});
	}
</script>
</html>
