Notification now changes favicon to reflect unread messages.
This commit is contained in:
parent
684fea5d62
commit
067a731ace
2 changed files with 13 additions and 1 deletions
|
|
@ -250,6 +250,7 @@ function onBeforeUnload() {
|
||||||
var unread = 0;
|
var unread = 0;
|
||||||
var originalTitle = document.title;
|
var originalTitle = document.title;
|
||||||
var focused = true;
|
var focused = true;
|
||||||
|
var favico;
|
||||||
|
|
||||||
/*function onVisibilityChange() {
|
/*function onVisibilityChange() {
|
||||||
if(!document.hidden) {
|
if(!document.hidden) {
|
||||||
|
|
@ -264,11 +265,14 @@ function onBlur(e) {
|
||||||
function onFocus(e) {
|
function onFocus(e) {
|
||||||
focused = true;
|
focused = true;
|
||||||
document.title = originalTitle;
|
document.title = originalTitle;
|
||||||
|
unread = 0;
|
||||||
|
favico.badge(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onNewLine(text, originator) {
|
function onNewLine(text, originator) {
|
||||||
if(!focused) {
|
if(!focused) {
|
||||||
unread++;
|
unread++;
|
||||||
|
favico.badge(unread);
|
||||||
document.title = "(" + unread + ") " + originalTitle;
|
document.title = "(" + unread + ") " + originalTitle;
|
||||||
Notification.requestPermission().then(function(result) {
|
Notification.requestPermission().then(function(result) {
|
||||||
if(result === "granted") {
|
if(result === "granted") {
|
||||||
|
|
@ -296,6 +300,10 @@ $(document).ready(function() {
|
||||||
|
|
||||||
Notification.requestPermission();
|
Notification.requestPermission();
|
||||||
|
|
||||||
|
favico = new Favico({
|
||||||
|
animation: 'none'
|
||||||
|
});
|
||||||
|
|
||||||
// Event when client window changes
|
// Event when client window changes
|
||||||
$(window).bind("resize", doWindowResize);
|
$(window).bind("resize", doWindowResize);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,8 @@ JQuery available.
|
||||||
|
|
||||||
<link rel='stylesheet' type="text/css" media="screen" href={% static "webclient/css/webclient.css" %}>
|
<link rel='stylesheet' type="text/css" media="screen" href={% static "webclient/css/webclient.css" %}>
|
||||||
|
|
||||||
|
<link rel="icon" type="image/x-icon" href="/static/website/images/favicon.ico" />
|
||||||
|
|
||||||
<!-- Import JQuery and warn if there is a problem -->
|
<!-- Import JQuery and warn if there is a problem -->
|
||||||
{% block jquery_import %}
|
{% block jquery_import %}
|
||||||
<script src="http://code.jquery.com/jquery-2.1.1.min.js" type="text/javascript" charset="utf-8"></script>
|
<script src="http://code.jquery.com/jquery-2.1.1.min.js" type="text/javascript" charset="utf-8"></script>
|
||||||
|
|
@ -54,6 +56,8 @@ JQuery available.
|
||||||
<script src={% static "webclient/js/webclient_gui.js" %} language="javascript" type="text/javascript" charset="utf-8"></script>
|
<script src={% static "webclient/js/webclient_gui.js" %} language="javascript" type="text/javascript" charset="utf-8"></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
<script src="https://cdn.rawgit.com/ejci/favico.js/master/favico-0.3.10.min.js" language="javascript" type="text/javascript" charset="utf-8"></script>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue