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
This commit is contained in:
Jon Atkins 2014-09-16 01:50:50 +01:00
parent 5710cb511a
commit 5dd108c922

View File

@ -41,7 +41,7 @@ window.chat._oldBBox = null;
window.chat.genPostData = function(isFaction, storageHash, getOlderMsgs) { window.chat.genPostData = function(isFaction, storageHash, getOlderMsgs) {
if(typeof isFaction !== 'boolean') throw('Need to know if public or faction chat.'); 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 // set a current bounding box if none set so far
if (!chat._oldBBox) chat._oldBBox = b; if (!chat._oldBBox) chat._oldBBox = b;
@ -430,6 +430,13 @@ window.chat.getActive = function() {
return $('#chatcontrols .active').text(); 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() { window.chat.toggle = function() {
var c = $('#chat, #chatcontrols'); var c = $('#chat, #chatcontrols');
@ -481,9 +488,13 @@ window.chat.needMoreMessages = function() {
chat.requestFaction(true); chat.requestFaction(true);
else else
chat.requestPublic(true); chat.requestPublic(true);
} };
window.chat.chooseAnchor = function(t) { window.chat.chooseAnchor = function(t) {
var oldTab = chat.getActive();
var oldChannel = chat.tabToChannel(oldTab);
var tt = t.text(); var tt = t.text();
localStorage['iitc-chat-tab'] = tt; localStorage['iitc-chat-tab'] = tt;
@ -494,6 +505,9 @@ window.chat.chooseAnchor = function(t) {
$('#chatcontrols .active').removeClass('active'); $('#chatcontrols .active').removeClass('active');
$("#chatcontrols a:contains('" + tt + "')").addClass('active'); $("#chatcontrols a:contains('" + tt + "')").addClass('active');
var newChannel = chat.tabToChannel(tt);
if (newChannel != oldChannel) setTimeout(chat.request,1);
$('#chat > div').hide(); $('#chat > div').hide();
var elm; var elm;