diff --git a/src/controllers/profileController.js b/src/controllers/profileController.js
index f6d9032..5d75746 100644
--- a/src/controllers/profileController.js
+++ b/src/controllers/profileController.js
@@ -37,6 +37,7 @@ module.exports.get = async function(req, res){
user: userDB.user,
date: userDB.date,
tokes: userDB.tokes,
+ tokeCount: userDB.getTokeCount(),
img: userDB.img,
signature: userDB.signature,
bio: userDB.bio
diff --git a/src/schemas/userSchema.js b/src/schemas/userSchema.js
index 7051b30..4bd96d9 100644
--- a/src/schemas/userSchema.js
+++ b/src/schemas/userSchema.js
@@ -283,6 +283,20 @@ userSchema.methods.setFlair = async function(flair){
return flairDB;
}
+userSchema.methods.getTokeCount = function(){
+ //Set tokeCount to 0
+ var tokeCount = 0;
+
+ //For each toke command the user has used
+ this.tokes.forEach((commandCount) => {
+ //Add the count for that specific command to the total
+ tokeCount += commandCount;
+ });
+
+ //Return the amount of tokes recorded
+ return tokeCount;
+}
+
//note: if you gotta call this from a request authenticated by it's user, make sure to kill that session first!
userSchema.methods.killAllSessions = async function(reason = "A full log-out from all devices was requested for your account."){
//get authenticated sessions
diff --git a/src/views/profile.ejs b/src/views/profile.ejs
index 0783555..076a121 100644
--- a/src/views/profile.ejs
+++ b/src/views/profile.ejs
@@ -34,8 +34,15 @@ along with this program. If not, see
(edit)
<% } %> -tokes: <%- profile.tokes %> (Not yet implemented)
- + +tokes: <%- profile.tokeCount %>
+ + +!<%- toke %>: <%- count %>
+ <% }); %> +Signature: <%- profile.signature %>
<% if(selfProfile){ %> diff --git a/www/css/profile.css b/www/css/profile.css index 4490f0f..0f3e2fc 100644 --- a/www/css/profile.css +++ b/www/css/profile.css @@ -40,4 +40,32 @@ input.account-settings-password-reset{ a#account-settings-delete-button{ font-weight: bold; +} + +span.profile-toke-count{ + display: flex; + flex-direction: row; + width: fit-content; +} + +p.profile-toke-count{ + margin: 0; +} + +#profile-tokes{ + resize: vertical; + max-width: fit-content; + height: fit-content; + min-height: 1.5em; + max-height: 5.8em; + display: none; +} + +/*Little hacky but this keeps initial max-height from fucking up resizing*/ +#profile-tokes[style*="height"]{ + max-height: 40vh; +} + +.profile-toke{ + margin: 0.2em 1em; } \ No newline at end of file diff --git a/www/css/theme/movie-night.css b/www/css/theme/movie-night.css index 9279b3d..894b0c9 100644 --- a/www/css/theme/movie-night.css +++ b/www/css/theme/movie-night.css @@ -77,7 +77,7 @@ a:hover, i:hover{ a:active, i:active{ color: var(--focus0-alt1); - box-shadow: var(--focus-glow0-alt0); + text-shadow: var(--focus-glow0-alt0); } select{ @@ -196,10 +196,6 @@ div.channel-guide-entry{ box-shadow: 0.2em 0.2em 0.1em var(--bg1-alt0) inset; } -a.channel-guide-entry-item{ - color: var(--accent1); -} - span.channel-guide-entry-item{ background-color: var(--bg1-alt0); box-shadow: 0.2em 0.2em 0.1em black inset; diff --git a/www/js/profile.js b/www/js/profile.js index 5b26adc..ad128ca 100644 --- a/www/js/profile.js +++ b/www/js/profile.js @@ -155,6 +155,31 @@ class passwordResetPrompt{ } } +class tokeList{ + constructor(){ + this.tokeList = document.querySelector('#profile-tokes'); + this.tokeListLabel = document.querySelector('.profile-toke-count'); + this.tokeListToggleIcon = document.querySelector('#toggle-toke-list'); + console.log(this.tokeList) + + this.setupInput(); + } + + setupInput(){ + this.tokeListLabel.addEventListener('click', this.toggleTokeList.bind(this)); + } + + toggleTokeList(){ + if(this.tokeList.checkVisibility()){ + this.tokeList.style.display = "none"; + this.tokeListToggleIcon.classList.replace("bi-caret-down-fill","bi-caret-left-fill"); + }else{ + this.tokeList.style.display = "block"; + this.tokeListToggleIcon.classList.replace("bi-caret-left-fill","bi-caret-down-fill"); + } + } +} + class deleteAccountButton{ constructor(){ this.deleteLink = document.querySelector('#account-settings-delete-button'); @@ -197,5 +222,6 @@ class deleteAccountPopup{ new profileTextEditPrompt("signature"); new profileTextEditPrompt("bio", true); new profileImgEditPrompt(); +new tokeList(); new passwordResetPrompt(); new deleteAccountButton(); \ No newline at end of file