diff --git a/TableturfBattleClient/index.html b/TableturfBattleClient/index.html
index 5527326..6b833ee 100644
--- a/TableturfBattleClient/index.html
+++ b/TableturfBattleClient/index.html
@@ -8,7 +8,6 @@
This application requires JavaScript.
- Loading game data...

Tableturf Battle
@@ -21,7 +20,7 @@
-
Waiting for players to join.
+
Other players can join using a link to this page.
diff --git a/TableturfBattleClient/src/Pages/LobbyPage.ts b/TableturfBattleClient/src/Pages/LobbyPage.ts
index f1cccd6..cfc87f7 100644
--- a/TableturfBattleClient/src/Pages/LobbyPage.ts
+++ b/TableturfBattleClient/src/Pages/LobbyPage.ts
@@ -1,5 +1,25 @@
let cardButtons: CardButton[] = [ ];
+let shareLinkButton = document.getElementById('shareLinkButton') as HTMLButtonElement;
let submitDeckButton = document.getElementById('submitDeckButton') as HTMLButtonElement;
+let lobbyShareData: ShareData | null;
+
+function initLobbyPage(url: string) {
+ lobbyShareData = { url: url, title: 'Tableturf Battle' };
+ if (navigator.canShare && navigator.canShare(lobbyShareData)) {
+ shareLinkButton.innerText = 'Share link';
+ } else {
+ lobbyShareData = null;
+ shareLinkButton.innerText = 'Copy link';
+ }
+}
+
+shareLinkButton.addEventListener('click', () => {
+ if (lobbyShareData != null) {
+ navigator.share(lobbyShareData);
+ } else {
+ navigator.clipboard.writeText(window.location.toString()).then(() => shareLinkButton.innerText = 'Copied');
+ }
+});
function clearReady() {
if (currentGame == null) return;
diff --git a/TableturfBattleClient/src/Pages/PreGamePage.ts b/TableturfBattleClient/src/Pages/PreGamePage.ts
index 068d5e0..257b242 100644
--- a/TableturfBattleClient/src/Pages/PreGamePage.ts
+++ b/TableturfBattleClient/src/Pages/PreGamePage.ts
@@ -60,6 +60,7 @@ function tryJoinGame(name: string, idOrUrl: string) {
function getGameInfo(gameID: string, myPlayerIndex: number | null) {
board.playerIndex = myPlayerIndex;
window.location.hash = `#${gameID}`;
+ initLobbyPage(window.location.toString());
const webSocket = new WebSocket(`${config.apiBaseUrl.replace(/(http)(s)?\:\/\//, 'ws$2://')}/websocket?gameID=${gameID}&clientToken=${clientToken}`);
webSocket.addEventListener('open', e => {
diff --git a/TableturfBattleClient/src/app.ts b/TableturfBattleClient/src/app.ts
index 2d976f9..cddd256 100644
--- a/TableturfBattleClient/src/app.ts
+++ b/TableturfBattleClient/src/app.ts
@@ -4,7 +4,7 @@ function delay(ms: number) { return new Promise(resolve => setTimeout(() => reso
// Sections
const sections = new Map();
-for (var id of [ 'noJS', 'loading', 'preGame', 'lobby', 'deck', 'game' ]) {
+for (var id of [ 'noJS', 'preGame', 'lobby', 'deck', 'game' ]) {
let el = document.getElementById(`${id}Section`) as HTMLDivElement;
if (!el) throw new EvalError(`Element not found: ${id}Section`);
sections.set(id, el);