Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Move the "Copy Button" functionality to a separate Javascript module, to be loaded and used independently from the timeline graph module. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | tooltip-copyhash |
| Files: | files | file ages | folders |
| SHA3-256: |
f6fcbf292b9560d47c2eebd845bac5a6 |
| User & Date: | florian 2019-05-29 14:02:00.000 |
References
|
2019-05-30
| ||
| 11:04 | Revert the manual edits to the makefiles from [f6fcbf292b], and only keep the changes made by the src/makemake.tcl script. ... (check-in: 2002a50893 user: florian tags: tooltip-copyhash) | |
Context
|
2019-05-29
| ||
| 14:14 | Apply the "hash-digits" setting to limit the length of hash prefixes displayed on tooltips. ... (check-in: 90e4f5ae9f user: florian tags: tooltip-copyhash) | |
| 14:02 | Move the "Copy Button" functionality to a separate Javascript module, to be loaded and used independently from the timeline graph module. ... (check-in: f6fcbf292b user: florian tags: tooltip-copyhash) | |
| 12:55 | More consistent naming of variables in the newly added Javascript part. ... (check-in: c887a1bb00 user: florian tags: tooltip-copyhash) | |
Changes
Added src/copybtn.js.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
/* Create (if necessary) and initialize a "Copy Text" button <idButton> linked
** to the target element <idTarget>.
**
** HTML snippet for statically created buttons:
** <span class="copy-button" id="idButton" data-copytarget="idTarget"></span>
**
** Note: <idTarget> can be set statically or dynamically, this function does not
** overwrite "data-copytarget" attributes with empty values.
*/
function makeCopyButton(idButton,idTarget){
var elButton = document.getElementById(idButton);
if( !elButton ){
elButton = document.createElement("span");
elButton.className = "copy-button";
elButton.id = idButton;
}
elButton.style.transition = "";
elButton.style.opacity = 1;
if( idTarget ) elButton.setAttribute("data-copytarget",idTarget);
elButton.onclick = clickCopyButton;
return elButton;
}
/* The onclick handler for the "Copy Text" button. */
var lockCopyText = false;
function clickCopyButton(e){
e.preventDefault(); /* Mandatory for <a> and <button>. */
e.stopPropagation();
if( lockCopyText ) return;
lockCopyText = true;
this.style.transition = "opacity 400ms ease-in-out";
this.style.opacity = 0;
var idTarget = this.getAttribute("data-copytarget");
var elTarget = document.getElementById(idTarget);
if( elTarget ){
var text = elTarget.innerText;
copyTextToClipboard(text);
}
setTimeout(function(id){
var elButton = document.getElementById(id);
if( elButton ){
elButton.style.transition = "";
elButton.style.opacity = 1;
}
lockCopyText = false;
}.bind(null,this.id),400);
}
/* Create a temporary <textarea> element and copy the contents to clipboard. */
function copyTextToClipboard(text){
var textArea = document.createElement("textarea");
textArea.style.position = 'fixed';
textArea.style.top = 0;
textArea.style.left = 0;
textArea.style.width = '2em';
textArea.style.height = '2em';
textArea.style.padding = 0;
textArea.style.border = 'none';
textArea.style.outline = 'none';
textArea.style.boxShadow = 'none';
textArea.style.background = 'transparent';
textArea.value = text;
document.body.appendChild(textArea);
textArea.focus();
textArea.select();
try{
document.execCommand('copy');
}catch(err){
}
document.body.removeChild(textArea);
}
|
Changes to src/graph.js.
| ︙ | ︙ | |||
744 745 746 747 748 749 750 |
var dataObj = document.getElementById("timeline-data-"+i);
if(!dataObj) break;
var txJson = dataObj.textContent || dataObj.innerText;
var tx = JSON.parse(txJson);
TimelineGraph(tx);
}
}())
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 744 745 746 747 748 749 750 |
var dataObj = document.getElementById("timeline-data-"+i);
if(!dataObj) break;
var txJson = dataObj.textContent || dataObj.innerText;
var tx = JSON.parse(txJson);
TimelineGraph(tx);
}
}())
|
Changes to src/main.mk.
| ︙ | ︙ | |||
208 209 210 211 212 213 214 215 216 217 218 219 220 221 | $(SRCDIR)/../skins/rounded1/footer.txt \ $(SRCDIR)/../skins/rounded1/header.txt \ $(SRCDIR)/../skins/xekri/css.txt \ $(SRCDIR)/../skins/xekri/details.txt \ $(SRCDIR)/../skins/xekri/footer.txt \ $(SRCDIR)/../skins/xekri/header.txt \ $(SRCDIR)/ci_edit.js \ $(SRCDIR)/diff.tcl \ $(SRCDIR)/forum.js \ $(SRCDIR)/graph.js \ $(SRCDIR)/href.js \ $(SRCDIR)/login.js \ $(SRCDIR)/markdown.md \ $(SRCDIR)/menu.js \ | > | 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | $(SRCDIR)/../skins/rounded1/footer.txt \ $(SRCDIR)/../skins/rounded1/header.txt \ $(SRCDIR)/../skins/xekri/css.txt \ $(SRCDIR)/../skins/xekri/details.txt \ $(SRCDIR)/../skins/xekri/footer.txt \ $(SRCDIR)/../skins/xekri/header.txt \ $(SRCDIR)/ci_edit.js \ $(SRCDIR)/copybtn.js \ $(SRCDIR)/diff.tcl \ $(SRCDIR)/forum.js \ $(SRCDIR)/graph.js \ $(SRCDIR)/href.js \ $(SRCDIR)/login.js \ $(SRCDIR)/markdown.md \ $(SRCDIR)/menu.js \ |
| ︙ | ︙ |
Changes to src/style.c.
| ︙ | ︙ | |||
80 81 82 83 84 85 86 | ** Ad-unit styles. */ static unsigned adUnitFlags = 0; /* ** Flags for various javascript files needed prior to </body> */ | | | | > | 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | ** Ad-unit styles. */ static unsigned adUnitFlags = 0; /* ** Flags for various javascript files needed prior to </body> */ static int needHrefJs = 0; /* href.js */ static int needSortJs = 0; /* sorttable.js */ static int needGraphJs = 0; /* graph.js */ static int needCopyBtnJs = 0; /* copybtn.js */ /* ** Extra JS added to the end of the file. */ static Blob blobOnLoad = BLOB_INITIALIZER; /* |
| ︙ | ︙ | |||
531 532 533 534 535 536 537 |
** Indicate that the table-sorting javascript is needed.
*/
void style_table_sorter(void){
needSortJs = 1;
}
/*
| | > > > > > > > | 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 |
** Indicate that the table-sorting javascript is needed.
*/
void style_table_sorter(void){
needSortJs = 1;
}
/*
** Indicate that the timeline graph javascript is needed.
*/
void style_graph_generator(void){
needGraphJs = 1;
}
/*
** Indicate that the copy button javascript is needed.
*/
void style_copy_button(void){
needCopyBtnJs = 1;
}
/*
** Generate code to load a single javascript file
*/
void style_load_one_js_file(const char *zFile){
@ <script src='%R/builtin/%s(zFile)?id=%S(MANIFEST_UUID)'></script>
}
|
| ︙ | ︙ | |||
589 590 591 592 593 594 595 596 597 598 599 600 601 602 |
}
if( needSortJs ){
cgi_append_content(builtin_text("sorttable.js"),-1);
}
if( needGraphJs ){
cgi_append_content(builtin_text("graph.js"),-1);
}
for(i=0; i<nJsToLoad; i++){
cgi_append_content(builtin_text(azJsToLoad[i]),-1);
}
if( blob_size(&blobOnLoad)>0 ){
@ window.onload = function(){
cgi_append_content(blob_buffer(&blobOnLoad), blob_size(&blobOnLoad));
cgi_append_content("\n}\n", -1);
| > > > | 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 |
}
if( needSortJs ){
cgi_append_content(builtin_text("sorttable.js"),-1);
}
if( needGraphJs ){
cgi_append_content(builtin_text("graph.js"),-1);
}
if( needCopyBtnJs ){
cgi_append_content(builtin_text("copybtn.js"),-1);
}
for(i=0; i<nJsToLoad; i++){
cgi_append_content(builtin_text(azJsToLoad[i]),-1);
}
if( blob_size(&blobOnLoad)>0 ){
@ window.onload = function(){
cgi_append_content(blob_buffer(&blobOnLoad), blob_size(&blobOnLoad));
cgi_append_content("\n}\n", -1);
|
| ︙ | ︙ |
Changes to src/timeline.c.
| ︙ | ︙ | |||
989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 |
if( k ) cgi_printf("],");
cgi_printf("\"br\":\"%j\",", pRow->zBranch ? pRow->zBranch : "");
cgi_printf("\"h\":\"%!S\"}%s",
pRow->zUuid, pRow->pNext ? ",\n" : "]\n");
}
@ }</script>
style_graph_generator();
graph_free(pGraph);
}
}
/*
** Create a temporary table suitable for storing timeline data.
*/
| > | 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 |
if( k ) cgi_printf("],");
cgi_printf("\"br\":\"%j\",", pRow->zBranch ? pRow->zBranch : "");
cgi_printf("\"h\":\"%!S\"}%s",
pRow->zUuid, pRow->pNext ? ",\n" : "]\n");
}
@ }</script>
style_graph_generator();
style_copy_button(); /* Dependency: graph.js requires copybtn.js. */
graph_free(pGraph);
}
}
/*
** Create a temporary table suitable for storing timeline data.
*/
|
| ︙ | ︙ |
Changes to win/Makefile.mingw.
| ︙ | ︙ | |||
630 631 632 633 634 635 636 637 638 639 640 641 642 643 | $(SRCDIR)/../skins/rounded1/footer.txt \ $(SRCDIR)/../skins/rounded1/header.txt \ $(SRCDIR)/../skins/xekri/css.txt \ $(SRCDIR)/../skins/xekri/details.txt \ $(SRCDIR)/../skins/xekri/footer.txt \ $(SRCDIR)/../skins/xekri/header.txt \ $(SRCDIR)/ci_edit.js \ $(SRCDIR)/diff.tcl \ $(SRCDIR)/forum.js \ $(SRCDIR)/graph.js \ $(SRCDIR)/href.js \ $(SRCDIR)/login.js \ $(SRCDIR)/markdown.md \ $(SRCDIR)/menu.js \ | > | 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 | $(SRCDIR)/../skins/rounded1/footer.txt \ $(SRCDIR)/../skins/rounded1/header.txt \ $(SRCDIR)/../skins/xekri/css.txt \ $(SRCDIR)/../skins/xekri/details.txt \ $(SRCDIR)/../skins/xekri/footer.txt \ $(SRCDIR)/../skins/xekri/header.txt \ $(SRCDIR)/ci_edit.js \ $(SRCDIR)/copybtn.js \ $(SRCDIR)/diff.tcl \ $(SRCDIR)/forum.js \ $(SRCDIR)/graph.js \ $(SRCDIR)/href.js \ $(SRCDIR)/login.js \ $(SRCDIR)/markdown.md \ $(SRCDIR)/menu.js \ |
| ︙ | ︙ |
Changes to win/Makefile.mingw.mistachkin.
| ︙ | ︙ | |||
630 631 632 633 634 635 636 637 638 639 640 641 642 643 | $(SRCDIR)/../skins/rounded1/footer.txt \ $(SRCDIR)/../skins/rounded1/header.txt \ $(SRCDIR)/../skins/xekri/css.txt \ $(SRCDIR)/../skins/xekri/details.txt \ $(SRCDIR)/../skins/xekri/footer.txt \ $(SRCDIR)/../skins/xekri/header.txt \ $(SRCDIR)/ci_edit.js \ $(SRCDIR)/diff.tcl \ $(SRCDIR)/forum.js \ $(SRCDIR)/graph.js \ $(SRCDIR)/href.js \ $(SRCDIR)/login.js \ $(SRCDIR)/markdown.md \ $(SRCDIR)/menu.js \ | > | 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 | $(SRCDIR)/../skins/rounded1/footer.txt \ $(SRCDIR)/../skins/rounded1/header.txt \ $(SRCDIR)/../skins/xekri/css.txt \ $(SRCDIR)/../skins/xekri/details.txt \ $(SRCDIR)/../skins/xekri/footer.txt \ $(SRCDIR)/../skins/xekri/header.txt \ $(SRCDIR)/ci_edit.js \ $(SRCDIR)/copybtn.js \ $(SRCDIR)/diff.tcl \ $(SRCDIR)/forum.js \ $(SRCDIR)/graph.js \ $(SRCDIR)/href.js \ $(SRCDIR)/login.js \ $(SRCDIR)/markdown.md \ $(SRCDIR)/menu.js \ |
| ︙ | ︙ |
Changes to win/Makefile.msc.
| ︙ | ︙ | |||
533 534 535 536 537 538 539 540 541 542 543 544 545 546 |
$(SRCDIR)\..\skins\rounded1\footer.txt \
$(SRCDIR)\..\skins\rounded1\header.txt \
$(SRCDIR)\..\skins\xekri\css.txt \
$(SRCDIR)\..\skins\xekri\details.txt \
$(SRCDIR)\..\skins\xekri\footer.txt \
$(SRCDIR)\..\skins\xekri\header.txt \
$(SRCDIR)\ci_edit.js \
$(SRCDIR)\diff.tcl \
$(SRCDIR)\forum.js \
$(SRCDIR)\graph.js \
$(SRCDIR)\href.js \
$(SRCDIR)\login.js \
$(SRCDIR)\markdown.md \
$(SRCDIR)\menu.js \
| > | 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 |
$(SRCDIR)\..\skins\rounded1\footer.txt \
$(SRCDIR)\..\skins\rounded1\header.txt \
$(SRCDIR)\..\skins\xekri\css.txt \
$(SRCDIR)\..\skins\xekri\details.txt \
$(SRCDIR)\..\skins\xekri\footer.txt \
$(SRCDIR)\..\skins\xekri\header.txt \
$(SRCDIR)\ci_edit.js \
$(SRCDIR)\copybtn.js \
$(SRCDIR)\diff.tcl \
$(SRCDIR)\forum.js \
$(SRCDIR)\graph.js \
$(SRCDIR)\href.js \
$(SRCDIR)\login.js \
$(SRCDIR)\markdown.md \
$(SRCDIR)\menu.js \
|
| ︙ | ︙ |