カード情報のリクエスト処理を共通化
This commit is contained in:
@@ -80,42 +80,8 @@
|
||||
|
||||
@push('script')
|
||||
<script>
|
||||
$('.link-card').each(function () {
|
||||
var $this = $(this);
|
||||
$.ajax({
|
||||
url: '{{ url('/api/checkin/card') }}',
|
||||
method: 'get',
|
||||
type: 'json',
|
||||
data: {
|
||||
url: $this.find('a').attr('href')
|
||||
}
|
||||
}).then(function (data) {
|
||||
var $title = $this.find('.card-title');
|
||||
var $desc = $this.find('.card-text');
|
||||
var $image = $this.find('img');
|
||||
|
||||
if (data.title === '') {
|
||||
$title.hide();
|
||||
} else {
|
||||
$title.text(data.title);
|
||||
}
|
||||
|
||||
if (data.description === '') {
|
||||
$desc.hide();
|
||||
} else {
|
||||
$desc.text(data.description);
|
||||
}
|
||||
|
||||
if (data.image === '') {
|
||||
$image.hide();
|
||||
} else {
|
||||
$image.attr('src', data.image);
|
||||
}
|
||||
|
||||
if (data.title !== '' || data.description !== '' || data.image !== '') {
|
||||
$this.removeClass('d-none');
|
||||
}
|
||||
});
|
||||
$('.link-card').linkCard({
|
||||
endpoint: '{{ url('/api/checkin/card') }}'
|
||||
});
|
||||
</script>
|
||||
@endpush
|
Reference in New Issue
Block a user