all JS functions are now inside old-school JS modules, preparation for ES6 modularization

This commit is contained in:
azivner
2018-03-24 23:58:58 -04:00
parent 001a5107dd
commit b96a1274c5
4 changed files with 261 additions and 245 deletions

View File

@@ -1,32 +1,39 @@
"use strict";
function exportSubTree(noteId) {
const url = utils.getHost() + "/api/export/" + noteId + "?protectedSessionId="
+ encodeURIComponent(protected_session.getProtectedSessionId());
const exportService = (function () {
function exportSubTree(noteId) {
const url = utils.getHost() + "/api/export/" + noteId + "?protectedSessionId="
+ encodeURIComponent(protected_session.getProtectedSessionId());
utils.download(url);
}
utils.download(url);
}
let importNoteId;
let importNoteId;
function importSubTree(noteId) {
importNoteId = noteId;
function importSubTree(noteId) {
importNoteId = noteId;
$("#import-upload").trigger('click');
}
$("#import-upload").trigger('click');
}
$("#import-upload").change(async function() {
const formData = new FormData();
formData.append('upload', this.files[0]);
$("#import-upload").change(async function() {
const formData = new FormData();
formData.append('upload', this.files[0]);
await $.ajax({
url: baseApiUrl + 'import/' + importNoteId,
headers: server.getHeaders(),
data: formData,
type: 'POST',
contentType: false, // NEEDED, DON'T OMIT THIS
processData: false, // NEEDED, DON'T OMIT THIS
await $.ajax({
url: baseApiUrl + 'import/' + importNoteId,
headers: server.getHeaders(),
data: formData,
type: 'POST',
contentType: false, // NEEDED, DON'T OMIT THIS
processData: false, // NEEDED, DON'T OMIT THIS
});
await treeService.reload();
});
await treeService.reload();
});
return {
exportSubTree,
importSubTree
};
})();