Fossil

Artifact [ec0dcc190d]
Login

Artifact ec0dcc190dade4e252183b6a4e9a0063a8032365934be1f3240d5c4b502a8134:

Wiki page [branch/tooltip-copyhash] by florian 2019-07-26 08:58:41.
D 2019-07-26T08:58:41.390
L branch/tooltip-copyhash
N text/x-markdown
P cc0712597ff996d06f51c49ef28344bcbb1fd64d32ddc0ac7af45fa93d9e3a51
U florian
W 4687
__TODO:__

* ☑️ <del>Trim the length of the copied hashes to the limit defined by the [`hash-digits`](/help?cmd=hash-digits) setting.</del>
* ☑️ <del>Also apply the same limit to the link text for hashes?</del>
* ☑️ <del>Reevaluate the position of the "Copy Hash" icon on the tooltip.</del>
* ❌ <del>Refresh my trigonometry skills, and calculate the outline of the icon more accurately.</del> See comment below.

__Copy text to clipboard using Javascript:__

* <https://stackoverflow.com/questions/400212/how-do-i-copy-to-the-clipboard-in-javascript>
* <https://stackoverflow.com/questions/46275918/copy-plain-text-with-no-rich-styles-to-clipboard-without-losing-focus>
* <https://blog.codeinside.eu/2016/05/12/copy-to-clipboard-with-javascript/>
* <https://techoverflow.net/2018/03/30/copying-strings-to-the-clipboard-using-pure-javascript/>

__Uncompressed source code for the "Copy Hash" icon:__

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 14 14" width="64" height="64">
<path
  style="fill: black; opacity:0"
  d="M 14 14 H 0 V 0 h 14 v 14 z" />
<path
  style="fill:rgb(240,240,240)"
  d="M 1 0 h 6.6 l 2 2 h 1 l 3.4 3.4 v 8.6 h -10 v -2 h -3 z" />
<path
  style="fill:rgb(64,64,64)"
  d="M 2 1 h 5 l 3 3 v 7 h -8 z" />
<path
  style="fill:rgb(248,248,248)"
  d="M 3 2 h 3.6 l 2.4 2.4 v 5.6 h -6 z" />
<path
  style="fill:rgb(80,128,208)"
  d="M 4 5 h 4 v 1 h -4 z m 0 2 h 4 v 1 h -4 z" />
<path
  style="fill:rgb(64,64,64)"
  d="M 5 3 h 5 l 3 3 v 7 h -8 z" />
<path
  style="fill:rgb(248,248,248)"
  d="M 10 4.4 v 1.6 h 1.6 z m -4 -0.6 h 3 v 3 h -3 z m 0 3 h 6 v 5.4 h -6 z" />
<path
  style="fill:rgb(80,128,208)"
  d="M 7 8 h 4 v 1 h -4 z m 0 2 h 4 v 1 h -4 z" />
</svg>

    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 14 14">
    <path
      style="fill: black; opacity:0"
      d="M 14 14 H 0 V 0 h 14 v 14 z" />
    <path
      style="fill:rgb(240,240,240)"
      d="M 1 0 h 6.6 l 2 2 h 1 l 3.4 3.4 v 8.6 h -10 v -2 h -3 z" />
    <path
      style="fill:rgb(64,64,64)"
      d="M 2 1 h 5 l 3 3 v 7 h -8 z" />
    <path
      style="fill:rgb(248,248,248)"
      d="M 3 2 h 3.6 l 2.4 2.4 v 5.6 h -6 z" />
    <path
      style="fill:rgb(80,128,208)"
      d="M 4 5 h 4 v 1 h -4 z m 0 2 h 4 v 1 h -4 z" />
    <path
      style="fill:rgb(64,64,64)"
      d="M 5 3 h 5 l 3 3 v 7 h -8 z" />
    <path
      style="fill:rgb(248,248,248)"
      d="M 10 4.4 v 1.6 h 1.6 z m -4 -0.6 h 3 v 3 h -3 z m 0 3 h 6 v 5.4 h -6 z" />
    <path
      style="fill:rgb(80,128,208)"
      d="M 7 8 h 4 v 1 h -4 z m 0 2 h 4 v 1 h -4 z" />
    </svg>

Following are example and source code for the icon with the outline calculated more accurately, i.e. narrower on the sloping side. Yet it turns out the original variant (drawn by eye) looks better at small sizes of 14 to 64 (device) pixels on dark backgrounds, due to the resulting softer anti-aliasing on the sloping side.

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 14 14" width="64" height="64">
<path
  style="fill: black; opacity:0"
  d="M 14 14 H 0 V 0 h 14 v 14 z" />
<path
  style="fill:rgb(240,240,240)"
  d="M 1 0 h 6.42 l 2 2 h 1 l 3.58 3.58 v 8.42 h -10 v -2 h -3 z" />
<path
  style="fill:rgb(64,64,64)"
  d="M 2 1 h 5 l 3 3 v 7 h -8 z" />
<path
  style="fill:rgb(248,248,248)"
  d="M 3 2 h 3.6 l 2.4 2.4 v 5.6 h -6 z" />
<path
  style="fill:rgb(80,128,208)"
  d="M 4 5 h 4 v 1 h -4 z m 0 2 h 4 v 1 h -4 z" />
<path
  style="fill:rgb(64,64,64)"
  d="M 5 3 h 5 l 3 3 v 7 h -8 z" />
<path
  style="fill:rgb(248,248,248)"
  d="M 10 4.4 v 1.6 h 1.6 z m -4 -0.6 h 3 v 3 h -3 z m 0 3 h 6 v 5.4 h -6 z" />
<path
  style="fill:rgb(80,128,208)"
  d="M 7 8 h 4 v 1 h -4 z m 0 2 h 4 v 1 h -4 z" />
</svg>

    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 14 14">
    <path
      style="fill: black; opacity:0"
      d="M 14 14 H 0 V 0 h 14 v 14 z" />
    <path
      style="fill:rgb(240,240,240)"
      d="M 1 0 h 6.42 l 2 2 h 1 l 3.58 3.58 v 8.42 h -10 v -2 h -3 z" />
    <path
      style="fill:rgb(64,64,64)"
      d="M 2 1 h 5 l 3 3 v 7 h -8 z" />
    <path
      style="fill:rgb(248,248,248)"
      d="M 3 2 h 3.6 l 2.4 2.4 v 5.6 h -6 z" />
    <path
      style="fill:rgb(80,128,208)"
      d="M 4 5 h 4 v 1 h -4 z m 0 2 h 4 v 1 h -4 z" />
    <path
      style="fill:rgb(64,64,64)"
      d="M 5 3 h 5 l 3 3 v 7 h -8 z" />
    <path
      style="fill:rgb(248,248,248)"
      d="M 10 4.4 v 1.6 h 1.6 z m -4 -0.6 h 3 v 3 h -3 z m 0 3 h 6 v 5.4 h -6 z" />
    <path
      style="fill:rgb(80,128,208)"
      d="M 7 8 h 4 v 1 h -4 z m 0 2 h 4 v 1 h -4 z" />
    </svg>
Z 4b9963a14b38036f5811a7c7b7d02541