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.5KB

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