Skip to content

Commit

Permalink
implement fragments for sharing
Browse files Browse the repository at this point in the history
  • Loading branch information
wyattscarpenter committed Dec 7, 2020
1 parent 792070c commit ca78383
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions quiplibre.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ <h1 id="roomname">Quiplibre</h1>
<script>
form.addEventListener("submit", function(event){event.preventDefault();}, false);

function toQuiplibreRoomId(s){return "quiplibre_"+(s.toLowerCase().replace(/[^a-z]/g, ""));}
//join if we have a fragment, for sharing purposes.
if(window.location.hash){join(window.location.hash.substring(1))};

function toQuiplibreSlug(s){return s.toLowerCase().replace(/[^a-z0-9]/g, "");}
function toQuiplibreRoomId(s){return "quiplibre_"+toQuiplibreSlug(s);}
function errorAlert(error){
alert("There has been a networking error; if you find yourself unable to play, please refresh the page.\n"+error);
console.log(error);
Expand Down Expand Up @@ -77,7 +81,7 @@ <h1 id="roomname">Quiplibre</h1>
//big screen stuff
function becomeBigScreen(name){
roomname.innerHTML += ": "+name
playDiv.innerHTML = "Hi, welcome to Quiplibre! Visit https://wyattscarpenter.github.io/quiplibre/ to join! Room code: "+name+"<br>"+
playDiv.innerHTML = "Hi, welcome to Quiplibre! Visit https://wyattscarpenter.github.io/quiplibre#"+toQuiplibreSlug(name)+" to join! Room code: "+name+"<br>"+
"No players established.<br>"+
"(You need at least two people to connect in order to play Quiplibre.)";
buttonDiv.style = ""; //show, by removing display: none;
Expand Down

0 comments on commit ca78383

Please sign in to comment.