diff options
-rw-r--r-- | include/output.php | 2 | ||||
-rw-r--r-- | js/layout.js | 30 | ||||
-rw-r--r-- | pics/edoko-favicon-your-turn.png | bin | 0 -> 1099 bytes | |||
-rw-r--r-- | testfav.php | 56 |
4 files changed, 87 insertions, 1 deletions
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() <title>e-Doko</title> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width; initial-scale=1.0;" /> - <link rel="shortcut icon" href="pics/edoko-favicon.png" /> + <link id="favicon" rel="shortcut icon" href="pics/edoko-favicon.png" /> <link rel="stylesheet" media="all" href="<?php echo autoversion("css/bootstrap.css"); ?>" /> <link rel="stylesheet" href="<?php echo autoversion("css/standard.css"); ?>" /> <link rel="stylesheet" href="<?php echo autoversion("css/dateinput.css"); ?>"/> 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 Binary files differnew file mode 100644 index 0000000..71604fc --- /dev/null +++ b/pics/edoko-favicon-your-turn.png diff --git a/testfav.php b/testfav.php new file mode 100644 index 0000000..7d29897 --- /dev/null +++ b/testfav.php @@ -0,0 +1,56 @@ +<?php +/* Copyright 2013 Arun Persaud <arun@nubati.net> + * + * 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 <http://www.gnu.org/licenses/>. + * + */ + +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: + */ +?> |