-
Notifications
You must be signed in to change notification settings - Fork 0
/
signature.html
119 lines (104 loc) · 3.45 KB
/
signature.html
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Signatur</title>
<style>
.signature {
display: flex;
flex-direction: row;
align-items: center;
}
.signature > *:nth-child(1) {
flex: 2;
}
.signature > *:nth-child(2) {
flex: 1;
}
.signature + .signature {
margin-top: 3rem;
}
</style>
</head>
<body>
<div class="signature">
<div id="optinor">
<div>
<p>Med venlig hilsen</p>
<p><strong>Jonas Westergaard</strong></p>
<img src="https://optinor.dk/assets/gmail/optinor.png" width="120" alt="Optinor logo">
</div>
</div>
<button onclick="copySignature('optinor')">Kopiér</button>
</div>
<div class="signature">
<div id="glass-security">
<div>
<p>Med venlig hilsen</p>
<p><strong>Jonas Westergaard</strong></p>
<img src="https://glass-security.dk/assets/gmail/ngs.png" width="120" alt="Nordic Glass Security logo">
</div>
</div>
<button onclick="copySignature('glass-security')">Kopiér</button>
</div>
<div class="signature">
<div id="solfilm-dk">
<div>
<p>Med venlig hilsen</p>
<p><strong>Jonas Westergaard</strong></p>
<img src="https://solfilm.dk/assets/gmail/solfilm.dk.png" width="120" alt="Solfilm.dk logo">
</div>
</div>
<button onclick="copySignature('solfilm-dk')">Kopiér</button>
</div>
<script>
function copySignature(id) {
console.log(id);
const elm = document.getElementById(id);
console.log(elm);
const type = "text/html";
const blob = new Blob([elm.innerHTML], {type});
const data = [new ClipboardItem({[type]: blob})];
navigator.clipboard.write(data).then(
function(){
console.log('copied!');
},
function(){
console.log('copy failed');
}
);
};
const copyToClipboard = function(id)
{
console.log(id);
const elm = document.getElementById(id);
console.log(elm);
if (!elm) {
return;
}
navigator.permissions.query({ name: "clipboard-write" }).then(
(res) => {
console.log(res);
if (!(res.state == "granted" || res.state == "prompt")) {
return;
}
navigator.clipboard.writeText(elm.outerHTML).then(
(res) => {
console.log('Content copied to clipboard', res);
/* Resolved - text copied to clipboard successfully */
},
(err) => {
console.error('Failed to copy', err);
/* Rejected - text failed to copy to the clipboard */
}
);
},
(err) => {
console.error(err);
}
);
}
</script>
</body>
</html>