Skip to content

TagSpaces is an offline, open source, document manager with tagging support

refactoring fileopener.js

uggrock29c56afd126c
diff --git a/data/js/ioapi.chrome.js b/data/js/ioapi.chrome.js
index a972264a5..399a418a1 100644
--- a/data/js/ioapi.chrome.js
+++ b/data/js/ioapi.chrome.js
@@ -61,7 +61,7 @@ IOAPI.loadTextFile = function(filePath) {
console.debug("Loading file: "+filePath);
if(IOAPI.plugin.fileExists(filePath)) {
var fileContent = IOAPI.plugin.getTextFile(filePath);
- FileViewer.updateEditorContent(fileContent);
+ UIAPI.FileOpener.updateEditorContent(fileContent);
} else {
console.error("File does not exists...");
}
diff --git a/data/js/ioapi.cordova.js b/data/js/ioapi.cordova.js
index 295641429..093c5a8a2 100644
--- a/data/js/ioapi.cordova.js
+++ b/data/js/ioapi.cordova.js
@@ -62,7 +62,7 @@ IOAPI.loadTextFile = function(filePath) {
console.debug("Loading file: "+filePath);
if(IOAPI.plugin.fileExists(filePath)) {
var fileContent = IOAPI.plugin.getTextFile(filePath);
- FileViewer.updateEditorContent(fileContent);
+ UIAPI.FileOpener.updateEditorContent(fileContent);
} else {
console.error("File does not exists...");
}
diff --git a/data/js/main.js b/data/js/main.js
index 8d349322f..6c07ac155 100644
--- a/data/js/main.js
+++ b/data/js/main.js
@@ -40,15 +40,16 @@ var initApp = function(){
"js/tagutils",
"js/view.manager",
"js/settings.api",
- "js/fileviewer.ui",
+ "js/fileopener",
"js/core.ui",
"js/tags.ui",
"js/core.api",
"js/directories.ui",
],
- function(tagutils, viewManager) {
+ function(tagutils, viewManager, setting, fileOpener) {
UIAPI.TagUtils = tagutils;
UIAPI.ViewManager = viewManager;
+ UIAPI.FileOpener = fileOpener;
TagsUI.initContextMenus();
TagsUI.initDialogs();
diff --git a/data/js/messaging.mozilla.js b/data/js/messaging.mozilla.js
index 9e299e168..a9a5c182c 100644
--- a/data/js/messaging.mozilla.js
+++ b/data/js/messaging.mozilla.js
@@ -71,7 +71,7 @@ document.documentElement.addEventListener("addon-message1", function(event) {
break;
case "loadTextFile":
if(message.success){
- FileViewer.updateEditorContent(message.content);
+ UIAPI.FileOpener.updateEditorContent(message.content);
} else {
UIAPI.updateLogger("File loading failed");
}
diff --git a/data/js/tagutils.js b/data/js/tagutils.js
index fd1c4d0c7..0bdd0cd62 100644
--- a/data/js/tagutils.js
+++ b/data/js/tagutils.js
@@ -36,7 +36,8 @@ define([
if(filePath.lastIndexOf(".") < 0) { ext = ""; }
return ext;
}
-
+
+ // TODO consider [qweq wqeqe].txt
function extractTitle(filePath) {
console.debug("Extracting title from: "+filePath);
var fileName = extractFileName(filePath);
@@ -177,6 +178,8 @@ define([
function writeTagsToFile(filePath, tags) {
console.debug("Add the tags to: "+filePath);
+
+ var fileName = extractFileName(filePath);
var containingDirectoryPath = extractContainingDirectoryPath(filePath);
@@ -197,6 +200,8 @@ define([
function renameTag(filePath, oldTag, newTag) {
console.debug("Rename tag for file: "+filePath);
+
+ var fileName = extractFileName(filePath);
var containingDirectoryPath = extractContainingDirectoryPath(filePath);
@@ -219,6 +224,8 @@ define([
function removeTag(filePath, tagName) {
console.debug("Removing tag: "+tagName+" from "+filePath);
+ var fileName = extractFileName(filePath);
+
var containingDirectoryPath = extractContainingDirectoryPath(filePath);
var tags = extractTags(filePath);