Skip to content

Commit 00c9be4

Browse files
authored
Merge pull request #353 from CorbinWunderlich/master
Format all files with format.sh
2 parents cb0fb02 + fb17b5e commit 00c9be4

27 files changed

+1199
-1088
lines changed

html5/clipboard.html

Lines changed: 45 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<!DOCTYPE html>
22
<html lang="en">
3+
34
<head>
45
<!--
56
Copyright (c) 2024 Antoine Martin <antoine@xpra.org>
@@ -18,36 +19,29 @@
1819

1920
<div>
2021
<label for="input">Input</label>
21-
<input
22-
title="Input"
23-
type="text"
24-
class="form-control"
25-
id="input"
26-
placeholder="Input"
27-
maxlength="256"
28-
/>
22+
<input title="Input" type="text" class="form-control" id="input" placeholder="Input" maxlength="256" />
2923
</div>
3024

3125
<hr />
3226

3327
<div>
3428
<input type="checkbox" id="autofocus" />
3529
<br />
36-
<label for="pasteboard">Pasteboard:</label><br/>
30+
<label for="pasteboard">Pasteboard:</label><br />
3731
<textarea id="pasteboard" readonly></textarea>
3832
</div>
3933

4034
<hr />
4135

4236
<div>
43-
<label for="contents">Contents:</label><br/>
37+
<label for="contents">Contents:</label><br />
4438
<pre id="contents"></pre>
4539
</div>
4640

4741
<hr />
4842

4943
<div>
50-
<label for="info">Events:</label><br/>
44+
<label for="info">Events:</label><br />
5145
<pre id="info"></pre>
5246
</div>
5347

@@ -74,7 +68,7 @@
7468

7569
function update_info(newtext) {
7670
console.log(newtext);
77-
while (lines.length>10) {
71+
while (lines.length > 10) {
7872
lines.shift();
7973
}
8074
lines.push(newtext);
@@ -90,7 +84,7 @@
9084
}
9185
}
9286

93-
autofocus.onchange = function () {
87+
autofocus.onchange = function() {
9488
pasteboard.autofocus = autofocus.checked;
9589
if (autofocus.checked) {
9690
pasteboard.focus();
@@ -103,62 +97,59 @@
10397
update_info("`navigator.clipboard` found");
10498
if (navigator.clipboard.clipboardData) {
10599
update_info("`navigator.clipboard.clipboardData` found");
106-
}
107-
else {
100+
} else {
108101
update_info("No `navigator.clipboard.clipboardData`");
109102
}
110-
}
111-
else {
103+
} else {
112104
update_info("Error: `navigator.clipboard` is missing!");
113105
}
114106

115107
function read_clipboard_data(format) {
116-
update_info("requesting "+format);
108+
update_info("requesting " + format);
117109
navigator.clipboard.read().then((data) => {
118-
update_info("got "+format+" clipboard data: "+data);
119-
for (const item of data) {
120-
for (const type of item.types) {
121-
const item_data = item.getType(type).then((item_data) => {
122-
update_info("got "+type+"="+item_data);
123-
const fileReader = new FileReader();
124-
fileReader.addEventListener("load", (event) => {
125-
update_info("loaded "+type+"="+event+" using "+event.target);
126-
update_info("result="+event.target.result);
127-
},
128-
(error) => {
129-
update_info("failed to load "+type+" clipboard data: "+error);
130-
});
131-
fileReader.readAsText(item_data);
132-
},
133-
(error) => {
134-
update_info("failed to get "+type+" clipboard data: "+error);
135-
});
110+
update_info("got " + format + " clipboard data: " + data);
111+
for (const item of data) {
112+
for (const type of item.types) {
113+
const item_data = item.getType(type).then((item_data) => {
114+
update_info("got " + type + "=" + item_data);
115+
const fileReader = new FileReader();
116+
fileReader.addEventListener("load", (event) => {
117+
update_info("loaded " + type + "=" + event + " using " + event.target);
118+
update_info("result=" + event.target.result);
119+
},
120+
(error) => {
121+
update_info("failed to load " + type + " clipboard data: " + error);
122+
});
123+
fileReader.readAsText(item_data);
124+
},
125+
(error) => {
126+
update_info("failed to get " + type + " clipboard data: " + error);
127+
});
128+
}
136129
}
137-
}
138-
contents.innerText = data;
139-
},
140-
(error) => {
141-
update_info("failed to read "+format+": "+error);
142-
});
130+
contents.innerText = data;
131+
},
132+
(error) => {
133+
update_info("failed to read " + format + ": " + error);
134+
});
143135
}
144136
if (navigator.clipboard.read) {
145137
read_clipboard_data("text/html");
146138
read_clipboard_data("text/plain");
147-
}
148-
else {
139+
} else {
149140
update_info("missing `navigator.clipboard.read`");
150141
}
151142

152143
function read_clipboard_text() {
153144
update_info("requesting contents via readText()");
154145
navigator.clipboard.readText().then((text) => {
155-
update_info("readText() clipboard data: '"+text+"'");
156-
contents.innerHTML = text;
157-
// const clipboard_buffer = unescape(encodeURIComponent(text));
158-
},
159-
(error) => {
160-
update_info("failed to readText(): "+error);
161-
});
146+
update_info("readText() clipboard data: '" + text + "'");
147+
contents.innerHTML = text;
148+
// const clipboard_buffer = unescape(encodeURIComponent(text));
149+
},
150+
(error) => {
151+
update_info("failed to readText(): " + error);
152+
});
162153
}
163154
read_clipboard_text();
164155

@@ -185,16 +176,17 @@
185176
exec_copy.onclick = function(e) {
186177
input.select();
187178
const copy = document.execCommand("copy");
188-
update_info("copy="+copy);
179+
update_info("copy=" + copy);
189180
}
190181

191182
const exec_paste = document.getElementById("exec-paste");
192183
exec_paste.onclick = function(e) {
193184
input.select();
194185
const paste = document.execCommand("paste");
195-
update_info("paste="+paste);
186+
update_info("paste=" + paste);
196187
}
197188

198189
</script>
199190
</body>
191+
200192
</html>

0 commit comments

Comments
 (0)