diff --git a/static/js/convert2html.js b/static/js/convert2html.js
index ae750ddce..567317955 100644
--- a/static/js/convert2html.js
+++ b/static/js/convert2html.js
@@ -1,3 +1,47 @@
+function convertNoteToHtml(noteId, failedNotes) {
+ $.ajax({
+ url: baseUrl + 'notes/' + noteId,
+ type: 'GET',
+ async: false,
+ success: function (note) {
+ const noteNode = getNodeByKey(noteId);
+
+ if (noteNode.data.is_clone) {
+ // we shouldn't process notes twice
+ return;
+ }
+
+ note.detail.note_text = notecase2html(note);
+ note.formatting = [];
+
+ for (const link of note.links) {
+ delete link.type;
+ }
+
+ $.ajax({
+ url: baseUrl + 'notes/' + noteId,
+ type: 'PUT',
+ data: JSON.stringify(note),
+ contentType: "application/json",
+ async: false,
+ success: function () {
+ console.log("Note " + noteId + " converted.")
+ },
+ error: function () {
+ console.log("Note " + noteId + " failed when writing");
+
+ failedNotes.push(noteId);
+ }
+ });
+ },
+ error: function () {
+ console.log("Note " + noteId + " failed when reading");
+
+ failedNotes.push(noteId);
+ }
+ });
+}
+
function convertAll2Html() {
const failedNotes = [];
let counter = 1;
@@ -6,44 +50,7 @@ function convertAll2Html() {
console.log('Converting ' + counter + "/" + globalAllNoteIds.length);
counter++;
- $.ajax({
- url: baseUrl + 'notes/' + noteId,
- type: 'GET',
- async: false,
- success: function (note) {
- note.detail.note_text = notecase2html(note);
- note.formatting = [];
-
- for (const link of note.links) {
- delete link.type;
- }
-
- console.log(note.detail.note_text);
-
- $.ajax({
- url: baseUrl + 'notes/' + noteId,
- type: 'PUT',
- data: JSON.stringify(note),
- contentType: "application/json",
- async: false,
- success: function () {
- console.log("Note " + noteId + " converted.")
- },
- error: function () {
- console.log("Note " + noteId + " failed when writing");
-
- failedNotes.push(noteId);
- }
- });
- },
- error: function () {
- console.log("Note " + noteId + " failed when reading");
-
- failedNotes.push(noteId);
- }
- });
-
- break;
+ convertNoteToHtml(noteId, failedNotes);
}
console.log("Failed notes: ", failedNotes);
diff --git a/static/js/html2notecase.js b/static/js/html2notecase.js
index 59531083f..54ec2b2dd 100644
--- a/static/js/html2notecase.js
+++ b/static/js/html2notecase.js
@@ -1,4 +1,16 @@
+const globalHtmlEnabled = true;
+
function html2notecase(contents, note) {
+ note.formatting = [];
+ note.links = [];
+ note.images = [];
+
+ if (globalHtmlEnabled) {
+ note.detail.note_text = contents;
+
+ return;
+ }
+
// remove any possible extra newlines which might be inserted - all relevant new lines should be only in
and
contents = contents.replace(/(?:\r\n|\r|\n)/, ''); @@ -15,10 +27,6 @@ function html2notecase(contents, note) { let index = 0; - note.formatting = []; - note.links = []; - note.images = []; - while (index < contents.length) { let curContent = contents.substr(index); diff --git a/static/js/notecase2html.js b/static/js/notecase2html.js index d9cc07ce8..335034daf 100644 --- a/static/js/notecase2html.js +++ b/static/js/notecase2html.js @@ -1,4 +1,8 @@ function notecase2html(note) { + if (globalHtmlEnabled) { + return note.detail.note_text; + } + let noteText = note.detail.note_text; note.formatting.forEach(el => el.type = 'formatting');