Skip to main content

The page

This is the theme’s complete index.html. It will not change for the rest of the guide, so here it is in full:
What matters:
  • Leave the <head> tag as it is, with no attributes. ejGames inserts the SDK (<script src="/_sdk/ejg.js">) right after <head>, before your scripts. If it cannot find the tag, it puts the script at the very start, ahead of the <!doctype>, and the page drops into quirks mode.
  • type="module" on your script, so you can use import and await outside functions.
  • data-ejg-drag turns the bar into the handle for dragging the window (double-click maximizes). Anything that should not drag, such as the buttons, gets data-ejg-nodrag.
  • #rejilla will hold the covers, #ficha will be the game page (step 6) and #pistas the control bar (step 5). The data-focus… attributes are explained in step 5.
The visible strings (Buscar, Ajustes, and the ones in later steps) stay in Spanish. That text is the translation key. See Languages.

A little style

Start style.css with the base: colors in variables, the page fullscreen, and the top bar.
That free strip is there because ejGames draws minimize, maximize and close in the top-right corner (they appear when the mouse passes over) and that area receives the clicks. In step 8 you will see how to draw them yourself if you prefer.

The first main.js

  • await window.ejg.ready() waits until ejGames has sent the data (library, profile, options). Always start this way.
  • ejg.library.all is the list of games, already sorted by name. It is an in-memory copy: reading it costs nothing.
  • ejg.library.onChange(fn) tells you when something changes: new games, a favorite, a cover that just finished downloading… Here we draw everything again. In the next step we will do it without rebuilding what did not change.
Save, choose the theme, and you should see your games’ names. Each game (Game) carries, among other things: The full list is in the reference.