wss
This commit is contained in:
11
.github/workflows/docker-build.yml
vendored
11
.github/workflows/docker-build.yml
vendored
@@ -13,17 +13,6 @@ jobs:
|
|||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
# - name: Set up Go
|
|
||||||
# uses: actions/setup-go@v3
|
|
||||||
# with:
|
|
||||||
# go-version: '1.23'
|
|
||||||
|
|
||||||
# - name: Download dependencies
|
|
||||||
# run: go mod download
|
|
||||||
|
|
||||||
# - name: Build
|
|
||||||
# run: go build -o server src/main.go
|
|
||||||
|
|
||||||
- name: Build Docker image
|
- name: Build Docker image
|
||||||
run: |
|
run: |
|
||||||
docker build -t "ghcr.io/jurajkubrican/knet/go-web-server:latest" .
|
docker build -t "ghcr.io/jurajkubrican/knet/go-web-server:latest" .
|
||||||
|
|||||||
@@ -45,7 +45,12 @@
|
|||||||
</html>
|
</html>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
let socket = new WebSocket("ws://" + window.location.host + "/ws");
|
const socketUrl =
|
||||||
|
(window.location.protocol.startsWith("https") ? "wss://" : "ws://") +
|
||||||
|
window.location.host +
|
||||||
|
"/ws";
|
||||||
|
|
||||||
|
let socket = new WebSocket(socketUrl);
|
||||||
|
|
||||||
socket.addEventListener("message", function (event) {
|
socket.addEventListener("message", function (event) {
|
||||||
if (event.data.startsWith("u:")) {
|
if (event.data.startsWith("u:")) {
|
||||||
@@ -68,7 +73,10 @@
|
|||||||
input.checked = false;
|
input.checked = false;
|
||||||
});
|
});
|
||||||
items.forEach((i) => {
|
items.forEach((i) => {
|
||||||
console.log(i);
|
if (!i) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.log(i, document.getElementById("box-" + i));
|
||||||
document.getElementById("box-" + i).checked = true;
|
document.getElementById("box-" + i).checked = true;
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
@@ -82,7 +90,7 @@
|
|||||||
document.querySelectorAll("input").forEach((input) => {
|
document.querySelectorAll("input").forEach((input) => {
|
||||||
input.addEventListener("change", (event) => {
|
input.addEventListener("change", (event) => {
|
||||||
if (socket.readyState !== socket.OPEN) {
|
if (socket.readyState !== socket.OPEN) {
|
||||||
socket = new WebSocket("ws://" + window.location.host + "/ws");
|
socket = new WebSocket(socketUrl);
|
||||||
}
|
}
|
||||||
const id = event.target.id.split("-")[1];
|
const id = event.target.id.split("-")[1];
|
||||||
const value = event.target.checked ? "+" : "-";
|
const value = event.target.checked ? "+" : "-";
|
||||||
|
|||||||
Reference in New Issue
Block a user