mirror of https://github.com/mthenw/frontail.git
code fixes; new icon
parent
007ee800b7
commit
af0759bac2
|
@ -38,6 +38,12 @@ window.App = (function (window, document, io) {
|
|||
*/
|
||||
var _newLinesCount = 0;
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
* @private
|
||||
*/
|
||||
var _isWindowFocused = true;
|
||||
|
||||
/**
|
||||
* Hide element if doesn't contain filter value
|
||||
*
|
||||
|
@ -75,12 +81,10 @@ window.App = (function (window, document, io) {
|
|||
};
|
||||
|
||||
/**
|
||||
* Is page is scrolled to bottom
|
||||
*
|
||||
* @return {Boolean}
|
||||
* @private
|
||||
*/
|
||||
var _scrolledBottom = function () {
|
||||
var _isScrolledBottom = function () {
|
||||
var currentScroll = document.documentElement.scrollTop || document.body.scrollTop;
|
||||
var totalHeight = document.body.offsetHeight;
|
||||
var clientHeight = document.documentElement.clientHeight;
|
||||
|
@ -88,18 +92,33 @@ window.App = (function (window, document, io) {
|
|||
};
|
||||
|
||||
/**
|
||||
* If the window gains focus reset favicon count
|
||||
*
|
||||
* @return void
|
||||
* @private
|
||||
*/
|
||||
var _faviconReset = function () {
|
||||
window.addEventListener('focus', function () {
|
||||
_newLinesCount = 0;
|
||||
Tinycon.setBubble(0);
|
||||
}, false);
|
||||
_newLinesCount = 0;
|
||||
Tinycon.setBubble(0);
|
||||
};
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* @private
|
||||
*/
|
||||
var _updateFaviconCounter = function () {
|
||||
if(_isWindowFocused) {
|
||||
return;
|
||||
}
|
||||
|
||||
_newLinesCount = _newLinesCount + 1;
|
||||
|
||||
if (_newLinesCount > 99) {
|
||||
Tinycon.setBubble(99);
|
||||
} else {
|
||||
Tinycon.setBubble(_newLinesCount);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return {
|
||||
/**
|
||||
* Init socket.io communication and log container
|
||||
|
@ -108,11 +127,9 @@ window.App = (function (window, document, io) {
|
|||
*/
|
||||
init: function (opts) {
|
||||
var that = this;
|
||||
|
||||
_faviconReset();
|
||||
|
||||
// socket.io init
|
||||
_socket = new io.connect('/' + opts.namespace);
|
||||
_socket = new io.connect('/' + opts.namespace);
|
||||
_socket
|
||||
.on('options:lines', function (limit) {
|
||||
_linesLimit = limit;
|
||||
|
@ -136,6 +153,15 @@ window.App = (function (window, document, io) {
|
|||
}
|
||||
_filterLogs();
|
||||
});
|
||||
|
||||
// Favicon counter bind
|
||||
window.addEventListener('blur', function () {
|
||||
_isWindowFocused = false;
|
||||
}, true);
|
||||
window.addEventListener('focus', function () {
|
||||
_isWindowFocused = true;
|
||||
_faviconReset();
|
||||
}, true);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -144,7 +170,7 @@ window.App = (function (window, document, io) {
|
|||
* @param {string} data data to log
|
||||
*/
|
||||
log: function (data) {
|
||||
var wasScrolledBottom = _scrolledBottom();
|
||||
var wasScrolledBottom = _isScrolledBottom();
|
||||
var div = document.createElement('div');
|
||||
var p = document.createElement('p');
|
||||
p.className = 'inner-line';
|
||||
|
@ -171,9 +197,7 @@ window.App = (function (window, document, io) {
|
|||
window.scrollTo(0, document.body.scrollHeight);
|
||||
}
|
||||
|
||||
// update favicon
|
||||
_newLinesCount = _newLinesCount + 1;
|
||||
Tinycon.setBubble(_newLinesCount);
|
||||
_updateFaviconCounter();
|
||||
}
|
||||
};
|
||||
})(window, document, io);
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
Binary file not shown.
Before Width: | Height: | Size: 262 B |
|
@ -4,7 +4,7 @@
|
|||
<title>tail -F __TITLE__</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<link rel="stylesheet" type="text/css" href="/styles/__THEME__.css">
|
||||
<link rel="icon" href="/favicon.png">
|
||||
<link rel="icon" href="/favicon.ico">
|
||||
</head>
|
||||
<body>
|
||||
<div class="navbar">
|
||||
|
|
Loading…
Reference in New Issue