Skip to content

Commit

Permalink
YEAAAA BOIIIIIIII
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellstewart7 committed Dec 11, 2020
1 parent f658c7b commit 4a40977
Show file tree
Hide file tree
Showing 11 changed files with 119 additions and 54 deletions.
25 changes: 23 additions & 2 deletions public/profilePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ function getTutorIdFromURL() {
}

function toggleReviewModal() {
var modalBackdrop = document.getElementById('modal-backdrop');
var modalBackdrop = document.getElementById('review-modal-backdrop');
var modal = document.getElementById('add-review-modal');

//modalBackdrop.classList.toggle('hidden');
modalBackdrop.classList.toggle('hidden');
modal.classList.toggle('hidden');
}

Expand Down Expand Up @@ -68,10 +68,31 @@ function reviewModalAccept() {
}
});
reviewRequest.send(reqbody);

ratingTotal += Number(rating);
numberRatings += 1;
ratingAverage = ratingTotal / numberRatings;

var addingToEndOfTutorsSection = document.getElementById('average-rating-span');
addingToEndOfTutorsSection.textContent = ratingAverage + "/5";

toggleReviewModal();
}
}

var ratingArray = document.getElementsByClassName('review-rating');
var numberRatings = ratingArray.length;
console.log("ratingArray[0].textContent", ratingArray[0].textContent);
var ratingTotal = 0;
for (var i = 0; i < numberRatings; i++) {
ratingTotal += Number(ratingArray[i].textContent);
}
var ratingAverage = ratingTotal / numberRatings;
console.log("average rating:", ratingAverage);

var addingToEndOfTutorsSection = document.getElementById('average-rating-span');
addingToEndOfTutorsSection.textContent = ratingAverage + "/5";
console.log("text content:", addingToEndOfTutorsSection.textContent);

var createReviewButton = document.getElementById('add-review-button');
createReviewButton.addEventListener('click', toggleReviewModal);
Expand Down
4 changes: 2 additions & 2 deletions public/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ body {
bottom: 0;
left: 0;
right: 0;
z-index: 150;
z-index: 1500;
background-color: rgba(0, 0, 0, 0.85);
}

Expand All @@ -493,7 +493,7 @@ body {
bottom: 0;
left: 0;
right: 0;
z-index: 200;
z-index: 2000;
overflow: scroll;
}

