-
-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
145 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,31 @@ | ||
function $mol_build_client() { | ||
|
||
const origin = document.location.origin.replace( /^http/ , 'ws' ) | ||
const path = document.location.pathname | ||
const uri = origin + path | ||
// @ts-check | ||
|
||
const socket = new WebSocket( uri ) | ||
|
||
socket.onclose = ()=> setTimeout( ()=> $mol_build_client() , 1000 ) | ||
|
||
socket.onmessage = message => { | ||
if( message.data !== '$mol_build_obsolete' ) return | ||
location.reload() | ||
} | ||
class $mol_build_client { | ||
static closed = false | ||
static run() { | ||
const origin = document.location.origin.replace( /^http/ , 'ws' ) | ||
const path = document.location.pathname | ||
const uri = origin + path | ||
|
||
const socket = new WebSocket( uri ) | ||
|
||
socket.onclose = ()=> { | ||
this.closed = true | ||
setTimeout( ()=> $mol_build_client.run() , 1000 ) | ||
} | ||
|
||
socket.onopen = () => { | ||
if (this.closed) location.reload() | ||
this.closed = false | ||
} | ||
|
||
socket.onmessage = message => { | ||
if( message.data !== '$mol_build_obsolete' ) return | ||
location.reload() | ||
} | ||
|
||
} | ||
} | ||
|
||
$mol_build_client() | ||
$mol_build_client.run() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.