Repository navigation
Expand file tree
/
Copy pathjo.js
More file actions
40 lines (32 loc) · 1.51 KB
/
Copy pathjo.js
File metadata and controls
40 lines (32 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
function addEntry() {
const entryContent = document.querySelector('.journal-input').value;
if (entryContent.trim() === "") return; // Don't add if the content is empty
const entryDate = new Date().toLocaleDateString(); // Get current date
const newEntry = document.createElement('div');
newEntry.classList.add('journal-entry');
// Set up the journal entry structure
newEntry.innerHTML = `
<div class="entry-header">
<span class="entry-date">${entryDate}</span>
<button class="delete-btn" onclick="deleteEntry(this)"><i class="fas fa-trash-alt"></i></button>
</div>
<p class="entry-content">${entryContent}</p>
<button class="share-btn" onclick="sharePost(this)">Share as Post</button>
`;
// Append the new entry to the entries container
document.getElementById('entries-container').appendChild(newEntry);
// Clear the input field
document.querySelector('.journal-input').value = "";
}
// Function to delete a journal entry
function deleteEntry(button) {
const entry = button.closest('.journal-entry');
entry.remove();
}
// Function to simulate sharing the journal entry as a post
function sharePost(button) {
const entry = button.closest('.journal-entry');
const entryContent = entry.querySelector('.entry-content').textContent;
const entryDate = entry.querySelector('.entry-date').textContent;
alert(`Sharing post...\n\nDate: ${entryDate}\nContent: ${entryContent}`);
}