" - for (var line in popup.lines) + var htmlMessage = '
"; + var line; + for (line in popup.lines) { htmlMessage = htmlMessage + popup.lines[line] + "
"; } - htmlMessage = htmlMessage + "
diff --git a/web/map.js b/web/map.js index 740cfb14..6c1c7bb6 100644 --- a/web/map.js +++ b/web/map.js @@ -10,7 +10,7 @@ function splitArgs(s) { var obj = {}; var index = 0; $.each(arguments, function(argumentIndex, argument) { - if (!argumentIndex) return; + if (!argumentIndex) { return; } var value = r[argumentIndex-1]; obj[argument] = value; }); @@ -44,13 +44,13 @@ function DynMap(options) { $.getJSON(me.options.updateUrl + 'configuration', function(configuration) { me.configure(configuration); me.initialize(); - }) + }); } DynMap.prototype = { worlds: {}, - registeredTiles: new Array(), + registeredTiles: [], players: {}, - chatPopups: new Array(), + chatPopups: [], lasttimestamp: '0', followingPlayer: '', configure: function(configuration) { @@ -190,10 +190,10 @@ DynMap.prototype = { // The Compass var compass = $('
') .addClass('compass') - .appendTo(container) + .appendTo(container); // The chat - if (me.options.showchat == 'modal') { + if (me.options.showchat === 'modal') { var chat = me.chat = $('') .addClass('chat') .appendTo(container); @@ -208,7 +208,7 @@ DynMap.prototype = { value: '' }) .keydown(function(event) { - if (event.keyCode == '13') { + if (event.keyCode === '13') { event.preventDefault(); sendChat(chatinput.val()); chatinput.val(''); @@ -254,8 +254,8 @@ DynMap.prototype = { }, selectWorld: function(world, completed) { var me = this; - if (typeof(world) == 'String') { world = me.worlds[world]; } - if (me.world == world) { + if (typeof(world) === 'String') { world = me.worlds[world]; } + if (me.world === world) { if (completed) { completed(); } return; } @@ -292,7 +292,8 @@ DynMap.prototype = { } newplayers[name] = player; }); - for(var name in me.players) { + var name; + for(name in me.players) { var player = me.players[name]; if(!(name in newplayers)) { me.removePlayer(player); @@ -305,17 +306,19 @@ DynMap.prototype = { me.onTileUpdated(update.name); }, chat: function() { - if (!me.options.showchat) - return; + if (!me.options.showchat) { + return; + } me.onPlayerChat(update.playerName, update.message); }, webchat: function() { - if (!me.options.showchat) - return; + if (!me.options.showchat) { + return; + } me.onPlayerChat('[WEB]' + update.playerName, update.message); } }, function(type) { - console.log('Unknown type ', value, '!'); + console.log('Unknown type ', type, '!'); }); /* remove older messages from chat*/ //var timestamp = event.timeStamp; @@ -356,7 +359,8 @@ DynMap.prototype = { var POPUP_LIFE = 8000; var d = new Date(); var now = d.getTime(); - for (var popupIndex in this.chatPopups) + var popupIndex; + for (popupIndex in this.chatPopups) { var popup = this.chatPopups[popupIndex]; if (now - popup.popupTime > POPUP_LIFE) @@ -373,26 +377,28 @@ DynMap.prototype = { var map = me.map; var player = me.players[playerName]; var playerMarker = player && player.marker; - if (me.options.showchat == 'balloons') { + if (me.options.showchat === 'balloons') { if (playerMarker) { var popup = chatPopups[playerName]; - if (!popup) + if (!popup) { popup = { lines: [ message ] }; - else + } else { popup.lines[popup.lines.length] = message; + } var MAX_LINES = 5; if (popup.lines.length > MAX_LINES) { popup.lines = popup.lines.slice(1); } - htmlMessage = '