// Lightstreamer Monitor Console Demo
// Table Management for the Server Details Section

  function pad(n){
    return n<10 ? '0'+n : n
  }
  
//////////////// Table Management for Server Identification Data
  // create an OverwriteTable
  var identificationTable = new OverwriteTable(null, null, "MERGE");

  identificationTable.setDataAdapter("MONITOR");
  identificationTable.setSnapshotRequired(true);

  identificationTable.onItemUpdate = function(item, info) {
    // the Server address information is available on the client side;
    // we add this information as extra fields on the monitor_identification item,
    // in order to take advantage of the visual tables support for data display;
    // note that only one snapshot event is expected for this item,
    // which carries immutable information
    if (engineRef) {
        info.addField("#SERVER_ADDRESS", engineRef.connection.getLSHost(), true);
      }
  };
  // define visual effects
  identificationTable.onChangingValues = function(itemPos, visualUpdateInfo, itemName) {
    if (visualUpdateInfo == null) {
      return;
    }
    visualUpdateInfo.setHotTime(0);
    visualUpdateInfo.setRowStyle('infoValue', 'infoValue');
    var ms = visualUpdateInfo.getFormattedValue("STARTUP_TIME");
    if (ms !== null) {
      ms = new Date(Number(ms));
      var dateStr = ms.getUTCFullYear()+"-"+
        pad(ms.getUTCMonth()+1)+"-"+
        pad(ms.getUTCDate())+" "+
        pad(ms.getUTCHours())+":"+
        pad(ms.getUTCMinutes())+":"
        +pad(ms.getUTCSeconds())+" UTC";
      visualUpdateInfo.setFormattedValue("STARTUP_TIME",dateStr);
    }
  };

  // bind the table to the corresponding HTML elements
  pushPage.addTable(identificationTable, "license");


//////////////// Table Management for Server Local Port Data

  // create an OverwriteTable
  var socketTable = new OverwriteTable(null, null, "MERGE");

  socketTable.setDataAdapter("MONITOR");
  socketTable.setSnapshotRequired(true);

  // define visual effects
  socketTable.onChangingValues = function(itemPos, visualUpdateInfo, itemName) {
    if (visualUpdateInfo != null) {
      visualUpdateInfo.setHotTime(0);
      visualUpdateInfo.setRowStyle('infoValue', 'infoValue');
    }
  };

  // bind the table to the corresponding HTML elements
  pushPage.addTable(socketTable, "socket");

