mirror of
https://github.com/aquatix/alfagok.git
synced 2025-12-06 21:05:10 +01:00
Use AlpineJS clipboard plugin, eliminating empty lines in copy
This commit is contained in:
@@ -33,8 +33,8 @@ a.title {
|
|||||||
padding: 2rem 0 0 0;
|
padding: 2rem 0 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.guessesheading {
|
.guessesheading, .copied {
|
||||||
color: #CCC;;
|
color: #CCC;
|
||||||
}
|
}
|
||||||
|
|
||||||
.guessesheading, .guessesbefore, .guessesafter {
|
.guessesheading, .guessesbefore, .guessesafter {
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ document.addEventListener('alpine:init', () => {
|
|||||||
resultGuesses: Alpine.$persist('').as('resultGuesses'),
|
resultGuesses: Alpine.$persist('').as('resultGuesses'),
|
||||||
resultTimeTaken: Alpine.$persist('').as('resultTimeTaken'),
|
resultTimeTaken: Alpine.$persist('').as('resultTimeTaken'),
|
||||||
|
|
||||||
|
resultsCopied: false,
|
||||||
|
|
||||||
async init() {
|
async init() {
|
||||||
/** Initialise the application after loading */
|
/** Initialise the application after loading */
|
||||||
await this.getGameID();
|
await this.getGameID();
|
||||||
@@ -190,23 +192,6 @@ document.addEventListener('alpine:init', () => {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/* Clipboard stuff **/
|
|
||||||
|
|
||||||
let clip = new ClipboardJS('.copy');
|
|
||||||
|
|
||||||
clip.on("success", function(e) {
|
|
||||||
document.getElementById('copyresults').innerHTML = '<p style="font-size:var(--small);opacity:50%">Gekopieerd! Deel je resultaat.</p>';
|
|
||||||
e.clearSelection();
|
|
||||||
});
|
|
||||||
|
|
||||||
clip.on("error", function() {
|
|
||||||
document.getElementById('copyresults').innerHTML = '<p style="font-size:var(--small);opacity:50%">Fout. Graag handmatig kopiëren...</p>';
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
/* Get current gameID etc **/
|
|
||||||
|
|
||||||
// document.addEventListener('alpine:initialized', () => {
|
// document.addEventListener('alpine:initialized', () => {
|
||||||
/* On AlpineJS completely loaded, do all this */
|
/* On AlpineJS completely loaded, do all this */
|
||||||
// Alpine.store('alfagok').getGameID();
|
// Alpine.store('alfagok').getGameID();
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
<link rel="icon" type="image/png" sizes="16x16" href="/static/images/favicon-16x16.png">
|
<link rel="icon" type="image/png" sizes="16x16" href="/static/images/favicon-16x16.png">
|
||||||
<link rel="manifest" href="/static/images/site.webmanifest">
|
<link rel="manifest" href="/static/images/site.webmanifest">
|
||||||
<script src="https://cdn.jsdelivr.net/npm/@alpinejs/persist@3.x.x/dist/cdn.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/@alpinejs/persist@3.x.x/dist/cdn.min.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/@ryangjchandler/alpine-clipboard@2.x.x/dist/alpine-clipboard.js" defer></script>
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script>
|
<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -49,8 +50,8 @@
|
|||||||
<p>🔗 <span class="link">alfagok.diginaut.net</span></p>
|
<p>🔗 <span class="link">alfagok.diginaut.net</span></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="copyresults"></div>
|
<div class="copied" x-show="$store.alfagok.resultsCopied">Gekopieerd! Deel je resultaat.</div>
|
||||||
<button class="copy" data-clipboard-target="#results">
|
<button class="copy" @click="$clipboard($store.alfagok.resultGameID + '\n' + $store.alfagok.resultGuesses + '\n' + $store.alfagok.resultTimeTaken + '\n' + '🔗 alfagok.diginaut.net'); $store.alfagok.resultsCopied = true">
|
||||||
Tik om te kopiëren en te delen ❤️
|
Tik om te kopiëren en te delen ❤️
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -64,7 +65,6 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/clipboard@2.0.11/dist/clipboard.min.js"></script>
|
|
||||||
<script src="/static/game.js?v={{ version }}"></script>
|
<script src="/static/game.js?v={{ version }}"></script>
|
||||||
{#
|
{#
|
||||||
<button x-data @click="$store.darkMode.toggle()">Toggle Dark Mode</button>
|
<button x-data @click="$store.darkMode.toggle()">Toggle Dark Mode</button>
|
||||||
|
|||||||
Reference in New Issue
Block a user