first attempt at loading portal details, and displaying in the sidebar once loaded
This commit is contained in:
@ -540,6 +540,7 @@ function boot() {
|
||||
window.setupPlayerStat();
|
||||
window.setupTooltips();
|
||||
window.chat.setup();
|
||||
window.portalDetail.setup();
|
||||
window.setupQRLoadLib();
|
||||
window.setupLayerChooserSelectOne();
|
||||
window.setupLayerChooserStatusRecorder();
|
||||
|
@ -48,7 +48,8 @@
|
||||
// called after each map data request finished. Argument is
|
||||
// {success: boolean} indicated the request success or fail.
|
||||
// iitcLoaded: called after IITC and all plugins loaded
|
||||
|
||||
// portalDetailLoaded: called when a request to load full portal detail
|
||||
// completes. guid, success, details parameters
|
||||
|
||||
window._hooks = {}
|
||||
window.VALID_HOOKS = [
|
||||
@ -58,7 +59,8 @@ window.VALID_HOOKS = [
|
||||
'portalDetailsUpdated',
|
||||
'publicChatDataAvailable', 'factionChatDataAvailable',
|
||||
'requestFinished', 'nicknameClicked',
|
||||
'geoSearch', 'iitcLoaded'];
|
||||
'geoSearch', 'iitcLoaded',
|
||||
'portalDetailLoaded'];
|
||||
|
||||
window.runHooks = function(event, data) {
|
||||
if(VALID_HOOKS.indexOf(event) === -1) throw('Unknown event type: ' + event);
|
||||
|
55
code/portal_detail.js
Normal file
55
code/portal_detail.js
Normal file
@ -0,0 +1,55 @@
|
||||
/// PORTAL DETAIL //////////////////////////////////////
|
||||
// code to retrieve the new potal detail data from the servers
|
||||
|
||||
|
||||
// anonymous function wrapper for the code - any variables/functions not placed into 'window' will be private
|
||||
(function(){
|
||||
|
||||
var cache;
|
||||
|
||||
|
||||
window.portalDetail = function() {};
|
||||
|
||||
window.portalDetail.setup = function() {
|
||||
cache = new DataCache();
|
||||
|
||||
cache.startExpireInterval(20);
|
||||
}
|
||||
|
||||
window.portalDetail.get = function(guid) {
|
||||
return cache.get(guid);
|
||||
}
|
||||
|
||||
window.portalDetail.isFresh = function(guid) {
|
||||
return cache.isFresh(guid);
|
||||
}
|
||||
|
||||
|
||||
var handleResponse = function(guid, data, success) {
|
||||
|
||||
if (success) {
|
||||
cache.store(guid,data);
|
||||
|
||||
//FIXME..? better way of handling sidebar refreshing...
|
||||
|
||||
if (guid == selectedPortal) {
|
||||
renderPortalDetails(guid);
|
||||
}
|
||||
}
|
||||
|
||||
window.runHooks ('portalDetailLoaded', {guid:guid, success:success, details:data});
|
||||
}
|
||||
|
||||
window.portalDetail.request = function(guid) {
|
||||
|
||||
window.postAjax('getPortalDetails', {guid:guid},
|
||||
function(data,textStatus,jqXHR) { handleResponse(guid, data, true); },
|
||||
function() { handleResponse(guid, undefined, false); }
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
})(); // anonumous wrapper function end
|
||||
|
||||
|
@ -3,11 +3,14 @@
|
||||
// methods that highlight the portal in the map view.
|
||||
|
||||
window.renderPortalDetails = function(guid) {
|
||||
// TODO: start a request for the selected portal detailed data
|
||||
// (do this even if not in window.portals?)
|
||||
|
||||
selectPortal(window.portals[guid] ? guid : null);
|
||||
|
||||
if (!portalDetail.isFresh(guid)) {
|
||||
portalDetail.request(guid);
|
||||
}
|
||||
|
||||
// TODO? handle the case where we request data for a particular portal GUID, but it *isn't* in
|
||||
// window.portals....
|
||||
|
||||
if(!window.portals[guid]) {
|
||||
urlPortal = guid;
|
||||
@ -21,11 +24,11 @@ window.renderPortalDetails = function(guid) {
|
||||
|
||||
var portal = window.portals[guid];
|
||||
var data = portal.options.data;
|
||||
var details = undefined; //TODO: get the details
|
||||
var details = portalDetail.get(guid);
|
||||
|
||||
|
||||
var modDetails = details ? '<div class="mods">'+getModDetails(details)+'</div>' : '';
|
||||
var randDetails = details ? getPortalRandDetails(details) : '';
|
||||
var miscDetails = details ? getPortalMiscDetails(guid,details) : '';
|
||||
var resoDetails = details ? getResonatorDetails(details) : '';
|
||||
|
||||
//TODO? other status details...
|
||||
@ -132,7 +135,7 @@ window.renderPortalDetails = function(guid) {
|
||||
),
|
||||
|
||||
modDetails,
|
||||
randDetails,
|
||||
miscDetails,
|
||||
resoDetails,
|
||||
statusDetails,
|
||||
'<div class="linkdetails">' + linkDetails.join('') + '</div>'
|
||||
@ -144,7 +147,7 @@ window.renderPortalDetails = function(guid) {
|
||||
|
||||
|
||||
|
||||
window.getRandPortalDetails = function(d) {
|
||||
window.getPortalMiscDetails = function(guid,d) {
|
||||
|
||||
var randDetails;
|
||||
|
||||
@ -160,7 +163,7 @@ window.getRandPortalDetails = function(d) {
|
||||
var linksText = [linkExpl('links'), linkExpl(' ↳ ' + links.incoming+' • '+links.outgoing+' ↴')];
|
||||
|
||||
var player = d.captured && d.captured.capturingPlayerId
|
||||
? '<span class="nickname">' + getPlayerName(d.captured.capturingPlayerId) + '</span>'
|
||||
? '<span class="nickname">' + d.captured.capturingPlayerId + '</span>'
|
||||
: null;
|
||||
var playerText = player ? ['owner', player] : null;
|
||||
|
||||
|
@ -102,7 +102,7 @@ window.getModDetails = function(d) {
|
||||
|
||||
modTooltip = modName + '\n';
|
||||
if (mod.installingUser) {
|
||||
modTooltip += 'Installed by: '+ getPlayerName(mod.installingUser) + '\n';
|
||||
modTooltip += 'Installed by: '+ mod.installingUser + '\n';
|
||||
}
|
||||
|
||||
if (mod.stats) {
|
||||
@ -176,7 +176,7 @@ window.getResonatorDetails = function(d) {
|
||||
|
||||
var l = parseInt(reso.level);
|
||||
var v = parseInt(reso.energyTotal);
|
||||
var nick = window.getPlayerName(reso.ownerGuid);
|
||||
var nick = reso.ownerGuid;
|
||||
var dist = reso.distanceToPortal;
|
||||
// if array order and slot order drift apart, at least the octant
|
||||
// naming will still be correct.
|
||||
|
Reference in New Issue
Block a user