Skip to content

Commit

Permalink
paste and copy pgns
Browse files Browse the repository at this point in the history
  • Loading branch information
Disservin committed Apr 22, 2023
1 parent 789f678 commit 83d4d4d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
9 changes: 7 additions & 2 deletions src/components/AppBtn.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div>
<v-btn class="btn" color="primary" v-bind="$attrs">
<font-awesome-icon icon="fa-solid fa-clipboard" />
<span>Copy PGN</span>
<span>{{ text }}</span>
</v-btn>
</div>
</template>
Expand All @@ -12,7 +12,12 @@ import { defineComponent } from "vue";
export default defineComponent({
name: "AppBtn",
props: {},
props: {
text: {
type: String,
required: true,
},
},
inheritAttrs: false,
});
</script>
Expand Down
8 changes: 4 additions & 4 deletions src/components/AppCopyBtn.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<AppBtn @click="copyToClipBoard(text)" />
<AppBtn @click="copyToClipBoard(copy)" :text="'copy pgn'" />
</template>

<script lang="ts">
Expand All @@ -13,14 +13,14 @@ export default defineComponent({
AppBtn,
},
props: {
text: {
copy: {
type: String,
required: true,
},
},
methods: {
copyToClipBoard(text: string) {
navigator.clipboard.writeText(text);
copyToClipBoard(copy: string) {
navigator.clipboard.writeText(copy);
},
},
});
Expand Down
14 changes: 13 additions & 1 deletion src/views/Analysis.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { defineComponent } from "vue";
import Sidebar from "@/components/AppSideBar.vue";
import AppBtn from "@/components/AppBtn.vue";
import AppCopyBtn from "@/components/AppCopyBtn.vue";
import EngineStats from "@/components/Analysis/EngineStats.vue";
import EngineButtons from "@/components/Analysis/EngineButtons.vue";
Expand Down Expand Up @@ -30,6 +31,7 @@ export default defineComponent({
Pgn: Pgn,
ChessGroundBoard: ChessGroundBoard,
AppCopyBtn: AppCopyBtn,
AppBtn: AppBtn,
},
data() {
return {
Expand Down Expand Up @@ -178,6 +180,11 @@ export default defineComponent({
this.sendEngineCommand("quit");
},
methods: {
parsePgnFromClipboard() {
navigator.clipboard.readText().then((text) => {
this.parsePgn(text);
});
},
evalFunction(x: number) {
return (5 - Math.pow(2, -(Math.abs(x) - 2.319281))) * (x < 0 ? -1 : 1);
},
Expand Down Expand Up @@ -500,7 +507,12 @@ export default defineComponent({
:status="isRunning"
:key="isRunning.toString()"
/>
<AppCopyBtn :text="currentPgn" v-if="activeTab == 'prompt'" />
<AppBtn
:text="'paste pgn'"
v-if="activeTab == 'prompt'"
@click="parsePgnFromClipboard"
/>
<AppCopyBtn :copy="currentPgn" v-if="activeTab == 'prompt'" />
</div>
<div class="nav-secondary-content">
<Pgn
Expand Down

0 comments on commit 83d4d4d

Please sign in to comment.