function makeNote(noteStore, noteTitle, noteBody, resources, parentNotebook, callback) { // Create note object var ourNote = new Evernote.Note(); ourNote.title = noteTitle; // Build body of note var nBody = ""; nBody += ""; nBody += "" + noteBody; if (resources && resources.length > 0) { // Add Resource objects to note body nBody += "

"; ourNote.resources = resources; for (i in resources) { var md5 = crypto.createHash('md5'); md5.update(resources[i].data.body); var hexhash = md5.digest('hex'); nBody += "Attachment with hash " + hexhash + ":

" } } nBody += "
"; ourNote.content = nBody; // parentNotebook is optional; if omitted, default notebook is used if (parentNotebook && parentNotebook.guid) { ourNote.notebookGuid = parentNotebook.guid; } // Attempt to create note in Evernote account noteStore.createNote(ourNote, function(note) { if (note.errorCode) { // Something was wrong with the note data // See EDAMErrorCode enumeration for error code explanation // http://dev.evernote.com/documentation/reference/Errors.html#Enum_EDAMErrorCode console.log(note); } else { callback(note); } }); }