-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.html
More file actions
87 lines (84 loc) · 2.4 KB
/
Copy pathexample.html
File metadata and controls
87 lines (84 loc) · 2.4 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>ClipBoardJS</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
<script src="clipboardjs.js"></script>
<style>
#clipresult {
width: 100%;
min-height: 500px;
border: 1px dotted gray;
}
[controls] {
max-width: 100%;
}
body {
font-family: Arial;
font-size: 16px;
color: #232323;
padding: 2em;
}
pre {
white-space: pre-wrap;
word-wrap: break-word;
padding: 1em;
}
</style>
<script>
let clipb = new ClipBoard({ loadingFunction: AwaitLoading });
clipb.PastEvent(SeePast);
function SeePast(clipVals) {
console.log(clipVals);
$("#clbvals").text(JSON.stringify(clipVals));
if (clipVals.Type.includes("image")) {
let img = $("<img>");
//img.prop("src", clipVals.Base64Data);
img.prop("src", clipVals.BlobSrc);
$("#clipresult").html(img);
} else if (clipVals.Type.includes("text")) {
$("#clipresult").html(clipVals.Text);
} else if (clipVals.Type.includes("audio")) {
let obj = $("<audio>");
obj.attr("controls", "");
let src = $("<source>");
src.prop("src", clipVals.BlobSrc);
src.attr("type", clipVals.Type);
obj.append(src);
$("#clipresult").html(obj);
} else if (clipVals.Type.includes("video")) {
let obj = $("<video>");
obj.attr("controls", "");
let src = $("<source>");
src.prop("src", clipVals.BlobSrc);
src.attr("type", clipVals.Type);
obj.append(src);
$("#clipresult").html(obj);
} else {
new_window = window.open(clipVals.BlobSrc);
}
$("#wait").hide();
$("#clipresult").show();
}
function AwaitLoading() {
$("#wait").show();
$("#clipresult").hide();
alert("loading");
}
</script>
</head>
<body>
<p>Paste using <code>ctrl+v</code></p>
<p>Try pasting: text, images, video, mp3, pdf.</p>
<div>
<pre><code id="clbvals"></code></pre>
</div>
<hr />
<div id="wait" style="display: none;">
<h1>Loading...</h1>
<h4>please wait..</h4>
</div>
<div id="clipresult"></div>
</body>
</html>