From e47b4dc49fb26607097841ddceeebd5b325d69fa Mon Sep 17 00:00:00 2001 From: FrozenCow Date: Wed, 26 Jan 2011 01:05:00 +0100 Subject: [PATCH] Small fixes to chat-balloons. --- web/map.js | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/web/map.js b/web/map.js index e93e0eaf..0e2bf670 100644 --- a/web/map.js +++ b/web/map.js @@ -274,7 +274,7 @@ DynMap.prototype = { { popup.infoWindow.close(); popup.infoWindow = null; - this.chatPopups[popupIndex] = popup; + delete this.chatPopups[popupIndex]; } } }, @@ -288,20 +288,11 @@ DynMap.prototype = { if (playerMarker) { var popup = chatPopups[playerName]; - if (popup == null) - { - popup = new Object(); - popup.lines = new Array(); - popup.lines[0] = message; - } + if (!popup) + popup = { lines: [ message ] }; else - { - if (popup.infoWindow != null) - { - popup.infoWindow.close(); - } popup.lines[popup.lines.length] = message; - } + var MAX_LINES = 5; if (popup.lines.length > MAX_LINES) { @@ -315,9 +306,13 @@ DynMap.prototype = { htmlMessage = htmlMessage + "" var now = new Date(); popup.popupTime = now.getTime(); - popup.infoWindow = new google.maps.InfoWindow({ - content: htmlMessage - }); + if (!popup.infoWindow) { + popup.infoWindow = new google.maps.InfoWindow({ + content: htmlMessage + }); + } else { + popup.infoWindow.setContent(htmlMessage); + } popup.infoWindow.open(map, playerMarker); this.chatPopups[playerName] = popup; }