home *** CD-ROM | disk | FTP | other *** search
/ internet.au CDrom 42 / NETCD42.iso / web / w95 / dream2.exe / data1.cab / Program_Files / Configuration / Inspectors / ssi_widget.js < prev    next >
Encoding:
Text File  |  1998-11-30  |  3.1 KB  |  139 lines

  1.  
  2.  
  3. function canInspectSelection() 
  4. {
  5.  
  6.     var curSelection    = dreamweaver.getSelection();
  7.     var includeStr;
  8.     var tempStr;
  9.     var theObj            = dreamweaver.offsetsToNode(curSelection[0],curSelection[1]);
  10.  
  11.     
  12.     if (theObj.nodeType == Node.COMMENT_NODE) 
  13.     {
  14.         tempStr        = theObj.data;
  15.         includeStr    = tempStr.toLowerCase().indexOf("#include");
  16.  
  17.         if (includeStr != -1) 
  18.         {
  19.             return "true";
  20.         }
  21.         else
  22.         {
  23.              return "false"; 
  24.         }
  25.     } 
  26.     else
  27.     {
  28.          return "false";
  29.     }
  30. }
  31. function inspectSelection() 
  32. {
  33.     var result = dreamweaver.getSelection();
  34.     var theObj = dreamweaver.offsetsToNode(result[0],result[1]);
  35.     var fileStr,virtualStr,quoteStr,tempStr,includeStr,quoteStrLast;
  36.      if (theObj.nodeType != Node.COMMENT_NODE) 
  37.         return;
  38.  
  39.     tempStr                = theObj.data;
  40.     fileStr                = tempStr.toLowerCase().indexOf("file");
  41.     virtualStr            = tempStr.toLowerCase().indexOf("virtual");
  42.     quoteStr            = tempStr.indexOf('"');
  43.     quoteStrLast        = tempStr.lastIndexOf('"');
  44.     includeStr            = tempStr.toLowerCase().indexOf("#include");
  45.     var fileRadObj        = findObject("radioFile");
  46.     var virtualRadObj    = findObject("radioVirtual");
  47.     gOrignalURL            = tempStr.substring(quoteStr+1,quoteStrLast);
  48.     findObject("editField").value  = gOrignalURL;
  49.         
  50.     gOrignalRadio = ssiType( tempStr.toLowerCase() );
  51.     if ( gOrignalRadio == "virtual" )
  52.     {
  53.         virtualRadObj.checked    = true;
  54.         fileRadObj.checked        = false;
  55.     }
  56.     else 
  57.     {
  58.         fileRadObj.checked        = true; 
  59.         virtualRadObj.checked    = false;
  60.     } 
  61.  
  62.     
  63. }    
  64.  
  65. // whichButton is 0 for no button clicked, 1 for the virtual button,
  66. // 2 for the file button
  67. function setComment(whichButton) 
  68. {
  69.     var result = dreamweaver.getSelection();
  70.     var theObj = dreamweaver.offsetsToNode(result[0],result[1]);
  71.  
  72.     if (theObj.nodeType != Node.COMMENT_NODE) 
  73.         return;
  74.  
  75.     tempStr = theObj.data;
  76.     var radioStr;
  77.     var fileRadObj = findObject("radioFile");
  78.     var virtualRadObj = findObject("radioVirtual");
  79.     if (whichButton == 1) 
  80.     {
  81.         // virtual button was checked
  82.         fileRadObj.checked = false;
  83.         virtualRadObj.checked = true;
  84.     } 
  85.     else if (whichButton == 2)
  86.      {
  87.         // file button was checked
  88.         virtualRadObj.checked = false;
  89.         fileRadObj.checked = true;
  90.     }
  91.     
  92.     var URL = findObject("editField").value;
  93.         if (fileRadObj.checked) 
  94.         {
  95.             // verify that it's okay as a file-type URL
  96.  
  97.  
  98.             radioStr = "file";
  99.             if (URL.charAt(0) == '/' || URL.indexOf("../") != -1)
  100.             {
  101.                 var fileURL;
  102.                 
  103.                 relativeURL = findObject("editField").value;
  104.                 fileURL = virtualToFile(relativeURL);    
  105.  
  106.                 if ( fileURL == "" )
  107.                 {        
  108.                     radioStr = "virtual";
  109.                     virtualRadObj.checked = true;
  110.                     fileRadObj.checked = false;
  111.                     return;
  112.                 }
  113.                 else
  114.                 {
  115.                     URL = fileURL;
  116.                     findObject("editField").value = fileURL;
  117.                 }
  118.  
  119.             }    
  120.             
  121.             // file button was checked
  122.             virtualRadObj.checked    = false;
  123.             fileRadObj.checked        = true;    
  124.         } 
  125.         else 
  126.         {
  127.             radioStr = "virtual";
  128.             virtualRadObj.checked    = true;
  129.             fileRadObj.checked        = false;
  130.         }
  131.  
  132.         if ( unchanged( radioStr, URL ) )
  133.             return;
  134.  
  135.     theObj.data =  "#include " + radioStr + "=" + '"' + URL + '" ';
  136.  
  137. }
  138.  
  139.