Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions starter-code/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<link rel="stylesheet" href="styles/modules.css">
<!-- Code Fellows favicon -->
<link rel="icon" type="image/x-icon" href="https://i.imgur.com/7v5ASc8.png">
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.12.4.min.js"></script>
</head>
<body>
<header class="site-header clearfix">
Expand Down Expand Up @@ -47,5 +48,7 @@ <h1>Title</h1>
&copy; 2016 Code Fellows | Static Blog | Happy Ipsum!
</footer>
<!-- // TODO: Intentionally vague: include all necessary script tags, in proper order! -->
<script type="text/javascript" src="scripts/blogArticles.js"></script>
<script type="text/javascript" src="scripts/article.js"></script>
</body>
</html>
29 changes: 22 additions & 7 deletions starter-code/scripts/article.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,38 @@ function Article (options) {
new Object according to this new definition. options is
a placeholder for the object that will ultimately be
passed in. Use all of the properties in blogArticles
to populate the new Article data that we'll use. */
this.title = options.title;
to populate the new Article data that we'll use.
DONE */
this.title = options.title;
this.category = options.category;
this.author = options.author;
this.authorUrl = options.authorUrl;
this.publishedOn = options.publishedOn;
this.body = options.body;
};

Article.prototype.toHtml = function() {
var $newArticle = $('article.template').clone();
$newArticle.attr('data-category', this.category);
$newArticle.find('a').text(this.author);
$newArticle.find('a').attr('href', this.authorUrl);
$newArticle.find('h1').text(this.title);
$newArticle.find('section').append(this.body);
$newArticle.find('time').text(this.publishedOn);
// $newArticle.attr('datetime', this.publishedOn);

/* TODO: We also need to fill in:
1. author name
2. author url
3. article title
4. article body
5. publication*/
DONE
1. author name done
2. author url done
3. article title done
4. article body done
5. publication done*/
$newArticle.find('time[pubdate]').attr('title', this.publishedOn);
$newArticle.find('time').text('about ' + parseInt((new Date() - new Date(this.publishedOn))/60/60/24/1000) + ' days ago');
/* TODO: This cloned article is no longer a template, as it now
has real data attached to it. Remove the class from this new article! */
$newArticle.removeAttr('class');
return $newArticle;
};

Expand Down