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
25 changes: 20 additions & 5 deletions components/journal-entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@ class JournalEntry extends HTMLElement {
*/

// CODE GOES HERE
let article = this.shadowRoot.querySelector('.entry');

let title = this.shadowRoot.querySelector('.entry-title');
title.textContent = entry.title;

let date = this.shadowRoot.querySelector('.entry-date');
date.textContent = entry.date;

let content = this.shadowRoot.querySelector('.entry-content');
content.textContent = entry.content;

if (entry.image) {
let entryImage;
Expand All @@ -85,8 +95,11 @@ class JournalEntry extends HTMLElement {

// CODE GOES HERE vvv



let image = document.createElement('img');
image.className = 'entry-image';
image.src = entry.image.src;
image.alt = entry.image.alt;
article.appendChild(image);


// CODE GOES HERE ^^^
Expand All @@ -111,9 +124,11 @@ class JournalEntry extends HTMLElement {

// CODE GOES HERE vvv




let audio = document.createElement('audio');
audio.className = 'entry-audio';
audio.src = entry.audio;
audio.controls = true;
article.appendChild(audio);


// CODE GOES HERE ^^^
Expand Down
13 changes: 6 additions & 7 deletions scripts/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ document.addEventListener('DOMContentLoaded', () => {
* the current entry for each journal-entry element.
*/

let url = "" // SET URL
let url = "https://cse110lab6.herokuapp.com/entries" // SET URL

fetch(url)
.then( /* FILL IN RESPONSE HANDLING HERE */ )
.then( /* FILL IN RESPONSE HANDLING HERE */ response => response.json())
.then(entries => {
entries.forEach((entry) => {

Expand All @@ -28,11 +28,10 @@ document.addEventListener('DOMContentLoaded', () => {

// CODE GOES HERE vvv






let main = document.querySelector('main');
newPost = document.createElement('journal-entry');
newPost.entry = entry;
main.appendChild(newPost);


// CODE GOES HERE ^^^
Expand Down