diff --git a/app/lib/base.php b/app/lib/base.php
index fc90c132..df49ed60 100644
--- a/app/lib/base.php
+++ b/app/lib/base.php
@@ -1119,7 +1119,7 @@ final class Base extends Prefab implements ArrayAccess {
$time=microtime(TRUE);
header_remove('Pragma');
header('Cache-Control: max-age='.(int)$secs);
- header('Expires: '.gmdate('r',$time+(int)$secs));
+ header('Expires: '.gmdate('r',$time+$secs));
header('Last-Modified: '.gmdate('r'));
}
else {
diff --git a/app/main/controller/api/map.php b/app/main/controller/api/map.php
index 6ea2b14e..7c9de808 100644
--- a/app/main/controller/api/map.php
+++ b/app/main/controller/api/map.php
@@ -577,23 +577,17 @@ class Map extends Controller\AccessController {
* -> if characters with map access found -> broadcast mapData to them
* @param Model\MapModel $map
* @param array $characterIds
- * @return int
*/
protected function broadcastMapAccess($map, $characterIds){
- $connectionCount = 0;
-
$mapAccess = [
'id' => $map->_id,
'characterIds' => $characterIds
];
- $charCount = (int)(new Socket( Config::getSocketUri() ))->sendData('mapAccess', $mapAccess);
- if($charCount > 0){
- // map has active connections that should receive map Data
- $connectionCount = $this->broadcastMapData($map);
- }
+ (new Socket( Config::getSocketUri() ))->sendData('mapAccess', $mapAccess);
- return $connectionCount;
+ // map has (probably) active connections that should receive map Data
+ $this->broadcastMapData($map);
}
/**
diff --git a/app/main/model/mapmodel.php b/app/main/model/mapmodel.php
index 95ac1366..47b74660 100644
--- a/app/main/model/mapmodel.php
+++ b/app/main/model/mapmodel.php
@@ -20,6 +20,11 @@ class MapModel extends BasicModel {
*/
const DATA_CACHE_KEY_CHARACTER = 'CHARACTERS';
+ /**
+ * default TTL for getData(); cache
+ */
+ const DEFAULT_CACHE_TTL = 60;
+
protected $fieldConf = [
'active' => [
'type' => Schema::DT_BOOL,
@@ -205,7 +210,7 @@ class MapModel extends BasicModel {
// max caching time for a map
// the cached date has to be cleared manually on any change
// this includes system, connection,... changes (all dependencies)
- $this->updateCacheData($mapDataAll);
+ $this->updateCacheData($mapDataAll, '', self::DEFAULT_CACHE_TTL);
}
return $mapDataAll;
diff --git a/app/pathfinder.ini b/app/pathfinder.ini
index fe0b1280..9fc6e64d 100644
--- a/app/pathfinder.ini
+++ b/app/pathfinder.ini
@@ -60,7 +60,7 @@ LOGIN = templates/view/login.html
; - Whether user activity should be logged for a map type
; - E.g. create/update/delete of systems/connections/signatures
[PATHFINDER.MAP.PRIVATE]
-LIFETIME = 14
+LIFETIME = 30
MAX_COUNT = 3
MAX_SHARED = 10
MAX_SYSTEMS = 50
@@ -100,28 +100,28 @@ RALLY_SET =
; TIMER ===========================================================================================
[PATHFINDER.TIMER]
-; login time (minutes)
-LOGGED = 240
-; double click timer (ms)
+; login time (minutes) (default: 480)
+LOGGED = 480
+; double click timer (milliseconds) (default: 250)
DBL_CLICK = 250
-; time for status change visibility in header (ms)
+; time for status change visibility in header (milliseconds) (default: 5000)
PROGRAM_STATUS_VISIBLE = 5000
-; main map update ping (ajax) (ms)
+; main map update ping (ajax) (milliseconds)
[PATHFINDER.TIMER.UPDATE_SERVER_MAP]
DELAY = 5000
EXECUTION_LIMIT = 200
-; update client map data (ms)
+; update client map data (milliseconds)
[PATHFINDER.TIMER.UPDATE_CLIENT_MAP]
EXECUTION_LIMIT = 50
-; map user update ping (ajax) (ms)
+; map user update ping (ajax) (milliseconds)
[PATHFINDER.TIMER.UPDATE_SERVER_USER_DATA]
DELAY = 5000
EXECUTION_LIMIT = 500
-; update client user data (ms)
+; update client user data (milliseconds)
[PATHFINDER.TIMER.UPDATE_CLIENT_USER_DATA]
EXECUTION_LIMIT = 50
diff --git a/app/routes.ini b/app/routes.ini
index 067dc6f3..e139be66 100644
--- a/app/routes.ini
+++ b/app/routes.ini
@@ -12,6 +12,6 @@ GET @sso: /sso/@action [sync] = Controller\Ccp\Sso->
GET @map: /map [sync] = Controller\MapController->init
; ajax wildcard APIs (throttled)
-GET|POST /api/@controller/@action [ajax] = Controller\Api\@controller->@action, , 512
-GET|POST /api/@controller/@action/@arg1 [ajax] = Controller\Api\@controller->@action, , 512
-GET|POST /api/@controller/@action/@arg1/@arg2 [ajax] = Controller\Api\@controller->@action, , 512
+GET|POST /api/@controller/@action [ajax] = Controller\Api\@controller->@action, 0, 512
+GET|POST /api/@controller/@action/@arg1 [ajax] = Controller\Api\@controller->@action, 0, 512
+GET|POST /api/@controller/@action/@arg1/@arg2 [ajax] = Controller\Api\@controller->@action, 0, 512
diff --git a/js/app.js b/js/app.js
index 063467b8..df982a8e 100644
--- a/js/app.js
+++ b/js/app.js
@@ -21,7 +21,7 @@ requirejs.config({
mappage: './app/mappage', // initial start "map page" view
setup: './app/setup', // initial start "setup page" view
- jquery: 'lib/jquery-3.0.0.min', // v3.0.0 jQuery
+ jquery: 'lib/jquery-3.1.1.min', // v3.1.1 jQuery
bootstrap: 'lib/bootstrap.min', // v3.3.0 Bootstrap js code - http://getbootstrap.com/javascript
text: 'lib/requirejs/text', // v2.0.12 A RequireJS/AMD loader plugin for loading text resources.
mustache: 'lib/mustache.min', // v1.0.0 Javascript template engine - http://mustache.github.io
diff --git a/js/app/config/signature_type.js b/js/app/config/signature_type.js
index 97f2b056..90a9eb0d 100644
--- a/js/app/config/signature_type.js
+++ b/js/app/config/signature_type.js
@@ -15,7 +15,7 @@ define(['jquery'], function($) {
// NullSec Relic sites, which can also spawn in C1, C2, C3 wormholes
- var nullSecRelicSites = {
+ let nullSecRelicSites = {
10: 'Ruined Angel Crystal Quarry',
11: 'Ruined Angel Monument Site',
12: 'Ruined Angel Science Outpost',
@@ -39,7 +39,7 @@ define(['jquery'], function($) {
};
// NulSec Data sites, which can also spawn in C1, C2, C3 wormholes
- var nullSecDataSites = {
+ let nullSecDataSites = {
10: 'Abandoned Research Complex DA005',
11: 'Abandoned Research Complex DA015',
12: 'Abandoned Research Complex DC007',
@@ -70,7 +70,7 @@ define(['jquery'], function($) {
// signature types
- var signatureTypes = {
+ let signatureTypes = {
1: { // system type (wh)
1: { // C1 (area id)
1: { // Combat
diff --git a/js/app/config/system_effect.js b/js/app/config/system_effect.js
index b433d937..fe97afa2 100644
--- a/js/app/config/system_effect.js
+++ b/js/app/config/system_effect.js
@@ -9,7 +9,7 @@ define([], function() {
'use strict';
// system effects
- var systemEffects = {
+ let systemEffects = {
wh: {
magnetar: {
1: [
diff --git a/js/app/map/magnetizing.js b/js/app/map/magnetizing.js
index 618014a1..f83e8885 100644
--- a/js/app/map/magnetizing.js
+++ b/js/app/map/magnetizing.js
@@ -15,15 +15,15 @@ define([
* Cached current "Magnetizer" object
* @type {Magnetizer}
*/
- var m8 = null;
+ let m8 = null;
/**
* init a jsPlumb (map) Element for "magnetised" function.
* this is optional and prevents systems from being overlapped
*/
$.fn.initMagnetizer = function(){
- var mapContainer = this;
- var systems = mapContainer.getSystems();
+ let mapContainer = this;
+ let systems = mapContainer.getSystems();
/**
* helper function
@@ -32,10 +32,10 @@ define([
* @returns {{left, top}}
* @private
*/
- var _offset = function(system) {
+ let _offset = function(system) {
- var _ = function(p) {
- var v = system.style[p];
+ let _ = function(p) {
+ let v = system.style[p];
return parseInt(v.substring(0, v.length - 2));
};
@@ -52,8 +52,8 @@ define([
* @param o
* @private
*/
- var _setOffset = function(system, o) {
- var markAsUpdated = false;
+ let _setOffset = function(system, o) {
+ let markAsUpdated = false;
// new position must be within parent container
// no negative offset!
@@ -85,11 +85,11 @@ define([
* @returns {boolean}
* @private
*/
- var _dragFilter = function(id) {
+ let _dragFilter = function(id) {
return !$('#' + id).is('.jsPlumb_dragged, .pf-system-locked');
};
- var gridConstrain = function(gridX, gridY) {
+ let gridConstrain = function(gridX, gridY) {
return function(id, current, delta) {
if( mapContainer.hasClass(MapUtil.config.mapGridClass) ){
// active grid
@@ -126,7 +126,7 @@ define([
};
$.fn.destroyMagnetizer = function(){
- var mapContainer = this;
+ let mapContainer = this;
// remove cached "magnetizer" instance
m8 = null;
@@ -137,7 +137,7 @@ define([
* @param map
* @param e
*/
- var executeAtEvent = function(map, e){
+ let executeAtEvent = function(map, e){
if(m8 !== null && e ){
m8.executeAtEvent(e);
map.repaintEverything();
@@ -149,7 +149,7 @@ define([
* needs "magnetization" to be active
* @param map
*/
- var executeAtCenter = function(map){
+ let executeAtCenter = function(map){
if(m8 !== null){
m8.executeAtCenter();
map.repaintEverything();
@@ -161,10 +161,10 @@ define([
* -> (e.g. new systems was added)
* @param map
*/
- var setElements = function(map){
+ let setElements = function(map){
if(m8 !== null){
- var mapContainer = $(map.getContainer());
- var systems = mapContainer.getSystems();
+ let mapContainer = $(map.getContainer());
+ let systems = mapContainer.getSystems();
m8.setElements(systems);
// re-arrange systems
diff --git a/js/app/map/map.js b/js/app/map/map.js
index 5d04d420..b64e00f6 100644
--- a/js/app/map/map.js
+++ b/js/app/map/map.js
@@ -78,6 +78,10 @@ define([
// active connections per map (cache object)
let connectionCache = {};
+ // mapIds that receive updates while they are "locked" (active timer)
+ // -> those maps queue their updates until "pf:unlocked" event
+ let mapUpdateQueue = [];
+
// jsPlumb config
let globalMapConfig = {
source: {
@@ -456,17 +460,10 @@ define([
// check if system already exists
let system = document.getElementById( systemId );
-
- // just update data if system is new OR "updated" timestamp vary
- let updateSystemData = false;
-
- let updated = parseInt(data.updated.updated);
let newPosX = data.position.x + 'px';
let newPosY = data.position.y + 'px';
if(!system){
- updateSystemData = true;
-
// set system name or alias
let systemName = data.name;
@@ -534,87 +531,81 @@ define([
}else{
system = $(system);
- if( system.data('updated') !== updated){
- // system Data has changed
- updateSystemData = true;
+ // set system position
+ let currentPosX = system.css('left');
+ let currentPosY = system.css('top');
- // set system position
- let currentPosX = system.css('left');
- let currentPosY = system.css('top');
+ if(
+ newPosX !== currentPosX ||
+ newPosY !== currentPosY
+ ){
+ // change position with animation
+ system.velocity(
+ {
+ left: newPosX,
+ top: newPosY
+ },{
+ easing: 'linear',
+ duration: Init.animationSpeed.mapMoveSystem,
+ begin: function(system){
+ // hide system tooltip
+ $(system).toggleSystemTooltip('hide', {});
- if(
- newPosX !== currentPosX ||
- newPosY !== currentPosY
- ){
- // change position with animation
- system.velocity(
- {
- left: newPosX,
- top: newPosY
- },{
- easing: 'linear',
- duration: Init.animationSpeed.mapMoveSystem,
- begin: function(system){
- // hide system tooltip
- $(system).toggleSystemTooltip('hide', {});
+ // move them to the "top"
+ $(system).updateSystemZIndex();
+ },
+ progress: function(){
+ map.revalidate( systemId );
+ },
+ complete: function(system){
+ // show tooltip
+ $(system).toggleSystemTooltip('show', {show: true});
- // move them to the "top"
- $(system).updateSystemZIndex();
- },
- progress: function(){
- map.revalidate( systemId );
- },
- complete: function(system){
- // show tooltip
- $(system).toggleSystemTooltip('show', {show: true});
-
- map.revalidate( systemId );
- }
+ map.revalidate( systemId );
}
- );
- }
+ }
+ );
+ }
- // set system alias
- let alias = system.getSystemInfo(['alias']);
+ // set system alias
+ let alias = system.getSystemInfo(['alias']);
- if(alias !== data.alias){
- // alias changed
- system.find('.' + config.systemHeadNameClass).editable('setValue', data.alias);
- }
+ if(alias !== data.alias){
+ // alias changed
+ system.find('.' + config.systemHeadNameClass).editable('setValue', data.alias);
}
}
- if(updateSystemData){
- // set system status
- system.setSystemStatus(data.status.name);
- system.data('id', parseInt(data.id));
- system.data('systemId', parseInt(data.systemId));
- system.data('name', data.name);
- system.data('typeId', parseInt(data.type.id));
- system.data('effect', data.effect);
- system.data('security', data.security);
- system.data('trueSec', parseFloat(data.trueSec));
- system.data('regionId', parseInt(data.region.id));
- system.data('region', data.region.name);
- system.data('constellationId', parseInt(data.constellation.id));
- system.data('constellation', data.constellation.name);
- system.data('statics', data.statics);
- system.data('updated', parseInt(data.updated.updated));
- system.attr('data-mapid', parseInt(mapContainer.data('id')));
+ // set system status
+ system.setSystemStatus(data.status.name);
+ system.data('id', parseInt(data.id));
+ system.data('systemId', parseInt(data.systemId));
+ system.data('name', data.name);
+ system.data('typeId', parseInt(data.type.id));
+ system.data('effect', data.effect);
+ system.data('security', data.security);
+ system.data('trueSec', parseFloat(data.trueSec));
+ system.data('regionId', parseInt(data.region.id));
+ system.data('region', data.region.name);
+ system.data('constellationId', parseInt(data.constellation.id));
+ system.data('constellation', data.constellation.name);
+ system.data('statics', data.statics);
+ system.data('updated', parseInt(data.updated.updated));
+ system.data('changed', false);
+ system.attr('data-mapid', parseInt(mapContainer.data('id')));
- // locked system
- if( Boolean( system.data( 'locked') ) !== data.locked ){
- system.toggleLockSystem(false, {hideNotification: true, hideCounter: true, map: map});
- }
-
- // rally system
- system.setSystemRally(data.rallyUpdated, {
- poke: data.rallyPoke || false,
- hideNotification: true,
- hideCounter: true,
- });
+ // locked system
+ if( Boolean( system.data( 'locked') ) !== data.locked ){
+ system.toggleLockSystem(false, {hideNotification: true, hideCounter: true, map: map});
}
+ // rally system
+ system.setSystemRally(data.rallyUpdated, {
+ poke: data.rallyPoke || false,
+ hideNotification: true,
+ hideCounter: true,
+ });
+
return system;
};
@@ -891,51 +882,58 @@ define([
connection.setParameter('created', newConnectionData.created);
connection.setParameter('updated', newConnectionData.updated);
connection.setParameter('eolUpdated', newConnectionData.eolUpdated);
+ connection.setParameter('changed', false);
return connection;
};
/**
- * draw a new map or update an existing map with all its systems and connections
+ * get a mapMapElement
* @param parentElement
* @param mapConfig
* @returns {*}
*/
- let updateMap = function(parentElement, mapConfig){
+ let newMapElement = (parentElement, mapConfig) => {
+ let mapId = mapConfig.config.id;
+ // create map wrapper
+ let mapWrapper = $('
', {
+ class: config.mapWrapperClass
+ });
+
+ // create new map container
+ let mapContainer = $('
', {
+ id: config.mapIdPrefix + mapId,
+ class: [config.mapClass].join(' ')
+ });
+
+ // add additional information
+ mapContainer.data('id', mapId);
+
+ mapWrapper.append(mapContainer);
+
+ // append mapWrapper to parent element (at the top)
+ $(parentElement).prepend(mapWrapper);
+
+ // set main Container for current map -> the container exists now in DOM !! very important
+ mapConfig.map.setContainer( config.mapIdPrefix + mapId );
+
+ // set map observer
+ setMapObserver(mapConfig.map);
+
+ return mapConfig;
+ };
+
+ /**
+ * draw a new map or update an existing map with all its systems and connections
+ * @param mapConfig
+ * @returns {*}
+ */
+ let updateMap = function(mapConfig){
let mapContainer = mapConfig.map.getContainer();
-
+ let mapId = mapConfig.config.id;
let newSystems = 0;
- if(mapContainer === undefined){
- // add new map
-
- // create map wrapper
- let mapWrapper = $('