From 2c688e2aa8ade2d70a5a5901283b928bafbfec63 Mon Sep 17 00:00:00 2001 From: exodus4d Date: Sat, 25 Apr 2015 17:43:42 +0200 Subject: [PATCH] IGB Header support implemented --- .idea/dictionaries/exodus4d.xml | 1 + app/config.cfg | 2 +- app/main/controller/AccessController.php | 1 + app/main/controller/Controller.php | 39 ++ app/main/controller/MapController.php | 7 +- app/main/controller/api/Map.php | 3 + app/main/model/CharacterLogModel.php | 3 +- app/main/model/CharacterModel.php | 22 +- app/main/model/MapModel.php | 1 - app/main/model/UserCharacterModel.php | 5 +- app/main/model/UserModel.php | 36 ++ js/app/ccp.js | 39 +- js/app/init.js | 3 +- js/app/logging.js | 13 - js/app/main.js | 692 +--------------------- js/app/map/map.js | 5 +- js/app/module_map.js | 2 - js/app/page.js | 142 ++++- js/app/ui/dialog/map_info.js | 12 +- js/app/ui/dialog/shutdown.js | 93 +++ js/app/ui/dialog/trust.js | 138 +++++ js/app/ui/form_element.js | 2 +- js/app/ui/system_info.js | 40 +- js/app/ui/system_killboard.js | 321 ++++++++-- js/app/ui/system_route.js | 69 +-- js/app/util.js | 104 +--- public/css/pathfinder.css | 4 +- public/img/icons/zkillboard_logo.png | Bin 3085 -> 0 bytes public/templates/dialog/shutdown.html | 10 + public/templates/dialog/trust.html | 20 + public/templates/modules/header.html | 6 +- public/templates/modules/system_info.html | 31 +- public/templates/view/map.html | 9 +- sass/bootstrap/_badges.scss | 3 +- sass/layout/_dialogs.scss | 11 - sass/layout/_images.scss | 10 +- sass/layout/_main.scss | 40 +- sass/layout/_system-info.scss | 88 ++- 38 files changed, 1046 insertions(+), 981 deletions(-) create mode 100644 js/app/ui/dialog/shutdown.js create mode 100644 js/app/ui/dialog/trust.js delete mode 100644 public/img/icons/zkillboard_logo.png create mode 100644 public/templates/dialog/shutdown.html create mode 100644 public/templates/dialog/trust.html diff --git a/.idea/dictionaries/exodus4d.xml b/.idea/dictionaries/exodus4d.xml index 64b0780f..0a252852 100644 --- a/.idea/dictionaries/exodus4d.xml +++ b/.idea/dictionaries/exodus4d.xml @@ -19,6 +19,7 @@ killboard killmail malihu + minify mouseover nonblock onerror diff --git a/app/config.cfg b/app/config.cfg index 61fb4803..cfd22e0d 100644 --- a/app/config.cfg +++ b/app/config.cfg @@ -1,7 +1,7 @@ [globals] ; Verbosity level of the stack trace. Assign values between 0 to 3 for increasing verbosity levels -DEBUG = 1 +DEBUG = 3 ; If TRUE, the framework, after having logged stack trace and errors, stops execution (die without any status) when a non-fatal error is detected. HALT = FALSE diff --git a/app/main/controller/AccessController.php b/app/main/controller/AccessController.php index f9a6e617..be45f1aa 100644 --- a/app/main/controller/AccessController.php +++ b/app/main/controller/AccessController.php @@ -170,4 +170,5 @@ class AccessController extends Controller { return $user; } + } \ No newline at end of file diff --git a/app/main/controller/Controller.php b/app/main/controller/Controller.php index d66f2168..19353ab8 100644 --- a/app/main/controller/Controller.php +++ b/app/main/controller/Controller.php @@ -85,5 +85,44 @@ class Controller { $this->setTemplate('templates/view/login.html'); } + /** + * check weather the page is IGB trusted or not + * @return mixed + */ + static function isIGBTrusted(){ + + $igbHeaderData = self::getIGBHeaderData(); + + return $igbHeaderData->trusted; + } + + /** + * extract all eve IGB specific header data + * @return object + */ + static function getIGBHeaderData(){ + $data = (object) []; + $data->trusted = false; + $data->values = []; + $headerData = apache_request_headers(); + + foreach($headerData as $key => $value){ + if (strpos($key, 'EVE_') === 0) { + $key = str_replace('EVE_', '', $key); + $key = strtolower($key); + + if ( + $key === 'trusted' && + $value === 'Yes' + ) { + $data->trusted = true; + } + + $data->values[$key] = $value; + } + } + + return $data; + } } \ No newline at end of file diff --git a/app/main/controller/MapController.php b/app/main/controller/MapController.php index ac90f0b2..27e5a864 100644 --- a/app/main/controller/MapController.php +++ b/app/main/controller/MapController.php @@ -8,7 +8,7 @@ namespace Controller; -class MapController extends Controller { +class MapController extends \Controller\AccessController { function __construct() { parent::__construct(); @@ -16,8 +16,11 @@ class MapController extends Controller { public function showMap() { - $this->setTemplate('templates/view/map.html'); + // set trust attribute to template + $this->f3->set('trusted', (int)self::isIGBTrusted()); + + $this->setTemplate('templates/view/map.html'); } /** diff --git a/app/main/controller/api/Map.php b/app/main/controller/api/Map.php index b706f73a..3681fed2 100644 --- a/app/main/controller/api/Map.php +++ b/app/main/controller/api/Map.php @@ -305,6 +305,9 @@ class Map extends \Controller\AccessController { // check if data for specific system is requested $systemData = (array)$f3->get('POST.systemData'); + // update current location (IGB data) + $user->updateCharacterLog(); + $userData = (object) []; // data for the current user $userData->userData = $user->getData(); diff --git a/app/main/model/CharacterLogModel.php b/app/main/model/CharacterLogModel.php index 5e8d52e5..2691434c 100644 --- a/app/main/model/CharacterLogModel.php +++ b/app/main/model/CharacterLogModel.php @@ -36,8 +36,9 @@ class CharacterLogModel extends BasicModel { $logData->system->name = $this->systemName; $logData->ship = (object) []; - $logData->ship->Id = $this->shipId; + $logData->ship->id = $this->shipId; $logData->ship->name = $this->shipName; + $logData->ship->typeName = $this->shipTypeName; return $logData; } diff --git a/app/main/model/CharacterModel.php b/app/main/model/CharacterModel.php index 93c369ad..cbf8503a 100644 --- a/app/main/model/CharacterModel.php +++ b/app/main/model/CharacterModel.php @@ -16,11 +16,7 @@ class CharacterModel extends BasicModel { protected $rel_ttl = 0; protected $fieldConf = array( - /* wirft fehler - 'characterId' => array( - 'has-one' => array('Model\CharacterLogModel', 'characterId') - ) - */ + ); /** @@ -50,4 +46,20 @@ class CharacterModel extends BasicModel { return $characterData; } + /** + * get the character log entry for this character + * @return bool|null + */ + public function getLog(){ + $characterLog = self::getNew('CharacterLogModel'); + $characterLog->getByForeignKey('characterId', $this->characterId); + + $characterLogReturn = false; + if(! $characterLog->dry() ){ + $characterLogReturn = $characterLog; + } + + return $characterLogReturn; + } + } \ No newline at end of file diff --git a/app/main/model/MapModel.php b/app/main/model/MapModel.php index deeaf59e..dd9fc81b 100644 --- a/app/main/model/MapModel.php +++ b/app/main/model/MapModel.php @@ -341,7 +341,6 @@ class MapModel extends BasicModel{ if(count($systemUserData->user) > 0){ $mapUserData->data->systems[] = $systemUserData; } - } return $mapUserData; diff --git a/app/main/model/UserCharacterModel.php b/app/main/model/UserCharacterModel.php index 37222ee7..c05cf16d 100644 --- a/app/main/model/UserCharacterModel.php +++ b/app/main/model/UserCharacterModel.php @@ -119,9 +119,10 @@ class UserCharacterModel extends BasicModel { * @return bool|mixed */ public function getLog(){ - $this->filter('log', array('active = ?', 1)); + //$this->filter('log', array('active = ?', 1)); - $characterLog = false; + + $characterLog = $this->characterId->getLog(); if($this->log){ $characterLog = $this->log; } diff --git a/app/main/model/UserModel.php b/app/main/model/UserModel.php index 30ee0a64..04ed1773 100644 --- a/app/main/model/UserModel.php +++ b/app/main/model/UserModel.php @@ -7,6 +7,7 @@ */ namespace Model; +use Controller; class UserModel extends BasicModel { @@ -259,5 +260,40 @@ class UserModel extends BasicModel { return $activeUserCharacters; } + /** + * updated the character log entry for a user character by IGB Header data + */ + public function updateCharacterLog(){ + $apiController = Controller\CcpApiController::getIGBHeaderData(); + + // check if IGB Data is available + if(! empty($apiController->values)){ + $userCharacters = $this->getUserCharacters(); + + foreach($userCharacters as $userCharacter){ + if( $userCharacter->characterId->characterId == $apiController->values['charid']){ + + // check for existing character log entry + $characterLog = self::getNew('CharacterLogModel'); + $characterLog->getByForeignKey('characterId', $apiController->values['charid']); + + $characterLog->characterId = $apiController->values['charid']; + $characterLog->systemId = $apiController->values['solarsystemid']; + $characterLog->systemName = $apiController->values['solarsystemname']; + $characterLog->shipId = $apiController->values['shiptypeid']; + $characterLog->shipName = $apiController->values['shipname']; + $characterLog->shipTypeName = $apiController->values['shiptypename']; + + $characterLog->save(); + break; + } + + } + } + + + + } + } \ No newline at end of file diff --git a/js/app/ccp.js b/js/app/ccp.js index 220d6c64..a6c0ae95 100644 --- a/js/app/ccp.js +++ b/js/app/ccp.js @@ -4,7 +4,40 @@ define(['jquery'], function($) { - "use strict"; + 'use strict'; + + /** + * checks weather the program URL is IGB trusted or not + * @returns {boolean} + */ + var isTrusted = function(){ + var isPageTrusted = false; + + if(isInGameBrowser()){ + var trustedAttribute = $('body').attr('data-trusted'); + if(trustedAttribute === '1'){ + isPageTrusted = true; + } + }else{ + // out of game browser is always trusted + isPageTrusted = true; + } + + return isPageTrusted; + }; + + /** + * show IGB trust message + */ + var requestTrust = function(){ + + if( + isInGameBrowser() && + ! isTrusted() + ){ + CCPEVE.requestTrust( location.protocol + '//' + location.host ); + } + }; /** * in-game or out-of-game browser @@ -20,6 +53,8 @@ define(['jquery'], function($) { }; return { - isInGameBrowser: isInGameBrowser + isInGameBrowser: isInGameBrowser, + isTrusted: isTrusted, + requestTrust: requestTrust }; }); \ No newline at end of file diff --git a/js/app/init.js b/js/app/init.js index 228f7ec6..605267b2 100644 --- a/js/app/init.js +++ b/js/app/init.js @@ -52,7 +52,8 @@ define(['jquery'], function($) { headerLink: 100, // links in head bar mapMoveSystem: 300, // system position has changed animation mapDeleteSystem: 200, // remove system from map - mapModule: 200 // show/hide of an map module + mapModule: 200, // show/hide of an map module + dialogEvents: 180 // dialog events /slide/show/... }, classes: { // log types diff --git a/js/app/logging.js b/js/app/logging.js index 6303d1a1..f5621502 100644 --- a/js/app/logging.js +++ b/js/app/logging.js @@ -410,7 +410,6 @@ define([ */ var init = function(){ - var maxEntries = 150; // set global logging listener @@ -425,24 +424,13 @@ define([ var logDescription = options.description; var logDuration = options.duration; - // add new row to log table (time and message) - // var logRowData = ['', getLogTime(), '', logDescription, '', '']; - // check log type by duration var logType = getLogTypeByDuration(logKey, logDuration); var typeClass = Util.getLogInfo( logType, 'class' ); -/* - logRowData[0] = ''; - logRowData[2] = '' + logDuration + 'ms'; -*/ // update graph data updateLogGraph(logKey, logDuration); -/* - logRowData[4] = '123'; - logRowData[5] = logKey; -*/ var logRowData = { type: '', @@ -463,7 +451,6 @@ define([ } } - // delete old log entries from table --------------------------------- var rowCount = logData.length; diff --git a/js/app/main.js b/js/app/main.js index ff15921f..6a47684e 100644 --- a/js/app/main.js +++ b/js/app/main.js @@ -23,686 +23,27 @@ define([ }; - $(function() { - //CCP.requestTrust(); + $(function(){ + // load page + $('body').loadPageStructure(); // init logging Logging.init(); - // load page - $('body').loadPageStructure(); - - // Map init options - var mapData = []; - - - - // TEST ============================================= - - - /* - * Lazy Line Painter - Path Object - * Generated using 'SVG to Lazy Line Converter' - * - * http://lazylinepainter.info - * Copyright 2013, Cam O'Connell - * - */ -/* - var pathObj = { - "test-line": { - "strokepath": [ - { - "path": "M 393.7 195.2 442.6 649.1 643.6 756.3 394.1 195.6", - "strokeColor": '#477372', - "duration": 800 - }, - { - "path": "M 87.1 750.5 201.1 629.8 366.3 632.7 87.9 750.6", - "strokeColor": '#4f9e4f', - "duration": 800 - }, - { - "path": "M 389 632.7 275.8 683.1 614.2 753.9 389.7 632.7", - "strokeColor": '#375959', - "duration": 800 - }, - { - "path": "M 404.5 404 84.7 736.7 383 181.2 404.5 403.1", - "strokeColor": '#63676a', - "duration": 800 - } - ], - "dimensions": { - "width": 745, - "height": 1053 - } - } - }; - - - - $(document).ready(function(){ - $('#test-line').lazylinepainter( - { - "svgData": pathObj, - "strokeWidth": 2, - "drawSequential": false - }).lazylinepainter('paint'); - }); -*/ - - /* - var mapData =[{ - map: {}, - config: { - id: 99, - name: 'Polaris', - scope: { - id: 1, - name: 'wh', - label: 'w-space' - }, - icon: 'fa-globe', - type: { - id: 1, - name: 'alliance', - label: 'Alliance' - }, - updated: 1424545904 - }, - data: { - systems: [ - { - id: 2, - systemId: 31002378, - name: 'J150020', - alias: 'Polaris', - effect: 'magnetar', - type: { - id: 1, - name: 'wh' - }, - security: 'C6', - trueSec: -1, - region: { - id: '11000030', - name: 'F-R00030' - }, - constellation: { - id: '21000298', - name: 'F-C00298' - }, - status: { - id: 2, - name: 'friendly' - }, - locked: 1, - rally: 0, - position: { - x: 8, - y: 300 - }, - updated: 1420903681 - },{ - id: 3, - systemId: 31002375, - name: 'J115844', - alias: '', - effect: 'wolfRyet', - type: { - id: 1, - name: 'wh' - }, - security: 'C6', - trueSec: -1, - region: { - id: '11000030', - name: 'F-R00030' - }, - constellation: { - id: '21000298', - name: 'F-C00298' - }, - status: { - id: 5, - name: 'empty' - }, - position: { - x: 25, - y: 40 - }, - updated: 1420903681 - - },{ - id: 4, - systemId: 31002402, - name: 'J155207', - alias: '', - effect: 'wolfRyet', - type: { - id: 1, - name: 'wh' - }, - security: 'C6', - trueSec: -1, - region: { - id: '11000030', - name: 'F-R00030' - }, - constellation: { - id: '21000301', - name: 'F-C00301' - }, - status: { - id: 1, - name: 'unknown' - }, - locked: '1', - rally: '1', - position: { - x: 203, - y: 60 - }, - updated: 1420903681 - },{ - id: 5, - systemId: 31002416, - name: 'J145510', - alias: '', - effect: 'pulsar', - security: 'C3', - trueSec: -1, - region: { - id: '11000030', - name: 'F-R00030' - }, - constellation: { - id: '21000303', - name: 'F-C00303' - }, - type: { - id: 1, - name: 'wh' - }, - status: { - id: 4, - name: 'hostile' - }, - position: { - x: 40, - y: 160 - }, - updated: 1420903681 - },{ - id: 542, - systemId: 30002979, - name: 'Tararan', - alias: '', - effect: '', - security: 'L', - trueSec: 0.3, - region: { - id: 10000036, - name: 'Devoid' - }, - constellation: { - id: 20000436, - name: 'Jayai' - }, - type: { - id: 2, - name: 'k-space' - }, - status: { - id: 1, - name: 'unknown' - }, - position: { - x: 280, - y: 250 - }, - updated: 1420903681 - },{ - id: 429, - systemId: 30000142, - name: 'Jita', - alias: '', - effect: '', - security: 'H', - trueSec: 0.9, - region: { - id: 10000002, - name: 'The Forge' - }, - constellation: { - id: 20000020, - name: 'Kimotoro' - }, - type: { - id: 2, - name: 'k-space' - }, - status: { - id: 1, - name: 'unknown' - }, - position: { - x: 400, - y: 150 - }, - updated: 1420903681 - },{ - id: 876, - systemId: 31000152, - name: 'J121418', - alias: '', - effect: '', - security: 'C1', - trueSec: -1, - region: { - id: 11000002, - name: 'A-R00002' - }, - constellation: { - id: 21000002, - name: 'A-C00002' - }, - type: { - id: 1, - name: 'wh' - }, - status: { - id: 3, - name: 'occupied' - }, - position: { - x: 600, - y: 75 - }, - updated: 1420903681 - },{ - id: 755, - systemId: 30000144, - name: 'Perimeter', - alias: '', - effect: '', - security: 'H', - trueSec: 0.9, - region: { - id: 10000002, - name: 'The Forge' - }, - constellation: { - id: '20000020', - name: 'Kimotoro' - }, - type: { - id: 2, - name: 'k-space' - }, - status: { - id: 6, - name: 'unscanned' - }, - position: { - x: 550, - y: 200 - }, - updated: 1420903681 - },{ - id: 8555, - systemId: 30001028, - name: 'RMOC-W', - alias: '', - effect: '', - security: '0.0', - trueSec: -0.1, - region: { - id: 10000012, - name: 'Curse' - }, - constellation: { - id: '20000150', - name: 'Sound' - }, - type: { - id: 2, - name: 'k-space' - }, - status: { - id: 1, - name: 'unknown' - }, - position: { - x: 500, - y: 300 - }, - updated: 1420903681 - } - - ], - connections: [ - { - id: 2, - source: 2, - target: 5, - scope: 'wh', - type: [ - 'wh_reduced' - ], - updated: 1420903681 - },{ - id: 3, - source: 5, - target: 4, - scope: 'wh', - type: [ - 'wh_fresh', - 'frigate' - ], - updated: 1420903681 - },{ - id: 5, - source: 3, - target: 4, - scope: 'wh', - type: [ - 'wh_critical' - ], - updated: 1420903681 - }, - { - id: 77, - source: 4, - target: 542, - scope: 'wh', - type: [ - 'wh_critical' - ], - updated: 1420903681 - }, - { - id: 95, - source: 4, - target: 429, - scope: 'wh', - type: [ - 'wh_eol', - 'wh_reduced', - 'preserve_mass' - ], - updated: 1420903681 - }, - { - id: 96, - source: 429, - target: 755, - scope: 'wh', - type: [ - 'wh_fresh' - ], - updated: 1420903681 - }, - { - id: 97, - source: 429, - target: 876, - scope: 'stargate', - type: [ - 'stargate' - ], - updated: 1420903681 - }, - { - id: 98, - source: 542, - target: 8555, - scope: 'jumpbridge', - type: [ - 'jumpbridge' - ], - updated: 1420903681 - } - ] - } - }, - { - map: {}, - config: { - name: 'Providence', - id: 2, - scope: { - id: 1, - name: 'wh', - label: 'w-space' - }, - icon: 'fa-bookmark', - type: { - id: 3, - name: 'global', - label: 'global' - }, - updated: 1424545903 - }, - data: { - systems: [ - { - id: 755, - systemId: 30000144, - name: 'Perimeter', - alias: '', - effect: '', - security: 'H', - trueSec: 0.9, - region: { - id: 10000002, - name: 'The Forge' - }, - constellation: { - id: '20000020', - name: 'Kimotoro' - }, - type: { - id: 2, - name: 'k-space' - }, - status: { - id: 6, - name: 'unscanned' - }, - position: { - x: 550, - y: 200 - }, - updated: 1420903681 - },{ - id: 8555, - systemId: 30001028, - name: 'RMOC-W', - alias: '', - effect: '', - security: '0.0', - trueSec: -0.1, - region: { - id: 10000012, - name: 'Curse' - }, - constellation: { - id: '20000150', - name: 'Sound' - }, - type: { - id: 2, - name: 'k-space' - }, - status: { - id: 1, - name: 'unknown' - }, - position: { - x: 500, - y: 300 - }, - updated: 1420903681 - } - ], - connections: [{ - id: 23, - source: 755, - target: 8555, - type: [ - 'wh_fresh' - ], - updated: 1420903681 - }] - } - }, - { - map: {}, - config: { - name: 'Exodus 4D', - id: 3, - scope: { - id: 1, - name: 'wh', - label: 'w-space' - }, - icon: 'fa-sitemap', - type: { - id: 2, - name: 'private', - label: 'private' - }, - updated: 1424545903 - }, - data: { - systems: [], - connections: [] - } - }]; -*/ -/* - // current user Data for a map - var tempUserData ={ - userData: { - id: 1262, - character: [{ - id: 12, - characterId: 90581222, - characterName: 'Exodus 3D Gidrine', - corporationId: 423229765, - corporationName: 'eXceed Inc.', - allianceId: 99000210, - allianceName: 'No Holes Barred', - isMain: 0 - },{ - id: 9, - characterId: 91301110, - characterName: 'Exodus 2D Gidrine', - isMain: 1 - },{ - id: 10, - characterId: 94940499, - characterName: 'Exodus 8D Gidrine', - isMain: 0 - },{ - id: 11, - characterId: 1946320202, - characterName: 'Exodus 4D', - isMain: 0 - }], - ship: 'Legion', - name: 'Exodus 4D', - system: { - name: 'J115844', - id: 4 - } - }, - mapUserData: [ // user Data for all maps - { - config: { // map config - id: 99 // map id - }, - data: { - systems:[ // systems in map - { - id: 4, // system id - user: [ - { - id: 3, - name: 'Exodus 4D', - ship: { - id: 55, - name: 'Legion' - }, - status: 'corp' - } - ] - }, - { - id: 5, // system id - user: [ - { - id: 4, - name: 'Faye Fantastic', - ship: { - id: 56, - name: 'Armageddon' - }, - status: 'ally' - },{ - id: 5, - name: 'Sibasomos', - ship: { - id: 57, - name: 'Proteus' - }, - status: 'corp' - },{ - id: 6, - name: 'Xtrah', - ship: { - id: 58, - name: 'Pod' - }, - status: 'ally' - } - ] - } - ] - } - },{ - config: { // map config - id: 128 // map id - }, - data: { - systems:[ // systems in map - { - id: 8597, // system id - user: [ - { - id: 6, - name: 'Exodus 6D Gidrine', - ship: { - id: 69, - name: 'Tengu' - }, - status: 'corp' - } - ] - } - ] - } - } - ]}; -*/ - // update map module ======================================== + // page initialized event ============================================================== $('#' + config.mapModuleId).on('pf:initModule', function(){ + if(! CCP.isTrusted()){ + // show trust message + $(document).trigger('pf:showTrustDialog'); + return; + } + + + var mapModule = $(this); - // map init load static data ================================== + // map init load static data ======================================================= $.getJSON( Init.path.initMap, function( initData ) { Init.mapTypes = initData.mapTypes; @@ -717,7 +58,8 @@ define([ }).fail(function( jqXHR, status, error) { var reason = status + ' ' + jqXHR.status + ': ' + error; - Util.emergencyShutdown(reason); + + $(document).trigger('pf:shutdown', {reason: reason}); }); }); @@ -791,7 +133,7 @@ define([ }).fail(function( jqXHR, status, error) { var reason = status + ' ' + jqXHR.status + ': ' + error; - Util.emergencyShutdown(reason); + $(document).trigger('pf:shutdown', {reason: reason}); }); }; @@ -843,7 +185,7 @@ define([ }).fail(function( jqXHR, status, error) { var reason = status + ' ' + jqXHR.status + ': ' + error; - Util.emergencyShutdown(reason); + $(document).trigger('pf:shutdown', {reason: reason}); }); }; diff --git a/js/app/map/map.js b/js/app/map/map.js index 864ca5c5..b1313483 100644 --- a/js/app/map/map.js +++ b/js/app/map/map.js @@ -163,12 +163,13 @@ define([ data && data.user ){ + var cacheArray = []; // loop all active pilots and build cache-key for(var i = 0; i < data.user.length; i++){ userCounter++; var tempUserData = data.user[i]; - cacheArray.push(tempUserData.id + '_' + tempUserData.log.ship.name); + cacheArray.push(tempUserData.id + '_' + tempUserData.log.ship.typeName); } var cacheKey = cacheArray.join('_'); @@ -192,7 +193,7 @@ define([ class: config.systemBodyItemClass }).append( $('', { - text: userData.log.ship.name, + text: userData.log.ship.typeName, class: config.systemBodyRightClass }) ).append( diff --git a/js/app/module_map.js b/js/app/module_map.js index 6768e457..33b16fee 100644 --- a/js/app/module_map.js +++ b/js/app/module_map.js @@ -191,8 +191,6 @@ define([ }); } } - - }); }; diff --git a/js/app/page.js b/js/app/page.js index 0f1507ed..578af705 100644 --- a/js/app/page.js +++ b/js/app/page.js @@ -9,6 +9,8 @@ define([ 'app/render', 'app/ccp', 'app/logging', + 'dialog/shutdown', + 'dialog/trust', 'dialog/map_info', 'dialog/settings', 'dialog/manual', @@ -42,6 +44,9 @@ define([ headMapClass: 'pf-head-map', // class for page head map button (right) headUserCharacterClass: 'pf-head-user-character', // class for "user settings" link userCharacterImageClass: 'pf-head-user-character-image', // class for "current user image" + + headUserShipClass: 'pf-head-user-ship', // class for "user settings" link + userShipImageClass: 'pf-head-user-ship-image', // class for "current user ship image" headActiveUserClass: 'pf-head-active-user', // class for "active user" link headCurrentLocationClass: 'pf-head-current-location', // class for "show current location" link headProgramStatusClass: 'pf-head-program-status', // class for "program status" notification @@ -193,7 +198,9 @@ define([ $('',{ class: 'fa fa-power-off fa-fw' }) - ) + ).on('click', function(){ + $(document).triggerMenuEvent('Logout'); + }) ) ); @@ -356,7 +363,9 @@ define([ id: config.pageHeaderId, brandLogo: config.menuHeadMenuLogoClass, userCharacterClass: config.headUserCharacterClass, - userCharacterImageClass: config.userCharacterImageClass + userCharacterImageClass: config.userCharacterImageClass, + userShipClass: config.headUserShipClass, + userShipImageClass: config.userShipImageClass }; Render.showModule(moduleConfig, moduleData); @@ -509,6 +518,15 @@ define([ return false; }); + $(document).on('pf:menuLogout', function(e, data){ + // logout + console.log('! LOGOUT !'); + return false; + }); + + // END menu events ============================================================================= + + // update header links with current map data $(document).on('pf:updateHeaderMapData', function(e, data){ var activeMap = Util.getMapModule().getActiveMap(); @@ -527,6 +545,32 @@ define([ updateHeaderActiveUserCount(userCount); updateHeaderCurrentLocation(currentLocationData); }); + + $(document).on('pf:showTrustDialog', function(e){ + // show trust dialog + $.fn.showTrustDialog(); + return false; + }); + + $(document).on('pf:shutdown', function(e, data){ + // show shutdown dialog + $.fn.showShutdownDialog(data); + + $(document).setProgramStatus('offline'); + + Util.showNotify({title: 'Emergency shutdown', text: data.reason, type: 'error'}, false); + + // remove map + Util.getMapModule().velocity('fadeOut', { + duration: 300, + complete: function(){ + $(this).remove(); + } + }); + + return false; + }); + }; /** @@ -536,33 +580,99 @@ define([ var userData = Util.getCurrentUserData(); - if( - userData && - userData.character - ){ + var userInfoElement = $('.' + config.headUserCharacterClass); + var currentCharacterId = userInfoElement.data('characterId'); + var newCharacterId = 0; + var newCharacterName = ''; - var userInfoElement = $('.' + config.headUserCharacterClass); + var userShipElement = $('.' + config.headUserShipClass); + var currentShipId = userShipElement.data('shipId'); + var newShipId = 0; + var newShipName = ''; - // hide element - userInfoElement.velocity('stop').velocity({ - opacity: 0 - },{ + // function for header element toggle animation + var animateHeaderElement = function(element, callback, triggerShow){ + + element.show().velocity('stop').velocity({ + opacity: 0 + },{ visibility : 'hidden', duration: 500, - complete: function(){ - // set new data - userInfoElement.find('span').text(userData.character.name); - userInfoElement.find('img').attr('src', Init.url.ccpImageServer + '/Character/' + userData.character.characterId + '_32.jpg' ); + complete: function(){ - userInfoElement.velocity({ + // callback + callback(); + + // show element + if(triggerShow === true){ + element.velocity({ opacity: 1 }, { visibility : 'visible', duration: 500 }); + }else{ + // hide element + element.hide(); } + + } }); + + }; + + // check for changees + if( + userData && + userData.character + ){ + newCharacterId = userData.character.characterId; + newCharacterName = userData.character.name; + + if(userData.character.log){ + newShipId = userData.character.log.ship.id; + newShipName = userData.character.log.ship.typeName; + } } + + // update user character data --------------------------------------------------- + if(currentCharacterId !== newCharacterId){ + + var showCharacterElement = true; + if(newCharacterId === 0){ + showCharacterElement = false; + } + + // toggle element + animateHeaderElement(userInfoElement, function(){ + userInfoElement.find('span').text( newCharacterName ); + userInfoElement.find('img').attr('src', Init.url.ccpImageServer + 'Character/' + newCharacterId + '_32.jpg' ); + }, showCharacterElement); + + // set new id for next check + userInfoElement.data('characterId', newCharacterId); + } + + // update user ship data -------------------------------------------------------- + if(currentShipId !== newShipId){ console.log('update ship '); + + var showShipElement = true; + if(newShipId === 0){ + showShipElement = false; + } + + // toggle element + animateHeaderElement(userShipElement, function(){ + userShipElement.find('span').text( newShipName ); + userShipElement.find('img').attr('src', Init.url.ccpImageServer + 'Render/' + newShipId + '_32.png' ); + }, showShipElement); + + // set new id for next check + userShipElement.data('shipId', newShipId); + } + + + }; /** diff --git a/js/app/ui/dialog/map_info.js b/js/app/ui/dialog/map_info.js index a9c4bef2..1689a91c 100644 --- a/js/app/ui/dialog/map_info.js +++ b/js/app/ui/dialog/map_info.js @@ -144,13 +144,6 @@ define([ // name tempData.push( tempSystemData.name ); - // alias - if( tempSystemData.name !== tempSystemData.alias){ - tempData.push( tempSystemData.alias ); - }else{ - tempData.push( '' ); - } - // status var systemStatusClass = Util.getStatusInfoForSystem(tempSystemData.status.id, 'class'); if(systemStatusClass !== ''){ @@ -219,10 +212,7 @@ define([ title: 'type', width: '50px' },{ - title: 'system', - width: '50px' - },{ - title: 'alias' + title: 'system' },{ title: 'status', width: '30px', diff --git a/js/app/ui/dialog/shutdown.js b/js/app/ui/dialog/shutdown.js new file mode 100644 index 00000000..03fcbba9 --- /dev/null +++ b/js/app/ui/dialog/shutdown.js @@ -0,0 +1,93 @@ +/** + * error/shutdown dialog + */ + +define([ + 'jquery', + 'app/init', + 'app/util', + 'app/render', + 'bootbox', +], function($, Init, Util, Render, bootbox) { + 'use strict'; + + var config = { + + // shutdown dialog + shutdownDialogId: 'pf-shutdown-dialog' // id for "trust" dialog + + }; + + /** + * show/animate dialog page content + * @param pageElement + */ + var showPageContent = function(dialog){ + + dialog.find('h1').delay(300).velocity('transition.shrinkIn', { + duration: 500 + }).delay(800) + + dialog.find('h1').velocity({ + scale: 1.05 + }, { + duration: 600, + loop: 5 + }); + }; + + /** + * show "shutdown" dialog + */ + $.fn.showShutdownDialog = function(dialogData){ + + requirejs(['text!templates/dialog/shutdown.html', 'mustache'], function(template, Mustache) { + + var data = { + id: config.shutdownDialogId, + reason: dialogData.reason + }; + + var content = Mustache.render(template, data); + + // show dialog + var shutdownDialog = bootbox.dialog({ + title: 'Shutdown', + message: content, + buttons: { + logout: { + label: ' logout', + className: ['btn-default', 'pull-left'].join(' '), + callback: function() { + + $(document).trigger('pf:menuLogout'); + } + }, + refresh: { + label: ' reload', + className: ['btn-danger'].join(' '), + callback: function(){ + // refresh page + location.reload(); + return false; + } + } + } + }); + + + shutdownDialog.on('shown.bs.modal', function(e) { + // remove close button + var dialog = $(this); + + dialog.find('.bootbox-close-button').remove(); + dialog.find('button').blur(); + + // show error message + showPageContent(dialog); + }); + }); + }; + + +}); \ No newline at end of file diff --git a/js/app/ui/dialog/trust.js b/js/app/ui/dialog/trust.js new file mode 100644 index 00000000..89878219 --- /dev/null +++ b/js/app/ui/dialog/trust.js @@ -0,0 +1,138 @@ +/** + * set IGB trust dialog + */ + +define([ + 'jquery', + 'app/init', + 'app/util', + 'app/render', + 'bootbox', + 'app/ccp' +], function($, Init, Util, Render, bootbox, CCP) { + 'use strict'; + + var config = { + + // trust dialog + trustDialogId: 'pf-trust-dialog', // id for "trust" dialog + trustDialogFirstPageId: 'pf-trust-first-page', // id for first page + trustDialogSecondPageId: 'pf-trust-second-page' // id for second page + + }; + + /** + * show/animate dialog page content + * @param pageElement + */ + var showPageContent = function(pageElement){ + + pageElement.find('h1').delay(300).velocity('transition.shrinkIn', { + duration: 500 + }).delay(800) + + pageElement.find('h1').velocity({ + scale: 1.05 + }, { + duration: 600, + loop: 5 + }); + }; + + /** + * show "trust" dialog + */ + $.fn.showTrustDialog = function(){ + + requirejs(['text!templates/dialog/trust.html', 'mustache'], function(template, Mustache) { + + var data = { + id: config.trustDialogId, + firstPageId: config.trustDialogFirstPageId, + secondPageId: config.trustDialogSecondPageId + }; + + + var content = Mustache.render(template, data); + + + + // show dialog + var trustDialog = bootbox.dialog({ + title: 'Trust Page', + message: content, + buttons: { + logout: { + label: ' logout', + className: ['btn-default', 'pull-left'].join(' '), + callback: function() { + + $(document).trigger('pf:menuLogout'); + } + }, + trust: { + label: ' trust', + className: 'btn-primary', + callback: function(){ + var dialog = $(this); + + // request trust + CCP.requestTrust(); + + var firstPageElement = dialog.find('#' + config.trustDialogFirstPageId); + var secondPageElement = dialog.find('#' + config.trustDialogSecondPageId); + + // toggle buttons + dialog.find('.btn-primary').hide(); + dialog.find('.btn-success').removeClass('hide'); + + + // toggle pages + firstPageElement.velocity('slideUp', { + duration: Init.animationSpeed.dialogEvents, + complete: function(){ + secondPageElement.velocity('slideDown', { + duration: Init.animationSpeed.dialogEvents, + display: 'block' + }); + } + }); + + // show reload button + showPageContent(secondPageElement); + + + return false; + } + }, + reload: { + label: ' reload', + className: ['btn-success', 'hide'].join(' '), + callback: function(){ + // reload page + location.reload(); + return false; + } + } + } + }); + + + trustDialog.on('shown.bs.modal', function(e) { + // remove close button + var dialog = $(this); + + dialog.find('.bootbox-close-button').remove(); + dialog.find('button').blur(); + + // show trust message + var firstPageElement = dialog.find('#' + config.trustDialogFirstPageId); + showPageContent(firstPageElement); + }); + + + }); + }; + + +}); \ No newline at end of file diff --git a/js/app/ui/form_element.js b/js/app/ui/form_element.js index c2b5514e..341672b9 100644 --- a/js/app/ui/form_element.js +++ b/js/app/ui/form_element.js @@ -55,7 +55,7 @@ define([ selectElement.select2('destroy'); var reason = status + ' ' + jqXHR.status + ': ' + error; - Util.emergencyShutdown(reason); + $(document).trigger('pf:shutdown', {reason: reason}); } } diff --git a/js/app/ui/system_info.js b/js/app/ui/system_info.js index 01773df2..50567374 100644 --- a/js/app/ui/system_info.js +++ b/js/app/ui/system_info.js @@ -28,7 +28,8 @@ define([ addDescriptionButtonClass: 'pf-system-info-description-button', // class for "add description" button moduleElementToolbarClass: 'pf-table-tools', // class for "module toolbar" element moduleToolbarActionId: 'pf-system-info-collapse-container', // id for "module toolbar action" element - descriptionTextareaElementClass: 'pf-system-info-description' // class for "description" textarea element (xEditable) + descriptionTextareaElementClass: 'pf-system-info-description', // class for "description" textarea element (xEditable) + descriptionTextareaTooltipClass: 'pf-system-info-description-tooltip' // class for "description" tooltip }; // disable Module update temporary (until. some requests/animations) are finished @@ -127,8 +128,8 @@ define([ if(description !== systemData.description){ // description changed - // toolbar element - var toolbarElement = moduleElement.find('.' + config.moduleElementToolbarClass); + // description button + var descriptionButton = moduleElement.find('.' + config.addDescriptionButtonClass); // set new value descriptionTextareaElement.editable('setValue', systemData.description); @@ -137,9 +138,7 @@ define([ // show/activate description field // show button if value is empty - toolbarElement.velocity('slideDown',{ - duration: animationSpeedToolbar - }); + descriptionButton.show(); hideToolsActionElement(); @@ -147,10 +146,8 @@ define([ }else{ // hide/disable description field - // hide tool buttons - toolbarElement.velocity('slideUp',{ - duration: animationSpeedToolbar - }); + // hide tool button + descriptionButton.hide() showToolsActionElement(); } @@ -204,7 +201,7 @@ define([ var descriptionButton = tempModuleElement.find('.' + config.addDescriptionButtonClass); // toolbar element - var toolbarElement = tempModuleElement.find('.' + config.moduleElementToolbarClass); + //var toolbarElement = tempModuleElement.find('.' + config.moduleElementToolbarClass); // description textarea element var descriptionTextareaElement = tempModuleElement.find('.' + config.descriptionTextareaElementClass); @@ -221,7 +218,7 @@ define([ onblur: 'cancel', showbuttons: true, value: '', // value is set by trigger function updateSystemInfoModule() - rows: 2, + rows: 5, name: 'description', inputclass: config.descriptionTextareaElementClass, params: function(params){ @@ -268,6 +265,9 @@ define([ descriptionTextareaElement.on('shown', function(e){ // disable module update until description field is open disableModuleUpdate = true; + + // disable tooltip + tempModuleElement.find('.' + config.descriptionTextareaTooltipClass).tooltip('disable'); }); // on xEditable close @@ -275,13 +275,14 @@ define([ var value = $(this).editable('getValue', true); if(value.length === 0){ - // show button if value is empty + // show button if value is empty hideToolsActionElement(); - toolbarElement.velocity('slideDown',{ - duration: animationSpeedToolbar - }); + descriptionButton.show(); + }else{ + // enable tooltip + tempModuleElement.find('.' + config.descriptionTextareaTooltipClass).tooltip('enable'); } // enable module update @@ -293,9 +294,7 @@ define([ e.stopPropagation(); // hide tool buttons - toolbarElement.velocity('slideUp',{ - duration: animationSpeedToolbar - }); + descriptionButton.hide(); // show field *before* showing the element descriptionTextareaElement.editable('show'); @@ -359,7 +358,8 @@ define([ moduleToolbarClass: config.moduleElementToolbarClass, descriptionButtonClass: config.addDescriptionButtonClass, moduleToolbarActionId: config.moduleToolbarActionId, - descriptionTextareaClass: config.descriptionTextareaElementClass + descriptionTextareaClass: config.descriptionTextareaElementClass, + descriptionTooltipClass: config.descriptionTextareaTooltipClass }; Render.showModule(moduleConfig, moduleData); diff --git a/js/app/ui/system_killboard.js b/js/app/ui/system_killboard.js index 97812cf5..0c450ca7 100644 --- a/js/app/ui/system_killboard.js +++ b/js/app/ui/system_killboard.js @@ -4,16 +4,25 @@ define([ 'app/util', 'morris' ], function($, Init, Util, Morris) { - "use strict"; + 'use strict'; var config = { // module info moduleClass: 'pf-module', // class for each module + // headline toolbar + systemModuleHeadlineIcon: 'pf-module-icon-button', // class for toolbar icons in the head + // system killboard module systemKillboardModuleClass: 'pf-system-killboard-module', // module wrapper - systemKillboardGraphsClass: 'pf-system-killboard-graphs', // wrapper for graph - systemKillboardGraphKillsClass: 'pf-system-killboard-graph-kills' // class for system kill graph + systemKillboardGraphKillsClass: 'pf-system-killboard-graph-kills', // class for system kill graph + + // system killboard list + systemKillboardListClass: 'pf-system-killboard-list', // class for a list with kill entries + systemKillboardListEntryClass: 'pf-system-killboard-list-entry', // class for a list entry + systemKillboardListImgShip: 'pf-system-killboard-img-ship', // class for all ship images + systemKillboardListImgAlly: 'pf-system-killboard-img-ally', // class for all alliance logos + systemKillboardListImgCorp: 'pf-system-killboard-img-corp' // class for all corp logos }; @@ -34,19 +43,176 @@ define([ return label; }; + // show number of killmails + var killMailCounterMax = 20; + var killMailCounter = 0; + + + var showKillmails = function(moduleElement, killboardData){ +console.log(killboardData) + + // change order (show right to left) + killboardData.tableData.reverse(); + + for(var i = 0; i < killboardData.tableData.length; i++){ + + // check if killMails exist in this hour + if(killboardData.tableData[i].killmails){ + + if(killMailCounter >= killMailCounterMax){ + break; + } + + moduleElement.append( $('
').text(i + 'h ago')); + + var killMailData = killboardData.tableData[i].killmails; + + var listeElement = $('