diff --git a/data/.hidden b/data/.hidden new file mode 100644 index 0000000..e69de29 diff --git a/run.py b/debug.py similarity index 100% rename from run.py rename to debug.py diff --git a/shop.py b/shop.py index e9be3ee..fa10336 100644 --- a/shop.py +++ b/shop.py @@ -410,20 +410,23 @@ def register(): @app.route('/profile', methods=['GET', 'POST']) def profile(): + if not session.get('logged_in'): + abort(401) error = None + user=get_username(session.get('user')) if request.method == 'POST': import re, string pattern = re.compile('[\W]+') password=password_hash(request.form['password']) if len(request.form['password'])<5: error="Password too short" - return render_template('profile.html', error=error) + return render_template('profile.html', error=error,user=user) g.db.execute('update users set pass=? where id=?', [password,session.get('user')]) g.db.commit() flash('successfully updated profile.') return redirect(url_for('profile')) - return render_template('profile.html', error=error) + return render_template('profile.html', error=error,user=user) diff --git a/static/script.js b/static/script.js index 1dfd807..b8115bc 100644 --- a/static/script.js +++ b/static/script.js @@ -28,3 +28,21 @@ function hidetoggle(name) { }} } } +function dropDown() { + document.getElementById("Dropdown").classList.toggle("show"); +} + +// Close the dropdown menu if the user clicks outside of it +window.onclick = function(event) { + if (!event.target.matches('.dropbtn')) { + + var dropdowns = document.getElementsByClassName("dropdown-content"); + var i; + for (i = 0; i < dropdowns.length; i++) { + var openDropdown = dropdowns[i]; + if (openDropdown.classList.contains('show')) { + openDropdown.classList.remove('show'); + } + } + } +} diff --git a/static/style.css b/static/style.css index eb40e93..026c2a7 100644 --- a/static/style.css +++ b/static/style.css @@ -23,3 +23,47 @@ td { height: 1.75em; } .error { background: #f0d6d6; padding: 0.5em; } .hidden { display: none; } .pointer { cursor: pointer; } + +/* dropdown */ + +.dropbtn { + color: #377ba8; + text-decoration: underline; + cursor: pointer; + font-weight: bold; + letter-spacing:-0.1em; +} + +/* Dropdown button on hover & focus */ +.dropbtn:hover, .dropbtn:focus { + background-color: #ccc; +} + +/* The container