Skip to content

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

removing search functionality

uggrock2c04612b0465
diff --git a/data/node-webkit/node-webkit.api.js b/data/node-webkit/node-webkit.api.js
index e2b76f12c..85ac8cd07 100644
--- a/data/node-webkit/node-webkit.api.js
+++ b/data/node-webkit/node-webkit.api.js
@@ -223,7 +223,6 @@ define(function(require, exports, module) {
}
}
-
var createDirectoryIndex = function(dirPath) {
console.log("Creating index for directory: " + dirPath);
TSCORE.showWaitingDialog($.i18n.t("ns.common:waitDialogDiectoryIndexing"));
@@ -245,44 +244,6 @@ define(function(require, exports, module) {
};
- var liveSearch = function(dirPath, query) {
- console.log("Searching directory: " + dirPath);
- TSCORE.showWaitingDialog($.i18n.t("ns.common:waitDialogDiectoryIndexing"));
- //TSCORE.showLoadingAnimation();
-
- function fileFilter(file) {
- return /\.(html|txt|xml|md|json)$/i.test(file);
- }
-
- var searchResults = [];
- walkDirectory(dirPath, {recursive: true},
- function(fileEntry) {
- if(fileEntry.name.indexOf(query) > 0) {
- searchResults.push(fileEntry);
- }
- if(fileFilter(fileEntry.name)) {
-
- }
- },
- function(dirEntry) {
- if(dirEntry.name.indexOf(query) > 0) {
- searchResults.push(dirEntry);
- }
- }
- ).then(
- function(entries) {
- TSPOSTIO.createDirectoryIndex(directoryIndex);
- },
- function(err) {
- console.warn("Error creating index: " + err);
- }
- ).catch(function() {
- TSCORE.hideWaitingDialog();
- });
-
- };
-
-
var createDirectoryTree = function(dirPath) {
console.log("Creating directory index for: " + dirPath);
TSCORE.showWaitingDialog($.i18n.t("ns.common:waitDialogDiectoryIndexing"));
@@ -452,6 +413,35 @@ define(function(require, exports, module) {
});
};
+ var loadTextStreamPromise = function(filePath, isPreview) {
+// console.log("Loading text stream for: " + filePath);
+ return new Promise(function(resolve, reject) {
+ if (isPreview) {
+ var stream = fs.createReadStream(filePath, {
+ start: 0,
+ end: 10000
+ });
+ stream.on('error', function(err) {
+ reject(err);
+ });
+
+ stream.on('data', function(content) {
+ //console.log("Stream: " + content);
+ resolve(content);
+ });
+
+ } else {
+ fs.readFile(filePath, 'utf8', function(error, content) {
+ if (error) {
+ reject(error)
+ } else {
+ resolve(content);
+ }
+ });
+ }
+ });
+ };
+
var loadTextFile = function(filePath, isPreview) {
console.log("Loading file: " + filePath);
loadTextFilePromise(filePath, isPreview).then(function(content) {
@@ -878,4 +868,5 @@ define(function(require, exports, module) {
exports.getDirectoryMetaInformation = getDirectoryMetaInformation;
exports.getFileContentPromise = getFileContentPromise;
exports.listDirectoryPromise = listDirectoryPromise;
+ exports.walkDirectory = walkDirectory;
});