Fossil SCM
Demonstration of the copybtn.js module beyond tooltips: add a copy button near the full-length hash of check-ins on the /info page, to copy only the hash prefix when clicked.
Commit
46f91da1a8d867c6dfa19a694dfed7dfe522d9f6d84f6442c989a98a33151c1a
Parent
148b01359c84444…
1 file changed
+10
-1
+10
-1
| --- src/info.c | ||
| +++ src/info.c | ||
| @@ -652,10 +652,16 @@ | ||
| 652 | 652 | ReCompiled *pRe = 0; /* regex */ |
| 653 | 653 | const char *zW; /* URL param for ignoring whitespace */ |
| 654 | 654 | const char *zPage = "vinfo"; /* Page that shows diffs */ |
| 655 | 655 | const char *zPageHide = "ci"; /* Page that hides diffs */ |
| 656 | 656 | |
| 657 | +/* Preprocessor definitions copied from src\printf.c. */ | |
| 658 | +#ifndef FOSSIL_HASH_DIGITS | |
| 659 | +# define FOSSIL_HASH_DIGITS 10 | |
| 660 | +#endif | |
| 661 | + int nDigitHuman = db_get_int("hash-digits", FOSSIL_HASH_DIGITS); | |
| 662 | + | |
| 657 | 663 | login_check_credentials(); |
| 658 | 664 | if( !g.perm.Read ){ login_needed(g.anon.Read); return; } |
| 659 | 665 | zName = P("name"); |
| 660 | 666 | rid = name_to_rid_www("name"); |
| 661 | 667 | if( rid==0 ){ |
| @@ -793,11 +799,14 @@ | ||
| 793 | 799 | @ | %z(href("%R/fileage?name=%!S",zUuid))file ages</a> |
| 794 | 800 | @ | %z(href("%R/tree?nofiles&type=tree&ci=%!S",zUuid))folders</a> |
| 795 | 801 | @ </td> |
| 796 | 802 | @ </tr> |
| 797 | 803 | |
| 798 | - @ <tr><th>%s(hname_alg(nUuid)):</th><td>%.32s(zUuid)<wbr>%s(zUuid+32) | |
| 804 | + @ <tr><th>%s(hname_alg(nUuid)):</th><td> | |
| 805 | + @ <span class="copy-button" id="copy-fullhash" data-copytarget="fullhash" | |
| 806 | + @ data-copylength="%d(nDigitHuman)"></span> | |
| 807 | + @ <span id="fullhash">%.32s(zUuid)<wbr>%s(zUuid+32)</span> | |
| 799 | 808 | if( g.perm.Setup ){ |
| 800 | 809 | @ (Record ID: %d(rid)) |
| 801 | 810 | } |
| 802 | 811 | @ </td></tr> |
| 803 | 812 | @ <tr><th>User & Date:</th><td> |
| 804 | 813 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -652,10 +652,16 @@ | |
| 652 | ReCompiled *pRe = 0; /* regex */ |
| 653 | const char *zW; /* URL param for ignoring whitespace */ |
| 654 | const char *zPage = "vinfo"; /* Page that shows diffs */ |
| 655 | const char *zPageHide = "ci"; /* Page that hides diffs */ |
| 656 | |
| 657 | login_check_credentials(); |
| 658 | if( !g.perm.Read ){ login_needed(g.anon.Read); return; } |
| 659 | zName = P("name"); |
| 660 | rid = name_to_rid_www("name"); |
| 661 | if( rid==0 ){ |
| @@ -793,11 +799,14 @@ | |
| 793 | @ | %z(href("%R/fileage?name=%!S",zUuid))file ages</a> |
| 794 | @ | %z(href("%R/tree?nofiles&type=tree&ci=%!S",zUuid))folders</a> |
| 795 | @ </td> |
| 796 | @ </tr> |
| 797 | |
| 798 | @ <tr><th>%s(hname_alg(nUuid)):</th><td>%.32s(zUuid)<wbr>%s(zUuid+32) |
| 799 | if( g.perm.Setup ){ |
| 800 | @ (Record ID: %d(rid)) |
| 801 | } |
| 802 | @ </td></tr> |
| 803 | @ <tr><th>User & Date:</th><td> |
| 804 |
| --- src/info.c | |
| +++ src/info.c | |
| @@ -652,10 +652,16 @@ | |
| 652 | ReCompiled *pRe = 0; /* regex */ |
| 653 | const char *zW; /* URL param for ignoring whitespace */ |
| 654 | const char *zPage = "vinfo"; /* Page that shows diffs */ |
| 655 | const char *zPageHide = "ci"; /* Page that hides diffs */ |
| 656 | |
| 657 | /* Preprocessor definitions copied from src\printf.c. */ |
| 658 | #ifndef FOSSIL_HASH_DIGITS |
| 659 | # define FOSSIL_HASH_DIGITS 10 |
| 660 | #endif |
| 661 | int nDigitHuman = db_get_int("hash-digits", FOSSIL_HASH_DIGITS); |
| 662 | |
| 663 | login_check_credentials(); |
| 664 | if( !g.perm.Read ){ login_needed(g.anon.Read); return; } |
| 665 | zName = P("name"); |
| 666 | rid = name_to_rid_www("name"); |
| 667 | if( rid==0 ){ |
| @@ -793,11 +799,14 @@ | |
| 799 | @ | %z(href("%R/fileage?name=%!S",zUuid))file ages</a> |
| 800 | @ | %z(href("%R/tree?nofiles&type=tree&ci=%!S",zUuid))folders</a> |
| 801 | @ </td> |
| 802 | @ </tr> |
| 803 | |
| 804 | @ <tr><th>%s(hname_alg(nUuid)):</th><td> |
| 805 | @ <span class="copy-button" id="copy-fullhash" data-copytarget="fullhash" |
| 806 | @ data-copylength="%d(nDigitHuman)"></span> |
| 807 | @ <span id="fullhash">%.32s(zUuid)<wbr>%s(zUuid+32)</span> |
| 808 | if( g.perm.Setup ){ |
| 809 | @ (Record ID: %d(rid)) |
| 810 | } |
| 811 | @ </td></tr> |
| 812 | @ <tr><th>User & Date:</th><td> |
| 813 |