14
14
15
15
< script >
16
16
function toggleCitation ( ) {
17
- var citation = document . getElementById ( "citation " ) ;
17
+ var citation = document . getElementById ( "citationContainer " ) ;
18
18
var button = event . target ;
19
- if ( citation . style . display === "none" ) {
19
+ if ( citation . style . display === "none" || citationContainer . style . display === "" ) {
20
20
citation . style . display = "block" ;
21
- button . innerText = "Bibtex" ;
21
+ button . innerText = "Hide Bibtex" ;
22
22
} else {
23
23
citation . style . display = "none" ;
24
- button . innerText = "Bibtex" ;
24
+ button . innerText = "Show Bibtex" ;
25
25
}
26
26
}
27
+
28
+ function copyCitation ( ) {
29
+ // Retrieve the raw citation text, preserving formatting
30
+ var citationText = document . getElementById ( "citation" ) . innerText ;
31
+
32
+ // Use Clipboard API to copy the text
33
+ navigator . clipboard . writeText ( citationText ) . then ( function ( ) {
34
+ // Change button text to confirm the copy
35
+ var copyButton = document . getElementById ( "copyButton" ) ;
36
+ copyButton . innerText = "Copied!" ;
37
+
38
+ // Revert the button text after 2 seconds
39
+ setTimeout ( function ( ) {
40
+ copyButton . innerText = "Copy Bibtex" ;
41
+ } , 2000 ) ;
42
+ } , function ( err ) {
43
+ console . error ( 'Failed to copy text: ' , err ) ;
44
+ } ) ;
45
+ }
46
+
27
47
</ script >
28
48
29
49
< div class ="{{ include.type | default: "list " }}__item">
@@ -55,7 +75,7 @@ <h2 class="archive__item-title" itemprop="headline">
55
75
{% if post.collection == 'teaching' %}
56
76
< p > {{ post.type }}, < i > {{ post.venue }}</ i > , {{ post.date | default: "1900-01-01" | date: "%Y" }} </ p >
57
77
{% elsif post.collection == 'publications' %}
58
- < p > Published in < i > {{ post.venue }}</ i > , {{ post.date | default: "1900-01-01" | date: "%Y" }} </ p >
78
+ < p > < i > {{ post.author_list }} </ i > < br > < i > {{ post.venue }}</ i > , {{ post.date | default: "1900-01-01" | date: "%Y" }} </ p >
59
79
{% elsif post.date %}
60
80
< p class ="page__date "> < strong > < i class ="fa fa-fw fa-calendar " aria-hidden ="true "> </ i > {{ site.data.ui-text[site.locale].date_label | default: "Published:" }}</ strong > < time datetime ="{{ post.date | default: "1900-01-01 " | date_to_xmlschema }}"> {{ post.date | default: "1900-01-01" | date: "%B %d, %Y" }}</ time > </ p >
61
81
{% endif %}
@@ -66,29 +86,28 @@ <h2 class="archive__item-title" itemprop="headline">
66
86
< p class ="archive__item-excerpt " itemprop ="description "> < p > {{ post.excerpt | markdownify | remove: '< p > ' | remove: '</ p > ' }}< strong > < a href ="{{ base_path }}{{ post.url }} " rel ="permalink "> Read more</ a > </ strong > </ p > </ p >
67
87
{% endif %}
68
88
69
- <!-- {% if post.citation and post.paperurl and post.slidesurl %}
70
- <p>Recommended citation: {{ post.citation }}<br /><a href="{{ post.paperurl }}">Download Paper</a> | <a href="{{ post.slidesurl }}">Download Slides</a></p>
71
- {% elsif post.citation and post.paperurl %}
72
- <!-- <p>Recommended citation: {{ post.citation }} <br /> <a href="{{ post.paperurl }}">Download Paper</a></p> -->
73
- <!-- <p>
74
- <button onclick="toggleCitation()">Show Citation</button>
89
+
90
+ < div style ="display: flex; gap: 10px; "> <!-- Flexbox for inline buttons with some spacing -->
91
+ {% if post.citation %}
92
+ < p >
93
+ < button onclick ="toggleCitation() " style ="padding: 10px 20px; background-color: #4CAF50; color: white; border: none; border-radius: 5px; font-size: 16px; cursor: pointer; transition: background-color 0.3s; "> Show Bibtex</ button >
75
94
</ p >
76
- <p id="citation" style="display:none;">Recommended citation: {{ post.citation }}</p>
77
- {% elsif post.citation and post.slidesurl %}
78
- <p>Recommended citation: {{ post.citation }}<br /><a href="{{ post.slidesurl }}">Download Slides</a></p>
79
- {% elsif post.citation %}
80
- <p>Recommended citation: {{ post.citation }}</p>
81
- {% elsif post.paperurl %}
82
- <p><a href=" {{ post.paperurl }} ">Download Paper</a></p>
83
- {% elsif post.slidesurl %}
84
- <p>Download <a href="{{ post.slidesurl }}">Download Slides</a></p></p>
85
- {% endif %} -->
86
- {% if post.citation %}
95
+ {% endif %}
96
+ {% if post.pdf %}
87
97
< p >
88
- < button onclick ="toggleCitation() " style ="padding: 10px 20px; background-color: #4CAF50; color: white; border: none; border-radius: 5px; font-size: 16px; cursor: pointer; transition: background-color 0.3s; "> Bibtex</ button >
98
+ < a href ="{{ post.pdf }} " download >
99
+ < button style ="padding: 10px 20px; background-color: #4CAF50; color: white; border: none; border-radius: 5px; font-size: 16px; cursor: pointer; transition: background-color 0.3s; ">
100
+ Download PDF
101
+ </ button >
102
+ </ a >
89
103
</ p >
90
- < pre id ="citation " style ="display:none; background-color: #f4f4f9; border-left: 4px solid #4CAF50; padding: 20px; white-space: pre-wrap; word-wrap: break-word; font-family: 'Courier New', Courier, monospace; color: #333; line-height: 1.5; font-size: 14px; border-radius: 5px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); "> {{ post.citation }}</ pre >
91
104
{% endif %}
105
+ </ div >
92
106
107
+ < div id ="citationContainer " style ="display:none; background-color: #f4f4f9; border-left: 4px solid #4CAF50; padding: 20px; border-radius: 5px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); position: relative; ">
108
+ < pre id ="citation " style ="white-space: pre-wrap; word-wrap: break-word; overflow-wrap: break-word; font-family: 'Courier New', Courier, monospace; font-size: 12px; "> {{ post.citation }}</ pre >
109
+ < button onclick ="copyCitation() " id ="copyButton " style ="padding: 5px 15px; background-color: #2196F3; color: white; border: none; border-radius: 5px; font-size: 14px; cursor: pointer; transition: background-color 0.3s; position: absolute; top: 10px; right: 10px; "> Copy Bibtex</ button >
110
+ </ div >
111
+
93
112
</ article >
94
113
</ div >
0 commit comments