Pass data to JS through DOM not to confuse GoHTML syntax highlighters
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
<template id="name-template">
|
||||
<span class="name"></span>
|
||||
</template>
|
||||
<section id="names" data-my-name="{{ .P.Name }}"></section>
|
||||
<section id="names" data-my-name="{{ .P.Name }}" data-my-id="{{ .P.ID }}"></section>
|
||||
|
||||
<template id="answer-template">
|
||||
<button class="answer"></button>
|
||||
@@ -31,13 +31,6 @@
|
||||
</section>
|
||||
|
||||
<script>
|
||||
const socket = new WebSocket('ws://' + window.location.host + '/ws/' + encodeURIComponent({{ .P.ID }}));
|
||||
|
||||
//TODO remove
|
||||
socket.addEventListener('open', () => {
|
||||
console.log("WS oppened");
|
||||
});
|
||||
|
||||
const namesSection = document.getElementById('names');
|
||||
const nameTemplate = document.getElementById('name-template')
|
||||
|
||||
@@ -45,6 +38,10 @@
|
||||
const questionTemplate = document.getElementById('question-template');
|
||||
const answerTemplate = document.getElementById('answer-template');
|
||||
|
||||
const playerId = namesSection.dataset.myId;
|
||||
|
||||
const socket = new WebSocket('ws://' + window.location.host + '/ws/' + encodeURIComponent(playerId));
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
const next = document.querySelector('#controls .next');
|
||||
next.addEventListener("click", () => {
|
||||
|
||||
Reference in New Issue
Block a user