forked from OpenUserJS/OpenUserJS.org
/
clipboard.html
47 lines (39 loc) · 1.07 KB
/
clipboard.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
<script type="text/javascript" src="/redist/npm/clipboard/dist/clipboard.js"></script>
<script type="text/javascript">
(function () {
var clipboard = null;
var rMin = /\.min\.js$/;
var allowedIds = [
'#copyright-raw',
'#downloadurl-raw',
'#groupid-raw',
'#groupid-urn',
'#license-raw',
'#require-min',
'#require-raw',
'#scriptid-raw',
'#scriptid-urn',
'#updateurl-raw',
'#userid-raw',
'#userid-urn'
];
function unsupported() {
allowedIds.forEach(function (aElement, aIndex, aArray) {
$(aElement).prop('disabled', true);
});
}
if (ClipboardJS.isSupported()) {
clipboard = new ClipboardJS(allowedIds.join(', '));
clipboard.on('success', function(aE) {
if (rMin.test(aE.text)) {
// TODO: Flash tooltip saying copied and then restore it
} else {
// TODO: Flash tooltip saying copied and then restore it
}
});
clipboard.on('error', unsupported);
} else {
unsupported();
}
})();
</script>