Salome HOME
Porting GUI documentation on Doxygen tool.
[modules/smesh.git] / doc / salome / gui / SMESH / whcsh_home.htm
1 <html>
2 <script language="javascript1.2" src="whver.js"></script>
3 <script language="javascript1.2" src="whmozemu.js"></script>
4 <script language="javascript1.2" src="whutils.js"></script>
5 <script language="javascript1.2">
6 <!--
7 if(gbIE4||gbNav61)
8 {
9         document.write("<body></body>");
10 }
11 else
12 {
13         document.write("<frameset rows=\"100%,*\"><frame name=\"data_frm\" src=\"about:blank\"><frame name=\"dumb_frm\" src=\"about:blank\"></frameset>");
14 }
15 var gCSHFileName="whcshdata.htm";
16
17 var gHomePage="index.htm";
18 var gaProj=new Array();
19 gaProj[0]=new Object();
20 gaProj[0].sProjPath=_replaceSlash(_getPath(document.location.href));
21 gaProj[0].nLoadState=0;
22 var gCurrent=0;
23
24 var gsTopicURL="";
25 var gnCurProj=0;
26 var gnCommand=-1;
27 var CMD_SHOWTOC=1;
28 var CMD_SHOWINDEX=2;
29 var CMD_SHOWSEARCH=3;
30 var CMD_SHOWGLOSSARY=4;
31 var CMD_SHOWNONE=0;
32
33 var RHWO_LOCATION=0x01;         /*need location bar?*/
34 var RHWO_MENUBAR=0x02;          /*need menubar?*/               
35 var RHWO_RESIZABLE=0x04;        /*resizable window?*/
36 var RHWO_TOOLBAR=0x08;          /*need toolbar?*/
37 var RHWO_STATUS=0x10;           /*need statusbar?*/
38 var RHWO_SCROLLBARS=0x20;       /*need scrollbars?*/
39
40 var gsStr="";
41 var gnId=-1;
42 var gsWindow="";
43 var gsJava="false";
44 var gbUseStr=false;
45 var gbURLReady=false;
46 var goWnd=new Object();
47 goWnd.sName="whCshDefault";
48 goWnd.nBOptions=RHWO_RESIZABLE|RHWO_SCROLLBARS;
49 goWnd.sBLeft="49%";
50 goWnd.sBTop="0";
51 goWnd.sBWidth="49%";
52 goWnd.sBHeight="49%";
53 goWnd.nPanes=1;
54 var goFullWnd=new Object();
55 goFullWnd.sName="whDefault";
56 goFullWnd.nBOptions=RHWO_RESIZABLE|RHWO_SCROLLBARS;
57 goFullWnd.sBLeft="20%";
58 goFullWnd.sBTop="0";
59 goFullWnd.sBWidth="79%";
60 goFullWnd.sBHeight="79%";
61 goFullWnd.nPanes=2;
62
63 var goNewWnd=null;
64 var gbLoadWnd=false;
65 var gsURL="";
66
67 function showCSH(sParam)
68 {
69         //id=
70         //str=
71         //url=
72         //cmd=
73         //with the format #<a=xxx>>b=xxx>>c=xxx...
74         parseParam(sParam);
75         SwitchURL();
76 }
77
78 function IsWndReady()
79 {
80         if(gaProj[0].nLoadState==0)
81         {
82                 var sCshFile=_getFullPath(gaProj[0].sProjPath,gCSHFileName);
83                 gaProj[0].nLoadState=1;
84                 setTimeout("loadFail("+0+");",3000);
85                 loadDataCsh(sCshFile);
86                 gbLoadWnd=true;
87                 return false;
88         }
89         else
90                 return true;
91 }
92
93 function SwitchURL()
94 {
95         if(gbURLReady)
96         {
97                 var sURL="";
98                 var oWnd=null;
99                 if(gsTopicURL)
100                 {
101                         sURL=_getPath(document.location.href)+gHomePage+"#"+gsTopicURL;
102                         oWnd=goWnd;
103                 }
104                 else
105                 {
106                         if(gnCommand!=-1)
107                                 sURL=_getPath(document.location.href)+gHomePage+"#>>cmd="+gnCommand;
108                         else
109                                 sURL=_getPath(document.location.href)+gHomePage;
110                         oWnd=goFullWnd;
111                 }
112                 if(gsWindow)
113                 {
114                         if(!IsWndReady())
115                                 return false;
116                         if(gaProj[gnCurProj].aWnd)
117                         {
118                                 var aWnd=gaProj[gnCurProj].aWnd;
119                                 var bFound=false;
120                                 for(var i=0;i<aWnd.length;i++)
121                                 {
122                                         if(aWnd[i].sName.toLowerCase()==gsWindow.toLowerCase())
123                                         {
124                                                 oWnd=aWnd[i];
125                                                 bFound=true;
126                                                 break;
127                                         }
128                                 }
129                                 if(!bFound&&gnCurProj!=0)
130                                 {
131                                         var aWnd=gaProj[0].aWnd;
132                                         for(var j=0;j<aWnd.length;j++)
133                                         {
134                                                 if(aWnd[j].sName.toLowerCase()==gsWindow.toLowerCase())
135                                                 {
136                                                         oWnd=aWnd[j];
137                                                         break;
138                                                 }
139                                         }
140                                 }
141                         }
142                 }
143
144                 if(sURL&&oWnd)
145                 {
146                         strURLOpt="";
147                         if(oWnd.sCaption)
148                                 strURLOpt+=">>cap="+oWnd.sCaption;
149                         if(oWnd.nPanes==1)
150                                 strURLOpt+=">>pan="+oWnd.nPanes;
151                         else if(oWnd.nPanes==2)
152                         {
153                                 strURLOpt+=">>pan="+oWnd.nPanes;
154                                 if(oWnd.nPOptions)
155                                         strURLOpt+=">>pot="+oWnd.nPOptions;
156                                 if(oWnd.sPButtons)
157                                         strURLOpt+=">>pbs="+oWnd.sPButtons;
158                                 if(oWnd.sPDefBtn)
159                                         strURLOpt+=">>pdb="+oWnd.sPDefBtn;
160                         }
161                         if(strURLOpt)
162                         {
163                                 if(sURL.indexOf("#")==-1)
164                                         sURL+="#";
165                                 sURL+=strURLOpt;
166                         }
167                         if(gsJava=="false")
168                         {
169                                 var strOpt=getBrowserOptionString(oWnd);
170                                 var sNewName=convertWindowName(oWnd.sName);
171                                 if(gbNav4)
172                                 {
173                                         if (gbNav6)
174                                         {
175                                                 gsURL = sURL;
176                                                 goNewWnd=window.open("about:blank",sNewName,strOpt);
177                                                 setTimeout("postWindowNSOpen();",100);
178                                         }
179                                         else
180                                         {
181                                                 window.open("about:blank",sNewName,strOpt);
182                                                 var oNewWnd=window.open(sURL,sNewName);
183                                                 window.close();
184                                                 oNewWnd.focus();
185                                         }
186                                 }
187                                 else
188                                 {
189                                         if(gbIE5)
190                                         {
191                                                 window.open("about:blank",sNewName,strOpt);
192                                                 goNewWnd=window.open(sURL,sNewName);
193                                         }
194                                         else
195                                         {
196                                                 gsURL = sURL; // IE4 had hard time to handle bookmark.
197                                                 goNewWnd=window.open("about:blank",sNewName,strOpt);
198                                         }
199                                         setTimeout("postWindowOpen();",100);
200                                 }
201                         }
202                         else
203                                 document.location=sURL;
204                 }
205         }
206 }
207
208 function convertWindowName(strName)
209 {
210         var strNewName = strName;
211         var strResultName = "";
212         var re=new RegExp("_","g");
213         strNewName = strName.replace(re,"__");
214         for (var i=0;i<strNewName.length;i++)
215                 if (!(strNewName[i] == '_' ||
216                         (strNewName[i] <= '9' && strNewName[i] >= '0') ||
217                         (strNewName[i] <= 'z' && strNewName[i] >= 'a') ||
218                         (strNewName[i] <= 'Z' && strNewName[i] >= 'A')))
219                 {
220                         strResultName += "_" + strNewName.charCodeAt(i);
221                 }
222                 else
223                         strResultName += strNewName[i];
224         return strResultName;
225 }
226
227 function postWindowNSOpen()
228 {
229         if(goNewWnd)
230         {
231                 if (gsURL)
232                         goNewWnd.document.location.href=gsURL;
233                 window.close();
234                 goNewWnd.focus();
235         }
236 }
237
238 function postWindowOpen()
239 {
240         if(goNewWnd)
241         {
242                 if (gsURL&&!gbIE5&&gbIE4)
243                         goNewWnd.document.location.href=gsURL;
244                 goNewWnd.focus();
245         }
246 }
247
248 function parseParam(sParam)
249 {
250         if(sParam)
251         {
252                 var nBPos=0;
253                 do
254                 {
255                         var nPos=sParam.indexOf(">>",nBPos);
256                         if(nPos!=-1)
257                         {
258                                 if(nPos>0)
259                                 {
260                                         var sPart=sParam.substring(nBPos,nPos);
261                                         parsePart(sPart);
262                                 }
263                                 nBPos=nPos+2;
264                         }
265                         else
266                         {
267                                 var sPart=sParam.substring(nBPos);
268                                 parsePart(sPart);
269                                 break;
270                         }
271                 }while(nBPos<sParam.length);
272         }
273 }
274
275 function parsePart(sPart)
276 {
277         if(sPart.toLowerCase().indexOf("id=")==0)
278         {
279                 fetchURLById(sPart.substring(3));
280                 gbURLReady=false;
281         }
282         else if(sPart.toLowerCase().indexOf("str=")==0)
283         {
284                 fetchURLByStr(sPart.substring(4));
285                 gbURLReady=false;
286         }
287         else if(sPart.toLowerCase().indexOf("url=")==0)
288         {
289                 gsTopicURL=sPart.substring(4);
290                 gbURLReady=true;
291         }
292         else if(sPart.toLowerCase().indexOf("cmd=")==0)
293         {
294                 var sCmd=sPart.substring(4);
295                 if(sCmd.toLowerCase()=="toc")
296                 {
297                         gnCommand=CMD_SHOWTOC;
298                 }
299                 else if(sCmd.toLowerCase()=="idx")
300                 {
301                         gnCommand=CMD_SHOWINDEX;
302                 }
303                 else if(sCmd.toLowerCase()=="fts")
304                 {
305                         gnCommand=CMD_SHOWSEARCH;
306                 }
307                 else if(sCmd.toLowerCase()=="glo")
308                 {
309                         gnCommand=CMD_SHOWGLOSSARY;
310                 }
311                 else if(sCmd.toLowerCase()=="none")
312                 {
313                         gnCommand=CMD_SHOWNONE;
314                 }
315                 gbURLReady=true;
316         }
317         else if(sPart.toLowerCase().indexOf("wnd=")==0)
318         {
319                 gsWindow=_browserStringToText(sPart.substring(4));
320         }
321         else if(sPart.toLowerCase().indexOf("java=")==0)
322         {
323                 gsJava=sPart.substring(5);
324         }
325 }
326
327 function fetchURLById(sId)
328 {
329         var nId=parseInt(sId);
330         gsTopicURL="";
331         fetchURL("",nId,false);
332 }
333
334 function fetchURLByStr(sStr)
335 {
336         gsTopicURL="";
337         fetchURL(sStr,0,true);
338 }
339
340 function fetchURL(sStr,nId,bUseStr)
341 {
342         var bNeedLoad=false;
343         var bFound=false;
344         for(var i=0;i<gaProj.length;i++)
345         {
346                 if(gaProj[i].nLoadState==3)
347                 {
348                         if(gaProj[i].aCsh)
349                         {
350                                 for(var j=0;j<gaProj[i].aCsh.length;j++)
351                                 {
352                                         var sTopicURL="";
353                                         if(bUseStr)
354                                         {
355                                                 if(gaProj[i].aCsh[j].strAliasId.toLowerCase()==sStr.toLowerCase())
356                                                         sTopicURL=gaProj[i].aCsh[j].strUrl;
357                                         }
358                                         else
359                                         {
360                                                 if(gaProj[i].aCsh[j].nTopicNum==nId)
361                                                         sTopicURL=gaProj[i].aCsh[j].strUrl;
362                                         }
363                                         if(sTopicURL)
364                                         {
365                                                 if(i!=0)
366                                                 {
367                                                         gnCurProj=i;
368                                                         if(gaProj[i].sProjPath.indexOf(gaProj[0].sProjPath)==0)
369                                                         {
370                                                                 var sRelPath=gaProj[i].sProjPath.substring(gaProj[0].sProjPath.length);
371                                                                 gsTopicURL=sRelPath+sTopicURL;
372                                                         }
373                                                         else
374                                                                 gsTopicURL=gaProj[i].sProjPath+sTopicURL;
375                                                 }
376                                                 else
377                                                         gsTopicURL=sTopicURL;
378                                                 bFound=true;
379                                                 break;
380                                         }
381                                 }
382                         }
383                         
384                 }
385                 else if(gaProj[i].nLoadState==0)
386                 {
387                         gsStr=sStr;
388                         gnId=nId;
389                         gbUseStr=bUseStr;
390                         var sCshFile=_getFullPath(gaProj[i].sProjPath,gCSHFileName);
391                         gaProj[i].nLoadState=1;
392                         setTimeout("loadFail("+i+");",3000);
393                         loadDataCsh(sCshFile);
394                         bNeedLoad=true;
395                 }
396                 if(bFound||bNeedLoad)
397                         break;
398         }
399         if(!bNeedLoad)
400         {
401                 gbURLReady=true;
402                 SwitchURL();
403         }
404 }
405
406 function loadDataCsh(sFile)
407 {
408         if(gbIE4||gbNav61)
409                 loadData(sFile);
410         else
411         {
412                 window.frames[0].location=sFile;
413         }
414 }
415
416 function loadFail(nProj)
417 {
418         if(gaProj[nProj].nLoadState==1)
419         {
420                 gaProj[nProj].nLoadState=2;
421                 if(!gbLoadWnd)
422                         fetchURL(gsStr,gnId,gbUseStr);
423                 else
424                         SwitchURL();
425         }
426 }
427
428 function putCshData(strProj,aCsh,aWnd,aRmtProj)
429 {
430         if(strProj)
431         {
432                 strProj=_replaceSlash(strProj);
433                 if(strProj.lastIndexOf("/")!=strProj.length-1)
434                         strProj+="/";
435                 for(var i=0;i<gaProj.length;i++)
436                 {
437                         if(gaProj[i].sProjPath)
438                         {
439                                 if(isSamePath(gaProj[i].sProjPath,strProj))
440                                 {
441                                         gaProj[i].nLoadState=3;
442                                         gaProj[i].aCsh=aCsh;
443                                         gaProj[i].aWnd=aWnd;
444                                         break;
445                                 }
446                         }
447                 }
448                 if(aRmtProj&&aRmtProj.length)
449                 {
450                         for(var j=0;j<aRmtProj.length;j++)
451                         {
452                                 var strRPath=_getFullPath(strProj,aRmtProj[j]);
453                                 var bFound=false;
454                                 for (var k=0;k<gaProj.length;k++)
455                                 {
456                                         if(gaProj[k].sProjPath)
457                                         {
458                                                 if(isSamePath(gaProj[k].sProjPath,strRPath))
459                                                 {
460                                                         bFound=true;
461                                                         break;
462                                                 }
463                                         }
464                                 }
465                                 if(!bFound)
466                                 {
467                                         var len=gaProj.length;
468                                         gaProj[len]=new Object();
469                                         gaProj[len].sProjPath=strRPath;
470                                         gaProj[len].nLoadState=0;
471                                 }
472                         }
473                 }
474                 if(!gbLoadWnd)
475                         fetchURL(gsStr,gnId,gbUseStr);
476                 else
477                         SwitchURL();
478                         
479         }
480 }
481
482 function isSamePath(strPath1,strPath2)
483 {
484         return strPath1.toLowerCase()==strPath2.toLowerCase();
485 }
486
487 function getRelHomePage(strLocation)
488 {
489         var strCurPPath=_getPath(strLocation);
490         var strOriPPath=_getPath(getHomePage());
491         var strRelPath=_getRelativeFileName(strOriPPath,strCurPPath);
492         var strURL=getHomePage()+"#"+strRelPath;
493         return strURL;
494 }
495
496 function getHomePage()
497 {
498         var strHomePage;
499         var strTmp=location.toString();
500         var nPos=strTmp.indexOf("#");
501         if(nPos!=-1)
502         {
503                 strHomePage=strTmp.substring(0,nPos);
504         }
505         else
506         {
507                 strHomePage=strTmp;
508         }
509         return strHomePage;
510 }
511
512 function getBrowserOptionString(oWnd)
513 {
514         var strOpts="";
515         if(oWnd.bUseDefault)
516                 return strOpts;
517         if(oWnd.nBOptions&RHWO_LOCATION)
518                 strOpts+="location=yes";
519         else
520                 strOpts+="location=no";
521         if(oWnd.nBOptions&RHWO_TOOLBAR)
522                 strOpts+=",toolbar=yes";                
523         else
524                 strOpts+=",toolbar=no";         
525         if(oWnd.nBOptions&RHWO_MENUBAR)
526                 strOpts+=",menubar=yes";                
527         else
528                 strOpts+=",menubar=no";
529         if(oWnd.nBOptions&RHWO_STATUS)
530                 strOpts+=",status=yes";         
531         else
532                 strOpts+=",status=no";          
533         if(oWnd.nBOptions&RHWO_SCROLLBARS)
534                 strOpts+=",scrollbars=yes";
535         else
536                 strOpts+=",scrollbars=no";      
537         if(oWnd.nBOptions&RHWO_RESIZABLE)
538                 strOpts+=",resizable=yes";
539         else
540                 strOpts+=",resizable=no";
541         if(oWnd.sBTop)
542         {
543                 var nTop=getSValue(oWnd.sBTop,screen.height);
544                 strOpts+=",top="+nTop;
545                 strOpts+=",screenY="+nTop;
546         }
547         if(oWnd.sBLeft)
548         {
549                 var nLeft=getSValue(oWnd.sBLeft,screen.width);
550                 strOpts+=",left="+nLeft;
551                 strOpts+=",screenX="+nLeft;
552         }
553         if(oWnd.sBWidth)
554         {
555                 var nWidth=getSValue(oWnd.sBWidth,screen.width);
556                 strOpts+=",width="+nWidth;
557                 strOpts+=",outerWidth="+nWidth;
558         }
559         if(oWnd.sBHeight)
560         {
561                 var nHeight=getSValue(oWnd.sBHeight,screen.height);
562                 strOpts+=",height="+nHeight;
563                 strOpts+=",outerHeight="+nHeight;
564         }
565         return strOpts;
566 }
567
568 function getSValue(sValue,nLength)
569 {
570         var nValue=0;
571         var nPos=sValue.indexOf("%");
572         if(nPos!=-1)
573         {
574                 if(nPos>0)
575                 {
576                         var nPart=parseInt(sValue.substring(0,nPos));
577                         nValue=nLength*nPart/100;
578                 }
579         }
580         else
581                 nValue=parseInt(sValue);
582         return nValue;
583 }
584
585
586 window.onload=window_OnLoad;
587
588 function window_OnLoad()
589 {
590         if(document.location.hash.length>0)
591         {
592                 showCSH(document.location.hash.substring(1));
593         }
594
595         if(gsJava=="false")
596                 window.moveTo(screen.width,screen.height);
597 }
598 //-->
599 </script>
600 </html>