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 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <title>Slides</title>
  7. <style>
  8. html, body {
  9. margin: 0px;
  10. padding: 0px;
  11. height: 100%;
  12. overflow: hidden;
  13. font-family: sans-serif;
  14. }
  15. #_overlay {
  16. z-index: 2;
  17. will-change: opacity;
  18. }
  19. #_main {
  20. z-index: 1;
  21. }
  22. #_msg {
  23. z-index: 3;
  24. position: absolute;
  25. top: 6px;
  26. right: 6px;
  27. display: none;
  28. }
  29. #_msg.active {
  30. display: block;
  31. }
  32. ._content {
  33. background: white;
  34. position: absolute;
  35. width: 100%;
  36. height: 100%;
  37. top: 0%;
  38. left: 0px;
  39. display: flex;
  40. align-items: center;
  41. justify-content: center;
  42. }
  43. ._content ._wrapper {
  44. display: inline-block;
  45. text-align: center;
  46. }
  47. ._content h1 { font-size: 5em }
  48. ._content h2 { font-size: 4.5em }
  49. ._content h3 { font-size: 4em }
  50. ._content p { font-size: 2.2em }
  51. ._content .fullscreen {
  52. position: absolute;
  53. width: 100%;
  54. height: 100%;
  55. top: 0px;
  56. left: 50%;
  57. -moz-transform: translateX(-50%);
  58. -ms-transform: translateX(-50%);
  59. -webkit-transform: translateX(-50%);
  60. transform: translateX(-50%);
  61. }
  62. ._content img.fullscreen {
  63. width: auto;
  64. }
  65. #_overlay {
  66. transition: opacity <<transition_time>>s;
  67. opacity: 1;
  68. }
  69. #_overlay.hidden {
  70. opacity: 0;
  71. }
  72. </style>
  73. </head>
  74. <body>
  75. <div id="_main" class="_content"></div>
  76. <div id="_overlay" class="_content"></div>
  77. <div id="_msg"></div>
  78. <!-- Fetch polyfill -->
  79. <script src="/polyfills.js"></script>
  80. <!-- Handle reloading -->
  81. <script>
  82. </script>
  83. <script>
  84. (function fullscreen() {
  85. var elem = document.body;
  86. var rFS = elem.requestFullScreen ||
  87. elem.msRequestFullScreen ||
  88. elem.mozRequestFullScreen ||
  89. elem.webkitRequestFullScreen;
  90. if (rFS)
  91. rFS.call(elem);
  92. })();
  93. var overlay = () => document.querySelector("#_overlay");
  94. var main = () => document.querySelector("#_main");
  95. var msg = () => document.querySelector("#_msg");
  96. function message(str) {
  97. msg().innerHTML = str;
  98. msg().className = "active";
  99. }
  100. // Swap the IDs of two elements
  101. function swap(elem1, elem2) {
  102. var tmp = elem1.id;
  103. elem1.id = elem2.id;
  104. elem2.id = tmp;
  105. }
  106. // Change slides with a transition
  107. function update(name) {
  108. overlay().innerHTML = "";
  109. overlay().className = "_content";
  110. swap(main(), overlay());
  111. fetch("/slide")
  112. .then(response => response.text())
  113. .then(text => {
  114. history.replaceState({}, "", "/"+name+"/");
  115. main().innerHTML = "<div class='_wrapper'>"+text+"</div>";
  116. setTimeout(() => {
  117. overlay().className = "_content hidden";
  118. }, 1000);
  119. })
  120. .catch(err => console.error(err));
  121. }
  122. function reload() {
  123. message("Server down, waiting");
  124. var i = setInterval(() => {
  125. fetch("/")
  126. .then(() => {
  127. history.replaceState({}, "", "/");
  128. location.reload();
  129. })
  130. .catch(() => {});
  131. }, 1000);
  132. }
  133. function await() {
  134. // Wait for the next slide change, then update again
  135. console.log("fetching");
  136. fetch("/await", { method: "POST" })
  137. .then(response => response.json())
  138. .then(obj => {
  139. console.log("fetched", JSON.stringify(obj));
  140. if (obj.evt === "next") {
  141. update(obj.args.name);
  142. } else if (obj.evt === "reload") {
  143. return reload();
  144. } else {
  145. console.log("Unknown event: "+obj.evt);
  146. }
  147. await();
  148. })
  149. .catch(err => { console.error(err); await(); });
  150. }
  151. await();
  152. fetch("/init")
  153. .then(response => response.text())
  154. .then(name => update(name));
  155. </script>
  156. </body>
  157. </html>