Pictures!
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.

index.html 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Slides</title>
  6. <style>
  7. html, body {
  8. margin: 0px;
  9. padding: 0px;
  10. height: 100%;
  11. overflow: hidden;
  12. }
  13. #_overlay {
  14. z-index: 2;
  15. }
  16. #_main {
  17. z-index: 1;
  18. }
  19. ._content {
  20. background: white;
  21. position: absolute;
  22. width: 100%;
  23. height: 100%;
  24. top: 0px;
  25. left: 0px;
  26. }
  27. ._content {
  28. text-align: center;
  29. }
  30. ._content h1 { font-size: 5em }
  31. ._content h2 { font-size: 4.5em }
  32. ._content h3 { font-size: 4em }
  33. ._content p { font-size: 2.2em }
  34. ._content .fullscreen {
  35. position: absolute;
  36. width: 100%;
  37. height: 100%;
  38. top: 0px;
  39. left: 50%;
  40. -moz-transform: translateX(-50%);
  41. -ms-transform: translateX(-50%);
  42. -webkit-transform: translateX(-50%);
  43. transform: translateX(-50%);
  44. }
  45. ._content img.fullscreen {
  46. width: auto;
  47. }
  48. #_overlay {
  49. transition: opacity {{transition_time}}s;
  50. opacity: 1;
  51. }
  52. #_overlay.hidden {
  53. opacity: 0;
  54. }
  55. </style>
  56. </head>
  57. <body>
  58. <div id="_main" class="_content"></div>
  59. <div id="_overlay" class="_content"></div>
  60. <!-- Fetch polyfill -->
  61. <script src="https://cdnjs.cloudflare.com/ajax/libs/fetch/1.0.0/fetch.min.js"></script>
  62. <script>
  63. var overlay = () => document.querySelector("#_overlay");
  64. var main = () => document.querySelector("#_main");
  65. // Swap the IDs of two elements
  66. function swap(elem1, elem2) {
  67. var tmp = elem1.id;
  68. elem1.id = elem2.id;
  69. elem2.id = tmp;
  70. }
  71. // Change slides with a transition
  72. function update(name) {
  73. overlay().innerHTML = "";
  74. overlay().className = "_content";
  75. swap(main(), overlay());
  76. fetch("/slide")
  77. .then(response => response.text())
  78. .then(text => {
  79. setTimeout(() => {
  80. history.replaceState({}, "", "/"+name+"/");
  81. main().innerHTML = text;
  82. overlay().className = "_content hidden";
  83. }, 1000);
  84. })
  85. .catch(err => console.error(err));
  86. }
  87. function reload() {
  88. var i = setInterval(() => {
  89. fetch("/")
  90. .then(() => {
  91. history.replaceState({}, "", "/");
  92. location.reload();
  93. })
  94. .catch(() => {});
  95. }, 1000);
  96. }
  97. function await() {
  98. // Wait for the next slide change, then update again
  99. fetch("/await")
  100. .then(response => response.json())
  101. .then(obj => {
  102. if (obj.evt === "next") {
  103. update(obj.args.name);
  104. } else if (obj.evt === "reload") {
  105. return reload();
  106. } else {
  107. console.log("Unknown event: "+obj.evt);
  108. }
  109. await();
  110. })
  111. .catch(err => { console.error(err); await(); });
  112. }
  113. await();
  114. fetch("/init")
  115. .then(response => response.text())
  116. .then(name => update(name));
  117. </script>
  118. </body>
  119. </html>