home *** CD-ROM | disk | FTP | other *** search
/ Microsoft DirectX SDK 7.0 / Dx7.bin / DXF / doc / directx6.1 / directx.chm / dxmedia / foundation / dplay / debug.js < prev    next >
Encoding:
JavaScript  |  1999-03-03  |  1.7 KB  |  70 lines

  1. // Debugging Library 
  2.  
  3. // Outputs a string. Assumes txtStatus is a TEXTAREA
  4. function Trace(cStatusText)
  5. {
  6.     if ((typeof(_debug_txtStatus) != 'object') || _debug_txtStatus.tagName != 'TEXTAREA')
  7.         return;
  8.  
  9. /*
  10.     if(typeof(x) != 'string')
  11.     {
  12.         x = '_debug_txtStatus';
  13.     }
  14.     else
  15.     {
  16.         alert(x);
  17.     }
  18. */
  19.  
  20.     _debug_txtStatus.value = _debug_txtStatus.value + cStatusText + '\n';
  21. }
  22.  
  23. // Initialize the debugger by dropping a TEXTAREA into the document
  24. // Call this before calling Trace.
  25. function InitDebug(iHeight, iWidth)
  26. {
  27.     var oColl = document.all('_debug_txtStatus');
  28. //    if (oColl.tagName != 'undefined' || oColl.length > 0)
  29.     if (oColl != null)
  30.     {
  31.         alert('Debug Error: Object with ID/NAME "_debug_txtStatus" already exists on the page');
  32.         return;
  33.     }
  34.  
  35.     if (InitDebug.arguments.length == 0)
  36.     {
  37.         iHeight = 300;
  38.         iWidth = 300;
  39.     }
  40.  
  41.     document.body.insertAdjacentHTML('beforeEnd', '<P><TEXTAREA STYLE="height:' + iHeight + ';width:' + iWidth + '" ID=_debug_txtStatus></TEXTAREA>');
  42. }
  43.  
  44. function Debugger(iTop, iLeft, iHeight, iWidth)
  45. {
  46.     this.m_sTraceWindow = '_debug_txtStatus';
  47.     this.Trace = Trace;
  48.  
  49.     var oColl = document.all(this.m_sTraceWindow);
  50.     if (oColl != null)
  51.     {
  52.         alert('Debug Error: Object with ID/NAME "_debug_txtStatus" already exists on the page');
  53.         return;
  54.     }
  55.  
  56.     if (Debugger.arguments.length < 4)
  57.     {
  58.         sStyle = 'height:300;width:300';
  59.     }
  60.     else
  61.     {
  62.         sStyle = 'position:absolute;top:' + iTop + ';left:' + iLeft + ';height:' + iHeight + ';width:' + iWidth;
  63.     }
  64.  
  65.     sDebugWindow = '<P><TEXTAREA STYLE="' + sStyle + '" ID=' + this.m_sTraceWindow + '></TEXTAREA>';
  66.     document.body.insertAdjacentHTML('beforeEnd', sDebugWindow);
  67.  
  68.     Trace('Debugger Initialized...');
  69. //    Trace.x = 'foobar';
  70. }