Fossil SCM

Minor improvements to the copy-button logic.

drh 2019-06-07 13:15 trunk merge
Commit 759fbda4e8963d89d157ef45b7329f33fb1c5ec633130ffcd6442d8ecf8f72d6
--- src/copybtn.js
+++ src/copybtn.js
@@ -30,10 +30,11 @@
3030
elButton.id = "copy-" + idTarget;
3131
initCopyButton(elButton,idTarget,cchLength);
3232
return elButton;
3333
}
3434
function initCopyButtonById(idButton,idTarget,cchLength){
35
+ idButton = idButton || "copy-" + idTarget;
3536
var elButton = document.getElementById(idButton);
3637
if( elButton ) initCopyButton(elButton,idTarget,cchLength);
3738
return elButton;
3839
}
3940
function initCopyButton(elButton,idTarget,cchLength){
4041
--- src/copybtn.js
+++ src/copybtn.js
@@ -30,10 +30,11 @@
30 elButton.id = "copy-" + idTarget;
31 initCopyButton(elButton,idTarget,cchLength);
32 return elButton;
33 }
34 function initCopyButtonById(idButton,idTarget,cchLength){
 
35 var elButton = document.getElementById(idButton);
36 if( elButton ) initCopyButton(elButton,idTarget,cchLength);
37 return elButton;
38 }
39 function initCopyButton(elButton,idTarget,cchLength){
40
--- src/copybtn.js
+++ src/copybtn.js
@@ -30,10 +30,11 @@
30 elButton.id = "copy-" + idTarget;
31 initCopyButton(elButton,idTarget,cchLength);
32 return elButton;
33 }
34 function initCopyButtonById(idButton,idTarget,cchLength){
35 idButton = idButton || "copy-" + idTarget;
36 var elButton = document.getElementById(idButton);
37 if( elButton ) initCopyButton(elButton,idTarget,cchLength);
38 return elButton;
39 }
40 function initCopyButton(elButton,idTarget,cchLength){
41
--- src/default_css.txt
+++ src/default_css.txt
@@ -787,5 +787,8 @@
787787
.copy-button-flipped {
788788
//Note: .16em is suitable for element grouping.
789789
margin-left: .16em;
790790
margin-right: 0;
791791
}
792
+.nobr {
793
+ white-space: nowrap;
794
+}
792795
--- src/default_css.txt
+++ src/default_css.txt
@@ -787,5 +787,8 @@
787 .copy-button-flipped {
788 //Note: .16em is suitable for element grouping.
789 margin-left: .16em;
790 margin-right: 0;
791 }
 
 
 
792
--- src/default_css.txt
+++ src/default_css.txt
@@ -787,5 +787,8 @@
787 .copy-button-flipped {
788 //Note: .16em is suitable for element grouping.
789 margin-left: .16em;
790 margin-right: 0;
791 }
792 .nobr {
793 white-space: nowrap;
794 }
795
+12 -19
--- src/info.c
+++ src/info.c
@@ -763,15 +763,14 @@
763763
" AND tag.tagid=tagxref.tagid "
764764
" AND +tag.tagname GLOB 'sym-*'", rid);
765765
while( db_step(&q2)==SQLITE_ROW ){
766766
const char *zTagName = db_column_text(&q2, 0);
767767
if( fossil_strcmp(zTagName,zBrName)==0 ){
768
- @ | <span class="copy-button" id="copy-name-br"
769
- @ data-copytarget="name-br" data-copylength="0">
770
- @ </span><span id="name-br"><!--
771
- @ -->%z(href("%R/timeline?r=%T&unhide",zTagName))%h(zTagName)</a>
772
- @ </span>
768
+ cgi_printf(" | ");
769
+ style_copy_button(1, "name-br", 0, 0, "%z%h</a>",
770
+ href("%R/timeline?r=%T&unhide",zTagName), zTagName);
771
+ cgi_printf("\n");
773772
if( wiki_tagid2("branch",zTagName)!=0 ){
774773
blob_appendf(&wiki_read_links, " | %z%h</a>",
775774
href("%R/wiki?name=branch/%h",zTagName), zTagName);
776775
}else if( g.perm.Write && g.perm.WrWiki ){
777776
blob_appendf(&wiki_add_links, " | %z%h</a>",
@@ -798,15 +797,13 @@
798797
@ | %z(href("%R/tree?nofiles&type=tree&ci=%!S",zUuid))folders</a>
799798
@ </td>
800799
@ </tr>
801800
802801
@ <tr><th>%s(hname_alg(nUuid)):</th><td>
803
- @ <span class="copy-button" id="copy-hash-ci"
804
- @ data-copytarget="hash-ci" data-copylength="%d(hash_digits(1))">
805
- @ </span><span id="hash-ci">%.32s(zUuid)<wbr>%s(zUuid+32)</span>
802
+ style_copy_button(1, "hash-ci", 0, 2, "%.32s<wbr>%s", zUuid, zUuid+32);
806803
if( g.perm.Setup ){
807
- @ (Record ID: %d(rid))
804
+ @ (Record ID: %d(rid))
808805
}
809806
@ </td></tr>
810807
@ <tr><th>User&nbsp;&amp;&nbsp;Date:</th><td>
811808
hyperlink_to_user(zUser,zDate," on ");
812809
hyperlink_to_date(zDate, "</td></tr>");
@@ -1919,19 +1916,17 @@
19191916
}else{
19201917
style_submenu_element("Shun", "%s/shun?shun=%s#addshun", g.zTop, zUuid);
19211918
}
19221919
}
19231920
style_header("Hex Artifact Content");
1924
- style_copy_button();
19251921
zUuid = db_text("?","SELECT uuid FROM blob WHERE rid=%d", rid);
19261922
@ <h2>Artifact
1927
- @ <span class="copy-button" id="copy-hash-ar"
1928
- @ data-copytarget="hash-ar" data-copylength="%d(hash_digits(1))">
1923
+ style_copy_button(1, "hash-ar", 0, 2, "%s", zUuid);
19291924
if( g.perm.Setup ){
1930
- @ </span><span id="hash-ar">%s(zUuid)</span> (%d(rid)):</h2>
1925
+ @ (%d(rid)):</h2>
19311926
}else{
1932
- @ </span><span id="hash-ar">%s(zUuid)</span>:</h2>
1927
+ @ :</h2>
19331928
}
19341929
blob_zero(&downloadName);
19351930
if( P("verbose")!=0 ) objdescFlags |= OBJDESC_DETAIL;
19361931
object_description(rid, objdescFlags, &downloadName);
19371932
style_submenu_element("Download", "%s/raw/%T?name=%s",
@@ -2194,18 +2189,16 @@
21942189
zUuid = db_text("?", "SELECT uuid FROM blob WHERE rid=%d", rid);
21952190
if( isFile ){
21962191
@ <h2>Latest version of file '%h(zName)':</h2>
21972192
style_submenu_element("Artifact", "%R/artifact/%S", zUuid);
21982193
}else{
2199
- style_copy_button();
22002194
@ <h2>Artifact
2201
- @ <span class="copy-button" id="copy-hash-ar"
2202
- @ data-copytarget="hash-ar" data-copylength="%d(hash_digits(1))">
2195
+ style_copy_button(1, "hash-ar", 0, 2, "%s", zUuid);
22032196
if( g.perm.Setup ){
2204
- @ </span><span id="hash-ar">%s(zUuid)</span> (%d(rid)):</h2>
2197
+ @ (%d(rid)):</h2>
22052198
}else{
2206
- @ </span><span id="hash-ar">%s(zUuid)</span>:</h2>
2199
+ @ :</h2>
22072200
}
22082201
}
22092202
blob_zero(&downloadName);
22102203
asText = P("txt")!=0;
22112204
if( asText ) objdescFlags &= ~OBJDESC_BASE;
22122205
--- src/info.c
+++ src/info.c
@@ -763,15 +763,14 @@
763 " AND tag.tagid=tagxref.tagid "
764 " AND +tag.tagname GLOB 'sym-*'", rid);
765 while( db_step(&q2)==SQLITE_ROW ){
766 const char *zTagName = db_column_text(&q2, 0);
767 if( fossil_strcmp(zTagName,zBrName)==0 ){
768 @ | <span class="copy-button" id="copy-name-br"
769 @ data-copytarget="name-br" data-copylength="0">
770 @ </span><span id="name-br"><!--
771 @ -->%z(href("%R/timeline?r=%T&unhide",zTagName))%h(zTagName)</a>
772 @ </span>
773 if( wiki_tagid2("branch",zTagName)!=0 ){
774 blob_appendf(&wiki_read_links, " | %z%h</a>",
775 href("%R/wiki?name=branch/%h",zTagName), zTagName);
776 }else if( g.perm.Write && g.perm.WrWiki ){
777 blob_appendf(&wiki_add_links, " | %z%h</a>",
@@ -798,15 +797,13 @@
798 @ | %z(href("%R/tree?nofiles&type=tree&ci=%!S",zUuid))folders</a>
799 @ </td>
800 @ </tr>
801
802 @ <tr><th>%s(hname_alg(nUuid)):</th><td>
803 @ <span class="copy-button" id="copy-hash-ci"
804 @ data-copytarget="hash-ci" data-copylength="%d(hash_digits(1))">
805 @ </span><span id="hash-ci">%.32s(zUuid)<wbr>%s(zUuid+32)</span>
806 if( g.perm.Setup ){
807 @ (Record ID: %d(rid))
808 }
809 @ </td></tr>
810 @ <tr><th>User&nbsp;&amp;&nbsp;Date:</th><td>
811 hyperlink_to_user(zUser,zDate," on ");
812 hyperlink_to_date(zDate, "</td></tr>");
@@ -1919,19 +1916,17 @@
1919 }else{
1920 style_submenu_element("Shun", "%s/shun?shun=%s#addshun", g.zTop, zUuid);
1921 }
1922 }
1923 style_header("Hex Artifact Content");
1924 style_copy_button();
1925 zUuid = db_text("?","SELECT uuid FROM blob WHERE rid=%d", rid);
1926 @ <h2>Artifact
1927 @ <span class="copy-button" id="copy-hash-ar"
1928 @ data-copytarget="hash-ar" data-copylength="%d(hash_digits(1))">
1929 if( g.perm.Setup ){
1930 @ </span><span id="hash-ar">%s(zUuid)</span> (%d(rid)):</h2>
1931 }else{
1932 @ </span><span id="hash-ar">%s(zUuid)</span>:</h2>
1933 }
1934 blob_zero(&downloadName);
1935 if( P("verbose")!=0 ) objdescFlags |= OBJDESC_DETAIL;
1936 object_description(rid, objdescFlags, &downloadName);
1937 style_submenu_element("Download", "%s/raw/%T?name=%s",
@@ -2194,18 +2189,16 @@
2194 zUuid = db_text("?", "SELECT uuid FROM blob WHERE rid=%d", rid);
2195 if( isFile ){
2196 @ <h2>Latest version of file '%h(zName)':</h2>
2197 style_submenu_element("Artifact", "%R/artifact/%S", zUuid);
2198 }else{
2199 style_copy_button();
2200 @ <h2>Artifact
2201 @ <span class="copy-button" id="copy-hash-ar"
2202 @ data-copytarget="hash-ar" data-copylength="%d(hash_digits(1))">
2203 if( g.perm.Setup ){
2204 @ </span><span id="hash-ar">%s(zUuid)</span> (%d(rid)):</h2>
2205 }else{
2206 @ </span><span id="hash-ar">%s(zUuid)</span>:</h2>
2207 }
2208 }
2209 blob_zero(&downloadName);
2210 asText = P("txt")!=0;
2211 if( asText ) objdescFlags &= ~OBJDESC_BASE;
2212
--- src/info.c
+++ src/info.c
@@ -763,15 +763,14 @@
763 " AND tag.tagid=tagxref.tagid "
764 " AND +tag.tagname GLOB 'sym-*'", rid);
765 while( db_step(&q2)==SQLITE_ROW ){
766 const char *zTagName = db_column_text(&q2, 0);
767 if( fossil_strcmp(zTagName,zBrName)==0 ){
768 cgi_printf(" | ");
769 style_copy_button(1, "name-br", 0, 0, "%z%h</a>",
770 href("%R/timeline?r=%T&unhide",zTagName), zTagName);
771 cgi_printf("\n");
 
772 if( wiki_tagid2("branch",zTagName)!=0 ){
773 blob_appendf(&wiki_read_links, " | %z%h</a>",
774 href("%R/wiki?name=branch/%h",zTagName), zTagName);
775 }else if( g.perm.Write && g.perm.WrWiki ){
776 blob_appendf(&wiki_add_links, " | %z%h</a>",
@@ -798,15 +797,13 @@
797 @ | %z(href("%R/tree?nofiles&type=tree&ci=%!S",zUuid))folders</a>
798 @ </td>
799 @ </tr>
800
801 @ <tr><th>%s(hname_alg(nUuid)):</th><td>
802 style_copy_button(1, "hash-ci", 0, 2, "%.32s<wbr>%s", zUuid, zUuid+32);
 
 
803 if( g.perm.Setup ){
804 @ (Record ID: %d(rid))
805 }
806 @ </td></tr>
807 @ <tr><th>User&nbsp;&amp;&nbsp;Date:</th><td>
808 hyperlink_to_user(zUser,zDate," on ");
809 hyperlink_to_date(zDate, "</td></tr>");
@@ -1919,19 +1916,17 @@
1916 }else{
1917 style_submenu_element("Shun", "%s/shun?shun=%s#addshun", g.zTop, zUuid);
1918 }
1919 }
1920 style_header("Hex Artifact Content");
 
1921 zUuid = db_text("?","SELECT uuid FROM blob WHERE rid=%d", rid);
1922 @ <h2>Artifact
1923 style_copy_button(1, "hash-ar", 0, 2, "%s", zUuid);
 
1924 if( g.perm.Setup ){
1925 @ (%d(rid)):</h2>
1926 }else{
1927 @ :</h2>
1928 }
1929 blob_zero(&downloadName);
1930 if( P("verbose")!=0 ) objdescFlags |= OBJDESC_DETAIL;
1931 object_description(rid, objdescFlags, &downloadName);
1932 style_submenu_element("Download", "%s/raw/%T?name=%s",
@@ -2194,18 +2189,16 @@
2189 zUuid = db_text("?", "SELECT uuid FROM blob WHERE rid=%d", rid);
2190 if( isFile ){
2191 @ <h2>Latest version of file '%h(zName)':</h2>
2192 style_submenu_element("Artifact", "%R/artifact/%S", zUuid);
2193 }else{
 
2194 @ <h2>Artifact
2195 style_copy_button(1, "hash-ar", 0, 2, "%s", zUuid);
 
2196 if( g.perm.Setup ){
2197 @ (%d(rid)):</h2>
2198 }else{
2199 @ :</h2>
2200 }
2201 }
2202 blob_zero(&downloadName);
2203 asText = P("txt")!=0;
2204 if( asText ) objdescFlags &= ~OBJDESC_BASE;
2205
+85 -1
--- src/style.c
+++ src/style.c
@@ -366,10 +366,94 @@
366366
char *zConfigName = mprintf("%s-image", zImageName);
367367
url_var(zVarPrefix, zConfigName, zImageName);
368368
free(zVarPrefix);
369369
free(zConfigName);
370370
}
371
+
372
+/*
373
+** Output TEXT with a click-to-copy button next to it. Loads the copybtn.js
374
+** Javascript module, and generates HTML elements with the following IDs:
375
+**
376
+** TARGETID: The <span> wrapper around TEXT.
377
+** copy-TARGETID: The <span> for the copy button.
378
+**
379
+** If the FLIPPED argument is non-zero, the copy button is displayed after TEXT.
380
+**
381
+** The COPYLENGTH argument defines the length of the substring of TEXT copied to
382
+** clipboard:
383
+**
384
+** <= 0: No limit (default if the argument is omitted).
385
+** >= 3: Truncate TEXT after COPYLENGTH (single-byte) characters.
386
+** 1: Use the "hash-digits" setting as the limit.
387
+** 2: Use the length appropriate for URLs as the limit (defined at
388
+** compile-time by FOSSIL_HASH_DIGITS_URL, defaults to 16).
389
+*/
390
+char *style_copy_button(
391
+ int bOutputCGI, /* Don't return result, but send to cgi_printf(). */
392
+ const char *zTargetId, /* The TARGETID argument. */
393
+ int bFlipped, /* The FLIPPED argument. */
394
+ int cchLength, /* The COPYLENGTH argument. */
395
+ const char *zTextFmt, /* Formatting of the TEXT argument (htmlized). */
396
+ ... /* Formatting parameters of the TEXT argument. */
397
+){
398
+ va_list ap;
399
+ char *zText;
400
+ char *zResult = 0;
401
+ va_start(ap,zTextFmt);
402
+ zText = vmprintf(zTextFmt/*works-like:?*/,ap);
403
+ va_end(ap);
404
+ if( cchLength==1 ) cchLength = hash_digits(0);
405
+ else if( cchLength==2 ) cchLength = hash_digits(1);
406
+ if( !bFlipped ){
407
+ const char *zBtnFmt =
408
+ "<span class=\"nobr\">"
409
+ "<span "
410
+ "class=\"copy-button\" "
411
+ "id=\"copy-%h\" "
412
+ "data-copytarget=\"%h\" "
413
+ "data-copylength=\"%d\">"
414
+ "</span>"
415
+ "<span id=\"%h\">"
416
+ "%s"
417
+ "</span>"
418
+ "</span>";
419
+ if( bOutputCGI ){
420
+ cgi_printf(
421
+ zBtnFmt/*works-like:"%h%h%d%h%s"*/,
422
+ zTargetId,zTargetId,cchLength,zTargetId,zText);
423
+ }else{
424
+ zResult = mprintf(
425
+ zBtnFmt/*works-like:"%h%h%d%h%s"*/,
426
+ zTargetId,zTargetId,cchLength,zTargetId,zText);
427
+ }
428
+ }else{
429
+ const char *zBtnFmt =
430
+ "<span class=\"nobr\">"
431
+ "<span id=\"%h\">"
432
+ "%s"
433
+ "</span>"
434
+ "<span "
435
+ "class=\"copy-button copy-button-flipped\" "
436
+ "id=\"copy-%h\" "
437
+ "data-copytarget=\"%h\" "
438
+ "data-copylength=\"%d\">"
439
+ "</span>"
440
+ "</span>";
441
+ if( bOutputCGI ){
442
+ cgi_printf(
443
+ zBtnFmt/*works-like:"%h%s%h%h%d"*/,
444
+ zTargetId,zText,zTargetId,zTargetId,cchLength);
445
+ }else{
446
+ zResult = mprintf(
447
+ zBtnFmt/*works-like:"%h%s%h%h%d"*/,
448
+ zTargetId,zText,zTargetId,zTargetId,cchLength);
449
+ }
450
+ }
451
+ free(zText);
452
+ style_copybutton_control();
453
+ return zResult;
454
+}
371455
372456
/*
373457
** Return a random nonce that is stored in static space. For a particular
374458
** run, the same nonce is always returned.
375459
*/
@@ -543,11 +627,11 @@
543627
}
544628
545629
/*
546630
** Indicate that the copy button javascript is needed.
547631
*/
548
-void style_copy_button(void){
632
+void style_copybutton_control(void){
549633
needCopyBtnJs = 1;
550634
}
551635
552636
/*
553637
** Generate code to load a single javascript file
554638
--- src/style.c
+++ src/style.c
@@ -366,10 +366,94 @@
366 char *zConfigName = mprintf("%s-image", zImageName);
367 url_var(zVarPrefix, zConfigName, zImageName);
368 free(zVarPrefix);
369 free(zConfigName);
370 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
371
372 /*
373 ** Return a random nonce that is stored in static space. For a particular
374 ** run, the same nonce is always returned.
375 */
@@ -543,11 +627,11 @@
543 }
544
545 /*
546 ** Indicate that the copy button javascript is needed.
547 */
548 void style_copy_button(void){
549 needCopyBtnJs = 1;
550 }
551
552 /*
553 ** Generate code to load a single javascript file
554
--- src/style.c
+++ src/style.c
@@ -366,10 +366,94 @@
366 char *zConfigName = mprintf("%s-image", zImageName);
367 url_var(zVarPrefix, zConfigName, zImageName);
368 free(zVarPrefix);
369 free(zConfigName);
370 }
371
372 /*
373 ** Output TEXT with a click-to-copy button next to it. Loads the copybtn.js
374 ** Javascript module, and generates HTML elements with the following IDs:
375 **
376 ** TARGETID: The <span> wrapper around TEXT.
377 ** copy-TARGETID: The <span> for the copy button.
378 **
379 ** If the FLIPPED argument is non-zero, the copy button is displayed after TEXT.
380 **
381 ** The COPYLENGTH argument defines the length of the substring of TEXT copied to
382 ** clipboard:
383 **
384 ** <= 0: No limit (default if the argument is omitted).
385 ** >= 3: Truncate TEXT after COPYLENGTH (single-byte) characters.
386 ** 1: Use the "hash-digits" setting as the limit.
387 ** 2: Use the length appropriate for URLs as the limit (defined at
388 ** compile-time by FOSSIL_HASH_DIGITS_URL, defaults to 16).
389 */
390 char *style_copy_button(
391 int bOutputCGI, /* Don't return result, but send to cgi_printf(). */
392 const char *zTargetId, /* The TARGETID argument. */
393 int bFlipped, /* The FLIPPED argument. */
394 int cchLength, /* The COPYLENGTH argument. */
395 const char *zTextFmt, /* Formatting of the TEXT argument (htmlized). */
396 ... /* Formatting parameters of the TEXT argument. */
397 ){
398 va_list ap;
399 char *zText;
400 char *zResult = 0;
401 va_start(ap,zTextFmt);
402 zText = vmprintf(zTextFmt/*works-like:?*/,ap);
403 va_end(ap);
404 if( cchLength==1 ) cchLength = hash_digits(0);
405 else if( cchLength==2 ) cchLength = hash_digits(1);
406 if( !bFlipped ){
407 const char *zBtnFmt =
408 "<span class=\"nobr\">"
409 "<span "
410 "class=\"copy-button\" "
411 "id=\"copy-%h\" "
412 "data-copytarget=\"%h\" "
413 "data-copylength=\"%d\">"
414 "</span>"
415 "<span id=\"%h\">"
416 "%s"
417 "</span>"
418 "</span>";
419 if( bOutputCGI ){
420 cgi_printf(
421 zBtnFmt/*works-like:"%h%h%d%h%s"*/,
422 zTargetId,zTargetId,cchLength,zTargetId,zText);
423 }else{
424 zResult = mprintf(
425 zBtnFmt/*works-like:"%h%h%d%h%s"*/,
426 zTargetId,zTargetId,cchLength,zTargetId,zText);
427 }
428 }else{
429 const char *zBtnFmt =
430 "<span class=\"nobr\">"
431 "<span id=\"%h\">"
432 "%s"
433 "</span>"
434 "<span "
435 "class=\"copy-button copy-button-flipped\" "
436 "id=\"copy-%h\" "
437 "data-copytarget=\"%h\" "
438 "data-copylength=\"%d\">"
439 "</span>"
440 "</span>";
441 if( bOutputCGI ){
442 cgi_printf(
443 zBtnFmt/*works-like:"%h%s%h%h%d"*/,
444 zTargetId,zText,zTargetId,zTargetId,cchLength);
445 }else{
446 zResult = mprintf(
447 zBtnFmt/*works-like:"%h%s%h%h%d"*/,
448 zTargetId,zText,zTargetId,zTargetId,cchLength);
449 }
450 }
451 free(zText);
452 style_copybutton_control();
453 return zResult;
454 }
455
456 /*
457 ** Return a random nonce that is stored in static space. For a particular
458 ** run, the same nonce is always returned.
459 */
@@ -543,11 +627,11 @@
627 }
628
629 /*
630 ** Indicate that the copy button javascript is needed.
631 */
632 void style_copybutton_control(void){
633 needCopyBtnJs = 1;
634 }
635
636 /*
637 ** Generate code to load a single javascript file
638
+4 -33
--- src/th_main.c
+++ src/th_main.c
@@ -1025,47 +1025,18 @@
10251025
"copybtn TARGETID FLIPPED TEXT ?COPYLENGTH?");
10261026
}
10271027
if( enableOutput ){
10281028
int flipped = 0;
10291029
int copylength = 0;
1030
- char *zTargetId, *zText, *zResult;
1030
+ char *zResult;
10311031
if( Th_ToInt(interp, argv[2], argl[2], &flipped) ) return TH_ERROR;
10321032
if( argc==5 ){
10331033
if( Th_ToInt(interp, argv[4], argl[4], &copylength) ) return TH_ERROR;
10341034
}
1035
- if( copylength==1 ) copylength = hash_digits(0);
1036
- else if( copylength==2 ) copylength = hash_digits(1);
1037
- zTargetId = htmlize((char*)argv[1], argl[1]);
1038
- zText = htmlize((char*)argv[3], argl[3]);
1039
- if( !flipped ){
1040
- zResult = mprintf(
1041
- "<span "
1042
- "class=\"copy-button\" "
1043
- "id=\"copy-%s\" "
1044
- "data-copytarget=\"%s\" "
1045
- "data-copylength=\"%d\">"
1046
- "</span>"
1047
- "<span id=\"%s\">"
1048
- "%s"
1049
- "</span>",
1050
- zTargetId, zTargetId, copylength, zTargetId, zText);
1051
- }else{
1052
- zResult = mprintf(
1053
- "<span id=\"%s\">"
1054
- "%s"
1055
- "</span>"
1056
- "<span "
1057
- "class=\"copy-button copy-button-flipped\" "
1058
- "id=\"copy-%s\" "
1059
- "data-copytarget=\"%s\" "
1060
- "data-copylength=\"%d\">"
1061
- "</span>",
1062
- zTargetId, zText, zTargetId, zTargetId, copylength);
1063
- }
1064
- free(zTargetId);
1065
- free(zText);
1066
- style_copy_button();
1035
+ zResult = style_copy_button(
1036
+ /*bOutputCGI==*/0, /*TARGETID==*/(char*)argv[1],
1037
+ flipped, copylength, "%h", /*TEXT==*/(char*)argv[3]);
10671038
sendText(zResult, -1, 0);
10681039
free(zResult);
10691040
}
10701041
return TH_OK;
10711042
}
10721043
--- src/th_main.c
+++ src/th_main.c
@@ -1025,47 +1025,18 @@
1025 "copybtn TARGETID FLIPPED TEXT ?COPYLENGTH?");
1026 }
1027 if( enableOutput ){
1028 int flipped = 0;
1029 int copylength = 0;
1030 char *zTargetId, *zText, *zResult;
1031 if( Th_ToInt(interp, argv[2], argl[2], &flipped) ) return TH_ERROR;
1032 if( argc==5 ){
1033 if( Th_ToInt(interp, argv[4], argl[4], &copylength) ) return TH_ERROR;
1034 }
1035 if( copylength==1 ) copylength = hash_digits(0);
1036 else if( copylength==2 ) copylength = hash_digits(1);
1037 zTargetId = htmlize((char*)argv[1], argl[1]);
1038 zText = htmlize((char*)argv[3], argl[3]);
1039 if( !flipped ){
1040 zResult = mprintf(
1041 "<span "
1042 "class=\"copy-button\" "
1043 "id=\"copy-%s\" "
1044 "data-copytarget=\"%s\" "
1045 "data-copylength=\"%d\">"
1046 "</span>"
1047 "<span id=\"%s\">"
1048 "%s"
1049 "</span>",
1050 zTargetId, zTargetId, copylength, zTargetId, zText);
1051 }else{
1052 zResult = mprintf(
1053 "<span id=\"%s\">"
1054 "%s"
1055 "</span>"
1056 "<span "
1057 "class=\"copy-button copy-button-flipped\" "
1058 "id=\"copy-%s\" "
1059 "data-copytarget=\"%s\" "
1060 "data-copylength=\"%d\">"
1061 "</span>",
1062 zTargetId, zText, zTargetId, zTargetId, copylength);
1063 }
1064 free(zTargetId);
1065 free(zText);
1066 style_copy_button();
1067 sendText(zResult, -1, 0);
1068 free(zResult);
1069 }
1070 return TH_OK;
1071 }
1072
--- src/th_main.c
+++ src/th_main.c
@@ -1025,47 +1025,18 @@
1025 "copybtn TARGETID FLIPPED TEXT ?COPYLENGTH?");
1026 }
1027 if( enableOutput ){
1028 int flipped = 0;
1029 int copylength = 0;
1030 char *zResult;
1031 if( Th_ToInt(interp, argv[2], argl[2], &flipped) ) return TH_ERROR;
1032 if( argc==5 ){
1033 if( Th_ToInt(interp, argv[4], argl[4], &copylength) ) return TH_ERROR;
1034 }
1035 zResult = style_copy_button(
1036 /*bOutputCGI==*/0, /*TARGETID==*/(char*)argv[1],
1037 flipped, copylength, "%h", /*TEXT==*/(char*)argv[3]);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1038 sendText(zResult, -1, 0);
1039 free(zResult);
1040 }
1041 return TH_OK;
1042 }
1043
+1 -1
--- src/timeline.c
+++ src/timeline.c
@@ -1003,11 +1003,11 @@
10031003
cgi_printf("\"h\":\"%!S\"}%s",
10041004
pRow->zUuid, pRow->pNext ? ",\n" : "]\n");
10051005
}
10061006
@ }</script>
10071007
style_graph_generator();
1008
- style_copy_button(); /* Dependency: graph.js requires copybtn.js. */
1008
+ style_copybutton_control(); /* Dependency: graph.js requires copybtn.js. */
10091009
graph_free(pGraph);
10101010
}
10111011
}
10121012
10131013
/*
10141014
--- src/timeline.c
+++ src/timeline.c
@@ -1003,11 +1003,11 @@
1003 cgi_printf("\"h\":\"%!S\"}%s",
1004 pRow->zUuid, pRow->pNext ? ",\n" : "]\n");
1005 }
1006 @ }</script>
1007 style_graph_generator();
1008 style_copy_button(); /* Dependency: graph.js requires copybtn.js. */
1009 graph_free(pGraph);
1010 }
1011 }
1012
1013 /*
1014
--- src/timeline.c
+++ src/timeline.c
@@ -1003,11 +1003,11 @@
1003 cgi_printf("\"h\":\"%!S\"}%s",
1004 pRow->zUuid, pRow->pNext ? ",\n" : "]\n");
1005 }
1006 @ }</script>
1007 style_graph_generator();
1008 style_copybutton_control(); /* Dependency: graph.js requires copybtn.js. */
1009 graph_free(pGraph);
1010 }
1011 }
1012
1013 /*
1014
+1 -1
--- src/timeline.c
+++ src/timeline.c
@@ -1003,11 +1003,11 @@
10031003
cgi_printf("\"h\":\"%!S\"}%s",
10041004
pRow->zUuid, pRow->pNext ? ",\n" : "]\n");
10051005
}
10061006
@ }</script>
10071007
style_graph_generator();
1008
- style_copy_button(); /* Dependency: graph.js requires copybtn.js. */
1008
+ style_copybutton_control(); /* Dependency: graph.js requires copybtn.js. */
10091009
graph_free(pGraph);
10101010
}
10111011
}
10121012
10131013
/*
10141014
--- src/timeline.c
+++ src/timeline.c
@@ -1003,11 +1003,11 @@
1003 cgi_printf("\"h\":\"%!S\"}%s",
1004 pRow->zUuid, pRow->pNext ? ",\n" : "]\n");
1005 }
1006 @ }</script>
1007 style_graph_generator();
1008 style_copy_button(); /* Dependency: graph.js requires copybtn.js. */
1009 graph_free(pGraph);
1010 }
1011 }
1012
1013 /*
1014
--- src/timeline.c
+++ src/timeline.c
@@ -1003,11 +1003,11 @@
1003 cgi_printf("\"h\":\"%!S\"}%s",
1004 pRow->zUuid, pRow->pNext ? ",\n" : "]\n");
1005 }
1006 @ }</script>
1007 style_graph_generator();
1008 style_copybutton_control(); /* Dependency: graph.js requires copybtn.js. */
1009 graph_free(pGraph);
1010 }
1011 }
1012
1013 /*
1014

Keyboard Shortcuts

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