From d1f34d088b3b4b36f26b41df0357d62781e0d3c4 Mon Sep 17 00:00:00 2001 From: Zach Parks Date: Sun, 31 Jul 2022 15:17:26 +0000 Subject: [PATCH] WebHost: Add links to "Setup Guides" in Supported Games page (#847) * WebHost: Add links to "Setup Guides" in Supported Games page * Remove a hanging console.log() I left in --- WebHostLib/static/assets/tutorialLanding.js | 10 ++++++++++ WebHostLib/templates/supportedGames.html | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/WebHostLib/static/assets/tutorialLanding.js b/WebHostLib/static/assets/tutorialLanding.js index d00eefa3..b820cc34 100644 --- a/WebHostLib/static/assets/tutorialLanding.js +++ b/WebHostLib/static/assets/tutorialLanding.js @@ -23,6 +23,7 @@ window.addEventListener('load', () => { games.forEach((game) => { const gameTitle = document.createElement('h2'); gameTitle.innerText = game.gameTitle; + gameTitle.id = `${encodeURIComponent(game.gameTitle)}`; tutorialDiv.appendChild(gameTitle); game.tutorials.forEach((tutorial) => { @@ -65,6 +66,15 @@ window.addEventListener('load', () => { showError(); console.error(error); } + + // Check if we are on an anchor when coming in, and scroll to it. + const hash = window.location.hash; + if (hash) { + const offset = 128; // To account for navbar banner at top of page. + window.scrollTo(0, 0); + const rect = document.getElementById(hash.slice(1)).getBoundingClientRect(); + window.scrollTo(rect.left, rect.top - offset); + } }; ajax.open('GET', `${window.location.origin}/static/generated/tutorials.json`, true); ajax.send(); diff --git a/WebHostLib/templates/supportedGames.html b/WebHostLib/templates/supportedGames.html index 00f49d6d..125551fb 100644 --- a/WebHostLib/templates/supportedGames.html +++ b/WebHostLib/templates/supportedGames.html @@ -15,10 +15,15 @@

{{ world.__doc__ | default("No description provided.", true) }}
Game Page + {% if world.web.tutorials %} | + Setup Guides + {% endif %} {% if world.web.settings_page is string %} + | Settings Page {% elif world.web.settings_page %} + | Settings Page {% endif %} {% if world.web.bug_report_page %}