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">
|
<template id="name-template">
|
||||||
<span class="name"></span>
|
<span class="name"></span>
|
||||||
</template>
|
</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">
|
<template id="answer-template">
|
||||||
<button class="answer"></button>
|
<button class="answer"></button>
|
||||||
@@ -31,13 +31,6 @@
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<script>
|
<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 namesSection = document.getElementById('names');
|
||||||
const nameTemplate = document.getElementById('name-template')
|
const nameTemplate = document.getElementById('name-template')
|
||||||
|
|
||||||
@@ -45,6 +38,10 @@
|
|||||||
const questionTemplate = document.getElementById('question-template');
|
const questionTemplate = document.getElementById('question-template');
|
||||||
const answerTemplate = document.getElementById('answer-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", () => {
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
const next = document.querySelector('#controls .next');
|
const next = document.querySelector('#controls .next');
|
||||||
next.addEventListener("click", () => {
|
next.addEventListener("click", () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user