洛阳中航光电项目,为12年项目,此处使用反编译工具恢复源码,恢复为.netframe4.0版本,但仍需使用ie8访问; 数据库使用oracle,现再192.168.8.3服务器,访问账户scott,密码800100

rightdtree.js 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770
  1. /*--------------------------------------------------|
  2. | dTree 2.05 | www.destroydrop.com/javascript/tree/ |
  3. |---------------------------------------------------|
  4. | Copyright (c) 2002-2003 Geir Landr? |
  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. // Node object
  12. function Node(id, pid, name, url, title, target, icon, iconOpen, open,chk) {
  13. this.id = id;
  14. this.pid = pid;
  15. this.name = name;
  16. this.url = url;
  17. this.title = title;
  18. this.target = target;
  19. this.icon = icon;
  20. this.iconOpen = iconOpen;
  21. this._io = open || false;
  22. this._is = false;
  23. this._ls = false;
  24. this._hc = false;
  25. this._ai = 0;
  26. this._p;
  27. this.chk = chk;
  28. };
  29. // Tree object add checkbox control from 2009-08-14 by zhgjie
  30. function dTree(objName) {
  31. this.config = {
  32. target : null,
  33. folderLinks : true,
  34. useSelection : true,
  35. useCookies : true,
  36. useLines : true,
  37. useIcons : true,
  38. useStatusText : false,
  39. closeSameLevel : false,
  40. inOrder: false,
  41. blCheckBox:true
  42. }
  43. this.icon = {
  44. root : '../DtreeImg/base.gif',
  45. folder : '../DtreeImg/folder.gif',
  46. folderOpen : '../DtreeImg/folderopen.gif',
  47. node : '../DtreeImg/page.gif',
  48. empty : '../DtreeImg/empty.gif',
  49. line : '../DtreeImg/line.gif',
  50. join : '../DtreeImg/join.gif',
  51. joinBottom : '../DtreeImg/joinbottom.gif',
  52. plus : '../DtreeImg/plus.gif',
  53. plusBottom : '../DtreeImg/plusbottom.gif',
  54. minus : '../DtreeImg/minus.gif',
  55. minusBottom : '../DtreeImg/minusbottom.gif',
  56. nlPlus : '../DtreeImg/nolines_plus.gif',
  57. nlMinus : '../DtreeImg/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
  68. dTree.prototype.add = function(id, pid, name, url, title, target, icon, iconOpen, open,chk) {
  69. this.aNodes[this.aNodes.length] = new Node(id, pid, name, url, title, target, icon, iconOpen, open,chk);
  70. };
  71. // Open/close all nodes
  72. dTree.prototype.openAll = function() {
  73. this.oAll(true);
  74. };
  75. dTree.prototype.closeAll = function() {
  76. this.oAll(false);
  77. };
  78. // Outputs the tree to the page add checkbox control from 2009-08-14 by zhgjie
  79. dTree.prototype.toString = function() {
  80. var str = '<div class="dtree">\n';
  81. if (document.getElementById) {
  82. if (this.config.useCookies) this.selectedNode = this.getSelected();
  83. str += this.addNode(this.root);
  84. } else str += 'Browser not supported.';
  85. str += '</div>';
  86. if (!this.selectedFound) this.selectedNode = null;
  87. this.completed = true;
  88. return str;
  89. };
  90. // add checkbox control from 2009-08-14 by zhgjie
  91. dTree.prototype.cc = function(nodeId) {
  92. var cs = document.getElementById("c" + this.obj + nodeId).checked;
  93. var n, node = this.aNodes[nodeId];
  94. var len = this.aNodes.length;
  95. for (n = 0; n < len; n++) {
  96. if (this.aNodes[n].pid == node.id) {
  97. document.getElementById("c" + this.obj + n).checked = cs;
  98. this.cc(n);
  99. }
  100. }
  101. if (cs == false) return;
  102. var pid = node.pid;
  103. var bSearch;
  104. do {
  105. bSearch = false;
  106. for (n = 0; n < len; n++) {
  107. if (this.aNodes[n].id == pid) {
  108. document.getElementById("c" + this.obj + n).checked = true;
  109. pid = this.aNodes[n].pid;
  110. bSearch = true;
  111. break;
  112. }
  113. }
  114. } while (bSearch == true);
  115. }
  116. // Creates the tree structure
  117. dTree.prototype.addNode = function(pNode) {
  118. var str = '';
  119. var n=0;
  120. if (this.config.inOrder) n = pNode._ai;
  121. for (n; n<this.aNodes.length; n++) {
  122. if (this.aNodes[n].pid == pNode.id) {
  123. var cn = this.aNodes[n];
  124. cn._p = pNode;
  125. cn._ai = n;
  126. this.setCS(cn);
  127. if (!cn.target && this.config.target) cn.target = this.config.target;
  128. if (cn._hc && !cn._io && this.config.useCookies) cn._io = this.isOpen(cn.id);
  129. if (!this.config.folderLinks && cn._hc) cn.url = null;
  130. if (this.config.useSelection && cn.id == this.selectedNode && !this.selectedFound) {
  131. cn._is = true;
  132. this.selectedNode = n;
  133. this.selectedFound = true;
  134. }
  135. str += this.node(cn, n);
  136. if (cn._ls) break;
  137. }
  138. }
  139. return str;
  140. };
  141. // Creates the node icon, url and text
  142. dTree.prototype.node = function(node, nodeId) {
  143. var str = '<div class="dTreeNode">' + this.indent(node, nodeId);
  144. if (this.config.useIcons) {
  145. if (!node.icon) node.icon = (this.root.id == node.pid) ? this.icon.root : ((node._hc) ? this.icon.folder : this.icon.node);
  146. if (!node.iconOpen) node.iconOpen = (node._hc) ? this.icon.folderOpen : this.icon.node;
  147. var blimg = true;
  148. if (this.root.id == node.pid) {
  149. node.icon = this.icon.root;
  150. node.iconOpen = this.icon.root;
  151. blimg = false;
  152. }
  153. if (blimg) {
  154. str += '<img id="i' + this.obj + nodeId + '" src="' + ((node._io) ? node.iconOpen : node.icon) + '" alt="" />';
  155. }
  156. else {
  157. str += '<img id="i' + this.obj + nodeId + '" src="' + ((node._io) ? node.iconOpen : node.icon) + '" alt="" style="display:none;" />';
  158. }
  159. }
  160. if (this.config.blCheckBox == true) {
  161. if (this.root.id == node.pid) {
  162. str += '<input style="display:none;" type="checkbox" id="c' + this.obj + nodeId + '" onclick=""/>';
  163. }
  164. else {
  165. if (!node.chk) {
  166. str += '<input name="chkrights" type="checkbox" id="c' + this.obj + nodeId + '" checksname="' + node.title + '" checkpid="' + node.pid + '" checksid="' + node.id + '" onclick="javascript:checkTree(this.id,this.checkpid,this.checksid,this.checked,this.checksname);"/>';
  167. }
  168. }
  169. }
  170. if (node.url) {
  171. str += '<a id="s' + this.obj + nodeId + '" class="' + ((this.config.useSelection) ? ((node._is ? 'nodeSel' : 'node')) : 'node') + '" href="' + node.url + '"';
  172. if (node.title) str += ' title="' + node.title + '"';
  173. if (node.target) str += ' target="' + node.target + '"';
  174. if (this.config.useStatusText) str += ' onmouseover="window.status=\'' + node.name + '\';return true;" onmouseout="window.status=\'\';return true;" ';
  175. if (this.config.useSelection && ((node._hc && this.config.folderLinks) || !node._hc))
  176. str += ' onclick="javascript: ' + this.obj + '.s(' + nodeId + ');"';
  177. str += '>';
  178. }
  179. else if ((!this.config.folderLinks || !node.url) && node._hc && node.pid != this.root.id)
  180. str += '<a href="javascript: ' + this.obj + '.o(' + nodeId + ');" class="node">';
  181. if (this.root.id != node.pid) {
  182. str += node.name;
  183. }
  184. if (node.url || ((!this.config.folderLinks || !node.url) && node._hc)) str += '</a>';
  185. str += '</div>';
  186. if (node._hc) {
  187. str += '<div id="d' + this.obj + nodeId + '" class="clip" style="display:' + ((this.root.id == node.pid || node._io) ? 'block' : 'none') + ';">';
  188. str += this.addNode(node);
  189. str += '</div>';
  190. }
  191. this.aIndent.pop();
  192. return str;
  193. };
  194. // Adds the empty and line icons
  195. dTree.prototype.indent = function(node, nodeId) {
  196. var str = '';
  197. if (this.root.id != node.pid) {
  198. for (var n=0; n<this.aIndent.length; n++)
  199. str += '<img src="' + ( (this.aIndent[n] == 1 && this.config.useLines) ? this.icon.line : this.icon.empty ) + '" alt="" />';
  200. (node._ls) ? this.aIndent.push(0) : this.aIndent.push(1);
  201. if (node._hc) {
  202. str += '<a href="javascript: ' + this.obj + '.o(' + nodeId + ');"><img id="j' + this.obj + nodeId + '" src="';
  203. if (!this.config.useLines) str += (node._io) ? this.icon.nlMinus : this.icon.nlPlus;
  204. 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 ) );
  205. str += '" alt="" /></a>';
  206. } else str += '<img src="' + ( (this.config.useLines) ? ((node._ls) ? this.icon.joinBottom : this.icon.join ) : this.icon.empty) + '" alt="" />';
  207. }
  208. return str;
  209. };
  210. // Checks if a node has any children and if it is the last sibling
  211. dTree.prototype.setCS = function(node) {
  212. var lastId;
  213. for (var n=0; n<this.aNodes.length; n++) {
  214. if (this.aNodes[n].pid == node.id) node._hc = true;
  215. if (this.aNodes[n].pid == node.pid) lastId = this.aNodes[n].id;
  216. }
  217. if (lastId==node.id) node._ls = true;
  218. };
  219. // Returns the selected node
  220. dTree.prototype.getSelected = function() {
  221. var sn = this.getCookie('cs' + this.obj);
  222. return (sn) ? sn : null;
  223. };
  224. // Highlights the selected node
  225. dTree.prototype.s = function(id) {
  226. if (!this.config.useSelection) return;
  227. var cn = this.aNodes[id];
  228. if (cn._hc && !this.config.folderLinks) return;
  229. if (this.selectedNode != id) {
  230. if (this.selectedNode || this.selectedNode == 0) {
  231. eOld = document.getElementById("s" + this.obj + this.selectedNode);
  232. eOld.className = "node";
  233. }
  234. eNew = document.getElementById("s" + this.obj + id);
  235. eNew.className = "nodeSel";
  236. this.selectedNode = id;
  237. if (this.config.useCookies) this.setCookie('cs' + this.obj, cn.id);
  238. } SelectToBind(cn.id,cn.name);
  239. // if (document.getElementById("c" + this.obj + id) != null) {
  240. // document.getElementById("c" + this.obj + id).click();
  241. // this.SelectAllChildren(cn);
  242. // }
  243. // else {
  244. // this.SelectAllChildren(cn);
  245. // }
  246. };
  247. dTree.prototype.SelectAllChildren = function(node) {
  248. for (var n = 0; n < this.aNodes.length; n++) {
  249. if (this.aNodes[n].pid == node.id) {
  250. //alert("c" + this.obj + this.aNodes[n]._ai);
  251. if (document.getElementById("c" + this.obj + this.aNodes[n]._ai) != null) {
  252. document.getElementById("c" + this.obj + this.aNodes[n]._ai).click();
  253. // if (document.getElementById("divSelectTree1") != null) {
  254. // if (document.getElementById("divSelectTree1").innerHTML != "") {
  255. // return;
  256. // }
  257. // }
  258. }
  259. this.SelectAllChildren(this.aNodes[n]);
  260. }
  261. }
  262. }
  263. // Toggle Open or close
  264. dTree.prototype.o = function(id) {
  265. var cn = this.aNodes[id];
  266. this.nodeStatus(!cn._io, id, cn._ls);
  267. cn._io = !cn._io;
  268. if (this.config.closeSameLevel) this.closeLevel(cn);
  269. if (this.config.useCookies) this.updateCookie();
  270. };
  271. // Open or close all nodes
  272. dTree.prototype.oAll = function(status) {
  273. for (var n=0; n<this.aNodes.length; n++) {
  274. if (this.aNodes[n]._hc && this.aNodes[n].pid != this.root.id) {
  275. this.nodeStatus(status, n, this.aNodes[n]._ls)
  276. this.aNodes[n]._io = status;
  277. }
  278. }
  279. if (this.config.useCookies) this.updateCookie();
  280. };
  281. // Opens the tree to a specific node
  282. dTree.prototype.openTo = function(nId, bSelect, bFirst) {
  283. if (!bFirst) {
  284. for (var n=0; n<this.aNodes.length; n++) {
  285. if (this.aNodes[n].id == nId) {
  286. nId=n;
  287. break;
  288. }
  289. }
  290. }
  291. var cn=this.aNodes[nId];
  292. if (cn.pid==this.root.id || !cn._p) return;
  293. cn._io = true;
  294. cn._is = bSelect;
  295. if (this.completed && cn._hc) this.nodeStatus(true, cn._ai, cn._ls);
  296. if (this.completed && bSelect) this.s(cn._ai);
  297. else if (bSelect) this._sn=cn._ai;
  298. this.openTo(cn._p._ai, false, true);
  299. };
  300. // Closes all nodes on the same level as certain node
  301. dTree.prototype.closeLevel = function(node) {
  302. for (var n=0; n<this.aNodes.length; n++) {
  303. if (this.aNodes[n].pid == node.pid && this.aNodes[n].id != node.id && this.aNodes[n]._hc) {
  304. this.nodeStatus(false, n, this.aNodes[n]._ls);
  305. this.aNodes[n]._io = false;
  306. this.closeAllChildren(this.aNodes[n]);
  307. }
  308. }
  309. }
  310. // Closes all children of a node
  311. dTree.prototype.closeAllChildren = function(node) {
  312. for (var n=0; n<this.aNodes.length; n++) {
  313. if (this.aNodes[n].pid == node.id && this.aNodes[n]._hc) {
  314. if (this.aNodes[n]._io) this.nodeStatus(false, n, this.aNodes[n]._ls);
  315. this.aNodes[n]._io = false;
  316. this.closeAllChildren(this.aNodes[n]);
  317. }
  318. }
  319. }
  320. // Change the status of a node(open or closed)
  321. dTree.prototype.nodeStatus = function(status, id, bottom) {
  322. eDiv = document.getElementById('d' + this.obj + id);
  323. eJoin = document.getElementById('j' + this.obj + id);
  324. if (this.config.useIcons) {
  325. eIcon = document.getElementById('i' + this.obj + id);
  326. eIcon.src = (status) ? this.aNodes[id].iconOpen : this.aNodes[id].icon;
  327. }
  328. eJoin.src = (this.config.useLines)?
  329. ((status)?((bottom)?this.icon.minusBottom:this.icon.minus):((bottom)?this.icon.plusBottom:this.icon.plus)):
  330. ((status)?this.icon.nlMinus:this.icon.nlPlus);
  331. eDiv.style.display = (status) ? 'block': 'none';
  332. };
  333. // [Cookie] Clears a cookie
  334. dTree.prototype.clearCookie = function() {
  335. var now = new Date();
  336. var yesterday = new Date(now.getTime() - 1000 * 60 * 60 * 24);
  337. this.setCookie('co'+this.obj, 'cookieValue', yesterday);
  338. this.setCookie('cs'+this.obj, 'cookieValue', yesterday);
  339. };
  340. // [Cookie] Sets value in a cookie
  341. dTree.prototype.setCookie = function(cookieName, cookieValue, expires, path, domain, secure) {
  342. document.cookie =
  343. escape(cookieName) + '=' + escape(cookieValue)
  344. + (expires ? '; expires=' + expires.toGMTString() : '')
  345. + (path ? '; path=' + path : '')
  346. + (domain ? '; domain=' + domain : '')
  347. + (secure ? '; secure' : '');
  348. };
  349. // [Cookie] Gets a value from a cookie
  350. dTree.prototype.getCookie = function(cookieName) {
  351. var cookieValue = '';
  352. var posName = document.cookie.indexOf(escape(cookieName) + '=');
  353. if (posName != -1) {
  354. var posValue = posName + (escape(cookieName) + '=').length;
  355. var endPos = document.cookie.indexOf(';', posValue);
  356. if (endPos != -1) cookieValue = unescape(document.cookie.substring(posValue, endPos));
  357. else cookieValue = unescape(document.cookie.substring(posValue));
  358. }
  359. return (cookieValue);
  360. };
  361. // [Cookie] Returns ids of open nodes as a string
  362. dTree.prototype.updateCookie = function() {
  363. var str = '';
  364. for (var n=0; n<this.aNodes.length; n++) {
  365. if (this.aNodes[n]._io && this.aNodes[n].pid != this.root.id) {
  366. if (str) str += '.';
  367. str += this.aNodes[n].id;
  368. }
  369. }
  370. this.setCookie('co' + this.obj, str);
  371. };
  372. // [Cookie] Checks if a node id is in a cookie
  373. dTree.prototype.isOpen = function(id) {
  374. var aOpen = this.getCookie('co' + this.obj).split('.');
  375. for (var n=0; n<aOpen.length; n++)
  376. if (aOpen[n] == id) return true;
  377. return false;
  378. };
  379. // If Push and pop is not implemented by the browser
  380. if (!Array.prototype.push) {
  381. Array.prototype.push = function array_push() {
  382. for(var i=0;i<arguments.length;i++)
  383. this[this.length]=arguments[i];
  384. return this.length;
  385. }
  386. };
  387. if (!Array.prototype.pop) {
  388. Array.prototype.pop = function array_pop() {
  389. lastElement = this[this.length-1];
  390. this.length = Math.max(this.length-1,0);
  391. return lastElement;
  392. }
  393. };