Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/webroot/rsrc/js/core/Title.js
12241 views
1
/**
2
* @provides phabricator-title
3
* @requires javelin-install
4
*/
5
6
/**
7
* Update the document title to show a notification/message count.
8
*/
9
JX.install('Title', {
10
statics: {
11
_counts: {},
12
_title: null,
13
14
setCount: function(k, v) {
15
var self = JX.Title;
16
self._counts[k] = v;
17
self._update();
18
},
19
20
setTitle: function(title) {
21
var self = JX.Title;
22
self._title = title;
23
self._update();
24
},
25
26
_update: function() {
27
var self = JX.Title;
28
29
if (self._title === null) {
30
self._title = document.title;
31
}
32
33
var sum = 0;
34
for (var k in self._counts) {
35
sum += parseInt(self._counts[k], 10) || 0;
36
}
37
38
var title;
39
if (sum) {
40
title = '(' + sum + ') ' + self._title;
41
} else {
42
title = self._title;
43
}
44
45
document.title = title;
46
47
}
48
}
49
});
50
51