Correction favorite
This commit is contained in:
parent
dbf28b5afa
commit
d2e97c3348
@ -3,8 +3,8 @@
|
|||||||
namespace WebProjectFitness;
|
namespace WebProjectFitness;
|
||||||
|
|
||||||
class Config {
|
class Config {
|
||||||
const SITE_JS_VERSION = '1.04';
|
const SITE_JS_VERSION = '1.05';
|
||||||
const SITE_CSS_VERSION = '1.04';
|
const SITE_CSS_VERSION = '1.05';
|
||||||
|
|
||||||
const TITLE_HEADER = 'Fitness';
|
const TITLE_HEADER = 'Fitness';
|
||||||
const DESCRIPTION_HEADER = 'Site for find all the fitness exercise you need';
|
const DESCRIPTION_HEADER = 'Site for find all the fitness exercise you need';
|
||||||
|
@ -246,7 +246,7 @@ let Point = ( function () {
|
|||||||
let fav = favStorage[ $elem.data( "id" ) ];
|
let fav = favStorage[ $elem.data( "id" ) ];
|
||||||
|
|
||||||
main.html( `
|
main.html( `
|
||||||
<div data-id="${ $elem.data( "id" ) }" data-fav="false" class="right favorite">
|
<div data-id="${ $elem.data( "id" ) }" data-fav="${ fav ? "true" : "false" }" class="right favorite">
|
||||||
<img src="/img/${ fav ? "" : "no-" }favorite.png" alt="">
|
<img src="/img/${ fav ? "" : "no-" }favorite.png" alt="">
|
||||||
</div>
|
</div>
|
||||||
<h2>${ data.title }</h2>
|
<h2>${ data.title }</h2>
|
||||||
@ -275,10 +275,11 @@ let Point = ( function () {
|
|||||||
favStorage = {};
|
favStorage = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $elem.data( "fav" ) === "true" ) {
|
console.log( $elem );
|
||||||
|
if ( $elem.attr( "data-fav" ) === "true" ) {
|
||||||
favStorage[ $elem.data( "id" ) ] = false;
|
favStorage[ $elem.data( "id" ) ] = false;
|
||||||
$elem.find( "img" ).attr( "src", "/img/no-favorite.png" );
|
$elem.find( "img" ).attr( "src", "/img/no-favorite.png" );
|
||||||
$elem.data( "fav", "false" );
|
$elem.attr( "data-fav", "false" );
|
||||||
$.ajax( {
|
$.ajax( {
|
||||||
url: "/api/user/favorite-delete",
|
url: "/api/user/favorite-delete",
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@ -289,7 +290,7 @@ let Point = ( function () {
|
|||||||
} );
|
} );
|
||||||
} else {
|
} else {
|
||||||
favStorage[ $elem.data( "id" ) ] = true;
|
favStorage[ $elem.data( "id" ) ] = true;
|
||||||
$elem.data( "fav", "true" );
|
$elem.attr( "data-fav", "true" );
|
||||||
$elem.find( "img" ).attr( "src", "/img/favorite.png" );
|
$elem.find( "img" ).attr( "src", "/img/favorite.png" );
|
||||||
$.ajax( {
|
$.ajax( {
|
||||||
url: "/api/user/favorite-add",
|
url: "/api/user/favorite-add",
|
||||||
@ -400,7 +401,7 @@ $( document ).ready( () => {
|
|||||||
if ( favStorage[ id ] ) {
|
if ( favStorage[ id ] ) {
|
||||||
if ( exercisesStorage.hasOwnProperty( id ) ) {
|
if ( exercisesStorage.hasOwnProperty( id ) ) {
|
||||||
main.append( `
|
main.append( `
|
||||||
<div data-id="${ id }" data-fav="false" class="right favorite">
|
<div data-id="${ id }" data-fav="true" class="right favorite">
|
||||||
<img src="/img/favorite.png" alt="">
|
<img src="/img/favorite.png" alt="">
|
||||||
</div>
|
</div>
|
||||||
<h2>${ exercisesStorage[ id ].title }</h2>
|
<h2>${ exercisesStorage[ id ].title }</h2>
|
||||||
|
Loading…
Reference in New Issue
Block a user