• Hugo Lefeuvre's avatar
    chatview: major cleanup · 368c47c5
    Hugo Lefeuvre authored
    Despite of the recent optimization commits, the chatview is still
    affected by a significant number of performance issues. This commit
    tries to address some of them:
    * Use getElementById instead of querySelector, when possible.
    * Use getElementByClassName instead of querySelector, when possible.
    (querySelector is in average 2x slower than getElementById or
    In this commit we also address the following bugs:
    * printHistoryPart: it doesn't make any sense to call
      addOrUpdateMessage if we are at the end of the buffer.
    * the bottom padding of the body isn't updated with the size of
      the #message textarea, leading to an annoying overlap when writing
      large messages.
    * selection highlighting in the chatview is crappy. The user should
      not be able to highlight the background because it doesn't make
      any sense. Only meaningful elements should be highlightable.
    * The first time a message fails to be sent, the cross 'X' icon
      is displayed with a very bad looking shift to the right. This is
      because the 'sending' icon is still displayed, with visibility
    * Many variables were not declared / using some broken, ancient
      JavaScript Sith magic we don't want to mess with. In order to make
      sure we are not going to rely on such mechanisms anymore, add
      "use strict" stanza.
    In addition to that we also fix a _very_ large number of style issues
    (semicolons, indentation, comments) and define a clear style policy
    for the JS code.
    A code audit revealed several small bugs which we are not going to
    address in this commit. Add FIXME comments.
    Also, remove some useless debug warnings from the GTK side chatview
    Change-Id: If6b605868ba6b0b9623ae01c5293064211b58327
    Reviewed-by: Sébastien Blin's avatarSebastien Blin <sebastien.blin@savoirfairelinux.com>