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

3 thoughts on “Thunderbird Jetpack Teasers: Words per Minute in Compose

  1. 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).

  2. Pingback: Bryan Clark » Blog Archive » Try other web apps in Thunderbird tabs

Comments are closed.