PageSourceSearch

https://www.gsxy.cn/inc/tree.js

js gsxy.cn collected 2026-10-05 22:55:52 UTC 5,670 bytes, 131 lines download raw bytes

1// Title: Tigra Tree
2// Description: See the demo at url
3// URL: http://www.softcomplex.com/products/tigra_menu_tree/
4// Version: 1.0
5// Date: 07-20-2002 (mm-dd-yyyy)
6// Contact: [email protected] (specify product title in the subject)
7// Notes: Registration needed to use this script on your web site.
8// 	Registration for this version (1.0) is free of charge.
9//	Visit official site for details
10
11function tree (a_items, a_template) {
12	this.a_tpl      = a_template;
13	this.a_config   = a_items;
14	this.o_root     = this;
15	this.a_index    = [];
16	this.o_selected = null;
17	this.n_depth    = -1;
18	
19	var o_icone = new Image(),
20		o_iconl = new Image();
21	o_icone.src = a_template['icon_e'];
22	o_iconl.src = a_template['icon_l'];
23	a_template['im_e'] = o_icone;
24	a_template['im_l'] = o_iconl;
25	for (var i = 0; i < 64; i++)
26		if (a_template['icon_' + i]) {
27			var o_icon = new Image();
28			a_template['im_' + i] = o_icon;
29			o_icon.src = a_template['icon_' + i];
30		}
31	
32	this.toggle = function (n_id) {	var o_item = this.a_index[n_id]; o_item.open(o_item.b_opened) };
33	this.select = function (n_id) { return this.a_index[n_id].select(); };
34	this.mout   = function (n_id) { this.a_index[n_id].upstatus(true) };
35	this.mover  = function (n_id) { this.a_index[n_id].upstatus() };
36
37	this.a_children = [];
38	for (var i = 0; i < a_items.length; i++)
39		new tree_item(this, i);
40
41	this.n_id = trees.length;
42	trees[this.n_id] = this;
43	
44	for (var i = 0; i < this.a_children.length; i++) {
45		document.write(this.a_children[i].init());
46		this.a_children[i].open();
47	}
48}
49function tree_item (o_parent, n_order) {
50
51	this.n_depth  = o_parent.n_depth + 1;
52	this.a_config = o_parent.a_config[n_order + (this.n_depth ? 2 : 0)];
53	if (!this.a_config) return;
54
55	this.o_root    = o_parent.o_root;
56	this.o_parent  = o_parent;
57	this.n_order   = n_order;
58	this.b_opened  = !this.n_depth;
59
60	this.n_id = this.o_root.a_index.length;
61	this.o_root.a_index[this.n_id] = this;
62	o_parent.a_children[n_order] = this;
63
64	this.a_children = [];
65	for (var i = 0; i < this.a_config.length - 2; i++)
66		new tree_item(this, i);
67
68	this.get_icon = item_get_icon;
69	this.open     = item_open;
70	this.select   = item_select;
71	this.init     = item_init;
72	this.upstatus = item_upstatus;
73	this.is_last  = function () { return this.n_order == this.o_parent.a_children.length - 1 };
74}
75
76function item_open (b_close) {
77	var o_idiv = get_element('i_div' + this.n_id);
78	if (!o_idiv) return;
79	
80	if (!o_idiv.innerHTML) {
81		var a_children = [];
82		for (var i = 0; i < this.a_children.length; i++)
83			a_children[i]= this.a_children[i].init();
84		o_idiv.innerHTML = a_children.join('');
85	}
86	o_idiv.style.display = (b_close ? 'none' : 'block');
87	
88	this.b_opened = !b_close;
89	var o_jicon = document.images['j_img' + this.n_id],
90		o_iicon = document.images['i_img' + this.n_id];
91	if (o_jicon) o_jicon.src = this.get_icon(true);
92	if (o_iicon) o_iicon.src = this.get_icon();
93	this.upstatus();
94}
95
96function item_select (b_deselect) {
97	if (!b_deselect) {
98		var o_olditem = this.o_root.o_selected;
99		this.o_root.o_selected = this;
100		if (o_olditem) o_olditem.select(true);
101	}
102	var o_iicon = document.images['i_img' + this.n_id];
103	if (o_iicon) o_iicon.src = this.get_icon();
104	get_element('i_txt' + this.n_id).style.fontWeight = b_deselect ? 'normal' : 'bold';
105	
106	this.upstatus();
107	return Boolean(this.a_config[1]);
108}
109
110function item_upstatus (b_clear) {
111	window.setTimeout('window.status="' + (b_clear ? '' : this.a_config[0] + (this.a_config[1] ? ' ('+ this.a_config[1] + ')' : '')) + '"', 10);
112}
113
114function item_init () {
115	var a_offset = [],
116		o_current_item = this.o_parent;
117	for (var i = this.n_depth; i > 1; i--) {
118		a_offset[i] = '<img src="' + this.o_root.a_tpl[o_current_item.is_last() ? 'icon_e' : 'icon_l'] + '" border="0" align="absbottom">';
119		o_current_item = o_current_item.o_parent;
120	}
121	return '<table cellpadding="0" cellspacing="0" border="0"><tr><td nowrap>' + (this.n_depth ? a_offset.join('') + (this.a_children.length ? '<a href="javascript: trees[' + this.o_root.n_id + '].toggle(' + this.n_id + ')" onmouseover="trees[' + this.o_root.n_id + '].mover(' + this.n_id + ')" onmouseout="trees[' + this.o_root.n_id + '].mout(' + this.n_id + ')"><img src="' + this.get_icon(true) + '" border="0" align="absbottom" name="j_img' + this.n_id + '"></a>' : '<img src="' + this.get_icon(true) + '" border="0" align="absbottom">') : '') + '<a href="' + this.a_config[1] + '" target="' + this.o_root.a_tpl['target'] + '" onclick="return trees[' + this.o_root.n_id + '].select(' + this.n_id + ')" ondblclick="trees[' + this.o_root.n_id + '].toggle(' + this.n_id + ')" onmouseover="trees[' + this.o_root.n_id + '].mover(' + this.n_id + ')" onmouseout="trees[' + this.o_root.n_id + '].mout(' + this.n_id + ')" class="t' + this.o_root.n_id + 'i" id="i_txt' + this.n_id + '"><img src="' + this.get_icon() + '" border="0" align="absbottom" name="i_img' + this.n_id + '" class="t' + this.o_root.n_id + 'im">' + this.a_config[0] + '</a></td></tr></table>' + (this.a_children.length ? '<div id="i_div' + this.n_id + '" style="display:none"></div>' : '');
122}
123
124function item_get_icon (b_junction) {
125	return this.o_root.a_tpl['icon_' + ((this.n_depth ? 0 : 32) + (this.a_children.length ? 16 : 0) + (this.a_children.length && this.b_opened ? 8 : 0) + (!b_junction && this.o_root.o_selected == this ? 4 : 0) + (b_junction ? 2 : 0) + (b_junction && this.is_last() ? 1 : 0))];
126}
127
128var trees = [];
129get_element = document.all ?
130	function (s_id) { return document.all[s_id] } :
131	function (s_id) { return document.getElementById(s_id) };

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.