-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
task4 #6
Open
ghost
wants to merge
11
commits into
master
Choose a base branch
from
task4
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
task4 #6
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
3a941a3
Add
yadamskaya 8a881f7
add
yadamskaya d2df6c4
add
yadamskaya 0ce08f7
add
yadamskaya e92c880
add
yadamskaya 6133232
add
yadamskaya f3cbbe1
add
yadamskaya 7f4c6d1
add
yadamskaya b916184
add
yadamskaya 0039053
add
yadamskaya b3d56b9
add
yadamskaya File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Marshmallows</title> | ||
<link rel="stylesheet" href="style.css"> | ||
</head> | ||
<body> | ||
<header> | ||
<div class="logo">Marshmallows</div> | ||
<div class="menu"> | ||
<a href="index.html" class="home">Home</a> | ||
<form action="" method="get" class="search"> | ||
<!--1search--> | ||
<input type="text" placeholder=" search by date..."> | ||
<!--2search--> | ||
<input type="text" placeholder=" search by name..."> | ||
<!--3search--> | ||
<input type="text" list="hashTag" placeholder=" search by hashTag..."> | ||
<datalist id="hashTag"> | ||
<option>#nature</option> | ||
<option>#food</option> | ||
<option>#coffe</option> | ||
<option>#flowers</option> | ||
</datalist> | ||
|
||
<button type="submit" class="button_search"><img src="images/search.png"/></button> | ||
</form> | ||
<a href="" class="sign_out">Sign out</a> | ||
</div> | ||
</header> | ||
<main> | ||
<div class="site_content"> | ||
<!--<!–1photo–>--> | ||
<!--<div class="photo_post">--> | ||
<!--<div class="post">--> | ||
<!--<div class="image_name_date">--> | ||
<!--<img class="post_image" src="images/103.png"/>--> | ||
<!--<p class="name">Murashko Yuliya</p>--> | ||
<!--<p class="date_post">06.03.2018</p>--> | ||
<!--</div>--> | ||
<!--</div>--> | ||
<!--<img class="photo" src="images/1_1.jpg">--> | ||
<!--<div class="entry">--> | ||
<!--<p class="description">Text...</p>--> | ||
<!--<p class="hashTag">#coffe</p>--> | ||
<!--<div class="like"> <p>Like: </p><p>author1, author2</p>--> | ||
<!--</div>--> | ||
<!--</div>--> | ||
<!--<button type="button" class="put_like"><img src="images/heart1.png" alt="like"/></button>--> | ||
<!--</div>--> | ||
|
||
<!--<button type="button" class="download"><b>...</b></button>--> | ||
|
||
</div> | ||
<div class="avatar"> | ||
<img class="avatar_image" src="images/101.png"/> | ||
<div class="name"> | ||
<p><b>Adamskaya Yuliya</b></p> | ||
<a href=""><i>Add post</i></a> | ||
<div class="line"></div> | ||
</div> | ||
</div> | ||
</main> | ||
<footer> | ||
<div class="logo_footer">Marshmallows</div> | ||
<div class="footer_icon"> | ||
<button type="button" class="vk"><img src="images/vk.png" alt="vk"/></button> | ||
<button type="button" class="email"><img src="images/email.png" alt="email"/></button> | ||
<button type="button" class="insta"><img src="images/insta.png" alt="instagram"/></button> | ||
</div> | ||
<p class="data">Adamskaya Yuliya 2 course 6 group<br>03.03.2018</p> | ||
</footer> | ||
<script src="DOM.js"></script> | ||
</body> | ||
</html> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,282 @@ | ||
var photoPosts = [{ | ||
id: '1', | ||
description: 'Text', | ||
createdAt: new Date('2018-03-01T23:00:00'), | ||
author: 'Adamskaya Yuliya', | ||
photoLink: 'images/1.jpg', | ||
hashTag: ['#hashtag_1'], | ||
like: ["author1", "author2"] | ||
}, { | ||
id: '2', | ||
description: 'Text', | ||
createdAt: new Date('2018-02-23T23:00:00'), | ||
author: 'Murashko Yuliya', | ||
photoLink: 'images/2.jpg', | ||
hashTag: ['#hashTag'], | ||
like: ["author1"] | ||
}, { | ||
id: '3', | ||
description: 'Text', | ||
createdAt: new Date('2018-02-28T23:00:00'), | ||
author: 'Ambrosyonok Marina', | ||
photoLink: 'images/3.jpg', | ||
hashTag: ['#hashtag_1'], | ||
like: ["author2"] | ||
}, { | ||
id: '4', | ||
description: 'Text', | ||
createdAt: new Date('2018-02-27T23:00:00'), | ||
author: 'Adamskaya Yuliya', | ||
photoLink: 'images/4.jpg', | ||
hashTag: ['#hashtag_1'], | ||
like: ["author1", "author2", "author3"] | ||
}, { | ||
id: '5', | ||
description: 'Text', | ||
createdAt: new Date('2018-02-20T23:00:00'), | ||
author: 'Adamskaya Yuliya', | ||
photoLink: 'images/5.jpg', | ||
hashTag: ['#hashtag_2'], | ||
like: ["author1", "author2"] | ||
}, { | ||
id: '6', | ||
description: 'Text', | ||
createdAt: new Date('2018-02-23T23:00:00'), | ||
author: 'Ambrosyonok Marina', | ||
photoLink: 'images/6.jpg', | ||
hashTag: ['#hashtag_10'], | ||
like: ["author1", "author2"] | ||
}, { | ||
id: '7', | ||
description: 'Text', | ||
createdAt: new Date('2018-02-23T23:00:00'), | ||
author: 'Adamskaya Yuliya', | ||
photoLink: 'images/7.jpg', | ||
hashTag: ['#hashTag'], | ||
like: ["author3"] | ||
}, { | ||
id: '8', | ||
description: 'Text', | ||
createdAt: new Date('2018-02-23T23:00:00'), | ||
author: 'Murashko Yuliya', | ||
photoLink: 'images/8.jpg', | ||
hashTag: ['#hashtag_1'], | ||
like: ["author2"] | ||
}, { | ||
id: '9', | ||
description: 'Text', | ||
createdAt: new Date('2018-02-23T23:00:00'), | ||
author: 'Adamskaya Yuliya', | ||
photoLink: 'images/9.jpg', | ||
hashTag: ['#hashtag_11'], | ||
like: ["author1", "author3"] | ||
}, { | ||
id: '10', | ||
description: 'Text', | ||
createdAt: new Date('2018-02-23T23:00:00'), | ||
author: 'Adamskaya Yuliya', | ||
photoLink: 'images/10.jpg', | ||
hashTag: ['#hashtag_5'], | ||
like: ["author1", "author2"] | ||
}, { | ||
id: '11', | ||
description: 'Text', | ||
createdAt: new Date('2018-03-01T23:00:00'), | ||
author: 'Adamskaya Yuliya', | ||
photoLink: 'images/11.jpg', | ||
hashTag: ['#hashtag_1'], | ||
like: ["author1", "author2"] | ||
}, { | ||
id: '12', | ||
description: 'Text', | ||
createdAt: new Date('2018-02-23T23:00:00'), | ||
author: 'Murashko Yuliya', | ||
photoLink: 'images/12.jpg', | ||
hashTag: ['#hashTag'], | ||
like: ["author1"] | ||
}, { | ||
id: '13', | ||
description: 'Text', | ||
createdAt: new Date('2018-02-28T23:00:00'), | ||
author: 'Ambrosyonok Marina', | ||
photoLink: 'images/13.jpg', | ||
hashTag: ['#hashtag_1'], | ||
like: ["author2"] | ||
}, { | ||
id: '14', | ||
description: 'Text', | ||
createdAt: new Date('2018-02-27T23:00:00'), | ||
author: 'Adamskaya Yuliya', | ||
photoLink: 'images/14.jpg', | ||
hashTag: ['#hashtag_1'], | ||
like: ["author1", "author2", "author3"] | ||
}, { | ||
id: '15', | ||
description: 'Text', | ||
createdAt: new Date('2018-02-20T23:00:00'), | ||
author: 'Adamskaya Yuliya', | ||
photoLink: 'images/15.jpg', | ||
hashTag: ['#hashtag_2'], | ||
like: ["author1", "author2"] | ||
}, { | ||
id: '16', | ||
description: 'Text', | ||
createdAt: new Date('2018-02-23T23:00:00'), | ||
author: 'Ambrosyonok Marina', | ||
photoLink: 'images/16.jpg', | ||
hashTag: ['#hashtag_10'], | ||
like: ["author1", "author2"] | ||
}, { | ||
id: '17', | ||
description: 'Text', | ||
createdAt: new Date('2018-02-23T23:00:00'), | ||
author: 'Adamskaya Yuliya', | ||
photoLink: 'images/17.jpg', | ||
hashTag: ['#hashTag'], | ||
like: ["author3"] | ||
}, { | ||
id: '18', | ||
description: 'Text', | ||
createdAt: new Date('2018-02-23T23:00:00'), | ||
author: 'Murashko Yuliya', | ||
photoLink: 'images/18.jpg', | ||
hashTag: ['#hashtag_1'], | ||
like: ["author2"] | ||
}, { | ||
id: '19', | ||
description: 'Text', | ||
createdAt: new Date('2018-02-23T23:00:00'), | ||
author: 'Adamskaya Yuliya', | ||
photoLink: 'images/19.jpg', | ||
hashTag: ['#hashtag_11'], | ||
like: ["author1", "author3"] | ||
}, { | ||
id: '20', | ||
description: 'Text', | ||
createdAt: new Date('2018-02-23T23:00:00'), | ||
author: 'Adamskaya Yuliya', | ||
photoLink: 'images/20.jpg', | ||
hashTag: ['#hashtag_5'], | ||
like: ["author1", "author2"] | ||
}]; | ||
|
||
var module = (function () { | ||
function compareDate(a, b) { | ||
return (a.createdAt) - (b.createdAt); | ||
} | ||
|
||
function getPhotoPosts(skip, top, filterConfig) { | ||
skip = skip || 0; | ||
top = top || 10; | ||
if (filterConfig === undefined) { | ||
return photoPosts.sort(compareDate).slice(skip, skip + top); | ||
} else { | ||
if (filterConfig.author !== undefined) { | ||
photoPosts = photoPosts.filter((element) => element.author === filterConfig.author); | ||
} | ||
if (filterConfig.hashTag !== undefined) { | ||
photoPosts = photoPosts.filter((element) => element.hashTag === filterConfig.hashTag); | ||
} | ||
return photoPosts.sort(compareDate).slice(skip, skip + top); | ||
} | ||
} | ||
|
||
function getPhotoPost(id) { | ||
return photoPosts.find((element) => element.id === id); | ||
} | ||
|
||
function validatePhotoPost(photoPost) { | ||
if (typeof(photoPost.id) !== "string" || typeof(photoPost.author) !== "string" || typeof(photoPost.description) !== "string" | ||
|| typeof(photoPost.photoLink) !== "string") { | ||
return false; | ||
} | ||
if (photoPost.id.trim() === "" || photoPost.author.trim() === "" || photoPost.description.trim() === "" || photoPost.photoLink.trim() === "" | ||
|| photoPost.hashTag.length === 0 || photoPost.like.length === 0) { | ||
return false; | ||
} | ||
for (var index = 0; index < photoPost.hashTag.length; index++) { | ||
if (typeof(photoPost.hashTag[index]) !== "string" || photoPost.hashTag[index].trim() === "") { | ||
return false; | ||
} | ||
} | ||
|
||
for (var index = 0; index < photoPost.like.length; index++) { | ||
if (typeof(photoPost.like[index]) !== "string" || photoPost.like[index].trim() === "") { | ||
return false; | ||
} | ||
} | ||
|
||
if (!photoPost.createdAt instanceof Date) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
function removePhotoPost(id) { | ||
var index = photoPosts.findIndex((element) => element.id === id); | ||
if (index) { | ||
photoPosts = photoPosts.splice(index, 1); | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
|
||
function addPhotoPost(objectPhotoPost) { | ||
if (validatePhotoPost(objectPhotoPost)) { | ||
photoPosts.push(objectPhotoPost); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
function editPhotoPost(id, objectPhotoPost) { | ||
if (!objectPhotoPost) { | ||
return false; | ||
} | ||
if (id === undefined || typeof id !== 'string') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typeof id !== 'string' этого будет достаточно |
||
return false; | ||
} | ||
var index = photoPosts.findIndex((element) => element.id === id); | ||
|
||
var post = photoPosts[index]; | ||
if (objectPhotoPost.photoLink !== undefined && objectPhotoPost.photoLink !== 0) { | ||
post.photoLink = objectPhotoPost.photoLink; | ||
} | ||
if (objectPhotoPost.description !== undefined && objectPhotoPost.description !== 0 && objectPhotoPost.description.length < 200) { | ||
|
||
post.description = objectPhotoPost.description; | ||
} | ||
if (objectPhotoPost.hashTag !== undefined && objectPhotoPost.hashTag.length > 0) { | ||
|
||
post.hashTag = objectPhotoPost.hashTag; | ||
} | ||
console.log(post); | ||
return true; | ||
|
||
} | ||
|
||
return { | ||
getPhotoPosts: getPhotoPosts, | ||
removePhotoPost: removePhotoPost, | ||
editPhotoPost: editPhotoPost, | ||
addPhotoPost: addPhotoPost, | ||
getPhotoPost: getPhotoPost | ||
} | ||
} | ||
) | ||
(); | ||
console.log(module.getPhotoPosts(0, 10)); | ||
console.log(module.getPhotoPosts(0, 10, {author: "Adamskaya Yuliya"})); | ||
console.log(module.getPhotoPost('9')); | ||
console.log(module.editPhotoPost('1', {hashTag: ['#hashtag_1', '#hashtag_8']})); | ||
console.log(module.addPhotoPost({ | ||
id: '21', | ||
description: 'Text', | ||
createdAt: new Date('2018-02-23T21:00:00'), | ||
author: 'Adamskaya Yuliya', | ||
photoLink: 'images/21.jpg', | ||
hashTag: ['#hashtag_1', '#hashtag_2'], | ||
like: ['author21'] | ||
})); | ||
console.log(module.removePhotoPost('4')); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Логика не соответствует той которая прописана в задании.