From 5dd108c9224e3cd3d533803e5b75e6023ee36e08 Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Tue, 16 Sep 2014 01:50:50 +0100 Subject: [PATCH] COMM fixes - when on global view, clamp the lat/lng so it's not beyond +-180 E/W and +-90 N/S - otherwise the server no longer returns data - fix refresh on chat tab changing - it was firing too early on first page load --- code/chat.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/code/chat.js b/code/chat.js index 00a7d192..6931a1a1 100644 --- a/code/chat.js +++ b/code/chat.js @@ -41,7 +41,7 @@ window.chat._oldBBox = null; window.chat.genPostData = function(isFaction, storageHash, getOlderMsgs) { if(typeof isFaction !== 'boolean') throw('Need to know if public or faction chat.'); - var b = map.getBounds(); + var b = clampLatLngBounds(map.getBounds()); // set a current bounding box if none set so far if (!chat._oldBBox) chat._oldBBox = b; @@ -430,6 +430,13 @@ window.chat.getActive = function() { return $('#chatcontrols .active').text(); } +window.chat.tabToChannel = function(tab) { + if (tab == 'faction') return 'faction'; + if (tab == 'alerts') return 'alerts'; + return 'public'; //for 'full', 'compact' and 'public' +}; + + window.chat.toggle = function() { var c = $('#chat, #chatcontrols'); @@ -481,9 +488,13 @@ window.chat.needMoreMessages = function() { chat.requestFaction(true); else chat.requestPublic(true); -} +}; + window.chat.chooseAnchor = function(t) { + var oldTab = chat.getActive(); + var oldChannel = chat.tabToChannel(oldTab); + var tt = t.text(); localStorage['iitc-chat-tab'] = tt; @@ -494,6 +505,9 @@ window.chat.chooseAnchor = function(t) { $('#chatcontrols .active').removeClass('active'); $("#chatcontrols a:contains('" + tt + "')").addClass('active'); + var newChannel = chat.tabToChannel(tt); + if (newChannel != oldChannel) setTimeout(chat.request,1); + $('#chat > div').hide(); var elm;