From 5307946ce62402ac7cf23aa1b0bf0770b49acc37 Mon Sep 17 00:00:00 2001 From: Fluffy Date: Fri, 23 Jun 2023 21:58:31 +0000 Subject: [PATCH] Update pfp preview on file uplaod --- TFR/server/__init__.py | 6 +--- TFR/server/static/sass/profile-settings.sass | 11 ++++++- TFR/server/static/sass/style.sass | 13 +++++++-- TFR/server/templates/error.html | 2 +- .../templates/views/account_settings.html | 29 +++++++++++++++---- TFR/server/templates/views/scores.html | 20 +++++-------- 6 files changed, 53 insertions(+), 28 deletions(-) diff --git a/TFR/server/__init__.py b/TFR/server/__init__.py index 053fc46..04a6baf 100644 --- a/TFR/server/__init__.py +++ b/TFR/server/__init__.py @@ -1,5 +1,3 @@ -from random import randint - from flask import Flask, render_template, abort from flask_assets import Bundle from werkzeug.exceptions import HTTPException @@ -53,8 +51,6 @@ def error_page(err): abort(500) return ( - render_template( - "error.html", error=err.code, msg=err.description, image=str(randint(1, 3)) - ), + render_template("error.html", error=err.code, msg=err.description), err.code, ) diff --git a/TFR/server/static/sass/profile-settings.sass b/TFR/server/static/sass/profile-settings.sass index 8219a87..4b613ac 100644 --- a/TFR/server/static/sass/profile-settings.sass +++ b/TFR/server/static/sass/profile-settings.sass @@ -12,6 +12,7 @@ flex-direction: column border: 1px solid RGBA($white, 0.1) + box-sizing: content-box > img height: 10rem @@ -67,7 +68,11 @@ gap: 0.5rem > .text-input - margin: 0 !important + margin: 0 + + > button + margin: 0 0 0 auto + width: auto @media (max-width: 621px) .profile-settings @@ -80,3 +85,7 @@ > img height: 13rem width: 13rem + + .other > button + margin: 0 + width: 100% \ No newline at end of file diff --git a/TFR/server/static/sass/style.sass b/TFR/server/static/sass/style.sass index fd0004f..716e30b 100644 --- a/TFR/server/static/sass/style.sass +++ b/TFR/server/static/sass/style.sass @@ -90,9 +90,16 @@ body padding: 0.5rem text-align: center - &.player - color: RGB($secondary) - text-shadow: 0 0 5px RGBA($secondary, 0.7) + > a + color: RGB($white) + text-decoration: none + + &#you + color: RGB($primary) + text-shadow: 0 0 5px RGBA($primary, 0.4) + + &:hover + text-decoration: underline > i padding: 0.25rem diff --git a/TFR/server/templates/error.html b/TFR/server/templates/error.html index 9dd1290..977574f 100644 --- a/TFR/server/templates/error.html +++ b/TFR/server/templates/error.html @@ -3,6 +3,6 @@

{{ error }}

{{ msg }}

- Error + Error
{% endblock %} \ No newline at end of file diff --git a/TFR/server/templates/views/account_settings.html b/TFR/server/templates/views/account_settings.html index 66ceb3e..5a450fb 100644 --- a/TFR/server/templates/views/account_settings.html +++ b/TFR/server/templates/views/account_settings.html @@ -8,9 +8,9 @@
{% if current_user.picture %} - Profile picture + Profile picture {% else %} - Profile picture + Profile picture {% endif %} @@ -60,9 +60,26 @@
- {% if not current_user.email %} - - {% endif %} + {% endif %} + + // Adjusted from https://stackoverflow.com/a/3814285/14885829 + document.getElementById('profile-picture').onchange = (event) => { + let tgt = event.target || window.event.srcElement, + files = tgt.files; + + if (FileReader && files && files.length) { + let fr = new FileReader(); + fr.onload = () => { + document.getElementById('picture-preview').src = fr.result; + } + fr.readAsDataURL(files[0]); + } + else { + addFlashMessage("Your browser could not show a preview of your profile picture!", "error") + } + } + {% endblock %} diff --git a/TFR/server/templates/views/scores.html b/TFR/server/templates/views/scores.html index 9f56813..336e62f 100644 --- a/TFR/server/templates/views/scores.html +++ b/TFR/server/templates/views/scores.html @@ -45,11 +45,8 @@ {% endif %}

{{ user.username }}

-

Joined {{ user.joined_at.strftime('%Y-%m-%d') }}

-
- -

Best score: {{ scores[0].score | format_result }}

+

Joined {{ user.joined_at|timesince }}

{% endif %} @@ -74,14 +71,13 @@ {% else %} {{ loop.index }} {% endif %} - - {% if score.users.id == current_user.id %} - {{ score.users.username }} - {% else %} - {{ score.users.username }} - {% endif %} - - {{ score.score | format_result }} + + {{ score.users.username }} + + {{ score.score|format_result }} {{ score.scored_at.strftime('%Y-%m-%d') }} {% endfor %}