Skip to content

Commit 0efa0b5

Browse files
author
Max Kelly
committed
145. Converting Notes App: Part IV
1 parent d8c4cbf commit 0efa0b5

13 files changed

+170
-18
lines changed

notes-app/node_modules/.cache/uglifyjs-webpack-plugin/content-v2/sha512/44/ab/3c001212f37e885e63cf9f7da6f928e33954f683e56f561bb794761241227d18d4b2c95898ffb4677338ae9948fd4008b14cea8650e08cea23f00b4b6f24

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

notes-app/node_modules/.cache/uglifyjs-webpack-plugin/content-v2/sha512/b8/43/93d6a793e636dce7ae92379e690015bd9384aff80628ccbde77da99bc7fa550c069845a3515665a303957d9f06222d655c367299fa4d652721ffdaa5c2b9

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

notes-app/node_modules/.cache/uglifyjs-webpack-plugin/index-v5/49/7e/0fa652999ef4ddc6a3f1063c36e5a54a9dc3b302b7012fcb6b5fb25f1233

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

notes-app/node_modules/.cache/uglifyjs-webpack-plugin/index-v5/87/e4/42957236f21c042cadcb0e8e3e7ed9ae62ef17dca6315ed41c3d0e8504bc

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

notes-app/public/scripts/bundle.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

notes-app/public/scripts/edit-bundle.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

notes-app/public/scripts/edit-bundle.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

notes-app/public/scripts/index-bundle.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

notes-app/public/scripts/index-bundle.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

notes-app/src/edit.js

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,40 @@
1-
console.log('edit.js')
1+
import { initializedEditPage, generateLastEdited } from './views'
2+
import { updateNote, removeNote } from './notes'
3+
4+
const titleElement = document.querySelector("#note-title");
5+
const bodyElement = document.querySelector("#note-body");
6+
const dateElement = document.querySelector("#edited");
7+
const removeElement = document.querySelector("#remove-note");
8+
const noteId = location.hash.substring(1);
9+
10+
initializedEditPage(noteId)
11+
12+
13+
// This saves the title of the note.
14+
titleElement.addEventListener("input", e => {
15+
const note = updateNote(noteId, {
16+
title: e.target.value
17+
})
18+
dateElement.textContent = generateLastEdited(note.updatedAt)
19+
});
20+
21+
// This saves the body of the note.
22+
bodyElement.addEventListener("input", e => {
23+
const note = updateNote(noteId, {
24+
body: e.target.value
25+
})
26+
dateElement.textContent = generateLastEdited(note.updatedAt);
27+
});
28+
29+
// This removes the note and redirects the user back the /index.html
30+
removeElement.addEventListener("click", e => {
31+
removeNote(noteId);
32+
location.assign("/index.html");
33+
});
34+
35+
// The below code lets the console listen and any changes made in the window will update across other windows.
36+
window.addEventListener("storage", e => {
37+
if (e.key === "notes") {
38+
initializedEditPage(noteId)
39+
}
40+
});

0 commit comments

Comments
 (0)