/*--------------------------------------------------|
| dTree 2.05 | www.destroydrop.com/javascript/tree/ |
|---------------------------------------------------|
| Copyright (c) 2002-2003 Geir Landr? |
| |
| This script can be used freely as long as all |
| copyright messages are intact. |
| |
| Updated: 17.04.2003 |
|--------------------------------------------------*/
// Node object
function Node(id, pid, cate, name, hide, url, title, target, icon, iconOpen, open) {
this.id = id;
this.pid = pid;
this.cate = cate;
this.name = name;
this.hide = hide;
this.url = url;
this.title = title;
this.target = target;
this.icon = icon;
this.iconOpen = iconOpen;
this._io = open || false;
this._is = false;
this._ls = false;
this._hc = false;
this._ai = 0;
this._p;
};
// Tree object
function dTree(objName) {
this.config = {
target : null,
folderLinks : true,
useSelection : true,
useCookies : true,
useLines : true,
useIcons : true,
useStatusText : false,
closeSameLevel : false,
inOrder : false
}
this.icon = {
root : 'img/base.gif',
folder : 'img/folder.gif',
folderOpen : 'img/folderopen.gif',
hfolder : 'img/hfolder.gif',
hfolderOpen : 'img/hfolderopen.gif',
node : 'img/page.gif',
hnode : 'img/hpage.gif',
empty : 'img/empty.gif',
line : 'img/line.gif',
join : 'img/join.gif',
joinBottom : 'img/joinbottom.gif',
plus : 'img/plus.gif',
plusBottom : 'img/plusbottom.gif',
minus : 'img/minus.gif',
minusBottom : 'img/minusbottom.gif',
nlPlus : 'img/nolines_plus.gif',
nlMinus : 'img/nolines_minus.gif'
};
this.obj = objName;
this.aNodes = [];
this.aIndent = [];
this.root = new Node(-1);
this.selectedNode = null;
this.selectedFound = false;
this.completed = false;
};
// Adds a new node to the node array
dTree.prototype.add = function(id, pid, cate, name, hide, url, title, target, icon, iconOpen, open) {
this.aNodes[this.aNodes.length] = new Node(id, pid, cate, name, hide, url, title, target, icon, iconOpen, open);
};
// Open/close all nodes
dTree.prototype.openAll = function() {
this.oAll(true);
};
dTree.prototype.closeAll = function() {
this.oAll(false);
};
// Outputs the tree to the page
dTree.prototype.toString = function() {
var str = '
\n';
if (document.getElementById) {
if (this.config.useCookies) this.selectedNode = this.getSelected();
str += this.addNode(this.root);
} else str += 'ºê¶ó¿ìÁ®°¡ Áö¿øÇÏÁö ¾Ê½À´Ï´Ù.Àͽº 7ÀÌ»ó »ç¿ë';
str += '
';
if (!this.selectedFound) this.selectedNode = null;
this.completed = true;
return str;
};
// Creates the tree structure
dTree.prototype.addNode = function(pNode) {
var str = '';
var n=0;
if (this.config.inOrder) n = pNode._ai;
for (n; n';
}
// str += '';
if(node.cate == '00000000'){
str += '';
str += '';
} else {
str += '';
str += '';
str += '';
}
if (node.url) {
str += '';
str += '';
}
// str += node.name;
//Æú´õ³×ÀÓ
// if (node.url || ((!this.config.folderLinks || !node.url) && node._hc)) str += '';
str += '';
str += '';
if (node._hc) {
str += '';
str += this.addNode(node);
str += '
';
}
this.aIndent.pop();
return str;
};
// ¼±ÅÃÇϱâ
dTree.prototype.ch = function(id) {
for (var n=0; n';
vHtml += '
';
vHtml += '


';
vHtml += '
';
vHtml += '

';
document.getElementById("addtree_"+chkcate).innerHTML = vHtml;
} else {
alert("ºÐ·ù´Â ÇѰ³¾¿ Ãß°¡ °¡´ÉÇÕ´Ï´Ù.");
return;
}
} else { //´ëºÐ·ù ¹ØÀ¸·Î Ãß°¡
// var numcate = chkcate*1;
var cate3 = chkcate.substring(4,6);
var cate2 = chkcate.substring(2,4);
var cate1 = chkcate.substring(0,2);
if(cate1 > 0 && cate2 == 0 && cate3 == 0){ // ´ëºÐ·ù -> ÁߺзùÃß°¡
var cnt = document.getElementById("addcatecode"); //Ä«Å×°í¸® ÇѰǾ¿¸¸ Ãß°¡ °¡´É
if(cnt == null){
var vHtml = "";
vHtml += '';
vHtml += '
';
vHtml += '



';
vHtml += '
';
vHtml += '

';
document.getElementById("addtree_"+chkcate).innerHTML = vHtml;
} else {
alert("ºÐ·ù´Â ÇѰ³¾¿ Ãß°¡ °¡´ÉÇÕ´Ï´Ù.");
return;
}
} else if(cate2 > 0 && cate3 == 0){ // Áߺзù -> ¼ÒºÐ·ùÃß°¡
var cnt = document.getElementById("addcatecode"); //Ä«Å×°í¸® ÇѰǾ¿¸¸ Ãß°¡ °¡´É
if(cnt == null){
var vHtml = "";
vHtml += '
';
vHtml += '
';
vHtml += '




';
vHtml += '
';
vHtml += '

';
document.getElementById("addtree_"+chkcate).innerHTML = vHtml;
} else {
alert("ºÐ·ù´Â ÇѰ³¾¿ Ãß°¡ °¡´ÉÇÕ´Ï´Ù.");
return;
}
} else if(cate3 > 0){ //¼ÒºÐ·ù - > ÇÏÀ§¾øÀ½
alert("¼ÒºÐ·ù ÇÏÀ§·Î´Â Ãß°¡ ºÒ°¡´ÉÇÕ´Ï´Ù.");
return;
}
}
/*
if(confirm("»èÁ¦ÇϽðڽÀ´Ï±î?")){
window.open( "./submenu4/cateProcess.php?mode=delete&ccode="+id+"","saveproduct");
document.getElementById('catemode').value = '';
} else {
return;
}
*/
}
}
// Ä«Å×°í¸® ´ëºÐ·ù Ãß°¡
function addcate1(){
var cate = document.getElementById("addcatename"); //Ãß°¡ºÐ·ù¸í ÀԷ¹ڽº
var catecode = document.getElementById("addcatecode"); //»óÀ§ ¼±Åà ºÐ·ùÄÚµå
if(cate.value == ""){ //ºÐ·ù¸í ¹ÌÀÔ·Â
alert("ºÐ·ù¸íÀ» ÀÔ·ÂÇϼ¼¿ä.");
cate.focus();
return;
} else { //ºÐ·ù¸í ÀÔ·Â
if(confirm("ÀúÀå ÇϽðڽÀ´Ï±î?")){
window.open( "./submenu4/cateProcess.php?mode=add&clevel=1&ccode="+catecode.value+"&cvalue="+cate.value+"","saveproduct");
document.getElementById('catemode').value = '';
} else {
return;
}
}
}
//Ä«Å×°í¸® Áߺзù Ãß°¡
function addcate2(){
var cate = document.getElementById("addcatename"); //Ãß°¡ºÐ·ù¸í ÀԷ¹ڽº
var catecode = document.getElementById("addcatecode"); //»óÀ§ ¼±Åà ºÐ·ùÄÚµå
if(cate.value == ""){ //ºÐ·ù¸í ¹ÌÀÔ·Â
alert("ºÐ·ù¸íÀ» ÀÔ·ÂÇϼ¼¿ä.");
cate.focus();
return;
} else { //ºÐ·ù¸í ÀÔ·Â
if(confirm("ÀúÀå ÇϽðڽÀ´Ï±î?")){
window.open( "./submenu4/cateProcess.php?mode=add&clevel=2&ccode="+catecode.value+"&cvalue="+cate.value+"","saveproduct");
document.getElementById('catemode').value = '';
} else {
return;
}
}
}
//Ä«Å×°í¸® Áߺзù Ãß°¡
function addcate3(){
var cate = document.getElementById("addcatename"); //Ãß°¡ºÐ·ù¸í ÀԷ¹ڽº
var catecode = document.getElementById("addcatecode"); //»óÀ§ ¼±Åà ºÐ·ùÄÚµå
if(cate.value == ""){ //ºÐ·ù¸í ¹ÌÀÔ·Â
alert("ºÐ·ù¸íÀ» ÀÔ·ÂÇϼ¼¿ä.");
cate.focus();
return;
} else { //ºÐ·ù¸í ÀÔ·Â
if(confirm("ÀúÀå ÇϽðڽÀ´Ï±î?")){
window.open( "./submenu4/cateProcess.php?mode=add&clevel=3&ccode="+catecode.value+"&cvalue="+cate.value+"","saveproduct");
document.getElementById('catemode').value = '';
} else {
return;
}
}
}
// Ä«Å×°í¸® º¯°æÈÄ ¿£ÅÍó¸®
function enter(id,kc,vu){
var code = kc.keyCode?kc.keyCode:kc.charCode;
if(code == 13){
if(confirm("¼öÁ¤ÇϽðڽÀ´Ï±î?")){
window.open( "./submenu4/cateProcess.php?mode=edit&ccode="+id+"&cvalue="+vu+"","saveproduct");
document.getElementById('catemode').value = '';
} else {
return;
}
}
}
// Adds the empty and line icons
dTree.prototype.indent = function(node, nodeId) {
var str = '';
if (this.root.id != node.pid) {
for (var n=0; n
';
(node._ls) ? this.aIndent.push(0) : this.aIndent.push(1);
if (node._hc) {
str += '
 str += (node._io) ? this.icon.nlMinus : this.icon.nlPlus;
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 ) );
str += ')
';
} else str += '
 ? ((node._ls) ? this.icon.joinBottom : this.icon.join ) : this.icon.empty) + ')
';
}
return str;
};
// Checks if a node has any children and if it is the last sibling
dTree.prototype.setCS = function(node) {
var lastId;
for (var n=0; n