function renderState(state, time) {
  const now = Date.now();
  const diff = Math.round((time - now) / 1000);
  const str =
    diff == 0
      ? 'now'
      : Math.abs(diff) + ' seconds ' + (diff > 0 ? 'from now' : 'ago');
  const col = state == 'active' ? '#009900' : '#990000';
  return "<b style='color: " + col + "'>" + state + '</b> ' + str;
}
Convert a state and time into a nice styled chunk of HTML.