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.

91 lines
2.6 KiB

4 years ago
  1. <script>
  2. $(document).ready(function () {
  3. // ☜ ☝ ☞ ☟ ☆ ✠ ✡ ✢ ✣ ✤ ✥ ✦ ✧ ✩ ✪
  4. // get all the "slides", hide them
  5. $sections = $('section');
  6. $sections.hide();
  7. var section_number = 0;
  8. var $cur_section = $( $sections.get(section_number) );
  9. $cur_section.toggle(); // show first slide
  10. var transit = function (jump) {
  11. $('button').hide();
  12. $cur_section.hide();
  13. section_number += jump;
  14. if (section_number > ($sections.length - 1)) {
  15. section_number = 0;
  16. }
  17. $cur_section = $( $sections.get(section_number) );
  18. $cur_section.toggle({
  19. duration: 200,
  20. done: function () { $('button').show(); }
  21. });
  22. };
  23. var $fwd_button = $('<button class=clicker-button>next</button>');
  24. var $bwd_button = $('<button class=clicker-button>prev</button>');
  25. $fwd_button.click(function (e) {
  26. e.preventDefault();
  27. transit(1);
  28. });
  29. $bwd_button.click(function (e) {
  30. e.preventDefault();
  31. transit(-1);
  32. });
  33. $(document).keydown(function(e) {
  34. switch(e.which) {
  35. case 8: // backspace
  36. case 37: // left
  37. $bwd_button.click();
  38. break;
  39. case 32: // spacebar
  40. case 39: // right
  41. $fwd_button.click();
  42. break;
  43. case 90:
  44. toggleFullScreen();
  45. break;
  46. default:
  47. return;
  48. }
  49. e.preventDefault();
  50. });
  51. $button_group = $('<div class=buttons/>');
  52. $button_group.append($bwd_button);
  53. $button_group.append($fwd_button);
  54. $('body').append($button_group);
  55. var toggleFullScreen = function () {
  56. if (!document.fullscreenElement && // alternative standard method
  57. !document.mozFullScreenElement && !document.webkitFullscreenElement && !document.msFullscreenElement ) { // current working methods
  58. if (document.documentElement.requestFullscreen) {
  59. document.documentElement.requestFullscreen();
  60. } else if (document.documentElement.msRequestFullscreen) {
  61. document.documentElement.msRequestFullscreen();
  62. } else if (document.documentElement.mozRequestFullScreen) {
  63. document.documentElement.mozRequestFullScreen();
  64. } else if (document.documentElement.webkitRequestFullscreen) {
  65. document.documentElement.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
  66. }
  67. } else {
  68. if (document.exitFullscreen) {
  69. document.exitFullscreen();
  70. } else if (document.msExitFullscreen) {
  71. document.msExitFullscreen();
  72. } else if (document.mozCancelFullScreen) {
  73. document.mozCancelFullScreen();
  74. } else if (document.webkitExitFullscreen) {
  75. document.webkitExitFullscreen();
  76. }
  77. }
  78. };
  79. });
  80. </script>
  81. </body>
  82. </html>