home *** CD-ROM | disk | FTP | other *** search
/ Beginning Direct3D Game Programming / Direct3D.iso / directx / dxf / extras / documentation / directx7 / directx7.chm / dxmedia / foundation / d3drm / js / glossary.js < prev    next >
Text File  |  2000-09-22  |  3KB  |  112 lines

  1.  
  2. window.self.document.writeln('<DIV ID="bufferGLS" STYLE="DISPLAY: none"><OBJECT ID="objectGLS" STYLE="width:1; height:1;" TYPE=TEXT/X-SCRIPTLET></OBJECT></DIV>');
  3.  
  4. window.self.document.writeln('<SCR' + 'IPT LANGUAGE="JSCRIPT" FOR="objectGLS" EVENT="onscriptletevent(event, obj)">if (event == "evt_DocComplete") GetHTMLData(); </SCR' + 'IPT>')
  5.  
  6. window.self.document.writeln('<DIV ID="displayGLS" STYLE="z-index:100; position:absolute; display:none ; width:400px; padding:3px; background-color:lemonchiffon; border-style: inset; border-left-width: 1;  border-top-width: 1;  border-right-width: 2;  border-bottom-width: 2; border-right-color: black; border-bottom-color: black; font:8pt Tahoma; line-height:8pt;"></DIV>');
  7.  
  8. function GlossaryObject(sFileName,sDataID,oSrc, sWordEntry){
  9.     this.sFileName     = sFileName;
  10.     this.sDataID    = sDataID;
  11.     this.oSrc        = oSrc;
  12.     this.sWordEntry = sWordEntry;
  13. }
  14.  
  15. var glbGlossary = new GlossaryObject();
  16.  
  17. function Glossary(oSrc){
  18.     
  19.     glbGlossary.oSrc        = oSrc;    
  20.     glbGlossary.sDataID     = oSrc.DATAID;
  21.     SetGlossaryPositionToClientPos();
  22.  
  23.     if(glbGlossary.sFileName != oSrc.FILENAME){
  24.         var sObject     =  '<OBJECT ID=\"objectGLS" TYPE="text/x-scriptlet" STYLE="DISPLAY: none; WIDTH : 0 ; HEIGHT: 0 ">\n';
  25.             sObject     += '<PARAM NAME="url" VALUE="' + oSrc.FILENAME + '">\n';
  26.             sObject     += '</OBJECT>\n';
  27.             bufferGLS.innerHTML     = sObject;    
  28.     }
  29.     else
  30.         GetHTMLData();
  31.         
  32.     glbGlossary.sFileName     = oSrc.FILENAME;
  33. }
  34.  
  35. function GetHTMLData(){
  36.  
  37.     if(glbGlossary.oSrc.DSPTITLE){
  38.         var str = glbGlossary.oSrc.DSPTITLE;
  39.     }
  40.     else{
  41.         var str = ReplaceCh(glbGlossary.sDataID, '_', ' ');
  42.     };
  43.     glbGlossary.sWordEntry = '<B>' + str + '</B><BR>' + objectGLS.getInnerHTML('GLS_' + glbGlossary.sDataID);
  44.     
  45.     SetGlossaryDisplay(1);
  46. }
  47.  
  48. function ReplaceCh(str, ch_old, ch_new){
  49.     var i;
  50.     var str_new = '';
  51.     var ch;
  52.     
  53.     for(i=0; i<str.length; i++){
  54.         ch = str.charAt(i);
  55.         if (ch == ch_old)
  56.             str_new += ch_new;
  57.         else
  58.             str_new += ch;
  59.     }
  60.     return str_new;
  61. }
  62.  
  63. function SetGlossaryPositionToClientPos(){
  64.     var offSetLeft     = window.event.clientX + document.body.scrollLeft + 10 ;
  65.     var offSetTop    = window.event.clientY + document.body.scrollTop + 10;
  66.     
  67.     // avoid runing to the right of the screen
  68.     if (((offSetLeft + 430) > document.body.offsetWidth) && (document.body.offsetWidth > 430 )) {
  69.             //offSetLeft     = document.body.offsetWidth - 430; displayGLS
  70.             offSetLeft     = document.body.offsetWidth - parseInt(displayGLS.style.width) - 34 ;
  71.         //alert(displayGLS.style.width);
  72.         }
  73.  
  74.     displayGLS.style.left     = offSetLeft;
  75.           displayGLS.style.top     = offSetTop;
  76.     }
  77.  
  78. function SetGlossaryDisplay(nState){
  79.  
  80.     if(nState == 0){
  81.         displayGLS.style.display = "none";
  82.     }
  83.         
  84.     if(nState == 1){
  85.         displayGLS.innerHTML    = glbGlossary.sWordEntry;
  86.         displayGLS.style.display     = "";
  87.         //displayGLS.focus();
  88.         ClearBuffer();
  89.     }
  90. }
  91.  
  92. function ClearBuffer(){
  93.     if(bufferGLS.innerHTML != "<BR>"){
  94.         setTimeout("bufferGLS.innerHTML = '<BR>'", 100)
  95.         glbGlossary.sFileName = " ";
  96.         
  97.     }
  98. }
  99.  
  100. function SetGlossary(){
  101.     ClearBuffer();
  102. }
  103.  
  104. function window.document.onclick(){
  105.     if( typeof(bufferGLS) != "undefined" && window.event.srcElement.className != "Glossary" )
  106.         SetGlossaryDisplay(0);
  107. }
  108.  
  109. function glossOnResize(){
  110.     if( typeof(bufferGLS) != "undefined")
  111.         SetGlossaryDisplay(0);
  112. }