Skip to content

Commit

Permalink
Message.html changes to support optional close and copy buttons.
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Davis authored and Luke Davis committed Apr 11, 2024
1 parent 25a4561 commit 6355374
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion source/message.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,51 @@
if(e.keyCode == 27){ // code for escape
window.close();
}
};
}

function onCopyButtonPress() {
// Copy code came from http://www.codestore.net/store.nsf/unid/DOMM-4QHQE8/
var rng = document.body.createTextRange();
rng.moveToElementText(messageID);
rng.scrollIntoView();
rng.select();
rng.execCommand("Copy");
rng.collapse(false);
rng.select();
}

function onCloseButtonPress() {
//window.open('', '_self', ''); // Only enable if window.close() stops working in a future version, may fix.
window.close();
}

function windowOnLoad() {
var args = window.dialogArguments;
if (args) {
document.title = args.item('title');
messageID.innerHTML = args.item('message');
// If caller wants a close button
if (args.item('closeButtonText') != null) {
closeButton.innerHTML = args.item('closeButtonText'); // Assign the (translated) label
closeButton.style.display = 'inline'; // Display the button
buttonDiv.style.display = 'block'; // Display the div
}
// If caller wants a copy to clip button
if (args.item('copyButtonText') != null) {
copyButton.innerHTML = args.item('copyButtonText'); // Assign the (translated) label
copyButtonSpan.style.display = 'inline'; // Display the button
buttonDiv.style.display = 'block'; // Display the div
}
}
}
//-->
</SCRIPT>
</HEAD>
<BODY tabindex='0' id='main_body' style="margin:1em" LANGUAGE=javascript onload="return windowOnLoad()" onkeypress="return escapeKeyPress()" >
<div id=messageID></div>
<div id="buttonDiv" style="display: none;"><hr>
<span id="copyButtonSpan" style="display: none;"><button id="copyButton" onclick="onCopyButtonPress();"></button>&nbsp;</span>
<span><button id="closeButton" style="display: none;" onclick="onCloseButtonPress();"></button></span>
</div>
</body>
</html>

0 comments on commit 6355374

Please sign in to comment.