TagSpaces is an offline, open source, document manager with tagging support
removing postio callbacks
Ilian Sapundshiev6bcbf8ff49fa
diff --git a/data/chromium/chrome.api.js b/data/chromium/chrome.api.jsindex 4f5ef8107..8cc3a52e8 100644--- a/data/chromium/chrome.api.js+++ b/data/chromium/chrome.api.js@@ -96,7 +96,7 @@ define(function(require, exports, module) {TSCORE.showAlertDialog("Creating directory tree not supported.");//var directoyTree = generateDirectoryTree(dirPath);//console.log(JSON.stringify(directoyTree));- //TSPOSTIO.createDirectoryTree(directoyTree);+ //.createDirectoryTree(directoyTree);}/**diff --git a/data/cordova/cordova.api.js b/data/cordova/cordova.api.jsindex 565169219..cf78cf48f 100644--- a/data/cordova/cordova.api.js+++ b/data/cordova/cordova.api.js@@ -243,7 +243,7 @@ define(function(require, exports, module) {pendingCallbacks--;console.log("Pending recursions: " + pendingCallbacks);if (pendingCallbacks <= 0) {- // TSPOSTIO.createDirectoryTree(anotatedTree);+ // .createDirectoryTree(anotatedTree);}} */diff --git a/data/electron/electron.api.js b/data/electron/electron.api.jsindex 1a001311f..74fbd20c7 100644--- a/data/electron/electron.api.js+++ b/data/electron/electron.api.js@@ -21,7 +21,7 @@ define(function(require, exports, module) {//console.log("CM Args: " + JSON.stringify(process.argv));var TSCORE = require("tscore");- var TSPOSTIO = require("tspostioapi");+var fsWatcher;var win = remote.getCurrentWindow();@@ -985,7 +985,19 @@ define(function(require, exports, module) {var chooser = $('#folderDialogNodeWebkit');chooser.on("change", function(ev) {var file = ev.target.files[0];- TSPOSTIO.selectDirectory(file.path);+ var dirPath = file.path;++ if (!TSCORE.TagUtils.stringEndsWith(dirPath, TSCORE.dirSeparator)) {+ dirPath = dirPath + TSCORE.dirSeparator;+ }+ var dirName = TSCORE.TagUtils.extractContainingDirectoryName(dirPath);+ $('#connectionName').val(dirName);+ $('#folderLocation').val(dirPath);+ $('#folderLocation2').val(dirPath);+ $('#folderLocation').blur();+ $('#folderLocation2').blur();+ $('#moveCopyDirectoryPath').val(dirPath);+$(this).off("change");$(this).val("");});diff --git a/data/js/core.ui.js b/data/js/core.ui.jsindex 05a31a3cd..d32dfcfdd 100644--- a/data/js/core.ui.js+++ b/data/js/core.ui.js@@ -9,7 +9,6 @@ define(function(require, exports) {console.log('Loading core.ui.js ...');var TSCORE = require('tscore');- var TSPOSTIO = require("tspostioapi");require('datetimepicker');require('moment');@@ -169,7 +168,7 @@ define(function(require, exports) {var newFilePath = containingDir + TSCORE.dirSeparator + $('#renamedFileName').val();TSCORE.IO.renameFilePromise(initialFilePath, newFilePath).then(function(success) {TSCORE.hideWaitingDialog();- TSPOSTIO.renameFile(initialFilePath, newFilePath);+ TSCORE.IOUtils.renameFileSuccess(initialFilePath, newFilePath);}, function(err) {TSCORE.hideWaitingDialog();TSCORE.showAlertDialog(err);@@ -665,7 +664,14 @@ define(function(require, exports) {filePath: filePath}), function() {TSCORE.IO.deleteFilePromise(filePath).then(function() {- TSPOSTIO.deleteElement(filePath);+ TSCORE.showSuccessDialog("File deleted successfully.");+ TSCORE.removeFileModel(TSCORE.fileList, filePath);+ TSCORE.Meta.deleteMetaData(filePath);+ TSCORE.PerspectiveManager.removeFileUI(filePath);+ if (filePath === TSCORE.FileOpener.getOpenedFilePath()) {+ TSCORE.FileOpener.closeFile(true);+ }+ TSCORE.hideLoadingAnimation();},function(error) {TSCORE.hideLoadingAnimation();diff --git a/data/js/directories.ui.js b/data/js/directories.ui.jsindex e6c22007c..a89c72e5b 100644--- a/data/js/directories.ui.js+++ b/data/js/directories.ui.js@@ -9,7 +9,6 @@ define(function(require, exports, module) {console.log('Loading directories.ui.js ...');var TSCORE = require('tscore');- var TSPOSTIO = require("tspostioapi");var tsExtManager = require('tsextmanager');var homeFolderTitle = 'Home';@@ -342,7 +341,7 @@ define(function(require, exports, module) {var newFilePath = targetDir + TSCORE.dirSeparator + fileName;TSCORE.IO.renameFilePromise(filePath, newFilePath).then(function(success) {TSCORE.hideWaitingDialog();- TSPOSTIO.renameFile(filePath, newFilePath);+ TSCORE.IOUtils.renameFileSuccess(filePath, newFilePath);}, function(err) {TSCORE.hideWaitingDialog();TSCORE.showAlertDialog(err);@@ -369,7 +368,7 @@ define(function(require, exports, module) {var newFilePath = targetDir + TSCORE.dirSeparator + fileName;TSCORE.IO.renameFilePromise(filePath, newFilePath).then(function(success) {TSCORE.hideWaitingDialog();- TSPOSTIO.renameFile(filePath, newFilePath);+ TSCORE.IOUtils.renameFileSuccess(filePath, newFilePath);}, function(err) {TSCORE.hideWaitingDialog();TSCORE.showAlertDialog(err);@@ -493,7 +492,8 @@ define(function(require, exports, module) {TSCORE.showLoadingAnimation();//TSCORE.PerspectiveManager.removeAllFiles();TSCORE.IO.listDirectoryPromise(dirPath).then(function(entries) {- TSPOSTIO.listDirectory(entries);+ TSCORE.PerspectiveManager.updateFileBrowserData(entries);+ TSCORE.updateSubDirs(entries)TSCORE.hideLoadingAnimation();console.log("Listing: " + dirPath + " done!");@@ -505,7 +505,16 @@ define(function(require, exports, module) {});}}).catch(function(err) {- TSPOSTIO.errorOpeningPath(dirPath);+ // Normalazing the paths+ var dir1 = TSCORE.TagUtils.cleanTrailingDirSeparator(TSCORE.currentLocationObject.path);+ var dir2 = TSCORE.TagUtils.cleanTrailingDirSeparator(dirPath);+ // Close the current location if the its path could not be opened+ if (dir1 === dir2) {+ TSCORE.showAlertDialog($.i18n.t('ns.dialogs:errorOpeningLocationAlert'));+ TSCORE.closeCurrentLocation();+ } else {+ TSCORE.showAlertDialog($.i18n.t('ns.dialogs:errorOpeningPathAlert'));+ }console.log("Error listing directory " + dirPath + " - " + err);});diff --git a/data/js/directorybrowser.js b/data/js/directorybrowser.jsindex 9b1e68284..abcbd9a7d 100644--- a/data/js/directorybrowser.js+++ b/data/js/directorybrowser.js@@ -5,7 +5,6 @@ define(function(require, exports, module) {'use strict';console.log('Loading directorybrowser.js ...');var TSCORE = require('tscore');- var TSPOSTIO = require('tspostioapi');function initUI() {$('#gotoParentDirButton').click(function() {@@ -22,7 +21,18 @@ define(function(require, exports, module) {});}$('#selectDirectoryButton').click(function() {- TSPOSTIO.selectDirectory($('#directoryPath').val());+ var dirPath = $('#directoryPath').val();+ if (!TSCORE.TagUtils.stringEndsWith(dirPath, TSCORE.dirSeparator)) {+ dirPath = dirPath + TSCORE.dirSeparator;+ }+ var dirName = TSCORE.TagUtils.extractContainingDirectoryName(dirPath);+ $('#connectionName').val(dirName);+ $('#folderLocation').val(dirPath);+ $('#folderLocation2').val(dirPath);+ $('#folderLocation').blur();+ $('#folderLocation2').blur();+ $('#moveCopyDirectoryPath').val(dirPath);+$('#driveSelector').prop('selectedIndex', 0);});}diff --git a/data/js/fileopener.js b/data/js/fileopener.jsindex a6a09370b..07190fce4 100644--- a/data/js/fileopener.js+++ b/data/js/fileopener.js@@ -10,8 +10,8 @@ define(function(require, exports, module) {console.log('Loading fileopener...');var TSCORE = require('tscore');- var TSPOSTIO = require("tspostioapi");var moment = require('moment');+var _openedFilePath;var _openedFileProperties;var _isFileOpened = false;diff --git a/data/js/ioutils.js b/data/js/ioutils.jsindex bc0e6df99..e5938cd2c 100644--- a/data/js/ioutils.js+++ b/data/js/ioutils.js@@ -12,7 +12,7 @@ define(function(require, exports, module) {console.log('Loading ioutils.js ...');var TSCORE = require('tscore');- var TSPOSTIO = require('tspostioapi');+var stopDirectoryWalking = false;var searchResultsCounter = 0;@@ -64,9 +64,21 @@ define(function(require, exports, module) {});}}- TSPOSTIO.listSubDirectories(anotatedDirList, dirPath);+ TSCORE.subfoldersDirBrowser = anotatedDirList;+ if (TSCORE.directoryBrowser !== undefined) {+ TSCORE.directoryBrowser.reInitUI(dirPath);+ }}).catch(function(error) {- TSPOSTIO.errorOpeningPath(dirPath);+ var dir1 = TSCORE.TagUtils.cleanTrailingDirSeparator(TSCORE.currentLocationObject.path);+ var dir2 = TSCORE.TagUtils.cleanTrailingDirSeparator(dirPath);+ // Close the current location if the its path could not be opened+ if (dir1 === dir2) {+ TSCORE.showAlertDialog($.i18n.t('ns.dialogs:errorOpeningLocationAlert'));+ TSCORE.closeCurrentLocation();+ } else {+ TSCORE.showAlertDialog($.i18n.t('ns.dialogs:errorOpeningPathAlert'));+ }+TSCORE.hideLoadingAnimation();console.error("Error listDirectory " + dirPath + " error: " + error);});@@ -126,6 +138,36 @@ define(function(require, exports, module) {});}+ function renameFileSuccess(oldFilePath, newFilePath) {+ var lastOpenedFile = TSCORE.FileOpener.getOpenedFilePath();+ if (lastOpenedFile !== undefined) {+ console.log('Last opened Filename: ' + lastOpenedFile);+ // TODO handle case in which a file opened for editing and a tag has been added / file renamed+ if (isCordova) {+ lastOpenedFile = lastOpenedFile.substring(("file://").length, lastOpenedFile.length);+ }+ if (TSCORE.FileOpener.isFileOpened() && oldFilePath === lastOpenedFile) {+ TSCORE.FileOpener.openFile(newFilePath);+ }+ }+ var oldFileContainingPath = TSCORE.TagUtils.extractContainingDirectoryPath(oldFilePath),+ newFileConaintingPath = TSCORE.TagUtils.extractContainingDirectoryPath(newFilePath);+ if (oldFileContainingPath !== newFileConaintingPath) {+ // File was moved+ // TODO consider case - file was moved in subdir shown in the recursive search results+ //TSCORE.removeFileModel(TSCORE.fileList, oldFilePath);+ //TSCORE.PerspectiveManager.removeFileUI(oldFilePath);+ TSCORE.navigateToDirectory(TSCORE.currentPath);+ } else {+ // File was renamed+ TSCORE.updateFileModel(TSCORE.fileList, oldFilePath, newFilePath);+ TSCORE.PerspectiveManager.updateFileUI(oldFilePath, newFilePath);+ }+ TSCORE.Meta.updateMetaData(oldFilePath, newFilePath);+ TSCORE.hideWaitingDialog();+ };++ exports.renameFileSuccess = renameFileSuccess;exports.stopDirectoryWalking = stopDirectoryWalking;exports.walkDirectory = walkDirectory;exports.listSubDirectories = listSubDirectories;diff --git a/data/js/perspective.manager.js b/data/js/perspective.manager.jsindex 0d4ad9cc0..992d7c9ad 100644--- a/data/js/perspective.manager.js+++ b/data/js/perspective.manager.js@@ -9,7 +9,6 @@ define(function(require, exports, module) {var perspectives;var TSCORE = require('tscore');- var TSPOSTIO = require("tspostioapi");function initPerspective(extPath) {return new Promise(function(resolve, reject) {@@ -63,11 +62,6 @@ define(function(require, exports, module) {var startupFilePath = TSCORE.Utils.getURLParameter("open");if (startupFilePath && startupFilePath.length) {startupFilePath = decodeURIComponent(startupFilePath);-- /*var parentFolderPath = TSCORE.TagUtils.extractContainingDirectoryPath(startupFilePath);- TSCORE.IO.listDirectoryPromise(parentFolderPath).then(function(entries) {- TSPOSTIO.listDirectory(entries);- })*/TSCORE.FileOpener.openFileOnStartup(startupFilePath);} else if (lastLocation && lastLocation.length >= 1) {TSCORE.openLocation(lastLocation);@@ -310,9 +304,19 @@ define(function(require, exports, module) {function refreshFileListContainer() {// TODO consider search viewTSCORE.IO.listDirectoryPromise(TSCORE.currentPath).then(function(entries) {- TSPOSTIO.listDirectory(entries);+ TSCORE.PerspectiveManager.updateFileBrowserData(entries);+ TSCORE.updateSubDirs(entries);}).catch(function(err) {- TSPOSTIO.errorOpeningPath(TSCORE.currentPath);+ // Normalazing the paths+ var dir1 = TSCORE.TagUtils.cleanTrailingDirSeparator(TSCORE.currentLocationObject.path);+ var dir2 = TSCORE.TagUtils.cleanTrailingDirSeparator(TSCORE.currentPath);+ // Close the current location if the its path could not be opened+ if (dir1 === dir2) {+ TSCORE.showAlertDialog($.i18n.t('ns.dialogs:errorOpeningLocationAlert'));+ TSCORE.closeCurrentLocation();+ } else {+ TSCORE.showAlertDialog($.i18n.t('ns.dialogs:errorOpeningPathAlert'));+ }console.warn("Error listing directory" + err);});}diff --git a/data/js/postioapi.js b/data/js/postioapi.jsdeleted file mode 100644index 8779d634e..000000000--- a/data/js/postioapi.js+++ /dev/null@@ -1,89 +0,0 @@-/* Copyright (c) 2012-2016 The TagSpaces Authors. All rights reserved.- * Use of this source code is governed by a AGPL3 license that- * can be found in the LICENSE file. */--define(function(require, exports, module) {- 'use strict';-- console.log('Loading postioapi.js ...');- var TSCORE = require('tscore');-- exports.renameFile = function(oldFilePath, newFilePath) {- var lastOpenedFile = TSCORE.FileOpener.getOpenedFilePath();- if (lastOpenedFile !== undefined) {- console.log('Last opened Filename: ' + lastOpenedFile);- // TODO handle case in which a file opened for editing and a tag has been added / file renamed- if (isCordova) {- lastOpenedFile = lastOpenedFile.substring(("file://").length, lastOpenedFile.length);- }- if (TSCORE.FileOpener.isFileOpened() && oldFilePath === lastOpenedFile) {- TSCORE.FileOpener.openFile(newFilePath);- }- }- var oldFileContainingPath = TSCORE.TagUtils.extractContainingDirectoryPath(oldFilePath),- newFileConaintingPath = TSCORE.TagUtils.extractContainingDirectoryPath(newFilePath);- if (oldFileContainingPath !== newFileConaintingPath) {- // File was moved- // TODO consider case - file was moved in subdir shown in the recursive search results- //TSCORE.removeFileModel(TSCORE.fileList, oldFilePath);- //TSCORE.PerspectiveManager.removeFileUI(oldFilePath);- TSCORE.navigateToDirectory(TSCORE.currentPath);- } else {- // File was renamed- TSCORE.updateFileModel(TSCORE.fileList, oldFilePath, newFilePath);- TSCORE.PerspectiveManager.updateFileUI(oldFilePath, newFilePath);- }- TSCORE.Meta.updateMetaData(oldFilePath, newFilePath);- TSCORE.hideWaitingDialog();- };-- exports.listDirectory = function(anotatedDirList) {- TSCORE.PerspectiveManager.updateFileBrowserData(anotatedDirList);- TSCORE.updateSubDirs(anotatedDirList);- };-- exports.listSubDirectories = function(dirList, dirPath) {- TSCORE.subfoldersDirBrowser = dirList;- if (TSCORE.directoryBrowser !== undefined) {- TSCORE.directoryBrowser.reInitUI(dirPath);- }- };-- exports.errorOpeningPath = function(dirPath) {- // Normalazing the paths- var dir1 = TSCORE.TagUtils.cleanTrailingDirSeparator(TSCORE.currentLocationObject.path);- var dir2 = TSCORE.TagUtils.cleanTrailingDirSeparator(dirPath);- // Close the current location if the its path could not be opened- if (dir1 === dir2) {- TSCORE.showAlertDialog($.i18n.t('ns.dialogs:errorOpeningLocationAlert'));- TSCORE.closeCurrentLocation();- } else {- TSCORE.showAlertDialog($.i18n.t('ns.dialogs:errorOpeningPathAlert'));- }- };-- exports.deleteElement = function(filePath) {- TSCORE.showSuccessDialog("File deleted successfully.");- TSCORE.removeFileModel(TSCORE.fileList, filePath);- TSCORE.Meta.deleteMetaData(filePath);- TSCORE.PerspectiveManager.removeFileUI(filePath);- if (filePath === TSCORE.FileOpener.getOpenedFilePath()) {- TSCORE.FileOpener.closeFile(true);- }- TSCORE.hideLoadingAnimation();- };-- exports.selectDirectory = function(dirPath) {- // TODO make the use of this function more general- if (!TSCORE.TagUtils.stringEndsWith(dirPath, TSCORE.dirSeparator)) {- dirPath = dirPath + TSCORE.dirSeparator;- }- var dirName = TSCORE.TagUtils.extractContainingDirectoryName(dirPath);- $('#connectionName').val(dirName);- $('#folderLocation').val(dirPath);- $('#folderLocation2').val(dirPath);- $('#folderLocation').blur();- $('#folderLocation2').blur();- $('#moveCopyDirectoryPath').val(dirPath);- };-});diff --git a/data/js/search.ui.js b/data/js/search.ui.jsindex 138591a30..2d174b512 100644--- a/data/js/search.ui.js+++ b/data/js/search.ui.js@@ -7,7 +7,6 @@ define(function(require, exports, module) {'use strict';console.log('Loading search.ui.js ...');var TSCORE = require('tscore');- var TSPOSTIO = require("tspostioapi");var initUI = function() {// Search UI@@ -186,10 +185,19 @@ define(function(require, exports, module) {// Restoring initial dir listing without subdirectoriesTSCORE.IO.listDirectoryPromise(TSCORE.currentPath).then(function(entries) {- TSPOSTIO.listDirectory(entries);+ TSCORE.PerspectiveManager.updateFileBrowserData(entries);+ TSCORE.updateSubDirs(entries);}).catch(function(err) {- TSPOSTIO.errorOpeningPath(TSCORE.currentPath);+ var dir1 = TSCORE.TagUtils.cleanTrailingDirSeparator(TSCORE.currentLocationObject.path);+ var dir2 = TSCORE.TagUtils.cleanTrailingDirSeparator(TSCORE.currentPath);+ // Close the current location if the its path could not be opened+ if (dir1 === dir2) {+ TSCORE.showAlertDialog($.i18n.t('ns.dialogs:errorOpeningLocationAlert'));+ TSCORE.closeCurrentLocation();+ } else {+ TSCORE.showAlertDialog($.i18n.t('ns.dialogs:errorOpeningPathAlert'));+ }console.warn("Error listing directory" + err);});}diff --git a/data/js/tagutils.js b/data/js/tagutils.jsindex ef3040557..42636be51 100644--- a/data/js/tagutils.js+++ b/data/js/tagutils.js@@ -6,7 +6,6 @@ define(function(require, exports, module) {'use strict';console.log('Loading tagutils.js ...');var TSCORE = require('tscore');- var TSPOSTIO = require("tspostioapi");var BEGIN_TAG_CONTAINER = '[';var END_TAG_CONTAINER = ']';@@ -349,7 +348,7 @@ define(function(require, exports, module) {console.log("tagutils.renameFile " + filePath);TSCORE.IO.renameFilePromise(filePath, newFilePath).then(function(success) {TSCORE.hideWaitingDialog();- TSPOSTIO.renameFile(filePath, newFilePath);+ TSCORE.IOUtils.renameFileSuccess(filePath, newFilePath);}, function(err) {TSCORE.hideWaitingDialog();TSCORE.showAlertDialog(err);diff --git a/data/js/utils.js b/data/js/utils.jsindex 8db987489..e67f41c77 100644--- a/data/js/utils.js+++ b/data/js/utils.js@@ -9,7 +9,6 @@ define(function(require, exports, module) {console.log('Loading utils.js ...');var TSCORE = require('tscore');- var TSPOSTIO = require('tspostioapi');var marked = require("marked");var saveAs = require("libs/filesaver.js/FileSaver.min");diff --git a/data/loader.js b/data/loader.jsindex cb552e81e..11c7b78d0 100644--- a/data/loader.js+++ b/data/loader.js@@ -122,7 +122,6 @@ var isWin = navigator.appVersion.indexOf("Win")!==-1;tstagsui: 'js/tags.ui',tsdirectoriesui: 'js/directories.ui',tscoreui: 'js/core.ui',- tspostioapi: 'js/postioapi',tsdirectorybrowser: 'js/directorybrowser',tsutils: 'js/utils',tsioutils: 'js/ioutils',diff --git a/data/mozilla/mozilla.api.js b/data/mozilla/mozilla.api.jsindex c728e2959..ddbd1a452 100644--- a/data/mozilla/mozilla.api.js+++ b/data/mozilla/mozilla.api.js@@ -14,7 +14,6 @@ define(function(require, exports, module) {console.log("Loading mozilla.api.js..");var TSCORE = require("tscore");- var TSPOSTIO = require("tspostioapi");var args = [];document.documentElement.addEventListener("tsMessage", function(event) {@@ -47,14 +46,14 @@ define(function(require, exports, module) {case "createDirectoryTree":if (message.success) {console.log("Directory tree: " + JSON.stringify(message.content));- TSPOSTIO.createDirectoryTree(message.content);+ //.createDirectoryTree(message.content); // TODO broken} else {console.error("Indexing directory failed");}break;case "selectDirectory":if (message.success) {- TSPOSTIO.selectDirectory(message.content);+ //.selectDirectory(message.content); // TODO broken} else {console.error("Selecting directory failed.");}@@ -368,7 +367,7 @@ define(function(require, exports, module) {function createDirectory(dirPath, silentMode) {createDirectoryPromise(dirPath).then(function() {if(!silentMode) {- TSPOSTIO.createDirectory(dirPath);+ //.createDirectory(dirPath);}}, function(error){console.log(error);diff --git a/data/web/web.api.js b/data/web/web.api.jsindex 16378e4a5..20c5c68cd 100644--- a/data/web/web.api.js+++ b/data/web/web.api.js@@ -14,7 +14,6 @@ define(function(require, exports, module) {console.log("Loading web.js..");var TSCORE = require("tscore");- var TSPOSTIO = require("tspostioapi");require("webdav");//require("web/offlinelib/offline.min");