mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 01:00:29 +08:00
pikvm/pikvm#1228: another fix for http-only ocr
This commit is contained in:
parent
44ee4afcf2
commit
b8f568fcd8
@ -145,9 +145,7 @@ function __WindowManager() {
|
|||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|
||||||
self.copyTextToClipboard = function(text) {
|
self.copyTextToClipboard = function(text) {
|
||||||
navigator.clipboard.writeText(text).then(function() {
|
let workaround = function(err) {
|
||||||
wm.info("The text has been copied to the clipboard");
|
|
||||||
}, function(err) {
|
|
||||||
// https://stackoverflow.com/questions/60317969/document-execcommandcopy-not-working-even-though-the-dom-element-is-created
|
// https://stackoverflow.com/questions/60317969/document-execcommandcopy-not-working-even-though-the-dom-element-is-created
|
||||||
let callback = function() {
|
let callback = function() {
|
||||||
tools.error("copyTextToClipboard(): navigator.clipboard.writeText() is not working:", err);
|
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);
|
__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);
|
self.info = (...args) => __modalDialog("Info", args.join(" "), true, false);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user