Expand Down
4 changes: 3 additions & 1 deletion public/tutorProfileTemplate.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions public/tutorReviewTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ templates['tutorReview'] = template({"compiler":[8,">= 4.3.0"],"main":function(c

return "<div class=\"review-container\">\r\n <h2>Reviews:</h2>\r\n <div class=\"review\">\r\n <i class=\"fas fa-user\"></i>\r\n <h4>Reviewer Name: </h4><span class=\"review-name\"> "
+ alias4(((helper = (helper = lookupProperty(helpers,"reviewerName") || (depth0 != null ? lookupProperty(depth0,"reviewerName") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"reviewerName","hash":{},"data":data,"loc":{"start":{"line":5,"column":57},"end":{"line":5,"column":73}}}) : helper)))
+ "</span>\r\n <h4>Quality Rating: <span class=\"rating\">"
+ alias4(((helper = (helper = lookupProperty(helpers,"rating") || (depth0 != null ? lookupProperty(depth0,"rating") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"rating","hash":{},"data":data,"loc":{"start":{"line":6,"column":47},"end":{"line":6,"column":57}}}) : helper)))
+ "</span>\r\n <h4>Quality Rating: <span class=\"review-rating\">"
+ alias4(((helper = (helper = lookupProperty(helpers,"rating") || (depth0 != null ? lookupProperty(depth0,"rating") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"rating","hash":{},"data":data,"loc":{"start":{"line":6,"column":54},"end":{"line":6,"column":64}}}) : helper)))
+ "</span></h4>\r\n <hr></hr>\r\n <h4>Review:</h4>\r\n <span class=\"review-text\">"
+ alias4(((helper = (helper = lookupProperty(helpers,"reviewText") || (depth0 != null ? lookupProperty(depth0,"reviewText") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"reviewText","hash":{},"data":data,"loc":{"start":{"line":9,"column":32},"end":{"line":9,"column":46}}}) : helper)))
+ "</span>\r\n </div>\r\n</div>\r\n";
Expand Down
49 changes: 47 additions & 2 deletions public/tutorSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,18 @@ function insertTutorPreview(name, imageURL, hourlyRate, city, subject, year) {
}

var tutorPreviews = [];
var cityArray = document.getElementsByClassName('city-option');
var cities = [];
for (var i = 0; i < cityArray.length; i++) {
cities.push(cityArray[i].textContent);
}
console.log("cities:", cities);
var subjectArray = document.getElementsByClassName('subject-option');
var subjects = [];
for (var i = 0; i < subjectArray.length; i++) {
subjects.push(subjectArray[i].textContent);
}
console.log("subjects:", subjects);

function previewIsAcceptable(preview, filters) {

Expand All @@ -74,12 +85,16 @@ function previewIsAcceptable(preview, filters) {
}

if (filters.city) {
console.log("preview city:", preview.city.toLowerCase());
console.log("filter city", filters.city.toLowerCase());
if (preview.city.toLowerCase() !== filters.city.toLowerCase()) {
return false;
}
}

if (filters.subject) {
console.log("preview subject:", preview.subject.toLowerCase());
console.log("filter subject", filters.subject.toLowerCase());
if (preview.subject.toLowerCase() !== filters.subject.toLowerCase()) {
return false;
}
Expand Down Expand Up @@ -183,6 +198,18 @@ function modalClear() {
email.value = "";
}

function createCity(city) {
var newCityOption = document.createElement('option');
newCityOption.textContent = city;
return newCityOption;
}

function createSubject(subject) {
var newSubjectOption = document.createElement('option');
newSubjectOption.textContent = subject;
return newSubjectOption;
}

function modalAccept() {
console.log("modal accept has been clicked");
var url = document.getElementById('url-input').value.trim();
Expand Down Expand Up @@ -222,7 +249,7 @@ function modalAccept() {
tutorRequest.addEventListener('load', function (event) {
if (event.target.status === 200) {
var tutorPreviewTemplate = Handlebars.templates.tutorPreview;
var newTutorPreviewHTML = tutorPreviewTemplate({
var content = {
name: name,
imageURL: url,
hourlyRate: hourlyRate,
Expand All @@ -233,9 +260,27 @@ function modalAccept() {
experience: experience,
email: email,
reviewData: reviewData
});
}
if (cities.indexOf(content.city) == -1) {
var cityInHTML = document.getElementById('filter-city');
cityInHTML.appendChild(createCity(content.city));
cities.push(content.city);
}
if (subjects.indexOf(content.subject) == -1) {
var subjectInHTML = document.getElementById('filter-subject');
subjectInHTML.appendChild(createSubject(content.subject));
subjects.push(content.subject);
}

var newTutorPreviewHTML = tutorPreviewTemplate(content);
var tutorsSection = document.getElementById('tutors');
tutorsSection.insertAdjacentHTML('beforeend', newTutorPreviewHTML);

tutorPreviews = [];
var preloadedPreviews = document.getElementsByClassName('tutor');
for (var i = 0; i < preloadedPreviews.length; i++) {
tutorPreviews.push(saveCurrentPreviews(preloadedPreviews[i]));
}
}
else {
alert("Error adding tutor profile to database:" + event.target.response);
Expand Down
2 changes: 1 addition & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var path = require('path');
var express = require('express');
var exphbs = require('express-handlebars');
var app = express();
var port = process.env.PORT || 8121;
var port = process.env.PORT || 3281;

var tutorData = require('./tutorData');
//var tutorData = require('./tutorData.json');
Expand Down
55 changes: 24 additions & 31 deletions tutorData.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[
{
"name": "Jimmy Neutron",
"imageURL": "http://placekitten.com/480/480",
"imageURL": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQtIl4mv8vcfLKDDgqcR1WmKbDCvqWdnwCPhw&usqp=CAU",
"subject": "Math",
"city": "Corvallis",
"year": "Junior",
Expand All @@ -26,15 +26,31 @@
"reviewText": "sick bro"
},
{
"rating": "69",
"rating": "4",
"reviewerName": "Chengxi",
"reviewText": "Nice"
},
{
"rating": "5",
"reviewerName": "Mitchell Stewart",
"reviewText": "So good"
},
{
"rating": "4",
"reviewerName": "Mitchell Stewart Jr.",
"reviewText": "excellence"
},
{
"rating": "5",
"reviewerName": "Mitchell Stewart Jr. Jr.",
"reviewText": "excellence"
}
]
],
"_locals": {}
},
{
"name": "Cody Banks",
"imageURL": "http://placekitten.com/480/480",
"imageURL": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcT--OB3Ggc3seS7BkLTc1WCEqA66bIL_6w7UA&usqp=CAU",
"subject": "Computer Science",
"city": "West Linn",
"year": "Sophomore",
Expand Down Expand Up @@ -62,17 +78,12 @@
"rating": "1",
"reviewerName": "Please work",
"reviewText": "Please please please work you fucker"
},
{
"rating": "1",
"reviewerName": "AHHHHHHHH",
"reviewText": "Work"
}
]
},
{
"name": "Mitchell Stewart",
"imageURL": "http://placekitten.com/480/480",
"imageURL": "http://web.engr.oregonstate.edu/~stewamit/CS290/final-project-team-22/public/images/mitchell_pic.png",
"hourlyRate": "200",
"city": "West Linn",
"subject": "Economics",
Expand Down Expand Up @@ -100,29 +111,11 @@
"rating": "5",
"reviewerName": "Not Alex Vogt",
"reviewText": "excellence"
}
]
},
{
"name": "Swag McYeet",
"imageURL": "http://placekitten.com/480/480",
"hourlyRate": "500",
"city": "Woodinville",
"subject": "Math",
"year": "Senior",
"zoomURL": "yeetyeet.com",
"experience": "Not a lot tbh",
"email": "mitchthebeast844@yahoo.com",
"reviewData": [
{
"rating": "3",
"reviewerName": "Mitchell Stewart",
"reviewText": "Average at best"
},
{
"rating": "4",
"reviewerName": "Not Alex Vogt Jr.",
"reviewText": "He was an excellent tutor ;)"
"rating": "5",
"reviewerName": "Test Dummy",
"reviewText": "Should move rating to 4.8"
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion views/partials/tutorProfile.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<hr></hr>
<h4>Work Experience: </h4><span class="experience">{{experience}}</span>
<hr></hr>
<h4>Quality Rating: </h4><span class="rating">4.9/5 Stars</span>
<h4>Quality Rating: </h4><span class="rating"></span>
<hr></hr>
<h4>Hourly Rate: </h4><span class="price">{{hourlyRate}}</span>
</div>
Expand Down
2 changes: 1 addition & 1 deletion views/partials/tutorReview.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="review">
<i class="fas fa-user"></i>
<h4>Reviewer Name: </h4><span class="review-name"> {{reviewerName}}</span>
<h4>Quality Rating: <span class="rating">{{rating}}</span></h4>
<h4>Quality Rating: <span class="review-rating">{{rating}}</span></h4>
<hr></hr>
<h4>Review:</h4>
<span class="review-text">{{reviewText}}</span>
Expand Down
4 changes: 4 additions & 0 deletions views/profilePage.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,8 @@
</div>
</div>

<div class="average-rating-div">
<p id="average-rating-span">Text</p>
</div>

</main>
22 changes: 11 additions & 11 deletions views/tutorSearch.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
<label for="filter-city" class="filter-input-label">City</label>
<div class="filter-input-element">
<select id="filter-city" class="filter-input" name="filter-city">
<option selected value="">Any</option>
<option>Corvallis</option>
<option>West Linn</option>
<option>Mason's Hometown</option>
<option>Chengxi's Hometown</option>
<option>Woodinville</option>
<option class="city-option" selected value="">Any</option>
<option class="city-option">Corvallis</option>
<option class="city-option">West Linn</option>
<option class="city-option">Mason's Hometown</option>
<option class="city-option">Chengxi's Hometown</option>
<option class="city-option">Woodinville</option>
</select>
</div>
</div>
Expand All @@ -39,11 +39,11 @@
<label for="filter-subject" class="filter-input-label">Subject</label>
<div class="filter-input-element">
<select id="filter-subject" class="filter-input" name="filter-subject">
<option selected value="">Any</option>
<option>Math</option>
<option>Computer Science</option>
<option>History</option>
<option>Economics</option>
<option class="subject-option" selected value="">Any</option>
<option class="subject-option">Math</option>
<option class="subject-option">Computer Science</option>
<option class="subject-option">History</option>
<option class="subject-option">Economics</option>
</select>
</div>
</div>
Expand Down

0 comments on commit 4a40977

Please sign in to comment.