Skip to content

Develop#1

Open
phnsh wants to merge 7 commits intomasterfrom
develop
Open

Develop#1
phnsh wants to merge 7 commits intomasterfrom
develop

Conversation

@phnsh
Copy link
Copy Markdown
Owner

@phnsh phnsh commented Apr 30, 2019

Refactored the /homepage and /profilepage code

tweetContent.apply(this[2]);
}

var updateDOM = function() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just the profile info and not the whole DOM manipulation. Use more specific function names

Comment thread homepage/homepage.html Outdated
<div>
<div class="banner"></div>
<div class="profilepic">
<div><img src="img/profile.png"></div>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary div tags in many places

var div = '';
var rightbottom = document.querySelector(".rightbottom");
for(var i in data) {
var div = div + `<div class="indposts">
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing image

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JSON response does not have an image in it, otherwise I would implement it.

"https://fsd1.herokuapp.com/users/1/followers/suggestions",
"https://fsd1.herokuapp.com/users/1/following/tweets"];

var consolidate = urls.map(url => fetch(url).then(res => res.json()));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a .catch statement to handle promise rejection errors.

"https://fsd1.herokuapp.com/users/1/following"];

var consolidate = urls.map(url => fetch(url).then(res => res.json()));
Promise.all(consolidate).then(data => acceptURLs.call(data));//.then(res => console.log(res));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always make it a point to add .catch so that you handle the errors that might arise.

var photosAndVideos = document.querySelector(".photosAndVideos");
div = '';
for(var i = 0; i < 9; i++) {
var div = div + `<div class="mediaSquare"></div>`;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is where template strings come in. In most cases when you are joining two strings as above, you can replace it with template strings.

div = ${div} <div class="mediaSquare"></div>;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try identifying other places where you could use template strings.

var month = months[date.getMonth() + 1];
var day = date.getDate();
var year = date.getFullYear();
return day + " " + month + " " + year;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be a good place to use template strings.

Comment thread script/script.js
document.getElementById("login").style.display="block";
}

function closeDialog() {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While closing the dialog also remove any dom messages you would have added there.
If there is a message saying "incorrect credentials" just before closing the dialog, the same message should not reappear when the user reopens it.

Comment thread script/script.js

function closeDialog() {
document.getElementById("signup").style.display="none";
document.getElementById("login").style.display="none";
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of closing both dialogs, prefer having separate methods for closing each or make a utility function for closing the dialogs.

Comment thread script/script.js
//isItTrue.someval1.call(smg);
isItTrue.someval1(submitButtonEnabled);
document.querySelector("#signupform > button").disabled = false;
document.querySelector("#signupform span:nth-child(" + nthChild + ")").innerHTML = '';
Copy link
Copy Markdown
Collaborator

@fullstackgl fullstackgl May 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use nth-child unless actually necessary. This can be better handled using id selectors.

The reason nth-child is not recommended is that if you add another element in between, you would have to find and fix the parameters of all the elements after it.

Comment thread style/style.css
transform: translate(-50%,-200%);
}

#loginButton {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer sticking to one format of naming CSS selectors.
Either use snake_case_like_this or camelCase.

Comment thread script/script.js
method: "POST",
body: JSON.stringify(user)
}
var resp = fetch('https://fsd1.herokuapp.com/users/login',
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a .catch error handler in case the API call itself fails. This applies to all fetch requests(promises) that you create.

Comment thread script/script.js
}

let isItTrue = function() {
value1 = false;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use more descriptive variable names instead of just value1, value2.

cursor: pointer;
}

.modalContent div:nth-child(3) button:nth-child(1):hover {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nesting CSS nth-child selectors is neither preferable nor recommended.

Comment thread index.html
<input type="email" name="email" placeholder="E-mail" required>
<input type="password" name="password" placeholder="Password" required minlength="8">
<input type="password" name="confirmpassword" placeholder="confirm Password" required>
<form name="signupform" id="signupform" method="POST" onsubmit="signupUser()">
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up is not working. This function isn't defined.

</form>
<div style="position: absolute; bottom: 10px; padding: 10px;">
<button onclick="closeEditProfile()">Cancel</button>
<button onclick="closeEditProfile()">Save</button>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have to perform the same validations and make an API call to save these updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants