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