From d2e97c3348e887e495445a187363d0ef9bd80a23 Mon Sep 17 00:00:00 2001 From: Mathieu Sanchez Date: Sun, 16 Dec 2018 19:34:26 +0900 Subject: [PATCH] Correction favorite --- src/Config.php | 4 ++-- static/js/javascript.js | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Config.php b/src/Config.php index 90b55d0..bc6febf 100644 --- a/src/Config.php +++ b/src/Config.php @@ -3,8 +3,8 @@ namespace WebProjectFitness; class Config { - const SITE_JS_VERSION = '1.04'; - const SITE_CSS_VERSION = '1.04'; + const SITE_JS_VERSION = '1.05'; + const SITE_CSS_VERSION = '1.05'; const TITLE_HEADER = 'Fitness'; const DESCRIPTION_HEADER = 'Site for find all the fitness exercise you need'; diff --git a/static/js/javascript.js b/static/js/javascript.js index 387ef20..72a6c50 100644 --- a/static/js/javascript.js +++ b/static/js/javascript.js @@ -246,7 +246,7 @@ let Point = ( function () { let fav = favStorage[ $elem.data( "id" ) ]; main.html( ` -
+

${ data.title }

@@ -275,10 +275,11 @@ let Point = ( function () { favStorage = {}; } - if ( $elem.data( "fav" ) === "true" ) { + console.log( $elem ); + if ( $elem.attr( "data-fav" ) === "true" ) { favStorage[ $elem.data( "id" ) ] = false; $elem.find( "img" ).attr( "src", "/img/no-favorite.png" ); - $elem.data( "fav", "false" ); + $elem.attr( "data-fav", "false" ); $.ajax( { url: "/api/user/favorite-delete", method: "POST", @@ -289,7 +290,7 @@ let Point = ( function () { } ); } else { favStorage[ $elem.data( "id" ) ] = true; - $elem.data( "fav", "true" ); + $elem.attr( "data-fav", "true" ); $elem.find( "img" ).attr( "src", "/img/favorite.png" ); $.ajax( { url: "/api/user/favorite-add", @@ -400,7 +401,7 @@ $( document ).ready( () => { if ( favStorage[ id ] ) { if ( exercisesStorage.hasOwnProperty( id ) ) { main.append( ` -
+

${ exercisesStorage[ id ].title }