#!/bin/sh
#This script is created by ssparser automatically. The parser first created by MaoShouyan
printf "Content-type: text/html
Cache-Control: no-cache

"
echo -n "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\">
<head>
<title>Эѡ</title>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\">
<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">
<META HTTP-EQUIV=\"Cache-Control\" content=\"no-cache\">
<link rel=\"stylesheet\" type=\"text/css\" href=\"/img/dtree.css\" />
<script type=\"text/javascript\" src=\"/img/dtree.js\"></script>
<script type=\"text/javascript\">
function onAppClick(appid, appname)
{
	if (appid == \"custom\" || appid == \"usrgrp\") {
		window.returnValue = \"NONE\";
		document.getElementsByName(\"btnok\")[0].disabled = true;
	}
	else {
		window.returnValue = appid + \",\" + appname;
		document.getElementsByName(\"btnok\")[0].disabled = false;
	}
}
function onCancel()
{
	window.returnValue = \"NONE\";
	window.close();
}
function onOK()
{
	window.close();
}
</script>
</head>
";
. /etc/PG.conf
FLOWEYE=${PGPATH}/bin/floweye

echo -n "
<body>
<base target=\"_self\">
<div style=\"overflow: auto; position:absolute;left:8px;top:8px;height:540px;width:280px;border:2px\">
<script type=\"text/javascript\">
	d = new dTree('d');
	d.add(0, -1, 'ѡЭ');
	d.add(1044, 0, 'ӦЭ');
	d.add(2000, 1044, 'Э', \"javascript:onAppClick('any', 'Э')\", '','','','', true);
	d.add(2001, 1044, 'δ֪Э', \"javascript:onAppClick('default', 'δ֪Э')\", '','','','', true);
	";
		${FLOWEYE} app showtree all | while read parentid myid appid appname type
		do
			if [ "${appid}" != "unknown" -a "${appid}" != "default" ]; then
				url="javascript:onAppClick('${appid}', '${appname}')"
				echo "d.add(${myid}, ${parentid}, '${appname}', \"${url}\", '','','','', true);"
			fi
		done
	
echo -n "
	document.write(d);
</script>
</div>
<div style=\"overflow: auto; position:absolute;left:300px;top:8px;height:30px;width:100px;border:2px\">
<input type=button name=btnok value=\"ȷ\" align=center disabled style=\"width:80px\" onclick=\"onOK()\"></input>
</div>
<div style=\"overflow: auto; position:absolute;left:300px;top:40px;height:30px;width:100px;border:2px\">
<input type=button value=\"ȡ\" align=center style=\"width:80px\" onclick=\"onCancel()\"></input>
</div>
</body>
</html>
";