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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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: auto;
  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. #_overlay {
  46. transition: opacity {{transition_time}}s;
  47. opacity: 1;
  48. }
  49. #_overlay.hidden {
  50. opacity: 0;
  51. }
  52. </style>
  53. </head>
  54. <body>
  55. <div id="_main" class="_content"></div>
  56. <div id="_overlay" class="_content"></div>
  57. <!-- Fetch polyfill -->
  58. <script src="https://cdnjs.cloudflare.com/ajax/libs/fetch/1.0.0/fetch.min.js"></script>
  59. <script>
  60. var overlay = () => document.querySelector("#_overlay");
  61. var main = () => document.querySelector("#_main");
  62. // Swap the IDs of two elements
  63. function swap(elem1, elem2) {
  64. var tmp = elem1.id;
  65. elem1.id = elem2.id;
  66. elem2.id = tmp;
  67. }
  68. // Change slides with a transition
  69. function update(name) {
  70. overlay().innerHTML = "";
  71. overlay().className = "_content";
  72. swap(main(), overlay());
  73. fetch("/slide")
  74. .then(response => response.text())
  75. .then(text => {
  76. setTimeout(() => {
  77. history.replaceState({}, "", "/"+name+"/");
  78. main().innerHTML = text;
  79. overlay().className = "_content hidden";
  80. }, 1000);
  81. })
  82. .catch(err => console.error(err));
  83. }
  84. function reload() {
  85. var i = setInterval(() => {
  86. fetch("/")
  87. .then(() => {
  88. history.replaceState({}, "", "/");
  89. location.reload();
  90. })
  91. .catch(() => {});
  92. }, 1000);
  93. }
  94. function await() {
  95. // Wait for the next slide change, then update again
  96. fetch("/await")
  97. .then(response => response.json())
  98. .then(obj => {
  99. if (obj.evt === "next") {
  100. update(obj.args.name);
  101. } else if (obj.evt === "reload") {
  102. return reload();
  103. } else {
  104. console.log("Unknown event: "+obj.evt);
  105. }
  106. await();
  107. })
  108. .catch(err => { console.error(err); await(); });
  109. }
  110. await();
  111. fetch("/init")
  112. .then(response => response.text())
  113. .then(name => update(name));
  114. </script>
  115. </body>
  116. </html>