diff --git a/src/Config.php b/src/Config.php index 894ce38..4281a4c 100644 --- a/src/Config.php +++ b/src/Config.php @@ -3,8 +3,8 @@ namespace WebProjectFitness; class Config { - const SITE_JS_VERSION = '1.00'; - const SITE_CSS_VERSION = '1.00'; + const SITE_JS_VERSION = '1.01'; + const SITE_CSS_VERSION = '1.01'; const TITLE_HEADER = 'Fitness'; const DESCRIPTION_HEADER = 'Site for find all the fitness exercise you need'; diff --git a/src/Model/BDD.php b/src/Model/BDD.php index b2ef0e0..ebae790 100644 --- a/src/Model/BDD.php +++ b/src/Model/BDD.php @@ -6,15 +6,15 @@ use Exception; use PDO; class BDD { -// const SQL_SERVER = 'web3.pulseheberg.net'; // BDD Server -// const SQL_LOGIN = 'why7n0_fitness'; // BDD Login -// const SQL_PASSWORD = 'KpB728zu'; // BDD Password -// const SQL_DB = 'why7n0_fitness'; // BDD Name + const SQL_SERVER = 'web3.pulseheberg.net'; // BDD Server + const SQL_LOGIN = 'why7n0_fitness'; // BDD Login + const SQL_PASSWORD = 'KpB728zu'; // BDD Password + const SQL_DB = 'why7n0_fitness'; // BDD Name - const SQL_SERVER = 'localhost'; // BDD Server - const SQL_LOGIN = 'root'; // BDD Login - const SQL_PASSWORD = ''; // BDD Password - const SQL_DB = 'fitness'; // BDD Name +// const SQL_SERVER = 'localhost'; // BDD Server +// const SQL_LOGIN = 'root'; // BDD Login +// const SQL_PASSWORD = ''; // BDD Password +// const SQL_DB = 'fitness'; // BDD Name private static $bdd; diff --git a/src/View/Site/tpl/head.php b/src/View/Site/tpl/head.php index 5f51f8d..3c4ddc4 100644 --- a/src/View/Site/tpl/head.php +++ b/src/View/Site/tpl/head.php @@ -46,7 +46,7 @@ diff --git a/static/js/javascript.js b/static/js/javascript.js index b4b301a..4b57dad 100644 --- a/static/js/javascript.js +++ b/static/js/javascript.js @@ -122,7 +122,11 @@ let Point = ( function () { // Click on a point not selected $( document ).on( "click", ".point:not(.selected)", ( elem ) => { let $elem = $( elem.target ); + let storageData = localStorage.getItem( "muscles" ); + if ( storageData ) { + storageData = JSON.parse( storageData ); + } $( ".point" ).each( ( i, e ) => { let $e = $( e ); @@ -131,27 +135,47 @@ let Point = ( function () { $elem.addClass( "selected" ); $( "#exercise-title" ).text( $elem.attr( "title" ) ); - $.ajax( { - url: "/api/muscles/get-list", - method: "POST", - data: { - muscle: $elem.data( "name" ) - }, - success: function ( data ) { - let c = $( "#exercises-container" ); + if ( storageData && storageData[ $elem.data( "name" ) ] ) { + let data = storageData[ $elem.data( "name" ) ]; + let c = $( "#exercises-container" ); - data = JSON.parse( data ); - localStorage.setItem( $elem.data( "name" ), data ); - c.empty(); - if ( data.length > 0 ) { - for ( let exercise of data ) { - c.append( `
${ exercise.title }
` ); - } - } else { - c.append( "
Please select a muscle
" ); + c.empty(); + if ( data.length > 0 ) { + for ( let exercise of data ) { + c.append( `
${ exercise.title }
` ); } + } else { + c.append( "
Please select a muscle
" ); } - } ); + } else { + $.ajax( { + url: "/api/muscles/get-list", + method: "POST", + data: { + muscle: $elem.data( "name" ) + }, + success: function ( data ) { + data = JSON.parse( data ); + + if ( storageData === null ) { + storageData = {}; + } + storageData[ $elem.data( "name" ) ] = data; + localStorage.setItem( "muscles", JSON.stringify( storageData ) ); + + let c = $( "#exercises-container" ); + + c.empty(); + if ( data.length > 0 ) { + for ( let exercise of data ) { + c.append( `
${ exercise.title }
` ); + } + } else { + c.append( "
Please select a muscle
" ); + } + } + } ); + } } ); // Click on a point selected @@ -167,19 +191,19 @@ let Point = ( function () { // Click on an exercise $( document ).on( "click", "#exercises-container div", ( elem ) => { let $elem = $( elem.target ); + let storageData = localStorage.getItem( "exercises" ); + if ( storageData ) { + storageData = JSON.parse( storageData ); + } else { + storageData = {}; + } if ( $elem.data( "id" ) ) { - $.ajax( { - url: "/api/muscles/get-exercise", - method: "POST", - data: { - id: $elem.data( "id" ), - }, - success: function ( data ) { - data = JSON.parse( data ); - let main = $( "#main-container" ); + if ( storageData[ $elem.data( "id" ) ] ) { + let data = storageData[ $elem.data( "id" ) ]; + let main = $( "#main-container" ); - main.html( ` + main.html( `

${ data.title }

+
${ ( data.description ? data.description : "" ) }
+
+ ` ); + } + } ); + } } } ); };