Fossil SCM

Trim leading and trailing white space from the text to be copied to clipboard (do this in Javascript, so no need to care about the extra white space when generating HTML elements).

florian 2019-06-02 12:32 tooltip-copyhash
Commit 6a54cf2939a54f389d1383a7e60e47dcaa936f1a8b7c71b40ac3c6f822220b01
1 file changed +1 -1
+1 -1
--- src/copybtn.js
+++ src/copybtn.js
@@ -58,11 +58,11 @@
5858
this.style.transition = "opacity 400ms ease-in-out";
5959
this.style.opacity = 0;
6060
var idTarget = this.getAttribute("data-copytarget");
6161
var elTarget = document.getElementById(idTarget);
6262
if( elTarget ){
63
- var text = elTarget.innerText;
63
+ var text = elTarget.innerText.replace(/^\s+|\s+$/g,'');
6464
var cchLength = parseInt(this.getAttribute("data-copylength"));
6565
if( !isNaN(cchLength) && cchLength>0 ){
6666
text = text.slice(0,cchLength); // Assume single-byte chars.
6767
}
6868
copyTextToClipboard(text);
6969
--- src/copybtn.js
+++ src/copybtn.js
@@ -58,11 +58,11 @@
58 this.style.transition = "opacity 400ms ease-in-out";
59 this.style.opacity = 0;
60 var idTarget = this.getAttribute("data-copytarget");
61 var elTarget = document.getElementById(idTarget);
62 if( elTarget ){
63 var text = elTarget.innerText;
64 var cchLength = parseInt(this.getAttribute("data-copylength"));
65 if( !isNaN(cchLength) && cchLength>0 ){
66 text = text.slice(0,cchLength); // Assume single-byte chars.
67 }
68 copyTextToClipboard(text);
69
--- src/copybtn.js
+++ src/copybtn.js
@@ -58,11 +58,11 @@
58 this.style.transition = "opacity 400ms ease-in-out";
59 this.style.opacity = 0;
60 var idTarget = this.getAttribute("data-copytarget");
61 var elTarget = document.getElementById(idTarget);
62 if( elTarget ){
63 var text = elTarget.innerText.replace(/^\s+|\s+$/g,'');
64 var cchLength = parseInt(this.getAttribute("data-copylength"));
65 if( !isNaN(cchLength) && cchLength>0 ){
66 text = text.slice(0,cchLength); // Assume single-byte chars.
67 }
68 copyTextToClipboard(text);
69

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button