always use template strings instead of string concatenation

This commit is contained in:
zadam 2022-12-21 15:19:05 +01:00
parent ea006993f6
commit 1b24276a4a
154 changed files with 433 additions and 437 deletions

View File

@ -9,7 +9,7 @@ sqlInit.dbReady.then(async () => {
const resp = await backupService.anonymize();
if (resp.success) {
console.log("Anonymized file has been saved to: " + resp.anonymizedFilePath);
console.log(`Anonymized file has been saved to: ${resp.anonymizedFilePath}`);
process.exit(0);
} else {

View File

@ -66,12 +66,12 @@ const sessionParser = session({
name: 'trilium.sid',
store: new FileStore({
ttl: 30 * 24 * 3600,
path: dataDir.TRILIUM_DATA_DIR + '/sessions'
path: `${dataDir.TRILIUM_DATA_DIR}/sessions`
})
});
app.use(sessionParser);
app.use(favicon(__dirname + '/../images/app-icons/win/icon.ico'));
app.use(favicon(`${__dirname}/../images/app-icons/win/icon.ico`));
require('./routes/routes').register(app);
@ -91,7 +91,7 @@ app.use((err, req, res, next) => {
// catch 404 and forward to error handler
app.use((req, res, next) => {
const err = new Error('Router not found for request ' + req.url);
const err = new Error(`Router not found for request ${req.url}`);
err.status = 404;
next(err);
});

View File

@ -75,7 +75,7 @@ function getNoteTitle(childNoteId, parentNoteId) {
const branch = parentNote ? becca.getBranchFromChildAndParent(childNote.noteId, parentNote.noteId) : null;
return ((branch && branch.prefix) ? `${branch.prefix} - ` : '') + title;
return `${(branch && branch.prefix) ? `${branch.prefix} - ` : ''}${title}`;
}
function getNoteTitleArrayForPath(notePathArray) {

View File

@ -31,7 +31,7 @@ class AbstractEntity {
let contentToHash = "";
for (const propertyName of this.constructor.hashedProperties) {
contentToHash += "|" + this[propertyName];
contentToHash += `|${this[propertyName]}`;
}
if (isDeleted) {

View File

@ -185,7 +185,7 @@ class Branch extends AbstractEntity {
// first delete children and then parent - this will show up better in recent changes
log.info("Deleting note " + note.noteId);
log.info(`Deleting note ${note.noteId}`);
this.becca.notes[note.noteId].isBeingDeleted = true;

View File

@ -211,7 +211,7 @@ class Note extends AbstractEntity {
return undefined;
}
else {
throw new Error("Cannot find note content for noteId=" + this.noteId);
throw new Error(`Cannot find note content for noteId=${this.noteId}`);
}
}
@ -304,7 +304,7 @@ class Note extends AbstractEntity {
sql.upsert("note_contents", "noteId", pojo);
const hash = utils.hash(this.noteId + "|" + pojo.content.toString());
const hash = utils.hash(`${this.noteId}|${pojo.content.toString()}`);
entityChangesService.addEntityChange({
entityName: 'note_contents',
@ -739,22 +739,22 @@ class Note extends AbstractEntity {
*/
getFlatText() {
if (!this.flatTextCache) {
this.flatTextCache = this.noteId + ' ' + this.type + ' ' + this.mime + ' ';
this.flatTextCache = `${this.noteId} ${this.type} ${this.mime} `;
for (const branch of this.parentBranches) {
if (branch.prefix) {
this.flatTextCache += branch.prefix + ' ';
this.flatTextCache += `${branch.prefix} `;
}
}
this.flatTextCache += this.title + ' ';
this.flatTextCache += `${this.title} `;
for (const attr of this.getAttributes()) {
// it's best to use space as separator since spaces are filtered from the search string by the tokenization into words
this.flatTextCache += (attr.type === 'label' ? '#' : '~') + attr.name;
this.flatTextCache += `${attr.type === 'label' ? '#' : '~'}${attr.name}`;
if (attr.value) {
this.flatTextCache += '=' + attr.value;
this.flatTextCache += `=${attr.value}`;
}
this.flatTextCache += ' ';

View File

@ -81,7 +81,7 @@ class NoteRevision extends AbstractEntity {
return undefined;
}
else {
throw new Error("Cannot find note revision content for noteRevisionId=" + this.noteRevisionId);
throw new Error(`Cannot find note revision content for noteRevisionId=${this.noteRevisionId}`);
}
}
@ -124,7 +124,7 @@ class NoteRevision extends AbstractEntity {
sql.upsert("note_revision_contents", "noteRevisionId", pojo);
const hash = utils.hash(this.noteRevisionId + "|" + pojo.content.toString());
const hash = utils.hash(`${this.noteRevisionId}|${pojo.content.toString()}`);
entityChangesService.addEntityChange({
entityName: 'note_revision_contents',

View File

@ -66,7 +66,7 @@ function isNoteType(obj) {
const noteTypes = noteTypeService.getNoteTypeNames();
if (!noteTypes.includes(obj)) {
return `'${obj}' is not a valid note type, allowed types are: ` + noteTypes.join(", ");
return `'${obj}' is not a valid note type, allowed types are: ${noteTypes.join(", ")}`;
}
}

View File

@ -96,7 +96,7 @@ class AppContext extends Component {
/** @returns {Promise} */
triggerCommand(name, data = {}) {
for (const executor of this.components) {
const fun = executor[name + "Command"];
const fun = executor[`${name}Command`];
if (fun) {
return executor.callMethod(fun, data);

View File

@ -13,7 +13,7 @@ import utils from '../services/utils.js';
*/
export default class Component {
constructor() {
this.componentId = this.sanitizedClassName + '-' + utils.randomString(8);
this.componentId = `${this.sanitizedClassName}-${utils.randomString(8)}`;
/** @type Component[] */
this.children = [];
this.initialized = null;
@ -44,8 +44,8 @@ export default class Component {
handleEvent(name, data) {
try {
const callMethodPromise = this.initialized
? this.initialized.then(() => this.callMethod(this[name + 'Event'], data))
: this.callMethod(this[name + 'Event'], data);
? this.initialized.then(() => this.callMethod(this[`${name}Event`], data))
: this.callMethod(this[`${name}Event`], data);
const childrenPromise = this.handleEventInChildren(name, data);
@ -84,7 +84,7 @@ export default class Component {
/** @returns {Promise} */
triggerCommand(name, data = {}) {
const fun = this[name + 'Command'];
const fun = this[`${name}Command`];
if (fun) {
return this.callMethod(fun, data);

View File

@ -150,7 +150,7 @@ export default class Entrypoints extends Component {
ipcRenderer.send('create-extra-window', {notePath, hoistedNoteId});
}
else {
const url = window.location.protocol + '//' + window.location.host + window.location.pathname + '?extra=1#' + notePath;
const url = `${window.location.protocol}//${window.location.host}${window.location.pathname}?extra=1#${notePath}`;
window.open(url, '', 'width=1000,height=800');
}
@ -172,12 +172,12 @@ export default class Entrypoints extends Component {
if (note.mime.endsWith("env=frontend")) {
await bundleService.getAndExecuteBundle(note.noteId);
} else if (note.mime.endsWith("env=backend")) {
await server.post('script/run/' + note.noteId);
await server.post(`script/run/${note.noteId}`);
} else if (note.mime === 'text/x-sqlite;schema=trilium') {
const resp = await server.post("sql/execute/" + note.noteId);
const resp = await server.post(`sql/execute/${note.noteId}`);
if (!resp.success) {
toastService.showError("Error occurred while executing SQL query: " + resp.message);
toastService.showError(`Error occurred while executing SQL query: ${resp.message}`);
}
await appContext.triggerEvent('sqlQueryResults', {ntxId: ntxId, results: resp.results});

View File

@ -126,7 +126,7 @@ export default class TabManager extends Component {
if (window.history.length === 0 // first history entry
|| (activeNoteContext && activeNoteContext.notePath !== treeService.getHashValueFromAddress()[0])) {
const url = '#' + (activeNoteContext.notePath || "") + "-" + activeNoteContext.ntxId;
const url = `#${activeNoteContext.notePath || ""}-${activeNoteContext.ntxId}`;
// using pushState instead of directly modifying document.location because it does not trigger hashchange
window.history.pushState(null, "", url);

View File

@ -112,7 +112,7 @@ if (utils.isElectron()) {
if (hasText) {
const shortenedSelection = params.selectionText.length > 15
? (params.selectionText.substr(0, 13) + "…")
? (`${params.selectionText.substr(0, 13)}`)
: params.selectionText;
items.push({

View File

@ -119,7 +119,7 @@ class NoteShort {
async getContent() {
// we're not caching content since these objects are in froca and as such pretty long lived
const note = await server.get("notes/" + this.noteId);
const note = await server.get(`notes/${this.noteId}`);
return note.content;
}
@ -813,7 +813,7 @@ class NoteShort {
return await bundleService.getAndExecuteBundle(this.noteId);
}
else if (env === "backend") {
return await server.post('script/run/' + this.noteId);
return await server.post(`script/run/${this.noteId}`);
}
else {
throw new Error(`Unrecognized env type ${env} for note ${this.noteId}`);

View File

@ -52,7 +52,7 @@ async function initLabelValueAutocomplete({ $el, open, nameCallback }) {
return;
}
const attributeValues = (await server.get('attributes/values/' + encodeURIComponent(attributeName)))
const attributeValues = (await server.get(`attributes/values/${encodeURIComponent(attributeName)}`))
.map(attribute => ({ value: attribute }));
if (attributeValues.length === 0) {

View File

@ -125,9 +125,7 @@ function parse(tokens, str, allowEmptyRelations = false) {
startIndex = Math.max(0, startIndex - 20);
endIndex = Math.min(str.length, endIndex + 20);
return '"' + (startIndex !== 0 ? "..." : "")
+ str.substr(startIndex, endIndex - startIndex)
+ (endIndex !== str.length ? "..." : "") + '"';
return `"${startIndex !== 0 ? "..." : ""}${str.substr(startIndex, endIndex - startIndex)}${endIndex !== str.length ? "..." : ""}"`;
}
for (let i = 0; i < tokens.length; i++) {

View File

@ -6,7 +6,7 @@ async function renderAttribute(attribute, renderIsInheritable) {
const $attr = $("<span>");
if (attribute.type === 'label') {
$attr.append(document.createTextNode('#' + attribute.name + isInheritable));
$attr.append(document.createTextNode(`#${attribute.name}${isInheritable}`));
if (attribute.value) {
$attr.append('=');
@ -19,11 +19,11 @@ async function renderAttribute(attribute, renderIsInheritable) {
// when the relation has just been created then it might not have a value
if (attribute.value) {
$attr.append(document.createTextNode('~' + attribute.name + isInheritable + "="));
$attr.append(document.createTextNode(`~${attribute.name}${isInheritable}=`));
$attr.append(await createNoteLink(attribute.value));
}
} else {
ws.logError("Unknown attr type: " + attribute.type);
ws.logError(`Unknown attr type: ${attribute.type}`);
}
return $attr;
@ -34,16 +34,16 @@ function formatValue(val) {
return val;
}
else if (!val.includes('"')) {
return '"' + val + '"';
return `"${val}"`;
}
else if (!val.includes("'")) {
return "'" + val + "'";
return `'${val}'`;
}
else if (!val.includes("`")) {
return "`" + val + "`";
return `\`${val}\``;
}
else {
return '"' + val.replace(/"/g, '\\"') + '"';
return `"${val.replace(/"/g, '\\"')}"`;
}
}
@ -55,7 +55,7 @@ async function createNoteLink(noteId) {
}
return $("<a>", {
href: '#root/' + noteId,
href: `#root/${noteId}`,
class: 'reference-link',
'data-note-path': noteId
})

View File

@ -116,10 +116,10 @@ async function deleteNotes(branchIdsToDelete, forceDeleteAllClones = false) {
const branch = froca.getBranch(branchIdToDelete);
if (deleteAllClones) {
await server.remove(`notes/${branch.noteId}` + query);
await server.remove(`notes/${branch.noteId}${query}`);
}
else {
await server.remove(`branches/${branchIdToDelete}` + query);
await server.remove(`branches/${branchIdToDelete}${query}`);
}
}
@ -186,7 +186,7 @@ ws.subscribeToMessages(async message => {
toastService.closePersistent(message.taskId);
toastService.showError(message.message);
} else if (message.type === 'taskProgressCount') {
toastService.showPersistent(makeToast(message.taskId, "Delete notes in progress: " + message.progressCount));
toastService.showPersistent(makeToast(message.taskId, `Delete notes in progress: ${message.progressCount}`));
} else if (message.type === 'taskSucceeded') {
const toast = makeToast(message.taskId, "Delete finished successfully.");
toast.closeAfter = 5000;
@ -204,7 +204,7 @@ ws.subscribeToMessages(async message => {
toastService.closePersistent(message.taskId);
toastService.showError(message.message);
} else if (message.type === 'taskProgressCount') {
toastService.showPersistent(makeToast(message.taskId, "Undeleting notes in progress: " + message.progressCount));
toastService.showPersistent(makeToast(message.taskId, `Undeleting notes in progress: ${message.progressCount}`));
} else if (message.type === 'taskSucceeded') {
const toast = makeToast(message.taskId, "Undeleting notes finished successfully.");
toast.closeAfter = 5000;
@ -235,7 +235,7 @@ async function cloneNoteToNote(childNoteId, parentNoteId, prefix) {
// beware that first arg is noteId and second is branchId!
async function cloneNoteAfter(noteId, afterBranchId) {
const resp = await server.put('notes/' + noteId + '/clone-after/' + afterBranchId);
const resp = await server.put(`notes/${noteId}/clone-after/${afterBranchId}`);
if (!resp.success) {
toastService.showError(resp.message);

View File

@ -5,7 +5,7 @@ import froca from "./froca.js";
import utils from "./utils.js";
async function getAndExecuteBundle(noteId, originEntity = null) {
const bundle = await server.get('script/bundle/' + noteId);
const bundle = await server.get(`script/bundle/${noteId}`);
return await executeBundle(bundle, originEntity);
}

View File

@ -30,7 +30,7 @@ async function pasteAfter(afterBranchId) {
// copy will keep clipboardBranchIds and clipboardMode so it's possible to paste into multiple places
}
else {
toastService.throwError("Unrecognized clipboard mode=" + clipboardMode);
toastService.throwError(`Unrecognized clipboard mode=${clipboardMode}`);
}
}
@ -57,7 +57,7 @@ async function pasteInto(parentBranchId) {
// copy will keep clipboardBranchIds and clipboardMode, so it's possible to paste into multiple places
}
else {
toastService.throwError("Unrecognized clipboard mode=" + clipboardMode);
toastService.throwError(`Unrecognized clipboard mode=${clipboardMode}`);
}
}
@ -71,7 +71,7 @@ async function copy(branchIds) {
const links = [];
for (const branch of froca.getBranches(clipboardBranchIds)) {
const $link = await linkService.createNoteLink(branch.parentNoteId + '/' + branch.noteId, { referenceLink: true });
const $link = await linkService.createNoteLink(`${branch.parentNoteId}/${branch.noteId}`, { referenceLink: true });
links.push($link[0].outerHTML);
}

View File

@ -11,7 +11,7 @@ function createClassForColor(color) {
return "";
}
const className = 'color-' + normalizedColorName;
const className = `color-${normalizedColorName}`;
if (!registeredClasses.has(className)) {
$("head").append(`<style>.${className} { color: ${color} !important; }</style>`);

View File

@ -4,7 +4,7 @@ import ws from "./ws.js";
/** @returns {NoteShort} */
async function getInboxNote() {
const note = await server.get('special-notes/inbox/' + dayjs().format("YYYY-MM-DD"), "date-note");
const note = await server.get(`special-notes/inbox/${dayjs().format("YYYY-MM-DD")}`, "date-note");
return await froca.getNote(note.noteId);
}
@ -16,7 +16,7 @@ async function getTodayNote() {
/** @returns {NoteShort} */
async function getDayNote(date) {
const note = await server.get('special-notes/days/' + date, "date-note");
const note = await server.get(`special-notes/days/${date}`, "date-note");
await ws.waitForMaxKnownEntityChangeId();
@ -25,7 +25,7 @@ async function getDayNote(date) {
/** @returns {NoteShort} */
async function getWeekNote(date) {
const note = await server.get('special-notes/weeks/' + date, "date-note");
const note = await server.get(`special-notes/weeks/${date}`, "date-note");
await ws.waitForMaxKnownEntityChangeId();
@ -34,7 +34,7 @@ async function getWeekNote(date) {
/** @returns {NoteShort} */
async function getMonthNote(month) {
const note = await server.get('special-notes/months/' + month, "date-note");
const note = await server.get(`special-notes/months/${month}`, "date-note");
await ws.waitForMaxKnownEntityChangeId();
@ -43,7 +43,7 @@ async function getMonthNote(month) {
/** @returns {NoteShort} */
async function getYearNote(year) {
const note = await server.get('special-notes/years/' + year, "date-note");
const note = await server.get(`special-notes/years/${year}`, "date-note");
await ws.waitForMaxKnownEntityChangeId();

View File

@ -41,7 +41,7 @@ class Froca {
}
async loadSubTree(subTreeNoteId) {
const resp = await server.get('tree?subTreeNoteId=' + subTreeNoteId);
const resp = await server.get(`tree?subTreeNoteId=${subTreeNoteId}`);
this.addResp(resp);
@ -176,7 +176,7 @@ class Froca {
return;
}
const {searchResultNoteIds, highlightedTokens, error} = await server.get('search-note/' + note.noteId);
const {searchResultNoteIds, highlightedTokens, error} = await server.get(`search-note/${note.noteId}`);
if (!Array.isArray(searchResultNoteIds)) {
throw new Error(`Search note '${note.noteId}' failed: ${searchResultNoteIds}`);
@ -192,7 +192,7 @@ class Froca {
searchResultNoteIds.forEach((resultNoteId, index) => branches.push({
// branchId should be repeatable since sometimes we reload some notes without rerendering the tree
branchId: "virt-" + note.noteId + '-' + resultNoteId,
branchId: `virt-${note.noteId}-${resultNoteId}`,
noteId: resultNoteId,
parentNoteId: note.noteId,
notePosition: (index + 1) * 10,
@ -314,7 +314,7 @@ class Froca {
*/
async getNoteComplement(noteId) {
if (!this.noteComplementPromises[noteId]) {
this.noteComplementPromises[noteId] = server.get('notes/' + noteId)
this.noteComplementPromises[noteId] = server.get(`notes/${noteId}`)
.then(row => new NoteComplement(row))
.catch(e => console.error(`Cannot get note complement for note '${noteId}'`));

View File

@ -137,7 +137,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
return params.map(p => {
if (typeof p === "function") {
return "!@#Function: " + p.toString();
return `!@#Function: ${p.toString()}`;
}
else {
return p;
@ -173,7 +173,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
return ret.executionResult;
}
else {
throw new Error("server error: " + ret.error);
throw new Error(`server error: ${ret.error}`);
}
};
@ -564,7 +564,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
this.log = message => {
const {noteId} = this.startNote;
message = utils.now() + ": " + message;
message = `${utils.now()}: ${message}`;
console.log(`Script ${noteId}: ${message}`);

View File

@ -49,12 +49,12 @@ function setupGlobs() {
message += 'No details available';
} else {
message += [
'Message: ' + msg,
'URL: ' + url,
'Line: ' + lineNo,
'Column: ' + columnNo,
'Error object: ' + JSON.stringify(error),
'Stack: ' + (error && error.stack)
`Message: ${msg}`,
`URL: ${url}`,
`Line: ${lineNo}`,
`Column: ${columnNo}`,
`Error object: ${JSON.stringify(error)}`,
`Stack: ${error && error.stack}`
].join(', ');
}

View File

@ -44,7 +44,7 @@ async function checkNoteAccess(notePath, noteContext) {
const resolvedNotePath = await treeService.resolveNotePath(notePath, noteContext.hoistedNoteId);
if (!resolvedNotePath) {
console.log("Cannot activate " + notePath);
console.log(`Cannot activate ${notePath}`);
return false;
}

View File

@ -26,14 +26,14 @@ export async function uploadFiles(parentNoteId, files, options) {
}
({noteId} = await $.ajax({
url: baseApiUrl + 'notes/' + parentNoteId + '/import',
url: `${baseApiUrl}notes/${parentNoteId}/import`,
headers: await server.getHeaders(),
data: formData,
dataType: 'json',
type: 'POST',
timeout: 60 * 60 * 1000,
error: function(xhr) {
toastService.showError("Import failed: " + xhr.responseText);
toastService.showError(`Import failed: ${xhr.responseText}`);
},
contentType: false, // NEEDED, DON'T REMOVE THIS
processData: false, // NEEDED, DON'T REMOVE THIS
@ -59,7 +59,7 @@ ws.subscribeToMessages(async message => {
toastService.closePersistent(message.taskId);
toastService.showError(message.message);
} else if (message.type === 'taskProgressCount') {
toastService.showPersistent(makeToast(message.taskId, "Import in progress: " + message.progressCount));
toastService.showPersistent(makeToast(message.taskId, `Import in progress: ${message.progressCount}`));
} else if (message.type === 'taskSucceeded') {
const toast = makeToast(message.taskId, "Import finished successfully.");
toast.closeAfter = 5000;

View File

@ -86,7 +86,7 @@ async function requireLibrary(library) {
const loadedScriptPromises = {};
async function requireScript(url) {
url = window.glob.assetPath + "/" + url;
url = `${window.glob.assetPath}/${url}`;
if (!loadedScriptPromises[url]) {
loadedScriptPromises[url] = $.ajax({
@ -106,7 +106,7 @@ async function requireCss(url, prependAssetPath = true) {
if (!cssLinks.some(l => l.endsWith(url))) {
if (prependAssetPath) {
url = window.glob.assetPath + "/" + url;
url = `${window.glob.assetPath}/${url}`;
}
$('head').append($('<link rel="stylesheet" type="text/css" />').attr('href', url));

View File

@ -20,7 +20,7 @@ async function createNoteLink(notePath, options = {}) {
if (!notePath.startsWith("root")) {
// all note paths should start with "root/" (except for "root" itself)
// used e.g. to find internal links
notePath = "root/" + notePath;
notePath = `root/${notePath}`;
}
let noteTitle = options.title;
@ -41,12 +41,12 @@ async function createNoteLink(notePath, options = {}) {
const note = await froca.getNote(noteId);
$container
.append($("<span>").addClass("bx " + note.getIcon()))
.append($("<span>").addClass(`bx ${note.getIcon()}`))
.append(" ");
}
const $noteLink = $("<a>", {
href: '#' + notePath,
href: `#${notePath}`,
text: noteTitle
}).attr('data-action', 'note')
.attr('data-note-path', notePath);
@ -70,7 +70,7 @@ async function createNoteLink(notePath, options = {}) {
const parentNotePath = resolvedNotePathSegments.join("/").trim();
if (parentNotePath) {
$container.append($("<small>").text(" (" + await treeService.getNotePathTitle(parentNotePath) + ")"));
$container.append($("<small>").text(` (${await treeService.getNotePathTitle(parentNotePath)})`));
}
}
}

View File

@ -17,9 +17,9 @@ async function autocompleteSourceForCKEditor(queryText) {
return {
action: row.action,
noteTitle: row.noteTitle,
id: '@' + row.notePathTitle,
id: `@${row.notePathTitle}`,
name: row.notePathTitle,
link: '#' + row.notePath,
link: `#${row.notePath}`,
notePath: row.notePath,
highlightedNotePathTitle: row.highlightedNotePathTitle
}
@ -33,9 +33,7 @@ async function autocompleteSourceForCKEditor(queryText) {
async function autocompleteSource(term, cb, options = {}) {
const activeNoteId = appContext.tabManager.getActiveContextNoteId();
let results = await server.get('autocomplete'
+ '?query=' + encodeURIComponent(term)
+ '&activeNoteId=' + activeNoteId);
let results = await server.get(`autocomplete?query=${encodeURIComponent(term)}&activeNoteId=${activeNoteId}`);
if (term.trim().length >= 1 && options.allowCreatingNotes) {
results = [

View File

@ -37,7 +37,7 @@ async function getRenderedContent(note, options = {}) {
}
}
else if (type === 'code') {
const fullNote = await server.get('notes/' + note.noteId);
const fullNote = await server.get(`notes/${note.noteId}`);
$renderedContent.append($("<pre>").text(trim(fullNote.content, options.trim)));
}
@ -64,13 +64,13 @@ async function getRenderedContent(note, options = {}) {
if (type === 'pdf') {
const $pdfPreview = $('<iframe class="pdf-preview" style="width: 100%; flex-grow: 100;"></iframe>');
$pdfPreview.attr("src", openService.getUrlForDownload("api/notes/" + note.noteId + "/open"));
$pdfPreview.attr("src", openService.getUrlForDownload(`api/notes/${note.noteId}/open`));
$content.append($pdfPreview);
}
else if (type === 'audio') {
const $audioPreview = $('<audio controls></audio>')
.attr("src", openService.getUrlForStreaming("api/notes/" + note.noteId + "/open-partial"))
.attr("src", openService.getUrlForStreaming(`api/notes/${note.noteId}/open-partial`))
.attr("type", note.mime)
.css("width", "100%");
@ -78,7 +78,7 @@ async function getRenderedContent(note, options = {}) {
}
else if (type === 'video') {
const $videoPreview = $('<video controls></video>')
.attr("src", openService.getUrlForDownload("api/notes/" + note.noteId + "/open-partial"))
.attr("src", openService.getUrlForDownload(`api/notes/${note.noteId}/open-partial`))
.attr("type", note.mime)
.css("width", "100%");

View File

@ -178,7 +178,7 @@ class NoteListRenderer {
this.viewType = parentNote.type === 'search' ? 'list' : 'grid';
}
this.$noteList.addClass(this.viewType + '-view');
this.$noteList.addClass(`${this.viewType}-view`);
this.showNotePath = showNotePath;
}
@ -267,7 +267,7 @@ class NoteListRenderer {
const {$renderedAttributes} = await attributeRenderer.renderNormalAttributes(note);
const notePath = this.parentNote.type === 'search'
? note.noteId // for search note parent we want to display non-search path
: this.parentNote.noteId + '/' + note.noteId;
: `${this.parentNote.noteId}/${note.noteId}`;
const $card = $('<div class="note-book-card">')
.attr('data-note-id', note.noteId)
@ -345,7 +345,7 @@ class NoteListRenderer {
}
$content.append($renderedContent);
$content.addClass("type-" + type);
$content.addClass(`type-${type}`);
} catch (e) {
console.log(`Caught error while rendering note ${note.noteId} of type ${note.type}: ${e.message}, stack: ${e.stack}`);

View File

@ -50,7 +50,7 @@ async function mouseEnterHandler() {
return;
}
const html = '<div class="note-tooltip-content">' + content + '</div>';
const html = `<div class="note-tooltip-content">${content}</div>`;
// we need to check if we're still hovering over the element
// since the operation to get tooltip content was async, it is possible that
@ -89,7 +89,7 @@ async function renderTooltip(note) {
return;
}
let content = '<h5 class="note-tooltip-title">' + (await treeService.getNoteTitleWithPathAsSuffix(someNotePath)).prop('outerHTML') + '</h5>';
let content = `<h5 class="note-tooltip-title">${(await treeService.getNoteTitleWithPathAsSuffix(someNotePath)).prop('outerHTML')}</h5>`;
const {$renderedAttributes} = await attributeRenderer.renderNormalAttributes(note);
@ -98,9 +98,7 @@ async function renderTooltip(note) {
trim: true
});
content = content
+ '<div class="note-tooltip-attributes">' + $renderedAttributes[0].outerHTML + '</div>'
+ $renderedContent[0].outerHTML;
content = `${content}<div class="note-tooltip-attributes">${$renderedAttributes[0].outerHTML}</div>${$renderedContent[0].outerHTML}`;
return content;
}

View File

@ -2,10 +2,10 @@ import utils from "./utils.js";
import server from "./server.js";
function getFileUrl(noteId) {
return getUrlForDownload("api/notes/" + noteId + "/download");
return getUrlForDownload(`api/notes/${noteId}/download`);
}
function getOpenFileUrl(noteId) {
return getUrlForDownload("api/notes/" + noteId + "/open");
return getUrlForDownload(`api/notes/${noteId}/open`);
}
function download(url) {
@ -19,14 +19,14 @@ function download(url) {
}
function downloadFileNote(noteId) {
const url = getFileUrl(noteId) + '?' + Date.now(); // don't use cache
const url = `${getFileUrl(noteId)}?${Date.now()}`; // don't use cache
download(url);
}
async function openNoteExternally(noteId, mime) {
if (utils.isElectron()) {
const resp = await server.post("notes/" + noteId + "/save-to-tmp-dir");
const resp = await server.post(`notes/${noteId}/save-to-tmp-dir`);
const electron = utils.dynamicRequire('electron');
const res = await electron.shell.openPath(resp.tmpFilePath);
@ -59,7 +59,7 @@ function downloadNoteRevision(noteId, noteRevisionId) {
function getUrlForDownload(url) {
if (utils.isElectron()) {
// electron needs absolute URL so we extract current host, port, protocol
return getHost() + '/' + url;
return `${getHost()}/${url}`;
}
else {
// web server can be deployed on subdomain so we need to use relative path
@ -69,7 +69,7 @@ function getUrlForDownload(url) {
function getHost() {
const url = new URL(window.location.href);
return url.protocol + "//" + url.hostname + ":" + url.port;
return `${url.protocol}//${url.hostname}:${url.port}`;
}
export default {

View File

@ -88,7 +88,7 @@ async function protectNote(noteId, protect, includingSubtree) {
function makeToast(message, protectingLabel, text) {
return {
id: message.taskId,
title: protectingLabel + " status",
title: `${protectingLabel} status`,
message: text,
icon: message.data.protect ? "check-shield" : "shield"
};
@ -105,9 +105,9 @@ ws.subscribeToMessages(async message => {
toastService.closePersistent(message.taskId);
toastService.showError(message.message);
} else if (message.type === 'taskProgressCount') {
toastService.showPersistent(makeToast(message, protectingLabel,protectingLabel + " in progress: " + message.progressCount));
toastService.showPersistent(makeToast(message, protectingLabel,`${protectingLabel} in progress: ${message.progressCount}`));
} else if (message.type === 'taskSucceeded') {
const toast = makeToast(message, protectingLabel, protectingLabel + " finished successfully.");
const toast = makeToast(message, protectingLabel, `${protectingLabel} finished successfully.`);
toast.closeAfter = 3000;
toastService.showPersistent(toast);

View File

@ -10,7 +10,7 @@ async function render(note, $el) {
$el.empty().toggle(renderNoteIds.length > 0);
for (const renderNoteId of renderNoteIds) {
const bundle = await server.get('script/bundle/' + renderNoteId);
const bundle = await server.get(`script/bundle/${renderNoteId}`);
const $scriptContainer = $('<div>');
$el.append($scriptContainer);

View File

@ -20,7 +20,7 @@ async function ScriptContext(startNoteId, allNoteIds, originEntity = null, $cont
const note = candidates.find(c => c.title === moduleName);
if (!note) {
throw new Error("Could not find module note " + moduleName);
throw new Error(`Could not find module note ${moduleName}`);
}
return modules[note.noteId].exports;

View File

@ -2,7 +2,7 @@ import server from "./server.js";
import froca from "./froca.js";
async function searchForNoteIds(searchString) {
return await server.get('search/' + encodeURIComponent(searchString));
return await server.get(`search/${encodeURIComponent(searchString)}`);
}
async function searchForNotes(searchString) {

View File

@ -72,14 +72,14 @@ async function call(method, url, data, headers = {}) {
reqRejects[requestId] = reject;
if (REQUEST_LOGGING_ENABLED) {
console.log(utils.now(), "Request #" + requestId + " to " + method + " " + url);
console.log(utils.now(), `Request #${requestId} to ${method} ${url}`);
}
ipc.send('server-request', {
requestId: requestId,
headers: headers,
method: method,
url: "/" + baseApiUrl + url,
url: `/${baseApiUrl}${url}`,
data: data
});
});
@ -117,7 +117,7 @@ async function reportError(method, url, statusCode, response) {
toastService.showError(response.message);
throw new ValidationError(response);
} else {
const message = "Error when calling " + method + " " + url + ": " + statusCode + " - " + response;
const message = `Error when calling ${method} ${url}: ${statusCode} - ${response}`;
toastService.showError(message);
toastService.throwError(message);
}
@ -169,7 +169,7 @@ if (utils.isElectron()) {
ipc.on('server-response', async (event, arg) => {
if (REQUEST_LOGGING_ENABLED) {
console.log(utils.now(), "Response #" + arg.requestId + ": " + arg.statusCode);
console.log(utils.now(), `Response #${arg.requestId}: ${arg.statusCode}`);
}
if (arg.statusCode >= 200 && arg.statusCode < 300) {

View File

@ -15,7 +15,7 @@ function bindElShortcut($el, keyboardShortcut, handler, namespace = null) {
let eventName = 'keydown';
if (namespace) {
eventName += "." + namespace;
eventName += `.${namespace}`;
// if there's a namespace then we replace the existing event handler with the new one
$el.off(eventName);

View File

@ -9,17 +9,17 @@ async function syncNow(ignoreNotConfigured = false) {
}
else {
if (result.message.length > 200) {
result.message = result.message.substr(0, 200) + "...";
result.message = `${result.message.substr(0, 200)}...`;
}
if (!ignoreNotConfigured || result.errorCode !== 'NOT_CONFIGURED') {
toastService.showError("Sync failed: " + result.message);
toastService.showError(`Sync failed: ${result.message}`);
}
}
}
async function forceNoteSync(noteId) {
await server.post('sync/force-note-sync/' + noteId);
await server.post(`sync/force-note-sync/${noteId}`);
toastService.showMessage("Note added to sync queue.");
}

View File

@ -16,7 +16,7 @@ function toast(options) {
$toast.find('.toast-body').text(options.message);
if (options.id) {
$toast.attr("id", "toast-" + options.id);
$toast.attr("id", `toast-${options.id}`);
}
$("#toast-container").append($toast);
@ -34,7 +34,7 @@ function toast(options) {
}
function showPersistent(options) {
let $toast = $("#toast-" + options.id);
let $toast = $(`#toast-${options.id}`);
if ($toast.length > 0) {
$toast.find('.toast-body').html(options.message);
@ -51,7 +51,7 @@ function showPersistent(options) {
}
function closePersistent(id) {
$("#toast-" + id).remove();
$(`#toast-${id}`).remove();
}
function showMessage(message, delay = 2000) {

View File

@ -292,7 +292,7 @@ async function getNoteTitleWithPathAsSuffix(notePath) {
if (path.length > 0) {
$titleWithPath
.append($('<span class="note-path">').text(' (' + path.join(' / ') + ')'));
.append($('<span class="note-path">').text(` (${path.join(' / ')})`));
}
return $titleWithPath;

View File

@ -1,6 +1,6 @@
function reloadFrontendApp(reason) {
if (reason) {
logInfo("Frontend app reload: " + reason);
logInfo(`Frontend app reload: ${reason}`);
}
window.location.reload(true);
@ -11,20 +11,20 @@ function parseDate(str) {
return new Date(Date.parse(str));
}
catch (e) {
throw new Error("Can't parse date from " + str + ": " + e.stack);
throw new Error(`Can't parse date from ${str}: ${e.stack}`);
}
}
function padNum(num) {
return (num <= 9 ? "0" : "") + num;
return `${num <= 9 ? "0" : ""}${num}`;
}
function formatTime(date) {
return padNum(date.getHours()) + ":" + padNum(date.getMinutes());
return `${padNum(date.getHours())}:${padNum(date.getMinutes())}`;
}
function formatTimeWithSeconds(date) {
return padNum(date.getHours()) + ":" + padNum(date.getMinutes()) + ":" + padNum(date.getSeconds());
return `${padNum(date.getHours())}:${padNum(date.getMinutes())}:${padNum(date.getSeconds())}`;
}
// this is producing local time!
@ -37,11 +37,11 @@ function formatDate(date) {
// this is producing local time!
function formatDateISO(date) {
return date.getFullYear() + "-" + padNum(date.getMonth() + 1) + "-" + padNum(date.getDate());
return `${date.getFullYear()}-${padNum(date.getMonth() + 1)}-${padNum(date.getDate())}`;
}
function formatDateTime(date) {
return formatDate(date) + " " + formatTime(date);
return `${formatDate(date)} ${formatTime(date)}`;
}
function localNowDateTime() {
@ -101,14 +101,14 @@ async function stopWatch(what, func) {
}
function formatValueWithWhitespace(val) {
return /[^\w_-]/.test(val) ? '"' + val + '"' : val;
return /[^\w_-]/.test(val) ? `"${val}"` : val;
}
function formatLabel(label) {
let str = "#" + formatValueWithWhitespace(label.name);
let str = `#${formatValueWithWhitespace(label.name)}`;
if (label.value !== "") {
str += "=" + formatValueWithWhitespace(label.value);
str += `=${formatValueWithWhitespace(label.value)}`;
}
return str;
@ -154,22 +154,22 @@ function isDesktop() {
function setCookie(name, value) {
const date = new Date(Date.now() + 10 * 365 * 24 * 60 * 60 * 1000);
const expires = "; expires=" + date.toUTCString();
const expires = `; expires=${date.toUTCString()}`;
document.cookie = name + "=" + (value || "") + expires + ";";
document.cookie = `${name}=${value || ""}${expires};`;
}
function setSessionCookie(name, value) {
document.cookie = name + "=" + (value || "") + "; SameSite=Strict";
document.cookie = `${name}=${value || ""}; SameSite=Strict`;
}
function getCookie(name) {
const valueMatch = document.cookie.match('(^|;) ?' + name + '=([^;]*)(;|$)');
const valueMatch = document.cookie.match(`(^|;) ?${name}=([^;]*)(;|$)`);
return valueMatch ? valueMatch[2] : null;
}
function getNoteTypeClass(type) {
return "type-" + type;
return `type-${type}`;
}
function getMimeTypeClass(mime) {
@ -184,7 +184,7 @@ function getMimeTypeClass(mime) {
mime = mime.substr(0, semicolonIdx);
}
return 'mime-' + mime.toLowerCase().replace(/[\W_]+/g,"-");
return `mime-${mime.toLowerCase().replace(/[\W_]+/g, "-")}`;
}
function closeActiveDialog() {

View File

@ -195,8 +195,7 @@ async function consumeFrontendUpdateData() {
function connectWebSocket() {
const loc = window.location;
const webSocketUri = (loc.protocol === "https:" ? "wss:" : "ws:")
+ "//" + loc.host + loc.pathname;
const webSocketUri = `${loc.protocol === "https:" ? "wss:" : "ws:"}//${loc.host}${loc.pathname}`;
// use wss for secure messaging
const ws = new WebSocket(webSocketUri);

View File

@ -8,7 +8,7 @@ function SetupModel() {
setInterval(checkOutstandingSyncs, 1000);
}
const serverAddress = location.protocol + '//' + location.host;
const serverAddress = `${location.protocol}//${location.host}`;
$("#current-host").html(serverAddress);
@ -74,7 +74,7 @@ function SetupModel() {
hideAlert();
}
else {
showAlert('Sync setup failed: ' + resp.error);
showAlert(`Sync setup failed: ${resp.error}`);
}
};
}

View File

@ -628,9 +628,9 @@ export default class AttributeDetailWidget extends NoteContextAwareWidget {
}
if (this.attrType === 'label-definition') {
attrName = 'label:' + attrName;
attrName = `label:${attrName}`;
} else if (this.attrType === 'relation-definition') {
attrName = 'relation:' + attrName;
attrName = `relation:${attrName}`;
}
this.attribute.name = attrName;
@ -662,12 +662,12 @@ export default class AttributeDetailWidget extends NoteContextAwareWidget {
props.push(this.$inputLabelType.val());
if (this.$inputLabelType.val() === 'number' && this.$inputNumberPrecision.val() !== '') {
props.push('precision=' + this.$inputNumberPrecision.val());
props.push(`precision=${this.$inputNumberPrecision.val()}`);
}
} else if (this.attrType === 'relation-definition' && this.$inputInverseRelation.val().trim().length > 0) {
const inverseRelationName = this.$inputInverseRelation.val();
props.push("inverse=" + utils.filterAttributeName(inverseRelationName));
props.push(`inverse=${utils.filterAttributeName(inverseRelationName)}`);
}
this.$rowNumberPrecision.toggle(
@ -683,7 +683,7 @@ export default class AttributeDetailWidget extends NoteContextAwareWidget {
createNoteLink(noteId) {
return $("<a>", {
href: '#' + noteId,
href: `#${noteId}`,
class: 'reference-link',
'data-note-path': noteId
});

View File

@ -99,7 +99,7 @@ const mentionSetup = {
return names.map(name => {
return {
id: '#' + name,
id: `#${name}`,
name: name
}
});
@ -114,7 +114,7 @@ const mentionSetup = {
return names.map(name => {
return {
id: '~' + name,
id: `~${name}`,
name: name
}
});

View File

@ -20,7 +20,7 @@ export default class BookmarkSwitchWidget extends SwitchWidget {
}
async toggle(state) {
const resp = await server.put(`notes/${this.noteId}/toggle-in-parent/lbBookmarks/` + !!state);
const resp = await server.put(`notes/${this.noteId}/toggle-in-parent/lbBookmarks/${!!state}`);
if (!resp.success) {
toastService.showError(resp.message);

View File

@ -78,7 +78,7 @@ export default class CalendarWidget extends RightDropdownButtonWidget {
init(activeDate) {
// attaching time fixes local timezone handling
this.activeDate = activeDate ? new Date(activeDate + "T12:00:00") : null;
this.activeDate = activeDate ? new Date(`${activeDate}T12:00:00`) : null;
this.todaysDate = new Date();
this.date = new Date((this.activeDate || this.todaysDate).getTime());
this.date.setDate(1);
@ -97,7 +97,7 @@ export default class CalendarWidget extends RightDropdownButtonWidget {
if (day === 0) {
$newDay.css("marginLeft", (6 * 14.28) + '%');
} else {
$newDay.css("marginLeft", ((day - 1) * 14.28) + '%');
$newDay.css("marginLeft", `${(day - 1) * 14.28}%`);
}
}
@ -132,7 +132,7 @@ export default class CalendarWidget extends RightDropdownButtonWidget {
async createMonth() {
const month = utils.formatDateISO(this.date).substr(0, 7);
const dateNotesForMonth = await server.get('special-notes/notes-for-month/' + month);
const dateNotesForMonth = await server.get(`special-notes/notes-for-month/${month}`);
this.$month.empty();
@ -153,7 +153,7 @@ export default class CalendarWidget extends RightDropdownButtonWidget {
this.date.setDate(1);
this.date.setMonth(this.date.getMonth() - 1);
this.$label.html(this.monthsAsString(this.date.getMonth()) + ' ' + this.date.getFullYear());
this.$label.html(`${this.monthsAsString(this.date.getMonth())} ${this.date.getFullYear()}`);
}
monthsAsString(monthIndex) {

View File

@ -281,7 +281,7 @@ export default class GlobalMenuWidget extends BasicWidget {
const zoomFactor = utils.dynamicRequire('electron').webFrame.getZoomFactor();
const zoomPercent = Math.round(zoomFactor * 100);
this.$zoomState.text(zoomPercent + "%");
this.$zoomState.text(`${zoomPercent}%`);
}
async updateVersionStatus() {

View File

@ -20,7 +20,7 @@ export default class CollapsibleWidget extends NoteContextAwareWidget {
doRender() {
this.$widget = $(WIDGET_TPL);
this.contentSized();
this.$widget.find('[data-target]').attr('data-target', "#" + this.componentId);
this.$widget.find('[data-target]').attr('data-target', `#${this.componentId}`);
this.$bodyWrapper = this.$widget.find('.body-wrapper');
this.$bodyWrapper.attr('id', this.componentId); // for toggle to work we need id

View File

@ -70,7 +70,7 @@ export default class AboutDialog extends BasicWidget {
this.$syncVersion.text(appInfo.syncVersion);
this.$buildDate.text(appInfo.buildDate);
this.$buildRevision.text(appInfo.buildRevision);
this.$buildRevision.attr('href', 'https://github.com/zadam/trilium/commit/' + appInfo.buildRevision);
this.$buildRevision.attr('href', `https://github.com/zadam/trilium/commit/${appInfo.buildRevision}`);
this.$dataDirectory.text(appInfo.dataDirectory);
}

View File

@ -82,7 +82,7 @@ export default class BranchPrefixDialog extends BasicWidget {
const noteTitle = await treeService.getNoteTitle(noteId);
this.$noteTitle.text(" - " + noteTitle);
this.$noteTitle.text(` - ${noteTitle}`);
}
async editBranchPrefixEvent() {

View File

@ -130,7 +130,7 @@ export default class BulkActionsDialog extends BasicWidget {
for (const actionGroup of bulkActionService.ACTION_GROUPS) {
const $actionGroupList = $("<td>");
const $actionGroup = $("<tr>")
.append($("<td>").text(actionGroup.title + ": "))
.append($("<td>").text(`${actionGroup.title}: `))
.append($actionGroupList);
for (const action of actionGroup.actions) {

View File

@ -96,7 +96,7 @@ export default class ConfirmDialog extends BasicWidget {
.append(
$("<input>")
.attr("type", "checkbox")
.addClass("form-check-input " + DELETE_NOTE_BUTTON_CLASS)
.addClass(`form-check-input ${DELETE_NOTE_BUTTON_CLASS}`)
)
.append("Also delete the note")
));
@ -111,7 +111,7 @@ export default class ConfirmDialog extends BasicWidget {
doResolve(ret) {
this.resolve({
confirmed: ret,
isDeleteNoteChecked: this.$widget.find("." + DELETE_NOTE_BUTTON_CLASS + ":checked").length > 0
isDeleteNoteChecked: this.$widget.find(`.${DELETE_NOTE_BUTTON_CLASS}:checked`).length > 0
});
this.resolve = null;

View File

@ -203,7 +203,7 @@ export default class ExportDialog extends BasicWidget {
this.$singleType.prop("checked", true).trigger('change');
}
else {
throw new Error("Unrecognized type " + defaultType);
throw new Error(`Unrecognized type ${defaultType}`);
}
this.$widget.find(".opml-v2").prop("checked", true); // setting default
@ -242,7 +242,7 @@ ws.subscribeToMessages(async message => {
toastService.showError(message.message);
}
else if (message.type === 'taskProgressCount') {
toastService.showPersistent(makeToast(message.taskId, "Export in progress: " + message.progressCount));
toastService.showPersistent(makeToast(message.taskId, `Export in progress: ${message.progressCount}`));
}
else if (message.type === 'taskSucceeded') {
const toast = makeToast(message.taskId, "Export finished successfully.");

View File

@ -147,9 +147,9 @@ export default class NoteRevisionsDialog extends BasicWidget {
for (const item of this.revisionItems) {
this.$list.append(
$('<a class="dropdown-item" tabindex="0">')
.text(item.dateLastEdited.substr(0, 16) + ` (${item.contentLength} bytes)`)
.text(`${item.dateLastEdited.substr(0, 16)} (${item.contentLength} bytes)`)
.attr('data-note-revision-id', item.noteRevisionId)
.attr('title', 'This revision was last edited on ' + item.dateLastEdited)
.attr('title', `This revision was last edited on ${item.dateLastEdited}`)
);
}
@ -241,7 +241,7 @@ export default class NoteRevisionsDialog extends BasicWidget {
this.$content.html($("<img>")
// reason why we put this inline as base64 is that we do not want to let user to copy this
// as a URL to be used in a note. Instead if they copy and paste it into a note, it will be a uploaded as a new note
.attr("src", `data:${note.mime};base64,` + fullNoteRevision.content)
.attr("src", `data:${note.mime};base64,${fullNoteRevision.content}`)
.css("max-width", "100%")
.css("max-height", "100%"));
}
@ -253,7 +253,7 @@ export default class NoteRevisionsDialog extends BasicWidget {
))
.append($("<tr>").append(
$("<th>").text("File size:"),
$("<td>").text(revisionItem.contentLength + " bytes")
$("<td>").text(`${revisionItem.contentLength} bytes`)
));
if (fullNoteRevision.content) {

View File

@ -54,13 +54,15 @@ export default class NoteSourceDialog extends BasicWidget {
let textNode;
for (let i = 0; i < node.children.length; i++) {
textNode = document.createTextNode('\n' + indentBefore);
textNode = document.createTextNode(`
${indentBefore}`);
node.insertBefore(textNode, node.children[i]);
this.formatNode(node.children[i], level);
if (node.lastElementChild === node.children[i]) {
textNode = document.createTextNode('\n' + indentAfter);
textNode = document.createTextNode(`
${indentAfter}`);
node.appendChild(textNode);
}
}

View File

@ -110,7 +110,7 @@ export default class NoteTypeChooserDialog extends BasicWidget {
.attr("data-note-type", noteType.type)
.attr("data-template-note-id", noteType.templateNoteId)
.append($("<span>").addClass(noteType.uiIcon))
.append(" " + noteType.title)
.append(` ${noteType.title}`)
);
}
}

View File

@ -57,7 +57,7 @@ export default class RecentChangesDialog extends BasicWidget {
this.ancestorNoteId = hoistedNoteService.getHoistedNoteId();
}
const recentChangesRows = await server.get('recent-changes/' + this.ancestorNoteId);
const recentChangesRows = await server.get(`recent-changes/${this.ancestorNoteId}`);
// preload all notes into cache
await froca.getNotes(recentChangesRows.map(r => r.noteId), true);

View File

@ -37,7 +37,7 @@ export default class FindInHtml {
separateWordSearch: false,
caseSensitive: matchCase,
done: async () => {
this.$results = $content.find("." + FIND_RESULT_CSS_CLASSNAME);
this.$results = $content.find(`.${FIND_RESULT_CSS_CLASSNAME}`);
this.currentIndex = 0;
await this.jumpTo();

View File

@ -58,7 +58,7 @@ export default class CodeButtonsWidget extends NoteContextAwareWidget {
await appContext.tabManager.getActiveContext().setNote(notePath);
toastService.showMessage("SQL Console note has been saved into " + await treeService.getNotePathTitle(notePath));
toastService.showMessage(`SQL Console note has been saved into ${await treeService.getNotePathTitle(notePath)}`);
});
keyboardActionService.updateDisplayedShortcuts(this.$widget);

View File

@ -133,7 +133,7 @@ export default class BacklinksWidget extends NoteContextAwareWidget {
}));
if (backlink.relationName) {
$item.append($("<p>").text("relation: " + backlink.relationName));
$item.append($("<p>").text(`relation: ${backlink.relationName}`));
}
else {
$item.append(...backlink.excerpts);

View File

@ -78,9 +78,9 @@ export default class MermaidWidget extends NoteContextAwareWidget {
await wheelZoomLoaded;
this.$display.attr("id", 'mermaid-render-' + idCounter);
this.$display.attr("id", `mermaid-render-${idCounter}`);
WZoom.create('#mermaid-render-' + idCounter, {
WZoom.create(`#mermaid-render-${idCounter}`, {
type: 'html',
maxScale: 10,
speed: 20,
@ -101,7 +101,7 @@ export default class MermaidWidget extends NoteContextAwareWidget {
const noteComplement = await froca.getNoteComplement(this.noteId);
const content = noteComplement.content || "";
mermaid.mermaidAPI.render('mermaid-graph-' + idCounter, content, res);
mermaid.mermaidAPI.render(`mermaid-graph-${idCounter}`, content, res);
});
}
@ -118,12 +118,12 @@ export default class MermaidWidget extends NoteContextAwareWidget {
const renderedSvg = await this.renderSvg();
this.download(this.note.title + ".svg", renderedSvg);
this.download(`${this.note.title}.svg`, renderedSvg);
}
download(filename, text) {
const element = document.createElement('a');
element.setAttribute('href', 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(text));
element.setAttribute('href', `data:image/svg+xml;charset=utf-8,${encodeURIComponent(text)}`);
element.setAttribute('download', filename);
element.style.display = 'none';

View File

@ -40,7 +40,7 @@ class MobileDetailMenuWidget extends BasicWidget {
}
}
else {
throw new Error("Unrecognized command " + command);
throw new Error(`Unrecognized command ${command}`);
}
}
});

View File

@ -170,7 +170,7 @@ export default class NoteDetailWidget extends NoteContextAwareWidget {
getTypeWidget() {
if (!this.typeWidgets[this.type]) {
throw new Error("Could not find typeWidget for type: " + this.type);
throw new Error(`Could not find typeWidget for type: ${this.type}`);
}
return this.typeWidgets[this.type];
@ -268,13 +268,13 @@ export default class NoteDetailWidget extends NoteContextAwareWidget {
`,
importCSS: false,
loadCSS: [
assetPath + "/libraries/codemirror/codemirror.css",
assetPath + "/libraries/ckeditor/ckeditor-content.css",
assetPath + "/libraries/bootstrap/css/bootstrap.min.css",
assetPath + "/libraries/katex/katex.min.css",
assetPath + "/stylesheets/print.css",
assetPath + "/stylesheets/relation_map.css",
assetPath + "/stylesheets/ckeditor-theme.css"
`${assetPath}/libraries/codemirror/codemirror.css`,
`${assetPath}/libraries/ckeditor/ckeditor-content.css`,
`${assetPath}/libraries/bootstrap/css/bootstrap.min.css`,
`${assetPath}/libraries/katex/katex.min.css`,
`${assetPath}/stylesheets/print.css`,
`${assetPath}/stylesheets/relation_map.css`,
`${assetPath}/stylesheets/ckeditor-theme.css`
],
debug: true
});

View File

@ -119,7 +119,7 @@ export default class NoteIconWidget extends NoteContextAwareWidget {
}
async refreshWithNote(note) {
this.$icon.removeClass().addClass(note.getIcon() + " note-icon");
this.$icon.removeClass().addClass(`${note.getIcon()} note-icon`);
}
async entitiesReloadedEvent({loadResults}) {
@ -193,13 +193,13 @@ export default class NoteIconWidget extends NoteContextAwareWidget {
getIconClass(icon) {
if (icon.type_of_icon === 'LOGO') {
return "bx bxl-" + icon.name;
return `bx bxl-${icon.name}`;
}
else if (icon.type_of_icon === 'SOLID') {
return "bx bxs-" + icon.name;
return `bx bxs-${icon.name}`;
}
else {
return "bx bx-" + icon.name;
return `bx bx-${icon.name}`;
}
}
}

View File

@ -163,7 +163,7 @@ export default class NoteMapWidget extends NoteContextAwareWidget {
generateColorFromString(str) {
if (this.themeStyle === "dark") {
str = "0" + str; // magic lightening modifier
str = `0${str}`; // magic lightening modifier
}
let hash = 0;
@ -175,7 +175,7 @@ export default class NoteMapWidget extends NoteContextAwareWidget {
for (let i = 0; i < 3; i++) {
const value = (hash >> (i * 8)) & 0xFF;
color += ('00' + value.toString(16)).substr(-2);
color += (`00${value.toString(16)}`).substr(-2);
}
return color;
}
@ -209,14 +209,14 @@ export default class NoteMapWidget extends NoteContextAwareWidget {
}
ctx.fillStyle = this.css.textColor;
ctx.font = size + 'px ' + this.css.fontFamily;
ctx.font = `${size}px ${this.css.fontFamily}`;
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
let title = node.name;
if (title.length > 15) {
title = title.substr(0, 15) + "...";
title = `${title.substr(0, 15)}...`;
}
ctx.fillText(title, x, y + Math.round(size * 1.5));
@ -227,7 +227,7 @@ export default class NoteMapWidget extends NoteContextAwareWidget {
return;
}
ctx.font = '3px ' + this.css.fontFamily;
ctx.font = `3px ${this.css.fontFamily}`;
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.fillStyle = this.css.mutedTextColor;

View File

@ -273,19 +273,19 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
}
get hideArchivedNotes() {
return options.is("hideArchivedNotes_" + this.treeName);
return options.is(`hideArchivedNotes_${this.treeName}`);
}
async setHideArchivedNotes(val) {
await options.save("hideArchivedNotes_" + this.treeName, val.toString());
await options.save(`hideArchivedNotes_${this.treeName}`, val.toString());
}
get hideIncludedImages() {
return options.is("hideIncludedImages_" + this.treeName);
return options.is(`hideIncludedImages_${this.treeName}`);
}
async setHideIncludedImages(val) {
await options.save("hideIncludedImages_" + this.treeName, val.toString());
await options.save(`hideIncludedImages_${this.treeName}`, val.toString());
}
get autoCollapseNoteTree() {
@ -484,7 +484,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
} else if (data.hitMode === "over") {
branchService.moveToParentNote(selectedBranchIds, node.data.branchId);
} else {
throw new Error("Unknown hitMode=" + data.hitMode);
throw new Error(`Unknown hitMode=${data.hitMode}`);
}
}
}
@ -676,7 +676,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
return;
}
const title = (branch.prefix ? (branch.prefix + " - ") : "") + note.title;
const title = `${branch.prefix ? (`${branch.prefix} - `) : ""}${note.title}`;
node.data.isProtected = note.isProtected;
node.data.noteType = note.type;
@ -703,7 +703,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
throw new Error(`Branch "${branch.branchId}" has no child note "${branch.noteId}"`);
}
const title = (branch.prefix ? (branch.prefix + " - ") : "") + note.title;
const title = `${branch.prefix ? (`${branch.prefix} - `) : ""}${note.title}`;
const isFolder = note.isFolder();

View File

@ -139,7 +139,7 @@ export default class NoteTypeWidget extends NoteContextAwareWidget {
return;
}
await server.put('notes/' + this.noteId + '/type', { type, mime });
await server.put(`notes/${this.noteId}/type`, { type, mime });
}
async confirmChangeIfContent() {

View File

@ -98,12 +98,12 @@ export default class QuickSearchWidget extends BasicWidget {
this.$dropdownMenu.empty();
this.$dropdownMenu.append('<span class="dropdown-item disabled"><span class="bx bx-loader bx-spin"></span> Searching ...</span>');
const {searchResultNoteIds, error} = await server.get('quick-search/' + encodeURIComponent(searchString));
const {searchResultNoteIds, error} = await server.get(`quick-search/${encodeURIComponent(searchString)}`);
if (error) {
this.$searchString.tooltip({
trigger: 'manual',
title: "Search error: " + error,
title: `Search error: ${error}`,
placement: 'right'
});

View File

@ -48,7 +48,7 @@ export default class EditedNotesWidget extends CollapsibleWidget {
}
async refreshWithNote(note) {
let editedNotes = await server.get('edited-notes/' + note.getLabelValue("dateNote"));
let editedNotes = await server.get(`edited-notes/${note.getLabelValue("dateNote")}`);
editedNotes = editedNotes.filter(n => n.noteId !== note.noteId);
@ -69,7 +69,7 @@ export default class EditedNotesWidget extends CollapsibleWidget {
const $item = $('<span class="edited-note-line">');
if (editedNote.isDeleted) {
const title = editedNote.title + " (deleted)";
const title = `${editedNote.title} (deleted)`;
$item.append(
$("<i>")
.text(title)

View File

@ -104,7 +104,7 @@ export default class FilePropertiesWidget extends NoteContextAwareWidget {
formData.append('upload', fileToUpload);
const result = await $.ajax({
url: baseApiUrl + 'notes/' + this.noteId + '/file',
url: `${baseApiUrl}notes/${this.noteId}/file`,
headers: await server.getHeaders(),
data: formData,
type: 'PUT',
@ -136,7 +136,7 @@ export default class FilePropertiesWidget extends NoteContextAwareWidget {
const noteComplement = await this.noteContext.getNoteComplement();
this.$fileSize.text(noteComplement.contentLength + " bytes");
this.$fileSize.text(`${noteComplement.contentLength} bytes`);
// open doesn't work for protected notes since it works through browser which isn't in protected session
this.$openButton.toggle(!note.isProtected);

View File

@ -88,7 +88,7 @@ export default class ImagePropertiesWidget extends NoteContextAwareWidget {
formData.append('upload', fileToUpload);
const result = await $.ajax({
url: baseApiUrl + 'images/' + this.noteId,
url: `${baseApiUrl}images/${this.noteId}`,
headers: await server.getHeaders(),
data: formData,
type: 'PUT',
@ -105,7 +105,7 @@ export default class ImagePropertiesWidget extends NoteContextAwareWidget {
this.refresh();
}
else {
toastService.showError("Upload of a new image revision failed: " + result.message);
toastService.showError(`Upload of a new image revision failed: ${result.message}`);
}
});
}
@ -119,7 +119,7 @@ export default class ImagePropertiesWidget extends NoteContextAwareWidget {
const noteComplement = await this.noteContext.getNoteComplement();
this.$fileName.text(attributeMap.originalFileName || "?");
this.$fileSize.text(noteComplement.contentLength + " bytes");
this.$fileSize.text(`${noteComplement.contentLength} bytes`);
this.$fileType.text(note.mime);
}
}

View File

@ -110,7 +110,7 @@ export default class NoteInfoWidget extends NoteContextAwareWidget {
const subTreeResp = await server.get(`stats/subtree-size/${this.noteId}`);
if (subTreeResp.subTreeNoteCount > 1) {
this.$subTreeSize.text("(subtree size: " + this.formatSize(subTreeResp.subTreeSize) + ` in ${subTreeResp.subTreeNoteCount} notes)`);
this.$subTreeSize.text(`(subtree size: ${this.formatSize(subTreeResp.subTreeSize)} in ${subTreeResp.subTreeNoteCount} notes)`);
}
else {
this.$subTreeSize.text("");
@ -133,7 +133,7 @@ export default class NoteInfoWidget extends NoteContextAwareWidget {
this.$type.text(note.type);
if (note.mime) {
this.$mime.text('(' + note.mime + ')');
this.$mime.text(`(${note.mime})`);
}
else {
this.$mime.empty();

View File

@ -139,7 +139,7 @@ export default class PromotedAttributesWidget extends NoteContextAwareWidget {
$input.prop("type", "text");
// no need to await for this, can be done asynchronously
server.get('attributes/values/' + encodeURIComponent(valueAttr.name)).then(attributeValues => {
server.get(`attributes/values/${encodeURIComponent(valueAttr.name)}`).then(attributeValues => {
if (attributeValues.length === 0) {
return;
}
@ -207,7 +207,7 @@ export default class PromotedAttributesWidget extends NoteContextAwareWidget {
.append($openButton));
}
else {
ws.logError("Unknown labelType=" + definitionAttr.labelType);
ws.logError(`Unknown labelType=${definitionAttr.labelType}`);
}
}
else if (valueAttr.type === 'relation') {
@ -225,7 +225,7 @@ export default class PromotedAttributesWidget extends NoteContextAwareWidget {
$input.setSelectedNotePath(valueAttr.value);
}
else {
ws.logError("Unknown attribute type=" + valueAttr.type);
ws.logError(`Unknown attribute type=${valueAttr.type}`);
return;
}
@ -253,7 +253,7 @@ export default class PromotedAttributesWidget extends NoteContextAwareWidget {
const attributeId = $input.attr("data-attribute-id");
if (attributeId) {
await server.remove("notes/" + this.noteId + "/attributes/" + attributeId, this.componentId);
await server.remove(`notes/${this.noteId}/attributes/${attributeId}`, this.componentId);
}
// if it's the last one the create new empty form immediately

View File

@ -244,7 +244,7 @@ export default class SearchDefinitionWidget extends NoteContextAwareWidget {
await appContext.tabManager.getActiveContext().setNote(notePath);
toastService.showMessage("Search note has been saved into " + await treeService.getNotePathTitle(notePath));
toastService.showMessage(`Search note has been saved into ${await treeService.getNotePathTitle(notePath)}`);
});
}

View File

@ -64,7 +64,7 @@ export default class SimilarNotesWidget extends NoteContextAwareWidget {
// remember which title was when we found the similar notes
this.title = this.note.title;
const similarNotes = await server.get('similar-notes/' + this.noteId);
const similarNotes = await server.get(`similar-notes/${this.noteId}`);
if (similarNotes.length === 0) {
this.$similarNotesWrapper.empty().append("No similar notes found.");

View File

@ -61,7 +61,7 @@ export default class SearchString extends AbstractSearchOption {
if (this.note.title.startsWith('Search: ')) {
await server.put(`notes/${this.note.noteId}/title`, {
title: 'Search: ' + (searchString.length < 30 ? searchString : `${searchString.substr(0, 30)}`)
title: `Search: ${searchString.length < 30 ? searchString : `${searchString.substr(0, 30)}`}`
});
}
}, 1000);
@ -74,7 +74,7 @@ export default class SearchString extends AbstractSearchOption {
showSearchErrorEvent({error}) {
this.$searchString.tooltip({
trigger: 'manual',
title: "Search error: " + error,
title: `Search error: ${error}`,
placement: 'bottom'
});

View File

@ -35,11 +35,11 @@ export default class SharedInfoWidget extends NoteContextAwareWidget {
const shareId = this.getShareId(note);
if (syncServerHost) {
link = syncServerHost + "/share/" + shareId;
link = `${syncServerHost}/share/${shareId}`;
this.$sharedText.text("This note is shared publicly on");
}
else {
link = location.protocol + '//' + location.host + location.pathname + "share/" + shareId;
link = `${location.protocol}//${location.host}${location.pathname}share/${shareId}`;
this.$sharedText.text("This note is shared locally on");
}

View File

@ -105,7 +105,7 @@ export default class SyncStatusWidget extends BasicWidget {
this.$widget.show();
this.$widget.find('.sync-status-icon').hide();
this.$widget.find('.sync-status-' + className).show();
this.$widget.find(`.sync-status-${className}`).show();
}
processMessage(message) {
@ -134,7 +134,7 @@ export default class SyncStatusWidget extends BasicWidget {
if (['unknown', 'in-progress'].includes(this.syncState)) {
this.showIcon(this.syncState);
} else {
this.showIcon(this.syncState + '-' + (this.allChangesPushed ? 'no-changes' : 'with-changes'));
this.showIcon(`${this.syncState}-${this.allChangesPushed ? 'no-changes' : 'with-changes'}`);
}
}
}

File diff suppressed because one or more lines are too long

View File

@ -44,7 +44,7 @@ export default class EditableCodeTypeWidget extends TypeWidget {
delete CodeMirror.keyMap.default["Alt-Left"];
delete CodeMirror.keyMap.default["Alt-Right"];
CodeMirror.modeURL = window.glob.assetPath + '/libraries/codemirror/mode/%N/%N.js';
CodeMirror.modeURL = `${window.glob.assetPath}/libraries/codemirror/mode/%N/%N.js`;
this.codeEditor = CodeMirror(this.$editor[0], {
value: "",

View File

@ -249,9 +249,9 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget {
if (linkTitle) {
if (this.hasSelection()) {
this.watchdog.editor.execute('link', '#' + notePath);
this.watchdog.editor.execute('link', `#${notePath}`);
} else {
await this.addLinkToEditor('#' + notePath, linkTitle);
await this.addLinkToEditor(`#${notePath}`, linkTitle);
}
}
else {

View File

@ -76,9 +76,9 @@ export default class EmptyTypeWidget extends TypeWidget {
for (const workspaceNote of workspaceNotes) {
this.$workspaceNotes.append(
$('<div class="workspace-note">')
.append($("<div>").addClass(workspaceNote.getIcon() + " workspace-icon"))
.append($("<div>").addClass(`${workspaceNote.getIcon()} workspace-icon`))
.append($("<div>").text(workspaceNote.title))
.attr("title", "Enter workspace " + workspaceNote.title)
.attr("title", `Enter workspace ${workspaceNote.title}`)
.on('click', () => this.triggerCommand('hoistNote', {noteId: workspaceNote.noteId}))
);
}

View File

@ -65,19 +65,19 @@ export default class FileTypeWidget extends TypeWidget {
this.$previewContent.text(noteComplement.content);
}
else if (note.mime === 'application/pdf') {
this.$pdfPreview.show().attr("src", openService.getUrlForDownload("api/notes/" + this.noteId + "/open"));
this.$pdfPreview.show().attr("src", openService.getUrlForDownload(`api/notes/${this.noteId}/open`));
}
else if (note.mime.startsWith('video/')) {
this.$videoPreview
.show()
.attr("src", openService.getUrlForDownload("api/notes/" + this.noteId + "/open-partial"))
.attr("src", openService.getUrlForDownload(`api/notes/${this.noteId}/open-partial`))
.attr("type", this.note.mime)
.css("width", this.$widget.width());
}
else if (note.mime.startsWith('audio/')) {
this.$audioPreview
.show()
.attr("src", openService.getUrlForDownload("api/notes/" + this.noteId + "/open-partial"))
.attr("src", openService.getUrlForDownload(`api/notes/${this.noteId}/open-partial`))
.attr("type", this.note.mime)
.css("width", this.$widget.width());
}

View File

@ -45,10 +45,10 @@ class ImageTypeWidget extends TypeWidget {
this.$widget = $(TPL);
this.$imageWrapper = this.$widget.find('.note-detail-image-wrapper');
this.$imageView = this.$widget.find('.note-detail-image-view')
.attr("id", "image-view-" + utils.randomString(10));
.attr("id", `image-view-${utils.randomString(10)}`);
libraryLoader.requireLibrary(libraryLoader.WHEEL_ZOOM).then(() => {
WZoom.create('#' + this.$imageView.attr("id"), {
WZoom.create(`#${this.$imageView.attr("id")}`, {
maxScale: 10,
speed: 20,
zoomOnClick: false

View File

@ -24,7 +24,7 @@ export default class DatabaseIntegrityCheckOptions extends OptionsWidget {
toastService.showMessage("Integrity check succeeded - no problems found.");
}
else {
toastService.showMessage("Integrity check failed: " + JSON.stringify(results, null, 2), 15000);
toastService.showMessage(`Integrity check failed: ${JSON.stringify(results, null, 2)}`, 15000);
}
});
}

View File

@ -167,8 +167,8 @@ export default class FontsOptions extends OptionsWidget {
];
for (const optionName of optionsToSave) {
this['$' + optionName].on('change', () =>
this.updateOption(optionName, this['$' + optionName].val()));
this[`$${optionName}`].on('change', () =>
this.updateOption(optionName, this[`$${optionName}`].val()));
}
}

View File

@ -28,7 +28,7 @@ export default class ThemeOptions extends OptionsWidget {
this.$themeSelect.on('change', async () => {
const newTheme = this.$themeSelect.val();
await server.put('options/theme/' + newTheme);
await server.put(`options/theme/${newTheme}`);
utils.reloadFrontendApp("theme change");
});

View File

@ -48,7 +48,7 @@ export default class BackupOptions extends OptionsWidget {
this.$backupDatabaseButton.on('click', async () => {
const {backupFile} = await server.post('database/backup-database');
toastService.showMessage("Database has been backed up to " + backupFile, 10000);
toastService.showMessage(`Database has been backed up to ${backupFile}`, 10000);
});
this.$dailyBackupEnabled = this.$widget.find(".daily-backup-enabled");

View File

@ -106,7 +106,7 @@ export default class KeyboardShortcutsOptions extends OptionsWidget {
.map(shortcut => shortcut.replace("+Comma", "+,"))
.filter(shortcut => !!shortcut);
const optionName = 'keyboardShortcuts' + actionName.substr(0, 1).toUpperCase() + actionName.substr(1);
const optionName = `keyboardShortcuts${actionName.substr(0, 1).toUpperCase()}${actionName.substr(1)}`;
this.updateOption(optionName, JSON.stringify(shortcuts));
});

View File

@ -59,7 +59,7 @@ export default class SyncOptions extends OptionsWidget {
toastService.showMessage(result.message);
}
else {
toastService.showError("Sync server handshake failed, error: " + result.message);
toastService.showError(`Sync server handshake failed, error: ${result.message}`);
}
});
}

View File

@ -209,7 +209,7 @@ export default class RelationMapTypeWidget extends TypeWidget {
}
noteIdToId(noteId) {
return "rel-map-note-" + noteId;
return `rel-map-note-${noteId}`;
}
idToNoteId(id) {
@ -484,8 +484,8 @@ export default class RelationMapTypeWidget extends TypeWidget {
.prop("id", this.noteIdToId(noteId))
.append($("<span>").addClass("title").append($link))
.append($("<div>").addClass("endpoint").attr("title", "Start dragging relations from here and drop them on another note."))
.css("left", x + "px")
.css("top", y + "px");
.css("left", `${x}px`)
.css("top", `${y}px`);
this.jsPlumbInstance.getContainer().appendChild($noteBox[0]);
@ -537,7 +537,7 @@ export default class RelationMapTypeWidget extends TypeWidget {
const matches = transform.match(matrixRegex);
if (!matches) {
throw new Error("Cannot match transform: " + transform);
throw new Error(`Cannot match transform: ${transform}`);
}
return matches[1];

View File

@ -38,7 +38,7 @@ function getRecentNotes(activeNoteId) {
const hoistedNoteId = cls.getHoistedNoteId();
if (hoistedNoteId !== 'root') {
extraCondition = `AND recent_notes.notePath LIKE ?`;
params.push('%' + hoistedNoteId + '%');
params.push(`%${hoistedNoteId}%`);
}
const recentNotes = becca.getRecentNotesFromQuery(`

View File

@ -68,7 +68,7 @@ function addClipping(req) {
const existingContent = clippingNote.getContent();
clippingNote.setContent(existingContent + (existingContent.trim() ? "<br/>" : "") + rewrittenContent);
clippingNote.setContent(`${existingContent}${existingContent.trim() ? "<br/>" : ""}${rewrittenContent}`);
return {
noteId: clippingNote.noteId
@ -79,7 +79,7 @@ function createNote(req) {
let {title, content, pageUrl, images, clipType} = req.body;
if (!title || !title.trim()) {
title = "Clipped note from " + pageUrl;
title = `Clipped note from ${pageUrl}`;
}
const clipperInbox = getClipperInboxNote();
@ -123,7 +123,7 @@ function processContent(images, note, content) {
? dataUrl.substr(0, Math.min(100, dataUrl.length))
: "null";
log.info("Image could not be recognized as data URL: " + excerpt);
log.info(`Image could not be recognized as data URL: ${excerpt}`);
continue;
}

View File

@ -25,7 +25,7 @@ function vacuumDatabase() {
function checkIntegrity() {
const results = sql.getRows("PRAGMA integrity_check");
log.info("Integrity check result: " + JSON.stringify(results));
log.info(`Integrity check result: ${JSON.stringify(results)}`);
return {
results

View File

@ -18,7 +18,7 @@ function returnImage(req, res) {
}
else if (image.isDeleted || image.data === null) {
res.set('Content-Type', 'image/png');
return res.send(fs.readFileSync(RESOURCE_DIR + '/db/image-deleted.png'));
return res.send(fs.readFileSync(`${RESOURCE_DIR}/db/image-deleted.png`));
}
/**
@ -81,7 +81,7 @@ function updateImage(req) {
if (!["image/png", "image/jpeg", "image/gif", "image/webp", "image/svg+xml"].includes(file.mimetype)) {
return {
uploaded: false,
message: "Unknown image type: " + file.mimetype
message: `Unknown image type: ${file.mimetype}`
};
}

View File

@ -63,7 +63,7 @@ async function importToBranch(req) {
}
}
catch (e) {
const message = "Import failed with following error: '" + e.message + "'. More details might be in the logs.";
const message = `Import failed with following error: '${e.message}'. More details might be in the logs.`;
taskContext.reportError(message);
log.error(message + e.stack);

Some files were not shown because too many files have changed in this diff Show More