Building Your Own JavaScript Database

Eventually you’ll want to replace the records I’ve provided with your own records. You can do this in three easy steps.

  1. Open records.js in your text editor.

  2. Remove the records already there so that the file looks like this:

    var profiles = new Array(
            );
  3. For each record you want to add, use the following syntax:

    "Your_Page_Title|Your_Page_Description|http://your_page_url/file_name.html",

Add as many of these elements between the parentheses as you want. Be sure to include the comma at the end of each record—except the last one. Notice also the page title, description, and URL are each separated by | (the pipe character). Don’t use any of those in your titles, descriptions, or URLs. That will cause JavaScript errors. Remember, too that if you include double quotes (“) other than the ones on the outside, be sure to escape them with a backslash (e.g., use \” instead of just “).

Get JavaScript Application Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.