From e023a3b9396623330e74ad4bceade7800cf9651f Mon Sep 17 00:00:00 2001 From: Keplyx Date: Fri, 15 Jun 2018 11:12:55 +0200 Subject: [PATCH] Score changes position on mobile --- assets/css/score.css | 70 ++++++++++++++------------ assets/css/style.css | 8 ++- classes/dao.php | 39 ++++++++------ includes/score_counter.php | 29 +++-------- includes/{top_bar.html => top_bar.php} | 4 ++ index.php | 8 --- template.php | 19 ++++++- 7 files changed, 96 insertions(+), 81 deletions(-) rename includes/{top_bar.html => top_bar.php} (81%) diff --git a/assets/css/score.css b/assets/css/score.css index 4f07a92..c2e3377 100644 --- a/assets/css/score.css +++ b/assets/css/score.css @@ -1,69 +1,73 @@ -#score-counter { - display: block; - height: 200px; + +#mobile-score { + display: none; } -#score-counter #title-image { +#mobile-score .title-image { height: 100px; margin: 0; } - -#score-container { - display: block; +#mobile-score .score-display { + background: #1c1c1c; + box-shadow: 0 0 5px #000; } +#top-bar-score { + display: inline-flex; + position: fixed; + right: 0; +} -#score-display { - background-color: #1C1C1C; - box-shadow: 0 0 20px #1C1C1C; +#top-bar-score .title-image { + height: 40px; + margin: 0; +} + +.score-display { + background: none; border-radius: 10px; display: inline-flex; vertical-align: center; font-family: 'Russo One', sans-serif; - height: 80px; + height: 40px; + margin: 0; } - -#score-display a { +.score-display a { display: inline-flex; vertical-align: middle; align-items: center; - height: 80px; + height: 40px; } -#score-usa, #score-urss { - font-size: 50px; +.score-usa, .score-urss { + font-size: 20px; + line-height: 40px; } -#score-usa{ +.score-usa{ color: #1a5dad; } -#score-urss{ +.score-urss{ color: #d72229; } -#score-separator{ - font-size: 70px; +.score-separator{ + font-size: 20px; } .score-logo { - height: 70px; - margin: 5px; + height: 30px; + margin: 0; } @media screen and (max-width: 480px) { - #score-counter #title-image { - height: 75px; - } - #score-separator{ - font-size: 50px; - } - .score-logo{ - height: 50px; - } - #score-usa, #score-urss { - font-size: 40px; + #top-bar-score { + display: none; + } + #mobile-score { + display: block; } } diff --git a/assets/css/style.css b/assets/css/style.css index 8d8a216..49b9cf6 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -190,11 +190,15 @@ Full-Width Styles pointer-events: auto; vertical-align: middle; height: 40px; - margin: 5px; + margin: 5px 0 5px 0; } #header-wrap .inner { - padding: 100px 10px 100px 10px; + padding: 100px 10px 30px 10px; +} + +.title-logo { + width: 200px; } #menu-title { diff --git a/classes/dao.php b/classes/dao.php index 01b5279..ecacc0d 100644 --- a/classes/dao.php +++ b/classes/dao.php @@ -4,6 +4,8 @@ class Dao { private $conn; + private $debug = false; + public function __construct($path_to_password) { $username = 'accueil_insa'; @@ -13,7 +15,7 @@ class Dao { $this->conn = new PDO($dsn, $username, $password, [PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8']); } catch (PDOException $e){ - die($e->getMessage()); + $this->debug = true; } } @@ -25,26 +27,31 @@ class Dao { } public function get_score_team($team){ - $sql = 'SELECT text, points FROM scores WHERE team = ?'; - $cursor = $this->conn->prepare($sql); - $cursor->execute([$team]); - return $cursor->fetchAll(PDO::FETCH_ASSOC); + if (!$this->debug) + { + $sql = 'SELECT text, points FROM scores WHERE team = ?'; + $cursor = $this->conn->prepare($sql); + $cursor->execute([$team]); + return $cursor->fetchAll(PDO::FETCH_ASSOC); + } + else + return 0; } public function save_scores($scores_json, $team){ -// var_dump($scores_json); -// var_dump($team); - $sql = 'DELETE FROM scores WHERE team = ?'; - $cursor = $this->conn->prepare($sql); - $cursor->execute([$team]); - - $array = json_decode($scores_json)->array; - foreach ($array as $value){ - $sql = 'INSERT INTO scores (text, points, team) VALUES (?, ?, ?)'; + if (!$this->debug) + { + $sql = 'DELETE FROM scores WHERE team = ?'; $cursor = $this->conn->prepare($sql); - $cursor->execute([$value->text, $value->points, $team]); - } + $cursor->execute([$team]); + $array = json_decode($scores_json)->array; + foreach ($array as $value){ + $sql = 'INSERT INTO scores (text, points, team) VALUES (?, ?, ?)'; + $cursor = $this->conn->prepare($sql); + $cursor->execute([$value->text, $value->points, $team]); + } + } } } diff --git a/includes/score_counter.php b/includes/score_counter.php index 8fe99b9..7b00350 100644 --- a/includes/score_counter.php +++ b/includes/score_counter.php @@ -1,31 +1,18 @@ -get_score_team($team) as $row) { - $points += $row['points']; - } - return $points; -} - -?> -
- -
- \ No newline at end of file diff --git a/includes/top_bar.html b/includes/top_bar.php similarity index 81% rename from includes/top_bar.html rename to includes/top_bar.php index 2278f3e..7d43e26 100644 --- a/includes/top_bar.html +++ b/includes/top_bar.php @@ -9,4 +9,8 @@ +
diff --git a/index.php b/index.php index 161ab7f..52e07fe 100644 --- a/index.php +++ b/index.php @@ -6,8 +6,6 @@ - - @@ -32,11 +30,6 @@
-
-
@@ -104,5 +97,4 @@ include("includes/sidenav.html");
- diff --git a/template.php b/template.php index 11fe13e..c8b9fba 100644 --- a/template.php +++ b/template.php @@ -1,3 +1,19 @@ +get_score_team($team) as $row) { + $points += $row['points']; + } + return $points; +} + +$scoreUSA = get_total_points('usa'); +$scoreURSS = get_total_points('urss'); +?> + @@ -36,7 +52,7 @@
@@ -47,6 +63,7 @@ include("includes/sidenav.html");