A Qcodo based CMS/ecommerce framework
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
3.5 KiB

12 years ago
  1. ////////////////////////////////
  2. // Logging-related functionality
  3. ////////////////////////////////
  4. qcodo.logMessage = function(strMessage, blnReset, blnNonEscape) {
  5. var objLogger = qcodo.getControl("Qform_Logger");
  6. if (!objLogger) {
  7. var objLogger = document.createElement("div");
  8. objLogger.id = "Qform_Logger";
  9. objLogger.style.display = "none";
  10. objLogger.style.width = "400px";
  11. objLogger.style.backgroundColor = "#dddddd";
  12. objLogger.style.fontSize = "10px";
  13. objLogger.style.fontFamily = "lucida console, courier, monospaced";
  14. objLogger.style.padding = "6px";
  15. objLogger.style.overflow = "auto";
  16. if (qcodo.isBrowser(qcodo.IE))
  17. objLogger.style.filter = "alpha(opacity=50)";
  18. else
  19. objLogger.style.opacity = 0.5;
  20. document.body.appendChild(objLogger);
  21. };
  22. if (!blnNonEscape)
  23. if (strMessage.replace)
  24. strMessage = strMessage.replace(/</g, '&lt;');
  25. var strPosition = "fixed";
  26. var strTop = "0px";
  27. var strLeft = "0px";
  28. if (qcodo.isBrowser(qcodo.IE)) {
  29. // IE doesn't support position:fixed, so manually set positioning
  30. strPosition = "absolute";
  31. strTop = qcodo.scroll.y + "px";
  32. strLeft = qcodo.scroll.x + "px";
  33. };
  34. objLogger.style.position = strPosition;
  35. objLogger.style.top = strTop;
  36. objLogger.style.left = strLeft;
  37. objLogger.style.height = (qcodo.client.height - 100) + "px";
  38. objLogger.style.display = 'inline';
  39. var strHeader = '<a href="javascript:qcodo.logRemove()">Remove</a><br/><br/>';
  40. if (blnReset)
  41. objLogger.innerHTML = strHeader + strMessage + "<br/>";
  42. else if (objLogger.innerHTML == "")
  43. objLogger.innerHTML = strHeader + strMessage + "<br/>";
  44. else
  45. objLogger.innerHTML += strMessage + "<br/>";
  46. };
  47. qcodo.logRemove = function() {
  48. var objLogger = qcodo.getControl('Qform_Logger');
  49. if (objLogger)
  50. objLogger.style.display = 'none';
  51. };
  52. qcodo.logEventStats = function(objEvent) {
  53. objEvent = qcodo.handleEvent(objEvent);
  54. var strMessage = "";
  55. strMessage += "scroll (x, y): " + qcodo.scroll.x + ", " + qcodo.scroll.y + "<br/>";
  56. strMessage += "scroll (width, height): " + qcodo.scroll.width + ", " + qcodo.scroll.height + "<br/>";
  57. strMessage += "client (x, y): " + qcodo.client.x + ", " + qcodo.client.y + "<br/>";
  58. strMessage += "client (width, height): " + qcodo.client.width + ", " + qcodo.client.height + "<br/>";
  59. strMessage += "page (x, y): " + qcodo.page.x + ", " + qcodo.page.y + "<br/>";
  60. strMessage += "page (width, height): " + qcodo.page.width + ", " + qcodo.page.height + "<br/>";
  61. strMessage += "mouse (x, y): " + qcodo.mouse.x + ", " + qcodo.mouse.y + "<br/>";
  62. strMessage += "mouse (left, middle, right): " + qcodo.mouse.left + ", " + qcodo.mouse.middle + ", " + qcodo.mouse.right + "<br/>";
  63. strMessage += "key (alt, shift, control, code): " + qcodo.key.alt + ", " + qcodo.key.shift + ", " +
  64. qcodo.key.control + ", " + qcodo.key.code;
  65. qcodo.logMessage("Event Stats", true);
  66. qcodo.logMessage(strMessage, false, true);
  67. };
  68. qcodo.logObject = function(objObject) {
  69. var strDump = "";
  70. for (var strKey in objObject) {
  71. var strData = objObject[strKey];
  72. strDump += strKey + ": ";
  73. if (typeof strData == 'function')
  74. strDump += "&lt;FUNCTION&gt;";
  75. else if (typeof strData == 'object')
  76. strDump += "&lt;OBJECT&gt;";
  77. else if ((strKey == 'outerText') || (strKey == 'innerText') || (strKey == 'outerHTML') || (strKey == 'innerHTML'))
  78. strDump += "&lt;TEXT&gt;";
  79. else
  80. strDump += strData;
  81. strDump += "<br/>";
  82. };
  83. qcodo.logMessage("Object Stats", true);
  84. qcodo.logMessage(strDump, false, true);
  85. };