Enabling the behavior - updating the status periodically

This is an archived page. It's not actively maintained.


Now that we have code to retrieve tinderbox status and update the icon, we need to run it periodically.

function loadTinderboxStatus() {
  gXMLHttpRequest = new XMLHttpRequest();
  gXMLHttpRequest.onload = updateTinderboxStatus;
  gXMLHttpRequest.open("GET", "http://tinderbox.mozilla.org/SeaMonkey/panel.html");
  window.setTimeout(loadTinderboxStatus, 60000);

window.setTimeout(loadTinderboxStatus, 1000);

window.setTimeout schedules functions to run at some future time. We use it inside the loadTinderboxStatus function to make that function run a second (1,000 milliseconds) after startup and a minute (60,000 milliseconds) after each invocation. This allows users to get relatively frequent updates about tinderbox without overloading the tinderbox server or slowing down Mozilla with requests.

Our code is now ready to run, but Mozilla doesn't know about it yet. To enable its functionality, we have to add a reference to our JavaScript code into navigator.xul, just as we put a reference to our CSS code into that file back in Specifying the appearance. Put the JavaScript code into a file called tinderstatus.js in the same directory as navigator.xul and reference it in navigator.xul where other JavaScript scripts are referenced:


<!-- Navigator -->
<script type="application/javascript"
<script type="application/javascript"
<script type="application/javascript"
<script type="application/javascript"

<script type="application/javascript"

<!-- hook for stringbundle overlays -->


With this code in place, restarting Mozilla should cause the Tinderbox status panel to display the current tinderbox state. To confirm this state, go to Tinderbox and verify that the panel displays the current worst state of active tinderbox clients.