1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
|
var nodeLayer = null;
var sonLayer = null;
var oldstyle = '';
var newstyle = '';
var oldimg = '';
var newimg = '';
function readCollapsedNodes() {
collapsedNodes = new Array();
cn = document.cookie.split('collapsedNodes=');
if (cn.length < 2) return;
vl = cn[1];
if (vl.indexOf(';') != -1) {
vl = vl.split(';');
vl = vl[0];
}
if (vl) {
collapsed = vl.split('|');
for (i = 0; i < collapsed.length; i++) {
collapsedNodes[i] = collapsed[i];
}
}
}
function writeCollapsedNodes() {
document.cookie = 'collapsedNodes=' + collapsedNodes.join('|') + ';path=/';
}
function addCollapsedNode(nodeId) {
for (i = 0; i < collapsedNodes.length; i++) {
if (collapsedNodes[i] == nodeId) return;
}
collapsedNodes[collapsedNodes.length] = nodeId;
writeCollapsedNodes();
}
function delCollapsedNode(nodeId) {
newCollapsedNodes = new Array();
j = 0;
for (i = 0; i < collapsedNodes.length; i++) {
if (collapsedNodes[i] != nodeId) {
newCollapsedNodes[j++] = collapsedNodes[i];
}
}
collapsedNodes = newCollapsedNodes;
writeCollapsedNodes();
}
function updateNewStyle() {
nodeLayer.src = newimg;
sonLayer.style.display = newstyle;
}
function cancelNewStyle() {
nodeLayer.src = oldimg;
sonLayer.style.display = oldstyle;
}
function alertTreeNodeContents(html) {
if (html.replace(/(^\s*)|(\s*$)/g, '')) {
includeHTML(sonLayer, html);
}
updateNewStyle();
}
function opencloseTreeNode(nodeid,params,imgdir) {
cancelHttpRequest(); // cancel last request
// get the node element
if ((!DOM || Opera56 || Konqueror22) && !IE4) return;
if (!IE4) {
sonLayer = document.getElementById('jt' + nodeid + 'son');
nodeLayer = document.getElementById('jt' + nodeid + 'node');
} else {
sonLayer = document.all('jt' + nodeid + 'son');
nodeLayer = document.all('jt' + nodeid + 'node');
}
if (!sonLayer || !nodeLayer) return false;
// update global variables
oldstyle = sonLayer.style.display;
oldimg = nodeLayer.src;
var action = 0; // (action = 1) => expand ; (action = 2) => collapse
if (oldimg.indexOf(imgdir+'/tree_expand.png') > -1) {
newimg = imgdir+'/tree_collapse.png';
action = 1;
} else if (oldimg.indexOf(imgdir+'/tree_expand_first.png') > -1) {
newimg = imgdir+'/tree_collapse_first.png';
action = 1;
} else if (oldimg.indexOf(imgdir+'/tree_expand_corner.png') > -1) {
newimg = imgdir+'/tree_collapse_corner.png';
action = 1;
} else if (oldimg.indexOf(imgdir+'/tree_expand_corner_first.png') > -1) {
newimg = imgdir+'/tree_collapse_corner_first.png';
action = 1;
} else if (oldimg.indexOf(imgdir+'/tree_collapse.png') > -1) {
newimg = imgdir+'/tree_expand.png';
action = 2;
} else if (oldimg.indexOf(imgdir+'/tree_collapse_first.png') > -1) {
newimg = imgdir+'/tree_expand_first.png';
action = 2;
} else if (oldimg.indexOf(imgdir+'/tree_collapse_corner.png') > -1) {
newimg = imgdir+'/tree_expand_corner.png';
action = 2;
} else if (oldimg.indexOf(imgdir+'/tree_collapse_corner_first.png') > -1) {
newimg = imgdir+'/tree_expand_corner_first.png';
action = 2;
}
nodeLayer.src = 'images/ajax-spinner.gif';
// perform action
if (action == 2) {
newstyle = 'none';
updateNewStyle();
addCollapsedNode(nodeid);
} else if (action == 1) {
newstyle = 'block';
if (sonLayer.innerHTML == '') {
makeHttpRequest('cmd.php',params+'&cmd=draw_tree_node&action=1','GET','alertTreeNodeContents','cancelNewStyle');
} else {
updateNewStyle();
}
delCollapsedNode(nodeid);
}
return false;
}
function getDiv(div) {
if (!IE4) {
return document.getElementById('aj'+div);
} else {
return document.all('aj'+div);
}
}
function alertAJ(html,div) {
var pageDiv = getDiv(div);
if (pageDiv) includeHTML(pageDiv, html);
}
function cancelAJ(div) {
var pageDiv = getDiv(div);
if (pageDiv) includeHTML(pageDiv, '');
}
// close initial collapsed nodes
// Cant figure out why, but this runs twice in AJAX mode when using "refresh".
// Causing the collapsedNodes to be incorrect.
readCollapsedNodes();
for (k = 0; k < collapsedNodes.length; k++) {
opencloseTreeNode(collapsedNodes[k],'#','images/default');
}
var current;
function tree_unhide(whichLayer,old) {
if (current == null) current = old;
var oldtree = document.getElementById('ajSID_'+current).style;
oldtree.display = 'none';
if (document.getElementById) {
// this is the way the standards work
var newtree = document.getElementById(whichLayer).value;
var newtree_div = document.getElementById('ajSID_'+newtree).style;
newtree_div.display = 'block';
}
current = newtree;
}
|