} );
}
+function react_to_clipboard_text(text) {
+ clip_input.value = text;
+ clip_input.focus();
+ clip_input.setSelectionRange(0, clip_input.value.length);
+
+ check_likely_inputs(text);
+}
+
function get_clipboard_contents() {
- let clip_pot = document.getElementById('clip-pot');
- let clip_input = document.getElementById("clipboard");
- clip_pot.focus();
- if (document.execCommand("Paste")) {
- let q = clip_pot.textContent.trim();
- clip_input.value = q;
- clip_input.focus();
- clip_input.setSelectionRange(0, clip_input.value.length);
-
- check_likely_inputs(q);
+ if (navigator.clipboard && navigator.clipboard.readText) {
+ navigator.clipboard.readText().then(function(q){
+ react_to_clipboard_text(q);
+ });
+ }
+ else {
+ let clip_pot = document.getElementById('clip-pot');
+ let clip_input = document.getElementById("clipboard");
+ clip_pot.focus();
+ if (document.execCommand("Paste")) {
+ let q = clip_pot.textContent.trim();
+ react_to_clipboard_text(q);
+ }
}
}