Notes/static/js/convert2html.js

42 lines
1.2 KiB
JavaScript
Raw Normal View History

2017-09-17 21:17:04 -04:00
function convertNoteToHtml(noteId, failedNotes) {
$.ajax({
2017-09-30 10:05:12 -04:00
url: baseApiUrl + 'notes/' + noteId,
2017-09-17 21:17:04 -04:00
type: 'GET',
async: false,
success: note => {
2017-09-17 21:17:04 -04:00
const noteNode = getNodeByKey(noteId);
if (noteNode.data.is_clone) {
// we shouldn't process notes twice
return;
}
note.formatting = [];
for (const link of note.links) {
delete link.type;
}
$.ajax({
2017-09-30 10:05:12 -04:00
url: baseApiUrl + 'notes/' + noteId,
2017-09-17 21:17:04 -04:00
type: 'PUT',
data: JSON.stringify(note),
contentType: "application/json",
async: false,
success: () => {
2017-09-17 21:17:04 -04:00
console.log("Note " + noteId + " converted.")
},
error: () => {
2017-09-17 21:17:04 -04:00
console.log("Note " + noteId + " failed when writing");
failedNotes.push(noteId);
}
});
},
error: () => {
2017-09-17 21:17:04 -04:00
console.log("Note " + noteId + " failed when reading");
failedNotes.push(noteId);
}
});
2017-09-17 11:20:33 -04:00
}