sectree.js
上传用户:kaisitong
上传日期:2022-01-01
资源大小:3672k
文件大小:36k
源码类别:

OA系统

开发平台:

ASP/ASPX

  1. function startMenu() {
  2. // 菜单参数
  3. imageDirectory = '../../../img'; ////图片目录
  4. menuTree = new obj_collection()
  5. defineMenuItems(menuTree)
  6. if (definitionsHaveErrors(menuTree) == false) {createAppearanceArray(menuTree,menuTree.itemWithID('root'));
  7.        treeVariable = menuTree;
  8.        expandNode('root');
  9.        expandNode('ioffice')
  10. expandNode('sysset')
  11. }
  12. }
  13. // OBJ_NODE - 定义结点对象
  14. // ID = 每个结点的绝对标记
  15. // NAME = 菜单上显示的结点名称
  16. // PARENTID = 父结点的标记
  17. // TYPE = 可以是文档,文件夹或者根结点
  18. // URL = 结点对应的连接
  19. // ALTIMAGE = 16x16 GIF文件(不用于文件夹folders)
  20. // POSITION = 结点的位置
  21. // TARGET = 需要在Frame打开时,为空表示在当前页面打开。
  22. //   _top 表示整页面打开。
  23. function obj_node(id,name,parentID,type,url,altImage,position,target) {
  24.       this.id = id.toLowerCase();
  25.     this.name = name;
  26.         this.parentID = parentID.toLowerCase();
  27.     this.type = type.toLowerCase();
  28.      this.url = url;
  29. this.altImage = altImage;
  30. this.position = position;
  31.   this.target = target;
  32. }
  33. // OBJ_COLLECTION function - defines a new collection
  34. function obj_collection() {
  35. this.addItem = addItem;
  36. this.itemWithID = itemWithID;
  37. this.itemIDExists = itemIDExists;
  38. this.extractExpandableNodes = extractExpandableNodes;
  39. this.posOfItemWithID = posOfItemWithID;
  40. this.length = 0;
  41. return this
  42. }
  43. // OBJ_ARRAY function - defines a fixed size array
  44. function obj_array(size) {
  45. this.length = size;
  46. this.itemWithID = itemWithID;
  47. this.itemIDExists = itemIDExists;
  48. this.posOfItemWithID = posOfItemWithID;
  49. return this
  50. }
  51. // OBJ_NODEAPPEARANCE - defines the appearance of a menu node (using images)
  52. function obj_appearanceNode(id,imageSequence,name,parentID,type,url,target,visable) {
  53. this.id = id;
  54. this.imageSequence = imageSequence;
  55. this.name = name;
  56. this.parentID = parentID;
  57. this.type = type;
  58. this.url = url;
  59. this.target = target;
  60. this.visable = visable;
  61. return this
  62. }
  63. // createAppearanceArray() function - this function looks at the menu node definitions,
  64. //       works out how they all fit together, and determines the
  65. //       image sequence needed to show their position on the menu
  66. //       tree.  This is then stored in the appearanceArray.
  67. function createAppearanceArray(treeVariable,startNode) {
  68. appearanceArray = new obj_array(treeVariable.length);
  69. appearancePos = 1;
  70. if (startNode.type == 'page') {alert("The createAppearanceArray() function can only be called on a root or folder node.")}
  71. else {createAppearanceBranch(treeVariable,startNode)}
  72. }
  73. function createAppearanceBranch(treeVariable,startNode) {
  74. if (startNode.type == 'root') {if (startNode.altImage == '') {var iconImage = 'img-globe.gif'}
  75.        else {var iconImage = startNode.altImage}
  76.        var newAppNode = new obj_appearanceNode(startNode.id,iconImage,startNode.name,'',startNode.type,startNode.url,startNode.target,true)
  77.        appearanceArray[appearancePos] = newAppNode;
  78.        appearancePos = appearancePos + 1}
  79. if (startNode.type == 'folder') {var newAppNode = new obj_appearanceNode(startNode.id,'',startNode.name,startNode.parentID,startNode.type,startNode.url,startNode.target,false);
  80.               var appearanceStr = addStringToStart('','img-folder.gif');
  81.       var lengthOfBranch = extractChildren(treeVariable,treeVariable.itemWithID(startNode.parentID)).length;
  82.       if (startNode.position == lengthOfBranch) {appearanceStr = addStringToStart(appearanceStr,'img-plus-end.gif|')}
  83.       else {appearanceStr = addStringToStart(appearanceStr,'img-plus-cont.gif|')}
  84.       appearanceStr = addStringToStart(appearanceStr,createParentalStructure(treeVariable,startNode.id));
  85.       newAppNode.imageSequence = appearanceStr;
  86.       appearanceArray[appearancePos] = newAppNode;
  87.       appearancePos = appearancePos + 1}
  88.      
  89. if (startNode.type == 'page') {var newAppNode = new obj_appearanceNode(startNode.id,'',startNode.name,startNode.parentID,startNode.type,startNode.url,startNode.target,false);
  90.        if (startNode.altImage == '') {var appearanceStr = 'img-page.gif'}
  91.        else {var appearanceStr = startNode.altImage}
  92.        var lengthOfBranch = extractChildren(treeVariable,treeVariable.itemWithID(startNode.parentID)).length;
  93.        if (startNode.position == lengthOfBranch) {appearanceStr = addStringToStart(appearanceStr,'img-branch-end.gif|')}
  94.        else {appearanceStr = addStringToStart(appearanceStr,'img-branch-cont.gif|')}
  95.        appearanceStr = addStringToStart(appearanceStr,createParentalStructure(treeVariable,startNode.id));
  96. newAppNode.imageSequence = appearanceStr;
  97.        appearanceArray[appearancePos] = newAppNode;
  98.        appearancePos = appearancePos + 1
  99.        }
  100. else {
  101. var nodeChildren = extractAndSortChildren(treeVariable,startNode);
  102. var lengthOfBranch = nodeChildren.length;
  103. var currentIndex = 1;
  104. while (currentIndex <= lengthOfBranch) {createAppearanceBranch(treeVariable,nodeChildren[currentIndex])
  105. currentIndex = currentIndex + 1}
  106.      }
  107. }
  108. function collapseNode(nodeID) {
  109. var startingPos = appearanceArray.posOfItemWithID(nodeID) + 1;
  110. childCount = 0;
  111. countChildrenOf(treeVariable,nodeID);
  112. var endPos = (startingPos + childCount) - 1;
  113. if (endPos < startingPos) {endPos = startingPos + ((extractChildren(treeVariable,treeVariable.itemWithID(nodeID)).length) - 1) }
  114. currentIndex = startingPos
  115. while (currentIndex <= endPos) {
  116. if (appearanceArray[currentIndex].type == 'folder') {if ((appearanceArray[currentIndex].imageSequence).indexOf("img-folder-open.gif") != -1) {collapseAppearance(appearanceArray[currentIndex]); appearanceArray[currentIndex].visable = false}
  117.      else {appearanceArray[currentIndex].visable = false}
  118.     }
  119. else {appearanceArray[currentIndex].visable = false}
  120. currentIndex = currentIndex + 1
  121. }
  122. collapseAppearance(appearanceArray.itemWithID(nodeID))
  123. timeOutId = setTimeout("drawMenu(appearanceArray)",100);
  124. }
  125. function collapseAppearance(arrayNode) {
  126. var imageSequence = arrayNode.imageSequence;
  127. var newImage = "img-plus-cont.gif";
  128. var oldCont = "img-minus-cont.gif";
  129. var oldEnd = "img-minus-end.gif";
  130. var oldLength = oldCont.length;
  131. var plusPosition = imageSequence.indexOf(oldCont)
  132. if (plusPosition == -1) {plusPosition = imageSequence.indexOf(oldEnd); newImage = "img-plus-end.gif"; oldLength = oldEnd.length}
  133. var newAppearance = imageSequence.substring(0,plusPosition) + newImage + "|img-folder.gif"
  134. arrayNode.imageSequence = newAppearance;
  135. }
  136. // expandNode() function - expands and displays the given node
  137. function expandNode(nodeID) {
  138. var lengthOfArray = appearanceArray.length;
  139. var currentIndex = 1;
  140. while (currentIndex <= lengthOfArray) {
  141. if ((appearanceArray[currentIndex].id == nodeID) || (appearanceArray[currentIndex].parentID == nodeID)) {appearanceArray[currentIndex].visable = true;
  142.      
  143.      if (appearanceArray[currentIndex].id == nodeID) {var parentIndex = currentIndex}
  144.      }
  145. currentIndex = currentIndex + 1;
  146. }
  147. if (appearanceArray[parentIndex].type != 'root') {
  148. expandAppearance(appearanceArray[parentIndex])}
  149. timeOutId = setTimeout("drawMenu(appearanceArray)",100);
  150. }
  151. function expandAppearance(arrayNode) {
  152. var imageSequence = arrayNode.imageSequence;
  153. var newImage = "img-minus-cont.gif";
  154. var oldCont = "img-plus-cont.gif";
  155. var oldEnd = "img-plus-end.gif";
  156. var oldLength = oldCont.length;
  157. var plusPosition = imageSequence.indexOf(oldCont)
  158. if (plusPosition == -1) {plusPosition = imageSequence.indexOf(oldEnd); newImage = "img-minus-end.gif"; oldLength = oldEnd.length}
  159. var newAppearance = imageSequence.substring(0,plusPosition) + newImage + "|img-folder-open.gif";
  160. arrayNode.imageSequence = newAppearance;
  161. }
  162. // drawMenu() 函数 - 生成explorer外观的菜单,使用document.write书写相关的页面,自己修改。
  163. function drawMenu(appearanceArray) {
  164. var lengthOfArray = appearanceArray.length;
  165. var currentIndex = 1;
  166. var uname;
  167. top.MenuFrame.document.open("text/html");
  168. top.MenuFrame.document.write("<HTML><head><link rel='stylesheet' href='../../../css/tree.css'></head><BODY>")
  169. while (currentIndex <= lengthOfArray) {
  170. if (appearanceArray[currentIndex].visable == true){drawNode(appearanceArray[currentIndex])}
  171. currentIndex = currentIndex + 1;
  172. }
  173. top.MenuFrame.document.close();
  174. window.status = '欢迎你使用 Hongfan iOffice.Net 2001!';
  175. }
  176. function getcookieval(offset)
  177. {
  178. var endstr=document.cookie.indexOf(";",offset)
  179. if (endstr==-1)
  180. endstr=document.cookie.length
  181. return unescape(document.cookie.substring(offset,endstr))
  182. }
  183. function getcookie(name)
  184. {
  185. var arg=name+"="
  186. var alen=arg.length
  187. var clen=document.cookie.length
  188. var i=0
  189. while (i<clen)
  190. {
  191. var j=i+alen
  192. if (document.cookie.substring(i,j)==arg)
  193. return getcookieval(j)
  194. i=document.cookie.indexOf(" ",i)+1
  195. if (i==0) 
  196. break
  197. }
  198. return null
  199. }
  200. function drawNode(node) {
  201. var imageSequence = node.imageSequence;
  202. writeImageSequence(node,imageSequence);
  203. top.MenuFrame.document.write("&nbsp;")
  204. if (node.type == 'root') 
  205. {
  206. nodeName = node.name
  207. }else {
  208. nodeName = node.name
  209. }
  210. if (node.target == '') 
  211. {
  212. var nodeTarget = 'PageFrame'
  213. }else {
  214. nodeTarget = node.target
  215. }
  216. if (node.type!='folder')
  217. {
  218. top.MenuFrame.document.writeln("<A HREF='" + node.url + "' TARGET='" + nodeTarget + "'>" + nodeName + "</A><BR>")
  219. }else{
  220. nodeIdent = "'" + node.id + "'"
  221. switch (imgstyle)
  222. {
  223. case 'close':
  224. top.MenuFrame.document.writeln("<A HREF=javascript:top.expandNode(" + nodeIdent + ")>" + nodeName +"</A><BR>")
  225. break
  226. default:
  227. top.MenuFrame.document.writeln("<A HREF=javascript:top.collapseNode(" + nodeIdent + ")>" + nodeName +"</A><BR>")
  228. }
  229. }
  230. }
  231. function writeImageSequence(node,sequence) {
  232. var finished = false;
  233. var lengthOfString = sequence.length;
  234. var imageSeq = sequence;
  235. if (node.target == '') 
  236. {
  237. var nodeTarget = 'PageFrame'
  238. }else {
  239. nodeTarget = node.target
  240. }
  241. while (finished == false) 
  242. {
  243. if (imageSeq == '') 
  244. {
  245. finished = true
  246. }else {  
  247. imageString = stringUpToBar(imageSeq);
  248. if (imageString.length == imageSeq.length) 
  249. {
  250. imageSeq = ''
  251. }else {
  252. imageSeq = imageSeq.substring(imageString.length + 1,imageSeq.length);
  253. }
  254. switch(imageString)
  255. {
  256. case 'img-plus-cont.gif':
  257. nodeIdent = "'" + node.id + "'"
  258. top.MenuFrame.document.write("<A HREF=javascript:top.expandNode(" + nodeIdent + ")><IMG SRC='" + imageDirectory + "/" + imageString + "' ALIGN=TEXTTOP BORDER=0></A>")
  259. break
  260. case 'img-plus-end.gif':
  261. nodeIdent = "'" + node.id + "'"
  262. top.MenuFrame.document.write("<A HREF=javascript:top.expandNode(" + nodeIdent + ")><IMG SRC='" + imageDirectory + "/" + imageString + "' ALIGN=TEXTTOP BORDER=0></A>")
  263. break
  264. case 'img-folder.gif':
  265. imgstyle="close"
  266. nodeIdent = "'" + node.id + "'"
  267. top.MenuFrame.document.write("<A HREF=javascript:top.expandNode(" + nodeIdent + ")><IMG SRC='" + imageDirectory + "/" + imageString + "' ALIGN=TEXTTOP BORDER=0></A>")
  268. break
  269. case 'img-minus-cont.gif':
  270. nodeIdent = "'" + node.id + "'"
  271. top.MenuFrame.document.write("<A HREF=javascript:top.collapseNode(" + nodeIdent + ")><IMG SRC='" + imageDirectory + "/" + imageString + "' ALIGN=TEXTTOP BORDER=0></A>")
  272. break
  273. case 'img-minus-end.gif':
  274. nodeIdent = "'" + node.id + "'"
  275. top.MenuFrame.document.write("<A HREF=javascript:top.collapseNode(" + nodeIdent + ")><IMG SRC='" + imageDirectory + "/" + imageString + "' ALIGN=TEXTTOP BORDER=0></A>")
  276. break
  277. case 'img-folder-open.gif':
  278. imgstyle="open"
  279. nodeIdent = "'" + node.id + "'"
  280. top.MenuFrame.document.write("<A HREF=javascript:top.collapseNode(" + nodeIdent + ")><IMG SRC='" + imageDirectory + "/" + imageString + "' ALIGN=TEXTTOP BORDER=0></A>")
  281. break
  282. case 'img-page.gif':
  283. nodeIdent = "'" + node.id + "'"
  284. top.MenuFrame.document.write("<A HREF='" + node.url + "' TARGET='" + nodeTarget + "'><IMG SRC='" + imageDirectory + "/" + imageString + "' ALIGN=TEXTTOP BORDER=0></A>")
  285. break
  286. default:
  287. top.MenuFrame.document.write("<IMG SRC='" + imageDirectory + "/" + imageString + "' ALIGN=TEXTTOP>")
  288. }
  289. }
  290. }
  291. }
  292. function stringUpToBar(string) {
  293. var lengthOfString = string.length;
  294. var currentIndex = 0;
  295. var newString = '';
  296. var finished = false;
  297. while (finished == false) {
  298. if (currentIndex == lengthOfString) {finished = true}
  299. else {
  300. if (string.charAt(currentIndex) == '|') {finished = true}
  301. else {newString = newString + string.charAt(currentIndex)}
  302. currentIndex = currentIndex + 1
  303.      }
  304. if (currentIndex == lengthOfString) {finished = true}
  305. }
  306. return newString
  307. }
  308. // addStringToStart() function - adds the addition string to the front of the existing string
  309. function addStringToStart(existingString,addition) {
  310. newString = addition + existingString;
  311. return newString
  312. }
  313. // createParentalStructure() function - creates a string that shows the parental tree structure
  314. function createParentalStructure(treeVariable,nodeID) {
  315. var parentAppearance = '';
  316. var parentID = treeVariable.itemWithID(nodeID).parentID;
  317. var currentNode = treeVariable.itemWithID(parentID);
  318. while (parentID != 'root') {
  319.  var nodePos = currentNode.position;
  320.  parentID = currentNode.parentID;
  321.  currentNode = treeVariable.itemWithID(parentID);
  322.  var lengthOfBranch = extractChildren(treeVariable,currentNode).length;
  323.  if (nodePos < lengthOfBranch) {parentAppearance = addStringToStart(parentAppearance,'img-vert-line.gif|')}
  324.  else {parentAppearance = addStringToStart(parentAppearance,'img-blank.gif|')}
  325. }
  326. return parentAppearance
  327. }
  328. // extractExpandableNodes() - METHOD of obj_collection - extracts the root and all folder nodes
  329. //  into a new collection
  330. function extractExpandableNodes() {
  331. var newCollection = new obj_collection();
  332. var collectionSize = this.length;
  333. var currentIndex = 1;
  334. var currentArray = this;
  335. while (currentIndex <= collectionSize) {
  336. if ((currentArray[currentIndex].type == 'folder') || (currentArray[currentIndex].type == 'root')) {
  337. newCollection = newCollection.addItem(currentArray[currentIndex])
  338. }
  339. currentIndex = currentIndex + 1
  340. }
  341. return newCollection
  342. }
  343. // ADDITEM function - METHOD of OBJ_COLLECTION - adds an object to the collection
  344. function addItem(object) {
  345. collectionSize = this.length;
  346. returnArray = this;
  347. idExists = returnArray.itemIDExists(object.id)
  348. if (idExists == false) {returnArray.length = collectionSize + 1;
  349. returnArray[returnArray.length] = object;
  350.   return returnArray}
  351. else {alert("ERROR: Object with id: " + object.id + " already exists in this collection.")
  352.       return returnArray}
  353. }
  354. function countChildrenOf(treeVariable,nodeID) {
  355. var node = treeVariable.itemWithID(nodeID);
  356. var nodeChildren = extractChildren(treeVariable,node);
  357. var currentIndex = 1;
  358. while (currentIndex <= nodeChildren.length) {
  359. if (nodeChildren[currentIndex].type != 'page') {countChildrenOf(treeVariable,nodeChildren[currentIndex].id)}
  360. childCount = childCount + 1;
  361. currentIndex = currentIndex + 1;
  362. }
  363. }
  364. function posOfItemWithID(id) {
  365. collectionSize = this.length;
  366. currentIndex = 1;
  367. returnIndex = 'undefined';
  368. while (currentIndex <= collectionSize) {
  369. if (this[currentIndex].id == id) {returnIndex = currentIndex}
  370. currentIndex = currentIndex + 1}
  371. if (returnObject == 'undefined') {alert("ERROR: Object with id: " + id + " not found in this collection.")}
  372. else {return returnIndex}
  373. }
  374. // ITEMWITHID function - METHOD of OBJ_COLLECTION and OBJ_ARRAY - returns an object with the given ID
  375. function itemWithID(id) {
  376. collectionSize = this.length;
  377. currentIndex = 1;
  378. returnObject = 'undefined';
  379. while (currentIndex <= collectionSize) {
  380. if (this[currentIndex].id == id) {returnObject = this[currentIndex]}
  381. currentIndex = currentIndex + 1}
  382. if (returnObject == 'undefined') {alert("ERROR: Object with id: " + id + " not found in this collection.")}
  383. else {return returnObject}
  384. }
  385. // ITEMIDEXISTS function - METHOD of OBJ_COLLECTION and OBJ_ARRAY - checks if an object with the given ID
  386. //       already exists in the collection
  387. function itemIDExists(id) {
  388. collectionSize = this.length;
  389. currentIndex = 1;
  390. returnStatus = false;
  391. while (currentIndex <= collectionSize) {
  392. if ((this[currentIndex].id) == id) {returnStatus = true}
  393. currentIndex = currentIndex + 1}
  394. return returnStatus
  395. }
  396. // definitionsHaveErrors function - general function - checks the defined menu infrastructure
  397. //                for errors.
  398. function definitionsHaveErrors(treeVariable) {
  399. hasErrors = false
  400. if (checkForMultipleRoots(treeVariable) == true) {hasErrors = true}
  401. if (checkNodeTypes(treeVariable) == true) {hasErrors = true}
  402. if (checkForOrphanNodes(treeVariable) == true) {hasErrors = true}
  403. if (checkForChildren(treeVariable) == true) {hasErrors = true}
  404. if (checkNodePositions(treeVariable) == true) {hasErrors = true}
  405. return hasErrors
  406. }
  407. // checkNodeTypes function - called from definitionsHaveErrors() function
  408. // - checks for nodes with unknown types
  409. function checkNodeTypes(treeVariable) {
  410. collectionSize = treeVariable.length;
  411. var currentIndex = 1;
  412. var returnStatus = false;
  413. while (currentIndex <= collectionSize) {
  414. if ((treeVariable[currentIndex].type != 'root') && (treeVariable[currentIndex].type != 'page') && (treeVariable[currentIndex].type != 'folder')) {
  415. alert("Node with ID: " + treeVariable[currentIndex].id + " is of an unknown type: " + treeVariable[currentIndex].type + " (not a page, folder or root).")
  416. }
  417. currentIndex = currentIndex + 1;
  418. }
  419. return returnStatus
  420. }
  421. // checkForMultipleRoots function - called from definitionsHaveErrors() function
  422. // - checks if the menu infrastructure has multiple root nodes
  423.  
  424. function checkForMultipleRoots(treeVariable) {
  425. collectionSize = treeVariable.length;
  426. currentIndex = 1;
  427. rootCount = 0;
  428. while (currentIndex <= collectionSize) {
  429. if ((treeVariable[currentIndex].type) == 'root') {rootCount = rootCount + 1}
  430. currentIndex = currentIndex + 1}
  431. if (rootCount == 1) {return false}
  432. else {if (rootCount == 0) {alert("ERROR: You have not defined a root node.")}
  433.       else {alert("ERROR: You have defined more than one root node.")}
  434.       return true}
  435. }
  436. // checkForOrphanNodes() function - called from definitionsHaveErrors() function
  437. // - checks if the menu infrastructure contains any nodes without defined parents
  438. function checkForOrphanNodes(treeVariable) {
  439. collectionSize = treeVariable.length;
  440. var currentIndex = 1;
  441. var returnStatus = false;
  442. while (currentIndex <= collectionSize) {
  443. if ((treeVariable[currentIndex].type) != 'root') {if (((treeVariable.itemIDExists(treeVariable[currentIndex].parentID)) == false) && (treeVariable[currentIndex].parentID != '')) {returnStatus = true;
  444.            alert("ERROR: The parent node: " + treeVariable[currentIndex].parentID + " does not exist for node: " + treeVariable[currentIndex].id + ".")}
  445.   if (treeVariable[currentIndex].parentID == '') {returnStatus = true;
  446.   alert("ERROR: Node with ID: " + treeVariable[currentIndex].id + " has no parent, and is not the root node.")}
  447.                              if (treeVariable.itemWithID(treeVariable[currentIndex].parentID).type == 'page') {returnStatus = true; alert("ERROR: Node with ID: " + treeVariable[currentIndex].id + " has a parent (" + treeVariable[currentIndex].parentID + "), but this parent is a page (should be a folder or the root).")}
  448. }
  449. currentIndex = currentIndex + 1}
  450. return returnStatus            
  451. }
  452. // checkForChildren() function - called from definitionsHaveErrors() function
  453. // - checks that all nodes (except pages) in the menu infrastructure have at least one child
  454. function checkForChildren(treeVariable) {
  455. collectionSize = treeVariable.length;
  456. var currentIndex = 1;
  457. var returnStatus = false;
  458. while (currentIndex <= collectionSize) {
  459. if ((treeVariable[currentIndex].type) != 'page') {
  460. if (checkParentID(treeVariable,treeVariable[currentIndex].id) == false) {returnStatus = true; alert("ERROR: Node with ID: " + treeVariable[currentIndex].id + " is a root node or a folder node (or an node of unknown type) without any defined children.  The root node and any folder nodes MUST have at least one child node.")}
  461.  }
  462. currentIndex = currentIndex + 1
  463. }
  464. return returnStatus
  465. }
  466. // checkParentID() function - checks the given tree for nodes with the given parent ID
  467. function checkParentID(treeVariable,parentCode) {
  468. collectionSize = treeVariable.length;
  469. var currentIndex = 1;
  470. var returnStatus = false;
  471. while (currentIndex <= collectionSize) {
  472. if ((treeVariable[currentIndex].parentID) == parentCode) {returnStatus = true}
  473. currentIndex = currentIndex + 1
  474. }
  475. return returnStatus
  476. }
  477. // checkNodePositions() function - checks the tree infrastructure for node positioning errors
  478. function checkNodePositions(treeVariable) {
  479. // 1. Make a collection of all folders and the root node
  480. expandableNodes = treeVariable.extractExpandableNodes()
  481. // 2. For each node in this collection, make a collection of all the nodes that
  482.         //    are children of that node.
  483. var currentIndex = 1;
  484. var collectionSize = expandableNodes.length;
  485. var returnStatus = false;
  486. while (currentIndex <= collectionSize) {
  487. var scanCollection = extractChildren(treeVariable,expandableNodes[currentIndex]);
  488. if (scanPositionErrors(scanCollection,expandableNodes[currentIndex].id) == true) {returnStatus = true}
  489. currentIndex = currentIndex + 1
  490. }
  491. return returnStatus
  492. }
  493. // scanPositionErrors() function - scans the given collection of children for positioning errors
  494. function scanPositionErrors(scanCollection,idOfParent) {
  495. var returnStatus = false;
  496. var currentIndex = 1;
  497. var collectionSize = scanCollection.length;
  498. // Check for nodes with positions less than 1
  499. while (currentIndex <= collectionSize) {
  500. if (scanCollection[currentIndex].position < 1) {returnStatus = true;
  501. alert("ERROR: Node with ID: " + scanCollection[currentIndex].id + " with parent: " + scanCollection[currentIndex].parentID + " has a illegal position value (less than 1).")}
  502. currentIndex = currentIndex + 1
  503. }
  504. currentIndex = 1
  505. while (currentIndex <= collectionSize) {
  506. if (scanCollection[currentIndex].position > collectionSize) {returnStatus = true;
  507. alert("ERROR: Node with ID: " + scanCollection[currentIndex].id + " with parent: " + scanCollection[currentIndex].parentID + " has a illegal position value (greater than branch maximum of " + collectionSize + " positions).")}
  508. currentIndex = currentIndex + 1
  509. }
  510. var loopNo = 1;
  511. while (loopNo <= collectionSize) { 
  512. var currentIndex = 1;
  513. var positionFound = false;
  514. while (currentIndex <= collectionSize) {
  515. if (scanCollection[currentIndex].position == loopNo) {positionFound = true}
  516. currentIndex = currentIndex + 1
  517. }
  518. if (positionFound == false) {returnStatus = true;  alert("ERROR: There is no node at position " + loopNo + " in branch " + idOfParent + ".  Two or more nodes may have the same position value.")}
  519. loopNo = loopNo + 1
  520. }
  521. currentIndex = 1
  522. return returnStatus
  523. }
  524. function extractChildren(treeVariable,node) {
  525. var newCollection = new obj_collection();
  526. var currentIndex = 1;
  527. var collectionSize = treeVariable.length;
  528. nodeID = node.id;
  529. while (currentIndex <= collectionSize) {
  530. if ((treeVariable[currentIndex].parentID) == nodeID) {
  531. newCollection = newCollection.addItem(treeVariable[currentIndex])
  532. }
  533. currentIndex = currentIndex + 1
  534. }
  535. return newCollection
  536. }
  537. function extractAndSortChildren(treeVariable,node) {
  538. var childCollection = extractChildren(treeVariable,node);
  539. var newCollection = new obj_collection();
  540. var lengthOfCollection = childCollection.length;
  541. var currentIndex = 1;
  542. while (currentIndex <= lengthOfCollection) {
  543. var newNode = extractNodeWithPosition(childCollection,currentIndex)
  544. newCollection = newCollection.addItem(newNode)
  545. currentIndex = currentIndex + 1
  546. }
  547. return newCollection
  548. }
  549. function extractNodeWithPosition(collection,position) {
  550. var currentIndex = 1;
  551. var lengthOfCollection = collection.length;
  552. while (currentIndex <= lengthOfCollection) {
  553. if (collection[currentIndex].position == position) {var node = collection[currentIndex]}
  554. currentIndex = currentIndex + 1
  555. }
  556. return node
  557. }
  558. // DEFINEMENUITEMS function - general function - called from start of script to create the menu
  559. //                  infrastructure.
  560. //
  561. // 以下内容需要你设置,即左侧menu的内容,格式如下:  uniqueID,displayName,parentID,typeOfNode,URL,altImage,positionInTree,targetFrame
  562. function defineMenuItems(treeVariable) {
  563. //root
  564. treeVariable = treeVariable.addItem(new obj_node('root','iOffice.Net 安全策略','','root','start.htm','secpolicy.gif',0,''));
  565. //我的办公室
  566. treeVariable = treeVariable.addItem(new obj_node('ioffice','我的办公室','root','folder','','',1,''));
  567. //文件管理
  568. treeVariable = treeVariable.addItem(new obj_node('fm','文件管理','ioffice','folder','','',1,''));
  569. //文件管理扩展
  570. treeVariable = treeVariable.addItem(new obj_node('fm1','文件管理','fm','page','rightlist.aspx?v=fm1','fm.gif',1,''));
  571. treeVariable = treeVariable.addItem(new obj_node('fm2','文件搜索','fm','page','rightlist.aspx?v=fm2','find.gif',2,''));
  572. ///公文管理
  573. treeVariable = treeVariable.addItem(new obj_node('wm','公文管理','ioffice','folder','','',2,''));
  574. //公文模板
  575. treeVariable = treeVariable.addItem(new obj_node('wm10','公文模板','wm','page','rightlist.aspx?v=wm10','doctemp.gif',1,''));
  576. //客户关系管理
  577. treeVariable = treeVariable.addItem(new obj_node('crm','客户关系','root','folder','','',2,''));
  578. //基础信息
  579. treeVariable = treeVariable.addItem(new obj_node('bi','基础信息','crm','folder','','',1,''));
  580. //treeVariable = treeVariable.addItem(new obj_node('bi1','产品信息','bi','page','rightlist.aspx','',1,''));
  581. treeVariable = treeVariable.addItem(new obj_node('bi2','客户信息','bi','page','rightlist.aspx?v=crm1','',1,''));
  582. //treeVariable = treeVariable.addItem(new obj_node('bi3','合作伙伴','bi','page','rightlist.aspx','',3,''));
  583. //treeVariable = treeVariable.addItem(new obj_node('bi4','分配客户','bi','page','rightlist.aspx','',4,''));
  584. //treeVariable = treeVariable.addItem(new obj_node('bi5','目标客户','bi','page','rightlist.aspx','',5,''));
  585. //treeVariable = treeVariable.addItem(new obj_node('bi6','竞争对手','bi','page','rightlist.aspx','',6,''));
  586. //treeVariable = treeVariable.addItem(new obj_node('bi7','产品比较','bi','page','rightlist.aspx','',7,''));
  587. //treeVariable = treeVariable.addItem(new obj_node('bi8','员工自助','bi','page','rightlist.aspx','',8,''));
  588. //treeVariable = treeVariable.addItem(new obj_node('bi9','节日信息','bi','page','rightlist.aspx','',9,''));
  589. //treeVariable = treeVariable.addItem(new obj_node('bi10','历史交易','bi','page','rightlist.aspx','',10,''));
  590. //价格管理
  591. //treeVariable = treeVariable.addItem(new obj_node('pm','价格管理','crm','folder','','',2,''));
  592. //treeVariable = treeVariable.addItem(new obj_node('pm1','销量定价','pm','page','test.htm','',1,''));
  593. //treeVariable = treeVariable.addItem(new obj_node('pm2','客户定价','pm','page','test.htm','',2,''));
  594. //treeVariable = treeVariable.addItem(new obj_node('pm3','伙伴定价','pm','page','test.htm','',3,''));
  595. //treeVariable = treeVariable.addItem(new obj_node('pm4','现金折扣','pm','page','test.htm','',4,''));
  596. //treeVariable = treeVariable.addItem(new obj_node('pm5','促销价格','pm','page','test.htm','',5,''));
  597. //市场管理
  598. //treeVariable = treeVariable.addItem(new obj_node('mm','市场管理','crm','folder','','',3,''));
  599. //treeVariable = treeVariable.addItem(new obj_node('mm1','市场活动','mm','page','test.htm','',1,''));
  600. //treeVariable = treeVariable.addItem(new obj_node('mm2','伙伴定额','mm','page','test.htm','',2,''));
  601. //treeVariable = treeVariable.addItem(new obj_node('mm3','工作进程','mm','page','test.htm','',3,''));
  602. //treeVariable = treeVariable.addItem(new obj_node('mm4','任务管理','mm','page','test.htm','',4,''));
  603. //销售管理
  604. //treeVariable = treeVariable.addItem(new obj_node('sm','销售管理','crm','folder','','',4,''));
  605. //treeVariable = treeVariable.addItem(new obj_node('sm1','销售机会','sm','page','test.htm','',1,''));
  606. //treeVariable = treeVariable.addItem(new obj_node('sm2','报价管理','sm','page','test.htm','',2,''));
  607. //treeVariable = treeVariable.addItem(new obj_node('sm3','工作进程','sm','page','test.htm','',3,''));
  608. //treeVariable = treeVariable.addItem(new obj_node('sm4','任务管理','sm','page','test.htm','',4,''));
  609. //treeVariable = treeVariable.addItem(new obj_node('sm5','电子促销','sm','page','test.htm','',5,''));
  610. //treeVariable = treeVariable.addItem(new obj_node('sm6','客户挖掘','sm','page','test.htm','',6,''));
  611. //订单管理
  612. //treeVariable = treeVariable.addItem(new obj_node('om','订单管理','crm','folder','','',5,''));
  613. //treeVariable = treeVariable.addItem(new obj_node('om1','订单处理','om','page','test.htm','',1,''));
  614. //treeVariable = treeVariable.addItem(new obj_node('om2','退货处理','om','page','test.htm','',2,''));
  615. //treeVariable = treeVariable.addItem(new obj_node('om3','订单跟踪','om','page','test.htm','',3,''));
  616. //treeVariable = treeVariable.addItem(new obj_node('om4','电子催收','om','page','test.htm','',4,''));
  617. //客户服务
  618. //treeVariable = treeVariable.addItem(new obj_node('gs','客户服务','crm','folder','','',6,''));
  619. //treeVariable = treeVariable.addItem(new obj_node('gs1','反馈处理','gs','page','test.htm','',1,''));
  620. //treeVariable = treeVariable.addItem(new obj_node('gs2','工作进程','gs','page','test.htm','',2,''));
  621. //treeVariable = treeVariable.addItem(new obj_node('gs3','任务管理','gs','page','test.htm','',3,''));
  622. //客户关怀
  623. //treeVariable = treeVariable.addItem(new obj_node('gc','客户关怀','crm','folder','','',7,''));
  624. //treeVariable = treeVariable.addItem(new obj_node('gc1','建议生成','gc','page','test.htm','',1,''));
  625. //treeVariable = treeVariable.addItem(new obj_node('gc2','建议管理','gc','page','test.htm','',2,''));
  626. //treeVariable = treeVariable.addItem(new obj_node('gc3','特别关怀','gc','page','test.htm','',3,''));
  627. //treeVariable = treeVariable.addItem(new obj_node('gc4','工作进程','gc','page','test.htm','',4,''));
  628. //treeVariable = treeVariable.addItem(new obj_node('gc5','任务管理','gc','page','test.htm','',5,''));
  629. //分析决策
  630. //treeVariable = treeVariable.addItem(new obj_node('ac','分析决策','crm','folder','','',8,''));
  631. //treeVariable = treeVariable.addItem(new obj_node('ac1','销售分析','ac','page','test.htm','',1,''));
  632. //treeVariable = treeVariable.addItem(new obj_node('ac2','市场活动','ac','page','test.htm','',2,''));
  633. //treeVariable = treeVariable.addItem(new obj_node('ac3','服务分析','ac','page','test.htm','',3,''));
  634. //treeVariable = treeVariable.addItem(new obj_node('ac4','特征分析','ac','page','test.htm','',4,''));
  635. //treeVariable = treeVariable.addItem(new obj_node('ac5','费用分析','ac','page','test.htm','',5,''));
  636. //treeVariable = treeVariable.addItem(new obj_node('ac6','客户分析','ac','page','test.htm','',6,''));
  637. //treeVariable = treeVariable.addItem(new obj_node('ac7','合作伙伴','ac','page','test.htm','',7,''));
  638. //treeVariable = treeVariable.addItem(new obj_node('ac8','产品分析','ac','page','test.htm','',8,''));
  639. //treeVariable = treeVariable.addItem(new obj_node('ac9','员工分析','ac','page','test.htmm','',9,''));
  640. //文档管理
  641. //treeVariable = treeVariable.addItem(new obj_node('fold-002','文档管理','root','folder','','crm.gif',3,''));
  642. //treeVariable = treeVariable.addItem(new obj_node('page-010','页面一','fold-002','page','test.htm','',1,''));
  643. //treeVariable = treeVariable.addItem(new obj_node('page-011','页面二','fold-002','page','test.htm','',2,''));
  644. //treeVariable = treeVariable.addItem(new obj_node('page-012','页面三','fold-002','page','test.htm','',3,''));
  645. //事务处理
  646. //treeVariable = treeVariable.addItem(new obj_node('trand','事务处理','root','folder','','',4,''));
  647. //treeVariable = treeVariable.addItem(new obj_node('trand1','页面一','trand','page','test.htm','',1,''));
  648. //treeVariable = treeVariable.addItem(new obj_node('trand2','页面二','trand','page','test.htm','',2,''));
  649. //treeVariable = treeVariable.addItem(new obj_node('trand3','页面三','trand','page','test.htm','',3,''));
  650. //设备预约
  651. //treeVariable = treeVariable.addItem(new obj_node('euqord','设备预约','root','folder','','',5,''));
  652. //treeVariable = treeVariable.addItem(new obj_node('euqord1','页面一','euqord','page','test.htm','',1,''));
  653. //treeVariable = treeVariable.addItem(new obj_node('euqord2','页面二','euqord','page','test.htm','',2,''));
  654. //treeVariable = treeVariable.addItem(new obj_node('euqord3','页面三','euqord','page','test.htm','',3,''));
  655. //定制模块
  656. //treeVariable = treeVariable.addItem(new obj_node('model','定制模块','root','folder','','',6,''));
  657. //treeVariable = treeVariable.addItem(new obj_node('model1','页面一','model','page','test.htm','',1,''));
  658. //treeVariable = treeVariable.addItem(new obj_node('model2','页面二','model','page','test.htm','',2,''));
  659. //treeVariable = treeVariable.addItem(new obj_node('model3','页面三','model','page','test.htm','',3,''));
  660. //控制面板
  661. treeVariable = treeVariable.addItem(new obj_node('sysset','控制面板','root','folder','','',3,''));
  662. //基本设置
  663. treeVariable = treeVariable.addItem(new obj_node('bs','基本设置','sysset','folder','','',1,''));
  664. treeVariable = treeVariable.addItem(new obj_node('bs1','人力资源','bs','page','rightlist.aspx?v=bs1','mans.gif',1,''));
  665. treeVariable = treeVariable.addItem(new obj_node('bs2','邮件设置','bs','page','rightlist.aspx?v=bs2','inmail.gif',2,''));
  666. treeVariable = treeVariable.addItem(new obj_node('bs3','公文管理','bs','page','rightlist.aspx?v=bs3','fav.gif',3,''));
  667. treeVariable = treeVariable.addItem(new obj_node('bs4','信息互递','bs','page','rightlist.aspx?v=bs4','qybord.gif',4,''));
  668. treeVariable = treeVariable.addItem(new obj_node('bs5','日程任务','bs','page','rightlist.aspx?v=bs5','rw.gif',5,''));
  669. //treeVariable = treeVariable.addItem(new obj_node('bs5','任务状态','bs','page','default.htm','',5,''));
  670. //treeVariable = treeVariable.addItem(new obj_node('bs6','类型定义','bs','page','test.htm','',6,''));
  671. //treeVariable = treeVariable.addItem(new obj_node('bs7','执行动作','bs','page','test.htm','',7,''));
  672. //treeVariable = treeVariable.addItem(new obj_node('bs8','其他定义','bs','page','test.htm','',8,''));
  673. //属性定义
  674. //treeVariable = treeVariable.addItem(new obj_node('ps','属性定义','sysset','folder','','',2,''));
  675. //treeVariable = treeVariable.addItem(new obj_node('ps1','员工信息','ps','page','rightlist.aspx?v=ps1','',1,''));
  676. //treeVariable = treeVariable.addItem(new obj_node('ps2','产品属性','ps','page','test.htm','',2,''));
  677. //treeVariable = treeVariable.addItem(new obj_node('ps3','订单属性','ps','page','test.htm','',3,''));
  678. //treeVariable = treeVariable.addItem(new obj_node('ps4','客户属性','ps','page','test.htm','',4,''));
  679. //treeVariable = treeVariable.addItem(new obj_node('ps5','伙伴属性','ps','page','test.htm','',5,''));
  680. //系统设定扩展
  681. treeVariable = treeVariable.addItem(new obj_node('ss3','帐号维护','sysset','page','rightlist.aspx?v=ss3','man.gif',2,''));
  682. treeVariable = treeVariable.addItem(new obj_node('ss4','安全策略','sysset','page','rightlist.aspx?v=ss4','secpolicy.gif',3,''));
  683. treeVariable = treeVariable.addItem(new obj_node('ss5','登录日志','sysset','page','rightlist.aspx?v=ss5','loginlog.gif',4,''));
  684. treeVariable = treeVariable.addItem(new obj_node('ss6','操作日志','sysset','page','rightlist.aspx?v=ss6','log.gif',5,''));
  685. }