work finished through 2b on exercise checklist

main
Jason 3 years ago
parent b18ee4e062
commit 8673a7fdad

@ -19,11 +19,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge"> <meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Hack or Snooze</title> <title>Hack or Snooze</title>
<link <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css"
rel="stylesheet" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
href="https://use.fontawesome.com/releases/v5.3.1/css/all.css"
integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU"
crossorigin="anonymous">
<link rel="stylesheet" href="css/site.css"> <link rel="stylesheet" href="css/site.css">
<link rel="stylesheet" href="css/user.css"> <link rel="stylesheet" href="css/user.css">
<link rel="stylesheet" href="css/stories.css"> <link rel="stylesheet" href="css/stories.css">
@ -32,89 +29,91 @@
<body> <body>
<!-- top navigation bar --> <!-- top navigation bar -->
<nav> <nav>
<div class="navbar-brand"> <div class="navbar-brand">
<a class="nav-link" href="#" id="nav-all">Hack or Snooze</a> <a class="nav-link" href="#" id="nav-all">Hack or Snooze</a>
</div>
<div class="nav-center">
<a class="nav-link" href="#" id="nav-submit">submit</a>
</div>
<div class="nav-right">
<a class="nav-link" href="#" id="nav-login">login/signup</a>
<a class="nav-link" href="#" id="nav-user-profile"></a>
<a class="hidden" id="nav-logout" href="#"><small>(logout)</small></a>
</div>
</nav>
<!-- area for stories (all stories, user stories, favorites) -->
<section class="stories-container container">
<!-- loading message (removed by JS after stories loaded) -->
<div id="stories-loading-msg">Loading&hellip;</div>
<!-- List of all stories -->
<ol id="all-stories-list" class="stories-list"></ol>
</section>
<!-- Login and signup forms -->
<section class="account-forms-container container">
<form id="add-story-form" class="add-story hidden">
<h4>Add a story</h4>
<label for="story-title">Title: </label>
<input id="story-title" type="text">
<label for="story-author">Author: </label>
<input id="story-author" type="text">
<label for="story-url">URL: </label>
<input id="story-url" type="text">
<button type="submit">submit story</button>
</form>
<!-- Login form -->
<form id="login-form" class="account-form hidden">
<h4>Login</h4>
<div class="login-input">
<label for="login-username">username</label>
<input id="login-username" autocomplete="current-username">
</div> </div>
<div class="login-input"> <div class="nav-center">
<label for="login-password">password</label> <a class="nav-link" href="#" id="nav-submit">submit</a>
<input id="login-password" type="password" autocomplete="current-password">
</div> </div>
<button type="submit">login</button> <div class="nav-right">
<hr> <a class="nav-link" href="#" id="nav-login">login/signup</a>
</form> <a class="nav-link" href="#" id="nav-user-profile"></a>
<a class="hidden" id="nav-logout" href="#"><small>(logout)</small></a>
<!-- Signup form -->
<form id="signup-form" class="account-form hidden">
<h4>Create Account</h4>
<div class="login-input">
<label for="signup-name">name</label>
<input id="signup-name" autocapitalize="words">
</div> </div>
<div class="login-input"> </nav>
<label for="signup-username">username</label>
<input id="signup-username" autocomplete="new-username"> <!-- area for stories (all stories, user stories, favorites) -->
</div> <section class="stories-container container">
<div class="login-input">
<label for="signup-password">password</label> <!-- loading message (removed by JS after stories loaded) -->
<input id="signup-password" autocomplete="new-password" type="password"> <div id="stories-loading-msg">Loading&hellip;</div>
</div>
<button type="submit">create account</button> <!-- List of all stories -->
</form> <ol id="all-stories-list" class="stories-list"></ol>
</section>
</section>
<!-- Library JS & our JS -->
<script src="https://unpkg.com/jquery"></script> <!-- Login and signup and add story forms -->
<script src="https://unpkg.com/axios/dist/axios.js"></script> <section class="account-forms-container container">
<script src="js/models.js"></script> <!--add story form-->
<script src="js/main.js"></script> <form id="add-story-form" class="add-story hidden">
<script src="js/nav.js"></script> <h4>Add a story</h4>
<script src="js/user.js"></script> <label for="story-title">Title: </label>
<script src="js/stories.js"></script> <input id="story-title" type="text">
<label for="story-author">Author: </label>
<input id="story-author" type="text">
<label for="story-url">URL: </label>
<input id="story-url" type="text">
<button type="submit">submit story</button>
</form>
<!-- Login form -->
<form id="login-form" class="account-form hidden">
<h4>Login</h4>
<div class="login-input">
<label for="login-username">username</label>
<input id="login-username" autocomplete="current-username">
</div>
<div class="login-input">
<label for="login-password">password</label>
<input id="login-password" type="password" autocomplete="current-password">
</div>
<button type="submit">login</button>
<hr>
</form>
<!-- Signup form -->
<form id="signup-form" class="account-form hidden">
<h4>Create Account</h4>
<div class="login-input">
<label for="signup-name">name</label>
<input id="signup-name" autocapitalize="words">
</div>
<div class="login-input">
<label for="signup-username">username</label>
<input id="signup-username" autocomplete="new-username">
</div>
<div class="login-input">
<label for="signup-password">password</label>
<input id="signup-password" autocomplete="new-password" type="password">
</div>
<button type="submit">create account</button>
</form>
</section>
<!-- Library JS & our JS -->
<script src="https://unpkg.com/jquery"></script>
<script src="https://unpkg.com/axios/dist/axios.js"></script>
<script src="js/models.js"></script>
<script src="js/main.js"></script>
<script src="js/nav.js"></script>
<script src="js/user.js"></script>
<script src="js/stories.js"></script>
</body> </body>
</html> </html>

@ -77,16 +77,16 @@ class StoryList {
console.log("addStory called"); console.log("addStory called");
console.log("user.loginToken = ", user.loginToken); console.log("user.loginToken = ", user.loginToken);
const response = await axios.post( const response = await axios.post(
`${BASE_URL}/stories`, `${BASE_URL}/stories`,
{ token: user.loginToken, story: newStory } { token: user.loginToken, story: newStory }
); );
console.log("the response is : ", response); console.log("the response is : ", response);
return new Story(response.data.story); return new Story(response.data.story);
} }
} }

@ -73,13 +73,17 @@ async function getNewStoryAndSubmit(evt) {
title: title, title: title,
author: author, author: author,
url: url url: url
} };
// instantiate a Story with obj and display on page // instantiate a Story with obj and display on page
const resultOfAddStoryCall = await storyList.addStory(currentUser, newStory); const resultOfAddStoryCall = await storyList.addStory(currentUser, newStory);
console.log("resultOfAddStoryCall: ", resultOfAddStoryCall); console.log("resultOfAddStoryCall: ", resultOfAddStoryCall);
hidePageComponents(); hidePageComponents();
putStoriesOnPage(); await getAndShowStoriesOnStart();
//resets form with empty values
$addStoryForm.trigger("reset");
} }
//event listener for add story form submit
$addStoryForm.on("submit", getNewStoryAndSubmit); $addStoryForm.on("submit", getNewStoryAndSubmit);
Loading…
Cancel
Save