Advertisement
Guest User

Untitled

a guest
Apr 24th, 2015
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.52 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset=utf-8>
  5. <!-- while sh -c `~/Applications/nwjs-v0.12.1-linux-x64/nw .`; do true; done -->
  6. <title>bootlaunch</title>
  7. <style>
  8. html, body {
  9. margin: 0;
  10. padding: 0;
  11. overflow: hidden;
  12. }
  13.  
  14. body {
  15. position: absolute;
  16. background: #b0b0b0;
  17. height: 100%;
  18. width: 100%;
  19. left: 0;
  20. top: 0;
  21. display: block;
  22. font: 13px Helvetica;
  23. transition: background-color 700ms;
  24. }
  25.  
  26. menu {
  27. display: block;
  28. position: absolute;
  29. top: 50%;
  30. left: 50%;
  31. width: 100%;
  32. text-align: center;
  33. transform: translate(-50%, -50%);
  34. }
  35.  
  36. menuitem {
  37. position: relative;
  38. display: inline-block;
  39. padding: 0 13px;
  40. }
  41.  
  42. menuitem > img {
  43. position: absolute;
  44. display: block;
  45. top: 70px;
  46. left: 20px;
  47. width: 128px;
  48. padding: 0;
  49. transform: translateY(-50%);
  50. margin: auto 0;
  51. filter: drop-shadow(0 4px 2px #606060);
  52. -webkit-filter: drop-shadow(0 4px 2px #606060);
  53. opacity: 1;
  54. transition: opacity 700ms;
  55. }
  56.  
  57. menuitem[data-selected] > img {
  58. transition: opacity 700ms ease 300ms;
  59. }
  60.  
  61. label {
  62. display: block;
  63. margin-top: 152px;
  64. width: 144px;
  65. }
  66.  
  67. #selection-highlight {
  68. transition: transform 300ms, opacity 700ms ease 300ms;
  69. }
  70.  
  71. #selection-highlight, #selection-cursor {
  72. position: absolute;
  73. transform: translateX(0);
  74. transition: transform 300ms;
  75. }
  76.  
  77. #selection-highlight, #selection-cursor-interior {
  78. background: #808080;
  79. border: solid 2px #eaeaea;
  80. }
  81.  
  82. #selection-highlight {
  83. padding: 6px;
  84. width: 128px;
  85. height: 128px;
  86. border-radius: 12px;
  87. }
  88.  
  89. #selection-cursor {
  90. width: 144px;
  91. box-sizing: border-box;
  92. }
  93.  
  94. #selection-cursor-interior {
  95. display: inline-block;
  96. font: 28px Wingdings;
  97. color: white;
  98. border-radius: 100%;
  99. padding: 1px 6px 6px;
  100. margin: 6px 0 0 0;
  101. transition: opacity 700ms ease 300ms;
  102. }
  103. </style>
  104. </head>
  105. <body>
  106. <menu><!--
  107. --><menuitem data-selected>
  108. <div id=selection-highlight></div>
  109. <img src=desktop.jpeg>
  110. <label>Desktop</label>
  111. <div id=selection-cursor><span id=selection-cursor-interior></span></div>
  112. </menuitem><!--
  113. --><menuitem>
  114. <img src=kodi.png>
  115. <label>Kodi</label>
  116. </menuitem><!--
  117. --><menuitem>
  118. <img src=logo_es.png>
  119. <label>Emulation Station</label>
  120. </menuitem><!--
  121. --></menu>
  122. <script>
  123. var selectedIndex = 0;
  124. var itemCount = document.getElementsByTagName('menuitem').length;
  125.  
  126. function launch() {
  127. var path = [
  128. "xcalc",
  129. "xcalc",
  130. "xcalc"
  131. ][selectedIndex];
  132. process.stdout.write(path + "\n");
  133. process.exit();
  134. }
  135.  
  136. function select() {
  137. document.body.style.backgroundColor = 'black';
  138. var menuItemImages = document.querySelectorAll("menuitem > img");
  139. for (var i = 0; i < menuItemImages.length; i++)
  140. menuItemImages[i].style.opacity = 0;
  141. document.getElementById('selection-highlight').style.opacity = 0;
  142. document.getElementById('selection-cursor').style.opacity = 0;
  143.  
  144. setTimeout(launch, 1200);
  145. }
  146.  
  147. function move(direction) {
  148. document.getElementsByTagName('menuitem')[selectedIndex].removeAttribute('data-selected');
  149.  
  150. switch (direction) {
  151. case 'left':
  152. selectedIndex = selectedIndex == 0 ? itemCount - 1 : selectedIndex - 1;
  153. break;
  154. case 'right':
  155. selectedIndex = (selectedIndex + 1) % itemCount;
  156. break;
  157. }
  158.  
  159. document.getElementsByTagName('menuitem')[selectedIndex].setAttribute('data-selected',
  160. 'data-selected');
  161.  
  162. var transform = "translateX(" + ((144 + 13 + 13) * selectedIndex) + "px)";
  163. document.getElementById('selection-highlight').style.transform = transform;
  164. document.getElementById('selection-cursor').style.transform = transform;
  165. }
  166.  
  167. function keydown(event) {
  168. switch (event.keyCode) {
  169. case 13:
  170. select();
  171. break;
  172. case 37:
  173. move('left');
  174. break;
  175. case 39:
  176. move('right');
  177. break;
  178. }
  179. }
  180.  
  181. var gamepadState = [];
  182.  
  183. function pollGamepads() {
  184. var gamepads = navigator.getGamepads();
  185. for (var i = 0; i < gamepads.length; i++) {
  186. var gamepad = gamepads[i];
  187. if (gamepad == null)
  188. continue;
  189. if (gamepadState[i] == null) {
  190. gamepadState[i] = {
  191. buttons: [],
  192. axes: [],
  193. };
  194. }
  195. if (gamepad.axes.length >= 1 && gamepad.axes[0] < -0.5 && gamepadState[i].axes[0] == 0.0)
  196. move('left');
  197. if (gamepad.axes.length >= 1 && gamepad.axes[0] > 0.5 && gamepadState[i].axes[0] == 0.0)
  198. move('right');
  199. if (gamepad.buttons.length >= 16 && gamepad.buttons[15].pressed && !gamepadState[i].buttons[15])
  200. move('right');
  201. if (gamepad.buttons.length >= 17 && gamepad.buttons[16].pressed && !gamepadState[i].buttons[16])
  202. move('left');
  203. if (gamepad.buttons.length >= 10 && gamepad.buttons[9].pressed && !gamepadState[i].buttons[9])
  204. select();
  205.  
  206. for (var j = 0; j < gamepad.axes.length; j++)
  207. gamepadState[i].axes[j] = gamepad.axes[j];
  208. for (var j = 0; j < gamepad.buttons.length; j++)
  209. gamepadState[i].buttons[j] = gamepad.buttons[j].pressed;
  210. }
  211. }
  212.  
  213. document.body.addEventListener('keydown', keydown, false);
  214. window.setInterval(pollGamepads, 50);
  215.  
  216. </script>
  217. </body>
  218. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement