-
Notifications
You must be signed in to change notification settings - Fork 223
Project Reddit #237
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
Open
SBCode320
wants to merge
4
commits into
projectshft:master
Choose a base branch
from
SBCode320:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Project Reddit #237
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| <html> | ||
| <head> | ||
| <title>ReReddit</title> | ||
| <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.4.1/dist/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous"> | ||
| </head> | ||
| <body> | ||
| <div class="row"> | ||
| <div class="col-md-6 col-md-offset-3"> | ||
|
|
||
| <div class="page-header"> | ||
| <h1>ReReddit</h1> | ||
| </div> | ||
|
|
||
| <div class="posts"> | ||
| </div> | ||
|
|
||
| <form style="margin-top:30px;" onsubmit="event.preventDefault();"> | ||
|
|
||
| <div class="form-group"> | ||
| <input id="name" type="text" | ||
| class="form-control" | ||
| placeholder="Name"></input> | ||
| </div> | ||
|
|
||
| <div class="form-group"> | ||
| <textarea id="message" type="text" | ||
| class="form-control" | ||
| placeholder="Message"></textarea> | ||
| </div> | ||
|
|
||
| <button id="submit" class="btn btn-primary">Post</button> | ||
| </form> | ||
|
|
||
| </div> | ||
| </div> | ||
|
|
||
| <script src="main.js"></script> | ||
| </body> | ||
| </html> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,130 @@ | ||
| // Handle new post submission | ||
| document.getElementById('submit').addEventListener('click', function () { | ||
| // Get and trim input values | ||
| const name = document.getElementById('name').value.trim(); | ||
| const text = document.getElementById('message').value.trim(); | ||
|
|
||
| // Clear inputs | ||
| document.getElementById('name').value = ''; | ||
| document.getElementById('message').value = ''; | ||
|
|
||
| // Validate input | ||
| if (!name || !text) { | ||
| alert("Please fill out both fields!"); | ||
| return; | ||
| } | ||
|
|
||
| // Create post | ||
|
|
||
| const postsDiv = document.querySelector('.posts'); | ||
|
|
||
| // Post container | ||
| const postPanel = document.createElement('div'); | ||
| postPanel.className = 'panel panel-default'; | ||
|
|
||
| const postBody = document.createElement('div'); | ||
| postBody.className = 'panel-body'; | ||
|
|
||
| // Post content | ||
| const postText = document.createElement('p'); | ||
| postText.textContent = `${text} - Posted By: ${name}`; | ||
| postText.style.marginTop = '10px'; | ||
| postText.style.marginBottom = '15px'; | ||
|
|
||
| // Action buttons | ||
| const removeButton = document.createElement('button'); | ||
| removeButton.textContent = 'Remove Post'; | ||
| removeButton.className = 'btn btn-danger btn-xs'; | ||
|
|
||
| const commentButton = document.createElement('button'); | ||
| commentButton.textContent = 'Comments'; | ||
| commentButton.className = 'btn btn-default btn-xs'; | ||
|
|
||
| //Create comment section | ||
|
|
||
| const commentsDiv = document.createElement('div'); | ||
| commentsDiv.style.display = 'none'; | ||
|
|
||
| const commentsList = document.createElement('div'); | ||
| commentsList.style.marginTop = '10px'; | ||
|
|
||
| const commentInput = document.createElement('input'); | ||
| commentInput.className = 'form-control'; | ||
| commentInput.placeholder = 'Comment'; | ||
|
|
||
| const nameInput = document.createElement('input'); | ||
| nameInput.className = 'form-control'; | ||
| nameInput.placeholder = 'Your Name'; | ||
|
|
||
| const postCommentButton = document.createElement('button'); | ||
| postCommentButton.textContent = 'Post'; | ||
| postCommentButton.className = 'btn btn-primary btn-sm'; | ||
|
|
||
| // Assemble comment section | ||
| commentsDiv.appendChild(commentsList); | ||
| commentsDiv.appendChild(commentInput); | ||
| commentsDiv.appendChild(nameInput); | ||
| commentsDiv.appendChild(postCommentButton); | ||
|
|
||
| // Assemble post | ||
| postBody.appendChild(removeButton); | ||
| postBody.appendChild(commentButton); | ||
| postBody.appendChild(postText); | ||
| postBody.appendChild(commentsDiv); | ||
|
|
||
| postPanel.appendChild(postBody); | ||
| postsDiv.appendChild(postPanel); | ||
|
|
||
| // Buttons | ||
|
|
||
| // Remove entire post | ||
| removeButton.addEventListener('click', function () { | ||
| postPanel.remove(); | ||
| }); | ||
|
|
||
| // Toggle comment section | ||
| commentButton.addEventListener('click', function () { | ||
| commentsDiv.style.display = (commentsDiv.style.display === 'none') ? 'block' : 'none'; | ||
| }); | ||
|
|
||
| // Handle comment submission | ||
| postCommentButton.addEventListener('click', function () { | ||
| const commentText = commentInput.value.trim(); | ||
| const commenterName = nameInput.value.trim(); | ||
|
|
||
| // Validate comment input | ||
| if (!commentText || !commenterName) { | ||
| alert("Please fill out both fields!"); | ||
| return; | ||
| } | ||
|
|
||
| // Add well for first comment | ||
| if (commentsList.children.length === 0) { | ||
| commentsList.className = 'well well-sm'; | ||
| } | ||
|
|
||
| // Create comment element | ||
| const comment = document.createElement('p'); | ||
| comment.textContent = `${commentText} - Posted By: ${commenterName}`; | ||
|
|
||
| // Create remove link for comment | ||
| const removeLink = document.createElement('a'); | ||
| removeLink.href = '#'; | ||
| removeLink.textContent = ' x'; | ||
| removeLink.style.marginLeft = '10px'; | ||
| removeLink.style.color = 'red'; | ||
| removeLink.style.cursor = 'pointer'; | ||
|
|
||
| removeLink.addEventListener('click', function (e) { | ||
| e.preventDefault(); | ||
| comment.remove(); | ||
| }); | ||
|
|
||
| comment.appendChild(removeLink); | ||
| commentsList.appendChild(comment); | ||
|
|
||
| // Clear comment inputs | ||
| commentInput.value = ''; | ||
| nameInput.value = ''; | ||
| }); | ||
| }); |
Empty file.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
old version of bootstrap.