diff options
author | Jonathan Pryor <jpryor@novell.com> | 2008-10-28 21:11:27 +0300 |
---|---|---|
committer | Jonathan Pryor <jpryor@novell.com> | 2008-10-28 21:11:27 +0300 |
commit | 9e2eabccfbe2344c39708091ec1ded75f77ab50d (patch) | |
tree | 8da25446f26f36119b82383ed62d09a6dd307dfd /webdoc | |
parent | 972a042b6aca25d77632b353df0733277b2ab278 (diff) |
Preparing for future monodoc module deprecation...
svn path=/trunk/mono-tools/; revision=117280
Diffstat (limited to 'webdoc')
81 files changed, 2967 insertions, 0 deletions
diff --git a/webdoc/Changelog b/webdoc/Changelog new file mode 100644 index 00000000..90b0b083 --- /dev/null +++ b/webdoc/Changelog @@ -0,0 +1,31 @@ +2006-11-19 Miguel de Icaza <miguel@novell.com> + + * monodoc.ashx: Do not rewrite target urls that start with '#' + as those are links inside the current page. + +2005-02-18 Gonzalo Paniagua Javier <gonzalo@ximian.com> + + * monodoc.ashx: fixed nullrefs for the 'Various' node. + +2003-11-16 Gonzalo Paniagua Javier <gonzalo@ximian.com> + + * ptree/tree.js: make mouse selection lose the focus when ENTER is + pressed. + +2003-10-14 John Luke <jluke@cfl.rr.com> + + * ptree/tree.css: change a.hover to look like ndoc + +2003-08-22 Piers Haken <piersh@friskit.com> + + * monodoc.ash: PTree cleanup, keyboard support + +2003-08-21 Piers Haken <piersh@friskit.com> + + * monodoc.ash: add PTree support + +2003-08-14 John Luke <jluke@cfl.rr.com> + + * monodoc.ashx: do not close the XmlTextWriter in 'void + HandleTree (HttpContext context, string tree)' (allows the + tree to work on IE and moz>=1.4) diff --git a/webdoc/TODO b/webdoc/TODO new file mode 100644 index 00000000..9810de54 --- /dev/null +++ b/webdoc/TODO @@ -0,0 +1,23 @@ +Cosas por hacer: + + Despues del login, actualizar el "login" en el frame padre. + + Que use una base de datos para validar el login. + + Que haya dos clases de usuarios "trusted" y non-trusted, + para los trusted, los cambios aparecen en la pagina, para + los non-trusted, solamente aparece para ellos. + + En vez de hacer un upload de las contribuciones, darle un hit + directo a esta base de datos cuando se aprueban los cambios. + + Cuando se aplican, los cambios deben de removerse del + servidor, o moverse a otro sitio. + + exponer esto directamente al cliente de + Crear el comando SQL para actualizar la tabla para que + tenga otro campo "trusted" + + Para que no cargue la base de datos en cada hit, usar un + secreto calculado en cada "boot". Poner un cookie que + contenga los datos de la sesion encritados. diff --git a/webdoc/common.css b/webdoc/common.css new file mode 100644 index 00000000..87ce8a4e --- /dev/null +++ b/webdoc/common.css @@ -0,0 +1,183 @@ +body { + background-color: #ffffff; + margin: 0px; + padding: 0px; +} + +.HeaderTable { + border: 2px solid #99aadd; +} + +.Content { + margin: 1em; +} + +body, td, th { + font-family: Verdana, sans-serif; font-size: 12px; + color: black; +} + +.SignatureTable, .MemberSignatureTable { + border: 1px solid #DDDDDD; +} + +.Footer { + border-top: 2px solid #E5E5E5; + padding-left: 1em; +} + +.Footer hr { + display: none; +} + +h1, h2, h3, h4 { + font-family: Verdana,sans-serif; + font-weight: bold; +} + +h1 { +} + +h3 { +} + +h4 { +} + +.MasterNamespaceLink a { + font-weight: bold; + text-decoration: none; +} +.MasterNamespaceDescription { + margin-left: 2em; +} + +img { + border: 0; + vertical-align: top; +} + +.copyright { + border:1px solid black; + padding-left:5px; + padding-right:5px; + padding-top:5px; + padding-bottom:5px; + background-color:#BEBAA8; + font-size:9px; + margin-top: 10pt; + margin-left: -15pt; + margin-right: -15pt; +} + +.important { + padding-left:2px; + padding-right:2px; + padding-top:2px; + padding-bottom:2px; + background-color:#000000; + color:#ffffff; +} + +.menu { + font-family:Arial, Verdana; + font-size:12px; + font-weight:bold; +} + +.navbar{ + color:black; + font-family:Arial, Verdana; + font-size:10px; + border-bottom:1px solid #000000; + border-left:1px solid black; + border-right:1px solid black; + background-color:#efefef; + padding-left:2px; + padding-right:2px; + padding-top:2px; + padding-bottom:2px; + margin-left: -15pt; + margin-right: -15pt; +} + +.topframe { + background-image:url(images/backbig.png); + border:1px solid #000000; + background-color:#BEBAA8; + margin-left: -15pt; + margin-right: -15pt; +} + +.chapter { + font-size:14px; + font-weight:bold; + color:#444444; + padding-left:0px; + padding-right:0px; + padding-top:0px; + padding-bottom:0px; +} + +.table { + padding-left:2px; + padding-right:2px; + padding-top:0px; + padding-bottom:0px; + background-color:#efefef; + border:1px solid #c0c0c0; +} + +.elementOn { + color:#a40000; +} + +.element { + color:#0000a4; +} + +.code { + margin:15px; + padding:15px; + font-size: small; + font-family: "Courier New", Courier; + background:whitesmoke; + border: solid 1px silver; + line-height:110%; +} + +.box { + padding:15px; + font-size: small; + background:whitesmoke; + border: solid 1px silver; +} + +.console { + border-style: solid; + background: whitesmoke; + border-width: 1px; + padding: 2pt; + margin:15px; +} + +.headerlink { + vertical-align:bottom; +} + +a { + color: blue; +} +a:visited { + color: blue; +} + +td a { + text-decoration: none; +} + +.HeaderTable a { + color: black; + text-decoration: underline; +} + diff --git a/webdoc/edit.aspx b/webdoc/edit.aspx new file mode 100644 index 00000000..f2ad4dee --- /dev/null +++ b/webdoc/edit.aspx @@ -0,0 +1,62 @@ +<%@ Assembly name="monodoc" %> +<%@ Import Namespace="Monodoc" %> +<%@ Import Namespace="System.Xml" %> +<%@ Import Namespace="System.IO" %> +<html> +<head> + <script language="C#" runat=server> + static RootTree help_tree = RootTree.LoadTree (); + + void Page_Load (object sender, EventArgs ea) + { + HttpWorkerRequest r = (HttpWorkerRequest) ((IServiceProvider)Context).GetService (typeof (HttpWorkerRequest)); + // + // We need the untouched QueryString, as internally the editor uses the `@' symbol as a separator. + // + string q = Request ["link"]; + Console.WriteLine ("QueryString: " + q); + try { + XmlNode edit_node = EditingUtils.GetNodeFromUrl ("edit:" + q, help_tree); + Monodoc2Wiki m2w = new Monodoc2Wiki (); + Console.WriteLine ("XML TO TEXT: " + edit_node.InnerText); + EditBuffer.Text = m2w.ProcessNode ((XmlElement) edit_node); + } catch (Exception e){ + EditBuffer.Text = Request.QueryString.ToString () + e.ToString (); + } + } + + void Save (object o, EventArgs a) + { + + } + + void Preview (object o, EventArgs a) + { + WikiStyleDocConverter p = new WikiStyleDocConverter (EditBuffer.Text); + XmlNode result = p.ParseEntireDoc (); + + StringWriter sw = new StringWriter (); + sw.Write ("YOOHO:" + result.InnerText); + XmlTextWriter xw = new XmlTextWriter (sw); + xw.Formatting = Formatting.Indented; + result.WriteTo (xw); + xw.Close (); + + TextPreview.Text = "Preview<BR>" + sw.ToString (); + } + </script> +</head> + +<body> + <form runat=server> + <asp:Label id="TextPreview" runat=server/> + <asp:TextBox id="EditBuffer" Text="multiline" TextMode="MultiLine" runat="server" rows=15 cols=80 /> + <p> + <asp:Button Text="Save Page" OnClick="Save" runat=server/> + <asp:Button Text="Show Preview" OnClick="Preview" runat=server/> + <asp:LinkButton Text="Markup Help" runat=server/> + <asp:LinkButton Text="Cancel" runat=server/> + </form> +</body> + +</html>
\ No newline at end of file diff --git a/webdoc/header.aspx b/webdoc/header.aspx new file mode 100644 index 00000000..56004054 --- /dev/null +++ b/webdoc/header.aspx @@ -0,0 +1,99 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html> +<head> + <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"> + <title>MonoDoc Header</title> + <meta name="description" content="Mono Documentation header"> + <link rel="stylesheet" type="text/css" href="common.css" media="all" + title='Default Style'/> + <style> +img.toolbarsep { + border: 0px; + margin-bottom: 1px; + margin-top: 1px; + padding-top: 3px; + padding-bottom: 3px; + vertical-align: middle; +} + +img.toolbar { + border: 0px; + margin: 1px; + padding: 3px; + vertical-align: middle; +} + +img.toolbar:hover { + border-left: 1px solid white; + border-right: 1px solid #B1A598; + border-top: 1px solid white; + border-bottom: 1px solid #B1A598; + margin: 0px; +} + +img.toolbar:active { + border-right: 1px solid white; + border-left: 1px solid #B1A598; + border-bottom: 1px solid white; + border-top: 1px solid #B1A598; +} + + +#login { + position: fixed; + top: 0px; + right: 0px; + float: right; + padding: 5px; +} + +#rightSide { + position: fixed; + bottom: 0px; + right: 0px; + float: right; + padding: 5px; +} + </style> + + <script language="C#" runat=server> + void Page_Load (object sender, EventArgs e) + { + if (User.Identity.IsAuthenticated){ + login.NavigateUrl = "logout.aspx"; + login.Text = "Logged in as " + User.Identity.Name; + } else { + login.NavigateUrl = "javascript:parent.content.login (parent.content.window.location)"; + //login.Text = "Sign in / create account"; + } + } + </script> + +</head> + +<body +style="color: rgb(255, 255, 255); background-color: #c0dda2;" +link="#ffffff" alink="#ffffff" vlink="#ffffff"> + +<a href="index.aspx" class="headerlink" target="_top"><img + src="images/mono-logo.png" alt="Mono" + style="border: 0px solid ; height:75;" /></a> + +<div id="dlogin"> + <asp:HyperLink id="login" runat="server" target="_top"/> +</div> + +<div id="rightSide"> + <a href="javascript:parent.content.print();"> + <img class="toolbar" src="images/print.png" alt="Print" + title="Print this document"/> + </a> + <a target="_top" id="pageLink" href="/"> + <img class="toolbar" src="images/link.png" alt="Link to this + document" title="Link to this document"/> + </a> +</div> + + +</body> +</html> diff --git a/webdoc/header.html b/webdoc/header.html new file mode 100644 index 00000000..73f8d720 --- /dev/null +++ b/webdoc/header.html @@ -0,0 +1,65 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html> +<head> + <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"> + <title>MonoDoc Header</title> + <meta name="description" content="Mono Documentation header"> + <link rel="stylesheet" type="text/css" href="common.css" media="all" + title='Default Style'/> + <style> +img.toolbarsep { + border: 0px; + margin-bottom: 1px; + margin-top: 1px; + padding-top: 3px; + padding-bottom: 3px; + vertical-align: middle; +} + +img.toolbar { + border: 0px; + margin: 1px; + padding: 3px; + vertical-align: middle; +} + +img.toolbar:hover { + border-left: 1px solid white; + border-right: 1px solid #B1A598; + border-top: 1px solid white; + border-bottom: 1px solid #B1A598; + margin: 0px; +} + +img.toolbar:active { + border-right: 1px solid white; + border-left: 1px solid #B1A598; + border-bottom: 1px solid white; + border-top: 1px solid #B1A598; +} + + +#rightSide { + position: fixed; + bottom: 0px; + right: 0px; + float: right; + padding: 5px; +} + </style> +</head> + +<body +style="color: rgb(255, 255, 255); background-color: #c0dda2;" +link="#ffffff" alink="#ffffff" vlink="#ffffff"> + +<a href="index.aspx" class="headerlink" target="_top"><img + src="images/mono-logo.png" alt="Mono" + style="border: 0px solid ; height:75;" /></a> + +<div id="rightSide"> + <a href="javascript:parent.content.print();"><img class="toolbar" src="images/print.png" alt="Print" title="Print this document"/></a> + <a target="_top" id="pageLink" href="/"><img class="toolbar" src="images/link.png" alt="Link to this document" title="Link to this document"/></a> +</div> +</body> +</html> diff --git a/webdoc/images/link.png b/webdoc/images/link.png Binary files differnew file mode 100644 index 00000000..2e83ffe5 --- /dev/null +++ b/webdoc/images/link.png diff --git a/webdoc/images/mono-logo.png b/webdoc/images/mono-logo.png Binary files differnew file mode 100644 index 00000000..11437273 --- /dev/null +++ b/webdoc/images/mono-logo.png diff --git a/webdoc/images/mono_logo_g.gif b/webdoc/images/mono_logo_g.gif Binary files differnew file mode 100644 index 00000000..c6fbaf67 --- /dev/null +++ b/webdoc/images/mono_logo_g.gif diff --git a/webdoc/images/print.png b/webdoc/images/print.png Binary files differnew file mode 100644 index 00000000..077e5bce --- /dev/null +++ b/webdoc/images/print.png diff --git a/webdoc/images/searching.gif b/webdoc/images/searching.gif Binary files differnew file mode 100644 index 00000000..5ca0ab86 --- /dev/null +++ b/webdoc/images/searching.gif diff --git a/webdoc/index.aspx b/webdoc/index.aspx new file mode 100644 index 00000000..430ccc8b --- /dev/null +++ b/webdoc/index.aspx @@ -0,0 +1,35 @@ +<%@ Page Language="C#" %> +<%@ Import Namespace="System.Web" %> +<%@ Import Namespace="System.Collections.Specialized" %> +<html> + <head> + <title>Mono Documentation</title> + </head> + <script language="c#" runat="server"> + // Get the path to be shown in the content fram + string getContentFrame() + { + // Docs get shown from monodoc.ashx + string monodocUrl="monodoc.ashx"; + string defaultParams="?link=root:"; + NameValueCollection qStringParams=Request.QueryString; + + // If no querystring params, show root link + if(!qStringParams.HasKeys()) + return(monodocUrl+defaultParams); + // else, build query for the content frame + string nQueryString=monodocUrl+"?"; + foreach(string key in qStringParams) + nQueryString+=(HttpUtility.UrlEncode(key)+"="+HttpUtility.UrlEncode(qStringParams[key])); + return nQueryString; + } + </script> + +<frameset rows="75,*" frameborder="0" border="1"> + <frame src="header.aspx" name="Header" id='header' scrolling="no" noresize="true" /> + <frameset cols="20%,80%" frameborder="1" border="1"> + <frame src="monodoc.ashx?tree=boot" name="Tree" /> + <frame src="<% =getContentFrame() %>" name="content" /> + </frameset> +</frameset> +</html> diff --git a/webdoc/index.html b/webdoc/index.html new file mode 100644 index 00000000..ea7d7ef6 --- /dev/null +++ b/webdoc/index.html @@ -0,0 +1,10 @@ +<html> + <head> + <title>Mono Documentation</title> + </head> + + <frameset cols="20%,80%"> + <frame src="monodoc.ashx?tree=boot"> + <frame src="monodoc.ashx?link=root:" name="content"> + </frameset> +</html>
\ No newline at end of file diff --git a/webdoc/login.aspx b/webdoc/login.aspx new file mode 100644 index 00000000..c6762214 --- /dev/null +++ b/webdoc/login.aspx @@ -0,0 +1,68 @@ +<%@ Import Namespace="System.Web.Security" %> +<html> +<script language="C#" runat=server> + + void Allow () + { + FormsAuthentication.RedirectFromLoginPage (UserEmail.Value, false); + // PersistCookie.Checked); + } + + void Login_Click (object sender, EventArgs e) + { + FormsAuthenticationTicket trust = null; + HttpCookie c; + + switch (UserEmail.Value){ + case "miguel": + trust = new FormsAuthenticationTicket ("high", false, 1); + c = new HttpCookie ("level", FormsAuthentication.Encrypt (trust)); + Response.AppendCookie (c); + Allow (); + break; + case "guest": + trust = new FormsAuthenticationTicket ("low", false, 1); + c = new HttpCookie ("level", FormsAuthentication.Encrypt (trust)); + Response.AppendCookie (c); + Allow (); + break; + default: + Msg.Text = "Invalid Credentials: Please try again"; + break; + } + } + + void Page_Load () + { + Msg.Text = ">>> " + Request.QueryString ["ReturnUrl"] + "<<<"; + } +</script> +<body> +<form runat=server> + + <h3><font face="Verdana">Login Page</font></h3> + <table> + <tr> + <td>Email:</td> + <td><input id="UserEmail" type="text" runat=server/></td> + <td><ASP:RequiredFieldValidator ControlToValidate="UserEmail" + Display="Static" ErrorMessage="*" runat=server/></td> + </tr> + <tr> + <td>Password:</td> + <td><input id="UserPass" type=password runat=server/></td> + <td><ASP:RequiredFieldValidator ControlToValidate="UserPass" + Display="Static" ErrorMessage="*" runat=server/></td> + </tr> + <tr> + <td>Persistent Cookie:</td> + <td><ASP:CheckBox id=PersistCookie runat="server" /> </td> + <td></td> + </tr> + </table> + <asp:button text="Login" OnClick="Login_Click" runat=server/> + <p> + <asp:Label id="Msg" ForeColor="red" Font-Name="Verdana" Font-Size="10" runat=server /> +</form> +</body> +</html> diff --git a/webdoc/logout.aspx b/webdoc/logout.aspx new file mode 100644 index 00000000..af3621be --- /dev/null +++ b/webdoc/logout.aspx @@ -0,0 +1,12 @@ +<%@ Import Namespace="System.Web.Security" %> +<html> +<script language="C#" runat=server> + void Page_Load (object sender, EventArgs e) + { + FormsAuthentication.SignOut (); + Response.Redirect ("index.aspx"); + } +</script> +<body> +</body> +</html> diff --git a/webdoc/mono_logo_g.gif b/webdoc/mono_logo_g.gif Binary files differnew file mode 100644 index 00000000..c6fbaf67 --- /dev/null +++ b/webdoc/mono_logo_g.gif diff --git a/webdoc/monodoc.ashx b/webdoc/monodoc.ashx new file mode 100644 index 00000000..624e31b1 --- /dev/null +++ b/webdoc/monodoc.ashx @@ -0,0 +1,420 @@ +<%@ WebHandler Language="c#" class="Mono.Website.Handlers.MonodocHandler" %> +<%@ Assembly name="monodoc" %> + +#define MONODOC_PTREE + +// +// Mono.Web.Handlers.MonodocHandler. +// +// Authors: +// Ben Maurer (bmaurer@users.sourceforge.net) +// Miguel de Icaza (miguel@novell.com) +// +// (C) 2003 Ben Maurer +// (C) 2006 Novell, Inc. +// + +using System; +using System.Collections; +using System.IO; +using System.Text; +using System.Web; +using System.Web.UI; +using System.Xml; +using System.Xml.Xsl; +using Monodoc; +using System.Text.RegularExpressions; + +namespace Mono.Website.Handlers +{ + public class MonodocHandler : IHttpHandler + { + static RootTree help_tree; + + static MonodocHandler () + { + help_tree = RootTree.LoadTree (); + HelpSource.use_css = true; + HelpSource.FullHtml = false; + SettingsHandler.Settings.EnableEditing = false; + } + + void IHttpHandler.ProcessRequest (HttpContext context) + { + string s; + + s = (string) context.Request.Params["tlink"]; + if (s != null){ + HandleTreeLink (context, s); + return; + } + + s = (string) context.Request.Params["link"]; + if (s != null){ + HandleMonodocUrl (context, s); + return; + } + + s = (string) context.Request.Params["tree"]; + if (s != null){ + if (s == "boot") + HandleBoot (context); + else { + HandleTree (context, s); + } + return; + } + context.Response.Write ("<html><body>Unknown request</body></html>"); + context.Response.ContentType = "text/html"; + } + + void HandleTree (HttpContext context, string tree) + { + context.Response.ContentType = "text/xml"; + //Console.WriteLine ("Tree request: " + tree); + try { + // + // Walk the url, found what we are supposed to render. + // + string [] nodes = tree.Split (new char [] {'@'}); + Node current_node = help_tree; + for (int i = 0; i < nodes.Length; i++){ + try { + current_node = (Node)current_node.Nodes [int.Parse (nodes [i])]; + } catch (Exception e){ + Console.WriteLine ("Failure with: {0} {i}", tree, i); + } + } + + XmlTextWriter w = new XmlTextWriter (context.Response.Output); + + w.WriteStartElement ("tree"); + + for (int i = 0; i < current_node.Nodes.Count; i++) { + Node n = (Node)current_node.Nodes [i]; + + w.WriteStartElement ("tree"); + w.WriteAttributeString ("text", n.Caption); + + if (n.tree != null && n.tree.HelpSource != null) + w.WriteAttributeString ("action", n.tree.HelpSource.SourceID + "@" + HttpUtility.UrlEncode (n.URL)); + + if (n.Nodes != null){ + w.WriteAttributeString ("src", tree + "@" + i); + } + w.WriteEndElement (); + } + w.WriteEndElement (); + } catch (Exception e) { + Console.WriteLine (e); + } + //Console.WriteLine ("Tree request satisfied"); + } + + void CheckLastModified (HttpContext context) + { + string strHeader = context.Request.Headers ["If-Modified-Since"]; + DateTime lastHelpSourceTime = help_tree.LastHelpSourceTime; + try { + if (strHeader != null && lastHelpSourceTime != DateTime.MinValue) { + DateTime dtIfModifiedSince = DateTime.ParseExact (strHeader, "r", null); + DateTime ftime = lastHelpSourceTime.ToUniversalTime (); + if (ftime <= dtIfModifiedSince) { + context.Response.StatusCode = 304; + return; + } + } + } catch { } + + if (lastHelpSourceTime != DateTime.MinValue) { + DateTime lastWT = lastHelpSourceTime.ToUniversalTime (); + context.Response.AddHeader ("Last-Modified", lastWT.ToString ("r")); + } + + } + + void HandleMonodocUrl (HttpContext context, string link) + { + if (link.StartsWith ("source-id:") && + (link.EndsWith (".gif") || link.EndsWith (".jpeg") || + link.EndsWith (".jpg") || link.EndsWith(".png"))){ + switch (link.Substring (link.LastIndexOf ('.') + 1)) + { + case "gif": + context.Response.ContentType = "image/gif"; + break; + case "jpeg": + case "jpg": + context.Response.ContentType = "image/jpeg"; + break; + case "png": + context.Response.ContentType = "image/png"; + break; + default: + throw new Exception ("Internal error"); + } + + Stream s = help_tree.GetImage (link); + + if (s == null) + throw new HttpException (404, "File not found"); + + CheckLastModified (context); + if (context.Response.StatusCode == 304) + return; + + Copy (s, context.Response.OutputStream); + return; + } + + if (help_tree == null) + return; + Node n; + string content = help_tree.RenderUrl (link, out n); + CheckLastModified (context); + if (context.Response.StatusCode == 304) + return; + + PrintDocs (content, context); + } + + void HandleTreeLink (HttpContext context, string link) + { + string [] lnk = link.Split (new char [] {'@'}); + + if (lnk.Length == 1) { + HandleMonodocUrl (context, link); + return; + } + + int hsId = int.Parse (lnk [0]); + + Node n; + string content = help_tree.GetHelpSourceFromId (hsId).GetText (lnk [1], out n); + if (content == null) + content = help_tree.RenderUrl (lnk [1], out n); + PrintDocs (content, context); + + } + + void Copy (Stream input, Stream output) + { + const int BUFFER_SIZE=8192; // 8k buf + byte [] buffer = new byte [BUFFER_SIZE]; + + int len; + while ( (len = input.Read (buffer, 0, BUFFER_SIZE)) > 0) + output.Write (buffer, 0, len); + + output.Flush(); + } + + string requestPath; + void PrintDocs (string content, HttpContext ctx) + { + ctx.Response.Write (@" +<html> +<head> + <link type='text/css' rel='stylesheet' href='common.css' media='all' title='Default style' /> +<script> +<!-- +function login (rurl) +{ + document.location.href = 'login.aspx?ReturnUrl=' + rurl; +} + +function load () +{ + // If topic loaded in a window by itself, load index.aspx with the same set of params. + if (top.location == document.location) + { + top.location.href = 'index.aspx'+document.location.search; + } + parent.Header.document.getElementById ('pageLink').href = parent.content.window.location; + objs = document.getElementsByTagName('img'); + for (i = 0; i < objs.length; i++) + { + e = objs [i]; + if (e.src == null) continue; + + objs[i].src = makeLink (objs[i].src); + } +} + +function makeLink (link) +{ + if (link == '') return ''; + if (link.charAt(0) == '#') return link; + + protocol = link.substring (0, link.indexOf (':')); + + switch (protocol) + { + case 'http': + case 'ftp': + case 'mailto': + case 'javascript': + return link; + + default: + if(document.all) { + return '" + ctx.Request.Path + @"?link=' + link.replace(/\+/g, '%2B').replace(/file:\/\/\//, ''); + } + return '" + ctx.Request.Path + @"?link=' + link.replace(/\+/g, '%2B'); + } +} +--> + </script> + <title>Mono Documentation</title> + "); + if (EcmaHelpSource.css_ecma_code != null) { + ctx.Response.Write ("<style type=\"text/css\">\n"); + ctx.Response.Write (EcmaHelpSource.css_ecma_code); + ctx.Response.Write ("</style>\n"); + } + if (EcmaHelpSource.js_code != null) { + ctx.Response.Write ("<script type=\"text/JavaScript\">\n"); + ctx.Response.Write (EcmaHelpSource.js_code); + ctx.Response.Write ("</script>\n"); + } + ctx.Response.Write (@" + </head> + <body onLoad='load()'> + "); + // Set up object variable, as it's required by the MakeLink delegate + requestPath=ctx.Request.Path; + string output; + + if (content == null) + output = "No documentation available on this topic"; + else { + output = MakeLinks(content); + } + ctx.Response.Write (output); + ctx.Response.Write (@"</body></html>"); + } + + + string MakeLinks(string content) + { + MatchEvaluator linkUpdater=new MatchEvaluator(MakeLink); + if(content.Trim().Length<1|| content==null) + return content; + try + { + string updatedContents=Regex.Replace(content,"(<a[^>]*href=['\"])([^'\"]+)(['\"][^>]*)(>)", linkUpdater); + return(updatedContents); + } + catch(Exception e) + { + return "LADEDA" + content+"!<!--Exception:"+e.Message+"-->"; + } + } + + // Delegate to be called from MakeLinks for fixing <a> tag + string MakeLink (Match theMatch) + { + string updated_link = null; + + // Return the link without change if it of the form + // $protocol:... or #... + string link = theMatch.Groups[2].ToString(); + if (Regex.Match(link, @"^\w+:\/\/").Success || Regex.Match(link, "^#").Success || + Regex.Match(link, @"^javascript:").Success) + updated_link = theMatch.Groups[0].ToString(); + else if (link.StartsWith ("edit:")){ + link = link.Substring (5); + updated_link = String.Format("{0}/edit.aspx?link={2}{3} target=\"content\"{4}", + theMatch.Groups[1].ToString(), + requestPath, + HttpUtility.UrlEncode (link.Replace ("file://","")), + theMatch.Groups[3].ToString(), + theMatch.Groups[4].ToString()); + + } else { + updated_link = String.Format ("{0}{1}?link={2}{3} target=\"content\"{4}", + theMatch.Groups[1].ToString(), + requestPath, + HttpUtility.UrlEncode (link.Replace ("file://","")), + theMatch.Groups[3].ToString(), + theMatch.Groups[4].ToString()); + + } + return updated_link; + } + + bool IHttpHandler.IsReusable + { + get { + return true; + } + } + + void HandleBoot (HttpContext context) + { + context.Response.Write (@" +<html> + <head> + <link type='text/css' rel='stylesheet' href='ptree/tree.css'/> + <link type='text/css' rel='stylesheet' href='sidebar.css'/> + <script src='xtree/xmlextras.js'></script> + <script src='ptree/tree.js'></script> + <script src='sidebar.js'></script> + <script> + var tree = new PTree (); + function onBodyLoad () + { + tree.strTargetDefault = 'content'; + tree.strSrcBase = 'monodoc.ashx?tree='; + tree.strActionBase = 'monodoc.ashx?tlink='; + tree.strImagesBase = 'xtree/images/msdn2/'; + tree.strImageExt = '.gif'; + var content = document.getElementById ('contentList'); + var root = tree.CreateItem (null, 'Mono Documentation', 'intro.html', '', true); + content.appendChild (root); + "); + + for (int i = 0; i < help_tree.Nodes.Count; i++){ + Node n = (Node)help_tree.Nodes [i]; + context.Response.Write ( + "tree.CreateItem (root, '" + n.Caption + "', '" + + n.URL + "', "); + + if (n.Nodes.Count != 0) + context.Response.Write ("'" + i + "'"); + else + context.Response.Write ("null"); + + if (i == help_tree.Nodes.Count-1) + context.Response.Write (", true"); + + context.Response.Write (@"); + "); + } + context.Response.Write (@" + }</script> + </head> + <body onLoad='javascript:onBodyLoad();' onkeydown='javascript:return tree.onKeyDown (event);'> + <div id='tabs'> + <ul> + <li id='contentsTab' class='selected'><a href='javascript:ShowContents();'>Contents</a></li> + <li id='indexTab' style='display:none;'><a href='javascript:ShowIndex();'>Index</a></li> + </ul> + </div> + <div id='contents' class='activeTab'> + <div id='contentList'> + </div> + </div> + <div id='index' class='tab'> + <p> + <label for='indexInput'>Lookup:</label> <input type='text' id='indexInput'/> + <img alt='Spinner-blue' id='search_spinner' src='images/searching.gif' style='display:none;' align='middle' /> + <p id='errorText'></p> + <ul id='indexList'></ul> + </div> + </body> +</html> +"); + } + } +} diff --git a/webdoc/monodoc.asmx b/webdoc/monodoc.asmx new file mode 100755 index 00000000..eefa4cc4 --- /dev/null +++ b/webdoc/monodoc.asmx @@ -0,0 +1,210 @@ +<%@ WebService language="C#" class="Editing" %>
+
+// MonoDoc Editing WebService
+//
+// (C) 2003 by Johannes Roith
+// Author: Johannes Roith
+
+// Client API:
+//
+// Editing edit = new Editing();
+// Response response = edit.Submit("Johannes Roith", "johannes@jroith.de",
+// "This is a change through monodoc editing.", xml);
+
+// response contains:
+// a server status message (response.Message)
+// a statuscode (response.Status)
+
+// Statuscodes:
+//
+// 1 - everything went right
+// 2 - the xml is not well-formed.
+// 3 - some data is missing (email, name, etc.).
+// 4 - the data was already posted
+// 5 - Some internal Server error
+
+
+using System;
+using System.Web.Services;
+using System.Xml.Serialization;
+using System.Xml;
+using System.Text;
+using System.Security.Cryptography;
+
+[WebService(Namespace="http://www.go-mono.org/monodoc")]
+public class Editing {
+
+ [WebMethod]
+ public Response Submit(string author, string email, string personalmessage, string xmldata) {
+
+ Response response;
+ string newsum = GetMd5Sum(xmldata);
+ XmlElement dataroot;
+ XmlDocument oldposts;
+ string today = Convert.ToString(DateTime.Now.DayOfYear);
+
+ try {
+
+
+ oldposts = new XmlDocument();
+ oldposts.Load("oldposts.xml");
+
+ dataroot = oldposts.DocumentElement;
+
+ // Eventually only block in certain time frame?
+ // XmlNodeList datanodes = dataroot.SelectNodes("/oldposts/post[@date='" + today + "']");
+
+ XmlNodeList datanodes = dataroot.SelectNodes("/oldposts/post");
+
+ foreach(XmlNode datanode in datanodes) {
+ if (datanode.Attributes["md5"].Value == newsum) {
+
+ response = new Response();
+ response.Status = 4;
+ response.Message = "This was already posted.";
+
+ return response;
+ }
+ }
+
+ if (xmldata == "")
+ {
+
+ response = new Response();
+ response.Status = 2;
+ response.Message = "Xml not well-formed. No data was posted.";
+
+ return response;
+ }
+
+ XmlDocument doc = new XmlDocument();
+ doc.LoadXml(xmldata);
+
+ XmlElement root = doc.DocumentElement;
+ XmlNodeList nodes = root.SelectNodes("/GlobalChangeset/DocSetChangeset");
+
+ // IMO it's best to generate different Mails for
+ // different DocSets, so the correct people can get their hands on it.
+ // e.g one mail for Gtk#, one for ecma docs.
+
+ foreach (XmlNode node in nodes) {
+
+ string datastring = "";
+
+ XmlNodeList filenodes = node.SelectNodes("FileChangeset");
+
+
+ foreach (XmlNode filenode in filenodes) {
+ datastring += RenderFileSet(filenode);
+ }
+
+ string target = node.Attributes["DocSet"].Value;
+
+ string header = "---------------------\n"
+ + "MonoDoc Change\n"
+ + "---------------------\n\n"
+ + "This mail was generated by monodoc.\n\n"
+ + "--------------------------------------------------\n"
+ + "Author: " + author + "\n"
+ + "EMail: " + email + "\n"
+ + "personal Message: " + personalmessage + "\n\n"
+ + "--------------------------------------------------\n\n"
+ + "Changes are listed below:\n\n"
+ + "*************************************\n\n";
+
+ string footer = "\n\n---------------------------------------\n"
+ + "Monodoc Editing WebService";
+
+ SendMail("Monodoc: " + target, header + datastring + footer);
+ }
+
+ }
+
+ catch {
+
+ response = new Response();
+ response.Status = 5;
+ response.Message = "An unknown error occured.";
+
+ return response;
+
+ }
+
+
+ XmlNode rootnode = dataroot.SelectSingleNode("/oldposts");
+
+ XmlElement newentry = oldposts.CreateElement("post");
+ newentry.SetAttribute("md5", newsum);
+ newentry.SetAttribute("date", today);
+ rootnode.AppendChild(newentry);
+ oldposts.Save("oldposts.xml");
+
+ response = new Response();
+ response.Status = 1;
+ response.Message = "Your changes were sent to Mono Docs List.\n"
+ + "They will be reviewed as soon as possible.";
+
+ return response;
+
+ }
+
+ string RenderFileSet(XmlNode filenode) {
+
+ // Rendering should be improved eventually,
+ // so no xml remains.
+
+ return "FILE: " + filenode.Attributes["RealFile"] + "\n\n"
+ + filenode.InnerXml
+ + "\n\n*************************************\n\n";
+ }
+
+ public class Response {
+
+ public int Status;
+ public string Message;
+ }
+
+ public void SendMail(string subject, string body) {
+
+ System.Web.Mail.MailMessage mailMessage = new System.Web.Mail.MailMessage();
+
+ // NOTE: I have made this "groith@tcrz.net",
+ // so it won't be blocked.
+ // Should be changed later.
+
+ mailMessage.From = "groith@tcrz.net";
+ mailMessage.To = "mono-docs-list@ximian.com";
+ mailMessage.Subject = subject;
+ mailMessage.Body = body;
+ mailMessage.BodyFormat = System.Web.Mail.MailFormat.Text;
+
+ System.Web.Mail.SmtpMail.SmtpServer = "post.tcrz.net";
+ System.Web.Mail.SmtpMail.Send(mailMessage);
+
+
+ }
+
+ // from http://weblog.stevex.org/radio/stories/2002/12/08/
+ // cCodeSnippetCreatingAnMd5HashString.html
+
+ public string GetMd5Sum(string str)
+ {
+ Encoder enc = System.Text.Encoding.Unicode.GetEncoder();
+
+ byte[] unicodeText = new byte[str.Length * 2];
+ enc.GetBytes(str.ToCharArray(), 0, str.Length, unicodeText, 0, true);
+
+ MD5 md5 = new MD5CryptoServiceProvider();
+ byte[] result = md5.ComputeHash(unicodeText);
+
+ StringBuilder sb = new StringBuilder();
+ for (int i=0;i<result.Length;i++)
+ {
+ sb.Append(result[i].ToString("X2"));
+ }
+
+ return sb.ToString();
+}
+
+
+}
diff --git a/webdoc/oldposts.xml b/webdoc/oldposts.xml new file mode 100755 index 00000000..1a841827 --- /dev/null +++ b/webdoc/oldposts.xml @@ -0,0 +1,3 @@ +<?xml version="1.0" encoding="utf-8"?>
+<oldposts>
+</oldposts>
\ No newline at end of file diff --git a/webdoc/ptree/tree.css b/webdoc/ptree/tree.css new file mode 100755 index 00000000..fed1384f --- /dev/null +++ b/webdoc/ptree/tree.css @@ -0,0 +1,67 @@ +body { + font-family: verdana; + font-size: 70.5%; + font-weight: normal; + background-color: #fff; + color: Black; + margin: 0px 0px 0px 0px; + padding: 0px 0px 0px 0px; + vertical-align: middle; +} + +.tree-node, +.tree-node-collapsed +{ + margin: 0px; + padding: 0px; + border: 0px; + white-space: nowrap; +} + +.tree-label +.tree-label-selected +{ + margin: 0px; + padding: 0px; + border: 0px; + white-space: nowrap; +} + +.tree-node-collapsed .tree-node, +.tree-node-collapsed .tree-node-collapsed +{ + display: none; +} + +.tree-label-selected a, +.tree-label-selected a:hover +{ + text-decoration: none; + background: highlight; + color: highlighttext; +} + +.tree-label a +{ + text-decoration: none; + background: #fff; + color: black; +} + +.tree-label a:hover +{ + background-image: url('../images/searching.gif'); + text-decoration: none; + background: #dfdfdf; + color: black; + border: 1px solid; + border-color: grey; + padding: 1px; +} + +.tree-node img +{ + vertical-align: middle; + border: 0px; +} + diff --git a/webdoc/ptree/tree.js b/webdoc/ptree/tree.js new file mode 100755 index 00000000..69e1b862 --- /dev/null +++ b/webdoc/ptree/tree.js @@ -0,0 +1,397 @@ +//
+// PTree - A dynamically loaded TOC tree
+//
+// Author:
+// Piers Haken (piersh@friskit.com)
+//
+// (C) 2003 Piers Haken
+//
+
+// TODO:
+// work out how to cancel scrolling keyboard events on Mozilla
+// better support for multiple trees in a single body
+
+function PTree ()
+{
+ this.strActionBase = "";
+ this.strSrcBase = "";
+ this.strTargetDefault = "";
+ this.strImagesBase = "images/";
+ this.strImageExt = ".png";
+ this.eltSelected = null;
+ this.nImageWidth = 18;
+ this.nImageHeight = 18;
+
+ this.CreateItemFromXML = function (oNode, fLast, eltParent)
+ {
+ var strText = oNode.getAttribute ("text");
+ var strAction = oNode.getAttribute ("action");
+ var strSrc = oNode.getAttribute ("src");
+ var strTarget = oNode.getAttribute ("target");
+ return this.CreateItem (eltParent, strText, strAction, strSrc, fLast, strTarget, fLast, eltParent);
+ }
+
+ this.CreateItem = function (eltParent, strText, strAction, strSrc, fLast, strTarget)
+ {
+ var _this = this;
+
+ var eltDiv = document.createElement ("DIV");
+ if (eltParent == null)
+ eltDiv.tree_fRoot = true;
+
+ if (fLast)
+ eltDiv.tree_fLast = true;
+
+ if (strAction)
+ eltDiv.tree_action = strAction;
+
+ if (strSrc != null)
+ eltDiv.tree_src = strSrc;
+
+ var eltSpan = document.createElement ("SPAN");
+ eltSpan.className = "tree-label";
+
+ if (eltParent)
+ {
+ eltDiv.className = "tree-node-collapsed";
+
+ // this node's tree icon
+ var eltIcon = new Image ();
+ eltIcon.width = this.nImageWidth;
+ eltIcon.height = this.nImageHeight;
+ if (strSrc)
+ eltIcon.onclick = function () { _this.LoadNode (this); }
+ eltIcon.src = this.GetIconSrc (eltDiv, true);
+ eltSpan.appendChild (eltIcon);
+
+ // parent's tree icons
+ var eltIconLast = eltIcon;
+ var eltParentDiv = eltParent;
+ while (!this.IsRootDiv (eltParentDiv))
+ {
+ var eltIcon = new Image ();
+ eltIcon.width = this.nImageWidth;
+ eltIcon.height = this.nImageHeight;
+ if (this.IsLastDiv (eltParentDiv))
+ eltIcon.src = this.strImagesBase + "blank" + this.strImageExt;
+ else
+ eltIcon.src = this.strImagesBase + "I" + this.strImageExt;
+
+ eltSpan.insertBefore (eltIcon, eltIconLast);
+ eltIconLast = eltIcon;
+ eltParentDiv = this.GetParentDiv (eltParentDiv);
+ }
+ }
+ else
+ {
+ eltDiv.className = "tree-node";
+ //document.body.onkeydown = function () { return _this.onKeyDown (); }
+ }
+
+ // description
+ var eltText = document.createTextNode (strText);
+ var eltDescription;
+
+ if (strAction)
+ {
+ eltDescription = document.createElement ("a");
+ eltDescription.href = this.strActionBase + strAction; + eltDescription.title = strText;
+ if (strTarget)
+ eltDescription.target = strTarget;
+ else if (this.strTargetDefault)
+ eltDescription.target = this.strTargetDefault;
+ eltDescription.appendChild (eltText);
+ eltDescription.onclick = function () { _this.SelectNode (eltDiv); }
+ eltDescription.onmouseover = function () { this.blur (); }
+ eltDescription.onmouseup = function () { this.blur (); }
+ }
+ else
+ {
+ eltDescription = document.createElement ("span"); + eltDescription.className = "tree-label"; + eltDescription.innerHTML = strText; + }
+
+ eltSpan.appendChild (eltDescription);
+ eltDiv.appendChild (eltSpan);
+
+ // append this node to its parent
+ if (eltParent)
+ eltParent.appendChild (eltDiv);
+ else
+ this.SelectNode (eltDiv);
+
+ return eltDiv;
+ }
+
+ this.SelectNode = function (eltDiv)
+ {
+ if (this.eltSelected != eltDiv)
+ {
+ if (eltDiv)
+ {
+ var eltLabel = this.GetSpan (eltDiv);
+ eltLabel.className = "tree-label-selected";
+ }
+ if (this.eltSelected)
+ {
+ var eltLabel = this.GetSpan (this.eltSelected);
+ eltLabel.className = "tree-label";
+ }
+ this.eltSelected = eltDiv;
+ }
+ }
+
+ this.LoadNode = function (eltIcon)
+ {
+ var eltDiv = this.GetDivFromIcon (eltIcon);
+ eltIcon.onclick = null;
+
+ var eltLoading = this.CreateItem (eltDiv, "<img src=\"../images/searching.gif\"/>Loading...", null, null, true);
+ eltLoading.className = '';
+
+ var xmlHttp = XmlHttp.create();
+ xmlHttp.open ("GET", this.strSrcBase + eltDiv.tree_src, true); // async
+ var _this = this;
+ xmlHttp.onreadystatechange = function () { _this.onReadyStateChange (xmlHttp, eltIcon, eltLoading); }
+ setTimeout (function () { xmlHttp.send (null); }, 10);
+ }
+
+ this.onReadyStateChange = function (xmlHttp, eltIcon, eltLoading)
+ {
+ if (xmlHttp.readyState != 4)
+ return;
+ // XML loaded
+ var eltDiv = this.GetDivFromIcon (eltIcon);
+
+ try
+ {
+ var doc = xmlHttp.responseXML;
+ var root = doc.documentElement;
+
+ var nodes = root.childNodes;
+ var cNodes = nodes.length;
+
+ for (var iNode = 0; iNode < cNodes; iNode ++)
+ this.CreateItemFromXML (nodes [iNode], iNode == cNodes-1, eltDiv);
+
+ eltDiv.removeChild (eltLoading);
+
+ if (this.eltSelected == eltLoading)
+ this.SelectNode (this.GetFirstChild (eltDiv));
+
+ eltIcon.src = this.GetIconSrc (eltDiv, false);
+ }
+ catch (e)
+ {
+ this.SetText (eltLoading, "Failed to load topic");
+ }
+ eltDiv.className = "tree-node";
+ var _this = this;
+ eltIcon.onclick = function () { _this.onClickMinus (this); }
+ }
+
+ this.onClickPlus = function (eltIcon)
+ {
+ var eltDiv = this.GetDivFromIcon (eltIcon);
+ eltDiv.className = "tree-node";
+ eltIcon.src = this.GetIconSrc (eltDiv, false);
+ var _this = this;
+ eltIcon.onclick = function () { _this.onClickMinus (this); }
+ }
+
+ this.onClickMinus = function (eltIcon)
+ {
+ var eltDiv = this.GetDivFromIcon (eltIcon);
+ eltDiv.className = "tree-node-collapsed";
+ eltIcon.src = this.GetIconSrc (eltDiv, true);
+ var _this = this;
+ eltIcon.onclick = function () { _this.onClickPlus (this); }
+ }
+
+ this.onKeyDown = function (event)
+ {
+ var eltSelect = this.eltSelected;
+ var fLast = this.IsLastDiv (eltSelect);
+ var fRoot = this.IsRootDiv (eltSelect);
+
+ switch (event.keyCode)
+ {
+ case 13: // return
+ var eltLink = eltSelect.firstChild.lastChild;
+ if (eltSelect.tree_action)
+ window.open (eltLink.href, eltLink.target);
+ this.SelectNode (eltSelect);
+ return false; // don't EnsureVisible
+
+ case 38: // up
+ if (!fRoot)
+ {
+ if (this.IsFirstChild (eltSelect))
+ eltSelect = this.GetParentDiv (eltSelect);
+ else
+ {
+ eltSelect = eltSelect.previousSibling;
+ while (this.IsExpanded (eltSelect))
+ eltSelect = eltSelect.lastChild;
+ }
+ }
+ break;
+
+ case 40: // down
+ if (this.IsExpanded (eltSelect))
+ eltSelect = this.GetFirstChild (eltSelect);
+ else if (!fLast)
+ eltSelect = eltSelect.nextSibling;
+ else
+ {
+ while (!this.IsRootDiv (eltSelect) && this.IsLastDiv (eltSelect))
+ eltSelect = this.GetParentDiv (eltSelect);
+
+ if (this.IsRootDiv (eltSelect))
+ return false;
+
+ eltSelect = eltSelect.nextSibling;
+ }
+ break;
+
+ case 37: // left
+ if (!fRoot)
+ {
+ if (this.IsExpanded (eltSelect))
+ this.onClickMinus (this.GetIconFromDiv (eltSelect));
+ else
+ eltSelect = this.GetParentDiv (eltSelect);
+ }
+ break;
+
+ case 39: // right
+ if (this.HasChildren (eltSelect))
+ {
+ var eltChild = this.GetFirstChild (eltSelect);
+ if (this.IsExpanded (eltSelect))
+ eltSelect = eltChild;
+ else if (eltChild != null)
+ this.onClickPlus (this.GetIconFromDiv (eltSelect));
+ else
+ this.LoadNode (this.GetIconFromDiv (eltSelect));
+ }
+ break;
+
+ default:
+ return true;
+ }
+
+ this.SelectNode (eltSelect);
+ this.EnsureVisible (this.GetLabel (eltSelect));
+
+ return false;
+ }
+
+ this.SetText = function (eltDiv, strText)
+ {
+ var eltText = eltDiv.lastChild;
+ eltText.nodeValue = strText;
+ }
+
+ this.GetIconSrc = function (eltDiv, fPlus)
+ {
+ var strIconSrc = this.IsLastDiv (eltDiv) ? "L" : "T";
+ if (eltDiv.tree_src != null)
+ strIconSrc += fPlus ? "plus" : "minus";
+ return this.strImagesBase + strIconSrc + this.strImageExt;
+ }
+
+ this.GetDivFromIcon = function (eltIcon)
+ {
+ return eltIcon.parentNode.parentNode;
+ }
+
+ this.GetIconFromDiv = function (eltDiv)
+ {
+ return eltDiv.firstChild.lastChild.previousSibling;
+ }
+
+ this.GetFirstChild = function (eltDiv)
+ {
+ return eltDiv.firstChild.nextSibling;
+ }
+
+ this.GetSpan = function (eltDiv)
+ {
+ return eltDiv.firstChild;
+ }
+
+ this.GetLabel = function (eltDiv)
+ {
+ return eltDiv.firstChild.lastChild;
+ }
+
+ this.GetParentDiv = function (eltDiv)
+ {
+ if (this.IsRootDiv (eltDiv))
+ return null;
+ return eltDiv.parentNode;
+ }
+
+ this.HasChildren = function (eltDiv)
+ {
+ return eltDiv.tree_src || this.IsRootDiv (eltDiv);
+ }
+
+ this.IsLastDiv = function (eltDiv)
+ {
+ return eltDiv.tree_fLast;
+ }
+
+ this.IsRootDiv = function (eltDiv)
+ {
+ return Boolean (eltDiv.tree_fRoot);
+ }
+
+ this.IsExpanded = function (eltDiv)
+ {
+ return eltDiv.className != "tree-node-collapsed";
+ }
+
+ this.IsFirstChild = function (eltDiv)
+ {
+ var fFirst =
+ eltDiv.previousSibling &&
+ eltDiv.previousSibling.tagName != "DIV";
+ return fFirst;
+ }
+
+ this.EnsureVisible = function (elt)
+ {
+ var x = 0;
+ var y = 0;
+ var parent = elt;
+ while (parent != null)
+ {
+ x += parent.offsetLeft;
+ y += parent.offsetTop;
+ parent = parent.offsetParent;
+ }
+
+ var yView = window.frameElement.scrollTop + document.body.scrollTop;
+ var dyView = document.body.clientHeight;
+ var dy = 0;
+ if (y + elt.offsetHeight > yView + dyView)
+ dy = (y + elt.offsetHeight) - (yView + dyView);
+ if (y < yView + dy)
+ dy = y - yView;
+
+ var xView = window.frameElement.scrollLeft + document.body.scrollLeft;
+ var dxView = document.body.clientWidth;
+ var dx = 0;
+ if (x + elt.offsetWidth > xView + dxView)
+ dx = (x + elt.offsetWidth) - (xView + dxView);
+ if (x < xView + dx)
+ dx = x - xView;
+
+ if (dx != 0 || dy != 0)
+ window.scrollBy (dx, dy);
+ }
+}
diff --git a/webdoc/sidebar.css b/webdoc/sidebar.css new file mode 100644 index 00000000..6a848b39 --- /dev/null +++ b/webdoc/sidebar.css @@ -0,0 +1,129 @@ +body { + font-family: Verdana; + margin: 0px !important; + padding: 0px !important; + font-size: 8pt; + background-color: white; + white-space: nowrap; +} + +.tab { + display: none !important; +} + +.activeTab { + padding-top: 35px; + padding-left: 10px; + padding-right: 10px; + display: block !important; +} + +input[type=text] { + border: 1px solid #B1A598; + padding: 2px; +} + +input[type=text]:focus { +} + +.error { + color: red; + font-weight: bold; +} + +ul#indexList { + padding: 0px; + margin-left: 0px; + margin-right: 0px; + margin-bottom: 0px; + margin-top: 10px; +} + +ul#indexList li { + list-style: none; + padding-left: 13px; + padding-top: 2px; + padding-bottom: 2px; + background: url('/images/treenodedot.gif') no-repeat center left; +} + +#contentsList ul { + padding: 0px; + margin-left: 0px; + margin-top: 0px; +} + +#contentsList ul ul{ + padding-left: 15px; + margin: 0px !important; +} + +#contentsList ul li { + list-style: none; + padding-bottom: 3px; +} + +#contentsList ul li a { + text-decoration: none; + color: black; +} + +#contentsList ul li img { + border: 0px; + vertical-align: middle; +} + +#tabs { + position: fixed; + top: 0; + left: 0; + right: 0; +} + +#tabs ul { + margin-left: 0px; + padding-left: 5px; + border-bottom: 1px solid #B1A598; + padding-bottom: 3px; + background-color: #EFEBE7; + padding-top: 10px; + margin-top: 0px !important; + margin-bottom: 0px !important; +} +#tabs { + border-bottom: 2px solid white; +} + + +#tabs ul li { + display: inline; + border-top: 1px solid #B1A598; + border-left: 1px solid #B1A598; + border-right: 1px solid #B1A598; + padding-top: 3px; + padding-bottom: 3px; + padding-left: 5px; + padding-right: 5px; +} + +#tabs ul li.selected, ul#tabs li:hover { + background-color: white; +} +#tabs ul li.selected { + border-bottom: 1px solid white; +} +#tabs ul li a { + color: black; + text-decoration: none; +} + +a.selected { + /*font-weight: bold;*/ + background: #eee; + border: 1px solid #ccc; + padding: 1px; +} + +#errorText { + margin-top: 10px; +} diff --git a/webdoc/sidebar.js b/webdoc/sidebar.js new file mode 100644 index 00000000..f62b1770 --- /dev/null +++ b/webdoc/sidebar.js @@ -0,0 +1,28 @@ +function SetSelection(b,v) +{ + if (v){ + t = "activeTab"; + tab = "selected"; + } else { + t = "tab"; + tab = ""; + } + + document.getElementById (b).className = t; + document.getElementById (b + "Tab").className = tab; +} + +function ShowContents () +{ + SetSelection ("contents", true); + SetSelection ("index", false); +} + +function ShowIndex () +{ + SetSelection ("contents", false); + SetSelection ("index", true); + document.getElementById ('indexInput').focus (); +} + + diff --git a/webdoc/web.config b/webdoc/web.config new file mode 100644 index 00000000..5facc49c --- /dev/null +++ b/webdoc/web.config @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="utf-8"?> +<configuration> + <configSections> + <sectionGroup name="mono.aspnet"> + <section name="acceptEncoding" + type="Mono.Http.Configuration.AcceptEncodingSectionHandler, Mono.Http, Version=1.0.5000.0, PublicKeyToken=0738eb9f132ed756"/> + </sectionGroup> + </configSections> + <system.web> + <customErrors mode="Off"/> + <authentication mode= "Forms"> + </authentication> + </system.web> + <mono.aspnet> + <acceptEncoding> + <!-- Change disabled to 'no' to enable gzip content encoding --> + <add encoding="gzip" type="Mono.Http.GZipWriteFilter, Mono.Http, Version=1.0.5000.0, PublicKeyToken=0738eb9f132ed756" + disabled="no" /> + </acceptEncoding> + </mono.aspnet> + + <appSettings> + <add key="MonoServerDefaultIndexFiles" + value="index.aspx, Default.aspx, default.aspx, index.html, index.htm" /> + </appSettings> + <location path="edit.aspx"> + <system.web> + <authentication mode="Forms"> + <forms name=".MONOAUTH" loginUrl="login.aspx"/> + </authentication> + <authorization> + <deny users="?" /> + </authorization> + </system.web> + </location> +</configuration> + diff --git a/webdoc/wiki2ecmahelper.xsl b/webdoc/wiki2ecmahelper.xsl new file mode 100644 index 00000000..4039cd9e --- /dev/null +++ b/webdoc/wiki2ecmahelper.xsl @@ -0,0 +1,70 @@ +<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> + + <!-- default rule --> + <xsl:template match="*"> + <xsl:copy> + <xsl:copy-of select="@*" /> + <xsl:apply-templates /> + </xsl:copy> + </xsl:template> + + <xsl:template match="code"> + <xsl:element name="c"><xsl:apply-templates /></xsl:element> + </xsl:template> + + <xsl:template match="div"> + <xsl:choose> + <xsl:when test="@class = 'example'"> + <example><xsl:apply-templates /></example> + </xsl:when> + <xsl:when test="@class = 'behavior'"> + <block type="behavior"><xsl:apply-templates /></block> + </xsl:when> + <xsl:when test="@class = 'default'"> + <block type="default"><xsl:apply-templates /></block> + </xsl:when> + <xsl:when test="@class = 'example-block'"> + <block type="example"><xsl:apply-templates /></block> + </xsl:when> + <xsl:when test="@class = 'overrides'"> + <block type="overrides"><xsl:apply-templates /></block> + </xsl:when> + <xsl:when test="@class = 'usage'"> + <block type="usage"><xsl:apply-templates /></block> + </xsl:when> + <xsl:otherwise> + <xsl:copy-of select="." /> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + + <xsl:template match="table"> + <list type="table"> + <xsl:if test="tr[1]/th"> + <listheader><item> + <term> + <xsl:apply-templates select="tr[1]/th[1]" /> + </term> + <xsl:for-each select="tr[1]/th[position() > 1]"> + <description> + <xsl:apply-templates /> + </description> + </xsl:for-each> + </item></listheader> + </xsl:if> + <xsl:for-each select="tr"> + <item> + <term> + <xsl:apply-templates select="td[1]" /> + </term> + <xsl:for-each select="td[position() > 1]"> + <description> + <xsl:apply-templates /> + </description> + </xsl:for-each> + </item> + </xsl:for-each> + </list> + </xsl:template> + +</xsl:transform> diff --git a/webdoc/xtree/images/I.png b/webdoc/xtree/images/I.png Binary files differnew file mode 100644 index 00000000..e8512fb9 --- /dev/null +++ b/webdoc/xtree/images/I.png diff --git a/webdoc/xtree/images/L.png b/webdoc/xtree/images/L.png Binary files differnew file mode 100644 index 00000000..eb334eda --- /dev/null +++ b/webdoc/xtree/images/L.png diff --git a/webdoc/xtree/images/Lminus.png b/webdoc/xtree/images/Lminus.png Binary files differnew file mode 100644 index 00000000..f7c43c0a --- /dev/null +++ b/webdoc/xtree/images/Lminus.png diff --git a/webdoc/xtree/images/Lplus.png b/webdoc/xtree/images/Lplus.png Binary files differnew file mode 100644 index 00000000..848ec2fc --- /dev/null +++ b/webdoc/xtree/images/Lplus.png diff --git a/webdoc/xtree/images/T.png b/webdoc/xtree/images/T.png Binary files differnew file mode 100644 index 00000000..30173254 --- /dev/null +++ b/webdoc/xtree/images/T.png diff --git a/webdoc/xtree/images/Tminus.png b/webdoc/xtree/images/Tminus.png Binary files differnew file mode 100644 index 00000000..2260e424 --- /dev/null +++ b/webdoc/xtree/images/Tminus.png diff --git a/webdoc/xtree/images/Tplus.png b/webdoc/xtree/images/Tplus.png Binary files differnew file mode 100644 index 00000000..2c8d8f4f --- /dev/null +++ b/webdoc/xtree/images/Tplus.png diff --git a/webdoc/xtree/images/blank.png b/webdoc/xtree/images/blank.png Binary files differnew file mode 100644 index 00000000..cee9cd37 --- /dev/null +++ b/webdoc/xtree/images/blank.png diff --git a/webdoc/xtree/images/clean/I.gif b/webdoc/xtree/images/clean/I.gif Binary files differnew file mode 100644 index 00000000..b2d86c54 --- /dev/null +++ b/webdoc/xtree/images/clean/I.gif diff --git a/webdoc/xtree/images/clean/L.gif b/webdoc/xtree/images/clean/L.gif Binary files differnew file mode 100644 index 00000000..b58e9378 --- /dev/null +++ b/webdoc/xtree/images/clean/L.gif diff --git a/webdoc/xtree/images/clean/Lminus.gif b/webdoc/xtree/images/clean/Lminus.gif Binary files differnew file mode 100644 index 00000000..33c49d13 --- /dev/null +++ b/webdoc/xtree/images/clean/Lminus.gif diff --git a/webdoc/xtree/images/clean/Lplus.gif b/webdoc/xtree/images/clean/Lplus.gif Binary files differnew file mode 100644 index 00000000..9d2a2ac5 --- /dev/null +++ b/webdoc/xtree/images/clean/Lplus.gif diff --git a/webdoc/xtree/images/clean/T.gif b/webdoc/xtree/images/clean/T.gif Binary files differnew file mode 100644 index 00000000..b58e9378 --- /dev/null +++ b/webdoc/xtree/images/clean/T.gif diff --git a/webdoc/xtree/images/clean/Tminus.gif b/webdoc/xtree/images/clean/Tminus.gif Binary files differnew file mode 100644 index 00000000..33c49d13 --- /dev/null +++ b/webdoc/xtree/images/clean/Tminus.gif diff --git a/webdoc/xtree/images/clean/Tplus.gif b/webdoc/xtree/images/clean/Tplus.gif Binary files differnew file mode 100644 index 00000000..9d2a2ac5 --- /dev/null +++ b/webdoc/xtree/images/clean/Tplus.gif diff --git a/webdoc/xtree/images/clean/blank.gif b/webdoc/xtree/images/clean/blank.gif Binary files differnew file mode 100755 index 00000000..c23b58ca --- /dev/null +++ b/webdoc/xtree/images/clean/blank.gif diff --git a/webdoc/xtree/images/file.png b/webdoc/xtree/images/file.png Binary files differnew file mode 100644 index 00000000..a20c6fa0 --- /dev/null +++ b/webdoc/xtree/images/file.png diff --git a/webdoc/xtree/images/foldericon.png b/webdoc/xtree/images/foldericon.png Binary files differnew file mode 100644 index 00000000..2684748b --- /dev/null +++ b/webdoc/xtree/images/foldericon.png diff --git a/webdoc/xtree/images/msdn/I.gif b/webdoc/xtree/images/msdn/I.gif Binary files differnew file mode 100644 index 00000000..f9b3f272 --- /dev/null +++ b/webdoc/xtree/images/msdn/I.gif diff --git a/webdoc/xtree/images/msdn/L.gif b/webdoc/xtree/images/msdn/L.gif Binary files differnew file mode 100644 index 00000000..29f21fd2 --- /dev/null +++ b/webdoc/xtree/images/msdn/L.gif diff --git a/webdoc/xtree/images/msdn/Lminus.gif b/webdoc/xtree/images/msdn/Lminus.gif Binary files differnew file mode 100644 index 00000000..0fae6aca --- /dev/null +++ b/webdoc/xtree/images/msdn/Lminus.gif diff --git a/webdoc/xtree/images/msdn/Lplus.gif b/webdoc/xtree/images/msdn/Lplus.gif Binary files differnew file mode 100644 index 00000000..092e97e1 --- /dev/null +++ b/webdoc/xtree/images/msdn/Lplus.gif diff --git a/webdoc/xtree/images/msdn/T.gif b/webdoc/xtree/images/msdn/T.gif Binary files differnew file mode 100644 index 00000000..9e02eb26 --- /dev/null +++ b/webdoc/xtree/images/msdn/T.gif diff --git a/webdoc/xtree/images/msdn/Tminus.gif b/webdoc/xtree/images/msdn/Tminus.gif Binary files differnew file mode 100644 index 00000000..3f191949 --- /dev/null +++ b/webdoc/xtree/images/msdn/Tminus.gif diff --git a/webdoc/xtree/images/msdn/Tplus.gif b/webdoc/xtree/images/msdn/Tplus.gif Binary files differnew file mode 100644 index 00000000..7a7af256 --- /dev/null +++ b/webdoc/xtree/images/msdn/Tplus.gif diff --git a/webdoc/xtree/images/msdn/blank.gif b/webdoc/xtree/images/msdn/blank.gif Binary files differnew file mode 100755 index 00000000..c23b58ca --- /dev/null +++ b/webdoc/xtree/images/msdn/blank.gif diff --git a/webdoc/xtree/images/msdn/menu_bar.gif b/webdoc/xtree/images/msdn/menu_bar.gif Binary files differnew file mode 100644 index 00000000..f9b3f272 --- /dev/null +++ b/webdoc/xtree/images/msdn/menu_bar.gif diff --git a/webdoc/xtree/images/msdn/menu_corner.gif b/webdoc/xtree/images/msdn/menu_corner.gif Binary files differnew file mode 100644 index 00000000..29f21fd2 --- /dev/null +++ b/webdoc/xtree/images/msdn/menu_corner.gif diff --git a/webdoc/xtree/images/msdn/menu_corner_minus.gif b/webdoc/xtree/images/msdn/menu_corner_minus.gif Binary files differnew file mode 100644 index 00000000..0fae6aca --- /dev/null +++ b/webdoc/xtree/images/msdn/menu_corner_minus.gif diff --git a/webdoc/xtree/images/msdn/menu_corner_plus.gif b/webdoc/xtree/images/msdn/menu_corner_plus.gif Binary files differnew file mode 100644 index 00000000..092e97e1 --- /dev/null +++ b/webdoc/xtree/images/msdn/menu_corner_plus.gif diff --git a/webdoc/xtree/images/msdn/menu_tee.gif b/webdoc/xtree/images/msdn/menu_tee.gif Binary files differnew file mode 100644 index 00000000..9e02eb26 --- /dev/null +++ b/webdoc/xtree/images/msdn/menu_tee.gif diff --git a/webdoc/xtree/images/msdn/menu_tee_minus.gif b/webdoc/xtree/images/msdn/menu_tee_minus.gif Binary files differnew file mode 100644 index 00000000..3f191949 --- /dev/null +++ b/webdoc/xtree/images/msdn/menu_tee_minus.gif diff --git a/webdoc/xtree/images/msdn/menu_tee_plus.gif b/webdoc/xtree/images/msdn/menu_tee_plus.gif Binary files differnew file mode 100644 index 00000000..7a7af256 --- /dev/null +++ b/webdoc/xtree/images/msdn/menu_tee_plus.gif diff --git a/webdoc/xtree/images/msdn2/I.gif b/webdoc/xtree/images/msdn2/I.gif Binary files differnew file mode 100644 index 00000000..4784a029 --- /dev/null +++ b/webdoc/xtree/images/msdn2/I.gif diff --git a/webdoc/xtree/images/msdn2/L.gif b/webdoc/xtree/images/msdn2/L.gif Binary files differnew file mode 100644 index 00000000..29f21fd2 --- /dev/null +++ b/webdoc/xtree/images/msdn2/L.gif diff --git a/webdoc/xtree/images/msdn2/Lminus.gif b/webdoc/xtree/images/msdn2/Lminus.gif Binary files differnew file mode 100644 index 00000000..0fae6aca --- /dev/null +++ b/webdoc/xtree/images/msdn2/Lminus.gif diff --git a/webdoc/xtree/images/msdn2/Lplus.gif b/webdoc/xtree/images/msdn2/Lplus.gif Binary files differnew file mode 100644 index 00000000..092e97e1 --- /dev/null +++ b/webdoc/xtree/images/msdn2/Lplus.gif diff --git a/webdoc/xtree/images/msdn2/T.gif b/webdoc/xtree/images/msdn2/T.gif Binary files differnew file mode 100644 index 00000000..9e02eb26 --- /dev/null +++ b/webdoc/xtree/images/msdn2/T.gif diff --git a/webdoc/xtree/images/msdn2/Tminus.gif b/webdoc/xtree/images/msdn2/Tminus.gif Binary files differnew file mode 100644 index 00000000..3f191949 --- /dev/null +++ b/webdoc/xtree/images/msdn2/Tminus.gif diff --git a/webdoc/xtree/images/msdn2/Tplus.gif b/webdoc/xtree/images/msdn2/Tplus.gif Binary files differnew file mode 100644 index 00000000..7a7af256 --- /dev/null +++ b/webdoc/xtree/images/msdn2/Tplus.gif diff --git a/webdoc/xtree/images/msdn2/blank.gif b/webdoc/xtree/images/msdn2/blank.gif Binary files differnew file mode 100755 index 00000000..c23b58ca --- /dev/null +++ b/webdoc/xtree/images/msdn2/blank.gif diff --git a/webdoc/xtree/images/openfoldericon.png b/webdoc/xtree/images/openfoldericon.png Binary files differnew file mode 100644 index 00000000..15fcd567 --- /dev/null +++ b/webdoc/xtree/images/openfoldericon.png diff --git a/webdoc/xtree/images/xp/I.png b/webdoc/xtree/images/xp/I.png Binary files differnew file mode 100644 index 00000000..e8512fb9 --- /dev/null +++ b/webdoc/xtree/images/xp/I.png diff --git a/webdoc/xtree/images/xp/L.png b/webdoc/xtree/images/xp/L.png Binary files differnew file mode 100644 index 00000000..eb334eda --- /dev/null +++ b/webdoc/xtree/images/xp/L.png diff --git a/webdoc/xtree/images/xp/Lminus.png b/webdoc/xtree/images/xp/Lminus.png Binary files differnew file mode 100644 index 00000000..bba1a318 --- /dev/null +++ b/webdoc/xtree/images/xp/Lminus.png diff --git a/webdoc/xtree/images/xp/Lplus.png b/webdoc/xtree/images/xp/Lplus.png Binary files differnew file mode 100644 index 00000000..727889b2 --- /dev/null +++ b/webdoc/xtree/images/xp/Lplus.png diff --git a/webdoc/xtree/images/xp/T.png b/webdoc/xtree/images/xp/T.png Binary files differnew file mode 100644 index 00000000..30173254 --- /dev/null +++ b/webdoc/xtree/images/xp/T.png diff --git a/webdoc/xtree/images/xp/Tminus.png b/webdoc/xtree/images/xp/Tminus.png Binary files differnew file mode 100644 index 00000000..ca8745a3 --- /dev/null +++ b/webdoc/xtree/images/xp/Tminus.png diff --git a/webdoc/xtree/images/xp/Tplus.png b/webdoc/xtree/images/xp/Tplus.png Binary files differnew file mode 100644 index 00000000..64bc9daf --- /dev/null +++ b/webdoc/xtree/images/xp/Tplus.png diff --git a/webdoc/xtree/images/xp/file.png b/webdoc/xtree/images/xp/file.png Binary files differnew file mode 100644 index 00000000..a723c74f --- /dev/null +++ b/webdoc/xtree/images/xp/file.png diff --git a/webdoc/xtree/images/xp/folder.png b/webdoc/xtree/images/xp/folder.png Binary files differnew file mode 100644 index 00000000..7b6835d0 --- /dev/null +++ b/webdoc/xtree/images/xp/folder.png diff --git a/webdoc/xtree/images/xp/openfolder.png b/webdoc/xtree/images/xp/openfolder.png Binary files differnew file mode 100644 index 00000000..c8292f43 --- /dev/null +++ b/webdoc/xtree/images/xp/openfolder.png diff --git a/webdoc/xtree/xloadtree.js b/webdoc/xtree/xloadtree.js new file mode 100644 index 00000000..6bbd9fd1 --- /dev/null +++ b/webdoc/xtree/xloadtree.js @@ -0,0 +1,276 @@ +/*----------------------------------------------------------------------------\
+| XLoadTree 1.11 |
+|-----------------------------------------------------------------------------|
+| Created by Erik Arvidsson |
+| (http://webfx.eae.net/contact.html#erik) |
+| For WebFX (http://webfx.eae.net/) |
+|-----------------------------------------------------------------------------|
+| An extension to xTree that allows sub trees to be loaded at runtime by |
+| reading XML files from the server. Works with IE5+ and Mozilla 1.0+ |
+|-----------------------------------------------------------------------------|
+| Copyright (c) 1999 - 2002 Erik Arvidsson |
+|-----------------------------------------------------------------------------|
+| This software is provided "as is", without warranty of any kind, express or |
+| implied, including but not limited to the warranties of merchantability, |
+| fitness for a particular purpose and noninfringement. In no event shall the |
+| authors or copyright holders be liable for any claim, damages or other |
+| liability, whether in an action of contract, tort or otherwise, arising |
+| from, out of or in connection with the software or the use or other |
+| dealings in the software. |
+| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
+| This software is available under the three different licenses mentioned |
+| below. To use this software you must chose, and qualify, for one of those. |
+| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
+| The WebFX Non-Commercial License http://webfx.eae.net/license.html |
+| Permits anyone the right to use the software in a non-commercial context |
+| free of charge. |
+| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
+| The WebFX Commercial license http://webfx.eae.net/commercial.html |
+| Permits the license holder the right to use the software in a commercial |
+| context. Such license must be specifically obtained, however it's valid for |
+| any number of implementations of the licensed software. |
+| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
+| GPL - The GNU General Public License http://www.gnu.org/licenses/gpl.txt |
+| Permits anyone the right to use and modify the software without limitations |
+| as long as proper credits are given and the original and modified source |
+| code are included. Requires that the final product, software derivate from |
+| the original source or any software utilizing a GPL component, such as |
+| this, is also licensed under the GPL license. |
+|-----------------------------------------------------------------------------|
+| 2001-09-27 | Original Version Posted. |
+| 2002-01-19 | Added some simple error handling and string templates for |
+| | reporting the errors. |
+| 2002-01-28 | Fixed loading issues in IE50 and IE55 that made the tree load |
+| | twice. |
+| 2002-10-10 | (1.1) Added reload method that reloads the XML file from the |
+| | server. |
+/ 2003-05-06 | Added support for target attribute |
+|-----------------------------------------------------------------------------|
+| Dependencies: xtree.js - original xtree library |
+| xtree.css - simple css styling of xtree |
+| xmlextras.js - provides xml http objects and xml document |
+| objects |
+|-----------------------------------------------------------------------------|
+| Created 2001-09-27 | All changes are in the log above. | Updated 2003-05-06 |
+\----------------------------------------------------------------------------*/
+
+
+webFXTreeConfig.loadingText = "Loading...";
+webFXTreeConfig.loadErrorTextTemplate = "Error loading \"%1%\"";
+webFXTreeConfig.emptyErrorTextTemplate = "Error \"%1%\" does not contain any tree items";
+
+/*
+ * WebFXLoadTree class
+ */
+
+function WebFXLoadTree(sText, sXmlSrc, sAction, sBehavior, sIcon, sOpenIcon) {
+ // call super
+ this.WebFXTree = WebFXTree;
+ this.WebFXTree(sText, sAction, sBehavior, sIcon, sOpenIcon);
+
+ // setup default property values
+ this.src = sXmlSrc;
+ this.loading = false;
+ this.loaded = false;
+ this.errorText = "";
+
+ // check start state and load if open
+ if (this.open)
+ _startLoadXmlTree(this.src, this);
+ else {
+ // and create loading item if not
+ this._loadingItem = new WebFXTreeItem(webFXTreeConfig.loadingText);
+ this.add(this._loadingItem);
+ }
+}
+
+WebFXLoadTree.prototype = new WebFXTree;
+
+// override the expand method to load the xml file
+WebFXLoadTree.prototype._webfxtree_expand = WebFXTree.prototype.expand;
+WebFXLoadTree.prototype.expand = function() {
+ if (!this.loaded && !this.loading) {
+ // load
+ _startLoadXmlTree(this.src, this);
+ }
+ this._webfxtree_expand();
+};
+
+/*
+ * WebFXLoadTreeItem class
+ */
+
+function WebFXLoadTreeItem(sText, sXmlSrc, sAction, eParent, sIcon, sOpenIcon) {
+ // call super
+ this.WebFXTreeItem = WebFXTreeItem;
+ this.WebFXTreeItem(sText, sAction, eParent, sIcon, sOpenIcon);
+
+ // setup default property values
+ this.src = sXmlSrc;
+ this.loading = false;
+ this.loaded = false;
+ this.errorText = "";
+
+ // check start state and load if open
+ if (this.open)
+ _startLoadXmlTree(this.src, this);
+ else {
+ // and create loading item if not
+ this._loadingItem = new WebFXTreeItem(webFXTreeConfig.loadingText);
+ this.add(this._loadingItem);
+ }
+}
+
+WebFXLoadTreeItem.prototype = new WebFXTreeItem;
+
+// override the expand method to load the xml file
+WebFXLoadTreeItem.prototype._webfxtreeitem_expand = WebFXTreeItem.prototype.expand;
+WebFXLoadTreeItem.prototype.expand = function() {
+ if (!this.loaded && !this.loading) {
+ // load
+ _startLoadXmlTree(this.src, this);
+ }
+ this._webfxtreeitem_expand();
+};
+
+// reloads the src file if already loaded
+WebFXLoadTree.prototype.reload =
+WebFXLoadTreeItem.prototype.reload = function () {
+ // if loading do nothing
+ if (this.loaded) {
+ var open = this.open;
+ // remove
+ while (this.childNodes.length > 0)
+ this.childNodes[this.childNodes.length - 1].remove();
+
+ this.loaded = false;
+
+ this._loadingItem = new WebFXTreeItem(webFXTreeConfig.loadingText);
+ this.add(this._loadingItem);
+
+ if (open)
+ this.expand();
+ }
+ else if (this.open && !this.loading)
+ _startLoadXmlTree(this.src, this);
+};
+
+/*
+ * Helper functions
+ */
+
+// creates the xmlhttp object and starts the load of the xml document
+function _startLoadXmlTree(sSrc, jsNode) {
+ if (jsNode.loading || jsNode.loaded)
+ return;
+ jsNode.loading = true;
+ var xmlHttp = XmlHttp.create();
+ xmlHttp.open("GET", sSrc, true); // async
+ xmlHttp.onreadystatechange = function () {
+ if (xmlHttp.readyState == 4) {
+ _xmlFileLoaded(xmlHttp.responseXML, jsNode);
+ }
+ };
+ // call in new thread to allow ui to update
+ window.setTimeout(function () {
+ xmlHttp.send(null);
+ }, 10);
+}
+
+
+// Converts an xml tree to a js tree. See article about xml tree format
+function _xmlTreeToJsTree(oNode) {
+ // retreive attributes
+ var text = oNode.getAttribute("text");
+ var action = oNode.getAttribute("action");
+ var parent = null;
+ var icon = oNode.getAttribute("icon");
+ var openIcon = oNode.getAttribute("openIcon");
+ var src = oNode.getAttribute("src");
+ var target = oNode.getAttribute("target");
+ // create jsNode
+ var jsNode;
+ if (src != null && src != "")
+ jsNode = new WebFXLoadTreeItem(text, src, action, parent, icon, openIcon);
+ else
+ jsNode = new WebFXTreeItem(text, action, parent, icon, openIcon);
+
+ if (target != "")
+ jsNode.target = target;
+
+ // go through childNOdes
+ var cs = oNode.childNodes;
+ var l = cs.length;
+ for (var i = 0; i < l; i++) {
+ if (cs[i].tagName == "tree")
+ jsNode.add( _xmlTreeToJsTree(cs[i]), true );
+ }
+
+ return jsNode;
+}
+
+// Inserts an xml document as a subtree to the provided node
+function _xmlFileLoaded(oXmlDoc, jsParentNode) {
+ if (jsParentNode.loaded)
+ return;
+
+ var bIndent = false;
+ var bAnyChildren = false;
+ jsParentNode.loaded = true;
+ jsParentNode.loading = false;
+
+ // check that the load of the xml file went well
+ if( oXmlDoc == null || oXmlDoc.documentElement == null) {
+ alert(oXmlDoc.xml);
+ jsParentNode.errorText = parseTemplateString(webFXTreeConfig.loadErrorTextTemplate,
+ jsParentNode.src);
+ }
+ else {
+ // there is one extra level of tree elements
+ var root = oXmlDoc.documentElement;
+
+ // loop through all tree children
+ var cs = root.childNodes;
+ var l = cs.length;
+ for (var i = 0; i < l; i++) {
+ if (cs[i].tagName == "tree") {
+ bAnyChildren = true;
+ bIndent = true;
+ jsParentNode.add( _xmlTreeToJsTree(cs[i]), true);
+ }
+ }
+
+ // if no children we got an error
+ if (!bAnyChildren)
+ jsParentNode.errorText = parseTemplateString(webFXTreeConfig.emptyErrorTextTemplate,
+ jsParentNode.src);
+ }
+
+ // remove dummy
+ if (jsParentNode._loadingItem != null) {
+ jsParentNode._loadingItem.remove();
+ bIndent = true;
+ }
+
+ if (bIndent) {
+ // indent now that all items are added
+ jsParentNode.indent();
+ }
+
+ // show error in status bar
+ if (jsParentNode.errorText != "")
+ window.status = jsParentNode.errorText;
+}
+
+// parses a string and replaces %n% with argument nr n
+function parseTemplateString(sTemplate) {
+ var args = arguments;
+ var s = sTemplate;
+
+ s = s.replace(/\%\%/g, "%");
+
+ for (var i = 1; i < args.length; i++)
+ s = s.replace( new RegExp("\%" + i + "\%", "g"), args[i] )
+
+ return s;
+}
\ No newline at end of file diff --git a/webdoc/xtree/xmlextras.js b/webdoc/xtree/xmlextras.js new file mode 100644 index 00000000..5b56dbe0 --- /dev/null +++ b/webdoc/xtree/xmlextras.js @@ -0,0 +1,147 @@ +//<script>
+//////////////////
+// Helper Stuff //
+//////////////////
+
+// used to find the Automation server name
+function getDomDocumentPrefix() {
+ if (getDomDocumentPrefix.prefix)
+ return getDomDocumentPrefix.prefix;
+
+ var prefixes = ["MSXML2", "Microsoft", "MSXML", "MSXML3"];
+ var o;
+ for (var i = 0; i < prefixes.length; i++) {
+ try {
+ // try to create the objects
+ o = new ActiveXObject(prefixes[i] + ".DomDocument");
+ return getDomDocumentPrefix.prefix = prefixes[i];
+ }
+ catch (ex) {};
+ }
+
+ throw new Error("Could not find an installed XML parser");
+}
+
+function getXmlHttpPrefix() {
+ if (getXmlHttpPrefix.prefix)
+ return getXmlHttpPrefix.prefix;
+
+ var prefixes = ["MSXML2", "Microsoft", "MSXML", "MSXML3"];
+ var o;
+ for (var i = 0; i < prefixes.length; i++) {
+ try {
+ // try to create the objects
+ o = new ActiveXObject(prefixes[i] + ".XmlHttp");
+ return getXmlHttpPrefix.prefix = prefixes[i];
+ }
+ catch (ex) {};
+ }
+
+ throw new Error("Could not find an installed XML parser");
+}
+
+//////////////////////////
+// Start the Real stuff //
+//////////////////////////
+
+
+// XmlHttp factory
+function XmlHttp() {}
+
+XmlHttp.create = function () {
+ try {
+ if (window.XMLHttpRequest) {
+ var req = new XMLHttpRequest();
+
+ // some versions of Moz do not support the readyState property
+ // and the onreadystate event so we patch it!
+ if (req.readyState == null) {
+ req.readyState = 1;
+ req.addEventListener("load", function () {
+ req.readyState = 4;
+ if (typeof req.onreadystatechange == "function")
+ req.onreadystatechange();
+ }, false);
+ }
+
+ return req;
+ }
+ if (window.ActiveXObject) {
+ return new ActiveXObject(getXmlHttpPrefix() + ".XmlHttp");
+ }
+ }
+ catch (ex) {}
+ // fell through
+ throw new Error("Your browser does not support XmlHttp objects");
+};
+
+// XmlDocument factory
+function XmlDocument() {}
+
+XmlDocument.create = function () {
+ try {
+ // DOM2
+ if (document.implementation && document.implementation.createDocument) {
+ var doc = document.implementation.createDocument("", "", null);
+
+ // some versions of Moz do not support the readyState property
+ // and the onreadystate event so we patch it!
+ if (doc.readyState == null) {
+ doc.readyState = 1;
+ doc.addEventListener("load", function () {
+ doc.readyState = 4;
+ if (typeof doc.onreadystatechange == "function")
+ doc.onreadystatechange();
+ }, false);
+ }
+
+ return doc;
+ }
+ if (window.ActiveXObject)
+ return new ActiveXObject(getDomDocumentPrefix() + ".DomDocument");
+ }
+ catch (ex) {}
+ throw new Error("Your browser does not support XmlDocument objects");
+};
+
+// Create the loadXML method and xml getter for Mozilla
+if (window.DOMParser &&
+ window.XMLSerializer &&
+ window.Node && Node.prototype && Node.prototype.__defineGetter__) {
+
+ // XMLDocument did not extend the Document interface in some versions
+ // of Mozilla. Extend both!
+ XMLDocument.prototype.loadXML =
+ Document.prototype.loadXML = function (s) {
+
+ // parse the string to a new doc
+ var doc2 = (new DOMParser()).parseFromString(s, "text/xml");
+
+ // remove all initial children
+ while (this.hasChildNodes())
+ this.removeChild(this.lastChild);
+
+ // insert and import nodes
+ for (var i = 0; i < doc2.childNodes.length; i++) {
+ this.appendChild(this.importNode(doc2.childNodes[i], true));
+ }
+ };
+
+
+ /*
+ * xml getter
+ *
+ * This serializes the DOM tree to an XML String
+ *
+ * Usage: var sXml = oNode.xml
+ *
+ */
+ // XMLDocument did not extend the Document interface in some versions
+ // of Mozilla. Extend both!
+ XMLDocument.prototype.__defineGetter__("xml", function () {
+ return (new XMLSerializer()).serializeToString(this);
+ });
+ Document.prototype.__defineGetter__("xml", function () {
+ return (new XMLSerializer()).serializeToString(this);
+ });
+}
\ No newline at end of file diff --git a/webdoc/xtree/xtree.css b/webdoc/xtree/xtree.css new file mode 100644 index 00000000..3630da97 --- /dev/null +++ b/webdoc/xtree/xtree.css @@ -0,0 +1,54 @@ +body { + font-family: verdana; + font-size: 70.5%; + font-weight: normal; + background-color: #f1f1f1; + color: Black; + margin: 0px 0px 0px 0px; + padding: 0px 0px 0px 0px; +} + +.webfx-tree-container { + margin: 0px; + padding: 0px; + white-space: nowrap; +} + +.webfx-tree-item { + padding: 0px; + margin: 0px; + color: WindowText; + white-space: nowrap; + height: 16px; +} + +.webfx-tree-item a, .webfx-tree-item a:active, .webfx-tree-item a:hover { + margin-left: 3px; + padding: 0px 2px 1px 2px; +} + +.webfx-tree-item a { + color: black; + text-decoration: none; +} + +.webfx-tree-item a:hover { + color: blue; + text-decoration: underline; +} + +.webfx-tree-item a:active { + background: highlight; + color: highlighttext; + text-decoration: none; +} + +.webfx-tree-item img { + vertical-align: middle; + border: 0px; +} + +.webfx-tree-icon { + width:0px; + visibility: hidden; +}
\ No newline at end of file diff --git a/webdoc/xtree/xtree.js b/webdoc/xtree/xtree.js new file mode 100644 index 00000000..19362e10 --- /dev/null +++ b/webdoc/xtree/xtree.js @@ -0,0 +1,541 @@ +/*----------------------------------------------------------------------------\ +| Cross Browser Tree Widget 1.17 | +|-----------------------------------------------------------------------------| +| Created by Emil A Eklund | +| (http://webfx.eae.net/contact.html#emil) | +| For WebFX (http://webfx.eae.net/) | +|-----------------------------------------------------------------------------| +| An object based tree widget, emulating the one found in microsoft windows, | +| with persistence using cookies. Works in IE 5+, Mozilla and konqueror 3. | +|-----------------------------------------------------------------------------| +| Copyright (c) 1999 - 2002 Emil A Eklund | +|-----------------------------------------------------------------------------| +| This software is provided "as is", without warranty of any kind, express or | +| implied, including but not limited to the warranties of merchantability, | +| fitness for a particular purpose and noninfringement. In no event shall the | +| authors or copyright holders be liable for any claim, damages or other | +| liability, whether in an action of contract, tort or otherwise, arising | +| from, out of or in connection with the software or the use or other | +| dealings in the software. | +| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | +| This software is available under the three different licenses mentioned | +| below. To use this software you must chose, and qualify, for one of those. | +| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | +| The WebFX Non-Commercial License http://webfx.eae.net/license.html | +| Permits anyone the right to use the software in a non-commercial context | +| free of charge. | +| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | +| The WebFX Commercial license http://webfx.eae.net/commercial.html | +| Permits the license holder the right to use the software in a commercial | +| context. Such license must be specifically obtained, however it's valid for | +| any number of implementations of the licensed software. | +| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | +| GPL - The GNU General Public License http://www.gnu.org/licenses/gpl.txt | +| Permits anyone the right to use and modify the software without limitations | +| as long as proper credits are given and the original and modified source | +| code are included. Requires that the final product, software derivate from | +| the original source or any software utilizing a GPL component, such as | +| this, is also licensed under the GPL license. | +|-----------------------------------------------------------------------------| +| Dependencies: xtree.css (To set up the CSS of the tree classes) | +|-----------------------------------------------------------------------------| +| 2001-01-10 | Original Version Posted. | +| 2001-03-18 | Added getSelected and get/setBehavior that can make it behave | +| | more like windows explorer, check usage for more information. | +| 2001-09-23 | Version 1.1 - New features included keyboard navigation (ie) | +| | and the ability to add and remove nodes dynamically and some | +| | other small tweaks and fixes. | +| 2002-01-27 | Version 1.11 - Bug fixes and improved mozilla support. | +| 2002-06-11 | Version 1.12 - Fixed a bug that prevented the indentation line | +| | from updating correctly under some circumstances. This bug | +| | happened when removing the last item in a subtree and items in | +| | siblings to the remove subtree where not correctly updated. | +| 2002-06-13 | Fixed a few minor bugs cased by the 1.12 bug-fix. | +| 2002-08-20 | Added usePersistence flag to allow disable of cookies. | +| 2002-10-23 | (1.14) Fixed a plus icon issue | +| 2002-10-29 | (1.15) Last changes broke more than they fixed. This version | +| | is based on 1.13 and fixes the bugs 1.14 fixed withou breaking | +| | lots of other things. | +| 2003-02-15 | The selected node can now be made visible even when the tree | +| | control loses focus. It uses a new class declaration in the | +| | css file '.webfx-tree-item a.selected-inactive', by default it | +| | puts a light-gray rectangle around the selected node. | +| 2003-03-16 | Adding target support after lots of lobbying... | +|-----------------------------------------------------------------------------| +| Created 2000-12-11 | All changes are in the log above. | Updated 2003-03-16 | +\----------------------------------------------------------------------------*/ + +var webFXTreeConfig = { + rootIcon : 'xtree/images/foldericon.png', + openRootIcon : 'xtree/images/openfoldericon.png', + folderIcon : 'xtree/images/foldericon.png', + openFolderIcon : 'xtree/images/openfoldericon.png', + fileIcon : 'xtree/images/file.png', + iIcon : 'xtree/images/I.png', + lIcon : 'xtree/images/L.png', + lMinusIcon : 'xtree/images/Lminus.png', + lPlusIcon : 'xtree/images/Lplus.png', + tIcon : 'xtree/images/T.png', + tMinusIcon : 'xtree/images/Tminus.png', + tPlusIcon : 'xtree/images/Tplus.png', + blankIcon : 'xtree/images/blank.png', + defaultText : 'Tree Item', + defaultAction : 'javascript:void(0);', + defaultBehavior : 'classic', + usePersistence : true +}; + +var webFXTreeHandler = { + idCounter : 0, + idPrefix : "webfx-tree-object-", + all : {}, + behavior : null, + selected : null, + onSelect : null, /* should be part of tree, not handler */ + getId : function() { return this.idPrefix + this.idCounter++; }, + toggle : function (oItem) { this.all[oItem.id.replace('-plus','')].toggle(); }, + select : function (oItem) { this.all[oItem.id.replace('-icon','')].select(); }, + focus : function (oItem) { this.all[oItem.id.replace('-anchor','')].focus(); }, + blur : function (oItem) { this.all[oItem.id.replace('-anchor','')].blur(); }, + keydown : function (oItem, e) { return this.all[oItem.id].keydown(e.keyCode); }, + cookies : new WebFXCookie(), + insertHTMLBeforeEnd : function (oElement, sHTML) { + if (oElement.insertAdjacentHTML != null) { + oElement.insertAdjacentHTML("BeforeEnd", sHTML) + return; + } + var df; // DocumentFragment + var r = oElement.ownerDocument.createRange(); + r.selectNodeContents(oElement); + r.collapse(false); + df = r.createContextualFragment(sHTML); + oElement.appendChild(df); + } +}; + +/* + * WebFXCookie class + */ + +function WebFXCookie() { + if (document.cookie.length) { this.cookies = ' ' + document.cookie; } +} + +WebFXCookie.prototype.setCookie = function (key, value) { + document.cookie = key + "=" + escape(value); +} + +WebFXCookie.prototype.getCookie = function (key) { + if (this.cookies) { + var start = this.cookies.indexOf(' ' + key + '='); + if (start == -1) { return null; } + var end = this.cookies.indexOf(";", start); + if (end == -1) { end = this.cookies.length; } + end -= start; + var cookie = this.cookies.substr(start,end); + return unescape(cookie.substr(cookie.indexOf('=') + 1, cookie.length - cookie.indexOf('=') + 1)); + } + else { return null; } +} + +/* + * WebFXTreeAbstractNode class + */ + +function WebFXTreeAbstractNode(sText, sAction) { + this.childNodes = []; + this.id = webFXTreeHandler.getId(); + this.text = sText || webFXTreeConfig.defaultText; + this.action = sAction || webFXTreeConfig.defaultAction; + this._last = false; + webFXTreeHandler.all[this.id] = this; +} + +/* + * To speed thing up if you're adding multiple nodes at once (after load) + * use the bNoIdent parameter to prevent automatic re-indentation and call + * the obj.ident() method manually once all nodes has been added. + */ + +WebFXTreeAbstractNode.prototype.add = function (node, bNoIdent) { + node.parentNode = this; + this.childNodes[this.childNodes.length] = node; + var root = this; + if (this.childNodes.length >= 2) { + this.childNodes[this.childNodes.length - 2]._last = false; + } + while (root.parentNode) { root = root.parentNode; } + if (root.rendered) { + if (this.childNodes.length >= 2) { + document.getElementById(this.childNodes[this.childNodes.length - 2].id + '-plus').src = ((this.childNodes[this.childNodes.length -2].folder)?((this.childNodes[this.childNodes.length -2].open)?webFXTreeConfig.tMinusIcon:webFXTreeConfig.tPlusIcon):webFXTreeConfig.tIcon); + this.childNodes[this.childNodes.length - 2].plusIcon = webFXTreeConfig.tPlusIcon; + this.childNodes[this.childNodes.length - 2].minusIcon = webFXTreeConfig.tMinusIcon; + this.childNodes[this.childNodes.length - 2]._last = false; + } + this._last = true; + var foo = this; + while (foo.parentNode) { + for (var i = 0; i < foo.parentNode.childNodes.length; i++) { + if (foo.id == foo.parentNode.childNodes[i].id) { break; } + } + if (i == foo.parentNode.childNodes.length - 1) { foo.parentNode._last = true; } + else { foo.parentNode._last = false; } + foo = foo.parentNode; + } + webFXTreeHandler.insertHTMLBeforeEnd(document.getElementById(this.id + '-cont'), node.toString()); + if ((!this.folder) && (!this.openIcon)) { + this.icon = webFXTreeConfig.folderIcon; + this.openIcon = webFXTreeConfig.openFolderIcon; + } + if (!this.folder) { this.folder = true; this.collapse(true); } + if (!bNoIdent) { this.indent(); } + } + return node; +} + +WebFXTreeAbstractNode.prototype.toggle = function() { + if (this.folder) { + if (this.open) { this.collapse(); } + else { this.expand(); } +} } + +WebFXTreeAbstractNode.prototype.select = function() { + document.getElementById(this.id + '-anchor').focus(); +} + +WebFXTreeAbstractNode.prototype.deSelect = function() { + document.getElementById(this.id + '-anchor').className = ''; + webFXTreeHandler.selected = null; +} + +WebFXTreeAbstractNode.prototype.focus = function() { + if ((webFXTreeHandler.selected) && (webFXTreeHandler.selected != this)) { webFXTreeHandler.selected.deSelect(); } + webFXTreeHandler.selected = this; + if ((this.openIcon) && (webFXTreeHandler.behavior != 'classic')) { document.getElementById(this.id + '-icon').src = this.openIcon; } + document.getElementById(this.id + '-anchor').className = 'selected'; + document.getElementById(this.id + '-anchor').focus(); + if (webFXTreeHandler.onSelect) { webFXTreeHandler.onSelect(this); } +} + +WebFXTreeAbstractNode.prototype.blur = function() { + if ((this.openIcon) && (webFXTreeHandler.behavior != 'classic')) { document.getElementById(this.id + '-icon').src = this.icon; } + document.getElementById(this.id + '-anchor').className = 'selected-inactive'; +} + +WebFXTreeAbstractNode.prototype.doExpand = function() { + if (webFXTreeHandler.behavior == 'classic') { document.getElementById(this.id + '-icon').src = this.openIcon; } + if (this.childNodes.length) { document.getElementById(this.id + '-cont').style.display = 'block'; } + this.open = true; + if (webFXTreeConfig.usePersistence) { + webFXTreeHandler.cookies.setCookie(this.id.substr(18,this.id.length - 18), '1'); +} } + +WebFXTreeAbstractNode.prototype.doCollapse = function() { + if (webFXTreeHandler.behavior == 'classic') { document.getElementById(this.id + '-icon').src = this.icon; } + if (this.childNodes.length) { document.getElementById(this.id + '-cont').style.display = 'none'; } + this.open = false; + if (webFXTreeConfig.usePersistence) { + webFXTreeHandler.cookies.setCookie(this.id.substr(18,this.id.length - 18), '0'); +} } + +WebFXTreeAbstractNode.prototype.expandAll = function() { + this.expandChildren(); + if ((this.folder) && (!this.open)) { this.expand(); } +} + +WebFXTreeAbstractNode.prototype.expandChildren = function() { + for (var i = 0; i < this.childNodes.length; i++) { + this.childNodes[i].expandAll(); +} } + +WebFXTreeAbstractNode.prototype.collapseAll = function() { + this.collapseChildren(); + if ((this.folder) && (this.open)) { this.collapse(true); } +} + +WebFXTreeAbstractNode.prototype.collapseChildren = function() { + for (var i = 0; i < this.childNodes.length; i++) { + this.childNodes[i].collapseAll(); +} } + +WebFXTreeAbstractNode.prototype.indent = function(lvl, del, last, level, nodesLeft) { + /* + * Since we only want to modify items one level below ourself, + * and since the rightmost indentation position is occupied by + * the plus icon we set this to -2 + */ + if (lvl == null) { lvl = -2; } + var state = 0; + for (var i = this.childNodes.length - 1; i >= 0 ; i--) { + state = this.childNodes[i].indent(lvl + 1, del, last, level); + if (state) { return; } + } + if (del) { + if ((level >= this._level) && (document.getElementById(this.id + '-plus'))) { + if (this.folder) { + document.getElementById(this.id + '-plus').src = (this.open)?webFXTreeConfig.lMinusIcon:webFXTreeConfig.lPlusIcon; + this.plusIcon = webFXTreeConfig.lPlusIcon; + this.minusIcon = webFXTreeConfig.lMinusIcon; + } + else if (nodesLeft) { document.getElementById(this.id + '-plus').src = webFXTreeConfig.lIcon; } + return 1; + } } + var foo = document.getElementById(this.id + '-indent-' + lvl); + if (foo) { + if ((foo._last) || ((del) && (last))) { foo.src = webFXTreeConfig.blankIcon; } + else { foo.src = webFXTreeConfig.iIcon; } + } + return 0; +} + +/* + * WebFXTree class + */ + +function WebFXTree(sText, sAction, sBehavior, sIcon, sOpenIcon) { + this.base = WebFXTreeAbstractNode; + this.base(sText, sAction); + this.icon = sIcon || webFXTreeConfig.rootIcon; + this.openIcon = sOpenIcon || webFXTreeConfig.openRootIcon; + /* Defaults to open */ + if (webFXTreeConfig.usePersistence) { + this.open = (webFXTreeHandler.cookies.getCookie(this.id.substr(18,this.id.length - 18)) == '0')?false:true; + } else { this.open = true; } + this.folder = true; + this.rendered = false; + this.onSelect = null; + if (!webFXTreeHandler.behavior) { webFXTreeHandler.behavior = sBehavior || webFXTreeConfig.defaultBehavior; } +} + +WebFXTree.prototype = new WebFXTreeAbstractNode; + +WebFXTree.prototype.setBehavior = function (sBehavior) { + webFXTreeHandler.behavior = sBehavior; +}; + +WebFXTree.prototype.getBehavior = function (sBehavior) { + return webFXTreeHandler.behavior; +}; + +WebFXTree.prototype.getSelected = function() { + if (webFXTreeHandler.selected) { return webFXTreeHandler.selected; } + else { return null; } +} + +WebFXTree.prototype.remove = function() { } + +WebFXTree.prototype.expand = function() { + this.doExpand(); +} + +WebFXTree.prototype.collapse = function(b) { + if (!b) { this.focus(); } + this.doCollapse(); +} + +WebFXTree.prototype.getFirst = function() { + return null; +} + +WebFXTree.prototype.getLast = function() { + return null; +} + +WebFXTree.prototype.getNextSibling = function() { + return null; +} + +WebFXTree.prototype.getPreviousSibling = function() { + return null; +} + +WebFXTree.prototype.keydown = function(key) { + if (key == 39) { + if (!this.open) { this.expand(); } + else if (this.childNodes.length) { this.childNodes[0].select(); } + return false; + } + if (key == 37) { this.collapse(); return false; } + if ((key == 40) && (this.open) && (this.childNodes.length)) { this.childNodes[0].select(); return false; } + return true; +} + +WebFXTree.prototype.toString = function() { + var str = "<div id=\"" + this.id + "\" ondblclick=\"webFXTreeHandler.toggle(this);\" class=\"webfx-tree-item\" onkeydown=\"return webFXTreeHandler.keydown(this, event)\">" + + "<img id=\"" + this.id + "-icon\" class=\"webfx-tree-icon\" src=\"" + ((webFXTreeHandler.behavior == 'classic' && this.open)?this.openIcon:this.icon) + "\" onclick=\"webFXTreeHandler.select(this);\">" + + "<a href=\"" + this.action + "\" id=\"" + this.id + "-anchor\" onfocus=\"webFXTreeHandler.focus(this);\" onblur=\"webFXTreeHandler.blur(this);\"" + + (this.target ? " target=\"" + this.target + "\"" : "") + + ">" + this.text + "</a></div>" + + "<div id=\"" + this.id + "-cont\" class=\"webfx-tree-container\" style=\"display: " + ((this.open)?'block':'none') + ";\">"; + var sb = []; + for (var i = 0; i < this.childNodes.length; i++) { + sb[i] = this.childNodes[i].toString(i, this.childNodes.length); + } + this.rendered = true; + return str + sb.join("") + "</div>"; +}; + +/* + * WebFXTreeItem class + */ + +function WebFXTreeItem(sText, sAction, eParent, sIcon, sOpenIcon) { + this.base = WebFXTreeAbstractNode; + this.base(sText, sAction); + /* Defaults to close */ + if (webFXTreeConfig.usePersistence) { + this.open = (webFXTreeHandler.cookies.getCookie(this.id.substr(18,this.id.length - 18)) == '1')?true:false; + } else { this.open = false; } + if (sIcon) { this.icon = sIcon; } + if (sOpenIcon) { this.openIcon = sOpenIcon; } + if (eParent) { eParent.add(this); } +} + +WebFXTreeItem.prototype = new WebFXTreeAbstractNode; + +WebFXTreeItem.prototype.remove = function() { + var iconSrc = document.getElementById(this.id + '-plus').src; + var parentNode = this.parentNode; + var prevSibling = this.getPreviousSibling(true); + var nextSibling = this.getNextSibling(true); + var folder = this.parentNode.folder; + var last = ((nextSibling) && (nextSibling.parentNode) && (nextSibling.parentNode.id == parentNode.id))?false:true; + this.getPreviousSibling().focus(); + this._remove(); + if (parentNode.childNodes.length == 0) { + document.getElementById(parentNode.id + '-cont').style.display = 'none'; + parentNode.doCollapse(); + parentNode.folder = false; + parentNode.open = false; + } + if (!nextSibling || last) { parentNode.indent(null, true, last, this._level, parentNode.childNodes.length); } + if ((prevSibling == parentNode) && !(parentNode.childNodes.length)) { + prevSibling.folder = false; + prevSibling.open = false; + iconSrc = document.getElementById(prevSibling.id + '-plus').src; + iconSrc = iconSrc.replace('minus', '').replace('plus', ''); + document.getElementById(prevSibling.id + '-plus').src = iconSrc; + document.getElementById(prevSibling.id + '-icon').src = webFXTreeConfig.fileIcon; + } + if (document.getElementById(prevSibling.id + '-plus')) { + if (parentNode == prevSibling.parentNode) { + iconSrc = iconSrc.replace('minus', '').replace('plus', ''); + document.getElementById(prevSibling.id + '-plus').src = iconSrc; +} } } + +WebFXTreeItem.prototype._remove = function() { + for (var i = this.childNodes.length - 1; i >= 0; i--) { + this.childNodes[i]._remove(); + } + for (var i = 0; i < this.parentNode.childNodes.length; i++) { + if (this == this.parentNode.childNodes[i]) { + for (var j = i; j < this.parentNode.childNodes.length; j++) { + this.parentNode.childNodes[j] = this.parentNode.childNodes[j+1]; + } + this.parentNode.childNodes.length -= 1; + if (i + 1 == this.parentNode.childNodes.length) { this.parentNode._last = true; } + break; + } } + webFXTreeHandler.all[this.id] = null; + var tmp = document.getElementById(this.id); + if (tmp) { tmp.parentNode.removeChild(tmp); } + tmp = document.getElementById(this.id + '-cont'); + if (tmp) { tmp.parentNode.removeChild(tmp); } +} + +WebFXTreeItem.prototype.expand = function() { + this.doExpand(); + document.getElementById(this.id + '-plus').src = this.minusIcon; +} + +WebFXTreeItem.prototype.collapse = function(b) { + if (!b) { this.focus(); } + this.doCollapse(); + document.getElementById(this.id + '-plus').src = this.plusIcon; +} + +WebFXTreeItem.prototype.getFirst = function() { + return this.childNodes[0]; +} + +WebFXTreeItem.prototype.getLast = function() { + if (this.childNodes[this.childNodes.length - 1].open) { return this.childNodes[this.childNodes.length - 1].getLast(); } + else { return this.childNodes[this.childNodes.length - 1]; } +} + +WebFXTreeItem.prototype.getNextSibling = function() { + for (var i = 0; i < this.parentNode.childNodes.length; i++) { + if (this == this.parentNode.childNodes[i]) { break; } + } + if (++i == this.parentNode.childNodes.length) { return this.parentNode.getNextSibling(); } + else { return this.parentNode.childNodes[i]; } +} + +WebFXTreeItem.prototype.getPreviousSibling = function(b) { + for (var i = 0; i < this.parentNode.childNodes.length; i++) { + if (this == this.parentNode.childNodes[i]) { break; } + } + if (i == 0) { return this.parentNode; } + else { + if ((this.parentNode.childNodes[--i].open) || (b && this.parentNode.childNodes[i].folder)) { return this.parentNode.childNodes[i].getLast(); } + else { return this.parentNode.childNodes[i]; } +} } + +WebFXTreeItem.prototype.keydown = function(key) { + if ((key == 39) && (this.folder)) { + if (!this.open) { this.expand(); } + else { this.getFirst().select(); } + return false; + } + else if (key == 37) { + if (this.open) { this.collapse(); } + else { this.parentNode.select(); } + return false; + } + else if (key == 40) { + if (this.open) { this.getFirst().select(); } + else { + var sib = this.getNextSibling(); + if (sib) { sib.select(); } + } + return false; + } + else if (key == 38) { this.getPreviousSibling().select(); return false; } + return true; +} + +WebFXTreeItem.prototype.toString = function (nItem, nItemCount) { + var foo = this.parentNode; + var indent = ''; + if (nItem + 1 == nItemCount) { this.parentNode._last = true; } + var i = 0; + while (foo.parentNode) { + foo = foo.parentNode; + indent = "<img id=\"" + this.id + "-indent-" + i + "\" src=\"" + ((foo._last)?webFXTreeConfig.blankIcon:webFXTreeConfig.iIcon) + "\">" + indent; + i++; + } + this._level = i; + if (this.childNodes.length) { this.folder = 1; } + else { this.open = false; } + if ((this.folder) || (webFXTreeHandler.behavior != 'classic')) { + if (!this.icon) { this.icon = webFXTreeConfig.folderIcon; } + if (!this.openIcon) { this.openIcon = webFXTreeConfig.openFolderIcon; } + } + else if (!this.icon) { this.icon = webFXTreeConfig.fileIcon; } + var label = this.text.replace(/</g, '<').replace(/>/g, '>'); + var str = "<div id=\"" + this.id + "\" ondblclick=\"webFXTreeHandler.toggle(this);\" class=\"webfx-tree-item\" onkeydown=\"return webFXTreeHandler.keydown(this, event)\">" + + indent + + "<img id=\"" + this.id + "-plus\" src=\"" + ((this.folder)?((this.open)?((this.parentNode._last)?webFXTreeConfig.lMinusIcon:webFXTreeConfig.tMinusIcon):((this.parentNode._last)?webFXTreeConfig.lPlusIcon:webFXTreeConfig.tPlusIcon)):((this.parentNode._last)?webFXTreeConfig.lIcon:webFXTreeConfig.tIcon)) + "\" onclick=\"webFXTreeHandler.toggle(this);\">" + + "<img id=\"" + this.id + "-icon\" class=\"webfx-tree-icon\" src=\"" + ((webFXTreeHandler.behavior == 'classic' && this.open)?this.openIcon:this.icon) + "\" onclick=\"webFXTreeHandler.select(this);\">" + + "<a href=\"" + this.action + "\" id=\"" + this.id + "-anchor\" onfocus=\"webFXTreeHandler.focus(this);\" onblur=\"webFXTreeHandler.blur(this);\"" + + (this.target ? " target=\"" + this.target + "\"" : "") + + ">" + label + "</a></div>" + + "<div id=\"" + this.id + "-cont\" class=\"webfx-tree-container\" style=\"display: " + ((this.open)?'block':'none') + ";\">"; + var sb = []; + for (var i = 0; i < this.childNodes.length; i++) { + sb[i] = this.childNodes[i].toString(i,this.childNodes.length); + } + this.plusIcon = ((this.parentNode._last)?webFXTreeConfig.lPlusIcon:webFXTreeConfig.tPlusIcon); + this.minusIcon = ((this.parentNode._last)?webFXTreeConfig.lMinusIcon:webFXTreeConfig.tMinusIcon); + return str + sb.join("") + "</div>"; +}
\ No newline at end of file |