summaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
authorMaxim Devaev <[email protected]>2024-01-27 14:33:05 +0200
committerMaxim Devaev <[email protected]>2024-01-27 14:33:05 +0200
commitb8f568fcd8ba3ee365104d32b7c694f96d68c7c2 (patch)
tree6662c1eff037c944ecaab85f264852fb8588510c /web
parent44ee4afcf27b94d7979602d82f6538ba3433b740 (diff)
pikvm/pikvm#1228: another fix for http-only ocr
Diffstat (limited to 'web')
-rw-r--r--web/share/js/wm.js15
1 files changed, 11 insertions, 4 deletions
diff --git a/web/share/js/wm.js b/web/share/js/wm.js
index 633ac463..e6a7c46d 100644
--- a/web/share/js/wm.js
+++ b/web/share/js/wm.js
@@ -145,9 +145,7 @@ function __WindowManager() {
/************************************************************************/
self.copyTextToClipboard = function(text) {
- navigator.clipboard.writeText(text).then(function() {
- wm.info("The text has been copied to the clipboard");
- }, function(err) {
+ let workaround = function(err) {
// https://stackoverflow.com/questions/60317969/document-execcommandcopy-not-working-even-though-the-dom-element-is-created
let callback = function() {
tools.error("copyTextToClipboard(): navigator.clipboard.writeText() is not working:", err);
@@ -179,7 +177,16 @@ function __WindowManager() {
}
};
__modalDialog("Info", "Press OK to copy the text to the clipboard", true, false, callback);
- });
+ };
+ if (navigator.clipboard) {
+ navigator.clipboard.writeText(text).then(function() {
+ wm.info("The text has been copied to the clipboard");
+ }, function(err) {
+ workaround(err);
+ });
+ } else {
+ workaround("navigator.clipboard is not available");
+ }
};
self.info = (...args) => __modalDialog("Info", args.join(" "), true, false);