Permalink
Browse files

Patch for the log view:

- displaying the entries of the log pane with even/odd (theme dependent) 
background colors
- scrolling support if needed

Also added a simple String.sprintf() function that also could be used for the log view.
Moved the virtualBox.addMessage() to selectorWnd.logMessage().

git-svn-id: http://vboxweb.googlecode.com/svn/trunk@69 729376a8-6c6b-11de-afdd-bb9f892af8c1
  • Loading branch information...
vboxweb
vboxweb committed Aug 24, 2009
1 parent 13089cd commit a04a307969f7a2ccaf27cc6a069647c3a0fd2f47
@@ -176,8 +176,14 @@ body {
margin-left: 0;
}
-/* the message list */
-td.message {
+/*
+ * Message list
+ */
+#vmMessageArea {
+ overflow: auto;
+}
+
+tr.vmMessage {
border-bottom: 1px #000000 dotted;
text-align: left;
font-weight: normal;
@@ -190,7 +196,18 @@ td.message {
padding-right: 0px;
}
-/*
+/* Timestap */
+td.vmMessageTs {
+ width: 120px;
+ nowrap: nowrap;
+}
+
+/* The actual message text */
+td.vmMessageBody {
+ /* Nothing specified here yet */
+}
+
+/*
* Menu bar
*/
.menu{
@@ -29,6 +29,39 @@ function tr(a_String)
return a_String;
}
+function sprintf()
+{
+ if (sprintf.arguments.length < 1)
+ return;
+
+ var vaList = sprintf.arguments[0];
+ for( var i=1; i<sprintf.arguments.length; i++)
+ {
+ switch (typeof(sprintf.arguments[i]))
+ {
+ case 'string':
+ vaList = vaList.replace(/%s/, sprintf.arguments[i]);
+ break;
+
+ case 'number':
+ vaList = vaList.replace(/%d/, sprintf.arguments[i]);
+ break;
+
+ case 'boolean':
+ vaList = vaList.replace(/%b/, sprintf.arguments[i] ? 'true' : 'false');
+ break;
+
+ default:
+ break;
+ }
+ }
+ return vaList;
+}
+
+/* Make sprintf() function above part of the String class if not yet available */
+if (!String.sprintf)
+ String.sprintf = sprintf;
+
/* Fallback console for non-debugging environments. */
if (window.console == undefined /* add more check here when using "console.*" functions */)
{
@@ -94,6 +94,29 @@ var vboxSelectorWnd = Class.create(
},
+ logMessage: function(message)
+ {
+ /* this is ugly business but I couldn't find a better method */
+ date = new Date();
+ month = date.getMonth() + 1;
+ if (month < 10) month = '0' + month;
+ day = date.getDate();
+ if (day < 10) day = '0' + day;
+ hours = date.getHours();
+ if (hours < 10) hours = '0' + hours;
+ minutes = date.getMinutes();
+ if (minutes < 10) minutes = '0' + minutes;
+ seconds = date.getSeconds();
+ if (seconds < 10) seconds = '0' + seconds;
+ dateStr = date.getFullYear() + '-' + month + '-' + day + ' ' +
+ hours + ':' + minutes + ':' + seconds;
+
+ jQuery("#vmMessageTable").prepend('<tr class="vmMessage"><td class="vmMessageTs">' +
+ dateStr + '</td><td class="vmMessageBody">' + String.sprintf(message) + '</td></tr>');
+ jQuery("#vmMessageTable tr:nth-child(odd)").addClass("ui-state-hover");
+ jQuery("#vmMessageTable tr:nth-child(even)").removeClass("ui-state-hover");
+ },
+
curItem: function()
{
return this.mVMListView.selectedItem();
@@ -391,7 +391,7 @@ var vboxTabWidget = Class.create(
var curItem = this.mParent.curItem();
var rdpServ = curItem.machine().getVRDPServer();
- vbGlobal.mVirtualBox.addMessage("Establishing RDP connection to IP " + rdpServ.netAddress +
+ vbGlobal.selectorWnd().logMessage("Establishing RDP connection to IP " + rdpServ.netAddress +
" on port " + rdpServ.port + " for VM with ID " + curItem.id());
var flash = RDPWebClient.getFlashById(RDPWebClient.FlashId);
@@ -67,7 +67,7 @@ var vboxVMToolbar = Class.create(
break;
case "toolbar-button-settings":
- vbGlobal.mVirtualBox.addMessage("Change VM settings not implemented!");
+ vbGlobal.selectorWnd().logMessage("Change VM settings not %s implemented!", "foo!!!");
break;
case "toolbar-button-start-pause":
@@ -87,12 +87,12 @@ var vboxVMToolbar = Class.create(
}
else if (state == VMState.Saved)
{
- vbGlobal.mVirtualBox.addMessage("Discard VM not implemented!");
+ vbGlobal.selectorWnd().logMessage("Discard VM not implemented!");
}
break;
case "toolbar-button-logout":
- vbGlobal.mVirtualBox.logout();
+ vbGlobal.virtualBox().logout();
break;
default:
@@ -114,7 +114,7 @@ var vboxVirtualBox = Class.create(
/* Did we get a status messsage to display? */
if (res[0].statusMessage)
- vbGlobal.mVirtualBox.addMessage(res[0].statusMessage);
+ vbGlobal.selectorWnd().logMessage(res[0].statusMessage);
/* @todo Get rid of the res[INDEX] handling! This is very error
* prone and leads to confusion as more data will be added. */
@@ -195,27 +195,6 @@ var vboxVirtualBox = Class.create(
return true;
},
- addMessage: function(message)
- {
- /* this is ugly business but I couldn't find a better method */
- date = new Date();
- month = date.getMonth() + 1;
- if (month < 10) month = '0' + month;
- day = date.getDate();
- if (day < 10) day = '0' + day;
- hours = date.getHours();
- if (hours < 10) hours = '0' + hours;
- minutes = date.getMinutes();
- if (minutes < 10) minutes = '0' + minutes;
- seconds = date.getSeconds();
- if (seconds < 10) seconds = '0' + seconds;
- dateStr = date.getFullYear() + '-' + month + '-' + day + ' ' +
- hours + ':' + minutes + ':' + seconds;
-
- jQuery("#vmMessageTable").prepend('<tr><td class="message" style="width: 120px;" nowrap="nowrap">' +
- dateStr + '</td><td class="message">' + message + '</td></tr>');
- },
-
getUserName: function()
{
return this.userName;
View
@@ -503,8 +503,7 @@ <h1>Alternative content</h1>
</div> <!-- vmTab -->
<div id="vmMessageArea" class="outer-layout-south">
- <table id="vmMessageTable" width="100%" cellspacing="0">
- </table>
+ <table id="vmMessageTable" width="100%" cellspacing="0"></table>
</div>
<!-- VM power off dialog, initially hidden, displayed using jQuery -->

0 comments on commit a04a307

Please sign in to comment.