author | Dan |
Thu, 12 Jul 2007 15:30:26 -0400 | |
changeset 68 | eb34257a6377 |
parent 21 | 663fcf528726 |
child 530 | 8d3c49b8dc79 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
2 |
* Enano - an open source wiki-like CMS |
|
3 |
* Copyright (C) 2006-2007 Dan Fuhry |
|
4 |
* |
|
5 |
* This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License |
|
6 |
* as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. |
|
7 |
* |
|
8 |
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied |
|
9 |
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. |
|
10 |
* |
|
11 |
* Some code found in this script is not licensed under the GNU General Public License; however, it is believed that the license terms shown |
|
12 |
* below are GPL-compatible. If you believe that this is not the case, please drop a note to support@enano.homelinux.org. |
|
13 |
*/ |
|
14 |
||
15 |
/* |
|
16 |
* Title: Tigra Tree |
|
17 |
* Description: See the demo at url |
|
18 |
* URL: http://www.softcomplex.com/products/tigra_tree_menu/ |
|
19 |
* Version: 1.1 |
|
20 |
* Date: 11-12-2002 (mm-dd-yyyy) |
|
21 |
* Notes: This script is free. Visit official site for further details. |
|
22 |
* |
|
23 |
* There is no license fee or royalty fee to be paid at any time for using the Tigra Tree Menu v1.x |
|
24 |
* You may include the source code or modified source code within your own projects for either personal |
|
25 |
* or commercial use but excluding the restrictions outlined below. The following restrictions apply to |
|
26 |
* all parts of the component, including all source code, samples and documentation. |
|
27 |
* |
|
28 |
* - Header block of script file (tree.js) CAN NOT be modified or removed. |
|
29 |
* - The above items CAN NOT be sold as are, either individually or together. |
|
15
ad5986a53197
Fixed complicated SQL injection vulnerability in URL handler, updated license info for Tigra Tree Menu, and killed one XSS vulnerability
Dan
parents:
1
diff
changeset
|
30 |
* - The above items CAN NOT be modified and then sold as a library component, either individually or together. |
ad5986a53197
Fixed complicated SQL injection vulnerability in URL handler, updated license info for Tigra Tree Menu, and killed one XSS vulnerability
Dan
parents:
1
diff
changeset
|
31 |
* |
ad5986a53197
Fixed complicated SQL injection vulnerability in URL handler, updated license info for Tigra Tree Menu, and killed one XSS vulnerability
Dan
parents:
1
diff
changeset
|
32 |
* Due to the unclear licensing conditions on this script, I contacted the author, who said that because Enano |
ad5986a53197
Fixed complicated SQL injection vulnerability in URL handler, updated license info for Tigra Tree Menu, and killed one XSS vulnerability
Dan
parents:
1
diff
changeset
|
33 |
* is not a "competing product" I was allowed to treat the code as GPL. The conversation can be seen in the |
ad5986a53197
Fixed complicated SQL injection vulnerability in URL handler, updated license info for Tigra Tree Menu, and killed one XSS vulnerability
Dan
parents:
1
diff
changeset
|
34 |
* /licenses/tigra-menu.html document in the Enano distribution. |
1 | 35 |
*/ |
21
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
15
diff
changeset
|
36 |
|
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
15
diff
changeset
|
37 |
if ( typeof(readCookie) == 'function' ) |
1 | 38 |
{ |
21
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
15
diff
changeset
|
39 |
var ck = readCookie('admin_menu_state'); |
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
15
diff
changeset
|
40 |
if(ck) |
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
15
diff
changeset
|
41 |
{ |
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
15
diff
changeset
|
42 |
ck = parseInt(ck); |
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
15
diff
changeset
|
43 |
} |
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
15
diff
changeset
|
44 |
else |
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
15
diff
changeset
|
45 |
{ |
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
15
diff
changeset
|
46 |
ck = 0; |
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
15
diff
changeset
|
47 |
} |
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
15
diff
changeset
|
48 |
ck = ( isNaN(ck) ) ? 0 : ck; |
1 | 49 |
} |
50 |
else |
|
51 |
{ |
|
21
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
15
diff
changeset
|
52 |
var ck = 0; |
1 | 53 |
} |
54 |
||
55 |
function tree (a_items, a_template) { |
|
56 |
||
57 |
this.a_tpl = a_template; |
|
58 |
this.a_config = a_items; |
|
59 |
this.o_root = this; |
|
60 |
this.a_index = []; |
|
61 |
this.o_selected = null; |
|
62 |
this.n_depth = -1; |
|
63 |
||
64 |
var o_icone = new Image(), |
|
65 |
o_iconl = new Image(); |
|
66 |
o_icone.src = a_template['icon_e']; |
|
67 |
o_iconl.src = a_template['icon_l']; |
|
68 |
a_template['im_e'] = o_icone; |
|
69 |
a_template['im_l'] = o_iconl; |
|
70 |
for (var i = 0; i < 64; i++) |
|
71 |
if (a_template['icon_' + i]) { |
|
72 |
var o_icon = new Image(); |
|
73 |
a_template['im_' + i] = o_icon; |
|
74 |
o_icon.src = a_template['icon_' + i]; |
|
75 |
} |
|
76 |
||
77 |
this.toggle = function (n_id,co) { var o_item = this.a_index[n_id]; o_item.open(o_item.b_opened,co); }; |
|
78 |
this.open = function (n_id,co) { var o_item = this.a_index[n_id]; o_item.open(false,co); }; |
|
79 |
this.select = function (n_id) { return this.a_index[n_id].select(); }; |
|
80 |
this.mout = function (n_id) { this.a_index[n_id].upstatus(true) }; |
|
81 |
this.mover = function (n_id) { this.a_index[n_id].upstatus() }; |
|
82 |
||
83 |
this.a_children = []; |
|
84 |
for (var i = 0; i < a_items.length; i++) |
|
85 |
{ |
|
86 |
new tree_item(this, i); |
|
87 |
} |
|
88 |
||
89 |
this.n_id = trees.length; |
|
90 |
trees[this.n_id] = this; |
|
91 |
||
92 |
for (var i = 0; i < this.a_children.length; i++) { |
|
93 |
document.write(this.a_children[i].init()); |
|
94 |
this.a_children[i].open(false, true); |
|
95 |
} |
|
96 |
} |
|
97 |
function tree_item (o_parent, n_order) { |
|
98 |
||
99 |
this.n_depth = o_parent.n_depth + 1; |
|
100 |
this.a_config = o_parent.a_config[n_order + (this.n_depth ? 2 : 0)]; |
|
101 |
if (!this.a_config) return; |
|
102 |
||
103 |
this.o_root = o_parent.o_root; |
|
104 |
this.o_parent = o_parent; |
|
105 |
this.n_order = n_order; |
|
106 |
this.b_opened = !this.n_depth; |
|
107 |
||
108 |
this.n_id = this.o_root.a_index.length; |
|
109 |
this.o_root.a_index[this.n_id] = this; |
|
110 |
o_parent.a_children[n_order] = this; |
|
111 |
||
112 |
this.a_children = []; |
|
113 |
for (var i = 0; i < this.a_config.length - 2; i++) |
|
114 |
{ |
|
115 |
new tree_item(this, i); |
|
116 |
} |
|
117 |
||
118 |
this.get_icon = item_get_icon; |
|
119 |
this.open = item_open; |
|
120 |
this.select = item_select; |
|
121 |
this.init = item_init; |
|
122 |
this.upstatus = item_upstatus; |
|
123 |
this.is_last = function () { return this.n_order == this.o_parent.a_children.length - 1 }; |
|
124 |
||
125 |
// CODE MODIFICATION |
|
126 |
// added: |
|
127 |
// Do we need to open the branch? |
|
128 |
n = Math.pow(2, this.n_id); |
|
129 |
var disp = ( ck & n ) ? true : false; |
|
130 |
s = ( disp ) ? 'open' : 'closed'; |
|
131 |
//if(s=='open') alert(this.n_id + ': ' + s); |
|
132 |
if(disp) setTimeout('trees['+trees.length+'].open('+this.n_id+', true);', 10); |
|
133 |
// END MODIFICATIONS |
|
134 |
} |
|
135 |
||
136 |
function item_open (b_close, nocookie) { |
|
137 |
//alert('item_open('+this.n_id+');'); |
|
138 |
var o_idiv = get_element('i_div' + this.o_root.n_id + '_' + this.n_id); |
|
139 |
if (!o_idiv) return; |
|
140 |
||
141 |
if (!o_idiv.innerHTML) { |
|
142 |
var a_children = []; |
|
143 |
for (var i = 0; i < this.a_children.length; i++) |
|
144 |
{ |
|
145 |
a_children[i]= this.a_children[i].init(); |
|
146 |
} |
|
147 |
o_idiv.innerHTML = a_children.join(''); |
|
148 |
} |
|
149 |
o_idiv.style.display = (b_close ? 'none' : 'block'); |
|
150 |
||
151 |
// CODE MODIFICATION |
|
152 |
// added: |
|
153 |
if(!nocookie) |
|
154 |
{ |
|
155 |
// The idea here is to use a bitwise field. Nice 'n simple, right? Object of the game is to assemble |
|
156 |
// a binary number that depicts the open/closed state of the entire menu in one cookie. |
|
157 |
n = Math.pow(2, this.n_id); |
|
158 |
ck = ( b_close ) ? ck-n : ck+n; |
|
159 |
//alert('open(): doing the cookie routine for id '+this.n_id+"\nResult for bitwise op: "+ck); |
|
160 |
createCookie('admin_menu_state', ck, 365); |
|
161 |
} else { |
|
162 |
//alert('open(): NOT doing the cookie routine for id '+this.n_id); |
|
163 |
} |
|
164 |
// END MODIFICATIONS |
|
165 |
||
166 |
this.b_opened = !b_close; |
|
167 |
var o_jicon = document.images['j_img' + this.o_root.n_id + '_' + this.n_id], |
|
168 |
o_iicon = document.images['i_img' + this.o_root.n_id + '_' + this.n_id]; |
|
169 |
if (o_jicon) o_jicon.src = this.get_icon(true); |
|
170 |
if (o_iicon) o_iicon.src = this.get_icon(); |
|
171 |
this.upstatus(); |
|
172 |
} |
|
173 |
||
174 |
function item_select (b_deselect) { |
|
175 |
if (!b_deselect) { |
|
176 |
var o_olditem = this.o_root.o_selected; |
|
177 |
this.o_root.o_selected = this; |
|
178 |
if (o_olditem) o_olditem.select(true); |
|
179 |
} |
|
180 |
var o_iicon = document.images['i_img' + this.o_root.n_id + '_' + this.n_id]; |
|
181 |
if (o_iicon) o_iicon.src = this.get_icon(); |
|
182 |
get_element('i_txt' + this.o_root.n_id + '_' + this.n_id).style.fontWeight = b_deselect ? 'normal' : 'bold'; |
|
183 |
||
184 |
this.upstatus(); |
|
185 |
return Boolean(this.a_config[1]); |
|
186 |
} |
|
187 |
||
188 |
function item_upstatus (b_clear) { |
|
189 |
window.setTimeout('window.status="' + (b_clear ? '' : this.a_config[0] + (this.a_config[1] ? ' ('+ this.a_config[1] + ')' : '')) + '"', 10); |
|
190 |
} |
|
191 |
||
192 |
function item_init () { |
|
193 |
var a_offset = [], |
|
194 |
o_current_item = this.o_parent; |
|
195 |
for (var i = this.n_depth; i > 1; i--) { |
|
196 |
a_offset[i] = '<img src="' + this.o_root.a_tpl[o_current_item.is_last() ? 'icon_e' : 'icon_l'] + '" border="0" align="absbottom">'; |
|
197 |
o_current_item = o_current_item.o_parent; |
|
198 |
} |
|
199 |
return '<table cellpadding="0" cellspacing="0" border="0"><tr><td nowrap="nowrap">' + (this.n_depth ? a_offset.join('') + (this.a_children.length |
|
200 |
? '<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.o_root.n_id + '_' + this.n_id + '"></a>' |
|
201 |
: '<img src="' + this.get_icon(true) + '" border="0" align="absbottom">') : '') |
|
202 |
// CODE MODIFICATION |
|
203 |
// removed: |
|
204 |
// + '<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.o_root.n_id + '_' + this.n_id + '"><img src="' + this.get_icon() + '" border="0" align="absbottom" name="i_img' + this.o_root.n_id + '_' + 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.o_root.n_id + '_' + this.n_id + '" style="display:none"></div>' : ''); |
|
205 |
// added: |
|
206 |
+ '<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.o_root.n_id + '_' + this.n_id + '">' + this.a_config[0] + '</a></td></tr></table>' + (this.a_children.length ? '<div id="i_div' + this.o_root.n_id + '_' + this.n_id + '" style="display:none"></div>' : ''); |
|
207 |
// END MODIFICATIONS |
|
208 |
alert('i_div' + this.o_root.n_id + '_' + this.n_id); |
|
209 |
} |
|
210 |
||
211 |
function item_get_icon (b_junction) { |
|
212 |
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))]; |
|
213 |
} |
|
214 |
||
215 |
var trees = []; |
|
216 |
get_element = document.all ? |
|
217 |
function (s_id) { return document.all[s_id] } : |
|
218 |
function (s_id) { return document.getElementById(s_id) }; |
|
219 |
||
220 |