Author: nbelaevski
Date: 2008-08-10 10:51:56 -0400 (Sun, 10 Aug 2008)
New Revision: 10009
Modified:
trunk/ui/scrollableDataTable/src/main/javascript/ClientUILib.js
Log:
Log diff from extended data table applied
Modified: trunk/ui/scrollableDataTable/src/main/javascript/ClientUILib.js
===================================================================
--- trunk/ui/scrollableDataTable/src/main/javascript/ClientUILib.js 2008-08-10 13:18:54
UTC (rev 10008)
+++ trunk/ui/scrollableDataTable/src/main/javascript/ClientUILib.js 2008-08-10 14:51:56
UTC (rev 10009)
@@ -128,24 +128,81 @@
INFO: 1,
WARNING: 2,
ERROR: 3,
-
+ EVENT: 4, //KAW EVENT level added to trace events
+ ALERT: 5, //KAW ALERT level to stop executing script
+ hEnabledLevels: {
+ 1: true,
+ 2: true,
+ 3: true,
+ 4: true,
+ 5: false
+ },
// flag logger is initialized
isCreated: false,
width: 460,
- height: 90,
+ height: 600,
+ top: 0,
+ left: 750,
+ bLoggingEnabled: true,
create: function() {
+ this.mainDiv = $(document.createElement("div"));
+ this.mainDiv.setStyle({border: '1px black solid',
+ position: 'absolute',padding: '1px'});
this.logElement = $(document.createElement("div"));
- this.logElement.setStyle({position: 'absolute'});
- this.logElement.setStyle({overflow: 'auto'});
- this.logElement.setStyle({whiteSpace: 'nowrap'});
+ this.logElement.setStyle({overflow: 'auto', whiteSpace: 'nowrap'});
+ this.buttonsContainer = $(document.createElement("div"));
+ var clearDiv = this.buttonClear = $(document.createElement('div'));
+ clearDiv.setStyle({width: 120 + 'px', height: 25 + 'px',
+ border: '1px black solid'});
+ clearDiv.innerHTML = 'Clear';
+
+ var toggleLoggingDiv = this.buttonToggleLogging =
$(document.createElement('div'));
+ toggleLoggingDiv.setStyle({width: 120 + 'px', height: 25 + 'px',
+ border: '1px black solid', position: 'relative',
+ top: '-27px', left: '122px'
+ });
+ toggleLoggingDiv.innerHTML = 'Logging '+this.isLoggingEnabled();
+
+ var toggleAlertDiv = this.buttonToggleAlert =
$(document.createElement('div'));
+ toggleAlertDiv.setStyle({width: 120 + 'px', height: 25 + 'px',
+ border: '1px black solid', position: 'relative',
+ top: '-54px', left: '244px'
+ });
+ toggleAlertDiv.innerHTML = 'Alert
'+this.isLevelEnabled(ClientUILogger.ALERT);
+
+ this.buttonsContainer.appendChild(clearDiv);
+ this.buttonsContainer.appendChild(toggleLoggingDiv);
+ this.buttonsContainer.appendChild(toggleAlertDiv);
+ this.mainDiv.appendChild(this.logElement);
+ this.mainDiv.appendChild(this.buttonsContainer);
+
+ this.eventClearClicked = this.onClearClick.bindAsEventListener(this);
+ this.eventToggleLoggingClicked = this.onToggleLoggingClick.bindAsEventListener(this);
+ this.eventToggleAlertClicked = this.onToggleAlertClick.bindAsEventListener(this);
+ Event.observe(toggleLoggingDiv, 'click',
ClientUILogger.eventToggleLoggingClicked);
+ Event.observe(toggleAlertDiv, 'click',
ClientUILogger.eventToggleAlertClicked);
+ Event.observe(clearDiv, 'click', ClientUILogger.eventClearClicked);
Event.observe(window, 'load', ClientUILogger.init);
Event.observe(window, 'resize', ClientUILogger.resizeWindow);
+
this.isCreated = true;
},
+ onToggleAlertClick: function() {
+ this.toggleLevel(ClientUILogger.ALERT);
+ this.buttonToggleAlert.innerHTML = 'Alert
'+this.isLevelEnabled(ClientUILogger.ALERT);
+ },
+ onToggleLoggingClick: function(event) {
+ this.toggleLogging();
+ this.buttonToggleLogging.innerHTML = 'Logging '+this.isLoggingEnabled();
+ },
+ onClearClick: function(event) {
+ Event.stop(event);
+ this.logElement.innerHTML = '';
+ },
init: function() {
- if(ClientUILogger.logElement)
- document.body.appendChild(ClientUILogger.logElement);
+ if(ClientUILogger.mainDiv)
+ document.body.appendChild(ClientUILogger.mainDiv);
ClientUILogger.show();
},
resizeWindow: function() {
@@ -153,46 +210,75 @@
},
show: function() {
if(this.logElement) {
- Element.show(this.logElement);
- this.logElement.setStyle({width: this.width + 'px'});
- this.logElement.setStyle({height: this.height + 'px'});
+ Element.show(this.mainDiv);
+ this.mainDiv.setStyle({width: this.width + 'px',
+ height: this.height + 'px',
+ top: this.top + 'px',
+ left: this.left+ 'px',
+ zIndex: '1000'});
+ this.logElement.setStyle({width: '100%', height: '90%'});
+ this.buttonsContainer.setStyle({width: '100%', height: '10%'});
//this.logElement.setStyle({top: (this.getWindowHeight() - this.height - 10) +
'px'});
//this.logElement.setStyle({top: 10 + 'px'});
//this.logElement.setStyle({left: (this.getWindowWidth() - this.width - 10) +
'px'});
- this.logElement.setStyle({top: '0px'});
- this.logElement.setStyle({left: '250px'});
- this.logElement.setStyle({zIndex: '1000'});
+ //KAW changed logger display place
}
},
+ isLevelEnabled: function(level) {
+ return this.hEnabledLevels[level];
+ },
+ isLoggingEnabled: function() {
+ return this.bLoggingEnabled;
+ },
+ toggleLogging: function() {
+ this.bLoggingEnabled = !this.bLoggingEnabled;
+ },
+ toggleLevel: function(level) {
+ this.hEnabledLevels[level] = !this.hEnabledLevels[level];
+ },
log: function(level, infoText) {
- var msg = $(document.createElement("div"));
- this.logElement.appendChild(msg);
- msg.setStyle({width: '100%'});
+ var bIgnoreLog = !this.isLoggingEnabled() || !this.isLevelEnabled(level);
+ if (bIgnoreLog) {
+ //PREMATURE RETURN no logging required
+ return;
+ }
- var font = "bold normal bold 10pt Arial";
- var fontColor = "red";
-
- switch(level) {
- case ClientUILogger.INFO:
- fontColor = "black";
- font = "normal normal normal 10pt Arial";
- break;
- case ClientUILogger.WARNING:
- fontColor = "blue";
- font = "italic normal normal 10pt Arial";
- break;
- case ClientUILogger.ERROR:
- fontColor = "red";
- font = "normal normal bold 10pt Arial";
- break;
- default:
- infoText = "UNRESOLVED: level=" + level + ", msg=" + infoText;
+ if (level == ClientUILogger.ALERT) {
+ alert(infoText);
+ }else{
+ var msg = $(document.createElement("div"));
+ this.logElement.appendChild(msg);
+ msg.setStyle({width: '100%'});
+
+ var font = "bold normal bold 10pt Arial";
+ var fontColor = "red";
+
+ switch(level) {
+ case ClientUILogger.INFO:
+ fontColor = "black";
+ font = "normal normal normal 10pt Arial";
+ break;
+ case ClientUILogger.WARNING:
+ fontColor = "blue";
+ font = "italic normal normal 10pt Arial";
+ break;
+ case ClientUILogger.ERROR:
+ fontColor = "red";
+ font = "normal normal bold 10pt Arial";
+ break;
+ case ClientUILogger.EVENT:
+ fontColor = "green";
+ font = "normal normal bold 10pt Arial";
+ break;
+ default:
+ infoText = "UNRESOLVED: level=" + level + ", msg=" + infoText;
+ }
+ msg.setStyle({font: font});
+ msg.setStyle({color: fontColor});
+ msg.appendChild(document.createTextNode("> " + infoText));
+
+ this.logElement.scrollTop = this.logElement.scrollHeight;
}
- msg.setStyle({font: font});
- msg.setStyle({color: fontColor});
- msg.appendChild(document.createTextNode("> " + infoText));
-
- this.logElement.scrollTop = this.logElement.scrollHeight;
},
getWindowWidth: function(){
var innerWidth;
@@ -214,7 +300,7 @@
}
};
-ClientUILib.load();
+ClientUILib.load(false); //KAW debugging OFF
// declare predefined packages
var ClientUI = {