Animate favicon rather than document title

This commit is contained in:
Thibault Duplessis 2013-01-01 22:23:02 +01:00
parent df764498c5
commit f61871395e
15 changed files with 71 additions and 164 deletions

View file

@ -26,7 +26,8 @@ final class Settings(config: Config, val IsDev: Boolean) {
val GamePaginatorMaxPerPage = getInt("game.paginator.max_per_page")
val GameCollectionGame = getString("game.collection.game")
val GameCollectionPgn = getString("game.collection.pgn")
val GameJsPath = getString("game.js_path")
val GameJsPathRaw = getString("game.js_path.raw")
val GameJsPathCompiled = getString("game.js_path.compiled")
val SearchESHost = getString("search.elasticsearch.host")
val SearchESPort = getInt("search.elasticsearch.port")

View file

@ -36,5 +36,7 @@ final class GameEnv(
lazy val rewind = new Rewind
lazy val gameJs = new GameJs(app.path.getCanonicalPath + "/" + settings.GameJsPath)
lazy val gameJs = new GameJs(
path = app.path.getCanonicalPath + "/" + IsDev.fold(GameJsPathRaw, GameJsPathCompiled),
useCache = !IsDev)
}

View file

@ -1,14 +1,18 @@
package lila
package game
final class GameJs(path: String) {
final class GameJs(path: String, useCache: Boolean) {
lazy val unsigned: String = {
val source = scala.io.Source fromFile path
source.mkString ~ { _ source.close }
}
def unsigned: String = useCache.fold(cached, readFromSource)
val placeholder = "--tkph--"
def sign(token: String) = unsigned.replace(placeholder, token)
private lazy val cached: String = readFromSource
private def readFromSource = {
val source = scala.io.Source fromFile path
source.mkString ~ { _ source.close }
}
}

View file

@ -7,7 +7,7 @@ import play.api.templates.Html
trait AssetHelper {
val assetVersion = 34
val assetVersion = 35
def cssTag(name: String) = css("stylesheets/" + name)

View file

@ -12,7 +12,7 @@
@moreCss
<meta content="@trans.freeOnlineChessGamePlayChessNowInACleanInterfaceNoRegistrationNoAdsNoPluginRequiredPlayChessWithComputerFriendsOrRandomOpponents()" name="description">
<meta charset="utf-8">
<link rel="shortcut icon" href="@routes.Assets.at("favicon.ico")" type="image/x-icon" />
<link rel="shortcut icon" href="@routes.Assets.at("images/favicon-32-white.png")" type="image/x-icon" />
@if(!robots) {
<meta content="noindex, nofollow" name="robots">
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 632 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 714 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View file

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

Before

Width:  |  Height:  |  Size: 674 B

After

Width:  |  Height:  |  Size: 674 B

View file

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="45" height="45">
<g style="opacity:1; fill:none; fill-opacity:1; fill-rule:evenodd; stroke:#000000; stroke-width:1.5; stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4; stroke-dasharray:none; stroke-opacity:1;">
<path
d="M 22,10 C 32.5,11 38.5,18 38,39 L 15,39 C 15,30 25,32.5 23,18"
style="fill:#000000; stroke:#000000;" />
<path
d="M 24,18 C 24.38,20.91 18.45,25.37 16,27 C 13,29 13.18,31.34 11,31 C 9.958,30.06 12.41,27.96 11,28 C 10,28 11.19,29.23 10,30 C 9,30 5.997,31 6,26 C 6,24 12,14 12,14 C 12,14 13.89,12.1 14,10.5 C 13.27,9.506 13.5,8.5 13.5,7.5 C 14.5,6.5 16.5,10 16.5,10 L 18.5,10 C 18.5,10 19.28,8.008 21,7 C 22,7 22,10 22,10"
style="fill:#000000; stroke:#000000;" />
<path
d="M 9.5 25.5 A 0.5 0.5 0 1 1 8.5,25.5 A 0.5 0.5 0 1 1 9.5 25.5 z"
style="fill:#ffffff; stroke:#ffffff;" />
<path
d="M 15 15.5 A 0.5 1.5 0 1 1 14,15.5 A 0.5 1.5 0 1 1 15 15.5 z"
transform="matrix(0.866,0.5,-0.5,0.866,9.693,-5.173)"
style="fill:#ffffff; stroke:#ffffff;" />
<path
d="M 24.55,10.4 L 24.1,11.85 L 24.6,12 C 27.75,13 30.25,14.49 32.5,18.75 C 34.75,23.01 35.75,29.06 35.25,39 L 35.2,39.5 L 37.45,39.5 L 37.5,39 C 38,28.94 36.62,22.15 34.25,17.66 C 31.88,13.17 28.46,11.02 25.06,10.5 L 24.55,10.4 z "
style="fill:#ffffff; stroke:none;" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

View file

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="45" height="45">
<g style="opacity:1; fill:none; fill-opacity:1; fill-rule:evenodd; stroke:#000000; stroke-width:1.5; stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4; stroke-dasharray:none; stroke-opacity:1;">
<path
d="M 22,10 C 32.5,11 38.5,18 38,39 L 15,39 C 15,30 25,32.5 23,18"
style="fill:#ffffff; stroke:#000000;" />
<path
d="M 24,18 C 24.38,20.91 18.45,25.37 16,27 C 13,29 13.18,31.34 11,31 C 9.958,30.06 12.41,27.96 11,28 C 10,28 11.19,29.23 10,30 C 9,30 5.997,31 6,26 C 6,24 12,14 12,14 C 12,14 13.89,12.1 14,10.5 C 13.27,9.506 13.5,8.5 13.5,7.5 C 14.5,6.5 16.5,10 16.5,10 L 18.5,10 C 18.5,10 19.28,8.008 21,7 C 22,7 22,10 22,10"
style="fill:#ffffff; stroke:#000000;" />
<path
d="M 9.5 25.5 A 0.5 0.5 0 1 1 8.5,25.5 A 0.5 0.5 0 1 1 9.5 25.5 z"
style="fill:#000000; stroke:#000000;" />
<path
d="M 15 15.5 A 0.5 1.5 0 1 1 14,15.5 A 0.5 1.5 0 1 1 15 15.5 z"
transform="matrix(0.866,0.5,-0.5,0.866,9.693,-5.173)"
style="fill:#000000; stroke:#000000;" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

View file

@ -550,11 +550,14 @@ var lichess_translations = [];
}
if (!self.options.opponent.ai && !self.options.player.spectator) {
setTimeout(self.updateTitle = function() {
document.title = (self.isMyTurn() && self.options.game.started && !self.options.game.finished) ? document.title = document.title.indexOf('/\\/') == 0 ? '\\/\\ ' + document.title.replace(/\/\\\/ /, '') : '/\\/ ' + document.title.replace(/\\\/\\ /, '') : document.title;
setTimeout(self.updateTitle, 400);
},
400);
function resetFavicon() { $.favicon('assets/images/favicon-32-white.png'); }
function shouldNotify() { return self.isMyTurn() && self.options.game.started && !self.options.game.finished; }
setInterval(function() {
if (shouldNotify()) {
$.favicon('assets/images/favicon-32-black.png');
setTimeout(resetFavicon, 400);
} else resetFavicon();
}, 800);
}
lichess.socket = new strongSocket(

File diff suppressed because one or more lines are too long

1
todo
View file

@ -53,4 +53,3 @@ make signup more visible
traduction intégrale
block user creation from an IP
mute IP
use favicon to notify moves