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.

script.js 682B

1234567891011121314151617181920212223242526272829303132333435
  1. var elems = {
  2. games: document.getElementById("games"),
  3. overlay: document.getElementById("overlay"),
  4. };
  5. function makeGame(game) {
  6. var a = document.createElement("a");
  7. a.innerText = game;
  8. a.href = "javascript:void(0)";
  9. a.onclick = ipc.run.bind(null, game);
  10. return a;
  11. }
  12. ipc.init(8085, () => {
  13. elems.overlay.className = "";
  14. });
  15. ipc.ongamestopped = () => {
  16. console.log("Game stopped.");
  17. elems.overlay.className = "";
  18. }
  19. ipc.ongamestart = () => {
  20. console.log("Game started.");
  21. elems.overlay.className = "active";
  22. }
  23. ipc.ongamelist = games => {
  24. elems.games.innerHTML = "";
  25. games.forEach(g => elems.games.appendChild(makeGame(g)));
  26. }
  27. ipc.onerror = msg => {
  28. alert(msg);
  29. }