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://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></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 src="scripts/blogArticles.js" type="text/javascript"> </script>
<script src="scripts/article.js" type="text/javascript"> </script>
</body>
</html>
12 changes: 11 additions & 1 deletion starter-code/scripts/article.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ function Article (options) {
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;
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() {
Expand All @@ -19,10 +24,15 @@ Article.prototype.toHtml = function() {
3. article title
4. article body
5. publication*/
$newArticle.find('h1').html(this.title);
$newArticle.find('a').attr('href', this.authorUrl);
$newArticle.find('a').html(this.author);
$newArticle.find('section.article-body').html(this.body);
$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.removeClass('template');
return $newArticle;
};

Expand Down