index.html 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta name="viewport" content="width=device-width, initial-scale=1">
  5. <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" integrity="sha512-bLT0Qm9VnAYZDflyKcBaQ2gg0hSYNQrJ8RilYldYQ1FxQYoCLtUjuuRuZo+fjqhx/qtq/1itJ0C2ejDxltZVFg==" crossorigin="anonymous"></script>
  6. <style>
  7. body {
  8. background-color: black;
  9. height: 100%;
  10. overflow: hidden;
  11. }
  12. .slide {
  13. display: none;
  14. /**/
  15. }
  16. .slide.active {
  17. display: block !important;
  18. /**/
  19. }
  20. img {
  21. vertical-align: middle;
  22. height: auto;
  23. max-height: 100vh;
  24. max-width: 100vw;
  25. overflow: hidden;
  26. object-fit: cover;
  27. }
  28. .slideshow {
  29. max-width: 100vw;
  30. position: relative;
  31. margin: auto;
  32. }
  33. .dot {
  34. cursor: pointer;
  35. height: 10px;
  36. width: 10px;
  37. margin: 0 2px;
  38. background-color: #b7c6d8;
  39. border-radius: 50%;
  40. display: inline-block;
  41. }
  42. .dot.active,
  43. .dot:hover {
  44. background-color: #0067e6;
  45. }
  46. </style>
  47. </head>
  48. <body>
  49. <div class="slideshow">
  50. </div>
  51. <br>
  52. <div style="text-align: center; position: absolute; bottom: 0px; right: 0px;width:100px;height:100px" onclick="toSetting()"></div>
  53. <script>
  54. var endpoint = "/system/ajgi/interface?script=/Slideshow/backend/listFile.js";
  55. var image = [];
  56. var interval = 0;
  57. $.getJSON(endpoint, function(data) {
  58. image = data["results"];
  59. interval = data["interval"];
  60. }).done(function() {
  61. $("body").append('<div class="selector" style="text-align: center; position: absolute; bottom: 20px; left: 15px; "></div>');
  62. for (var i = 0; i < image.length; i++) {
  63. $("body > .slideshow").append('<div class="slide"><img src="' + image[i] + '" style="width:100% "></div>');
  64. $("body > .selector").append('<span class="dot" onclick="showSlides(' + (i + 1) + ') "></span>');
  65. }
  66. //realigin to center
  67. upd();
  68. showSlides(1);
  69. $('.slideshow .slide').on('load', function() {
  70. upd();
  71. });
  72. $(window).on('resize', function() {
  73. upd();
  74. });
  75. //auto refresh
  76. setInterval(function() {
  77. var selector = $("body > .selector > .dot.active").next();
  78. if (selector.length > 0) {
  79. selector.click();
  80. } else {
  81. $("body > .selector > .dot").first().click();
  82. }
  83. }, interval);
  84. });
  85. function showSlides(n) {
  86. $(".slideshow .slide").fadeOut(500, "linear");
  87. $(".slideshow .slide").attr("class", "slide")
  88. $(".slideshow .slide:nth-child(" + (n) + ")").attr("class", "slide active")
  89. $(".slideshow .slide:nth-child(" + (n) + ")").fadeIn("linear");
  90. //dot
  91. $("body .dot.active").attr("class", "dot")
  92. $("body .dot:nth-child(" + (n) + ")").attr("class", "dot active")
  93. upd();
  94. }
  95. function upd() {
  96. //ascept ratio calculator, use to resize the image
  97. var selector = $(".slideshow > .slide.active > img");
  98. var img_width = selector.prop("naturalWidth");
  99. var img_height = selector.prop("naturalHeight");
  100. console.log(img_width, img_height);
  101. var win_width = window.innerWidth;
  102. var win_height = window.innerHeight;
  103. var final_w = 0;
  104. var final_h = 0;
  105. final_h = win_height;
  106. final_w = img_width * (win_height / img_height);
  107. //reszie until everything fit the screen
  108. while (final_w >= win_width) {
  109. final_w *= 0.999;
  110. final_h *= 0.999;
  111. }
  112. selector.height(final_h);
  113. selector.width(final_w);
  114. if (img_width < win_width && img_height < win_height) {
  115. selector.height(img_height);
  116. selector.width(img_width);
  117. }
  118. $('.slide.active').css('margin-left', (window.innerWidth - selector.width()) / 2);
  119. $('.slide.active').css('margin-top', (window.innerHeight - selector.height()) / 2);
  120. }
  121. function toSetting() {
  122. window.location.href = "setting.html";
  123. }
  124. </script>
  125. </body>
  126. </html>