|
@@ -1,8 +1,14 @@
|
1
|
1
|
<div class="flex flex-col gap-5 w-4/5">
|
2
|
|
- <div class="text-center pb-3 ">
|
|
2
|
+ <div class="flex flex-col justify-center text-center gap-3 fade-element">
|
3
|
3
|
<p class="font-medium text-gray-600 pb-3">Ruangan Ucapan</p>
|
4
|
|
- <p class="font-medium text-sm text-gray-600 italic">Ucapan kepada kedua mempelai</p>
|
5
|
|
- <p class="font-medium text-sm text-gray-600 italic">-Nama-</p>
|
|
4
|
+ <div id="guestbook-container">
|
|
5
|
+ @include('partials.guestbook', ['entry' => $guestbooks->first()])
|
|
6
|
+ </div>
|
|
7
|
+ <div class="join flex justify-center" id="pagination-buttons">
|
|
8
|
+ @for ($i = 1; $i <= $totalPages; $i++)
|
|
9
|
+ <button class="join-item btn btn-xs {{ $i == 1 ? 'btn-active' : '' }} hidden" data-page="{{ $i }}">{{ $i }}</button>
|
|
10
|
+ @endfor
|
|
11
|
+ </div>
|
6
|
12
|
</div>
|
7
|
13
|
<div class="text-center pb-2 ">
|
8
|
14
|
<a onclick="guestbook.showModal()" class="rounded-full border-solid border-2 border-navbarcolor py-1 px-3 font-medium text-gray-600">
|
|
@@ -20,3 +26,49 @@
|
20
|
26
|
<hr class="border-t-1 border-gray-300 my-5 w-4/5 self-center ">
|
21
|
27
|
@include('modals.guestbook-modal')
|
22
|
28
|
</div>
|
|
29
|
+
|
|
30
|
+@push('script')
|
|
31
|
+<script>
|
|
32
|
+ $(document).ready(function() {
|
|
33
|
+ var autoSwitchInterval = 4500; // 3 seconds
|
|
34
|
+ var currentPage = 1;
|
|
35
|
+ var totalPages = {{ $totalPages }}; // Total number of pages
|
|
36
|
+
|
|
37
|
+ function fetchGuestbook(page) {
|
|
38
|
+ $.ajax({
|
|
39
|
+ url: '{{ route('guestbook.ajax') }}',
|
|
40
|
+ type: 'GET',
|
|
41
|
+ data: { page: page },
|
|
42
|
+ success: function(response) {
|
|
43
|
+ $('#guestbook-container').html(response.guestbook);
|
|
44
|
+
|
|
45
|
+ // Update pagination buttons
|
|
46
|
+ $('#pagination-buttons .join-item').removeClass('btn-active');
|
|
47
|
+ $('#pagination-buttons .join-item[data-page="' + page + '"]').addClass('btn-active');
|
|
48
|
+
|
|
49
|
+ // Update currentPage
|
|
50
|
+ currentPage = page;
|
|
51
|
+ },
|
|
52
|
+ error: function(xhr) {
|
|
53
|
+ console.log(xhr.responseText);
|
|
54
|
+ }
|
|
55
|
+ });
|
|
56
|
+ }
|
|
57
|
+
|
|
58
|
+ // Auto-switching every 3 seconds
|
|
59
|
+ setInterval(function() {
|
|
60
|
+ var nextPage = currentPage + 1;
|
|
61
|
+ if (nextPage > totalPages) {
|
|
62
|
+ nextPage = 1;
|
|
63
|
+ }
|
|
64
|
+ fetchGuestbook(nextPage);
|
|
65
|
+ }, autoSwitchInterval);
|
|
66
|
+
|
|
67
|
+ // Handle pagination button click
|
|
68
|
+ $('#pagination-buttons').on('click', '.join-item', function() {
|
|
69
|
+ var page = $(this).data('page');
|
|
70
|
+ fetchGuestbook(page);
|
|
71
|
+ });
|
|
72
|
+ });
|
|
73
|
+</script>
|
|
74
|
+@endpush
|