[applet.js] Remove code duplication in two similar applet classes

TextApplet and TextIconApplet are virtually identical, with only the
prototype being different, and one (seemingly unused) function added
in the latter, so why not use some JavaScript magic to avoid code duplication.