Skip to content

Commit

Permalink
0.8.12
Browse files Browse the repository at this point in the history
* added button `copy to clipboard` to `/serial`
  • Loading branch information
lumapu committed Nov 20, 2023
1 parent ba8d1f3 commit 5318697
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
3 changes: 3 additions & 0 deletions src/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Development Changes

## 0.8.12 - 2023-11-20
* added button `copy to clipboard` to `/serial`

## 0.8.11 - 2023-11-20
* improved communication, thx @rejoe2
* improved heuristics, thx @rejoe2, @Oberfritze
Expand Down
2 changes: 1 addition & 1 deletion src/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//-------------------------------------
#define VERSION_MAJOR 0
#define VERSION_MINOR 8
#define VERSION_PATCH 11
#define VERSION_PATCH 12

//-------------------------------------
typedef struct {
Expand Down
27 changes: 20 additions & 7 deletions src/web/html/serial.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<div class="col-6 col-sm-4 a-r">
<input type="button" value="clear" class="btn" id="clear"/>
<input type="button" value="autoscroll" class="btn" id="scroll"/>
<!--<input type="button" value="copy" class="btn" id="copy"/>-->
<input type="button" value="copy" class="btn" id="copy"/>
</div>
</div>
</div>
Expand Down Expand Up @@ -64,12 +64,25 @@
mAutoScroll = !mAutoScroll;
this.value = (mAutoScroll) ? "autoscroll" : "manual scroll";
});
/*document.getElementById("copy").addEventListener("click", function() {
con.select();
con.setSelectionRange(0, 9999999);
navigator.clipboard.writeText(con.value);
alert("Copied to clipboard");
});*/
document.getElementById("copy").addEventListener("click", function() {
if (window.clipboardData && window.clipboardData.setData) {
return window.clipboardData.setData("Text", text);
} else if (document.queryCommandSupported && document.queryCommandSupported("copy")) {
var ta = document.createElement("textarea");
ta.textContent = con.value;
ta.style.position = "fixed"; // Prevent scrolling to bottom of page in Microsoft Edge.
document.body.appendChild(ta);
ta.select();
try {
return document.execCommand("copy"); // Security exception may be thrown by some browsers.
} catch (ex) {
alert("Copy to clipboard failed" + ex);
} finally {
document.body.removeChild(ta);
alert("Copied to clipboard");
}
}
});

if (!!window.EventSource) {
var source = new EventSource('/events');
Expand Down

0 comments on commit 5318697

Please sign in to comment.