From 047e7d8b989e7ff5446956375546bf6080aaeb53 Mon Sep 17 00:00:00 2001 From: hamza zia Date: Wed, 17 Jul 2013 16:10:24 +0200 Subject: [PATCH] added page title for notifications if pinned as app tab in a modern browser --- js/ctrls/download.js | 6 +++++- js/services/utils.js | 16 ++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/js/ctrls/download.js b/js/ctrls/download.js index 3211b2d..bdc9b93 100644 --- a/js/ctrls/download.js +++ b/js/ctrls/download.js @@ -6,9 +6,11 @@ angular .controller('DownloadCtrl', [ '$scope', '$rpc', '$utils', '$alerts', '$modals', '$fileSettings', '$activeInclude', '$waitingExclude', + // for document title + '$window', function( scope, rpc, utils, alerts, modals, - fsettings, activeInclude, waitingExclude + fsettings, activeInclude, waitingExclude, window ) { scope.active = [], scope.waiting = [], scope.stopped = []; scope.gstats = {}; @@ -86,6 +88,8 @@ function( rpc.subscribe('getGlobalStat', [], function(data) { scope.gstats = data[0]; + window.document.title = utils.getTitle(scope.gstats); + }); rpc.once('getVersion', [], function(data) { diff --git a/js/services/utils.js b/js/services/utils.js index a11827a..a7a4848 100644 --- a/js/services/utils.js +++ b/js/services/utils.js @@ -1,5 +1,5 @@ angular.module('webui.services.utils', []) -.factory('$utils', function() { +.factory('$utils', ['$filter', function(filter) { return { // saves the key value pair in cookies setCookie: function(key, value) { @@ -58,6 +58,18 @@ angular.module('webui.services.utils', []) return dest; }, + // get info title from global statistics + getTitle: function(stats) { + var title = + '(' + + ' a:' + stats.numActive + + ' p:' + stats.numWaiting + + ' s:' + stats.numStopped + + ') ' + + 'aria2 Web Client'; + + return title; + }, // get download chunks from aria2 bitfield getChunksFromHex: function(bitfield, numOfPieces) { @@ -93,4 +105,4 @@ angular.module('webui.services.utils', []) return chunks; } }; -}); +}]);