backup_html.html 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. <script>
  53. var endpoint = "/system/ajgi/interface?script=/DemoPhoto/backend/listFile.js";
  54. var image = [];
  55. var interval = 0;
  56. $.getJSON(endpoint, function(data) {
  57. image = data["results"];
  58. interval = data["interval"];
  59. }).done(function() {
  60. $(".slideshow").append('<div class="selector" style="text-align: center; position: absolute; top: ; bottom: 20px; left: 15px; "></div>');
  61. for (var i = 0; i < image.length; i++) {
  62. $('<div class="slide"><img src="' + image[i] + '" style="width:100% "></div>').insertBefore(".slideshow > .selector");
  63. $(".slideshow > .selector").append('<span class="dot" onclick="showSlides(' + (i + 1) + ') "></span>');
  64. }
  65. //realigin to center
  66. upd();
  67. showSlides(1);
  68. $('.slideshow .slide').on('load', function() {
  69. upd();
  70. });
  71. $(window).on('resize', function() {
  72. upd();
  73. });
  74. //auto refresh
  75. setInterval(function() {
  76. var selector = $(".slideshow > .selector > .dot.active").next();
  77. if (selector.length > 0) {
  78. selector.click();
  79. } else {
  80. $(".slideshow > .selector > .dot").first().click();
  81. }
  82. }, interval);
  83. });
  84. function showSlides(n) {
  85. $(".slideshow .slide").fadeOut(500, "linear");
  86. $(".slideshow .slide").attr("class", "slide")
  87. $(".slideshow .slide:nth-child(" + (n) + ")").attr("class", "slide active")
  88. $(".slideshow .slide:nth-child(" + (n) + ")").fadeIn("linear");
  89. //dot
  90. $(".slideshow .dot.active").attr("class", "dot")
  91. $(".slideshow .dot:nth-child(" + (n) + ")").attr("class", "dot active")
  92. upd();
  93. }
  94. function upd() {
  95. //ascept ratio calculator, use to resize the image
  96. var selector = $(".slideshow > .slide.active > img");
  97. var img_width = selector.prop("naturalWidth");
  98. var img_height = selector.prop("naturalHeight");
  99. console.log(img_width, img_height);
  100. var win_width = window.innerWidth;
  101. var win_height = window.innerHeight;
  102. var final_w = 0;
  103. var final_h = 0;
  104. final_h = win_height;
  105. final_w = img_width * (win_height / img_height);
  106. //reszie until everything fit the screen
  107. while (final_w >= win_width) {
  108. final_w *= 0.999;
  109. final_h *= 0.999;
  110. }
  111. selector.height(final_h);
  112. selector.width(final_w);
  113. if (img_width < win_width && img_height < win_height) {
  114. selector.height(img_height);
  115. selector.width(img_width);
  116. }
  117. $('.slide.active').css('margin-left', (window.innerWidth - selector.width()) / 2);
  118. $('.slide.active').css('margin-top', (window.innerHeight - selector.height()) / 2);
  119. }
  120. </script>
  121. </body>
  122. </html>