From 44756b1a525c225438c4eb817fa52196a0255753 Mon Sep 17 00:00:00 2001 From: BelPE Date: Fri, 2 Dec 2022 14:41:14 +0800 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=BD=D1=84=D0=BE=D1=80=D0=BC=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D1=8F=20=D0=BF=D0=BE=20=D1=82=D1=80=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=80=D0=BE=D0=B2=D0=BA=D0=B0=D0=BC=20=D0=B2=D1=8B=D0=B2?= =?UTF-8?q?=D0=BE=D0=B4=D0=B8=D1=82=D1=81=D1=8F=20=D0=BF=D0=BE=20=D0=BD?= =?UTF-8?q?=D0=B0=D0=B6=D0=B0=D1=82=D0=B8=D1=8E=20Enter;=20=D0=98=D0=B7?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D1=8B=20=D0=B7=D0=B0=D0=BF=D1=80?= =?UTF-8?q?=D0=BE=D1=81=D1=8B=20=D0=B2=20=D0=91=D0=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- getData1.php | 57 ++++++ getData2.php | 57 ++++++ src/scripts/workout.js | 125 ++++++++++++++ src/styles/style.css | 33 ++++ src/styles/styleMobile.css | 32 ++++ workout.html | 323 ++-------------------------------- workout.php | 345 ------------------------------------- 7 files changed, 317 insertions(+), 655 deletions(-) create mode 100644 getData1.php create mode 100644 getData2.php create mode 100644 src/scripts/workout.js delete mode 100644 workout.php diff --git a/getData1.php b/getData1.php new file mode 100644 index 0000000..850c073 --- /dev/null +++ b/getData1.php @@ -0,0 +1,57 @@ +"; + echo '' . $row["week"] . ''; + echo ""; + echo ""; + echo '[' . $row["date"] . '] ' . $row["day_name"] . ''; + echo ""; + echo ''; + echo 'Упражнение'; + echo 'Группа мышц'; + echo 'Время/подходы'; + echo 'Вес'; + $last_day = $row["day_name"]; + $day_count = 1; + } + if ($row["day_name"] != $last_day) { + $last_day = $row["day_name"]; + echo ""; + echo '[' . $row["date"] . '] ' . $row["day_name"] . ''; + echo ""; + } + $tr = ''; + if ($row_count / 2 != 0) { + $tr = ''; + } else { + $tr = ''; + } + echo $tr; + echo ''. $row["exercise"] .''; + echo '' . $row["muscle_group_name"] . ''; + echo '' . $row["sets_count"] . ''; + echo '' . $row["weigth"] . ''; + echo ''; + } + //echo "Итого:" . mysqli_num_rows($result) . ""; + mysqli_free_result($result); + } else{ + echo "Ошибка: " . mysqli_error($conn); + } + mysqli_close($conn); + +?> \ No newline at end of file diff --git a/getData2.php b/getData2.php new file mode 100644 index 0000000..b03523b --- /dev/null +++ b/getData2.php @@ -0,0 +1,57 @@ +"; + echo '' . $row["week"] . ''; + echo ""; + echo ""; + echo '[' . $row["date"] . '] ' . $row["day_name"] . ''; + echo ""; + echo ''; + echo 'Упражнение'; + echo 'Группа мышц'; + echo 'Время/подходы'; + echo 'Вес'; + $last_day = $row["day_name"]; + $day_count = 1; + } + if ($row["day_name"] != $last_day) { + $last_day = $row["day_name"]; + echo ""; + echo '[' . $row["date"] . '] ' . $row["day_name"] . ''; + echo ""; + } + $tr = ''; + if ($row_count / 2 != 0) { + $tr = ''; + } else { + $tr = ''; + } + echo $tr; + echo ''. $row["exercise"] .''; + echo '' . $row["muscle_group_name"] . ''; + echo '' . $row["sets_count"] . ''; + echo '' . $row["weigth"] . ''; + echo ''; + } + //echo "Итого:" . mysqli_num_rows($result) . ""; + mysqli_free_result($result); + } else{ + echo "Ошибка: " . mysqli_error($conn); + } + mysqli_close($conn); + +?> \ No newline at end of file diff --git a/src/scripts/workout.js b/src/scripts/workout.js new file mode 100644 index 0000000..99a5f10 --- /dev/null +++ b/src/scripts/workout.js @@ -0,0 +1,125 @@ +$(document).ready(function() { + $('#nick-btn').click(function(){ + getData(); + }); + $("#nickname-input").keyup(function(event){ + if(event.keyCode == 13){ + getData(); + } + }); +}); + +// TODO Доделать! + + +function getData() { + if (($('#nickname-input').val() == '')) { + alert("Не указан ник!"); + } else { + var username = $('#nickname-input').val().trim(); + $.ajax({ + url:"getData1.php", + type: 'POST', + data: {user: username}, + success: function(msg){ + if (!(msg == '')) { + $('#wt1').empty(); + $('#wt1').css("display","block"); + $('#wt1').append(msg); + } else { + console.log(msg); + alert('Пользователь не найден!'); + return; + } + } + }); + $.ajax({ + url:"getData2.php", + type: 'POST', + data: {user: username}, + success: function(msg2){ + if (!(msg2 == '')) { + $('#wt2').empty(); + $('#wt2').css("display","block"); + $('#wt2').append(msg2); + } else { + console.log(msg2); + alert('Пользователь не найден!'); + return; + } + } + }); + } + window.setTimeout(function(){TodayIsTheDay();}, 2000); +} + +function TodayIsTheDay(){ + var now = new Date(); + var sNow = now.toString(); + let nowDate = parseDate(sNow); + let headers = document.getElementsByClassName('day-name'); + for (let i = 0; i < headers.length; i++){ + let sDate = getDate(headers[i].textContent); + if (sDate === nowDate) { + headers[i].setAttribute('style', 'text-shadow: 0 0 10px #609A21,0 0 10px #609A21,0 0 30px #609A21,0 0 10px #609A21; '); + } + } +} + +function getDate(sText){ + var textC = Array.from(sText); + var sDate = ""; + var record = false; + for (var i = 0; i < textC.length; i++){ + if (textC[i] === '['){ + record = true; + } else if (textC[i] === ']') { + record = false; + } + if (record){ + sDate = sDate + textC[i]; + } + } + sDate = sDate.replace('[', ''); + sDate = sDate.replace(']', ''); + return sDate; +} + +function parseDate(sDate){ + var dateArr = sDate.split(' '); + var day = dateArr[2]; + var sMonth = dateArr[1]; + var month = ''; + if (sMonth == 'Jan') { + month = '01'; + } else if (sMonth == 'Jan') { + month = '01'; + } else if (sMonth == 'Feb') { + month = '02'; + } else if (sMonth == 'Mar') { + month = '03'; + } else if (sMonth == 'Apr') { + month = '04'; + } else if (sMonth == 'May') { + month = '05'; + } else if (sMonth == 'Jun') { + month = '06'; + } else if (sMonth == 'Jul') { + month = '07'; + } else if (sMonth == 'Aug') { + month = '08'; + } else if (sMonth == 'Sep') { + month = '09'; + } else if (sMonth == 'Oct') { + month = '10'; + } else if (sMonth == 'Nov') { + month = '11'; + } else if (sMonth == 'Dec') { + month = '12'; + } else { + month = '01'; + } + var year = dateArr[3]; + var date = day + '.' + month + '.' + year; + return date; +} \ No newline at end of file diff --git a/src/styles/style.css b/src/styles/style.css index 27e0c4a..29300d8 100644 --- a/src/styles/style.css +++ b/src/styles/style.css @@ -411,4 +411,37 @@ h2 { text-align: center; grid-area: signin-form; padding-bottom: 20px; +} + +.nickname-form { + text-align:center; +} + +.nickname-input { + text-align: center; + width: 30%; + margin-left: 2em; + margin-bottom: 5px; + font-family: segoe print; + font-size: 16px; +} + +.nickname-button { + margin-left: 2em; + background-color: #609A21; + border: none; + border-radius: 5px; + width: 30%; + color: #E0E0E0; + font-family: segoe print; + font-size: 16px; + margin-top: 5px; +} + +#wt1 { + display: none; +} + +#wt2 { + display: none; } \ No newline at end of file diff --git a/src/styles/styleMobile.css b/src/styles/styleMobile.css index be66e26..84159b3 100644 --- a/src/styles/styleMobile.css +++ b/src/styles/styleMobile.css @@ -393,4 +393,36 @@ h2 { text-align: center; grid-area: signin-form; padding-bottom: 20px; +} +.nickname-form { + text-align:center; +} + +.nickname-input { + text-align: center; + width: 40%; + margin-left: 2em; + margin-bottom: 5px; + font-family: segoe print; + font-size: 14px; +} + +.nickname-button { + margin-left: 2em; + background-color: #609A21; + border: none; + border-radius: 5px; + width: 40%; + color: #E0E0E0; + font-family: segoe print; + font-size: 14px; + margin-top: 5px; +} + +#wt1 { + display: none; +} + +#wt2 { + display: none; } \ No newline at end of file diff --git a/workout.html b/workout.html index 8d8d7c2..7907b35 100644 --- a/workout.html +++ b/workout.html @@ -4,10 +4,11 @@ Dhaverd - - + + - + +