Fossil SCM

Output the copy button patterns for HTML pages and TH1 scripts from a centralized function, to make it easier to apply global modifications.

florian 2019-06-07 11:47 trunk
Commit eb960935fc8c9572e8e61ad65bf72d8100f276f7b9548ac727c266a982d4c495
+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
+ copybtn(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
+ copybtn(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
+ copybtn(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
+ copybtn(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 copybtn(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 copybtn(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 copybtn(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 copybtn(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
+81 -1
--- src/style.c
+++ src/style.c
@@ -366,10 +366,90 @@
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 *copybtn(
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 "
409
+ "class=\"copy-button\" "
410
+ "id=\"copy-%h\" "
411
+ "data-copytarget=\"%h\" "
412
+ "data-copylength=\"%d\">"
413
+ "</span>"
414
+ "<span id=\"%h\">"
415
+ "%s"
416
+ "</span>";
417
+ if( bOutputCGI ){
418
+ cgi_printf(
419
+ zBtnFmt/*works-like:"%h%h%d%h%s"*/,
420
+ zTargetId,zTargetId,cchLength,zTargetId,zText);
421
+ }else{
422
+ zResult = mprintf(
423
+ zBtnFmt/*works-like:"%h%h%d%h%s"*/,
424
+ zTargetId,zTargetId,cchLength,zTargetId,zText);
425
+ }
426
+ }else{
427
+ const char *zBtnFmt =
428
+ "<span id=\"%h\">"
429
+ "%s"
430
+ "</span>"
431
+ "<span "
432
+ "class=\"copy-button copy-button-flipped\" "
433
+ "id=\"copy-%h\" "
434
+ "data-copytarget=\"%h\" "
435
+ "data-copylength=\"%d\">"
436
+ "</span>";
437
+ if( bOutputCGI ){
438
+ cgi_printf(
439
+ zBtnFmt/*works-like:"%h%s%h%h%d"*/,
440
+ zTargetId,zText,zTargetId,zTargetId,cchLength);
441
+ }else{
442
+ zResult = mprintf(
443
+ zBtnFmt/*works-like:"%h%s%h%h%d"*/,
444
+ zTargetId,zText,zTargetId,zTargetId,cchLength);
445
+ }
446
+ }
447
+ free(zText);
448
+ style_copybtn();
449
+ return zResult;
450
+}
371451
372452
/*
373453
** Return a random nonce that is stored in static space. For a particular
374454
** run, the same nonce is always returned.
375455
*/
@@ -543,11 +623,11 @@
543623
}
544624
545625
/*
546626
** Indicate that the copy button javascript is needed.
547627
*/
548
-void style_copy_button(void){
628
+void style_copybtn(void){
549629
needCopyBtnJs = 1;
550630
}
551631
552632
/*
553633
** Generate code to load a single javascript file
554634
--- src/style.c
+++ src/style.c
@@ -366,10 +366,90 @@
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 +623,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,90 @@
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 *copybtn(
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 "
409 "class=\"copy-button\" "
410 "id=\"copy-%h\" "
411 "data-copytarget=\"%h\" "
412 "data-copylength=\"%d\">"
413 "</span>"
414 "<span id=\"%h\">"
415 "%s"
416 "</span>";
417 if( bOutputCGI ){
418 cgi_printf(
419 zBtnFmt/*works-like:"%h%h%d%h%s"*/,
420 zTargetId,zTargetId,cchLength,zTargetId,zText);
421 }else{
422 zResult = mprintf(
423 zBtnFmt/*works-like:"%h%h%d%h%s"*/,
424 zTargetId,zTargetId,cchLength,zTargetId,zText);
425 }
426 }else{
427 const char *zBtnFmt =
428 "<span id=\"%h\">"
429 "%s"
430 "</span>"
431 "<span "
432 "class=\"copy-button copy-button-flipped\" "
433 "id=\"copy-%h\" "
434 "data-copytarget=\"%h\" "
435 "data-copylength=\"%d\">"
436 "</span>";
437 if( bOutputCGI ){
438 cgi_printf(
439 zBtnFmt/*works-like:"%h%s%h%h%d"*/,
440 zTargetId,zText,zTargetId,zTargetId,cchLength);
441 }else{
442 zResult = mprintf(
443 zBtnFmt/*works-like:"%h%s%h%h%d"*/,
444 zTargetId,zText,zTargetId,zTargetId,cchLength);
445 }
446 }
447 free(zText);
448 style_copybtn();
449 return zResult;
450 }
451
452 /*
453 ** Return a random nonce that is stored in static space. For a particular
454 ** run, the same nonce is always returned.
455 */
@@ -543,11 +623,11 @@
623 }
624
625 /*
626 ** Indicate that the copy button javascript is needed.
627 */
628 void style_copybtn(void){
629 needCopyBtnJs = 1;
630 }
631
632 /*
633 ** Generate code to load a single javascript file
634
+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 = copybtn(
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 = copybtn(
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
@@ -988,11 +988,11 @@
988988
cgi_printf("\"h\":\"%!S\"}%s",
989989
pRow->zUuid, pRow->pNext ? ",\n" : "]\n");
990990
}
991991
@ }</script>
992992
style_graph_generator();
993
- style_copy_button(); /* Dependency: graph.js requires copybtn.js. */
993
+ style_copybtn(); /* Dependency: graph.js requires copybtn.js. */
994994
graph_free(pGraph);
995995
}
996996
}
997997
998998
/*
999999
--- src/timeline.c
+++ src/timeline.c
@@ -988,11 +988,11 @@
988 cgi_printf("\"h\":\"%!S\"}%s",
989 pRow->zUuid, pRow->pNext ? ",\n" : "]\n");
990 }
991 @ }</script>
992 style_graph_generator();
993 style_copy_button(); /* Dependency: graph.js requires copybtn.js. */
994 graph_free(pGraph);
995 }
996 }
997
998 /*
999
--- src/timeline.c
+++ src/timeline.c
@@ -988,11 +988,11 @@
988 cgi_printf("\"h\":\"%!S\"}%s",
989 pRow->zUuid, pRow->pNext ? ",\n" : "]\n");
990 }
991 @ }</script>
992 style_graph_generator();
993 style_copybtn(); /* Dependency: graph.js requires copybtn.js. */
994 graph_free(pGraph);
995 }
996 }
997
998 /*
999

Keyboard Shortcuts

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