Skip to content

Commit

Permalink
Added link position persistance
Browse files Browse the repository at this point in the history
  • Loading branch information
tybayn committed May 7, 2024
1 parent 0c9e369 commit 74b3edc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ <h3>Data Privacy</h3>
<script src="discord-v5/discord-v1.js"></script>
<script src="wiki-v5/wiki-v2.js"></script>
<script src="scripts-v5/filter-v2.js"></script>
<script src="scripts-v5/wslink-v7.js"></script>
<script src="scripts-v5/wslink-v8.js"></script>
<script src="scripts-v5/zn-v3.js"></script>
<script src="events-v5/events-v1.js"></script>
<script src="feed-v5/feed-v1.js"></script>
Expand Down
5 changes: 4 additions & 1 deletion scripts-v5/wslink-v7.js → scripts-v5/wslink-v8.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ function create_link(auto_link = false){

function link_room(){
var room_id = document.getElementById("room_id").value
ws = new WebSocket(`wss://zero-network.net/phasmolink/link/${znid}/${room_id}`);
var load_pos = getCookie("link-position")
ws = new WebSocket(`wss://zero-network.net/phasmolink/link/${znid}/${room_id}${load_pos ? '?pos='+load_pos : ''}`);
setCookie("room_id",room_id,1)

ws.onopen = function(event){
Expand Down Expand Up @@ -132,6 +133,7 @@ function link_room(){

if (incoming_state.hasOwnProperty("setpos")){
my_pos = incoming_state["setpos"]
setCookie("link-position",my_pos,1)
pos_elem = document.getElementById("link_pos")
pos_elem.innerText = my_pos
pos_elem.style.border = `2px solid #${pos_colors[my_pos]}`
Expand Down Expand Up @@ -517,6 +519,7 @@ function disconnect_room(reset=false,has_status=false){
document.getElementById("room_id").value = ""
}
setCookie("room_id","",-1)
setCookie("link-position","",1)
hasLink=false
}
}
Expand Down

0 comments on commit 74b3edc

Please sign in to comment.