From da19806a3d09b88f1ab252635d89b7137ec87910 Mon Sep 17 00:00:00 2001 From: shibafu Date: Wed, 26 Jun 2019 23:20:53 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=9A=E3=83=BC=E3=82=B8=E3=83=AD=E3=83=BC?= =?UTF-8?q?=E3=83=89=E6=99=82=E7=82=B9=E3=81=A7=E3=82=AA=E3=82=AB=E3=82=BA?= =?UTF-8?q?=E3=83=AA=E3=83=B3=E3=82=AF=E3=81=ABURL=E3=81=8C=E5=85=A5?= =?UTF-8?q?=E5=8A=9B=E3=81=95=E3=82=8C=E3=81=A6=E3=81=84=E3=82=8B=E5=A0=B4?= =?UTF-8?q?=E5=90=88=E3=80=81=E3=81=99=E3=81=90=E3=81=AB=E3=83=A1=E3=82=BF?= =?UTF-8?q?=E3=83=87=E3=83=BC=E3=82=BF=E3=82=92=E5=8F=96=E5=BE=97=E3=81=99?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resources/assets/js/checkin.ts | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/resources/assets/js/checkin.ts b/resources/assets/js/checkin.ts index fb79cc7..abd4beb 100644 --- a/resources/assets/js/checkin.ts +++ b/resources/assets/js/checkin.ts @@ -14,7 +14,11 @@ new Vue({ MetadataPreview }, mounted() { - // TODO: 編集モード時はすぐにメタデータを取得する + // オカズリンクにURLがセットされている場合は、すぐにメタデータを取得する + const linkInput = this.$el.querySelector("#link"); + if (linkInput && /^https?:\/\//.test(linkInput.value)) { + this.fetchMetadata(linkInput.value); + } }, methods: { // オカズリンクの変更時 @@ -27,19 +31,23 @@ new Vue({ return; } - $.ajax({ - url: '/api/checkin/card', - method: 'get', - type: 'json', - data: { - url - } - }).then(data => { - this.metadata = data; - }).catch(e => { - this.metadata = null; - }); + this.fetchMetadata(url); } + }, + // メタデータの取得 + fetchMetadata(url: string) { + $.ajax({ + url: '/api/checkin/card', + method: 'get', + type: 'json', + data: { + url + } + }).then(data => { + this.metadata = data; + }).catch(e => { + this.metadata = null; + }); } } });