- add current character name as document.title

- improved document.title blink on new rally point with inactive tab, #279
This commit is contained in:
Exodus4D
2016-08-06 16:30:02 +02:00
parent a87459895a
commit ec6ed66a6b
9 changed files with 111 additions and 35 deletions

View File

@@ -31,7 +31,7 @@ class AppController extends Controller {
*/
public function init(\Base $f3) {
// page title
$f3->set('pageTitle', 'Login');
$f3->set('pageTitle', 'Pathfinder');
// main page content
$f3->set('pageContent', $f3->get('PATHFINDER.VIEW.LOGIN'));

View File

@@ -14,9 +14,11 @@ class MapController extends AccessController {
* @param \Base $f3
*/
public function init($f3) {
$character = $this->getCharacter();
// page title
$f3->set('pageTitle', 'Maps');
$pageTitle = $character ? $character->name : 'Map';
$f3->set('pageTitle', $pageTitle);
// main page content
$f3->set('pageContent', false);

View File

@@ -37,6 +37,12 @@ define([
}
};
// initial page title (cached)
var initialPageTitle = document.title;
// global blink timeout cache
var blinkTimer;
// stack container for all notifications
var stack = {
bottomRight: {
@@ -137,35 +143,48 @@ define([
var startTabBlink = function(blinkTitle){
var initBlink = (function(blinkTitle){
var currentTitle = document.title;
// count blinks if tab is currently active
var activeTabBlinkCount = 0;
var timeoutId;
var blink = function(){
document.title = document.title === blinkTitle ? currentTitle : blinkTitle;
};
// number of "blinks" should be limited if tab is currently active
if(window.isVisible){
activeTabBlinkCount++;
}
var clear = function() {
clearInterval(timeoutId);
document.title = currentTitle;
window.onmousemove = null;
timeoutId = null;
};
// toggle page title
document.title = (document.title === blinkTitle) ? initialPageTitle : blinkTitle;
return function () {
if (!timeoutId) {
timeoutId = setInterval(blink, 1000);
window.onmousemove = clear;
if(activeTabBlinkCount > 10){
stopTabBlink();
}
};
return function () {
if (!blinkTimer) {
blinkTimer = setInterval(blink, 1000);
}
};
}( blinkTitle ));
initBlink();
};
/**
* stop blinking document.title
*/
var stopTabBlink = function(){
if(blinkTimer){
clearInterval(blinkTimer);
document.title = initialPageTitle;
blinkTimer = null;
}
};
return {
showNotify: showNotify,
startTabBlink: startTabBlink
startTabBlink: startTabBlink,
stopTabBlink: stopTabBlink
};
});

View File

@@ -890,12 +890,21 @@ define([
function handleVisibilityChange() {
if (document[hidden]) {
// tab is invisible
// globally store current visibility status
window.isVisible = false;
Util.getCurrentTriggerDelay( mapUpdateKey, increaseTimer );
Util.getCurrentTriggerDelay( mapUserUpdateKey, increaseTimer );
} else {
// tab is visible
// globally store current visibility status
window.isVisible = true;
Util.getCurrentTriggerDelay( mapUpdateKey, -increaseTimer );
Util.getCurrentTriggerDelay( mapUserUpdateKey, -increaseTimer );
// stop blinking tab from previous notifications
Util.stopTabBlink();
}
}

View File

@@ -970,12 +970,20 @@ define([
* @param desktop
*/
var showNotify = function(customConfig, desktop){
requirejs(['app/notification'], function(Notification) {
Notification.showNotify(customConfig, desktop);
});
};
/**
* stop browser tab title "blinking"
*/
var stopTabBlink = function(){
requirejs(['app/notification'], function(Notification) {
Notification.stopTabBlink();
});
};
/**
* get log entry info
* @param logType
@@ -1726,6 +1734,7 @@ define([
timeStop: timeStop,
log: log,
showNotify: showNotify,
stopTabBlink: stopTabBlink,
getLogInfo: getLogInfo,
isXHRAborted: isXHRAborted,
getMapModule: getMapModule,

View File

@@ -37,6 +37,12 @@ define([
}
};
// initial page title (cached)
var initialPageTitle = document.title;
// global blink timeout cache
var blinkTimer;
// stack container for all notifications
var stack = {
bottomRight: {
@@ -137,35 +143,48 @@ define([
var startTabBlink = function(blinkTitle){
var initBlink = (function(blinkTitle){
var currentTitle = document.title;
// count blinks if tab is currently active
var activeTabBlinkCount = 0;
var timeoutId;
var blink = function(){
document.title = document.title === blinkTitle ? currentTitle : blinkTitle;
};
// number of "blinks" should be limited if tab is currently active
if(window.isVisible){
activeTabBlinkCount++;
}
var clear = function() {
clearInterval(timeoutId);
document.title = currentTitle;
window.onmousemove = null;
timeoutId = null;
};
// toggle page title
document.title = (document.title === blinkTitle) ? initialPageTitle : blinkTitle;
return function () {
if (!timeoutId) {
timeoutId = setInterval(blink, 1000);
window.onmousemove = clear;
if(activeTabBlinkCount > 10){
stopTabBlink();
}
};
return function () {
if (!blinkTimer) {
blinkTimer = setInterval(blink, 1000);
}
};
}( blinkTitle ));
initBlink();
};
/**
* stop blinking document.title
*/
var stopTabBlink = function(){
if(blinkTimer){
clearInterval(blinkTimer);
document.title = initialPageTitle;
blinkTimer = null;
}
};
return {
showNotify: showNotify,
startTabBlink: startTabBlink
startTabBlink: startTabBlink,
stopTabBlink: stopTabBlink
};
});

View File

@@ -890,12 +890,21 @@ define([
function handleVisibilityChange() {
if (document[hidden]) {
// tab is invisible
// globally store current visibility status
window.isVisible = false;
Util.getCurrentTriggerDelay( mapUpdateKey, increaseTimer );
Util.getCurrentTriggerDelay( mapUserUpdateKey, increaseTimer );
} else {
// tab is visible
// globally store current visibility status
window.isVisible = true;
Util.getCurrentTriggerDelay( mapUpdateKey, -increaseTimer );
Util.getCurrentTriggerDelay( mapUserUpdateKey, -increaseTimer );
// stop blinking tab from previous notifications
Util.stopTabBlink();
}
}

View File

@@ -970,12 +970,20 @@ define([
* @param desktop
*/
var showNotify = function(customConfig, desktop){
requirejs(['app/notification'], function(Notification) {
Notification.showNotify(customConfig, desktop);
});
};
/**
* stop browser tab title "blinking"
*/
var stopTabBlink = function(){
requirejs(['app/notification'], function(Notification) {
Notification.stopTabBlink();
});
};
/**
* get log entry info
* @param logType
@@ -1726,6 +1734,7 @@ define([
timeStop: timeStop,
log: log,
showNotify: showNotify,
stopTabBlink: stopTabBlink,
getLogInfo: getLogInfo,
isXHRAborted: isXHRAborted,
getMapModule: getMapModule,

View File

@@ -31,7 +31,7 @@
<meta name="keywords" content="eve,wormhole,mapping,tool,mmo,space,game">
<meta name="author" content="Exodus 4D">
<title>Pathfinder - {{ @pageTitle}}</title>
<title>{{ @pageTitle}}</title>
<meta property="og:title" content="EVE ONLINE mapping tool">
<meta property="og:site_name" content="PATHFINDER">