From ef0fd1178c4f9e5bea92dac7d02a12ce0d523547 Mon Sep 17 00:00:00 2001 From: Arun Persaud Date: Sat, 17 Aug 2013 08:24:36 -0700 Subject: 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. --- js/layout.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'js/layout.js') 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); -- cgit v1.2.3-18-g5258