-
Notifications
You must be signed in to change notification settings - Fork 223
Project-Reddit Eval KF #226
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="utf-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
| <title>ReReddt</title> | ||
| <link | ||
| href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" | ||
| rel="stylesheet" | ||
| integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" | ||
| crossorigin="anonymous" | ||
| /> | ||
| <link rel="stylesheet" href="style.css" /> | ||
| </head> | ||
| <body> | ||
| <div class="row"> | ||
| <div class="col"></div> | ||
| <div class="col-5"> | ||
| <h1>ReReddit</h1> | ||
| <div class="posts lead"></div> | ||
| <div class="post-input"> | ||
| <h2>Make a Post</h2> | ||
| <form> | ||
| <div class="form-group post-submission"> | ||
| <input | ||
| type="text" | ||
| class="form-control" | ||
| id="postText" | ||
| placeholder="Your Text" | ||
| /> | ||
| </div> | ||
|
|
||
| <div class="form-group post-submission"> | ||
| <input | ||
| type="text" | ||
| class="form-control" | ||
| id="postName" | ||
| placeholder="Your Name" | ||
| /> | ||
| </div> | ||
| <button | ||
| type="button" | ||
| id="submitPost" | ||
| class="btn btn-primary float-start" | ||
| > | ||
| Submit | ||
| </button> | ||
| </form> | ||
| </div> | ||
| </div> | ||
| <div class="col"></div> | ||
| </div> | ||
| <script | ||
| src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" | ||
| integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" | ||
| crossorigin="anonymous" | ||
| ></script> | ||
| <script src="main.js"></script> | ||
| </body> | ||
| </html> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| function createPost(){ | ||
| const postText = document.getElementById("postText").value; | ||
| const postName = document.getElementById("postName").value; | ||
| const postsDiv = document.querySelector(".posts"); | ||
|
|
||
| const newPost = document.createElement("div"); | ||
| newPost.className = "d-inline-flex newPost"; | ||
|
|
||
|
|
||
|
|
||
| const newPostP = document.createElement("p"); | ||
| newPostP.innerHTML = `<a class='btn btn-link' id='commentsBtn'>comments</a> | ||
| <a class='btn btn-link' id='remove'>remove</a> | ||
| ${postText} - Posted By: ${postName} | ||
| <div name= "commentForm" class='commentForm collapse'> | ||
| <form class="comment-submission"> | ||
| <div name="commentSection"></div> | ||
| <div class='form-group' name='comment-input'> | ||
| <input type="text" class='form-control' name='commentText' placeholder ='Your Comment'> | ||
| </div> | ||
| <div class='form-group' name='name-input'> | ||
| <input type='text' class='form-control' name='commentName' placeholder='Your Name'> | ||
| </div> | ||
| <button type='button' id='submitComment' class='btn btn-primary float-start'>Submit</button> | ||
| </form> | ||
| </div>` | ||
| ; | ||
|
Comment on lines
+12
to
+27
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. check your indentation settings |
||
| newPost.appendChild(newPostP); | ||
| postsDiv.append(newPost) | ||
| } | ||
|
|
||
| document.getElementById("submitPost").addEventListener("click", () => { | ||
| if (document.getElementById("postText").value && document.getElementById ("postName").value){ | ||
|
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. spacing is off here |
||
| createPost(); | ||
| postText.value = ""; | ||
| ostName.value = "";} | ||
|
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. you have a typo that is creating a bug |
||
| else {alert("Please fill out all post input fields")} | ||
| }) | ||
|
|
||
| document.addEventListener("click", (e) =>{ | ||
| if (e.target.id === "remove"){ | ||
| e.target.closest(".newPost").remove() | ||
| } | ||
| }) | ||
|
|
||
| document.addEventListener("click", (e) => { | ||
| if (e.target.id === "commentsBtn"){ | ||
| const children = e.target.parentElement.children; | ||
| const form = children.namedItem("commentForm"); | ||
| if (form.classList.contains("collapse")){ | ||
| form.classList.remove("collapse"); | ||
| } | ||
| else (form.classList.add("collapse")); | ||
|
|
||
| }}) | ||
|
|
||
| document.addEventListener("click", (e)=> { | ||
| if (e.target.id === "submitComment" ){ | ||
| const submitButton = e.target; | ||
| const form = submitButton.closest(".comment-submission"); | ||
| const commentSection = form.children.commentSection; | ||
| const commentTextInput = form.children["comment-input"]; | ||
| let comment = commentTextInput.children["commentText"].value; | ||
| let commenter = form.children["name-input"].children["commentName"].value; | ||
| if (comment && commenter){ | ||
| const newComment = document.createElement("div"); | ||
| newComment.className = "d-inline-flext newComment" | ||
| const newCommentP = document.createElement("p") | ||
|
|
||
| newCommentP.innerHTML = `<a class='btn btn-link' id='removeComment'>remove</a> ${comment} - Posted By: ${commenter}` | ||
| newComment.appendChild(newCommentP) | ||
| commentSection.append(newComment)} | ||
|
Comment on lines
+66
to
+72
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. move to a new function |
||
| else(alert("Please fill out all comment input fields")); | ||
| form.children["name-input"].children["commentName"].value = ""; | ||
| form.children["comment-input"].children["commentText"].value = "" | ||
| }}) | ||
|
|
||
| document.addEventListener("click", (e) => { | ||
| if (e.target.id === "removeComment"){ | ||
| e.target.closest(".newComment").remove() | ||
| } | ||
| }) | ||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| body { | ||
| background: lightskyblue; | ||
| color: darkslategrey; | ||
| } | ||
|
|
||
| h1 { | ||
| color: black; | ||
| padding-top: 10px; | ||
| border-bottom: solid black 3px; | ||
| margin-bottom: 0px; | ||
| } | ||
|
|
||
| .post-submission { | ||
| padding-bottom: 15px; | ||
| } | ||
|
|
||
| .newPost { | ||
| border-bottom: solid slategray 1px; | ||
| width: 100%; | ||
| } | ||
|
|
||
| .posts { | ||
| width: 100%; | ||
| } | ||
| .posts button { | ||
| padding: 0; | ||
| height: 30px; | ||
| margin-right: 3px; | ||
| } | ||
|
|
||
| .posts p { | ||
| font-size: 16px; | ||
| margin: 0; | ||
| } | ||
|
|
||
| #remove, | ||
| #commentsBtn, | ||
| #removeComment { | ||
| padding: 0px; | ||
| } | ||
|
|
||
| hr { | ||
| margin: 0; | ||
| width: 100%; | ||
| } | ||
|
|
||
| .comment-submission { | ||
| padding-bottom: 15px; | ||
| } | ||
|
|
||
| .newComment { | ||
| border: 5pc; | ||
| padding: 5px; | ||
| margin: 5px; | ||
| } | ||
|
|
||
| #removeComment { | ||
| float: left; | ||
| padding-right: 2px; | ||
| } |
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.
no need for empty lines