#!/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>
<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 openurl(url)
{
        window.parent.document.getElementById(\"content\").src = url;
}
function appinfo(name, apid)
{
	var url;
	url = \"/cgi-bin/Protocol/sysapp_config?appid=\" + apid + \"&appname=\" + name;
        window.parent.document.getElementById(\"content\").src = url;
}
</script>
</head>
";
. /etc/PG.conf
FLOWEYE=${PGPATH}/bin/floweye

echo -n "
<body>
<div style=\"position:absolute;top:6px\">
<script type=\"text/javascript\">
	d = new dTree('d');
	d.add(0, -1, '');
	d.add(1044, 0, 'ӦЭ', '','','','','', true);
	";
		${FLOWEYE} app showtree system | while read parentid myid appid appname type
		do
			if [ "${appid}" != "unknown" -a "${appid}" != "default" -a \
			     "${appid}" != "custom" ]; then
				if [ "${type}" = "sysapp" ]; then
					url="javascript:appinfo('${appname}', '${appid}')"
					echo "d.add(${myid}, ${parentid}, '${appname}', \"${url}\");"
				else
					echo "d.add(${myid}, ${parentid}, '${appname}', \"\");"
				fi
			fi
		done
	
echo -n "
	d.add(10002, 0, '', '','','','','', true);
	d.add(10003,10002, 'ԶЭ', \"javascript:openurl('/cgi-bin/Protocol/usrapp_list?title=->ԶЭ')\");
       	d.add(10006,10002, '·', \"javascript:openurl('/cgi-bin/Protocol/vlink_list?title=->·')\");
	document.write(d);
</script>
</div>
</body>
</html>
";