-
Notifications
You must be signed in to change notification settings - Fork 0
/
entry.php
78 lines (72 loc) · 1.83 KB
/
entry.php
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
70
71
72
73
74
75
76
77
78
<style>
.tooltip {
position: relative;
display: inline-block;
}
.tooltip .tooltiptext {
visibility: hidden;
width: 135px;
background-color: #60605D;
color: #fff;
text-align: center;
border-radius: 5px;
padding: 5px;
position: absolute;
z-index: 1;
bottom: 100%;
left: 50%;
margin-left: -67px;
margin-bottom: 10px;
opacity: 0;
transition: opacity 0.5s;
}
.tooltip .tooltiptext::after {
content: "";
position: absolute;
top: 100%;
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: #60605D transparent transparent transparent;
}
.tooltip:hover .tooltiptext {
visibility: visible;
opacity: 1;
}
</style>
<?php $anchor = getYear($entry).'-'.date('m',strtotime($month)).'-'.getDay($entry) ; ?>
<details id="<?php echo $anchor; ?>">
<summary class="citation">
<?php require 'citation.php'; ?>
<div class="tooltip">
<button id="<?php echo $anchor; ?>" onclick="replyId(this.id)">
<span class="tooltiptext" id="<?php echo $anchor; ?>tooltip">Copy to clipboard</span>
⧉
</button>
</div>
</summary>
<?php require 'entry_body.php'; ?>
</details>
<script>
// https://stackoverflow.com/q/4825295
// store previous tooltip id to change it back after copying another link
var prev_tooltip;
function replyId(clicked_id) {
// removes anchor (if any) and adds anchor
let url = window.location.href.split('#')[0] + "#" + clicked_id;
if (navigator.clipboard) {
navigator.clipboard.writeText(url);
} else {
url.select();
document.execCommand("Copy");
}
// change tooltip text
if (prev_tooltip) {
prev_tooltip.innerHTML = "Copy to clipboard";
}
let tooltip = document.getElementById(clicked_id + "tooltip");
tooltip.innerHTML = "Copied";
prev_tooltip = tooltip;
}
</script>