From b8482e0e3c1a01ea72b0c7b8decefd901d5ccb4e Mon Sep 17 00:00:00 2001 From: shibafu Date: Tue, 11 Jun 2019 22:16:40 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=A1=E3=82=BF=E3=83=87=E3=83=BC=E3=82=BF?= =?UTF-8?q?=E3=83=97=E3=83=AC=E3=83=93=E3=83=A5=E3=83=BC=E3=81=A8=E3=82=BF?= =?UTF-8?q?=E3=82=B0=E5=80=99=E8=A3=9C=E9=81=B8=E6=8A=9E=E3=81=AE=E3=82=B3?= =?UTF-8?q?=E3=83=B3=E3=83=9D=E3=83=BC=E3=83=8D=E3=83=B3=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/assets/js/checkin.ts | 38 ++++++++++- .../assets/js/components/MetadataPreview.vue | 66 +++++++++++++++++++ resources/assets/js/components/TagInput.vue | 5 ++ .../assets/sass/components/_link-card.scss | 23 ++++++- resources/views/ejaculation/checkin.blade.php | 7 +- resources/views/ejaculation/edit.blade.php | 7 +- 6 files changed, 140 insertions(+), 6 deletions(-) create mode 100644 resources/assets/js/components/MetadataPreview.vue diff --git a/resources/assets/js/checkin.ts b/resources/assets/js/checkin.ts index 7e54285..fb79cc7 100644 --- a/resources/assets/js/checkin.ts +++ b/resources/assets/js/checkin.ts @@ -1,9 +1,45 @@ import Vue from 'vue'; import TagInput from "./components/TagInput.vue"; +import MetadataPreview from './components/MetadataPreview.vue'; + +export const bus = new Vue({name: "EventBus"}); new Vue({ el: '#app', + data: { + metadata: null + }, components: { - TagInput + TagInput, + MetadataPreview + }, + mounted() { + // TODO: 編集モード時はすぐにメタデータを取得する + }, + methods: { + // オカズリンクの変更時 + onChangeLink(event: Event) { + if (event.target instanceof HTMLInputElement) { + const url = event.target.value; + + if (url.trim() === '' || !/^https?:\/\//.test(url)) { + this.metadata = null; + return; + } + + $.ajax({ + url: '/api/checkin/card', + method: 'get', + type: 'json', + data: { + url + } + }).then(data => { + this.metadata = data; + }).catch(e => { + this.metadata = null; + }); + } + } } }); diff --git a/resources/assets/js/components/MetadataPreview.vue b/resources/assets/js/components/MetadataPreview.vue new file mode 100644 index 0000000..aa3a542 --- /dev/null +++ b/resources/assets/js/components/MetadataPreview.vue @@ -0,0 +1,66 @@ + + + + + diff --git a/resources/assets/js/components/TagInput.vue b/resources/assets/js/components/TagInput.vue index a2c1ff3..5da6bfb 100644 --- a/resources/assets/js/components/TagInput.vue +++ b/resources/assets/js/components/TagInput.vue @@ -17,6 +17,7 @@ -@endpush \ No newline at end of file +@endpush diff --git a/resources/views/ejaculation/edit.blade.php b/resources/views/ejaculation/edit.blade.php index 73b16d4..25f2215 100644 --- a/resources/views/ejaculation/edit.blade.php +++ b/resources/views/ejaculation/edit.blade.php @@ -53,7 +53,9 @@
- + オカズのURLを貼り付けて登録することができます。 @@ -62,6 +64,7 @@ @endif
+
@@ -97,4 +100,4 @@ @push('script') -@endpush \ No newline at end of file +@endpush