WebFund 2015W: Assignment 7
In this assignment you will be modifying the AJAX notes demo from Tutorial 7. There are 10 points in 3 tasks, 7 listed below and 3 for code style. This assignment is due by 10 AM on Monday, March 16, 2015.
Please submit your answers as a zip file called "<username>-comp2406-assign7.zip", where username is your MyCarletonOne username. This zip file should uncompress to a directory called "<username>-comp2406-assign7" and inside this directory should be two things: a directory "persistent-notes" that contains the application and a text file "comments.txt".
"comments.txt" should:
- list any references you used to complete the assignment (documentation web sites, for example),
- list your collaborators, and
- optionally, should discuss any issues or concerns you had when completing this assignment.
Remember that while you are allowed to collaborate with others, plagiarism is not allowed. In other words you should not be copying any code or data directly from anywhere, and any assistance or inspiration should be credited. Any significant code similarity (beyond the code already given to you) will be considered plagiarism and will be reported to the Dean.
Tasks
- [2] Implement a [delete] button on the edit note view (with an id of "delete"). When pressed it should put up a confirm modal dialog box that says 'Delete note "The note title"'? (Replace "The note title" with the actual title of the note to delete.) If the user says okay then it should do a post to "/deleteNote" where the form body contains an "id" value that has the _id of the note to be deleted. This post should return "note deleted" upon success or "ERROR: note not deleted" upon failure. When the POST returns the page should be refreshed with the current list of notes.
- [2] Make it so the contents of notes escape embedded HTML tags. However, allow links to be embedded in notes using the syntax of "[<link> <label>]" where link is a URL for an <a> tag and the label (the rest of the text in the square brackets) is the label for the URL. If there is no label then the link itself should be the <a> tag's label.
- [3] Add a Change Username button, besides the refresh button, that allows you to change the username for a user.
- This button should have an id=changeusername assigned. It should cause the notesArea to be replaced with an interface for changing the username.
- The text field for the changed username should have a id="username". Below this should be two buttons, "Change Username" (with id of "doChangeUsername") and "Cancel" (with id of "cancelUsernameChange").
- The Cancel button should cause the notes list to be redrawn. The Change Username button should do a POST to /changeusername to actually do the username change (with a body value of newUsername for the new username). When this post returns, if it was successful (returning a value "username changed") it should change the username on the page. It should NOT change the username if the name change failed (returning a value "ERROR: username not changed"). When the post returns the notes list should be redrawn.
- The new username can be any username that is not currently being used by any stored notes. Note that you'll need to change the username in the session and update the owner field in stored notes as appropriate.