Wedding Invitation
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

guestbook.blade.php 2.7KB

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