Created
February 18, 2022 04:20
-
-
Save wilt00/b0da26a0b5ef79d8ec80add43d895a10 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/posts/morse-codle/morse-codle.js b/posts/morse-codle/morse-codle.js | |
index b426847..78bc82e 100644 | |
--- a/posts/morse-codle/morse-codle.js | |
+++ b/posts/morse-codle/morse-codle.js | |
@@ -150,8 +150,7 @@ function getDayOffset() { | |
const GAME_NUMBER = getDayOffset(); | |
const STEP = 4; | |
-function share(event) { | |
- event.preventDefault(); | |
+function buildShareString() { | |
// Build results array | |
var result = ''; | |
for (let i = 0; i < gameState.currentGameGuesses.length; i++) { | |
@@ -170,13 +169,16 @@ function share(event) { | |
result += '\n'; | |
} | |
// Copy results to clipboard | |
- const stringToCopy =` | |
+ return ` | |
-- --- .-. ... . -.-. --- -.. .-.. . | |
Game #${GAME_NUMBER} | |
${result}`; | |
+} | |
- clipboard.writeText(stringToCopy).then(function () { | |
+function share(event) { | |
+ event.preventDefault(); | |
+ clipboard.writeText(buildShareString()).then(function () { | |
alert('Text copied successfully.'); | |
}, function (err) { | |
alert('There was a problem copying your result.'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment