[Mono-docs-list] monodoc javascript treeview
John Luke
jluke@cfl.rr.com
Sun, 03 Aug 2003 00:44:19 -0400
--=-Wid332Ii9MU5TQf2v1YQ
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
Hello,
I wasn't sure how you wanted to implement the menu dynamically so what I
have done is written a HttpHandler that writes the javascript menu like
the one that Miguel posted. So if someone can tell me how to get the
children nodes for a given item, then those children can be dynamically
added to the menu.
Currently I have a couple nodes hardcoded, but it would just be a matter
of adding a foreach to add the children items.
There is a screenshot at
http://helios.acomp.usf.edu/~luke/web/monodoc.png
--=-Wid332Ii9MU5TQf2v1YQ
Content-Disposition: attachment; filename=jstree.ashx
Content-Type: text/plain; name=jstree.ashx; charset=
Content-Transfer-Encoding: 7bit
<%@ WebHandler Language="c#" Class="Monodoc.JsTree" %>
//
// Authors:
// John Luke (jluke@cfl.rr.com)
//
// (C) 2003 John Luke
//
using System.Web;
using System.Text;
namespace Monodoc
{
public class JsTree : IHttpHandler
{
HttpResponse resp;
public void ProcessRequest (HttpContext context)
{
resp = context.Response;
resp.Write (@"
<html>
<head>
<script type='text/javascript'>
var relocateURL = '/monodoc';
if(parent.frames.length == 0) {
if(document.images) {
location.replace(relocateURL);
} else {
location = relocateURL;
}
}
</script>
<script type='text/javascript' src='mtmcode.js'>
</script>
<script type='text/javascript'>
MTMDefaultTarget = 'text';
var MTMIconList = null;
MTMIconList = new IconList();
MTMIconList.addIcon(new MTMIcon('menu_link_external.gif', 'http://', 'pre'));
MTMIconList.addIcon(new MTMIcon('menu_link_pdf.gif', '.pdf', 'post'));
MTMSubsGetPlus = 'Always';
MTMSubsAutoClose = 'true';
MTMenuText = 'Mono Documentation';
var menu = null;
menu = new MTMenu();
");
WriteMenu ("Class Library");
resp.Write (@"menu.addItem('Home', 'main.ashx');
</script>
</head>
<body onload='MTMStartMenu(true)' bgcolor='#000033' text='#ffffcc' link='yellow' vlink='lime' alink='red'>
</body>
</html>
");
}
public void WriteMenu (string name)
{
StringBuilder sb = new StringBuilder ();
sb.AppendFormat ("menu.addItem('{0}');", name);
sb.Append ("var bcl = null;");
sb.Append ("bcl = new MTMenu();");
// get list of items from monodoc and add to menu
sb.Append (WriteItem ("bcl", "System", "N:System"));
sb.Append (WriteItem ("bcl", "System.IO", "N:System.IO"));
sb.Append (WriteItem ("bcl", "System.Xml", "N:System.Xml"));
sb.Append ("menu.makeLastSubmenu(bcl);");
resp.Write (sb.ToString ());
}
public string WriteItem (string parent, string name, string link)
{
StringBuilder sb = new StringBuilder ();
sb.AppendFormat ("{0}.addItem('{1}', 'main.ashx?link={2}');", parent, name, link);
return sb.ToString ();
}
public bool IsReusable {
get { return true; }
}
}
}
--=-Wid332Ii9MU5TQf2v1YQ--