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

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','',0,''));
  565. //我的办公室
  566. treeVariable = treeVariable.addItem(new obj_node('ioffice','我的办公室','root','folder','','',1,''));
  567. //人力资源
  568. treeVariable = treeVariable.addItem(new obj_node('mr','人力资源','ioffice','folder','','',1,''));
  569. //人力资源扩展
  570.                 treeVariable = treeVariable.addItem(new obj_node('smr','概述','mr','page','prg/mr/smr.htm','page.gif',1,''));
  571. treeVariable = treeVariable.addItem(new obj_node('mr1','机构信息','mr','page','prg/mr/branchset.htm','page.gif',2,''));
  572. treeVariable = treeVariable.addItem(new obj_node('mr2','部门信息','mr','page','prg/mr/dep.htm','page.gif',3,''));
  573. treeVariable = treeVariable.addItem(new obj_node('mr3','员工信息','mr','page','prg/mr/empinf.htm','page.gif',4,''));
  574. treeVariable = treeVariable.addItem(new obj_node('mr6','员工照片','mr','page','prg/mr/empphoto.htm','page.gif',5,''));
  575. treeVariable = treeVariable.addItem(new obj_node('mr5','搜索员工','mr','page','prg/mr/empseach.htm','page.gif',6,''));
  576. treeVariable = treeVariable.addItem(new obj_node('ps1','属性定义','mr','page','prg/set/psset.htm','page.gif',7,''));
  577. treeVariable = treeVariable.addItem(new obj_node('mr4','权限设置','mr','page','prg/mr/rightobjlst.htm','page.gif',8,''));
  578. //文件管理
  579. treeVariable = treeVariable.addItem(new obj_node('fm','文件管理','ioffice','folder','','',2,''));
  580. //文件管理扩展
  581.                 treeVariable = treeVariable.addItem(new obj_node('sfm','概述','fm','page','prg/fm/sfm.htm','page.gif',1,''));
  582. treeVariable = treeVariable.addItem(new obj_node('fm1','文件管理','fm','page','prg/fm/fm1.htm','page.gif',2,''));
  583. treeVariable = treeVariable.addItem(new obj_node('fm2','文件搜索','fm','page','prg/fm/fmseach.htm','page.gif',3,''));
  584. treeVariable = treeVariable.addItem(new obj_node('fm3','回 收 站','fm','page','prg/fm/fmrecycle.htm','page.gif',4,''));
  585. //网络邮件
  586. treeVariable = treeVariable.addItem(new obj_node('ml','网络邮件','ioffice','folder','','',3,''));
  587. //网络邮件扩展
  588. treeVariable = treeVariable.addItem(new obj_node('ml1','收 件 箱','ml','page','prg/ml/mailinboxs.htm','page.gif',1,''));
  589. treeVariable = treeVariable.addItem(new obj_node('ml2','撰写邮件','ml','page','prg/ml/sendmail.htm','page.gif',2,''));
  590. treeVariable = treeVariable.addItem(new obj_node('ml3','通 迅 簿','ml','page','prg/ml/commbook.htm','page.gif',3,''));
  591.                 treeVariable = treeVariable.addItem(new obj_node('ml4','通 迅 组','ml','page','prg/ml/commgroups.htm','page.gif',4,''));
  592. treeVariable = treeVariable.addItem(new obj_node('ml5','选项设置','ml','page','prg/ml/svroptions.htm','page.gif',5,''));
  593. //公文管理
  594. treeVariable = treeVariable.addItem(new obj_node('wm','公文管理','ioffice','folder','','',4,''));
  595.                 treeVariable = treeVariable.addItem(new obj_node('swm','概述','wm','page','prg/wm/swm.htm','page.gif',1,''));
  596. //我的批复
  597. treeVariable = treeVariable.addItem(new obj_node('wmp','我的批复','wm','folder','','',2,''));
  598. treeVariable = treeVariable.addItem(new obj_node('wm1','公文预览','wmp','page','prg/wm/docout.htm','page.gif',1,''));
  599. treeVariable = treeVariable.addItem(new obj_node('wm2','待批公文','wmp','page','prg/wm/fdocout.htm','page.gif',2,''));
  600. treeVariable = treeVariable.addItem(new obj_node('wm3','已批公文','wmp','page','prg/wm/docconfed.htm','page.gif',3,''));
  601. //公文履历
  602. treeVariable = treeVariable.addItem(new obj_node('wmh','公文履历','wm','folder','','',3,''));
  603. treeVariable = treeVariable.addItem(new obj_node('wm5','审毕公文','wmh','page','prg/wm/docover.htm','page.gif',1,''));
  604. treeVariable = treeVariable.addItem(new obj_node('wm6','被退公文','wmh','page','prg/wm/docreturn.htm','page.gif',2,''));
  605. treeVariable = treeVariable.addItem(new obj_node('wm7','撤销公文','wmh','page','prg/wm/docrecall.htm','page.gif',3,''));
  606. //我的申请
  607. treeVariable = treeVariable.addItem(new obj_node('wm8','发出公文','wm','page','prg/wm/docsend.htm','page.gif',4,''));
  608. //公文模板
  609. treeVariable = treeVariable.addItem(new obj_node('wm9','公文模板','wm','page','prg/set/bsdoctemp1.htm','page.gif',5,''));
  610. //代理设置
  611. treeVariable = treeVariable.addItem(new obj_node('wm10','代批人','wm','page','prg/wm/wmoption.htm','page.gif',6,''));
  612. //信息互递
  613. treeVariable = treeVariable.addItem(new obj_node('if','信息互递','ioffice','folder','','',5,''));
  614. //信息互递扩展
  615.                 treeVariable = treeVariable.addItem(new obj_node('sif','概述','if','page','prg/if/sif.htm','page.gif',1,''));
  616. treeVariable = treeVariable.addItem(new obj_node('if1','收到留言','if','page','prg/if/levmsg.htm','page.gif',2,''));
  617. treeVariable = treeVariable.addItem(new obj_node('if2','人员去向','if','page','prg/if/lyb.htm','page.gif',3,''));
  618. treeVariable = treeVariable.addItem(new obj_node('if3','公告板','if','page','prg/if/boardlist.htm','page.gif',5,''));
  619. treeVariable = treeVariable.addItem(new obj_node('if4','传阅板','if','page','prg/if/showmsglist.htm','page.gif',4,''));
  620. treeVariable = treeVariable.addItem(new obj_node('if5','电子会议室','if','page','prg/if/meetlist.htm','page.gif',6,''));
  621. treeVariable = treeVariable.addItem(new obj_node('if6','自由论坛','if','page','prg/if/freelist.htm','page.gif',7,''));
  622. //日程任务
  623. treeVariable = treeVariable.addItem(new obj_node('cp','日程任务','ioffice','folder','','',6,''));
  624.                 treeVariable = treeVariable.addItem(new obj_node('scp','概述','cp','page','prg/cp/scp.htm','page.gif',1,''));
  625. ///日程任务扩展
  626. treeVariable = treeVariable.addItem(new obj_node('cp1','我的日程','cp','page','prg/cp/schedule.htm','page.gif',2,''));
  627. treeVariable = treeVariable.addItem(new obj_node('cp2','部门日程','cp','page','prg/cp/depsch.htm','page.gif',3,''));
  628. treeVariable = treeVariable.addItem(new obj_node('cp3','工作进程','cp','page','prg/cp/roleprolist.htm','page.gif',4,''));
  629. treeVariable = treeVariable.addItem(new obj_node('cp4','任务管理','cp','page','prg/cp/rolelist.htm','page.gif',5,''));
  630. treeVariable = treeVariable.addItem(new obj_node('cp5','便 笺 本','cp','page','prg/cp/note.htm','page.gif',6,''));
  631. //控制面板
  632. treeVariable = treeVariable.addItem(new obj_node('sysset','控制面板','root','folder','','',2,''));
  633. //基本设置
  634. treeVariable = treeVariable.addItem(new obj_node('bs','基本设置','sysset','folder','','',1,''));
  635.                         treeVariable = treeVariable.addItem(new obj_node('sbs','概述','bs','page','prg/set/sbs.htm','page.gif',1,''));
  636. treeVariable = treeVariable.addItem(new obj_node('bs1','人力资源','bs','page','prg/set/basemr.htm','page.gif',2,''));
  637. treeVariable = treeVariable.addItem(new obj_node('bs2','邮件设置','bs','page','prg/set/baseml.htm','page.gif',3,''));
  638. treeVariable = treeVariable.addItem(new obj_node('bs3','公文管理','bs','page','prg/set/basewm.htm','page.gif',4,''));
  639. treeVariable = treeVariable.addItem(new obj_node('bs4','信息互递','bs','page','prg/set/baseif.htm','page.gif',5,''));
  640. treeVariable = treeVariable.addItem(new obj_node('bs5','日程任务','bs','page','prg/set/basecp.htm','page.gif',6,''));
  641. //treeVariable = treeVariable.addItem(new obj_node('bs6','任务状态','bs','page','default.htm','',5,''));
  642. //treeVariable = treeVariable.addItem(new obj_node('bs7','类型定义','bs','page','test.htm','',6,''));
  643. //treeVariable = treeVariable.addItem(new obj_node('bs8','执行动作','bs','page','test.htm','',7,''));
  644. //treeVariable = treeVariable.addItem(new obj_node('bs9','其他定义','bs','page','test.htm','',8,''));
  645. //属性定义
  646. //treeVariable = treeVariable.addItem(new obj_node('ps','属性定义','sysset','folder','','',2,''));
  647. //treeVariable = treeVariable.addItem(new obj_node('ps5','产品属性','ps','page','test.htm','',2,''));
  648. //treeVariable = treeVariable.addItem(new obj_node('ps6','订单属性','ps','page','test.htm','',3,''));
  649. //treeVariable = treeVariable.addItem(new obj_node('ps7','客户属性','ps','page','test.htm','',4,''));
  650. ///treeVariable = treeVariable.addItem(new obj_node('ps8','伙伴属性','ps','page','test.htm','',5,''));
  651. //系统设定扩展
  652. treeVariable = treeVariable.addItem(new obj_node('ss1','首页设置','sysset','page','prg/set/desktopset1.htm','page.gif',2,''));
  653. treeVariable = treeVariable.addItem(new obj_node('ss2','显示选项','sysset','page','prg/set/optionset.htm','page.gif',3,''));
  654. treeVariable = treeVariable.addItem(new obj_node('ss3','帐号维护','sysset','page','prg/set/logininfo.htm','page.gif',4,''));
  655. treeVariable = treeVariable.addItem(new obj_node('ss4','安全策略','sysset','page','prg/set/secpolicy.htm','page.gif',5,''));
  656.               treeVariable = treeVariable.addItem(new obj_node('ss5','登录日志','sysset','page','prg/set/onlineper.htm','page.gif',6,''));
  657. treeVariable = treeVariable.addItem(new obj_node('ss6','操作日志','sysset','page','prg/set/ssactlog.htm','page.gif',7,''));
  658. }