// (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com) // (C) Copyright 2003-2007 Jonathan Turkanis // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.) //--------------Event-handlers------------------------------------------------// function toggle(id) { get_tree().find(id).toggle(); } function blur_tree() { if ( window.event && window.event.srcElement && window.event.srcElement.blur && window.event.srcElement != document.body ) window.event.srcElement.blur(); else if (target_frame()) target_frame().window.focus(); } document.onclick = blur_tree; //--------------Netscape 4.x-specific-----------------------------------------// window.saved_width = window.outerWidth; function reload_tree() { if (window.outerWidth != window.saved_width) window.location.reload(); } if (window.Event && Event.RESIZE) { window.captureEvents(Event.RESIZE); window.onResize = reload_tree; } //--------------Functions for browser-sniffing--------------------------------// function major_version(app) { var index = navigator.userAgent.indexOf(app); if (index == -1) return -1; return parseInt(navigator.userAgent.charAt(index + app.length + 1)); } function dom_support() { if (dom_support.cache == null) dom_support.cache = dom_support_impl(); return dom_support.cache; } function dom_support_impl() { var version; if ( (version = major_version("Mozilla")) != -1 && navigator.userAgent.indexOf("compatible") == -1 ) return version > 4; if ((version = major_version("Opera")) != -1) return version > 6; if ((version = major_version("Konqueror")) != -1) return version > 2; if ((version = major_version("Links")) != -1) return false; return document.getElementById || document.all; } //--------------Utility functions---------------------------------------------// function target_frame() { return get_tree() ? top.frames[get_tree().target] : null; } function get_tree() { return document.tree_control; } function static_display() { return !dom_support() || get_tree().dump_html; } function elt_by_id(id) { return document.all ? document.all[id] : document.getElementById ? document.getElementById(id) : null; } function replace_query(url, query) { var pos; if ((pos = url.indexOf("?")) != -1) url = url.substring(0, pos); return url + "?" + query; } //--------------Functions for HTML-generation---------------------------------// function icon_char(state) { return state == tree_node.expanded ? "-" : state == tree_node.collapsed ? "+" : " "; } function html_list(id, display, margin) { return "
"; } function html_list_item(content) { return "\n
" + content + "
"; } function html_anchor(content, cl, href, target) { return "" + content + ""; } //--------------Definition of class tree_node---------------------------------// function tree_node__add(text_or_node, link_or_hide, hide) { if (this.state == tree_node.neutral) this.state = tree_node.collapsed; var k; if (text_or_node.length != null) { k = new tree_node(text_or_node, link_or_hide); k.hide_kids = hide != null ? hide : false; } else { k = text_or_node; k.hide_kids = link_or_hide != null ? link_or_hide : false; } k.mom = this; if (this.kids == null) this.kids = new Array(); this.kids[this.kids.length] = k; return k; } function tree_node__level() { var level; var node; for (node = this.mom, level = -1; node; node = node.mom, ++level) ; return level; } function tree_node__parent() { return this.mom; } function tree_node__print() { var icon = !static_display() ? "" + icon_char(this.state) + "  " : ""; var handler = !static_display() && this.kids ? "javascript:toggle(\"id" + this.id + "\")" : ""; var text = "" + this.text + "" var tree = get_tree(); var indent = tree.indent * this.level(); return html_list_item( "
" + ( !tree.dump_html ? this.kids ? html_anchor(icon, "tree-icon", handler) : icon : "" ) + ( tree.numbered ? "" + "" + this.id.substring(1) + "" : "" ) + "  " + ( this.link ? html_anchor( text, "tree-text", this.link, tree.target ) : text ) + "
" + this.print_kids() ); } function tree_node__print_kids(margin) { var result = ""; if (this.kids != null && (!static_display() || !this.hide_kids)) { if (margin == null) margin = get_tree().indent; result += html_list( "list" + this.id, this.state == tree_node.collapsed && !static_display() ? "none" : "", margin ); for (var z = 0; z < this.kids.length; ++z) { var k = this.kids[z]; k.id = this.id + "." + (z + 1); result += k.print(); } result += "
"; } return result; } function tree_node__toggle(expand) { if ( static_display() || this.kids == null || expand != null && expand == (this.state == tree_node.expanded) ) { return; } this.state = this.state == tree_node.expanded ? tree_node.collapsed : tree_node.expanded; elt_by_id("icon" + this.id).innerHTML = icon_char(this.state); elt_by_id("list" + this.id).style.display = this.state == tree_node.expanded ? "" : "none"; } function add_methods(obj) { obj.add = tree_node__add; obj.level = tree_node__level; obj.parent = tree_node__parent; obj.print = tree_node__print; obj.print_kids = tree_node__print_kids; obj.toggle = tree_node__toggle; } function tree_node(text, link) { // Member data this.text = text; this.link = link; this.mom = null; this.kids = null; this.id = null; this.state = 0; // Neutral. if (!add_methods.prototype) add_methods(this); } tree_node.neutral = 0; tree_node.expanded = 1; tree_node.collapsed = 2; if (tree_node.prototype) add_methods(tree_node.prototype); //--------------Definition of class tree_control------------------------------// function tree_control__add(text, link, hide) { return this.root.add(text, link, hide); } function tree_control__draw() { var tree = get_tree(); var dom = dom_support(); var element = dom ? elt_by_id('tree_control') : null; if (element || !dom || tree.drawn) { var html = tree.html(); if (tree.dump_html) { var pat = new RegExp("<", "g"); html = "
" + html.replace(pat, "<") + "
"; if (document.body.innerHTML) document.body.innerHTML = html; else document.write(html); } else if (dom) { element.innerHTML = html; } else { document.open(); document.write( "" + html + ( major_version("MSIE") == 3 ? "