WebFund 2015W Lecture 18

From Soma-notes
Jump to navigation Jump to search

Audio

Notes

Assignment 7

Question 1

The delete button is implemented in the same way as the update button except that it will do something different in the callback function provided for its click event. You must create this callback function and set it up to:

  • Accept a parameter containing the note
  • Check with a dialogue box to confirm the user's choice to delete note
  • Make a POST request to '/deleteNote'

You must also set up a route on the serve to handle this request. The body of the callback function for this route will be very similar to the previously used delete note route.

Question 2

To easily format a string containing the contents of a note, you can use JavaScript regular expressions. One potential place to do this is on the server in the /updateNotes route.

HTML elements can be escaped in exactly the same way as in the previous assignment.

For a link with a label, use:

function makeLinkswLabel(str){
   return str.replace(/\[(\S+)\s+([^\]]+)\]/gi,'<a href=\"$1\">$2</a>'
);

For a link without a label, use:

function makeLinkswoLabel(str){
   return str.replace(/\[(\S+)\]/gi,'<a href=\"$l\">$1</a>');
};

Question 3

This will involve making a post request to a route /newName. The rest is left up to you to figure out...