mirror of
https://github.com/zadam/trilium.git
synced 2025-11-07 05:46:10 +01:00
refactoring utils into module
This commit is contained in:
@@ -18,7 +18,7 @@ const eventLog = (function() {
|
||||
$list.html('');
|
||||
|
||||
for (const event of result) {
|
||||
const dateTime = formatDateTime(parseDate(event.dateAdded));
|
||||
const dateTime = utils.formatDateTime(utils.parseDate(event.dateAdded));
|
||||
|
||||
if (event.noteId) {
|
||||
const noteLink = link.createNoteLink(event.noteId).prop('outerHTML');
|
||||
|
||||
@@ -17,7 +17,7 @@ const jumpToNote = (function() {
|
||||
});
|
||||
|
||||
await $autoComplete.autocomplete({
|
||||
source: await stopWatch("building autocomplete", treeService.getAutocompleteItems),
|
||||
source: await utils.stopWatch("building autocomplete", treeService.getAutocompleteItems),
|
||||
minLength: 0
|
||||
});
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ const labelsDialog = (function() {
|
||||
|
||||
addLastEmptyRow();
|
||||
|
||||
showMessage("Labels have been saved.");
|
||||
utils.showMessage("Labels have been saved.");
|
||||
|
||||
noteEditor.loadLabelList();
|
||||
};
|
||||
|
||||
@@ -28,11 +28,11 @@ const noteHistory = (function() {
|
||||
historyItems = await server.get('notes-history/' + noteId);
|
||||
|
||||
for (const item of historyItems) {
|
||||
const dateModified = parseDate(item.dateModifiedFrom);
|
||||
const dateModified = utils.parseDate(item.dateModifiedFrom);
|
||||
|
||||
$list.append($('<option>', {
|
||||
value: item.noteRevisionId,
|
||||
text: formatDateTime(dateModified)
|
||||
text: utils.formatDateTime(dateModified)
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@@ -22,10 +22,10 @@ const recentChanges = (function() {
|
||||
for (const [dateDay, dayChanges] of groupedByDate) {
|
||||
const changesListEl = $('<ul>');
|
||||
|
||||
const dayEl = $('<div>').append($('<b>').html(formatDate(dateDay))).append(changesListEl);
|
||||
const dayEl = $('<div>').append($('<b>').html(utils.formatDate(dateDay))).append(changesListEl);
|
||||
|
||||
for (const change of dayChanges) {
|
||||
const formattedTime = formatTime(parseDate(change.dateModifiedTo));
|
||||
const formattedTime = utils.formatTime(utils.parseDate(change.dateModifiedTo));
|
||||
|
||||
const revLink = $("<a>", {
|
||||
href: 'javascript:',
|
||||
@@ -58,7 +58,7 @@ const recentChanges = (function() {
|
||||
const dayCache = {};
|
||||
|
||||
for (const row of result) {
|
||||
let dateDay = parseDate(row.dateModifiedTo);
|
||||
let dateDay = utils.parseDate(row.dateModifiedTo);
|
||||
dateDay.setHours(0);
|
||||
dateDay.setMinutes(0);
|
||||
dateDay.setSeconds(0);
|
||||
|
||||
@@ -36,7 +36,7 @@ const settings = (function() {
|
||||
value: settingValue
|
||||
});
|
||||
|
||||
showMessage("Settings change have been saved.");
|
||||
utils.showMessage("Settings change have been saved.");
|
||||
}
|
||||
|
||||
$showDialogButton.click(showDialog);
|
||||
@@ -82,7 +82,7 @@ settings.addModule((function() {
|
||||
protected_session.resetProtectedSession();
|
||||
}
|
||||
else {
|
||||
showError(result.message);
|
||||
utils.showError(result.message);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -166,27 +166,27 @@ settings.addModule((async function () {
|
||||
$forceFullSyncButton.click(async () => {
|
||||
await server.post('sync/force-full-sync');
|
||||
|
||||
showMessage("Full sync triggered");
|
||||
utils.showMessage("Full sync triggered");
|
||||
});
|
||||
|
||||
$fillSyncRowsButton.click(async () => {
|
||||
await server.post('sync/fill-sync-rows');
|
||||
|
||||
showMessage("Sync rows filled successfully");
|
||||
utils.showMessage("Sync rows filled successfully");
|
||||
});
|
||||
|
||||
|
||||
$anonymizeButton.click(async () => {
|
||||
await server.post('anonymization/anonymize');
|
||||
|
||||
showMessage("Created anonymized database");
|
||||
utils.showMessage("Created anonymized database");
|
||||
});
|
||||
|
||||
$cleanupSoftDeletedButton.click(async () => {
|
||||
if (confirm("Do you really want to clean up soft-deleted items?")) {
|
||||
await server.post('cleanup/cleanup-soft-deleted-items');
|
||||
|
||||
showMessage("Soft deleted items have been cleaned up");
|
||||
utils.showMessage("Soft deleted items have been cleaned up");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -194,14 +194,14 @@ settings.addModule((async function () {
|
||||
if (confirm("Do you really want to clean up unused images?")) {
|
||||
await server.post('cleanup/cleanup-unused-images');
|
||||
|
||||
showMessage("Unused images have been cleaned up");
|
||||
utils.showMessage("Unused images have been cleaned up");
|
||||
}
|
||||
});
|
||||
|
||||
$vacuumDatabaseButton.click(async () => {
|
||||
await server.post('cleanup/vacuum-database');
|
||||
|
||||
showMessage("Database has been vacuumed");
|
||||
utils.showMessage("Database has been vacuumed");
|
||||
});
|
||||
|
||||
return {};
|
||||
|
||||
@@ -24,7 +24,7 @@ const sqlConsole = (function() {
|
||||
|
||||
async function initEditor() {
|
||||
if (!codeEditor) {
|
||||
await requireLibrary(CODE_MIRROR);
|
||||
await utils.requireLibrary(utils.CODE_MIRROR);
|
||||
|
||||
CodeMirror.keyMap.default["Shift-Tab"] = "indentLess";
|
||||
CodeMirror.keyMap.default["Tab"] = "indentMore";
|
||||
@@ -60,11 +60,11 @@ const sqlConsole = (function() {
|
||||
});
|
||||
|
||||
if (!result.success) {
|
||||
showError(result.error);
|
||||
utils.showError(result.error);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
showMessage("Query was executed successfully.");
|
||||
utils.showMessage("Query was executed successfully.");
|
||||
}
|
||||
|
||||
const rows = result.rows;
|
||||
|
||||
Reference in New Issue
Block a user