home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2003 Spring / INTERNET101.ISO / pc / software / windows / building / antechinus / setup.exe / Setups / JSEd / Installed / Debugger / debugger.js < prev    next >
Encoding:
Text File  |  2002-09-26  |  2.6 KB  |  96 lines

  1. // C Point Debugger JavaScript Library v5.0
  2. // Copyright© 2002 C Point Pty Ltd, 71 Williamson Road, Para Hills 5096
  3. // Web: http://www.c-point.com Email: c-point@c-point.com
  4.  
  5. // *********************************************************************** //
  6. // To use the C Point Debugger JavaScript Library you must be a registered 
  7. // user of Antechinus JavaScript Editor.
  8. // *********************************************************************** //
  9.  
  10. Debugger=1;
  11. debugInit=0;
  12. UseTimeStamp=1;
  13. DbgX=0;
  14. DbgY=0;
  15. DbgWidth=500;
  16. DbgHeight=120;
  17. function PROPERTIES(objName, obj)
  18. {
  19.       if(!Debugger) return;
  20.     InitDbgSession();
  21.     var str = "";
  22.     for(var v in obj)
  23.     {
  24.         str=objName+"."+v+" = " + obj[v] + "\n";
  25.         document.fm.ta.value = str + document.fm.ta.value;
  26.     }
  27. }
  28. function TRACE0(val)
  29. {
  30.       if(!Debugger)return;
  31.       InitDbgSession();
  32.     document.fm.ta.value = val + "\n" + document.fm.ta.value;
  33. }
  34. var timestamp=0;
  35. function TRACE(label, val)
  36. {
  37.     if(!Debugger)return;
  38.     InitDbgSession();
  39.     var msg = label + "=" + val;
  40.     var now = new Date();
  41.     var elapsed = now - timestamp;
  42.       if(UseTimeStamp)
  43.     {
  44.         msg+=" (" + elapsed + " msec)";    
  45.       }
  46.     timestamp = now;
  47.       
  48.     document.fm.ta.value = msg + "\n" + document.fm.ta.value;
  49. }
  50.  
  51. // ************  Move object functions ************ 
  52. function InitDbgSession()
  53. {
  54.       if(debugInit)return;
  55.       debugInit=1;    
  56. // Init the draggable class
  57.     bMoving = false;
  58.     document.onmousedown=DbgStartMove;
  59.     document.onmousemove=DbgMoveObj;
  60.     document.onmouseup=new Function("bMoving=false");
  61. // Init debugger session
  62.     var str = '<div class=dbgdrag border=1 style="position:absolute; left:' + DbgX +
  63.      ';top:' + DbgY + '; width:' + DbgWidth + 'px;' + 
  64.     'background-color=silver;height:' + DbgHeight + 'px; z-index:1;border=1;borderColor=black">' +
  65.     '<form name ="fm">';
  66.      DbgWidth-=10; 
  67.      DbgHeight-=10;
  68.      str+='<textarea name="ta" style="position:absolute; width:' + DbgWidth + 'px;height:' + DbgHeight + 
  69.          'px;left:5;top:5;">' + '</textarea></form></div>';
  70.     document.write(str);
  71. }
  72.  
  73. function DbgMoveObj()
  74. {
  75.     if(!bMoving) return true;
  76.     if(event.button!=1) return true;
  77.  
  78. // Reposition the object, keeping the same distance from the cursor
  79.     ob.style.pixelLeft=event.clientX-xdif;
  80.     ob.style.pixelTop=event.clientY-ydif;
  81.     return false;
  82. }
  83.  
  84. function DbgStartMove()
  85. {
  86. // Only "draggable" objects can move
  87.     if(event.srcElement.className!="dbgdrag") return;
  88.  
  89.     bMoving=true;
  90. // Store the object and the differnce between the obj pos and cursor pos: it must remain the same
  91.     ob=event.srcElement;
  92.     xdif=event.clientX-event.srcElement.style.pixelLeft;
  93.     ydif=event.clientY-event.srcElement.style.pixelTop;
  94. }
  95.  
  96.