Added favico.js

This commit is contained in:
Mattias Erming 2014-06-17 02:01:58 +02:00
parent 7e0672e035
commit 250995adbe
4 changed files with 33 additions and 7 deletions

View File

@ -168,7 +168,7 @@ button {
} }
#sidebar .pulse { #sidebar .pulse {
color: #fff; color: #fff;
transition: color 0s; transition: color 0.2s;
} }
#sidebar .network { #sidebar .network {
margin-top: 30px; margin-top: 30px;

View File

@ -157,6 +157,7 @@
<script src="/socket.io/socket.io.js"></script> <script src="/socket.io/socket.io.js"></script>
<script src="/js/jquery.js"></script> <script src="/js/jquery.js"></script>
<script src="/js/jquery.plugins.js"></script> <script src="/js/jquery.plugins.js"></script>
<script src="/js/favico.js"></script>
<script src="/js/uri.js"></script> <script src="/js/uri.js"></script>
<script src="/js/handlebars.js"></script> <script src="/js/handlebars.js"></script>
<script src="/js/chat.js"></script> <script src="/js/chat.js"></script>

View File

@ -2,11 +2,6 @@ $(function() {
var chat = $("#chat"); var chat = $("#chat");
var sidebar = $("#sidebar"); var sidebar = $("#sidebar");
setTimeout(function() {
// Enable transitions.
$("body").removeClass("preload");
}, 500);
var commands = [ var commands = [
"/ame", "/ame",
"/amsg", "/amsg",
@ -165,9 +160,24 @@ $(function() {
} }
} }
setTimeout(function() {
// Enable transitions.
$("body").removeClass("preload");
}, 500);
var pop = new Audio(); var pop = new Audio();
pop.src = "/audio/pop.ogg"; pop.src = "/audio/pop.ogg";
var favicon = new Favico({
animation: "none"
});
document.addEventListener("visibilitychange", function() {
if (sidebar.find(".highlight").length == 0) {
favicon.badge("");
}
});
var viewport = $("#viewport"); var viewport = $("#viewport");
var touchDevice = (window.screen.width <= 768); var touchDevice = (window.screen.width <= 768);
@ -179,6 +189,7 @@ $(function() {
if (!target) { if (!target) {
return; return;
} }
viewport.removeClass(); viewport.removeClass();
sidebar.find(".active").removeClass("active"); sidebar.find(".active").removeClass("active");
link.addClass("active") link.addClass("active")
@ -186,6 +197,10 @@ $(function() {
.removeClass("highlight") .removeClass("highlight")
.empty(); .empty();
if (sidebar.find(".highlight").length == 0) {
favicon.badge("");
}
$("#main .active").removeClass("active"); $("#main .active").removeClass("active");
var window = $(target) var window = $(target)
.css("z-index", z++) .css("z-index", z++)
@ -231,6 +246,9 @@ $(function() {
var last = messages.find(".row:last-child"); var last = messages.find(".row:last-child");
if (last.hasClass("highlight")) { if (last.hasClass("highlight")) {
pop.play(); pop.play();
if (document.hidden) {
favicon.badge("!");
}
} }
var link = $("#channel-" + id + ":not(.active)"); var link = $("#channel-" + id + ":not(.active)");

7
client/js/favico.js Normal file

File diff suppressed because one or more lines are too long