|
|
|
@ -11,7 +11,7 @@
|
|
|
|
|
<label for="text">Input: </label>
|
|
|
|
|
<input type="text" id="text" autofocus />
|
|
|
|
|
</form>
|
|
|
|
|
<script>
|
|
|
|
|
<script defer>
|
|
|
|
|
const log = (text, color) => {
|
|
|
|
|
document.getElementById(
|
|
|
|
|
"log"
|
|
|
|
@ -20,12 +20,10 @@
|
|
|
|
|
|
|
|
|
|
console.log(location.protocol);
|
|
|
|
|
console.log(
|
|
|
|
|
location.protocol == "https:"
|
|
|
|
|
? "wss://"
|
|
|
|
|
: "ws://" +
|
|
|
|
|
location.host +
|
|
|
|
|
location.pathname.replace(new RegExp("\/" + "$"), "") +
|
|
|
|
|
"/echo/"
|
|
|
|
|
(location.protocol == "https:" ? "wss://" : "ws://") +
|
|
|
|
|
location.host +
|
|
|
|
|
location.pathname.replace(new RegExp("\/" + "$"), "") +
|
|
|
|
|
"/echo/"
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const socket = new WebSocket(
|
|
|
|
|