Wedding Invitation
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

guestbook.blade.php 2.5KB

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