#!/bin/sh

printf "Content-type: text/html; charset=GB2312\r\n"
printf "Cache-Control: no-cache\r\n"
printf "\r\n"


export CGI_action="_load_sys_release_"

quert_string=`/usr/ramdisk/bin/urlencode -d "${QUERY_STRING}" | awk -F"&" \
'{
	dot = "";
	printf "{";

	for(i = 1; i <= NF; i++) {
		split($i, val, "=");
		printf "%s\"%s\":\"%s\"", dot, val[1], val[2];
		if(dot == "") dot=",";
	}

	printf "}";
}'`


awk '{gsub("\\t", "", $0); printf $0}' << EOF
<!DOCTYPE html>
<html>
<head>
	<meta charset="gb2312">
	<meta http-equiv="cache-control" content="no-cache" />
	<meta http-equiv="Pragma" content="no-cache" />
	<meta http-equiv="expires" content="0" />
	<title>${CGI_pop_title}</title>
	<link rel="stylesheet" href="/html/assert/panabit.css">
	<script src="/html/assert/layui.all.js"></script>
	<script src="/html/assert/panabit.js"></script>
	<script src="/img/highcharts.js"></script>
	<script src="/img/crypto.js"></script>
</head>

<body class="paui-bg-gray">
	<div id="app-page-body">
		<div class="layui-anim layui-anim-rotate layui-anim-loop" style="margin-top: 100px; text-align: center; ">
			<i class="pa-icon pa-loading" style="font-size:36px; color:#666666"></i>
		</div>
	</div>
</body>

<script>
g_sys_env = `sh ../system/ajax_sys_info`;
var paui_db = new Paui_db(g_sys_env.key);
	
layui.use(function(){
	var \$ = layui.\$, 
	util = layui.util,
	laytpl = layui.laytpl;

	var event_center = {
		paui_tips: function(obj){
			layer.tips(obj.attr("tips"), obj, {
				maxWidth: 700,
				time: 8000,
				tips: 1
			});
			\$(obj).off('mouseleave');
			\$(obj).on('mouseleave', function(){
				layer.closeAll('tips');
			})
		},

		paui_btn_more: function(obj){
			\$(obj).find("dl").show();
			\$(obj).off('mouseleave');
			\$(obj).on('mouseleave', function(){
				\$(this).find("dl").hide();
			});
		}
	};

	pa_ajax({
		url: '/html/${CGI_pop_route}.html'
		,dataType: 'html'
		,success: function(html){
			laytpl(html).render(${quert_string}, function(string){
				\$("#app-page-body").html(string);
			});
		}
	});

	\$(document).keydown(function(e){
		if(e.which === 27)
			window.close();
	});

	util.event('paui-hover-evt', event_center, 'mouseenter');
});
</script>
</html>

EOF
