class Phone{ constructor(){ this.position = 0; this.messages = []; } addMessage(message){ this.messages.push(message); let msg = document.createElement("div"); msg.className = "message"; let h2 = document.createElement("h2"); h2.className = "messageTitle"; h2.innerText = message.title; let p = document.createElement("p"); p.className = "messageContent"; p.innerText = message.content; msg.appendChild(h2); msg.appendChild(p); let chatMessages = document.getElementById("chatMessages"); chatMessages.appendChild(msg); chatMessages.scrollTop = chatMessages.scrollHeight; } sendMessage(title, content){ let message = { title: player.name, content: content } this.addMessage(message); net.sendMessage(title, content); } keyPress(input){ if(event.key=='Enter'){ if(input.value!=''){ this.sendMessage(player.name, input.value); input.value = ''; input.blur() } } } changePosition(){ if(this.position == 0){ document.getElementById("phoneContainer").className = "visible"; this.position = 1; }else{ document.getElementById("phoneContainer").className = "hidden"; this.position = 0; } } }