mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
Comment out full notification until webclient has a config pane. Make webclient title reflect game name. Merges #1046.
This commit is contained in:
parent
57ea70cb82
commit
401b60e233
2 changed files with 69 additions and 64 deletions
|
|
@ -206,9 +206,9 @@ function onText(args, kwargs) {
|
|||
mwin.append("<div class='" + cls + "'>" + args[0] + "</div>");
|
||||
mwin.animate({
|
||||
scrollTop: document.getElementById("messagewindow").scrollHeight
|
||||
}, 0);
|
||||
|
||||
onNewLine(args[0], null);
|
||||
}, 0);
|
||||
|
||||
onNewLine(args[0], null);
|
||||
}
|
||||
|
||||
// Handle prompt output from the server
|
||||
|
|
@ -245,74 +245,78 @@ function onDefault(cmdname, args, kwargs) {
|
|||
// in Firefox, there it's a standard error.
|
||||
function onBeforeUnload() {
|
||||
return "You are about to leave the game. Please confirm.";
|
||||
}
|
||||
|
||||
var unread = 0;
|
||||
var originalTitle = document.title;
|
||||
var focused = true;
|
||||
var favico;
|
||||
|
||||
/*function onVisibilityChange() {
|
||||
if(!document.hidden) {
|
||||
document.title = originalTitle;
|
||||
}
|
||||
}*/
|
||||
|
||||
function onBlur(e) {
|
||||
focused = false;
|
||||
}
|
||||
|
||||
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 = {
|
||||
body: text.replace(/(<([^>]+)>)/ig,""),
|
||||
icon: "/static/website/images/evennia_logo.png"
|
||||
}
|
||||
var n = new Notification(title, options);
|
||||
n.onclick = function(e) {
|
||||
e.preventDefault();
|
||||
window.focus();
|
||||
this.close();
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Notifications
|
||||
var unread = 0;
|
||||
var originalTitle = document.title;
|
||||
var focused = true;
|
||||
var favico;
|
||||
|
||||
function onBlur(e) {
|
||||
focused = false;
|
||||
}
|
||||
|
||||
// Notifications for unfocused window
|
||||
function onFocus(e) {
|
||||
focused = true;
|
||||
document.title = originalTitle;
|
||||
unread = 0;
|
||||
favico.badge(0);
|
||||
}
|
||||
|
||||
function onNewLine(text, originator) {
|
||||
if(!focused) {
|
||||
// Changes unfocused browser tab title to number of unread messages
|
||||
unread++;
|
||||
favico.badge(unread);
|
||||
document.title = "(" + unread + ") " + originalTitle;
|
||||
|
||||
//// TODO: Following code adds a full notification popup. It
|
||||
//// works fine but should be possible to turn off if a player
|
||||
//// wants to (pending webclient config pane).
|
||||
////
|
||||
//Notification.requestPermission().then(function(result) {
|
||||
// if(result === "granted") {
|
||||
//
|
||||
// var title = originalTitle === "" ? "Evennia" : originalTitle;
|
||||
// var options = {
|
||||
// body: text.replace(/(<([^>]+)>)/ig,""),
|
||||
// icon: "/static/website/images/evennia_logo.png"
|
||||
// }
|
||||
//
|
||||
// var n = new Notification(title, options);
|
||||
// n.onclick = function(e) {
|
||||
// e.preventDefault();
|
||||
// window.focus();
|
||||
// this.close();
|
||||
// // }
|
||||
// }
|
||||
//})
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Register Events
|
||||
//
|
||||
|
||||
// Event when client finishes loading
|
||||
$(document).ready(function() {
|
||||
|
||||
Notification.requestPermission();
|
||||
|
||||
favico = new Favico({
|
||||
animation: 'none'
|
||||
});
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
Notification.requestPermission();
|
||||
|
||||
favico = new Favico({
|
||||
animation: 'none'
|
||||
});
|
||||
|
||||
// Event when client window changes
|
||||
$(window).bind("resize", doWindowResize);
|
||||
|
||||
$(window).blur(onBlur);
|
||||
$(window).focus(onFocus);
|
||||
|
||||
//$(document).on("visibilitychange", onVisibilityChange);
|
||||
|
||||
$(window).bind("resize", doWindowResize);
|
||||
|
||||
$(window).blur(onBlur);
|
||||
$(window).focus(onFocus);
|
||||
|
||||
//$(document).on("visibilitychange", onVisibilityChange);
|
||||
|
||||
$("#inputfield").bind("resize", doWindowResize)
|
||||
.keypress(onKeyPress)
|
||||
.bind("paste", resizeInputField)
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ JQuery available.
|
|||
{% load staticfiles %}
|
||||
<html dir="ltr" lang="en">
|
||||
<head>
|
||||
<title> {{game_name}} </title>
|
||||
<meta http-equiv="content-type", content="application/xhtml+xml; charset=UTF-8" />
|
||||
<meta name="author" content="Evennia" />
|
||||
<meta name="generator" content="Evennia" />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue