Skip to content

Commit

Permalink
cleanup + comments
Browse files Browse the repository at this point in the history
  • Loading branch information
bgstaal committed Nov 23, 2023
1 parent fb1e12e commit 2b509c0
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions WindowManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ class WindowManager
{
let that = this;

// event listener for when localStorage is changed from another window
addEventListener("storage", (event) =>
{
//console.log(event)
if (event.key == "windows")
{
let newWindows = JSON.parse(event.newValue);
Expand All @@ -23,25 +23,23 @@ class WindowManager

if (winChange)
{
//console.log("change");
//console.log("windows", that.#windows);
//console.log("newWindows", newWindows);
if (that.#winChangeCallback) that.#winChangeCallback();
}
}

//console.log(that.#windows);
});

// event listener for when current window is about to ble closed
window.addEventListener('beforeunload', function (e)
{
let index = that.getWindowIndexFromId(that.#id);

//remove this window from the list and update local storage
that.#windows.splice(index, 1);
that.updateWindowsLocalStorage();
});
}

// check if theres any changes to the window list
#didWindowsChange (pWins, nWins)
{
if (pWins.length != nWins.length)
Expand All @@ -61,7 +59,7 @@ class WindowManager
}
}


// initiate current window (add metadata for custom data to store with each window instance)
init (metaData)
{
this.#windows = JSON.parse(localStorage.getItem("windows")) || [];
Expand Down

0 comments on commit 2b509c0

Please sign in to comment.