@meterBar(ID, HEIGHT_PIXELS)

Inserts a HTML <div> section for the purpose of a "meter bar" (0 to 100%).

The following parameters are recognized:

ID

The ID to use to refer to the meter bar.

HEIGHT_PIXELS

How thick the meter bar should be (in pixels).

This macro is used when one wants to display a "meter bar" within an HTML page. The macro will insert the necessary HTML, such that one can use JavaScript to then make the bar longer (and adjust the color) to indicate a percentage. The was initially created to facilitate the CPU usage bar.

Example of using the macro:

@meterBar("diskUsage","8")
@meterBar("memoryUsage","8")

@javascriptBegin()
function update(id, percent) {
  var e = document.getElementById(id);
  if (e) {
    e.style.width = "" + percent + "%";
    if (percent < 25.0) {
      e.style.backgroundColor = "@cpuUsageLow()";
    } else if (percent < 75.0) {
      e.style.backgroundColor = "@cpuUsageMedium()";
    } else {
      e.style.backgroundColor = "@cpuUsageHigh()";
    }
  }
}

update(diskUsage, 22);
update(memoryUsage, 45);
@javascriptEnd()

Assuming the com.ccg.macros.at.All class is within your CLASSPATH and the config/html.at macros file has been generated (Hint: run make atmacros in the wui directory), a developer should be able to run the above example by copy/pasting from below:

[root@probe root]# java com.ccg.macros.at.All <<EOF
@include("config/html.at",,"d")

@meterBar("diskUsage","8")
@meterBar("memoryUsage","8")

@javascriptBegin()
function update(id, percent) {
  var e = document.getElementById(id);
  if (e) {
    e.style.width = "" + percent + "%";
    if (percent < 25.0) {
      e.style.backgroundColor = "@cpuUsageLow()";
    } else if (percent < 75.0) {
      e.style.backgroundColor = "@cpuUsageMedium()";
    } else {
      e.style.backgroundColor = "@cpuUsageHigh()";
    }
  }
}

update(diskUsage, 22);
update(memoryUsage, 45);
@javascriptEnd()


EOF

This macro is defined as:

<div @htmlAttr("style","height: @param(1)px;")>
  <div @htmlAttr("id","@param(0)") @htmlAttr("style","height: @param(1)px;")><img @htmlAttr("width","0") @htmlAttr("height","@param(1)") @htmlAttr("alt","CPU Meter") @htmlAttr("src","/nstwui/images/transparent_pixel.gif") /></div>
</div>