Fossil

Check-in [b9823751]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Check that the value of the "data-copylength" attribute is a positive number prior to chopping the text.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tooltip-copyhash
Files: files | file ages | folders
SHA3-256: b9823751c95cc96fa808b4826eef7637de3dd7935c25236766473fddd4195cad
User & Date: florian 2019-05-31 14:44:00
Wiki:tooltip-copyhash
Context
2019-05-31
15:01
Revamp the comments, and refactor the code in preparation for an auto-init functionality for HTML-defined buttons. check-in: 7fddf96c user: florian tags: tooltip-copyhash
14:44
Check that the value of the "data-copylength" attribute is a positive number prior to chopping the text. check-in: b9823751 user: florian tags: tooltip-copyhash
2019-05-30
11:33
Add the "data-copylength" attribute to control the length of the copied text. (Rationale: Allow copying just the shortened hash prefixes from elements displaying the full-length hashes, because the short forms are preferred when building command-lines or URLs, and because the full-length hashes are already much easier to copy.) check-in: 2e17a063 user: florian tags: tooltip-copyhash
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/copybtn.js.

33
34
35
36
37
38
39
40

41

42
43
44
45
46
47
48
  lockCopyText = true;
  this.style.transition = "opacity 400ms ease-in-out";
  this.style.opacity = 0;
  var idTarget = this.getAttribute("data-copytarget");
  var elTarget = document.getElementById(idTarget);
  if( elTarget ){
    var text = elTarget.innerText;
    var cchLength = this.getAttribute("data-copylength");

    if( cchLength ) text = text.slice(0,cchLength); // Assume single-byte chars.

    copyTextToClipboard(text);
  }
  setTimeout(function(id){
    var elButton = document.getElementById(id);
    if( elButton ){
      elButton.style.transition = "";
      elButton.style.opacity = 1;







|
>
|
>







33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
  lockCopyText = true;
  this.style.transition = "opacity 400ms ease-in-out";
  this.style.opacity = 0;
  var idTarget = this.getAttribute("data-copytarget");
  var elTarget = document.getElementById(idTarget);
  if( elTarget ){
    var text = elTarget.innerText;
    var cchLength = parseInt(this.getAttribute("data-copylength"));
    if( !isNaN(cchLength) && cchLength>0 ){
      text = text.slice(0,cchLength);   // Assume single-byte chars.
    }
    copyTextToClipboard(text);
  }
  setTimeout(function(id){
    var elButton = document.getElementById(id);
    if( elButton ){
      elButton.style.transition = "";
      elButton.style.opacity = 1;