mirror of
https://github.com/evennia/evennia.git
synced 2026-03-28 02:36:32 +01:00
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 originalTitle = document.title;
|
||||
var focused = true;
|
||||
var favico;
|
||||
|
||||
/*function onVisibilityChange() {
|
||||
if(!document.hidden) {
|
||||
|
|
@ -264,16 +265,19 @@ function onBlur(e) {
|
|||
function onFocus(e) {
|
||||
focused = true;
|
||||
document.title = originalTitle;
|
||||
unread = 0;
|
||||
favico.badge(0);
|
||||
}
|
||||
|
||||
function onNewLine(text, originator) {
|
||||
if(!focused) {
|
||||
unread++;
|
||||
favico.badge(unread);
|
||||
document.title = "(" + unread + ") " + originalTitle;
|
||||
Notification.requestPermission().then(function(result) {
|
||||
if(result === "granted") {
|
||||
var title = originalTitle === "" ? "Evennia" : originalTitle;
|
||||
var options = {
|
||||
var options = {
|
||||
body: text.replace(/(<([^>]+)>)/ig,"")
|
||||
}
|
||||
var n = new Notification(title, options);
|
||||
|
|
@ -296,6 +300,10 @@ $(document).ready(function() {
|
|||
|
||||
Notification.requestPermission();
|
||||
|
||||
favico = new Favico({
|
||||
animation: 'none'
|
||||
});
|
||||
|
||||
// Event when client window changes
|
||||
$(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="icon" type="image/x-icon" href="/static/website/images/favicon.ico" />
|
||||
|
||||
<!-- Import JQuery and warn if there is a problem -->
|
||||
{% block jquery_import %}
|
||||
<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>
|
||||
{% 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>
|
||||
<body>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue