- fixed a bug with multi-character select (session mixed up)
- removed "beta" status from /admin login - changed "tooltip" default color "green" -> "gray"
This commit is contained in:
@@ -42,11 +42,10 @@ class User extends Controller\Controller{
|
||||
/**
|
||||
* login a valid character
|
||||
* @param Model\CharacterModel $characterModel
|
||||
* @param string $browserTabId
|
||||
* @return bool
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function loginByCharacter(Model\CharacterModel &$characterModel, string $browserTabId){
|
||||
protected function loginByCharacter(Model\CharacterModel &$characterModel){
|
||||
$login = false;
|
||||
|
||||
if($user = $characterModel->getUser()){
|
||||
@@ -97,7 +96,7 @@ class User extends Controller\Controller{
|
||||
|
||||
// set temp character data ------------------------------------------------------------
|
||||
// -> pass character data over for next http request (reroute())
|
||||
$this->setTempCharacterData($characterModel->_id, $browserTabId);
|
||||
$this->setTempCharacterData($characterModel->_id);
|
||||
|
||||
$login = true;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ class Sso extends Api\User{
|
||||
const SESSION_KEY_SSO_ERROR = 'SESSION.SSO.ERROR';
|
||||
const SESSION_KEY_SSO_STATE = 'SESSION.SSO.STATE';
|
||||
const SESSION_KEY_SSO_FROM = 'SESSION.SSO.FROM';
|
||||
const SESSION_KEY_SSO_TAB_ID = 'SESSION.SSO.TABID';
|
||||
|
||||
// error messages
|
||||
const ERROR_CCP_SSO_URL = 'Invalid "ENVIRONMENT.[ENVIRONMENT].CCP_SSO_URL" url. %s';
|
||||
@@ -56,7 +55,6 @@ class Sso extends Api\User{
|
||||
*/
|
||||
public function requestAdminAuthorization($f3){
|
||||
// store browser tabId to be "targeted" after login
|
||||
$f3->set(self::SESSION_KEY_SSO_TAB_ID, '');
|
||||
$f3->set(self::SESSION_KEY_SSO_FROM, 'admin');
|
||||
|
||||
$scopes = self::getScopesByAuthType('admin');
|
||||
@@ -72,10 +70,6 @@ class Sso extends Api\User{
|
||||
*/
|
||||
public function requestAuthorization($f3){
|
||||
$params = $f3->get('GET');
|
||||
$browserTabId = trim((string)$params['tabId']);
|
||||
|
||||
// store browser tabId to be "targeted" after login
|
||||
$f3->set(self::SESSION_KEY_SSO_TAB_ID, $browserTabId);
|
||||
|
||||
if(
|
||||
isset($params['characterId']) &&
|
||||
@@ -111,7 +105,7 @@ class Sso extends Api\User{
|
||||
$character->hasUserCharacter() &&
|
||||
($character->isAuthorized() === 'OK')
|
||||
){
|
||||
$loginCheck = $this->loginByCharacter($character, $browserTabId);
|
||||
$loginCheck = $this->loginByCharacter($character);
|
||||
|
||||
if($loginCheck){
|
||||
// set "login" cookie
|
||||
@@ -184,8 +178,6 @@ class Sso extends Api\User{
|
||||
$rootAlias = $f3->get(self::SESSION_KEY_SSO_FROM);
|
||||
}
|
||||
|
||||
$browserTabId = (string)$f3->get(self::SESSION_KEY_SSO_TAB_ID) ;
|
||||
|
||||
if($f3->exists(self::SESSION_KEY_SSO_STATE)){
|
||||
// check response and validate 'state'
|
||||
if(
|
||||
@@ -198,7 +190,6 @@ class Sso extends Api\User{
|
||||
// clear 'state' for new next login request
|
||||
$f3->clear(self::SESSION_KEY_SSO_STATE);
|
||||
$f3->clear(self::SESSION_KEY_SSO_FROM);
|
||||
$f3->clear(self::SESSION_KEY_SSO_TAB_ID);
|
||||
|
||||
$accessData = $this->getSsoAccessData($getParams['code']);
|
||||
|
||||
@@ -265,7 +256,7 @@ class Sso extends Api\User{
|
||||
$characterModel = $userCharactersModel->getCharacter();
|
||||
|
||||
// login by character
|
||||
$loginCheck = $this->loginByCharacter($characterModel, $browserTabId);
|
||||
$loginCheck = $this->loginByCharacter($characterModel);
|
||||
|
||||
if($loginCheck){
|
||||
// set "login" cookie
|
||||
@@ -317,7 +308,6 @@ class Sso extends Api\User{
|
||||
public function login(\Base $f3){
|
||||
$data = (array)$f3->get('GET');
|
||||
$cookieName = empty($data['cookie']) ? '' : $data['cookie'];
|
||||
$browserTabId = empty($data['tabId']) ? '' : $data['tabId'];
|
||||
$character = null;
|
||||
|
||||
if( !empty($cookieName) ){
|
||||
@@ -332,7 +322,7 @@ class Sso extends Api\User{
|
||||
|
||||
if( is_object($character)){
|
||||
// login by character
|
||||
$loginCheck = $this->loginByCharacter($character, $browserTabId);
|
||||
$loginCheck = $this->loginByCharacter($character);
|
||||
if($loginCheck){
|
||||
// route to "map"
|
||||
$f3->reroute(['map']);
|
||||
|
||||
@@ -345,7 +345,6 @@ class Controller {
|
||||
|
||||
/**
|
||||
* get current character data from session
|
||||
* ->
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
@@ -355,35 +354,16 @@ class Controller {
|
||||
if($user = $this->getUser()){
|
||||
$header = self::getRequestHeaders();
|
||||
$requestedCharacterId = (int)$header['Pf-Character'];
|
||||
$browserTabId = (string)$header['Pf-Tab-Id'];
|
||||
$tempCharacterData = (array)$this->getF3()->get(Api\User::SESSION_KEY_TEMP_CHARACTER_DATA);
|
||||
|
||||
if($this->getF3()->get('AJAX')){
|
||||
if( !$this->getF3()->get('AJAX') ){
|
||||
$requestedCharacterId = (int)$_COOKIE['old_char_id'];
|
||||
if(!$requestedCharacterId){
|
||||
$tempCharacterData = (array)$this->getF3()->get(Api\User::SESSION_KEY_TEMP_CHARACTER_DATA);
|
||||
if((int)$tempCharacterData['ID'] > 0){
|
||||
$requestedCharacterId = (int)$tempCharacterData['ID'];
|
||||
}
|
||||
|
||||
// _blank browser tab don´t have a $browserTabId jet..
|
||||
// first Ajax call from that new tab with empty $requestedCharacterId -> bind to that new tab
|
||||
if(
|
||||
!empty($browserTabId) &&
|
||||
$requestedCharacterId <= 0 &&
|
||||
(int)$tempCharacterData['ID'] > 0 &&
|
||||
empty($tempCharacterData['TAB_ID'])
|
||||
){
|
||||
$tempCharacterData['TAB_ID'] = $browserTabId;
|
||||
// update tempCharacterData (SESSION)
|
||||
$this->setTempCharacterData($tempCharacterData['ID'], $tempCharacterData['TAB_ID']);
|
||||
}
|
||||
|
||||
if(
|
||||
!empty($browserTabId) &&
|
||||
!empty($tempCharacterData['TAB_ID']) &&
|
||||
(int)$tempCharacterData['ID'] > 0 &&
|
||||
$browserTabId === $tempCharacterData['TAB_ID']
|
||||
){
|
||||
$requestedCharacterId = (int)$tempCharacterData['ID'];
|
||||
}
|
||||
|
||||
}elseif((int)$tempCharacterData['ID'] > 0){
|
||||
$requestedCharacterId = (int)$tempCharacterData['ID'];
|
||||
}
|
||||
|
||||
$data = $user->getSessionCharacterData($requestedCharacterId);
|
||||
@@ -450,14 +430,12 @@ class Controller {
|
||||
/**
|
||||
* set temp login character data (required during HTTP redirects on login)
|
||||
* @param int $characterId
|
||||
* @param string $browserTabId
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function setTempCharacterData(int $characterId, string $browserTabId){
|
||||
protected function setTempCharacterData(int $characterId){
|
||||
if($characterId > 0){
|
||||
$tempCharacterData = [
|
||||
'ID' => $characterId,
|
||||
'TAB_ID' => trim($browserTabId)
|
||||
'ID' => $characterId
|
||||
];
|
||||
$this->getF3()->set(Api\User::SESSION_KEY_TEMP_CHARACTER_DATA, $tempCharacterData);
|
||||
}else{
|
||||
|
||||
@@ -21,6 +21,9 @@ class MapController extends AccessController {
|
||||
public function init(\Base $f3) {
|
||||
$character = $this->getCharacter();
|
||||
|
||||
// characterId
|
||||
$f3->set('tplCharacterId', $character->id);
|
||||
|
||||
// page title
|
||||
$f3->set('tplPageTitle', $character->name . ' | ' . Config::getPathfinderData('name'));
|
||||
|
||||
|
||||
@@ -76,42 +76,6 @@ define([
|
||||
defaultAcceptCookieExpire: 365 // default expire for "accept coolies" cookie
|
||||
};
|
||||
|
||||
/**
|
||||
* set a cookie
|
||||
* @param cname
|
||||
* @param cvalue
|
||||
* @param exdays
|
||||
*/
|
||||
let setCookie = function(cname, cvalue, exdays) {
|
||||
let d = new Date();
|
||||
d.setTime(d.getTime() + (exdays*24*60*60*1000));
|
||||
let expires = 'expires=' + d.toUTCString();
|
||||
let path = 'path=' + Util.getDocumentPath();
|
||||
document.cookie = cname + '=' + cvalue + '; ' + expires + '; ' + path;
|
||||
};
|
||||
|
||||
/**
|
||||
* get cookie value by name
|
||||
* @param cname
|
||||
* @returns {*}
|
||||
*/
|
||||
let getCookie = function(cname) {
|
||||
let name = cname + '=';
|
||||
let ca = document.cookie.split(';');
|
||||
|
||||
for(let i = 0; i <ca.length; i++) {
|
||||
let c = ca[i];
|
||||
while (c.charAt(0) === ' ') {
|
||||
c = c.substring(1);
|
||||
}
|
||||
|
||||
if (c.indexOf(name) === 0) {
|
||||
return c.substring(name.length,c.length);
|
||||
}
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
||||
/**
|
||||
* set link observer for "version info" dialog
|
||||
*/
|
||||
@@ -146,7 +110,7 @@ define([
|
||||
moveAdminPanel('down');
|
||||
});
|
||||
|
||||
if(getCookie('cookie') !== '1'){
|
||||
if(Util.getCookie('cookie') !== '1'){
|
||||
// hint not excepted
|
||||
cookieHintElement.collapse('show');
|
||||
|
||||
@@ -163,7 +127,7 @@ define([
|
||||
btnCancelIcon: 'fa fa-fw fa-check',
|
||||
onCancel: function(e, target){
|
||||
// "Accept cookies"
|
||||
setCookie('cookie', 1, config.defaultAcceptCookieExpire);
|
||||
Util.setCookie('cookie', 1, config.defaultAcceptCookieExpire, 'd');
|
||||
|
||||
// set "default" href
|
||||
let href = $(target).data('bs.confirmation').getHref();
|
||||
@@ -181,7 +145,7 @@ define([
|
||||
}
|
||||
|
||||
cookieHintElement.find('.btn-success').on('click', function(){
|
||||
setCookie('cookie', 1, config.defaultAcceptCookieExpire);
|
||||
Util.setCookie('cookie', 1, config.defaultAcceptCookieExpire, 'd');
|
||||
});
|
||||
|
||||
// manual -------------------------------------------------------------
|
||||
|
||||
@@ -383,7 +383,18 @@ define([
|
||||
// Send map update request on tab close/reload, in order to save map changes that
|
||||
// haven´t been saved through default update trigger
|
||||
window.addEventListener('beforeunload', function(e) {
|
||||
// save unsaved map changes ...
|
||||
triggerMapUpdatePing();
|
||||
|
||||
// check if character should be switched on reload or current character should be loaded afterwards
|
||||
let characterSwitch = Boolean( $('body').data('characterSwitch') );
|
||||
if(!characterSwitch){
|
||||
let characterId = Util.getCurrentCharacterId();
|
||||
if(characterId){
|
||||
Util.setCookie('old_char_id', characterId, 3, 's');
|
||||
}
|
||||
}
|
||||
|
||||
// IMPORTANT, return false in order to not "abort" ajax request in background!
|
||||
return false;
|
||||
});
|
||||
|
||||
@@ -120,8 +120,8 @@ define([
|
||||
// load right menu
|
||||
$('.' + config.pageSlidebarRightClass).loadRightMenu();
|
||||
|
||||
// set document observer for global events
|
||||
setDocumentObserver();
|
||||
// set page observer for global events
|
||||
setPageObserver();
|
||||
});
|
||||
};
|
||||
|
||||
@@ -568,7 +568,7 @@ define([
|
||||
/**
|
||||
* catch all global document events
|
||||
*/
|
||||
let setDocumentObserver = function(){
|
||||
let setPageObserver = function(){
|
||||
|
||||
// on "full-screen" change event
|
||||
$(document).on('fscreenchange', function(e, state, elem){
|
||||
|
||||
115
js/app/util.js
115
js/app/util.js
@@ -620,6 +620,17 @@ define([
|
||||
popoverElement = button.data('bs.popover').tip();
|
||||
popoverElement.velocity('transition.' + easeEffect, velocityOptions);
|
||||
popoverElement.initTooltips();
|
||||
|
||||
// set click events. This is required to pass data to "beforeunload" events
|
||||
// -> there is no way to identify the target within that event
|
||||
popoverElement.on('click', '.btn', function(){
|
||||
// character switch detected
|
||||
$('body').data('characterSwitch', true);
|
||||
// ... and remove "characterSwitch" data again! after "unload"
|
||||
setTimeout(function() {
|
||||
$('body').removeData('characterSwitch');
|
||||
}, 500);
|
||||
});
|
||||
}else{
|
||||
popoverElement = button.data('bs.popover').tip();
|
||||
if(popoverElement.is(':visible')){
|
||||
@@ -1061,6 +1072,28 @@ define([
|
||||
return Init.currentUserData;
|
||||
};
|
||||
|
||||
/**
|
||||
* get either active characterID or characterId from initial page load
|
||||
* @returns {number}
|
||||
*/
|
||||
let getCurrentCharacterId = () => {
|
||||
let userData = getCurrentUserData();
|
||||
let currentCharacterId = 0;
|
||||
if(
|
||||
userData &&
|
||||
userData.character
|
||||
){
|
||||
currentCharacterId = parseInt( userData.character.id );
|
||||
}
|
||||
|
||||
if(!currentCharacterId){
|
||||
// no active character... -> get default characterId from initial page load
|
||||
currentCharacterId = parseInt(document.body.getAttribute('data-character-id'));
|
||||
}
|
||||
|
||||
return currentCharacterId;
|
||||
};
|
||||
|
||||
/**
|
||||
* get a unique ID for each tab
|
||||
* -> store ID in session storage
|
||||
@@ -1084,21 +1117,9 @@ define([
|
||||
// Add custom application headers on "same origin" requests only!
|
||||
// -> Otherwise a "preflight" request is made, which will "probably" fail
|
||||
if(settings.crossDomain === false){
|
||||
// Add browser tab information
|
||||
xhr.setRequestHeader('Pf-Tab-Id', getBrowserTabId()) ;
|
||||
|
||||
// add current character data to ANY XHR request (HTTP HEADER)
|
||||
// -> This helps to identify multiple characters on multiple browser tabs
|
||||
let userData = getCurrentUserData();
|
||||
let currentCharacterId = 0;
|
||||
if(
|
||||
userData &&
|
||||
userData.character
|
||||
){
|
||||
currentCharacterId = parseInt( userData.character.id );
|
||||
}
|
||||
|
||||
xhr.setRequestHeader('Pf-Character', currentCharacterId);
|
||||
xhr.setRequestHeader('Pf-Character', getCurrentCharacterId());
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -2084,7 +2105,7 @@ define([
|
||||
* @param date
|
||||
* @returns {Date}
|
||||
*/
|
||||
let createDateAsUTC = function(date){
|
||||
let createDateAsUTC = (date) => {
|
||||
return new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds()));
|
||||
};
|
||||
|
||||
@@ -2093,7 +2114,7 @@ define([
|
||||
* @param date
|
||||
* @returns {Date}
|
||||
*/
|
||||
let convertDateToUTC = function(date){
|
||||
let convertDateToUTC = (date) => {
|
||||
return new Date(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds());
|
||||
};
|
||||
|
||||
@@ -2103,7 +2124,7 @@ define([
|
||||
* @param showSeconds
|
||||
* @returns {string}
|
||||
*/
|
||||
let convertDateToString = function(date, showSeconds){
|
||||
let convertDateToString = (date, showSeconds) => {
|
||||
let dateString = ('0'+ (date.getMonth() + 1 )).slice(-2) + '/' + ('0'+date.getDate()).slice(-2) + '/' + date.getFullYear();
|
||||
let timeString = ('0' + date.getHours()).slice(-2) + ':' + ('0'+date.getMinutes()).slice(-2);
|
||||
timeString += (showSeconds) ? ':' + ('0'+date.getSeconds()).slice(-2) : '';
|
||||
@@ -2128,7 +2149,7 @@ define([
|
||||
* -> www.pathfinder.com/pathfinder/ -> /pathfinder
|
||||
* @returns {string|string}
|
||||
*/
|
||||
let getDocumentPath = function(){
|
||||
let getDocumentPath = () => {
|
||||
let pathname = window.location.pathname;
|
||||
// replace file endings
|
||||
let r = /[^\/]*$/;
|
||||
@@ -2141,7 +2162,7 @@ define([
|
||||
* @param url
|
||||
* @param params
|
||||
*/
|
||||
let redirect = function(url, params){
|
||||
let redirect = (url, params) => {
|
||||
let currentUrl = document.URL;
|
||||
|
||||
if(url !== currentUrl){
|
||||
@@ -2159,7 +2180,7 @@ define([
|
||||
* send logout request
|
||||
* @param params
|
||||
*/
|
||||
let logout = function(params){
|
||||
let logout = (params) => {
|
||||
let data = {};
|
||||
if(
|
||||
params &&
|
||||
@@ -2183,6 +2204,56 @@ define([
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* set a cookie
|
||||
* @param name
|
||||
* @param value
|
||||
* @param expire
|
||||
* @param format
|
||||
*/
|
||||
let setCookie = (name, value, expire, format) => {
|
||||
let d = new Date();
|
||||
let time = d.getTime();
|
||||
let timeExpire = time * -1;
|
||||
|
||||
if(expire > 0){
|
||||
switch(format){
|
||||
case 'd': // days
|
||||
timeExpire = expire * 24 * 60 * 60 * 1000; break;
|
||||
case 's': // seconds
|
||||
timeExpire = expire * 1000; break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
d.setTime(time + timeExpire);
|
||||
let expires = 'expires=' + d.toUTCString();
|
||||
let path = 'path=' + getDocumentPath();
|
||||
document.cookie = name + '=' + value + '; ' + expires + '; ' + path;
|
||||
};
|
||||
|
||||
/**
|
||||
* get cookie value by name
|
||||
* @param cname
|
||||
* @returns {string}
|
||||
*/
|
||||
let getCookie = (cname) => {
|
||||
let name = cname + '=';
|
||||
let ca = document.cookie.split(';');
|
||||
|
||||
for(let i = 0; i <ca.length; i++) {
|
||||
let c = ca[i];
|
||||
while (c.charAt(0) === ' ') {
|
||||
c = c.substring(1);
|
||||
}
|
||||
|
||||
if (c.indexOf(name) === 0) {
|
||||
return c.substring(name.length,c.length);
|
||||
}
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
||||
return {
|
||||
config: config,
|
||||
getVersion: getVersion,
|
||||
@@ -2225,6 +2296,7 @@ define([
|
||||
deleteCurrentMapData: deleteCurrentMapData,
|
||||
setCurrentUserData: setCurrentUserData,
|
||||
getCurrentUserData: getCurrentUserData,
|
||||
getCurrentCharacterId: getCurrentCharacterId,
|
||||
setCurrentSystemData: setCurrentSystemData,
|
||||
getCurrentSystemData: getCurrentSystemData,
|
||||
getCurrentLocationData: getCurrentLocationData,
|
||||
@@ -2244,8 +2316,9 @@ define([
|
||||
clearSessionStorage: clearSessionStorage,
|
||||
getBrowserTabId: getBrowserTabId,
|
||||
getObjVal: getObjVal,
|
||||
getDocumentPath: getDocumentPath,
|
||||
redirect: redirect,
|
||||
logout: logout
|
||||
logout: logout,
|
||||
setCookie: setCookie,
|
||||
getCookie: getCookie
|
||||
};
|
||||
});
|
||||
File diff suppressed because one or more lines are too long
@@ -76,42 +76,6 @@ define([
|
||||
defaultAcceptCookieExpire: 365 // default expire for "accept coolies" cookie
|
||||
};
|
||||
|
||||
/**
|
||||
* set a cookie
|
||||
* @param cname
|
||||
* @param cvalue
|
||||
* @param exdays
|
||||
*/
|
||||
let setCookie = function(cname, cvalue, exdays) {
|
||||
let d = new Date();
|
||||
d.setTime(d.getTime() + (exdays*24*60*60*1000));
|
||||
let expires = 'expires=' + d.toUTCString();
|
||||
let path = 'path=' + Util.getDocumentPath();
|
||||
document.cookie = cname + '=' + cvalue + '; ' + expires + '; ' + path;
|
||||
};
|
||||
|
||||
/**
|
||||
* get cookie value by name
|
||||
* @param cname
|
||||
* @returns {*}
|
||||
*/
|
||||
let getCookie = function(cname) {
|
||||
let name = cname + '=';
|
||||
let ca = document.cookie.split(';');
|
||||
|
||||
for(let i = 0; i <ca.length; i++) {
|
||||
let c = ca[i];
|
||||
while (c.charAt(0) === ' ') {
|
||||
c = c.substring(1);
|
||||
}
|
||||
|
||||
if (c.indexOf(name) === 0) {
|
||||
return c.substring(name.length,c.length);
|
||||
}
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
||||
/**
|
||||
* set link observer for "version info" dialog
|
||||
*/
|
||||
@@ -146,7 +110,7 @@ define([
|
||||
moveAdminPanel('down');
|
||||
});
|
||||
|
||||
if(getCookie('cookie') !== '1'){
|
||||
if(Util.getCookie('cookie') !== '1'){
|
||||
// hint not excepted
|
||||
cookieHintElement.collapse('show');
|
||||
|
||||
@@ -163,7 +127,7 @@ define([
|
||||
btnCancelIcon: 'fa fa-fw fa-check',
|
||||
onCancel: function(e, target){
|
||||
// "Accept cookies"
|
||||
setCookie('cookie', 1, config.defaultAcceptCookieExpire);
|
||||
Util.setCookie('cookie', 1, config.defaultAcceptCookieExpire, 'd');
|
||||
|
||||
// set "default" href
|
||||
let href = $(target).data('bs.confirmation').getHref();
|
||||
@@ -181,7 +145,7 @@ define([
|
||||
}
|
||||
|
||||
cookieHintElement.find('.btn-success').on('click', function(){
|
||||
setCookie('cookie', 1, config.defaultAcceptCookieExpire);
|
||||
Util.setCookie('cookie', 1, config.defaultAcceptCookieExpire, 'd');
|
||||
});
|
||||
|
||||
// manual -------------------------------------------------------------
|
||||
|
||||
@@ -383,7 +383,18 @@ define([
|
||||
// Send map update request on tab close/reload, in order to save map changes that
|
||||
// haven´t been saved through default update trigger
|
||||
window.addEventListener('beforeunload', function(e) {
|
||||
// save unsaved map changes ...
|
||||
triggerMapUpdatePing();
|
||||
|
||||
// check if character should be switched on reload or current character should be loaded afterwards
|
||||
let characterSwitch = Boolean( $('body').data('characterSwitch') );
|
||||
if(!characterSwitch){
|
||||
let characterId = Util.getCurrentCharacterId();
|
||||
if(characterId){
|
||||
Util.setCookie('old_char_id', characterId, 3, 's');
|
||||
}
|
||||
}
|
||||
|
||||
// IMPORTANT, return false in order to not "abort" ajax request in background!
|
||||
return false;
|
||||
});
|
||||
|
||||
@@ -120,8 +120,8 @@ define([
|
||||
// load right menu
|
||||
$('.' + config.pageSlidebarRightClass).loadRightMenu();
|
||||
|
||||
// set document observer for global events
|
||||
setDocumentObserver();
|
||||
// set page observer for global events
|
||||
setPageObserver();
|
||||
});
|
||||
};
|
||||
|
||||
@@ -568,7 +568,7 @@ define([
|
||||
/**
|
||||
* catch all global document events
|
||||
*/
|
||||
let setDocumentObserver = function(){
|
||||
let setPageObserver = function(){
|
||||
|
||||
// on "full-screen" change event
|
||||
$(document).on('fscreenchange', function(e, state, elem){
|
||||
|
||||
@@ -620,6 +620,17 @@ define([
|
||||
popoverElement = button.data('bs.popover').tip();
|
||||
popoverElement.velocity('transition.' + easeEffect, velocityOptions);
|
||||
popoverElement.initTooltips();
|
||||
|
||||
// set click events. This is required to pass data to "beforeunload" events
|
||||
// -> there is no way to identify the target within that event
|
||||
popoverElement.on('click', '.btn', function(){
|
||||
// character switch detected
|
||||
$('body').data('characterSwitch', true);
|
||||
// ... and remove "characterSwitch" data again! after "unload"
|
||||
setTimeout(function() {
|
||||
$('body').removeData('characterSwitch');
|
||||
}, 500);
|
||||
});
|
||||
}else{
|
||||
popoverElement = button.data('bs.popover').tip();
|
||||
if(popoverElement.is(':visible')){
|
||||
@@ -1061,6 +1072,28 @@ define([
|
||||
return Init.currentUserData;
|
||||
};
|
||||
|
||||
/**
|
||||
* get either active characterID or characterId from initial page load
|
||||
* @returns {number}
|
||||
*/
|
||||
let getCurrentCharacterId = () => {
|
||||
let userData = getCurrentUserData();
|
||||
let currentCharacterId = 0;
|
||||
if(
|
||||
userData &&
|
||||
userData.character
|
||||
){
|
||||
currentCharacterId = parseInt( userData.character.id );
|
||||
}
|
||||
|
||||
if(!currentCharacterId){
|
||||
// no active character... -> get default characterId from initial page load
|
||||
currentCharacterId = parseInt(document.body.getAttribute('data-character-id'));
|
||||
}
|
||||
|
||||
return currentCharacterId;
|
||||
};
|
||||
|
||||
/**
|
||||
* get a unique ID for each tab
|
||||
* -> store ID in session storage
|
||||
@@ -1084,21 +1117,9 @@ define([
|
||||
// Add custom application headers on "same origin" requests only!
|
||||
// -> Otherwise a "preflight" request is made, which will "probably" fail
|
||||
if(settings.crossDomain === false){
|
||||
// Add browser tab information
|
||||
xhr.setRequestHeader('Pf-Tab-Id', getBrowserTabId()) ;
|
||||
|
||||
// add current character data to ANY XHR request (HTTP HEADER)
|
||||
// -> This helps to identify multiple characters on multiple browser tabs
|
||||
let userData = getCurrentUserData();
|
||||
let currentCharacterId = 0;
|
||||
if(
|
||||
userData &&
|
||||
userData.character
|
||||
){
|
||||
currentCharacterId = parseInt( userData.character.id );
|
||||
}
|
||||
|
||||
xhr.setRequestHeader('Pf-Character', currentCharacterId);
|
||||
xhr.setRequestHeader('Pf-Character', getCurrentCharacterId());
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -2084,7 +2105,7 @@ define([
|
||||
* @param date
|
||||
* @returns {Date}
|
||||
*/
|
||||
let createDateAsUTC = function(date){
|
||||
let createDateAsUTC = (date) => {
|
||||
return new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds()));
|
||||
};
|
||||
|
||||
@@ -2093,7 +2114,7 @@ define([
|
||||
* @param date
|
||||
* @returns {Date}
|
||||
*/
|
||||
let convertDateToUTC = function(date){
|
||||
let convertDateToUTC = (date) => {
|
||||
return new Date(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds());
|
||||
};
|
||||
|
||||
@@ -2103,7 +2124,7 @@ define([
|
||||
* @param showSeconds
|
||||
* @returns {string}
|
||||
*/
|
||||
let convertDateToString = function(date, showSeconds){
|
||||
let convertDateToString = (date, showSeconds) => {
|
||||
let dateString = ('0'+ (date.getMonth() + 1 )).slice(-2) + '/' + ('0'+date.getDate()).slice(-2) + '/' + date.getFullYear();
|
||||
let timeString = ('0' + date.getHours()).slice(-2) + ':' + ('0'+date.getMinutes()).slice(-2);
|
||||
timeString += (showSeconds) ? ':' + ('0'+date.getSeconds()).slice(-2) : '';
|
||||
@@ -2128,7 +2149,7 @@ define([
|
||||
* -> www.pathfinder.com/pathfinder/ -> /pathfinder
|
||||
* @returns {string|string}
|
||||
*/
|
||||
let getDocumentPath = function(){
|
||||
let getDocumentPath = () => {
|
||||
let pathname = window.location.pathname;
|
||||
// replace file endings
|
||||
let r = /[^\/]*$/;
|
||||
@@ -2141,7 +2162,7 @@ define([
|
||||
* @param url
|
||||
* @param params
|
||||
*/
|
||||
let redirect = function(url, params){
|
||||
let redirect = (url, params) => {
|
||||
let currentUrl = document.URL;
|
||||
|
||||
if(url !== currentUrl){
|
||||
@@ -2159,7 +2180,7 @@ define([
|
||||
* send logout request
|
||||
* @param params
|
||||
*/
|
||||
let logout = function(params){
|
||||
let logout = (params) => {
|
||||
let data = {};
|
||||
if(
|
||||
params &&
|
||||
@@ -2183,6 +2204,56 @@ define([
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* set a cookie
|
||||
* @param name
|
||||
* @param value
|
||||
* @param expire
|
||||
* @param format
|
||||
*/
|
||||
let setCookie = (name, value, expire, format) => {
|
||||
let d = new Date();
|
||||
let time = d.getTime();
|
||||
let timeExpire = time * -1;
|
||||
|
||||
if(expire > 0){
|
||||
switch(format){
|
||||
case 'd': // days
|
||||
timeExpire = expire * 24 * 60 * 60 * 1000; break;
|
||||
case 's': // seconds
|
||||
timeExpire = expire * 1000; break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
d.setTime(time + timeExpire);
|
||||
let expires = 'expires=' + d.toUTCString();
|
||||
let path = 'path=' + getDocumentPath();
|
||||
document.cookie = name + '=' + value + '; ' + expires + '; ' + path;
|
||||
};
|
||||
|
||||
/**
|
||||
* get cookie value by name
|
||||
* @param cname
|
||||
* @returns {string}
|
||||
*/
|
||||
let getCookie = (cname) => {
|
||||
let name = cname + '=';
|
||||
let ca = document.cookie.split(';');
|
||||
|
||||
for(let i = 0; i <ca.length; i++) {
|
||||
let c = ca[i];
|
||||
while (c.charAt(0) === ' ') {
|
||||
c = c.substring(1);
|
||||
}
|
||||
|
||||
if (c.indexOf(name) === 0) {
|
||||
return c.substring(name.length,c.length);
|
||||
}
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
||||
return {
|
||||
config: config,
|
||||
getVersion: getVersion,
|
||||
@@ -2225,6 +2296,7 @@ define([
|
||||
deleteCurrentMapData: deleteCurrentMapData,
|
||||
setCurrentUserData: setCurrentUserData,
|
||||
getCurrentUserData: getCurrentUserData,
|
||||
getCurrentCharacterId: getCurrentCharacterId,
|
||||
setCurrentSystemData: setCurrentSystemData,
|
||||
getCurrentSystemData: getCurrentSystemData,
|
||||
getCurrentLocationData: getCurrentLocationData,
|
||||
@@ -2244,8 +2316,9 @@ define([
|
||||
clearSessionStorage: clearSessionStorage,
|
||||
getBrowserTabId: getBrowserTabId,
|
||||
getObjVal: getObjVal,
|
||||
getDocumentPath: getDocumentPath,
|
||||
redirect: redirect,
|
||||
logout: logout
|
||||
logout: logout,
|
||||
setCookie: setCookie,
|
||||
getCookie: getCookie
|
||||
};
|
||||
});
|
||||
@@ -43,17 +43,13 @@
|
||||
<meta property="og:description" content="PATHFINDER is an 'open source' mapping tool for EVE ONLINE,
|
||||
primarily developed to enrich the gameplay of small scale PvP and PvE.">
|
||||
|
||||
{* Chrome, Firefox OS and Opera *}
|
||||
<meta name="theme-color" content="#2b2b2b">
|
||||
{* Windows Phone *}
|
||||
<meta name="msapplication-navbutton-color" content="#2b2b2b">
|
||||
{* iOS Safari *}
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="#2b2b2b">
|
||||
|
||||
{* Youtube verification code *}
|
||||
<meta name="google-site-verification" content="sHoh0gfMw3x1wiwLTK5OsKsxt7kRgxi69hRgWEGh9DQ" />
|
||||
<meta name="theme-color" content="#2b2b2b"> {* Chrome, Firefox OS and Opera *}
|
||||
<meta name="msapplication-navbutton-color" content="#2b2b2b"> {* Windows Phone *}
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="#2b2b2b"> {* iOS Safari *}
|
||||
|
||||
<meta name="google-site-verification" content="sHoh0gfMw3x1wiwLTK5OsKsxt7kRgxi69hRgWEGh9DQ" /> {* Youtube verification code *}
|
||||
|
||||
{* Resources *}
|
||||
<set pathCSS="{{ @BASE . '/public/css/pathfinder.css?' . @PATHFINDER.VERSION }}" />
|
||||
<set pathJSApp="{{ @BASE . '/' . @tplPathJs . '/app' }}" />
|
||||
<set pathJSRequire="{{ @BASE . '/' . @tplPathJs . '/lib/require.js' }}" />
|
||||
@@ -74,7 +70,7 @@
|
||||
</check>
|
||||
|
||||
</head>
|
||||
<body class="pf-body {{ @tplBodyClass }}" data-js-path="{{ @BASE }}/{{ @tplPathJs }}" data-script="{{ @tplJsView }}" data-version="{{ @PATHFINDER.VERSION }}">
|
||||
<body class="pf-body {{ @tplBodyClass }}" data-js-path="{{ @BASE }}/{{ @tplPathJs }}" data-script="{{ @tplJsView }}" <check if="{{ @tplCharacterId }}">data-character-id="{{ @tplCharacterId }}"</check> data-version="{{ @PATHFINDER.VERSION }}">
|
||||
<include if="{{ @tplPageContent }}" href="{{ @tplPageContent }}"/>
|
||||
|
||||
<!-- Hey dude! Where is all the magic? -->
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
<li><a class="page-scroll" data-anchor="#pf-landing-top" href="#">Login</a></li>
|
||||
<li> <a class="page-scroll" data-anchor="#pf-landing-gallery" href="#">Features</a></li>
|
||||
<li> <a class="page-scroll" data-anchor="#pf-landing-maps" href="#">Maps</a></li>
|
||||
<li> <a class="page-scroll" data-anchor="#pf-landing-admin" href="#">Admin <small class="txt-color txt-color-orange">[BETA]</small></a></li>
|
||||
<li> <a class="page-scroll" data-anchor="#pf-landing-admin" href="#">Admin</a></li>
|
||||
<li> <a class="page-scroll" data-anchor="#pf-landing-install" href="#">Install</a></li>
|
||||
<li> <a class="page-scroll" data-anchor="#pf-landing-about" href="#">About</a></li>
|
||||
<li> <a class="page-scroll" data-anchor="#pf-landing-faq" href="#">FAQ</a></li>
|
||||
@@ -673,7 +673,7 @@
|
||||
<div class="container">
|
||||
<div class="row text-center">
|
||||
<div class="col-md-6 col-md-offset-3">
|
||||
<h2><span class="text-primary">Admin</span> interface <small class="txt-color txt-color-warning">[BETA]</small></h2>
|
||||
<h2><span class="text-primary">Admin</span> interface</h2>
|
||||
<p class="lead">
|
||||
Characters with in-game corporation roles can grant acces to <em>PATHFINDER</em> corporation admin interface.
|
||||
</p>
|
||||
|
||||
@@ -913,7 +913,7 @@ table{
|
||||
|
||||
// global tooltip settings ========================================================================
|
||||
.tooltip-inner{
|
||||
color: $green;
|
||||
color: $gray-lighter;
|
||||
background-color: $gray;
|
||||
font-family: $font-family-bold;
|
||||
padding: 5px 5px;
|
||||
|
||||
Reference in New Issue
Block a user