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).
Commit
6a54cf2939a54f389d1383a7e60e47dcaa936f1a8b7c71b40ac3c6f822220b01
Parent
148b01359c84444…
1 file changed
+1
-1
+1
-1
| --- src/copybtn.js | ||
| +++ src/copybtn.js | ||
| @@ -58,11 +58,11 @@ | ||
| 58 | 58 | this.style.transition = "opacity 400ms ease-in-out"; |
| 59 | 59 | this.style.opacity = 0; |
| 60 | 60 | var idTarget = this.getAttribute("data-copytarget"); |
| 61 | 61 | var elTarget = document.getElementById(idTarget); |
| 62 | 62 | if( elTarget ){ |
| 63 | - var text = elTarget.innerText; | |
| 63 | + var text = elTarget.innerText.replace(/^\s+|\s+$/g,''); | |
| 64 | 64 | var cchLength = parseInt(this.getAttribute("data-copylength")); |
| 65 | 65 | if( !isNaN(cchLength) && cchLength>0 ){ |
| 66 | 66 | text = text.slice(0,cchLength); // Assume single-byte chars. |
| 67 | 67 | } |
| 68 | 68 | copyTextToClipboard(text); |
| 69 | 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; |
| 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 |