Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert "AI proposed more modern copy code. AI wasn't sure if it worke…
…d, and it doesn't.

This reverts commit f58e85f.
  • Loading branch information
Luke Davis, Open Source Systems Luke Davis, Open Source Systems
Luke Davis, Open Source Systems authored and Luke Davis, Open Source Systems committed Aug 19, 2024
commit c071400f97cb22580e9dcc69985da7ac4ee7f905
23 changes: 13 additions & 10 deletions source/message.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,21 @@
}
Comment thread
XLTechie marked this conversation as resolved.

function onCopyButtonPress() {
var range = document.createRange();
var selection = window.getSelection();
range.selectNodeContents(messageDiv);
selection.removeAllRanges();
selection.addRange(range);
try {
var success = document.execCommand('copy');
copyStatusDiv.innerHTML = '<p id="copyStatusText" style="font-weight:bold; text-align:center;"></p>';
copyStatusText.innerText = success ? args.item('copySuccessfulAlertText') : args.item('copyFailedAlertText');
} catch (err) {
// Copy code came from http://www.codestore.net/store.nsf/unid/DOMM-4QHQE8/
var rng = document.body.createTextRange();
rng.moveToElementText(messageDiv);
rng.scrollIntoView();
rng.select();
var success = rng.execCommand("Copy");
rng.collapse(false);
rng.select();
copyStatusDiv.innerHTML = '<p id="copyStatusText" style="font-weight:bold; text-align:center;"></p>';
if (success) { // Notify the user about the copy result
copyStatusText.innerText = args.item('copySuccessfulAlertText');
} else {
copyStatusText.innerText = args.item('copyFailedAlertText');
}
// Time out the user alert message
setTimeout(function() {
copyStatusDiv.innerHTML = '';
}, copyStatusTimeout);
Expand Down