MCPcopy
hub / github.com/PokemonGoF/PokemonGo-Bot / displayChatMessageOnMap

Function displayChatMessageOnMap

map-chat/javascript/map.js:180–239  ·  view source on GitHub ↗
(raw)

Source from the content-addressed store, hash-verified

178}
179
180function displayChatMessageOnMap(raw) {
181 var msg = JSON.parse(raw)
182 //console.log(msg)
183 var newPosition = new google.maps.LatLng(msg.lat, msg.lng);
184 var msgSessionId = msg.sessionId;
185
186 // xss prevention hack
187 msg.text = html_sanitize(msg.text);
188
189 msg.text = String(msg.text).replace(/[&<>"#'\/卐卍]/g, function (s) {
190 return entityMap[s];
191 });
192
193 // msg.text = msg.text ? embedTweet(msg.text) : "";
194 msg.text = msg.text.replace(/&#35;(\S*)/g, '<a href="http://maps.pikabot.org/#$1" target="_blank">#$1</a>');
195
196 // linkify
197 msg.text = msg.text.replace(
198 /(\b(https?|ftp|file):&#x2F;&#x2F;[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig,
199 "<a target='_blank' href='$1'>$1</a>"
200 );
201
202 if (markersMap[msgSessionId]) { // update existing marker
203 var existingMarker = markersMap[msgSessionId].marker;
204 var existingInfoWindow = markersMap[msgSessionId].infoWindow;
205 var existingTimeoutId = markersMap[msgSessionId].timeoutId;
206
207 existingMarker.setPosition(newPosition);
208 existingInfoWindow.setContent(msg.text);
209 existingInfoWindow.setZIndex(infoWindowZIndex);
210 infoWindowZIndex++;
211 if (msg.text && !markersMap[msgSessionId].disabled) {
212 if (existingTimeoutId) {
213 clearTimeout(existingTimeoutId);
214 }
215 markersMap[msgSessionId].timeoutId = setTimeout(function () { existingInfoWindow.close() }, 10000);
216 existingInfoWindow.open(map, existingMarker);
217 }
218 } else { // new marker
219 var markerWindow = setupMarkerAndInfoWindow(msgSessionId,msg.text, newPosition, map, markerImage, disabledMarkerImage);
220 var infoWindow = markerWindow.infoWindow;
221 var marker = markerWindow.marker;
222
223 if (msg.text !== 'undefined') {
224 infoWindow.open(map, marker);
225 }
226
227 var timeoutId = setTimeout(function () { infoWindow.close() }, 10000);
228 markersMap[msgSessionId] = {
229 marker: marker,
230 infoWindow: infoWindow,
231 timeoutId: timeoutId,
232 disabled: false
233 }
234 }
235
236 if (advanced) {
237 runAdvancedOptions(msg);

Callers 1

initialiseEventBusFunction · 0.85

Calls 3

setupMarkerAndInfoWindowFunction · 0.85
runAdvancedOptionsFunction · 0.85
parseMethod · 0.45

Tested by

no test coverage detected