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