<?php 
	$this->display(tpl('head',true));
?>
<style>
	.layui-elem-quote {
		margin-bottom: 10px;
		padding: 15px;
		line-height: 22px;
		border-left: 5px solid #009688;
		border-radius: 0 2px 2px 0;
		background-color: #f2f2f2;
		font-size: 14px;
	}
	.layui-textarea {
		border-color: #e6e6e6
	}
	.loading{
		position: absolute;
		top: 40%;
		border: 1px dotted #009688;
		background-color: #D2DCF8;
		left: 30%;
		width: 40%;
		height: 150px;
		line-height: 150px;
		text-align: center;
		color: #fff;
		font-weight: bold;
		font-size: 1.8em;
	}
	.loading{animation:change 10s linear 0s infinite;font-size:30px;font-weight:700;}
	@keyframes change{0%   {color:#333;}25%{color:#ff0;}50%{color:#f60;}75%{color:#cf0;}100% {color:#f00;}}
</style>
<div id="content"></div>
<div class="loading" id="load">
	正在向官方请求数据，请稍后。。。
</div>
<script>
	var obj1={
			'upgrade_temporary_number':'<?php echo $data[upgrade_temporary_number]?>',
			'olddata':'<?php echo $olddata?>',
		}
	<?php if($data[dir]=='mvc'){ ?>
	var	obj={
			'action':'mvc',
			'id':'<?php echo $data[id]?>',
			'i':'1',
			'to_i':'0',
		};
		$('#content').append('<blockquote class="layui-elem-quote layui-text" id="d">正在将主程序数据升级至<?php echo $data[version]?>版本</blockquote>');
	<?php }elseif($data[dir]=='modular'){ ?>
	var	obj={
			'action':'modular',
			'i':'1',
			'ii':'1',
			'to_i':'0',
			'id':'<?php echo $data[id]?>',
		};
		$('#content').append('<blockquote class="layui-elem-quote layui-text" id="d">正在将“<?php echo $data[name] ?>”模块数据升级至<?php echo $data[version]?>版本</blockquote>');
	<?php }elseif($data[dir]=='plugin'){ ?>
	var	obj={
			'action':'plugin',
			'i':'1',
			'ii':'1',
			'to_i':'0',
			'id':'<?php echo $data[id]?>',
		};
		$('#content').append('<blockquote class="layui-elem-quote layui-text" id="d">正在将“<?php echo $data[name] ?>”插件数据升级至<?php echo $data[version]?>版本</blockquote>');
	<?php } ?>
	obj2=Object.assign(obj1,obj);
	upgarde(obj2);
	var is_show=true;
	function upgarde(data){
	 	$.ajax({
				url:"/admin/upgrade/upgrade",
				type: 'POST',
				data:data,
				dataType: 'json',
				success: function(res){
					is_show=false;
					if(is_show==false){
						$('#load').hide();
					}
					var html='<blockquote class="layui-elem-quote layui-text" id="d">'+res.text+'</blockquote>';
					$('#content').append(html);
					if(res.text1){
						var html='<blockquote class="layui-elem-quote layui-text" id="d">'+res.text1+'</blockquote>';
						$('#content').append(html);
					}
					if(res.action=='mvc'){
						var mvc={
								'action':'mvc',
								'id':res.id,
								'i':res.i,
								'to_i':res.to_i
							};
						obj2=Object.assign(obj1,mvc);
						upgarde(obj2);
					}else if(res.action=='modular' || res.action=='plugin'){
						var data1={
								'action':res.action,
								'id':res.id,
								'i':res.i,
								'ii':res.ii,
								'to_i':res.to_i
							};
						obj2=Object.assign(obj1,data1);
						upgarde(obj2);
					}
					window.scrollTo(0, document.body.scrollHeight)
				}
				
				
				
				
			})
	}
</script>
<?php 
	$this->display(tpl('foot',true));
?>