Skip to content

Thunderbird Jetpack Teasers: Words per Minute in Compose

jetpack.future.import("thunderbird.compose");
jetpack.thunderbird.compose.appendComposePanel({
  onReady: function (panel, composeContext) {
    let doc = panel.contentDocument;
    let msgNode = $("<span />", doc.body).appendTo(doc.body);
 
    let started = Date.now();
    setInterval(function() {
      let words = composeContext.getPlaintextContents().split(/\s+/);
      let secs = Math.ceil((Date.now() - started) / 1000);
      let wordsPerMinute = Math.floor((words.length * 60) / secs);
      msgNode.text(wordsPerMinute + " words per minute.");
    }, 1000);
 
    panel.show();
  },
  html: <><body style="overflow: hidden"></body></>
});

thunderbird-jetpack-words-per-minute-example

{ 2 } Comments

  1. Aza Raskin | November 22, 2009 at 6:24 pm | Permalink

    Insanely cool. Although I wonder why we need “compose” in appendComposePanel when it lives off of the compose namespace?

  2. Andrew Sutherland | November 22, 2009 at 8:43 pm | Permalink

    Yeah, it’s not a good name. While I think we want ‘compose’ or something like it to expose multiple injection points in the compose window, neither compose or panel really differentiates that injection point from other potential injection points in the window.

    For example, the compose window has a sidebar that would make a good injection point. That somewhat overlaps with the slidebar, but I think it may make a far bit of sense to just surface that functionality through a window-specific namespace rather than having to expose all the parameters on the slidebar interface or requiring a second layer of callbacks to get at the composition context. I’d appreciate your thoughts on that (though likely on a better communication medium than my blog comments).

{ 1 } Trackback

  1. [...] you’re interested in this take a look at Andrew’s recent Jetpack in Thunderbird [...]