X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=public%2Fjavascripts%2Fcomponents%2Fchat.js;fp=public%2Fjavascripts%2Fcomponents%2Fchat.js;h=0000000000000000000000000000000000000000;hb=625022fdcf750f0aff8fcd699f7e9b89730e1d10;hp=8230e9f853ae01ca35c2fea68846ad05c2277cef;hpb=b955c65b942d09d24b5c3bed0d755d4f2f8f71f1;p=vchess.git
diff --git a/public/javascripts/components/chat.js b/public/javascripts/components/chat.js
deleted file mode 100644
index 8230e9f8..00000000
--- a/public/javascripts/components/chat.js
+++ /dev/null
@@ -1,79 +0,0 @@
-// TODO: myname, opppnents (optional, different style), people
-// --> also show messages like "X offers draw ?" (probably not)
-// myname: localStorage["username"] || "anonymous",
-Vue.component("my-chat", {
- props: ["conn","myname","opponents","people"],
- data: function() {
- return {
- chats: [], //chat messages after human game
- };
- },
- // TODO: Chat modal sur petit écran, dans la page pour grand écran
- template: `
-
-
-
-
-
-
- {{ translate("Chat with ") }}
- {{ o.name }}
-
-
o.id == chat.uid)"}
- v-html="chat.msg"
- >
- TODO: why chat.msg fails here?
-
-
-
-
-
-
- `,
- created: function() {
- const socketMessageListener = msg => {
- const data = JSON.parse(msg.data);
- switch (data.code)
- {
- case "newchat":
- // TODO: new chat just arrived: data contain all informations
- // (uid, name, message; no need for timestamp, we can use local time here)
- this.chats.push({msg:data.msg, author:this.oppid});
- break;
- // TODO: distinguish these (dis)connect events from their analogs in game.js
- // TODO: implement and harmonize: opponents and people are arrays, not objects ?!
- case "connect":
- this.players.push({name:data.name, id:data.uid});
- break;
- case "disconnect":
- const pIdx = this.players.findIndex(p => p.id == data.uid);
- this.players.splice(pIdx);
- break;
- }
- };
- const socketCloseListener = () => {
- this.conn.addEventListener('message', socketMessageListener);
- this.conn.addEventListener('close', socketCloseListener);
- };
- this.conn.onmessage = socketMessageListener;
- this.conn.onclose = socketCloseListener;
- },
- methods: {
- translate: translate,
- // TODO: complete this component
- sendChat: function() {
- let chatInput = document.getElementById("input-chat");
- const chatTxt = chatInput.value;
- chatInput.value = "";
- this.chats.push({msg:chatTxt, author:this.myid});
- this.conn.send(JSON.stringify({
- code:"newchat", oppid: this.oppid, msg: chatTxt}));
- },
-// startChat: function(e) {
-// document.getElementById("modal-chat").checked = true;
-// },
- },
-});