summaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
authorArun Persaud <arun@nubati.net>2013-08-17 08:24:36 -0700
committerArun Persaud <arun@nubati.net>2013-08-17 08:24:36 -0700
commitef0fd1178c4f9e5bea92dac7d02a12ce0d523547 (patch)
tree5e74f742a029170c8cfb82f151cbe67d2b7c0943 /js
parent7abff39352cfc8b29ab309e98ecf8b011db98039 (diff)
downloade-DoKo-ef0fd1178c4f9e5bea92dac7d02a12ce0d523547.tar.gz
e-DoKo-ef0fd1178c4f9e5bea92dac7d02a12ce0d523547.tar.bz2
e-DoKo-ef0fd1178c4f9e5bea92dac7d02a12ce0d523547.zip
update favicon if it's your turn.
Added a simple php script that returns via json if it's your turn and then check this every 10s using javascript.
Diffstat (limited to 'js')
-rw-r--r--js/layout.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/js/layout.js b/js/layout.js
index 88c85e5..ae8a8af 100644
--- a/js/layout.js
+++ b/js/layout.js
@@ -35,3 +35,33 @@ $('div.code').addClass('offset2 span2');
$('div.database').addClass('span2');
$('div.graphics').addClass('span2');
$('div.translation').addClass('span2');
+
+// favicon as indicator if it's your turn
+document.head || (document.head = document.getElementsByTagName('head')[0]);
+
+function checkFavicon() {
+ /* check if it's your turn */
+ url=window.location.href;
+ url=url.substring(0, url.lastIndexOf('index.php'))+"testfav.php";
+
+ $.getJSON(url)
+ .done(function( json ) {
+
+ var link = document.createElement('link'),
+ oldLink = document.getElementById('favicon');
+ link.id = 'favicon';
+ link.rel = 'shortcut icon';
+
+ if(json.turn=="yes")
+ link.href = "pics/edoko-favicon-your-turn.png";
+ else
+ link.href = "pics/edoko-favicon.png";
+
+ if (oldLink)
+ document.head.removeChild(oldLink);
+
+ document.head.appendChild(link);
+ });
+}
+checkFavicon();
+setInterval(checkFavicon,10000);