home *** CD-ROM | disk | FTP | other *** search
/ PC User 2003 December / Australian PC User - December 2003 (CD2).iso / software / apps / files / dwmx2k4.exe / Disk1 / data1.cab / Configuration_En / ServerDebugOutput / ColdFusion / ServerDebugOut.js < prev    next >
Encoding:
JavaScript  |  2003-09-05  |  7.0 KB  |  247 lines

  1. // Copyright 2001, 2002, 2003 Macromedia, Inc. All rights reserved.
  2.  
  3. //*************** GLOBALS VARS *****************
  4.  
  5. var DEBUG = false;
  6. var temp_file_name = null;
  7. var real_file_name = null;
  8.  
  9. //*******************  COMPONENT API **********************
  10.  
  11. //*-------------------------------------------------------------------
  12. // FUNCTION:
  13. //   findServerDebugInfo
  14. //
  15. // DESCRIPTION:
  16. //     this functions finds the debug data islands embedded in http respone
  17. //     The debug data is format is document
  18. //     http://developer.macromedia.com/ud/dtds/ultradev-debug-1.0.dtd
  19. //
  20. // ARGUMENTS:
  21. //
  22. //     source(browsed document source)
  23. //     filename(the name of the file)
  24. //     tempfilename(the temporary name of the file , if PIB using temp is enabled)
  25. //    
  26. // RETURNS:
  27. //   none.
  28. //   
  29. //--------------------------------------------------------------------
  30. function findServerDebugInfo(source, filename, tempfilename)
  31. {
  32.     var aCallbackObj = new Object();
  33.     aCallbackObj.directive  = findCFDebugOutput;
  34.     temp_file_name = tempfilename;
  35.     real_file_name = filename;
  36.     dreamweaver.scanSourceString(source, aCallbackObj);
  37. }
  38.  
  39. function findCFDebugOutput(code)
  40. {
  41.     // find start of comment
  42.     var aBeginIndex = code.indexOf("<!--");
  43.     if(aBeginIndex != -1)
  44.     {
  45.         // don't search whole string for our signature, just 1st few characters
  46.         var aCommentSlice = code.slice(aBeginIndex, code.length > 20 ? 20 : code.length - 1);
  47.         if (aCommentSlice.indexOf("cf_debug_start") != -1)
  48.         {
  49.             // create relative path to my folder
  50.             var aPath = "ServerDebugOutput" + dwscripts.FILE_SEP + "ColdFusion" + dwscripts.FILE_SEP;
  51.  
  52.             // create absolute path to XSLT file
  53.             var anXSLTPath = dw.getConfigurationPath() + dwscripts.FILE_SEP + aPath + "cfdebugout.xsl";
  54.  
  55.             // read the xslt file
  56. //
  57. // disable XSL cache for the time being
  58. //            if(MM.CFDebugXSLT == null)
  59. //            {
  60. //                MM.CFDebugXSLT = DWfile.read(anXSLTPath);
  61. //            }
  62. //
  63.             var MMCFDebugXSLT = DWfile.read(anXSLTPath);
  64.  
  65.             // create parameters array for the xslt engine
  66.             var someParams = new Array();
  67.             someParams[0] = "config_folder";
  68.             someParams[1] = aPath;
  69.             if(temp_file_name != null)
  70.             {
  71.                 someParams[2] = "temp_file_name";
  72.                 someParams[3] = temp_file_name;
  73.                 someParams[4] = "real_file_name";
  74.                 someParams[5] = real_file_name;
  75.             }
  76.  
  77.             // extract XML from comment tag
  78.             var aStartBracketIndex = code.indexOf("<", aBeginIndex + 1);
  79.             if(aStartBracketIndex != -1)
  80.             {
  81.                 var anEndBracketIndex = code.lastIndexOf(">");
  82.                 if(anEndBracketIndex != -1)
  83.                 {
  84.                     anEndBracketIndex = code.lastIndexOf(">", anEndBracketIndex - 1);
  85.                     if(anEndBracketIndex != -1)
  86.                     {
  87.                         code = code.slice(aStartBracketIndex, anEndBracketIndex + 1);
  88.  
  89.                         // extract XML from comment tag and transform it
  90.                         var theNewXML = XSLT.transform(code, MMCFDebugXSLT, someParams);
  91.                         dw.resultsPalette.debugWindow.addDebugContextData(theNewXML);
  92.                     }
  93.                 }
  94.             }
  95.         }
  96.     }
  97. }
  98.  
  99. //*-------------------------------------------------------------------
  100. // FUNCTION:
  101. //   OnHelp
  102. //
  103. // DESCRIPTION:
  104. //     this functions finds the debug data islands embedded in http respone
  105. //     The debug data is format is document
  106. //     http://developer.macromedia.com/ud/dtds/ultradev-debug-1.0.dtd
  107. //
  108. // ARGUMENTS:
  109. //     none.
  110. //    
  111. // RETURNS:
  112. //   none.
  113. //   
  114. //--------------------------------------------------------------------
  115. function OnEnableDebuggingHelp()
  116. {
  117.     var adminurl = "/cfide/administrator/debugging/index.cfm";
  118.     var servername = "";
  119.     if (dw.getDocumentDOM())
  120.     {
  121.             servername = dw.getDocumentDOM().serverModel.getAppURLPrefix();
  122.     }
  123.     if (servername.length)
  124.     {
  125.         var slashIndex = servername.indexOf("/",7);
  126.         servername         = servername.substring(0,slashIndex);
  127.     }
  128.     servername += adminurl;
  129.     dw.browseDocument(servername);
  130. }
  131.  
  132. //*-------------------------------------------------------------------
  133. // FUNCTION:
  134. //   OnHelp
  135. //
  136. // DESCRIPTION:
  137. //     this functions finds the debug data islands embedded in http respone
  138. //     The debug data is format is document
  139. //     http://developer.macromedia.com/ud/dtds/ultradev-debug-1.0.dtd
  140. //
  141. // ARGUMENTS:
  142. //     none.
  143. //    
  144. // RETURNS:
  145. //   none.
  146. //   
  147. //--------------------------------------------------------------------
  148. function OnSelectIPDebuggingHelp()
  149. {
  150.     var adminurl = "/cfide/administrator/debugging/iplist.cfm";
  151.     var servername = "";
  152.     if (dw.getDocumentDOM())
  153.     {
  154.             servername = dw.getDocumentDOM().serverModel.getAppURLPrefix();
  155.     }
  156.     if (servername.length)
  157.     {
  158.         var slashIndex = servername.indexOf("/",7);
  159.         servername         = servername.substring(0,slashIndex);
  160.     }
  161.     servername += adminurl;
  162.     dw.browseDocument(servername);
  163. }
  164.  
  165.  
  166. // TODO: Remove the following:
  167. // 1. displayInstructions() API is no longer necessary.
  168. // 2. cleanup code and strings
  169. //
  170. // Specify list of steps that user must complete to get useful information
  171. // in this panel. Note that we display previous steps (1-4) so that we present
  172. // user with a single dynamic list (not 2 static list)
  173. //
  174. // TODO: do we want to implement the "events" from previous list for consistency?
  175.  
  176. function getSetupSteps()
  177. {
  178.   var dom = null;
  179.   var url = "";
  180.   var curSite = null;
  181.  
  182.   // Try to get the site for the currently selected document
  183.   dom = dw.getDocumentDOM();
  184.   if (dom != null)
  185.     url = dom.URL;
  186.   if (url.length > 0)
  187.     curSite = site.getSiteForURL(url);
  188.   else
  189.     curSite = site.getCurrentSite(); 
  190.   if (curSite.length == 0)
  191.     curSite = site.getCurrentServerSite();
  192.     
  193.   var title = MM.MSG_Dynamic_InstructionsTitle;
  194.   var step1 = MM.MSG_Dynamic_InstructionsStep1;
  195.   if (curSite.length != 0 && site.getIsServerSite(curSite))
  196.     step1 = MM.MSG_Dynamic_InstructionsStep1A;
  197.   var step2 = MM.MSG_Dynamic_InstructionsStep2;
  198.   var step3 = MM.MSG_ServerDebug_InstructionsStep3;
  199.   if (curSite.length != 0 && site.getIsServerSite(curSite))
  200.     step3 = MM.MSG_Dynamic_InstructionsStep3A;
  201.  
  202.   return new Array(title, step1, step2, step3);
  203. }
  204.  
  205.  
  206. function setupStepsCompleted()
  207. {
  208.   var stepsCompleted = -1;    // all steps complete
  209.   var dom = null;
  210.   var serverModel = "";
  211.   var url = "";
  212.   var curSite = null;
  213.  
  214.   // Try to get the site for the currently selected document
  215.   dom = dw.getDocumentDOM();
  216.   if (dom != null)
  217.     url = dom.URL;
  218.   if (url.length > 0)
  219.     curSite = site.getSiteForURL(url);
  220.   else
  221.     curSite = site.getCurrentSite();
  222.   if (curSite.length == 0)
  223.     curSite = site.getCurrentServerSite();
  224.  
  225.   // If no site defined, prompt user to create one
  226.   if (curSite.length == 0)
  227.     return 0;
  228.  
  229.   // Try to get the server model of the currently selected document
  230.   // If no document is open, get the default server model for cur site.
  231.   if (dom == null)
  232.     dom = dw.getNewDocumentDOM();
  233.   if (dom && dom.serverModel)
  234.     serverModel = dom.serverModel.getFolderName();
  235.  
  236.   // If doc type does not support server markup, prompt user
  237.   // to choose dynamic doc type
  238.   if (serverModel.length == 0)
  239.     return 1;
  240.  
  241.   // If no app server is defined, prompt user to specify one
  242.   if (dom == null || dom.serverModel.testAppServer() == false)
  243.     return 2;
  244.  
  245.   return 3;
  246. }
  247.