diff --git a/map4.js b/map4.js index b0db6b5..0c20e36 100644 --- a/map4.js +++ b/map4.js @@ -36,13 +36,9 @@ let stationMarkers = []; /* ------------------------------------------------------ - ここから追加:招待リンクコピー機能 + スマホ対応:招待リンクコピー機能(textarea方式) ------------------------------------------------------- */ -// ボタンが map4.html に存在する場合のみ処理(安全対策) -/* ------------------------------------------------------ - 招待リンクコピー機能(完全修正版) -------------------------------------------------------- */ const inviteBtn = document.getElementById("inviteBtn"); if (inviteBtn) { @@ -67,20 +63,28 @@ const pass = data.password; - // join_group.html への招待リンク const inviteURL = `https://www.yatex.org/gitbucket/KoekiGameDesign/2025-shino/pages/join_group.html` + `?group=${encodeURIComponent(currentGroup)}&pass=${encodeURIComponent(pass)}`; + // ---- スマホでも確実にコピーできる処理 ---- + const temp = document.createElement("textarea"); + temp.value = inviteURL; + document.body.appendChild(temp); + + temp.select(); + temp.setSelectionRange(0, 99999); // iPhone対応 + try { - await navigator.clipboard.writeText(inviteURL); - alert("🎉 招待リンクをコピーしました!"); + document.execCommand("copy"); + alert("📋 招待リンクをコピーしました!"); } catch (e) { alert("コピーに失敗しました…"); } + + document.body.removeChild(temp); }); } - // =================================== // 自分の状態(移動中 / 遅れます / 寄り道中 / 到着) // ===================================