From ef0fd1178c4f9e5bea92dac7d02a12ce0d523547 Mon Sep 17 00:00:00 2001 From: Arun Persaud Date: Sat, 17 Aug 2013 08:24:36 -0700 Subject: [PATCH] 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. --- include/output.php | 2 +- js/layout.js | 30 +++++++++++++++++ pics/edoko-favicon-your-turn.png | Bin 0 -> 1099 bytes testfav.php | 56 +++++++++++++++++++++++++++++++ 4 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 pics/edoko-favicon-your-turn.png create mode 100644 testfav.php diff --git a/include/output.php b/include/output.php index 67c1870..6e5f15f 100644 --- a/include/output.php +++ b/include/output.php @@ -423,7 +423,7 @@ function output_header() e-Doko - + " /> " /> "/> 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); diff --git a/pics/edoko-favicon-your-turn.png b/pics/edoko-favicon-your-turn.png new file mode 100644 index 0000000000000000000000000000000000000000..71604fcaa7e3a8d507d26228561922d8277e0081 GIT binary patch literal 1099 zcmV-R1ho5!P)TIrP16w-P(-ZL>1=Lp-r@5TqlEZxc}%0x2!h~o z2u#!5-rl||EJP#+0k~x+PESuGI3^SLzQ4b}KW*)!uzbJSY6V07)j3vk_p7bGckhf=~VPL?SWs z4hn_Bx_%OeU~zFVLN=!M0n4)0YBhmSboGyuUN)PJxC1=ioTS_Bnx>gfrv*WnpP&ES zwqJi}OiTVSVOJ|vilS6iRaMotZBZ2G=H^)TUsa)MwOaUeczC$Awe|9u^O6N{Tm9~@ z2FAElDt&Kg&)Sn4wJx%TVeIVe-0a)0c=$P=S~cAJf7X59mn13N77XQjcX#)OYCMg` zWUE1(Zz&f-c#E)8u8LwH82J8$_cTKHsKM&$Dnf{=)oQI)>xI*^3)KMtbC7x-($^tF zrbtZ?1m2{O9|YF{{iCBxl7vjt+}qo`Tzx2KE+JrcID{M@A6u41DT;ENuwJC(J|6n6 z(@W9FG)?Q$A^s@ z$|ZQ77X;xKOde;IX#bJ9R;g5Y{+~Ld-qf~jRaG@ja~wyO<$ONRFiaRa zIy!pe_R}%z5(C_y*l9>xCdvI`I+xC?Ne*+fds0J6Y ROP>G$002ovPDHLkV1nlP_TB&h literal 0 HcmV?d00001 diff --git a/testfav.php b/testfav.php new file mode 100644 index 0000000..7d29897 --- /dev/null +++ b/testfav.php @@ -0,0 +1,56 @@ + + * + * This file is part of e-DoKo. + * + * e-DoKo is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * e-DoKo is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with e-DoKo. If not, see . + * + */ + +error_reporting(E_ALL); + +session_start(); + +include_once("config.php"); /* needs to be first in list, since other includes use this */ +include_once("./include/db.php"); /* database only */ + +/* open the database */ +$DBopen = DB_open(); +if($DBopen<0) + exit(); + +if(isset($_SESSION['id'])) + { + $myid = $_SESSION['id']; + + $result = DB_query_array("SELECT count(player) from Game ". + " WHERE player=".DB_quote_smart($myid). + " AND ( status='pre' OR status='play' ) "); + if($result[0]) + $ret=array('turn'=>'yes'); + else + $ret=array('turn'=>'no'); + + echo json_encode($ret); + }; + +DB_close(); + +/* + *Local Variables: + *mode: php + *mode: hs-minor + *End: + */ +?> -- 2.25.1