TagSpaces is an offline, open source, document manager with tagging support
js styling
uggrockcb1a8e3d7ff7
diff --git a/data/chromium/chrome.api.js b/data/chromium/chrome.api.jsindex 22060c8df..6ac62b427 100644--- a/data/chromium/chrome.api.js+++ b/data/chromium/chrome.api.js@@ -42,7 +42,7 @@ define(function(require, exports, module) {TSCORE.showAlertDialog($.i18n.t("ns.dialogs:accessFileURLNotAllowedAlert"));}});- };+ }function handleStartParameters() {var openFile = getURLParameter("openFile");@@ -53,19 +53,19 @@ define(function(require, exports, module) {//TSCORE.IO.listDirectory(dirPath);TSCORE.FileOpener.openFileOnStartup(openFile);}- };+ }function focusWindow() {// Places the TagSpaces window on top of the windowswindow.focus();- };+ }function saveSettings(content) {/*chrome.storage.sync.set({'tagSpacesSettings': content}, function() {// Notify that we saved.message('Settings saved');});*/- };+ }function checkNewVersion() {console.log("Checking for new version...");@@ -80,7 +80,7 @@ define(function(require, exports, module) {.fail(function(data) {console.log("AJAX failed " + data);});- };+ }function createDirectoryIndex(dirPath) {@@ -99,15 +99,14 @@ define(function(require, exports, module) {).catch(function() {TSCORE.hideWaitingDialog();});- };+ }function createDirectoryTree(dirPath) {- TSCORE.showLoadingAnimation();- console.log("Creating directory not supported: " + dirPath);+ TSCORE.showAlertDialog("Creating directory not supported.");//var directoyTree = generateDirectoryTree(dirPath);//console.log(JSON.stringify(directoyTree));//TSPOSTIO.createDirectoryTree(directoyTree);- };+ }function listDirectoryPromise(dirPath) {@@ -180,14 +179,14 @@ define(function(require, exports, module) {console.error("Error listDirectory " + dirPath + " error: " + error);});- };+ }function getDirectoryMetaInformation(dirPath, readyCallback) {listDirectory(dirPath, function(anotatedDirList) {TSCORE.metaFileList = anotatedDirList;readyCallback(anotatedDirList);});- };+ }function listSubDirectories(dirPath) {console.log("Listing sub directories: " + dirPath);@@ -209,7 +208,7 @@ define(function(require, exports, module) {TSCORE.hideLoadingAnimation();console.error("Error listDirectory " + dirPath + " error: " + error);});- };+ }function getPropertiesPromise(filePath) {@@ -221,15 +220,15 @@ define(function(require, exports, module) {fileProperties.lmdt = 0;resolve(fileProperties);});- };+ }function getFileProperties(filePath) {getPropertiesPromise().then(function(fileProperties) {TSPOSTIO.getFileProperties(fileProperties);}, function(err) {TSCORE.showAlertDialog("Could not get properties for: " + filePath);- })- };+ });+ }function loadTextFile(filePath) {@@ -241,7 +240,7 @@ define(function(require, exports, module) {console.error("loading text file failed " + data);});- };+ }function getFileContent(fullPath, result, error) {// TODO 4remove@@ -275,7 +274,7 @@ define(function(require, exports, module) {function saveFilePromise(filePath, content, mode) {console.log("Saving binary file: " + filePath);- return new Promise(function(resolve, reject){+ return new Promise(function(resolve, reject) {var blob = new Blob([content], {type: "text/plain;charset=utf-8"});@@ -295,7 +294,7 @@ define(function(require, exports, module) {console.error(error);});- };+ }function saveBinaryFile(filePath, content) {TSCORE.showLoadingAnimation();@@ -308,7 +307,7 @@ define(function(require, exports, module) {console.error(error);});- };+ }function createDirectoryPromise(dirPath) {@@ -316,12 +315,12 @@ define(function(require, exports, module) {TSCORE.showAlertDialog("Creating directory is not supported in Chrome, please use the desktop version.");res(true);});- };+ }function createDirectory(dirPath) {// TODO 4 removecreateDirectoryPromise();- };+ }function renameDirectoryPromise() {@@ -329,12 +328,12 @@ define(function(require, exports, module) {TSCORE.showAlertDialog("Renaming directory is not supported in Chrome, please use the desktop version.");res(true);});- };+ }function renameDirectory() {// TODO 4removerenameDirectoryPromise();- };+ }function renameFilePromise() {@@ -342,12 +341,12 @@ define(function(require, exports, module) {TSCORE.showAlertDialog("Renaming file is not supported in Chrome, please use the desktop version.");res(true);});- };+ }function renameFile() {// TODO 4removerenameFilePromise();- };+ }function copyFilePromise() {@@ -355,12 +354,12 @@ define(function(require, exports, module) {TSCORE.showAlertDialog("Copy file is not supported in Chrome, please use the desktop version.");res(true);});- };+ }function copyFile() {// TODO 4removecopyFilePromise();- };+ }function deleteFilePromise() {@@ -368,12 +367,12 @@ define(function(require, exports, module) {TSCORE.showAlertDialog("Creating directory is not supported in Chrome, please use the desktop version.");res(true);});- };+ }function deleteElement() {// TODO 4removedeleteDirectoryPromise();- };+ }function deleteDirectoryPromise() {@@ -381,12 +380,12 @@ define(function(require, exports, module) {TSCORE.showAlertDialog("Deleting directory is not supported in Chrome, please use the desktop version.");res(true);});- };+ }function deleteDirectory() {// TODO 4removedeleteDirectoryPromise();- };+ }function selectDirectory() {@@ -396,23 +395,23 @@ define(function(require, exports, module) {rootPath = "C:";}TSCORE.showDirectoryBrowserDialog(rootPath);- };+ }function selectFile() {// TODOTSCORE.showAlertDialog("Select file not implemented!");- };+ }function openDirectory(dirPath) {// TODOTSCORE.showAlertDialog($.i18n.t("ns.dialogs:openContainingDirectoryAlert"));- };+ }function openFile(filePath) {// TODOTSCORE.showAlertDialog($.i18n.t("ns.dialogs:openFileNativelyAlert"));- };+ }// Platform specific callsexports.checkAccessFileURLAllowed = checkAccessFileURLAllowed;diff --git a/data/js/core.api.js b/data/js/core.api.jsindex 38ea7a555..4c994628a 100644--- a/data/js/core.api.js+++ b/data/js/core.api.js@@ -89,7 +89,7 @@ define(function(require, exports, module) {}switchInterfaceLanguage(language);initKeyBindings();- tsIOApi.checkAccessFileURLAllowed?tsIOApi.checkAccessFileURLAllowed():true;+ tsIOApi.checkAccessFileURLAllowed ? tsIOApi.checkAccessFileURLAllowed() : true;// Show welcome dialog of first startif (tsSettings.isFirstRun()) {tsCoreUI.showWelcomeDialog();diff --git a/data/js/directories.ui.js b/data/js/directories.ui.jsindex c71fd0f3a..890b3220e 100644--- a/data/js/directories.ui.js+++ b/data/js/directories.ui.js@@ -122,7 +122,7 @@ define(function(require, exports, module) {function getDirHistoryItem(path) {for (var i = 0; i < directoryHistory.length; i++) {- if(directoryHistory[i].path === path) {+ if (directoryHistory[i].path === path) {return directoryHistory[i];}}@@ -130,7 +130,7 @@ define(function(require, exports, module) {function loadFolderMetaData(path, element, menuItem) {var historyItem = getDirHistoryItem(path);- if(historyItem.metaData !== undefined) {+ if (historyItem.metaData !== undefined) {generateFolderTags(historyItem.metaData.tags, element, menuItem);return;}diff --git a/data/js/extension.manager.js b/data/js/extension.manager.jsindex 44cfed61f..be0e9d569 100644--- a/data/js/extension.manager.js+++ b/data/js/extension.manager.js@@ -7,7 +7,7 @@ define(function(require, exports, module) {function getExtFolderPath() {var extPath = "ext";- if(isWeb) {+ if (isWeb) {return extPath;}if (isCordova) {diff --git a/data/js/fileopener.js b/data/js/fileopener.jsindex c85a1668b..ccfea4437 100644--- a/data/js/fileopener.js+++ b/data/js/fileopener.js@@ -244,7 +244,7 @@ define(function(require, exports, module) {$viewer.find('*').off();$viewer.find('*').unbind();$viewer.find('*').remove();- TSCORE.IO.checkAccessFileURLAllowed?TSCORE.IO.checkAccessFileURLAllowed():true;+ TSCORE.IO.checkAccessFileURLAllowed ? TSCORE.IO.checkAccessFileURLAllowed() : true;TSCORE.IO.getFileProperties(filePath.replace('\\\\', '\\'));updateUI();if (editMode) {diff --git a/data/js/perspective.manager.js b/data/js/perspective.manager.jsindex c1f9f422c..ac61f2a15 100644--- a/data/js/perspective.manager.js+++ b/data/js/perspective.manager.js@@ -57,7 +57,7 @@ define(function(require, exports, module) {}if (lastLocation && lastLocation.length >= 1) {TSCORE.openLocation(lastLocation);- TSCORE.IO.checkAccessFileURLAllowed?TSCORE.IO.checkAccessFileURLAllowed():true;+ TSCORE.IO.checkAccessFileURLAllowed ? TSCORE.IO.checkAccessFileURLAllowed() : true;var evt = TSCORE.createDocumentEvent("initApp");TSCORE.fireDocumentEvent(evt);$("#viewContainers").removeClass("appBackgroundTile");diff --git a/data/js/search.js b/data/js/search.jsindex 6f60001af..b9ab26004 100644--- a/data/js/search.js+++ b/data/js/search.js@@ -48,7 +48,7 @@ define(function(require, exports, module) {// cleaning up the query, reducing the spacesvar queryText = queryText.toLowerCase().replace(/^\s+|\s+$/g, '');var recursive = queryText.indexOf('?') === 0;- if(recursive) {+ if (recursive) {queryText = queryText.substring(1, queryText.length);}var queryTerms = queryText.split(' ');@@ -58,7 +58,7 @@ define(function(require, exports, module) {includedTags: [],excludedTags: [],recursive: recursive,- }+ };// parsing the queryqueryTerms.forEach(function(value) {@@ -101,10 +101,10 @@ define(function(require, exports, module) {var tags;// TODO consider tags in .ts/meta.json and ./ts/ts.json- if(fileEntry.tags) {+ if (fileEntry.tags) {tags = fileEntry.tags;} else {- tags = TSCORE.TagUtils.extractTags(fileEntry.path)+ tags = TSCORE.TagUtils.extractTags(fileEntry.path);}var result = true;@@ -156,46 +156,46 @@ define(function(require, exports, module) {var searchResults = [];var scan = function(content, fileEntry) {- return new Promise(function(resolve, reject){+ return new Promise(function(resolve, reject) {var found = false;queryObj.includedTerms.forEach(function(term) {- if(content.indexOf(term[0]) >= 0) {+ if (content.indexOf(term[0]) >= 0) {found = true;}- if(found) {+ if (found) {console.log("Term " + term[0] + " found in " + fileEntry.path);searchResults.push(fileEntry);}- })+ });resolve();});- }+ };if (TSCORE.Utils.walkDirectory) {- if(query.length > 0) {+ if (query.length > 0) {TSCORE.showWaitingDialog($.i18n.t("ns.common:waitDialogDiectoryIndexing"));TSCORE.Utils.walkDirectory(TSCORE.currentPath, {recursive: queryObj.recursive},function(fileEntry) {- return new Promise(function(resolve, reject){- if(filterFileObject(fileEntry, queryObj)) {+ return new Promise(function(resolve, reject) {+ if (filterFileObject(fileEntry, queryObj)) {searchResults.push(fileEntry);resolve();}- if(fileContentFilter(fileEntry.name)) {+ if (fileContentFilter(fileEntry.name)) {TSCORE.IO.loadTextFilePromise(fileEntry.path).then(function(content) {//return scan(content, fileEntry);var found = false;queryObj.includedTerms.forEach(function(term) {- if(content.indexOf(term[0]) >= 0) {+ if (content.indexOf(term[0]) >= 0) {found = true;}- if(found) {+ if (found) {console.log("Term " + term[0] + " found in " + fileEntry.path);searchResults.push(fileEntry);}- })+ });resolve();}, function(err) {resolve();@@ -245,7 +245,7 @@ define(function(require, exports, module) {path: value[TSCORE.fileListFILEPATH],name: value[TSCORE.fileListFILENAME],tags: value[TSCORE.fileListTAGS],- }+ };// Excluding files from tagspacec meta foldersif (fileEntry.path.indexOf(TSCORE.dirSeparator + ".ts") > 0) {return false;diff --git a/data/js/utils.js b/data/js/utils.jsindex d36b8a5e1..506ab9e53 100644--- a/data/js/utils.js+++ b/data/js/utils.js@@ -78,21 +78,21 @@ define(function(require, exports, module) {function walkDirectory(path, options, fileCallback, dirCallback) {return TSCORE.IO.listDirectoryPromise(path).then(function(entries) {return Promise.all(entries.map(function(entry) {- if(!options) {+ if (!options) {options = {};options.recursive = false;}if (entry.isFile) {- if(fileCallback) {+ if (fileCallback) {return fileCallback(entry);} else {return entry;}} else {- if(dirCallback) {+ if (dirCallback) {return dirCallback(entry);}- if(options.recursive) {+ if (options.recursive) {return walkDirectory(entry.path, options, fileCallback, dirCallback);} else {return entry;diff --git a/data/mozilla/mozilla.api.js b/data/mozilla/mozilla.api.jsindex 9a008352b..a36b31c23 100644--- a/data/mozilla/mozilla.api.js+++ b/data/mozilla/mozilla.api.js@@ -175,7 +175,7 @@ define(function(require, exports, module) {function focusWindow() {// Bring the TagSpaces window on top of the windowswindow.focus();- };+ }function saveSettings(content) {console.log("Saving setting...");@@ -187,7 +187,7 @@ define(function(require, exports, module) {}});document.documentElement.dispatchEvent(event);- };+ }function loadSettings() {console.log("Loading setting from firefox preferences...");@@ -198,7 +198,7 @@ define(function(require, exports, module) {}});document.documentElement.dispatchEvent(event);- };+ }function checkNewVersion() {console.log("Checking for new version...");@@ -209,7 +209,7 @@ define(function(require, exports, module) {}});document.documentElement.dispatchEvent(event);- };+ }function listDirectoryPromise(dirPath) {@@ -250,7 +250,7 @@ define(function(require, exports, module) {TSPOSTIO.errorOpeningPath();});- };+ }function loadTextFile(filePath) {@@ -263,7 +263,7 @@ define(function(require, exports, module) {console.warn("Error: " + error);});- };+ }function getFileContentPromise(filePath, type) {console.log("getFileContentPromise: " + filePath);@@ -314,7 +314,7 @@ define(function(require, exports, module) {}});document.documentElement.dispatchEvent(event);- };+ }function saveBinaryFile(filePath, content, overWrite, silentMode) {console.log("Saving binary file post: " + filePath); //+" - "+content);@@ -329,7 +329,7 @@ define(function(require, exports, module) {}});document.documentElement.dispatchEvent(event);- };+ }function createDirectory(dirPath, silentMode) {@@ -343,7 +343,7 @@ define(function(require, exports, module) {}});document.documentElement.dispatchEvent(event);- };+ }function copyFile(filePath, newFilePath) {console.log("Copy " + filePath + " to " + newFilePath);@@ -356,7 +356,7 @@ define(function(require, exports, module) {}});document.documentElement.dispatchEvent(event);- };+ }function renameFile(filePath, newFilePath) {console.log("Renaming " + filePath + " to " + newFilePath);@@ -369,12 +369,12 @@ define(function(require, exports, module) {}});document.documentElement.dispatchEvent(event);- };+ }function renameDirectory(filePath, newFilePath) {//TSCORE.showAlertDialog($.i18n.t("ns.common:functionalityNotImplemented"));- };+ }function listDirectory(dirPath) {@@ -387,7 +387,7 @@ define(function(require, exports, module) {TSPOSTIO.errorOpeningPath();});- };+ }function deleteElement(path) {console.log("Deleting: " + path);@@ -399,12 +399,12 @@ define(function(require, exports, module) {}});document.documentElement.dispatchEvent(event);- };+ }function deleteDirectory(dirPath) {//TSCORE.showAlertDialog($.i18n.t("ns.common:functionalityNotImplemented"));- };+ }function createDirectoryIndex(dirPath) {@@ -417,7 +417,7 @@ define(function(require, exports, module) {}});document.documentElement.dispatchEvent(event);- };+ }function createDirectoryTree(dirPath) {console.log("Creating directory tree for: " + dirPath);@@ -429,7 +429,7 @@ define(function(require, exports, module) {}});document.documentElement.dispatchEvent(event);- };+ }function getFileProperties(filePath) {getFilePropertiesPromise(filePath).then(function(properties) {diff --git a/data/node-webkit/node-webkit.api.js b/data/node-webkit/node-webkit.api.jsindex 2512c1b73..d7bd0bcfe 100644--- a/data/node-webkit/node-webkit.api.js+++ b/data/node-webkit/node-webkit.api.js@@ -297,7 +297,7 @@ define(function(require, exports, module) {);}- function listDirectoryPromise(path){+ function listDirectoryPromise(path) {return new Promise(function(resolve, reject) {var statEntriesPromises = [];fs.readdir(path, function(error, entries) {@@ -305,7 +305,7 @@ define(function(require, exports, module) {console.log("Error listing directory " + path);resolve(statEntriesPromises);} else {- if(entries) {+ if (entries) {entries.forEach(function(entry) {statEntriesPromises.push(getPropertiesPromise(path + TSCORE.dirSeparator + entry));});@@ -357,7 +357,7 @@ define(function(require, exports, module) {}if (stats) {var entry = {};- entry.name = path.substring(path.lastIndexOf(TSCORE.dirSeparator)+1, path.length);+ entry.name = path.substring(path.lastIndexOf(TSCORE.dirSeparator) + 1, path.length);entry.isFile = stats.isFile();entry.size = stats.size;entry.lmdt = stats.mtime;@@ -549,7 +549,7 @@ define(function(require, exports, module) {renameDirectoryPromise(dirPath, newDirName).then(function() {TSCORE.hideWaitingDialog();TSPOSTIO.renameDirectory(dirPath, newDirPath);- }, function(err){+ }, function(err) {TSCORE.hideWaitingDialog();TSCORE.showAlertDialog(err);});@@ -653,7 +653,7 @@ define(function(require, exports, module) {function saveFilePromise(filePath, content, overwrite) {- return new Promise(function(resolve,reject) {+ return new Promise(function(resolve, reject) {function saveFile(filePath, content) {fs.writeFile(filePath, content, 'utf8', function(error) {if (error) {@@ -664,9 +664,9 @@ define(function(require, exports, module) {}getPropertiesPromise(filePath).then(function(entry) {- if(entry && entry.isFile && overwrite) {+ if (entry && entry.isFile && overwrite) {saveFile(filePath, content);- } else if (!entry){+ } else if (!entry) {saveFile(filePath, content);} else {resolve();@@ -754,10 +754,10 @@ define(function(require, exports, module) {function deleteDirectoryPromise(path) {- return new Promise(function(resolve,reject) {+ return new Promise(function(resolve, reject) {fs.rmdir(path, function(error) {if (error) {- reject(error);+ reject(error);} else {resolve();}@@ -771,7 +771,7 @@ define(function(require, exports, module) {return trash([path]);}- deleteDirectoryPromise(path).then(function(){+ deleteDirectoryPromise(path).then(function() {TSPOSTIO.deleteDirectory(path);},function(error) {diff --git a/data/web/web.api.js b/data/web/web.api.jsindex 92069a71e..699e47783 100644--- a/data/web/web.api.js+++ b/data/web/web.api.js@@ -308,7 +308,7 @@ define(function(require, exports, module) {console.log("Saving file: " + filePath); //+" content: "+content);saveFilePromise(filePath, content, overWrite, silentMode, "text").then(function(isNewFile) {if (silentMode !== true) {- TSPOSTIO.saveTextFile(filePath, isNewFile);+ TSPOSTIO.saveTextFile(filePath, isNewFile);}}, function(error) {TSCORE.showAlertDialog("Save file " + filePath + " failed.");@@ -400,7 +400,7 @@ define(function(require, exports, module) {function renameFilePromise(filePath, newFilePath) {console.log("Renaming file: " + filePath + " to " + newFilePath);- return new Promise(function(resolve, reject){+ return new Promise(function(resolve, reject) {if (filePath === newFilePath) {TSCORE.hideWaitingDialog();TSCORE.showAlertDialog($.i18n.t("ns.common:fileTheSame"), $.i18n.t("ns.common:fileNotMoved"));