1 | |
---|
2 | var strShapeName = "圖形名稱"; |
---|
3 | var strShapeText = "圖形文字"; |
---|
4 | var strProps = "圖形資料"; |
---|
5 | var strResults = "搜尋結果關於:"; |
---|
6 | |
---|
7 | var strShape = "圖形名稱:"; |
---|
8 | var strNoCustomPropertiesToDisplayText = "CTRL+按一下繪圖中的圖形以檢視詳細資料。"; |
---|
9 | |
---|
10 | var FindShapeXML = parent.FindShapeXML; |
---|
11 | var Unquote = parent.Unquote; |
---|
12 | var put_Location = parent.put_Location; |
---|
13 | |
---|
14 | |
---|
15 | var strChkBox = "Chkbox"; |
---|
16 | var strPropChkBox = "PropChkbox"; |
---|
17 | |
---|
18 | function doExpando(xxx,yyy){ |
---|
19 | if (xxx.style.display=="none"){ |
---|
20 | xxx.style.display = "" |
---|
21 | yyy.src = up.src; |
---|
22 | }else{ |
---|
23 | xxx.style.display = "none" |
---|
24 | yyy.src = down.src; |
---|
25 | } |
---|
26 | } |
---|
27 | |
---|
28 | function doExp(xxx,yyy){ |
---|
29 | if (xxx.style.display=="none"){ |
---|
30 | xxx.style.display = "" |
---|
31 | yyy.src = "minus.gif"; |
---|
32 | }else{ |
---|
33 | xxx.style.display = "none" |
---|
34 | yyy.src = "plus.gif"; |
---|
35 | } |
---|
36 | } |
---|
37 | |
---|
38 | |
---|
39 | function FindOnClick() |
---|
40 | { |
---|
41 | var count, indexOfString; |
---|
42 | |
---|
43 | var fieldsToSearchArray = new Array(); |
---|
44 | if (parent.xmlData != null && document.theForm[strProps + strChkBox].checked) |
---|
45 | { |
---|
46 | for( count=0; count < document.theForm.length; count++ ) |
---|
47 | { |
---|
48 | indexOfString = document.theForm[count].name.indexOf(strPropChkBox); |
---|
49 | if( -1 != indexOfString && document.theForm[count].checked ) |
---|
50 | { |
---|
51 | fieldsToSearchArray[ fieldsToSearchArray.length ] = document.theForm[count].name.slice(0, indexOfString); |
---|
52 | } |
---|
53 | } |
---|
54 | } |
---|
55 | |
---|
56 | var searchTokensArray = CreateSearchTokens (document.theForm.findString.value); |
---|
57 | |
---|
58 | if (searchTokensArray.length > 0) |
---|
59 | { |
---|
60 | var findArray = Find(searchTokensArray, fieldsToSearchArray); |
---|
61 | var ArrayLength = findArray.length; |
---|
62 | var strResultsHTML = "找不到相符項目。"; |
---|
63 | var lastPageID = null; |
---|
64 | var shapeID; |
---|
65 | |
---|
66 | |
---|
67 | if(ArrayLength > 0) |
---|
68 | { |
---|
69 | strResultsHTML = strResults + ' <b>'+ parent.HTMLEscape(document.theForm.findString.value) +'</b>'; |
---|
70 | for ( count = 0; count < ArrayLength; count++) |
---|
71 | { |
---|
72 | |
---|
73 | if( lastPageID != findArray[count].PageID ) |
---|
74 | { |
---|
75 | lastPageID = findArray[count].PageID; |
---|
76 | } |
---|
77 | |
---|
78 | shapeID = findArray[count].ShapeID; |
---|
79 | strResultsHTML += '<p class="results"><a href="javascript:populateSearchResultDetails(\'results_'+ lastPageID +'_'+ shapeID +'\', '+ lastPageID +','+ shapeID +'); TogglePlus(results_' + lastPageID + '_' + shapeID + ',\'img_' + lastPageID + '_' + shapeID + '\', hideResults)"><img src="plus.gif" alt="顯示/隱藏圖形詳細資料" width="13" height="9" border="0" id="img_'+ lastPageID +'_'+ shapeID +'"></a>\n' |
---|
80 | strResultsHTML += '<a class="blu1" href="JavaScript:FindQuerySelect('; |
---|
81 | |
---|
82 | strResultsHTML += findArray[count].PageID + ","; |
---|
83 | strResultsHTML += findArray[count].ShapeID + ","; |
---|
84 | strResultsHTML += findArray[count].PinX + ","; |
---|
85 | strResultsHTML += findArray[count].PinY; |
---|
86 | |
---|
87 | strResultsHTML += ')">'+ findArray[count].Title +'</a></p>\n' |
---|
88 | |
---|
89 | strResultsHTML += '</div>\n'; |
---|
90 | strResultsHTML += '<div class="indent" id="results_'+ lastPageID +'_'+ shapeID +'" style="display:none;width:100%;"></div>\n' |
---|
91 | } |
---|
92 | |
---|
93 | } |
---|
94 | var divAdvSrch = document.all("hideAdvSrch"); |
---|
95 | var imgAS0 = document.all("as0"); |
---|
96 | |
---|
97 | var tmpObj = document.all("hideResults"); |
---|
98 | if( tmpObj != null ) |
---|
99 | { |
---|
100 | tmpObj.innerHTML = strResultsHTML; |
---|
101 | tmpObj.open = "true"; |
---|
102 | tmpObj.style.display = "block"; |
---|
103 | } |
---|
104 | } |
---|
105 | } |
---|
106 | |
---|
107 | function CreateSearchTokens (strUserString) |
---|
108 | { |
---|
109 | var searchTokensArray = new Array(); |
---|
110 | |
---|
111 | var strToken = ""; |
---|
112 | var chCurChar; |
---|
113 | |
---|
114 | for (var count = 0; count < strUserString.length; count++) |
---|
115 | { |
---|
116 | chCurChar = strUserString.charAt(count); |
---|
117 | if (chCurChar == '"') |
---|
118 | { |
---|
119 | var nNextQuote = strUserString.indexOf('"', count + 1); |
---|
120 | if (nNextQuote >= 0) |
---|
121 | { |
---|
122 | strToken = strUserString.slice(count + 1, nNextQuote); |
---|
123 | searchTokensArray[searchTokensArray.length] = strToken; |
---|
124 | strToken = ""; |
---|
125 | count = nNextQuote; |
---|
126 | } |
---|
127 | } |
---|
128 | else if (chCurChar == ' ') |
---|
129 | { |
---|
130 | if (strToken.length > 0) |
---|
131 | { |
---|
132 | searchTokensArray[searchTokensArray.length] = strToken; |
---|
133 | } |
---|
134 | |
---|
135 | strToken = ""; |
---|
136 | } |
---|
137 | else |
---|
138 | { |
---|
139 | strToken += chCurChar; |
---|
140 | } |
---|
141 | } |
---|
142 | |
---|
143 | if (strToken.length > 0) |
---|
144 | { |
---|
145 | searchTokensArray[searchTokensArray.length] = strToken; |
---|
146 | } |
---|
147 | |
---|
148 | return searchTokensArray; |
---|
149 | } |
---|
150 | |
---|
151 | function populateSearchResultDetails( divID, pageID, shapeID ) |
---|
152 | { |
---|
153 | var tmpShape = FindShapeXML (pageID, shapeID); |
---|
154 | var strOutput = CreatePropTable( tmpShape ); |
---|
155 | |
---|
156 | var tmpObj = document.all(divID); |
---|
157 | if( tmpObj != null ) |
---|
158 | { |
---|
159 | tmpObj.innerHTML = strOutput; |
---|
160 | } |
---|
161 | } |
---|
162 | |
---|
163 | function makeAdvancedFindCheckboxes(div) |
---|
164 | { |
---|
165 | if (parent.xmlData) |
---|
166 | { |
---|
167 | var strOutput = ""; |
---|
168 | |
---|
169 | strOutput += "<INPUT type='checkbox' name='" + strShapeName + strChkBox + "' id='" + strShapeName + strChkBox + "' checked><label for='" + strShapeName + strChkBox + "'>" + strShapeName + "</label><br>\n"; |
---|
170 | strOutput += "<INPUT type='checkbox' name='" + strShapeText + strChkBox + "' id='" + strShapeText + strChkBox + "' checked><label for='" + strShapeText + strChkBox + "'>" + strShapeText + "</label><br>\n"; |
---|
171 | strOutput += "<INPUT type='checkbox' name='" + strProps + strChkBox + "' id='" + strProps + strChkBox + "' onclick='AdvSearchCustomPropCheck ()'checked ><label for='" + strProps + strChkBox + "'>" + strProps +"</label><br>\n"; |
---|
172 | strOutput += "<div id='divCPBoxes' style='margin-left:1em;'>"; |
---|
173 | |
---|
174 | var objNodes = parent.xmlData.selectNodes(".//Shape/Prop/Label"); |
---|
175 | var filter = ""; |
---|
176 | var boolFirstPass = true; |
---|
177 | var tmpPropName; |
---|
178 | while( objNodes.length > 0) |
---|
179 | { |
---|
180 | tmpPropName = objNodes.item( 0 ).text; |
---|
181 | var escapedPropName = parent.EscapeString(tmpPropName); |
---|
182 | if( true == boolFirstPass ) |
---|
183 | { |
---|
184 | filter = ". != '" + escapedPropName + "'"; |
---|
185 | boolFirstPass = false; |
---|
186 | } |
---|
187 | else |
---|
188 | { |
---|
189 | filter += " and . != '" + escapedPropName + "'"; |
---|
190 | } |
---|
191 | |
---|
192 | tmpPropName = parent.HTMLEscape (tmpPropName); |
---|
193 | strOutput += "<INPUT type='checkbox' name='" + tmpPropName + strPropChkBox + "' id='"+ tmpPropName + strPropChkBox + "' checked><label for='"+ tmpPropName + strPropChkBox + "'>" + tmpPropName +"</label><br>\n"; |
---|
194 | |
---|
195 | objNodes = parent.xmlData.selectNodes(".//Shape/Prop/Label["+ filter + "]"); |
---|
196 | } |
---|
197 | strOutput += "</div>" |
---|
198 | div.innerHTML = strOutput; |
---|
199 | } |
---|
200 | } |
---|
201 | |
---|
202 | function AdvSearchCustomPropCheck () |
---|
203 | { |
---|
204 | for( count=0; count < document.theForm.length; count++ ) |
---|
205 | { |
---|
206 | indexOfString = document.theForm[count].name.indexOf(strPropChkBox); |
---|
207 | if( -1 != indexOfString ) |
---|
208 | { |
---|
209 | document.theForm[count].disabled = !document.theForm[strProps + strChkBox].checked; |
---|
210 | } |
---|
211 | } |
---|
212 | } |
---|
213 | |
---|
214 | |
---|
215 | function CResultItem(title, pageID, shapeID, pinX, pinY) |
---|
216 | { |
---|
217 | this["Title"] = title; |
---|
218 | this["PageID"] = pageID; |
---|
219 | this["ShapeID"] = shapeID; |
---|
220 | this["PinX"] = pinX; |
---|
221 | this["PinY"] = pinY; |
---|
222 | } |
---|
223 | |
---|
224 | function FindParentPage(nodeObject) |
---|
225 | { |
---|
226 | if(nodeObject == null) |
---|
227 | { |
---|
228 | return null; |
---|
229 | } |
---|
230 | if(nodeObject.baseName == "Page") |
---|
231 | return nodeObject; |
---|
232 | else |
---|
233 | return FindParentPage(nodeObject.parentNode); |
---|
234 | } |
---|
235 | |
---|
236 | function QueryStringForMatch(shapeNode, regTextForFind, filterString) |
---|
237 | { |
---|
238 | if (filterString.length > 0) |
---|
239 | { |
---|
240 | var nodesToCheck = shapeNode.selectNodes(filterString); |
---|
241 | |
---|
242 | var nodeCount = nodesToCheck.length; |
---|
243 | var stringToParse; |
---|
244 | for(var ncount = 0; ncount < nodeCount; ncount++) |
---|
245 | { |
---|
246 | stringToParse = nodesToCheck.item(ncount).text; |
---|
247 | stringToParse = stringToParse.toLowerCase (); |
---|
248 | if(stringToParse.indexOf(regTextForFind) > -1) |
---|
249 | { |
---|
250 | return true; |
---|
251 | } |
---|
252 | } |
---|
253 | } |
---|
254 | } |
---|
255 | |
---|
256 | function GetShapeTitle(shapeNode) |
---|
257 | { |
---|
258 | var objTempName = null; |
---|
259 | var objTempTextElement = shapeNode.selectSingleNode("./Text"); |
---|
260 | if(objTempTextElement != null) |
---|
261 | { |
---|
262 | var objTextNode = objTempTextElement.selectSingleNode("textnode()"); |
---|
263 | if (objTextNode != null) |
---|
264 | { |
---|
265 | return parent.HTMLEscape (objTextNode.text); |
---|
266 | } |
---|
267 | } |
---|
268 | |
---|
269 | objTempName = shapeNode.selectSingleNode("./@Name"); |
---|
270 | if(objTempName != null) |
---|
271 | { |
---|
272 | return parent.HTMLEscape (objTempName.text); |
---|
273 | } |
---|
274 | |
---|
275 | return ""; |
---|
276 | } |
---|
277 | |
---|
278 | function GetPageTitle(pageID) |
---|
279 | { |
---|
280 | var pagesObj = parent.xmlData.selectSingleNode("VisioDocument/Pages"); |
---|
281 | if(!pagesObj) |
---|
282 | { |
---|
283 | return ""; |
---|
284 | } |
---|
285 | |
---|
286 | var pageQuerryString = './/Page[@ID = "' + pageID + '"]'; |
---|
287 | var pageObj = pagesObj.selectSingleNode(pageQuerryString); |
---|
288 | if(!pageObj) |
---|
289 | { |
---|
290 | return ""; |
---|
291 | } |
---|
292 | |
---|
293 | var pageNameNode = pageObj.selectSingleNode("@Name"); |
---|
294 | if(!pageNameNode) |
---|
295 | { |
---|
296 | return ""; |
---|
297 | } |
---|
298 | return pageNameNode.text; |
---|
299 | } |
---|
300 | |
---|
301 | function Find(searchTokensArray, propsToSearchArray) |
---|
302 | { |
---|
303 | var bXMLNotValid = false; |
---|
304 | var findArray = new Array(); |
---|
305 | var findIndex = 0; |
---|
306 | |
---|
307 | if (parent.xmlData != null && searchTokensArray.length > 0) |
---|
308 | { |
---|
309 | var fieldsToSearchArray = new Array(); |
---|
310 | var filterString = ""; |
---|
311 | if( null != propsToSearchArray && |
---|
312 | propsToSearchArray.length > 0 ) |
---|
313 | { |
---|
314 | var propFilterString = ""; |
---|
315 | for( var count=0; count< propsToSearchArray.length; count++ ) |
---|
316 | { |
---|
317 | if( count == 0 ) |
---|
318 | { |
---|
319 | propFilterString = "[. = '" + parent.EscapeString (propsToSearchArray[count]) + "'"; |
---|
320 | } |
---|
321 | else |
---|
322 | { |
---|
323 | propFilterString += " or . = '"+ parent.EscapeString (propsToSearchArray[count]) + "'"; |
---|
324 | } |
---|
325 | } |
---|
326 | propFilterString += "]"; |
---|
327 | |
---|
328 | fieldsToSearchArray[fieldsToSearchArray.length] = "Prop[Label"+ propFilterString +"]/Value"; |
---|
329 | } |
---|
330 | |
---|
331 | if (document.theForm[strShapeText + strChkBox].checked) |
---|
332 | { |
---|
333 | fieldsToSearchArray[fieldsToSearchArray.length] = "Text"; |
---|
334 | } |
---|
335 | |
---|
336 | if (fieldsToSearchArray.length > 0) |
---|
337 | { |
---|
338 | filterString = "(.//("; |
---|
339 | |
---|
340 | for (var fieldCount = 0; fieldCount < fieldsToSearchArray.length; fieldCount++) |
---|
341 | { |
---|
342 | if (fieldCount != 0) |
---|
343 | { |
---|
344 | filterString += " | "; |
---|
345 | } |
---|
346 | |
---|
347 | filterString += fieldsToSearchArray[fieldCount]; |
---|
348 | } |
---|
349 | |
---|
350 | filterString += ")/textnode())"; |
---|
351 | } |
---|
352 | |
---|
353 | var objShapeNodes; |
---|
354 | |
---|
355 | if (document.theForm[strShapeName + strChkBox].checked) |
---|
356 | { |
---|
357 | if (filterString.length > 0) |
---|
358 | { |
---|
359 | filterString += " | "; |
---|
360 | } |
---|
361 | filterString += "(@Name)"; |
---|
362 | |
---|
363 | var objShapeNodes = parent.xmlData.selectNodes(".//Shape"); |
---|
364 | } |
---|
365 | else |
---|
366 | { |
---|
367 | var objShapeNodes = parent.xmlData.selectNodes(".//Shape[(Prop/Value | Prop/Label | Text)]"); |
---|
368 | } |
---|
369 | |
---|
370 | var shapeCount = objShapeNodes.length; |
---|
371 | var objTempData = new CResultItem("A Label","PageID","ShapeID","PinX","PinY"); |
---|
372 | var objTempShape = null; |
---|
373 | |
---|
374 | for (count = 0; count < shapeCount; count++) |
---|
375 | { |
---|
376 | objTempShape = objShapeNodes.item(count); |
---|
377 | |
---|
378 | var objParentPageNode = FindParentPage(objTempShape); |
---|
379 | if (objParentPageNode == null) |
---|
380 | { |
---|
381 | continue; |
---|
382 | } |
---|
383 | |
---|
384 | var objPageIDNode = objParentPageNode.selectSingleNode("@ID/textnode()"); |
---|
385 | if(objPageIDNode == null) |
---|
386 | { |
---|
387 | continue; |
---|
388 | } |
---|
389 | var pageID = objPageIDNode.text; |
---|
390 | |
---|
391 | var pageIndex = parent.PageIndexFromID (pageID); |
---|
392 | if (pageIndex < 0) |
---|
393 | { |
---|
394 | continue; |
---|
395 | } |
---|
396 | |
---|
397 | var objLayerMember = objTempShape.selectSingleNode("LayerMem/LayerMember"); |
---|
398 | if (objLayerMember != null && objLayerMember.text.length > 0) |
---|
399 | { |
---|
400 | var layerArray = objLayerMember.text.split (';'); |
---|
401 | var visibleLayer = false; |
---|
402 | for (var layerCount = 0; (layerCount < layerArray.length) && !visibleLayer; layerCount++) |
---|
403 | { |
---|
404 | var objLayerVisible = objParentPageNode.selectSingleNode("Layer[@IX=" + layerArray[layerCount] + "]/Visible"); |
---|
405 | if (objLayerVisible != null) |
---|
406 | { |
---|
407 | visibleLayer = (objLayerVisible.text != 0); |
---|
408 | } |
---|
409 | } |
---|
410 | |
---|
411 | if (!visibleLayer) |
---|
412 | { |
---|
413 | continue; |
---|
414 | } |
---|
415 | } |
---|
416 | |
---|
417 | for (var tokenCount = 0; tokenCount < searchTokensArray.length; tokenCount++) |
---|
418 | { |
---|
419 | var textToFind = searchTokensArray[tokenCount]; |
---|
420 | textToFind = textToFind.toLowerCase (); |
---|
421 | |
---|
422 | if (QueryStringForMatch(objTempShape, textToFind, filterString)) |
---|
423 | { |
---|
424 | objTempData.Title = GetShapeTitle(objTempShape); |
---|
425 | objTempData.PageID = pageID; |
---|
426 | |
---|
427 | objShapeIDNode = objTempShape.selectSingleNode("@ID/textnode()"); |
---|
428 | if(objShapeIDNode == null) |
---|
429 | { |
---|
430 | bXMLNotValid = true; |
---|
431 | break; |
---|
432 | } |
---|
433 | objTempData.ShapeID = objShapeIDNode.text; |
---|
434 | objPinXNode = objTempShape.selectSingleNode("XForm/PinX/textnode()"); |
---|
435 | if(objPinXNode == null) |
---|
436 | { |
---|
437 | bXMLNotValid = true; |
---|
438 | break; |
---|
439 | } |
---|
440 | objTempData.PinX = objPinXNode.text; |
---|
441 | objPinYNode = objTempShape.selectSingleNode("XForm/PinY/textnode()"); |
---|
442 | if(objPinYNode == null) |
---|
443 | { |
---|
444 | bXMLNotValid = true; |
---|
445 | break; |
---|
446 | } |
---|
447 | objTempData.PinY = objPinYNode.text; |
---|
448 | |
---|
449 | findArray[findIndex] = new CResultItem(objTempData.Title, objTempData.PageID, objTempData.ShapeID, objTempData.PinX, objTempData.PinY); |
---|
450 | findIndex++; |
---|
451 | break; |
---|
452 | } |
---|
453 | } |
---|
454 | } |
---|
455 | if(bXMLNotValid) |
---|
456 | { |
---|
457 | findArray.length = 0; |
---|
458 | } |
---|
459 | } |
---|
460 | |
---|
461 | return findArray; |
---|
462 | } |
---|
463 | |
---|
464 | function FindQuerySelect(pageID, shapeID, pinX, pinY) |
---|
465 | { |
---|
466 | if ((!widgets.GoTo && parent.g_FileList.length > 1) || (widgets.GoTo && parent.g_FileList[document.all("Select1").value].PageID != pageID)) |
---|
467 | { |
---|
468 | parent.g_callBackFunctionArray[parent.g_callBackFunctionArray.length] = function () { parent.viewMgr.put_Location (pageID, shapeID, pinX, pinY); }; |
---|
469 | parent.GoToPageByID(pageID); |
---|
470 | } |
---|
471 | else |
---|
472 | { |
---|
473 | if (parent.viewMgr != null) |
---|
474 | { |
---|
475 | parent.viewMgr.put_Location (pageID, shapeID, pinX, pinY); |
---|
476 | } |
---|
477 | } |
---|
478 | } |
---|
479 | |
---|
480 | function TreeSelect(pageID, shapeID) |
---|
481 | { |
---|
482 | var shapeNode = FindShapeXML (pageID, shapeID); |
---|
483 | if (shapeNode != null) |
---|
484 | { |
---|
485 | var pinXNode = shapeNode.selectSingleNode("XForm/PinX/textnode()"); |
---|
486 | var pinYNode = shapeNode.selectSingleNode("XForm/PinY/textnode()"); |
---|
487 | |
---|
488 | if (pinXNode != null && pinYNode != null) |
---|
489 | { |
---|
490 | FindQuerySelect (pageID, shapeID, pinXNode.text, pinYNode.text); |
---|
491 | } |
---|
492 | } |
---|
493 | } |
---|
494 | |
---|
495 | |
---|
496 | var g_RowStyleList = parent.g_RowStyleList; |
---|
497 | var FillPropPane = parent.FillPropPane; |
---|
498 | var CreatePropTable = parent.CreatePropTable; |
---|
499 | |
---|