PageSourceSearch

https://www.kibo.or.kr/js/dtree.js?ver=20221201

js kibo.or.kr collected 2026-10-03 19:55:59 UTC 12,002 bytes, 334 lines download raw bytes

1/*--------------------------------------------------|�
2| dTree 2.05 | www.destroydrop.com/javascript/tree/ |�
3|---------------------------------------------------|�
4
5|                                                   |�
6| This script can be used freely as long as all     |�
7| copyright messages are intact.                    |�
8|                                                   |�
9| Updated: 17.04.2003                               |�
10|--------------------------------------------------*/�
11�
12// Node object�
13function Node(id, pid, name, url, title, target, icon, iconOpen, open) {�
14	this.id = id;
15	this.pid = pid;
16	this.name = name;
17	this.url = url;
18	this.title = title;
19	this.target = target;
20	this.icon = icon;
21	this.iconOpen = iconOpen;
22	this._io = open || false;
23	this._is = false;
24	this._ls = false;
25	this._hc = false;
26	this._ai = 0;
27	this._p;�
28};�
29�
30// Tree object�
31function dTree(objName) {�
32	this.config = {
33		target					: null,
34		folderLinks			: true,
35		useSelection		: true,
36		useCookies			: true,
37		useLines				: true,
38		useIcons				: true,
39		useStatusText		: false,
40		closeSameLevel	: false,
41		inOrder					: false
42	}�
43	this.icon = {
44		root				: '/images/tree/base.gif',
45		folder				: '/images/tree/folder.gif',
46		folderOpen			: '/images/tree/folderopen.gif',
47		node				: '/images/tree/page.gif',
48		empty				: '/images/tree/empty.gif',
49		line				: '/images/tree/line.gif',
50		join				: '/images/tree/join.gif',
51		joinBottom			: '/images/tree/joinbottom.gif',
52		plus				: '/images/tree/plus.gif',
53		plusBottom			: '/images/tree/plusbottom.gif',
54		minus				: '/images/tree/minus.gif',
55		minusBottom			: '/images/tree/minusbottom.gif',
56		nlPlus				: '/images/tree/nolines_plus.gif',
57		nlMinus				: '/images/tree/nolines_minus.gif'
58	};�
59	this.obj = objName;
60	this.aNodes = [];
61	this.aIndent = [];
62	this.root = new Node(-1);
63	this.selectedNode = null;
64	this.selectedFound = false;
65	this.completed = false;�	�};�
66�
67// Adds a new node to the node array�
68dTree.prototype.add = function(id, pid, name, url, title, target, icon, iconOpen, open) {�
69	this.aNodes[this.aNodes.length] = new Node(id, pid, name, url, title, target, icon, iconOpen, open);�
70};�
71�
72// Open/close all nodes�
73dTree.prototype.openAll = function() {�
74	this.oAll(true);�
75};�
76dTree.prototype.closeAll = function() {�
77	this.oAll(false);�
78};�
79�
80// Outputs the tree to the page�
81dTree.prototype.toString = function() {�
82	var str = '<div class="dtree">\n';�
83	if (document.getElementById) {�
84		if (this.config.useCookies) this.selectedNode = this.getSelected();�		
85		str += this.addNode(this.root);�
86	} else str += 'Browser not supported.';�
87	str += '</div>';�
88	if (!this.selectedFound) this.selectedNode = null;�
89	this.completed = true;�
90	return str;�
91};�
92�
93// Creates the tree structure�
94dTree.prototype.addNode = function(pNode) {�
95	var str = '';�
96	var n=0;�
97	if (this.config.inOrder) n = pNode._ai;�
98	for (n; n<this.aNodes.length; n++) {�
99		if (this.aNodes[n].pid == pNode.id) {�
100			var cn = this.aNodes[n];�
101			cn._p = pNode;�
102			cn._ai = n;�
103			this.setCS(cn);�
104			if (!cn.target && this.config.target) cn.target = this.config.target;�
105			if (cn._hc && !cn._io && this.config.useCookies) cn._io = this.isOpen(cn.id);�
106			if (!this.config.folderLinks && cn._hc) cn.url = null;�
107			if (this.config.useSelection && cn.id == this.selectedNode && !this.selectedFound) {�
108					cn._is = true;�
109					this.selectedNode = n;�
110					this.selectedFound = true;�
111			}�
112			str += this.node(cn, n);�
113			if (cn._ls) break;�
114		}�
115	}�
116	return str;�
117};�
118�
119// Creates the node icon, url and text�
120dTree.prototype.node = function(node, nodeId) {�
121	var str = '<div class="dTreeNode">' + this.indent(node, nodeId);�
122	if (this.config.useIcons) {�
123		if (!node.icon) node.icon = (this.root.id == node.pid) ? this.icon.root : ((node._hc) ? this.icon.folder : this.icon.node);�
124		if (!node.iconOpen) node.iconOpen = (node._hc) ? this.icon.folderOpen : this.icon.node;�
125		if (this.root.id == node.pid) {�
126			node.icon = this.icon.root;�
127			node.iconOpen = this.icon.root;�
128		}�
129		str += '<img id="i' + this.obj + nodeId + '" src="' + ((node._io) ? node.iconOpen : node.icon) + '" alt="" />';�
130	}�
131	if (node.url) {�
132	}�	console.log(node.id);�	�	if(node.id != 0){�		str += '<input type="checkbox" id="'+node.id+'"  title="'+node.name+'" name="'+node.id+'" value="'+node.url+'" prevUsrAutrSctcd="'+node.url+'" suposMenId="' +node.pid+'" onclick="fn_checkBoxFunction(this);" style="margin-top:-3;">';�	}�	str += '&nbsp;&nbsp;<label for="'+node.id+'" style="cursor:pointer;">';�	str += node.name;�	str += '</label>';�	str += '<span style="color:red;"></span>';�	str += '</div>';�	�
133	if (node._hc) {�
134		str += '<div id="d' + this.obj + nodeId + '" class="clip" style="display:' + ((this.root.id == node.pid || node._io) ? 'block' : 'none') + ';">';�
135		str += this.addNode(node);�
136		str += '</div>';�
137	}�
138	this.aIndent.pop();��	console.log(str);�	
139	return str;�
140};�
141�
142// Adds the empty and line icons�
143dTree.prototype.indent = function(node, nodeId) {�
144	var str = '';�
145	if (this.root.id != node.pid) {�
146		for (var n=0; n<this.aIndent.length; n++)�
147			str += '<img src="' + ( (this.aIndent[n] == 1 && this.config.useLines) ? this.icon.line : this.icon.empty ) + '" alt="" />';�
148		(node._ls) ? this.aIndent.push(0) : this.aIndent.push(1);�
149		if (node._hc) {�
150			str += '<a title="펼치고접기" href="javascript: ' + this.obj + '.o(' + nodeId + ');"><img id="j' + this.obj + nodeId + '" src="';�
151			if (!this.config.useLines) str += (node._io) ? this.icon.nlMinus : this.icon.nlPlus;�
152			else str += ( (node._io) ? ((node._ls && this.config.useLines) ? this.icon.minusBottom : this.icon.minus) : ((node._ls && this.config.useLines) ? this.icon.plusBottom : this.icon.plus ) );�
153			str += '" alt="" /></a>';�
154		} else str += '<img src="' + ( (this.config.useLines) ? ((node._ls) ? this.icon.joinBottom : this.icon.join ) : this.icon.empty) + '" alt="" />';�
155	}�
156	return str;�
157};�
158�
159// Checks if a node has any children and if it is the last sibling�
160dTree.prototype.setCS = function(node) {�
161	var lastId;�
162	for (var n=0; n<this.aNodes.length; n++) {�
163		if (this.aNodes[n].pid == node.id) node._hc = true;�
164		if (this.aNodes[n].pid == node.pid) lastId = this.aNodes[n].id;�
165	}�
166	if (lastId==node.id) node._ls = true;�
167};�
168�
169// Returns the selected node�
170dTree.prototype.getSelected = function() {�
171	var sn = this.getCookie('cs' + this.obj);�
172	return (sn) ? sn : null;�
173};�
174�
175// Highlights the selected node�
176dTree.prototype.s = function(id) {�
177	if (!this.config.useSelection) return;�
178	var cn = this.aNodes[id];�
179	if (cn._hc && !this.config.folderLinks) return;�
180	if (this.selectedNode != id) {�
181		if (this.selectedNode || this.selectedNode==0) {�
182			eOld = document.getElementById("s" + this.obj + this.selectedNode);�
183			eOld.className = "node";�
184		}�
185		eNew = document.getElementById("s" + this.obj + id);�
186		eNew.className = "nodeSel";�
187		this.selectedNode = id;�
188		if (this.config.useCookies) this.setCookie('cs' + this.obj, cn.id);�
189	}�
190};�
191�
192// Toggle Open or close�
193dTree.prototype.o = function(id) {�
194	var cn = this.aNodes[id];�
195	this.nodeStatus(!cn._io, id, cn._ls);�
196	cn._io = !cn._io;�
197	if (this.config.closeSameLevel) this.closeLevel(cn);�
198	if (this.config.useCookies) this.updateCookie();�
199};�
200�
201// Open or close all nodes�
202dTree.prototype.oAll = function(status) {�
203	for (var n=0; n<this.aNodes.length; n++) {�
204		if (this.aNodes[n]._hc && this.aNodes[n].pid != this.root.id) {�
205			this.nodeStatus(status, n, this.aNodes[n]._ls)�
206			this.aNodes[n]._io = status;�
207		}�
208	}�
209	if (this.config.useCookies) this.updateCookie();�
210};�
211�
212// Opens the tree to a specific node�
213dTree.prototype.openTo = function(nId, bSelect, bFirst) {�
214	if (!bFirst) {�
215		for (var n=0; n<this.aNodes.length; n++) {�
216			if (this.aNodes[n].id == nId) {�
217				nId=n;�
218				break;�
219			}�
220		}�
221	}�
222	var cn=this.aNodes[nId];�
223	if (cn.pid==this.root.id || !cn._p) return;�
224	cn._io = true;�
225	cn._is = bSelect;�
226	if (this.completed && cn._hc) this.nodeStatus(true, cn._ai, cn._ls);�
227	if (this.completed && bSelect) this.s(cn._ai);�
228	else if (bSelect) this._sn=cn._ai;�
229	this.openTo(cn._p._ai, false, true);�
230};�
231�
232// Closes all nodes on the same level as certain node�
233dTree.prototype.closeLevel = function(node) {�
234	for (var n=0; n<this.aNodes.length; n++) {�
235		if (this.aNodes[n].pid == node.pid && this.aNodes[n].id != node.id && this.aNodes[n]._hc) {�
236			this.nodeStatus(false, n, this.aNodes[n]._ls);�
237			this.aNodes[n]._io = false;�
238			this.closeAllChildren(this.aNodes[n]);�
239		}�
240	}�
241}�
242�
243// Closes all children of a node�
244dTree.prototype.closeAllChildren = function(node) {�
245	for (var n=0; n<this.aNodes.length; n++) {�
246		if (this.aNodes[n].pid == node.id && this.aNodes[n]._hc) {�
247			if (this.aNodes[n]._io) this.nodeStatus(false, n, this.aNodes[n]._ls);�
248			this.aNodes[n]._io = false;�
249			this.closeAllChildren(this.aNodes[n]);		�
250		}�
251	}�
252}�
253�
254// Change the status of a node(open or closed)�
255dTree.prototype.nodeStatus = function(status, id, bottom) {�
256	eDiv	= document.getElementById('d' + this.obj + id);�
257	eJoin	= document.getElementById('j' + this.obj + id);�
258	if (this.config.useIcons) {�
259		eIcon	= document.getElementById('i' + this.obj + id);�
260		eIcon.src = (status) ? this.aNodes[id].iconOpen : this.aNodes[id].icon;�
261	}�
262	eJoin.src = (this.config.useLines)?�
263	((status)?((bottom)?this.icon.minusBottom:this.icon.minus):((bottom)?this.icon.plusBottom:this.icon.plus)):�
264	((status)?this.icon.nlMinus:this.icon.nlPlus);�
265	eDiv.style.display = (status) ? 'block': 'none';�
266};�
267�
268�
269// [Cookie] Clears a cookie�
270dTree.prototype.clearCookie = function() {�
271	var now = new Date();�
272	var yesterday = new Date(now.getTime() - 1000 * 60 * 60 * 24);�
273	this.setCookie('co'+this.obj, 'cookieValue', yesterday);�
274	this.setCookie('cs'+this.obj, 'cookieValue', yesterday);�
275};�
276�
277// [Cookie] Sets value in a cookie�
278dTree.prototype.setCookie = function(cookieName, cookieValue, expires, path, domain, secure) {�
279	document.cookie =�
280		escape(cookieName) + '=' + escape(cookieValue)�
281		+ (expires ? '; expires=' + expires.toGMTString() : '')�
282		+ (path ? '; path=' + path : '')�
283		+ (domain ? '; domain=' + domain : '')�
284		+ (secure ? '; secure' : '');�
285};�
286�
287// [Cookie] Gets a value from a cookie�
288dTree.prototype.getCookie = function(cookieName) {�
289	var cookieValue = '';�
290	var posName = document.cookie.indexOf(escape(cookieName) + '=');�
291	if (posName != -1) {�
292		var posValue = posName + (escape(cookieName) + '=').length;�
293		var endPos = document.cookie.indexOf(';', posValue);�
294		if (endPos != -1) cookieValue = unescape(document.cookie.substring(posValue, endPos));�
295		else cookieValue = unescape(document.cookie.substring(posValue));�
296	}�
297	return (cookieValue);�
298};�
299�
300// [Cookie] Returns ids of open nodes as a string�
301dTree.prototype.updateCookie = function() {�
302	var str = '';�
303	for (var n=0; n<this.aNodes.length; n++) {
304		if (this.aNodes[n]._io && this.aNodes[n].pid != this.root.id) {
305			if (str) str += '.';
306			str += this.aNodes[n].id;
307		}
308	}
309	this.setCookie('co' + this.obj, str);
310};�
311�
312// [Cookie] Checks if a node id is in a cookie
313dTree.prototype.isOpen = function(id) {
314	var aOpen = this.getCookie('co' + this.obj).split('.');
315	for (var n=0; n<aOpen.length; n++)
316		if (aOpen[n] == id) return true;
317	return false;
318};�
319�
320// If Push and pop is not implemented by the browser
321if (!Array.prototype.push) {
322	Array.prototype.push = function array_push() {
323		for(var i=0;i<arguments.length;i++)
324			this[this.length]=arguments[i];
325		return this.length;
326	}
327};�
328if (!Array.prototype.pop) {
329	Array.prototype.pop = function array_pop() {
330		lastElement = this[this.length-1];
331		this.length = Math.max(this.length-1,0);
332		return lastElement;
333	}
334};

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.