TagSpaces is an offline, open source, document manager with tagging support
getSubdirs mergerd to listDirectory for performance improvements all ioapis have now a unified interface
uggrock9377d896d66a
diff --git a/data/ext/viewerAudioVideo/viewerUI.js b/data/ext/viewerAudioVideo/viewerUI.jsnew file mode 100644index 000000000..88cc9c557--- /dev/null+++ b/data/ext/viewerAudioVideo/viewerUI.js@@ -0,0 +1,124 @@+/* Copyright (c) 2012-2013 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 UI for Image Viewer");++ var TSCORE = require("tscore");++ var TMB_SIZES = [ "100px", "200px", "300px", "400px", "500px" ];++ function ExtUI(extID, extContainerID, filePath) {+ this.extensionID = extID;+ this.containerElem = $('#'+extContainerID);++ //TODO minimize platform specific calls+ if(isCordova) {+ this.filePath = filePath;+ } else {+ this.filePath = "file:///"+filePath;+ }+ }++ ExtUI.prototype.buildUI = function() {+ console.log("Init UI module");++ this.viewContainer = $("#"+this.extensionID+"Container").empty();+ this.viewToolbar = $("#"+this.extensionID+"Toolbar").empty();+ this.viewFooter = $("#"+this.extensionID+"Footer").empty();++ var self = this;++ this.containerElem.addClass("row-fluid");++ this.containerElem.append($("<div>", {+ // class: "span11",+ })+ .append($('<img>', {+ id: "imgViewer",+ style: "max-width: 100%; max-height: 100%; display: block; margin-left: auto; margin-right: auto ",+ src: this.filePath+ })+ ));+/*+ this.containerElem.append($("<div>", {+ class: "btn-group btn-group-vertical span1",+ //style: "margin: 0px",+ id: this.extensionID+"Toolbar",+ })++ .append($("<button>", {+ class: "btn ",+ title: "Toggle Select All Files",+ id: this.extensionID+"ToogleSelectAll",+ })+ .click(function() {+ $("#imgViewer").pixastic("brightness", {brightness:60});+ })+ .append( "<i class='icon-sun'>" )+ )++ .append($("<button>", {+ class: "btn ",+ title: "Toggle Select All Files",+ id: this.extensionID+"ToogleSelectAll",+ })+ .click(function() {+ $("#imgViewer").pixastic("rotate", {angle:90});+ })+ .append( "<i class='icon-sun'>" )+ )++ .append($("<button>", {+ class: "btn ",+ title: "Toggle Select All Files",+ id: this.extensionID+"ToogleSelectAll",+ })+ .click(function() {+ Caman('#imgViewer', function () {+ this.saturation(-30);+ this.render();+ });+ })+ .append( "<i class='icon-sun'>" )+ )++ .append($("<button>", {+ class: "btn ",+ title: "Toggle Select All Files",+ id: this.extensionID+"ToogleSelectAll",+ })+ .click(function() {+ Caman('#imgViewer', function () {+ this.contrast(30);+ this.render();+ });+ })+ .append( "<i class='icon-sun'>" )+ )++ .append($("<button>", {+ class: "btn ",+ title: "Rotate",+ id: this.extensionID+"ToogleSelectAll",+ })+ .click(function() {+ Caman('#imgViewer', function () {+ this.rotate(90);+ this.render();+ });+ })+ .append( "<i class='icon-sun'>" )+ )++ ); // end toolbar+*/+++ };++ exports.ExtUI = ExtUI;+});\ No newline at end of filediff --git a/data/js/core.api.js b/data/js/core.api.jsindex ca8c47304..251864757 100644--- a/data/js/core.api.js+++ b/data/js/core.api.js@@ -8,6 +8,7 @@ define(function(require, exports, module) {var tsSettings = require("tssetting");var tsIOApi = require("tsioapi");+ var tsIOApiDropbox = require("tsioapidropbox");var tsPersManager = require("tspersmanager");var tsTagUtils = require("tstagutils");var tsFileOpener = require("tsfileopener");@@ -369,6 +370,15 @@ define(function(require, exports, module) {layoutContainer.close("east");}+ function switchIOAPI(type) {+ if(type=="dropbox") {+ tsIOApiDropbox.init();+ exports.IO = tsIOApiDropbox+ } else {+ exports.IO = tsIOApi;+ }+ }+// Proxying applications partsexports.Config = tsSettings;exports.IO = tsIOApi;diff --git a/data/js/directories.ui.js b/data/js/directories.ui.jsindex e535be038..42a3ced48 100644--- a/data/js/directories.ui.js+++ b/data/js/directories.ui.js@@ -31,17 +31,18 @@ define(function(require, exports, module) {// Updates the directory subtreefunction updateSubDirs(dirList) {- console.log("Updating subdirs(TSCORE)..."+JSON.stringify(dirList));-- // Sort the dirList alphabetically- dirList.sort(function(a,b) { return a.title.localeCompare(b.title); });+ //console.log("Updating subdirs(TSCORE)..."+JSON.stringify(dirList));for(var i=0; i < directoryHistory.length; i++) {- if(directoryHistory[i].key == TSCORE.currentPath) {+ if(directoryHistory[i].path == TSCORE.currentPath) {directoryHistory[i]["children"] = new Array();- for(var j=0; j < dirList.length; j++) {- directoryHistory[i]["children"].push(dirList[j]);+ for(var j=0; j < dirList.length; j++) {+ if(!dirList[j].isFile) {+ directoryHistory[i]["children"].push(dirList[j]);+ }}+ // Sort the dirList alphabetically+ directoryHistory[i]["children"].sort(function(a,b) { return a.name.localeCompare(b.name); });}}@@ -61,7 +62,7 @@ define(function(require, exports, module) {.append($("<div>", {"class": "accordion-heading btn-group",- "key": directoryHistory[i].key,+ "key": directoryHistory[i].path,"style": "width:100%; margin: 0px; ",})@@ -70,7 +71,7 @@ define(function(require, exports, module) {"class": "btn btn-link directoryIcon","data-toggle": "collapse","data-target": "#dirButtons"+i,- "key": directoryHistory[i].key,+ "key": directoryHistory[i].path,"title": "Toggle Directory",})@@ -79,9 +80,9 @@ define(function(require, exports, module) {.append($("<button>", { // Dir main button"class": "btn btn-link btn-small directoryTitle",- "key": directoryHistory[i].key,- "title": "Change Direoctory to: "+directoryHistory[i].key,- "text": directoryHistory[i].title,+ "key": directoryHistory[i].path,+ "title": "Change Direoctory to: "+directoryHistory[i].path,+ "text": directoryHistory[i].name,}).click(function() {@@ -106,7 +107,7 @@ define(function(require, exports, module) {.append($("<button>", {"class": "btn btn-link directoryActions",- "key": directoryHistory[i].key,+ "key": directoryHistory[i].path,"title": "Directory Options",}).dropdown( 'attach' , '#directoryMenu' )@@ -138,13 +139,13 @@ define(function(require, exports, module) {} else {for(var j=0; j < directoryHistory[i]["children"].length; j++) {if (TSCORE.Config.getShowUnixHiddenEntries() ||- (!TSCORE.Config.getShowUnixHiddenEntries() && (directoryHistory[i]["children"][j].title.indexOf(".") != 0))) {+ (!TSCORE.Config.getShowUnixHiddenEntries() && (directoryHistory[i]["children"][j].name.indexOf(".") != 0))) {dirButtons.append($("<button>", {"class": "btn btn-small dirButton",- "key": directoryHistory[i]["children"][j].key,- "title": directoryHistory[i]["children"][j].key,+ "key": directoryHistory[i]["children"][j].path,+ "title": directoryHistory[i]["children"][j].path,"style": "margin: 1px;",- "text": " "+directoryHistory[i]["children"][j].title+ "text": " "+directoryHistory[i]["children"][j].name}).droppable({greedy: "true",@@ -193,7 +194,7 @@ define(function(require, exports, module) {function getDirectoryCollapsed(directoryPath) {for(var i=0; i < directoryHistory.length; i++) {- if(directoryHistory[i].key == directoryPath) {+ if(directoryHistory[i].path == directoryPath) {return directoryHistory[i].collapsed;}}@@ -201,7 +202,7 @@ define(function(require, exports, module) {function setDirectoryCollapse(directoryPath, collapsed) {for(var i=0; i < directoryHistory.length; i++) {- if(directoryHistory[i].key == directoryPath) {+ if(directoryHistory[i].path == directoryPath) {directoryHistory[i].collapsed = collapsed;}}@@ -220,7 +221,7 @@ define(function(require, exports, module) {var directoryFoundOn = -1;for(var i=0; i < directoryHistory.length; i++) {- if(directoryHistory[i].key == directoryPath) {+ if(directoryHistory[i].path == directoryPath) {directoryHistory[i].collapsed = false;directoryFoundOn = i;} else {@@ -241,7 +242,7 @@ define(function(require, exports, module) {var parentLocation = directoryPath.substring(0, directoryPath.lastIndexOf(TSCORE.TagUtils.DIR_SEPARATOR));var parentFound = -1;for(var i=0; i < directoryHistory.length; i++) {- if(directoryHistory[i].key == parentLocation) {+ if(directoryHistory[i].path == parentLocation) {parentFound = i;}}@@ -254,15 +255,14 @@ define(function(require, exports, module) {var locationTitle = directoryPath.substring(directoryPath.lastIndexOf(TSCORE.TagUtils.DIR_SEPARATOR)+1,directoryPath.length);directoryHistory.push({- "title": locationTitle,- "key" : directoryPath,+ "name": locationTitle,+ "path" : directoryPath,"collapsed" : false,});}TSCORE.currentPath = directoryPath;TSCORE.startTime = new Date().getTime();- TSCORE.IO.getSubdirs(directoryPath);TSCORE.IO.listDirectory(directoryPath);}diff --git a/data/js/ioapi.chrome.js b/data/js/ioapi.chrome.jsindex 3916ac4d4..c467b4d91 100644--- a/data/js/ioapi.chrome.js+++ b/data/js/ioapi.chrome.js@@ -59,11 +59,11 @@ IO-API}}index.push({- "name": dirList[i],- "type": isDir?"directory":"file",- "size": fileSize,- "lmdt": lastDateModified,- "path": path+ "name": dirList[i],+ "isFile": !isDir,+ "size": fileSize,+ "lmdt": lastDateModified,+ "path": path});if (isDir) {scanDirectory(path, index);@@ -79,7 +79,7 @@ IO-APItry {var tree = {};tree["name"] = dirPath.substring(dirPath.lastIndexOf(getDirseparator()) + 1, dirPath.length);- tree["type"] = "directory";+ tree["type"] = false;tree["lmdt"] = 0;tree["path"] = dirPath;tree["children"] = [];@@ -95,11 +95,11 @@ IO-APIlastDateModified = new Date(nativeIO.getFileLastDateModified(path)*1000);}tree["children"].push({- "name": dirList[i],- "type": "file",- "size": fileSize,- "lmdt": lastDateModified,- "path": path+ "name": dirList[i],+ "isFile": true,+ "size": fileSize,+ "lmdt": lastDateModified,+ "path": path});} else {tree["children"].push( generateDirectoryTree(path) );@@ -123,7 +123,7 @@ IO-API}}- exports.checkNewVersion = function() {+ var checkNewVersion = function() {console.log("Checking for new version...");var cVer = TSCORE.Config.DefaultSettings["appVersion"]+"."+TSCORE.Config.DefaultSettings["appBuild"];$.ajax({@@ -139,7 +139,7 @@ IO-API;};- exports.loadTextFile = function(filePath) {+ var loadTextFile = function(filePath) {console.log("Loading file: "+filePath);if(nativeIO.fileExists(filePath)) {var blob;@@ -162,7 +162,7 @@ IO-API}};- exports.listDirectory = function(dirPath) {+ var listDirectory = function(dirPath) {console.log("Listing directory: "+dirPath);if(nativeIO.isDirectory(dirPath)) {try {@@ -181,7 +181,7 @@ IO-API}anotatedDirList.push({"name": dirList[i],- "type": isDir?"directory":"file",+ "isFile": !isDir,"size": fileSize,"lmdt": lastDateModified,"path": path@@ -195,34 +195,8 @@ IO-APIconsole.error("Directory does not exists.");}};-- exports.getSubdirs = function(dirPath) {- console.log("Getting subdirs: "+dirPath);- if(nativeIO.isDirectory(dirPath)) {- try {- var dirList = nativeIO.getDirEntries(dirPath);- var anotatedDirList = [];- for (var i=0; i < dirList.length; i++) {- var path = dirPath+getDirseparator()+dirList[i];- var isDir = nativeIO.isDirectory(path);- if(isDir) {- anotatedDirList.push({- "title": dirList[i],- "isFolder": true,- "key": path- });- }- }- TSPOSTIO.getSubdirs(anotatedDirList);- } catch(ex) {- console.error("Directory listing failed "+ex);- }- } else {- console.error("Directory does not exists.");- }- };- exports.deleteElement = function(path) {+ var deleteElement = function(path) {console.log("Deleting: "+path);try {nativeIO.removeRecursively(path);@@ -232,7 +206,7 @@ IO-API}};- exports.createDirectoryIndex = function(dirPath) {+ var createDirectoryIndex = function(dirPath) {console.log("Creating index for directory: "+dirPath);var directoryIndex = [];directoryIndex = scanDirectory(dirPath, directoryIndex);@@ -240,14 +214,14 @@ IO-APITSPOSTIO.createDirectoryIndex(directoryIndex);};- exports.createDirectoryTree = function(dirPath) {+ var createDirectoryTree = function(dirPath) {console.log("Creating directory index for: "+dirPath);var directoyTree = generateDirectoryTree(dirPath);//console.log(JSON.stringify(directoyTree));TSPOSTIO.createDirectoryTree(directoyTree);};- exports.saveTextFile = function(filePath,content) {+ var saveTextFile = function(filePath,content) {console.log("Saving file: "+filePath);var byteArray = [];for (var i = 0; i < content.length; ++i)@@ -265,7 +239,7 @@ IO-APIreader.readAsArrayBuffer(blob);};- exports.createDirectory = function(dirPath) {+ var createDirectory = function(dirPath) {console.log("Creating directory: "+dirPath);try {nativeIO.createDirectory(dirPath);@@ -275,7 +249,7 @@ IO-API}};- exports.renameFile = function(filePath, newFilePath) {+ var renameFile = function(filePath, newFilePath) {console.log("Renaming file: "+filePath+" to "+newFilePath);if(filePath.toLowerCase() == newFilePath.toLowerCase()) {console.log("Initial and target filenames are the same...");@@ -324,7 +298,7 @@ IO-API}};- exports.selectDirectory = function() {+ var selectDirectory = function() {console.log("Select directory!");nativeIO.launchFolderSelect(function(dirPath){if (dirPath && dirPath.length){@@ -333,7 +307,7 @@ IO-API});};- exports.selectFile = function() {+ var selectFile = function() {console.log("Select file!");nativeIO.launchFileSelect(function(filePath){if (filePath && filePath.length){@@ -342,7 +316,7 @@ IO-API});};- exports.checkAccessFileURLAllowed = function() {+ var checkAccessFileURLAllowed = function() {chrome.extension.isAllowedFileSchemeAccess(function(isAllowedAccess) {if(!isAllowedAccess) {TSCORE.showAlertDialog(@@ -356,15 +330,30 @@ IO-API});};- exports.openDirectory = function(dirPath) {+ var openDirectory = function(dirPath) {// TODO implement openDirectoryconsole.log("Open directory functionality not implemented in chrome yet!");TSCORE.showAlertDialog("Select file functionality not implemented on chrome yet!");};- exports.openExtensionsDirectory = function() {+ var openExtensionsDirectory = function() {// TODO implement openExtensionsDirectoryconsole.log("Open extensions directory functionality not implemented in chrome yet!");TSCORE.showAlertDialog("Open extensions directory functionality not implemented on chrome yet!");};++ exports.createDirectory = createDirectory;+ exports.renameFile = renameFile;+ exports.loadTextFile = loadTextFile;+ exports.saveTextFile = saveTextFile;+ exports.listDirectory = listDirectory;+ exports.deleteElement = deleteElement;+ exports.createDirectoryIndex = createDirectoryIndex;+ exports.createDirectoryTree = createDirectoryTree;+ exports.selectDirectory = selectDirectory;+ exports.openDirectory = openDirectory;+ exports.selectFile = selectFile;+ exports.openExtensionsDirectory = openExtensionsDirectory;+ exports.checkAccessFileURLAllowed = checkAccessFileURLAllowed;+ exports.checkNewVersion = checkNewVersion;});diff --git a/data/js/ioapi.cordova.js b/data/js/ioapi.cordova.jsindex c4c74d9ea..b0a2a72e4 100644--- a/data/js/ioapi.cordova.js+++ b/data/js/ioapi.cordova.js@@ -34,79 +34,12 @@ define(function (require, exports, module) {// TODO recursivly calling callback not workingfunction scanDirectory(dirPath, index) {- fsRoot.getDirectory(normalizePath(dirPath+"/"), {create: false, exclusive: false},- function (dirEntry) {- var directoryReader = dirEntry.createReader();- // Get a list of all the entries in the directory- directoryReader.readEntries(- function (entries) {- var i;- var recursed = false;- for (i = 0; i < entries.length; i++) {- index.push({- "name": entries[i].name,- "type": entries[i].isFile?"file":"directory",- "size": "0",- "lmdt": "0",- "path": entries[i].fullPath- });- if (entries[i].isDirectory) {- recursed = true;- scanDirectory(entries[i].fullPath, index);- }- }- if (!recursed) return index;- }, function (error) { // error get file system- console.log("Dir List Error: " + error.code);- }- );- },- function (error) {- console.log("Getting dir: "+dirPath+" failed with error code: " + error.code);- }- );+}- function generateDirectoryTree(dirPath) {- // TODO recursivly calling callback not working- dirPath = dirPath+"/"; // TODO make it platform independent- dirPath = normalizePath(dirPath);- var tree = {};- fsRoot.getDirectory(dirPath, {create: false, exclusive: false},- function (dirEntry) {- var directoryReader = dirEntry.createReader();- // Get a list of all the entries in the directory- directoryReader.readEntries(- function (entries) {- tree["name"] = dirEntry.name;- tree["type"] = "directory";- tree["lmdt"] = 0;- tree["path"] = dirEntry.fullPath;- tree["children"] = [];- for (var i=0; i < entries.length; i++) {- if (entries[i].isFile) {- tree["children"].push({- "name": entries[i].name,- "type": "file",- "size": "0",- "lmdt": "0",- "path": entries[i].fullPath- });- } else {- tree["children"].push( generateDirectoryTree(entries[i].fullPath) );- }- }- return tree;- },- function (error) { // error get file system- console.log("Dir Tree Creation Error: " + error.code);- }- );- },- function (error) {- console.log("Getting dir: "+dirPath+" failed with error code: " + error.code);- }- );+ // TODO recursivly calling callback not working+ function generateDirectoryTree(dirPath) {+}function isWindows() {@@ -144,7 +77,7 @@ define(function (require, exports, module) {;};- exports.listDirectory = function (dirPath) {+ var listDirectory = function (dirPath) {// directory path format DCIM/Camera/ !dirPath = dirPath+"/"; // TODO make it platform independentdirPath = normalizePath(dirPath);@@ -163,12 +96,13 @@ define(function (require, exports, module) {for (i = 0; i < entries.length; i++) {console.log("File: "+entries[i].name);anotatedDirList.push({- "name": entries[i].name,- "type": entries[i].isFile?"file":"directory",- "size": "0",- "lmdt": "0",- "path": entries[i].fullPath- });+ "name": entries[i].name,+ "isFile": entries[i].isFile,+ "size": "0",+ "lmdt": "0",+ "path": entries[i].fullPath+ });+ // TODO get file size and last modified date in cordova}//console.log("Dir content: " + JSON.stringify(entries));TSPOSTIO.listDirectory(anotatedDirList);@@ -182,46 +116,8 @@ define(function (require, exports, module) {});};-- exports.getSubdirs = function(dirPath) {- dirPath = dirPath+"/"; // TODO make it platform independent- dirPath = normalizePath(dirPath);-- console.log("Getting subdirs: "+dirPath);-- fsRoot.getDirectory(dirPath, {create: false, exclusive: false},- function (dirEntry) {- var directoryReader = dirEntry.createReader();- // Get a list of all the entries in the directory- directoryReader.readEntries(- function (entries) {- var i;- var anotatedDirList = [];- for (i = 0; i < entries.length; i++) {- console.log(entries[i].name);- if(entries[i].isDirectory) {- anotatedDirList.push({- "title": entries[i].name,- "isFolder": true,- "key": entries[i].fullPath- });- }- }- console.log("Subdir content: " + JSON.stringify(entries));- TSPOSTIO.getSubdirs(anotatedDirList);-- }, function (error) { // error get file system- console.log("Dir List Error: " + error.code);- }- );- },- function (error) {- console.log("Getting dir: "+dirPath+" failed with error code: " + error.code);- }- );- };- exports.deleteElement = function(path) {+ var deleteElement = function(path) {console.log("Deleting: "+path);path = normalizePath(path);@@ -243,7 +139,7 @@ define(function (require, exports, module) {);};- exports.createDirectoryIndex = function(dirPath) {+ var createDirectoryIndex = function(dirPath) {console.log("Creating index for directory: "+dirPath);TSCORE.showAlertDialog("Creating directory index is not supported on Android yet.");/* var directoryIndex = [];@@ -252,7 +148,7 @@ define(function (require, exports, module) {TSPOSTIO.createDirectoryIndex(directoryIndex); */};- exports.createDirectoryTree = function(dirPath) {+ var createDirectoryTree = function(dirPath) {console.log("Creating directory index for: "+dirPath);TSCORE.showAlertDialog("Creating directory tree is not supported on Android yet.");/* var directoyTree = generateDirectoryTree(dirPath);@@ -260,7 +156,7 @@ define(function (require, exports, module) {TSPOSTIO.createDirectoryTree(directoyTree);*/};- exports.loadTextFile = function(filePath) {+ var loadTextFile = function(filePath) {filePath = normalizePath(filePath);console.log("Loading file: "+filePath);fsRoot.getFile(filePath, {create: false, exclusive: false},@@ -284,7 +180,7 @@ define(function (require, exports, module) {);};- exports.saveTextFile = function(filePath,content) {+ var saveTextFile = function(filePath,content) {filePath = normalizePath(filePath);console.log("Saving file: "+filePath);fsRoot.getFile(filePath, {create: true, exclusive: false},@@ -307,7 +203,7 @@ define(function (require, exports, module) {);};- exports.createDirectory = function(dirPath) {+ var createDirectory = function(dirPath) {dirPath = normalizePath(dirPath);console.log("Creating directory: "+dirPath);fsRoot.getDirectory(dirPath, {create: true, exclusive: false},@@ -320,7 +216,7 @@ define(function (require, exports, module) {);};- exports.renameFile = function(filePath, newFilePath) {+ var renameFile = function(filePath, newFilePath) {filePath = normalizePath(filePath);var newFileName = newFilePath.substring(newFilePath.lastIndexOf('/')+1);var newFileParentPath = normalizePath(newFilePath.substring(0, newFilePath.lastIndexOf('/')));@@ -352,24 +248,39 @@ define(function (require, exports, module) {);};- exports.selectDirectory = function() {+ var selectDirectory = function() {console.log("Operation selectDirectory not supported on Android yet!");TSCORE.showAlertDialog("Selecting directory not supported on Android yet, please enter the desired directory path manually in the textbox!");};- exports.selectFile = function() {+ var selectFile = function() {console.log("Operation selectFile not supported on Android!");};- exports.checkAccessFileURLAllowed = function() {+ var checkAccessFileURLAllowed = function() {console.log("checkAccessFileURLAllowed function not relevant for Android..");};- exports.openDirectory = function(dirPath) {+ var openDirectory = function(dirPath) {TSCORE.showAlertDialog("Select file functionality not supported on Android!");};- exports.openExtensionsDirectory = function() {+ var openExtensionsDirectory = function() {TSCORE.showAlertDialog("Open extensions directory functionality not supported on Android!");- };+ };++ exports.createDirectory = createDirectory;+ exports.renameFile = renameFile;+ exports.loadTextFile = loadTextFile;+ exports.saveTextFile = saveTextFile;+ exports.listDirectory = listDirectory;+ exports.deleteElement = deleteElement;+ exports.createDirectoryIndex = createDirectoryIndex;+ exports.createDirectoryTree = createDirectoryTree;+ exports.selectDirectory = selectDirectory;+ exports.openDirectory = openDirectory;+ exports.selectFile = selectFile;+ exports.openExtensionsDirectory = openExtensionsDirectory;+ exports.checkAccessFileURLAllowed = checkAccessFileURLAllowed;+ exports.checkNewVersion = checkNewVersion;});\ No newline at end of filediff --git a/data/js/ioapi.dropbox.js b/data/js/ioapi.dropbox.jsindex 116efe36e..8a643cf61 100644--- a/data/js/ioapi.dropbox.js+++ b/data/js/ioapi.dropbox.js@@ -3,12 +3,8 @@* can be found in the LICENSE file. */define(function (require, exports, module) {"use strict";-- console.log("Loading ioapi.dropbox.js..");-- var TSCORE = require("tscore");-- var TSPOSTIO = require("tspostioapi");++ console.log("Loading ioapi.dropbox.js..");/* stat format- file@@ -16,123 +12,53 @@ define(function (require, exports, module) {- directory{"_json":{"revision":354,"rev":"1620068aeb1","thumb_exists":false,"bytes":0,"modified":"Tue, 19 Nov 2013 16:32:05 +0000","path":"/23","is_dir":true,"icon":"folder","root":"dropbox","size":"0 bytes"},"path":"/23","name":"23","isFolder":true,"isFile":false,"isRemoved":false,"typeIcon":"folder","modifiedAt":"2013-11-19T16:32:05.000Z","clientModifiedAt":null,"inAppFolder":false,"size":0,"humanSize":"0 bytes","hasThumbnail":false,"versionTag":"1620068aeb1","contentHash":null,"mimeType":"inode/directory"}*/+var fsRoot;- requirejs(['dropbox'], function () {- // TODO rework handling of hashes- if(window.location.hash.length < 1) {- init();- } else {- // #access_token=p00H94aHbVkAAAAAAAAAAbITvnyzGGMSw5EUYfbpH9V5lSeiK7QmoEIbyvn6uYMw&token_type=bearer&uid=4360164&state=oas_ho7adxkp_0.pd8q6hqf1zs8xgvi- // console.log(window.location.hash);- var locationHash = location.hash.substr(1);- var dboxToken = locationHash.substr(locationHash.indexOf('access_token=')).split('&')[0].split('=')[1];- console.log("Token: "+dboxToken);- if (!fsRoot) {+ var TSCORE = require("tscore");+ var TSPOSTIO = require("tspostioapi");+ require('dropbox');++ var init = function() {+ if (!fsRoot) {+ if(window.location.hash.length < 1) {+ fsRoot = new Dropbox.Client({+ key: "t174lonmydtl9mk",+ sandbox: false+ });+ fsRoot.authDriver(new Dropbox.AuthDriver.ChromeExtension({receiverPath: "index.html", rememberUser: true}));+ //fsRoot.authDriver(new Dropbox.AuthDriver.Popup({rememberUser: true}));+ fsRoot.authenticate(function (err, fsRoot) {+ if (err) {+ console.log("Auth Error: " + err);+ }+ });+ } else {+ // #access_token=p00H94aHbVkAAAAAAAAAAbITvnyzGGMSw5EUYfbpH9V5lSeiK7QmoEIbyvn6uYMw&token_type=bearer&uid=4360164&state=oas_ho7adxkp_0.pd8q6hqf1zs8xgvi+ var locationHash = location.hash.substr(1);+ var dboxToken = locationHash.substr(locationHash.indexOf('access_token=')).split('&')[0].split('=')[1];+ //console.log("Token: "+dboxToken);fsRoot = new Dropbox.Client({key: "t174lonmydtl9mk",sandbox: false,token: dboxToken,});- }- }- });-- function init(callback) {- if (!fsRoot) {- fsRoot = new Dropbox.Client({- key: "t174lonmydtl9mk",- sandbox: false- });- fsRoot.authDriver(new Dropbox.AuthDriver.ChromeExtension({receiverPath: "index.html", rememberUser: true}));- //fsRoot.authDriver(new Dropbox.AuthDriver.Popup({rememberUser: true}));- fsRoot.authenticate(function (err, fsRoot) {- if (err) {- console.log("Auth Error: " + err);- }- });- }- }+ }+ }+ };// TODO recursivly calling callback not workingfunction scanDirectory(dirPath, index) {- fsRoot.getDirectory(normalizePath(dirPath+"/"), {create: false, exclusive: false},- function (dirEntry) {- var directoryReader = dirEntry.createReader();- // Get a list of all the entries in the directory- directoryReader.readEntries(- function (entries) {- var i;- var recursed = false;- for (i = 0; i < entries.length; i++) {- index.push({- "name": entries[i].name,- "type": entries[i].isFile?"file":"directory",- "size": "0",- "lmdt": "0",- "path": entries[i].fullPath- });- if (entries[i].isDirectory) {- recursed = true;- scanDirectory(entries[i].fullPath, index);- }- }- if (!recursed) return index;- }, function (error) { // error get file system- console.log("Dir List Error: " + error.code);- }- );- },- function (error) {- console.log("Getting dir: "+dirPath+" failed with error code: " + error.code);- }- );+}+ // TODO recursivly calling callback not workingfunction generateDirectoryTree(dirPath) {- // TODO recursivly calling callback not working- dirPath = dirPath+"/"; // TODO make it platform independent- dirPath = normalizePath(dirPath);- var tree = {};- fsRoot.getDirectory(dirPath, {create: false, exclusive: false},- function (dirEntry) {- var directoryReader = dirEntry.createReader();- // Get a list of all the entries in the directory- directoryReader.readEntries(- function (entries) {- tree["name"] = dirEntry.name;- tree["type"] = "directory";- tree["lmdt"] = 0;- tree["path"] = dirEntry.fullPath;- tree["children"] = [];- for (var i=0; i < entries.length; i++) {- if (entries[i].isFile) {- tree["children"].push({- "name": entries[i].name,- "type": "file",- "size": "0",- "lmdt": "0",- "path": entries[i].fullPath- });- } else {- tree["children"].push( generateDirectoryTree(entries[i].fullPath) );- }- }- return tree;- },- function (error) { // error get file system- console.log("Dir Tree Creation Error: " + error.code);- }- );- },- function (error) {- console.log("Getting dir: "+dirPath+" failed with error code: " + error.code);- }- );+}- exports.checkNewVersion = function() {+ var checkNewVersion = function() {console.log("Checking for new version...");var cVer = TSCORE.Config.DefaultSettings["appVersion"]+"."+TSCORE.Config.DefaultSettings["appBuild"];$.ajax({@@ -148,7 +74,7 @@ define(function (require, exports, module) {;};- exports.listDirectory = function (dirPath) {+ var listDirectory = function (dirPath) {dirPath = dirPath+"/"; // TODO make it platform independentconsole.log("Listing directory: " + dirPath);@@ -164,55 +90,22 @@ define(function (require, exports, module) {for (i = 0; i < stats.length; i++) {console.log("File: "+stats[i].name);anotatedDirList.push({- "name": stats[i].name,- "type": stats[i].isFile?"file":"directory",- "size": stats[i].size,- "lmdt": stats[i].modifiedAt,- "path": stats[i].path+ "name": stats[i].name,+ "isFile": stats[i].isFile,+ "size": stats[i].size,+ "lmdt": stats[i].modifiedAt,+ "path": stats[i].path});}//console.log("Dir content: " + JSON.stringify(entries));TSPOSTIO.listDirectory(anotatedDirList);- }-- if (err) {+ } else {console.log("Dir List Error: " + err);}});};-- exports.getSubdirs = function(dirPath) {- dirPath = dirPath+"/"; // TODO make it platform independent-- console.log("Getting subdirs: "+dirPath);-- var stats = [];-- fsRoot.readdir(dirPath, function (err, contents, dirStat, stats) {- var i, convertedStats = [];-- if (err) {- console.log("Dir List Error: " + err);- } else {- var i;- var anotatedDirList = [];- for (i = 0; i < stats.length; i++) {- console.log("File: "+stats[i].name);- if(stats[i].isFolder) {- anotatedDirList.push({- "title": stats[i].name,- "isFolder": true,- "key": stats[i].path- });- }- }- //console.log("Dir content: " + JSON.stringify(stats));- TSPOSTIO.getSubdirs(anotatedDirList);- }- });- };- exports.deleteElement = function(path) {+ var deleteElement = function(path) {console.log("Deleting: "+path);fsRoot.unlink(path, function (err, stat) {if(err) {@@ -224,7 +117,7 @@ define(function (require, exports, module) {});};- exports.createDirectoryIndex = function(dirPath) {+ var createDirectoryIndex = function(dirPath) {console.log("Creating index for directory: "+dirPath);TSCORE.showAlertDialog("Creating directory index is not supported on Android yet.");/* var directoryIndex = [];@@ -233,7 +126,7 @@ define(function (require, exports, module) {TSPOSTIO.createDirectoryIndex(directoryIndex); */};- exports.createDirectoryTree = function(dirPath) {+ var createDirectoryTree = function(dirPath) {console.log("Creating directory index for: "+dirPath);TSCORE.showAlertDialog("Creating directory tree is not supported on Android yet.");/* var directoyTree = generateDirectoryTree(dirPath);@@ -241,7 +134,7 @@ define(function (require, exports, module) {TSPOSTIO.createDirectoryTree(directoyTree);*/};- exports.loadTextFile = function(filePath) {+ var loadTextFile = function(filePath) {console.log("Loading file: "+filePath);fsRoot.readFile(filePath, function (err, data, stat) {if(err) {@@ -252,7 +145,7 @@ define(function (require, exports, module) {});};- exports.saveTextFile = function(filePath,content) {+ var saveTextFile = function(filePath,content) {console.log("Saving file: "+filePath);fsRoot.writeFile(filePath, content, function (err, stat) {if(err) {@@ -263,7 +156,7 @@ define(function (require, exports, module) {});};- exports.createDirectory = function(dirPath) {+ var createDirectory = function(dirPath) {console.log("Creating directory: "+dirPath);fsRoot.mkdir(dirPath, function (err, stat) {if(err) {@@ -275,7 +168,7 @@ define(function (require, exports, module) {});};- exports.renameFile = function(filePath, newFilePath) {+ var renameFile = function(filePath, newFilePath) {console.log("Renaming file from: "+filePath+" to: "+newFilePath);fsRoot.move(filePath, newFilePath, function (err, stat) {if(err) {@@ -287,24 +180,41 @@ define(function (require, exports, module) {});};- exports.selectDirectory = function() {+ var selectDirectory = function() {console.log("Operation selectDirectory not supported in the Dropbox mode yet!");TSCORE.showAlertDialog("Selecting directory not supported in the Dropbox mode yet, please type the desired directory path manually in textbox!");};- exports.selectFile = function() {+ var selectFile = function() {console.log("Operation selectFile not supported in the Dropbox mode!");};- exports.checkAccessFileURLAllowed = function() {+ var checkAccessFileURLAllowed = function() {console.log("checkAccessFileURLAllowed function not relevant in the Dropbox mode!");};- exports.openDirectory = function(dirPath) {+ var openDirectory = function(dirPath) {TSCORE.showAlertDialog("Select file functionality not supported in the Dropbox mode!");};- exports.openExtensionsDirectory = function() {+ var openExtensionsDirectory = function() {TSCORE.showAlertDialog("Open extensions directory functionality not supported in the Dropbox mode!");- };+ };++ exports.init = init;++ exports.createDirectory = createDirectory;+ exports.renameFile = renameFile;+ exports.loadTextFile = loadTextFile;+ exports.saveTextFile = saveTextFile;+ exports.listDirectory = listDirectory;+ exports.deleteElement = deleteElement;+ exports.createDirectoryIndex = createDirectoryIndex;+ exports.createDirectoryTree = createDirectoryTree;+ exports.selectDirectory = selectDirectory;+ exports.openDirectory = openDirectory;+ exports.selectFile = selectFile;+ exports.openExtensionsDirectory = openExtensionsDirectory;+ exports.checkAccessFileURLAllowed = checkAccessFileURLAllowed;+ exports.checkNewVersion = checkNewVersion;});\ No newline at end of filediff --git a/data/js/ioapi.mozilla.js b/data/js/ioapi.mozilla.jsindex 73b8b7031..88f7c5abd 100644--- a/data/js/ioapi.mozilla.js+++ b/data/js/ioapi.mozilla.js@@ -90,18 +90,6 @@ define(function(require, exports, module) {TSCORE.updateLogger("Indexing directory failed");}break;- case "getSubdirs":- if(message.success){- var dirListing = [];- for (var i=0; i < message.content.length; i++) {- dirListing.push(message.content[i]);- }- // TODO JSON functions are a workarround for a bug....- TSPOSTIO.getSubdirs(JSON.parse( JSON.stringify(dirListing)));- } else {- TSCORE.updateLogger("Getting subdirs failed");- }- break;case "delete":if(message.success){TSPOSTIO.deleteElement();@@ -128,7 +116,7 @@ define(function(require, exports, module) {}}, false);- exports.saveSettings = function(content) {+ var saveSettings = function(content) {console.log("Saving setting...");TSCORE.showLoadingAnimation();var event = document.createEvent('CustomEvent');@@ -139,7 +127,7 @@ define(function(require, exports, module) {document.documentElement.dispatchEvent(event);};- exports.loadSettings = function() {+ var loadSettings = function() {console.log("Loading setting from firefox preferences...");TSCORE.showLoadingAnimation();var event = document.createEvent('CustomEvent');@@ -149,7 +137,7 @@ define(function(require, exports, module) {document.documentElement.dispatchEvent(event);};- exports.createDirectory = function(dirPath) {+ var createDirectory = function(dirPath) {console.log("Directory "+dirPath+" created.");TSCORE.showLoadingAnimation();var event = document.createEvent('CustomEvent');@@ -160,7 +148,7 @@ define(function(require, exports, module) {document.documentElement.dispatchEvent(event);};- exports.loadTextFile = function(filePath) {+ var loadTextFile = function(filePath) {console.log("Loading file: "+filePath);TSCORE.showLoadingAnimation();var event = document.createEvent('CustomEvent');@@ -171,7 +159,7 @@ define(function(require, exports, module) {document.documentElement.dispatchEvent(event);};- exports.renameFile = function(filePath, newFilePath) {+ var renameFile = function(filePath, newFilePath) {console.log("Renaming "+filePath+" to "+newFilePath);TSCORE.showLoadingAnimation();var event = document.createEvent('CustomEvent');@@ -183,7 +171,7 @@ define(function(require, exports, module) {document.documentElement.dispatchEvent(event);};- exports.saveTextFile = function(filePath,content) {+ var saveTextFile = function(filePath,content) {console.log("Saving file: "+filePath);TSCORE.showLoadingAnimation();var event = document.createEvent('CustomEvent');@@ -195,7 +183,7 @@ define(function(require, exports, module) {document.documentElement.dispatchEvent(event);};- exports.listDirectory = function(dirPath) {+ var listDirectory = function(dirPath) {console.log("Listing directory: "+dirPath);TSCORE.showLoadingAnimation();var event = document.createEvent('CustomEvent');@@ -206,18 +194,7 @@ define(function(require, exports, module) {document.documentElement.dispatchEvent(event);};- exports.getSubdirs = function(dirPath) {- console.log("Getting subdirs: "+dirPath);- TSCORE.showLoadingAnimation();- var event = document.createEvent('CustomEvent');- event.initCustomEvent("addon-message", true, true, {"detail":{- "command": "getSubdirs",- "path": dirPath- }});- document.documentElement.dispatchEvent(event);- };-- exports.deleteElement = function(path) {+ var deleteElement = function(path) {console.log("Deleting: "+path);TSCORE.showLoadingAnimation();var event = document.createEvent('CustomEvent');@@ -228,11 +205,11 @@ define(function(require, exports, module) {document.documentElement.dispatchEvent(event);};- exports.checkAccessFileURLAllowed = function() {+ var checkAccessFileURLAllowed = function() {console.log("checkAccessFileURLAllowed function not relevant for node..");};- exports.selectDirectory = function() {+ var selectDirectory = function() {console.log("Selecting directory...");var event = document.createEvent('CustomEvent');event.initCustomEvent("addon-message", true, true, {"detail":{@@ -241,7 +218,7 @@ define(function(require, exports, module) {document.documentElement.dispatchEvent(event);};- exports.selectFile = function() {+ var selectFile = function() {console.log("Selecting file...");var event = document.createEvent('CustomEvent');event.initCustomEvent("addon-message", true, true, {"detail":{@@ -250,7 +227,7 @@ define(function(require, exports, module) {document.documentElement.dispatchEvent(event);};- exports.openDirectory = function(dirPath) {+ var openDirectory = function(dirPath) {console.log("Opening directory: "+dirPath);var event = document.createEvent('CustomEvent');event.initCustomEvent("addon-message", true, true, {"detail":{@@ -260,7 +237,7 @@ define(function(require, exports, module) {document.documentElement.dispatchEvent(event);};- exports.openExtensionsDirectory = function() {+ var openExtensionsDirectory = function() {console.log("Opening extensions directory...");var event = document.createEvent('CustomEvent');event.initCustomEvent("addon-message", true, true, {"detail":{@@ -269,7 +246,7 @@ define(function(require, exports, module) {document.documentElement.dispatchEvent(event);};- exports.createDirectoryIndex = function(dirPath) {+ var createDirectoryIndex = function(dirPath) {console.log("Creating directory index for: "+dirPath);TSCORE.showLoadingAnimation();var event = document.createEvent('CustomEvent');@@ -280,7 +257,7 @@ define(function(require, exports, module) {document.documentElement.dispatchEvent(event);};- exports.createDirectoryTree = function(dirPath) {+ var createDirectoryTree = function(dirPath) {console.log("Creating directory tree for: "+dirPath);TSCORE.showLoadingAnimation();var event = document.createEvent('CustomEvent');@@ -291,7 +268,7 @@ define(function(require, exports, module) {document.documentElement.dispatchEvent(event);};- exports.checkNewVersion = function() {+ var checkNewVersion = function() {console.log("Checking for new version...");TSCORE.showLoadingAnimation();var event = document.createEvent('CustomEvent');@@ -300,5 +277,23 @@ define(function(require, exports, module) {}});document.documentElement.dispatchEvent(event);};++ exports.saveSettings = saveSettings;+ exports.loadSettings = loadSettings;++ exports.createDirectory = createDirectory;+ exports.renameFile = renameFile;+ exports.loadTextFile = loadTextFile;+ exports.saveTextFile = saveTextFile;+ exports.listDirectory = listDirectory;+ exports.deleteElement = deleteElement;+ exports.createDirectoryIndex = createDirectoryIndex;+ exports.createDirectoryTree = createDirectoryTree;+ exports.selectDirectory = selectDirectory;+ exports.openDirectory = openDirectory;+ exports.selectFile = selectFile;+ exports.openExtensionsDirectory = openExtensionsDirectory;+ exports.checkAccessFileURLAllowed = checkAccessFileURLAllowed;+ exports.checkNewVersion = checkNewVersion;});diff --git a/data/js/ioapi.node.js b/data/js/ioapi.node.jsindex f5769c2da..bd257519c 100644--- a/data/js/ioapi.node.js+++ b/data/js/ioapi.node.js@@ -36,7 +36,7 @@ define(function(require, exports, module) {//console.log('stats: ' + JSON.stringify(stats));index.push({"name": dirList[i],- "type": stats.isDirectory()?"directory":"file",+ "isFile": !stats.isDirectory(),"size": stats.size,"lmdt": stats.mtime,"path": path@@ -68,7 +68,7 @@ define(function(require, exports, module) {var tree = {};var dstats = fs.statSync(dirPath);tree["name"] = pathUtils.basename(dirPath);- tree["type"] = "directory";+ tree["isFile"] = false;tree["lmdt"] = dstats.mtime;tree["path"] = dirPath;tree["children"] = [];@@ -79,7 +79,7 @@ define(function(require, exports, module) {if (stats.isFile()) {tree["children"].push({"name": pathUtils.basename(path),- "type": "file",+ "isFile": true,"size": stats.size,"lmdt": stats.mtime,"path": path@@ -94,27 +94,27 @@ define(function(require, exports, module) {}}- exports.getFileSize = function(filePath) {+ var getFileSize = function(filePath) {console.log("Get filesize of: "+filePath);var stats = fs.statSync(filePath);return stats.size;//TSPOSTIO.createDirectoryIndex(directoryIndex);};- exports.getLMDT = function(filePath) {+ var getLMDT = function(filePath) {console.log("Get last modified date time of: "+filePath);var stats = fs.statSync(filePath);return stats.mtime;//TSPOSTIO.createDirectoryIndex(directoryIndex);};- exports.directoryExist = function(dirPath) {+ var directoryExist = function(dirPath) {console.log("Checks if a directory exist: "+dirPath);//TSPOSTIO.createDirectoryIndex(directoryIndex);};- exports.createDirectoryIndex = function(dirPath) {+ var createDirectoryIndex = function(dirPath) {console.log("Creating index for directory: "+dirPath);var directoryIndex = [];directoryIndex = scanDirectory(dirPath, directoryIndex);@@ -122,14 +122,14 @@ define(function(require, exports, module) {TSPOSTIO.createDirectoryIndex(directoryIndex);};- exports.createDirectoryTree = function(dirPath) {+ var createDirectoryTree = function(dirPath) {console.log("Creating directory index for: "+dirPath);var directoyTree = generateDirectoryTree(dirPath);//console.log(JSON.stringify(directoyTree));TSPOSTIO.createDirectoryTree(directoyTree);};- exports.createDirectory = function(dirPath) {+ var createDirectory = function(dirPath) {console.log("Creating directory: "+dirPath);fs.mkdir(dirPath, function(error) {if (error) {@@ -140,7 +140,7 @@ define(function(require, exports, module) {});};- exports.renameFile = function(filePath, newFilePath) {+ var renameFile = function(filePath, newFilePath) {console.log("Renaming file: "+filePath+" to "+newFilePath);if(filePath.toLowerCase() == newFilePath.toLowerCase()) {console.log("Initial and target filenames are the same...");@@ -159,7 +159,7 @@ define(function(require, exports, module) {});};- exports.loadTextFile = function(filePath) {+ var loadTextFile = function(filePath) {console.log("Loading file: "+filePath);fs.readFile(filePath, 'utf8', function(error, content) {if (error) {@@ -170,7 +170,7 @@ define(function(require, exports, module) {});};- exports.saveTextFile = function(filePath,content) {+ var saveTextFile = function(filePath,content) {console.log("Saving file: "+filePath);// TODO check if fileExist by saving needed/* if(plugin.fileExists(filePath)) {@@ -185,7 +185,7 @@ define(function(require, exports, module) {});};- exports.listDirectory = function(dirPath) {+ var listDirectory = function(dirPath) {console.log("Listing directory: "+dirPath);try {fs.readdir(dirPath, function(error, dirList) {@@ -196,13 +196,12 @@ define(function(require, exports, module) {var anotatedDirList = [];for (var i=0; i < dirList.length; i++) {- var path = dirPath+getDirseparator()+dirList[i];var path = dirPath+getDirseparator()+dirList[i];var stats = fs.statSync(path);//console.log('stats: ' + JSON.stringify(stats));anotatedDirList.push({"name": dirList[i],- "type": stats.isDirectory()?"directory":"file",+ "isFile": !stats.isDirectory(),"size": stats.size,"lmdt": stats.mtime,"path": path@@ -215,35 +214,7 @@ define(function(require, exports, module) {}};- exports.getSubdirs = function(dirPath) {- console.log("Getting subdirs: "+dirPath);- try {- fs.readdir(dirPath, function(error, dirList) {- if (error) {- console.log("Directory listing failed "+error);- return;- }-- var anotatedDirList = [];- for (var i=0; i < dirList.length; i++) {- var path = dirPath+getDirseparator()+dirList[i];- var stats = fs.statSync(path);- if(stats.isDirectory()) {- anotatedDirList.push({- "title": dirList[i],- //"isFolder": true,- "key": path- });- }- }- TSPOSTIO.getSubdirs(anotatedDirList);- });- } catch(ex) {- console.error("Listing directory "+dirPath+" failed "+ex);- }- };-- exports.deleteElement = function(path) {+ var deleteElement = function(path) {console.log("Deleting: "+path);fs.unlink(path, function(error) {if (error) {@@ -254,11 +225,11 @@ define(function(require, exports, module) {});};- exports.checkAccessFileURLAllowed = function() {+ var checkAccessFileURLAllowed = function() {console.log("checkAccessFileURLAllowed function not relevant for node..");};- exports.checkNewVersion = function() {+ var checkNewVersion = function() {console.log("Checking for new version...");var cVer = TSCORE.Config.DefaultSettings["appVersion"]+"."+TSCORE.Config.DefaultSettings["appBuild"];$.ajax({@@ -274,7 +245,7 @@ define(function(require, exports, module) {;};- exports.selectDirectory = function() {+ var selectDirectory = function() {if(document.getElementById('folderDialog') == null) {$("#folderLocation").after('<input style="display:none;" id="folderDialog" type="file" nwdirectory />');}@@ -285,11 +256,11 @@ define(function(require, exports, module) {chooser.trigger('click');};- exports.openDirectory = function(dirPath) {+ var openDirectory = function(dirPath) {gui.Shell.openItem(dirPath);};- exports.selectFile = function() {+ var selectFile = function() {if(document.getElementById('fileDialog') == null) {$("#folderLocation").after('<input style="display:none;" id="fileDialog" type="file" />');}@@ -300,11 +271,26 @@ define(function(require, exports, module) {chooser.trigger('click');};- exports.openExtensionsDirectory = function() {+ var openExtensionsDirectory = function() {// TODO implement openExtensionsDirectory on node//gui.Shell.openItem(extPath);console.log("Open extensions directory functionality not implemented on chrome yet!");TSCORE.showAlertDialog("Open extensions directory functionality not implemented on chrome yet!");};++ exports.createDirectory = createDirectory;+ exports.renameFile = renameFile;+ exports.loadTextFile = loadTextFile;+ exports.saveTextFile = saveTextFile;+ exports.listDirectory = listDirectory;+ exports.deleteElement = deleteElement;+ exports.createDirectoryIndex = createDirectoryIndex;+ exports.createDirectoryTree = createDirectoryTree;+ exports.selectDirectory = selectDirectory;+ exports.openDirectory = openDirectory;+ exports.selectFile = selectFile;+ exports.openExtensionsDirectory = openExtensionsDirectory;+ exports.checkAccessFileURLAllowed = checkAccessFileURLAllowed;+ exports.checkNewVersion = checkNewVersion;});diff --git a/data/js/perspective.manager.js b/data/js/perspective.manager.jsindex 9fa011b07..d4c059e58 100644--- a/data/js/perspective.manager.js+++ b/data/js/perspective.manager.js@@ -58,7 +58,7 @@ var initViews = function () {}});}-}+};var initViewSwitcher = function() {var extensions = TSCORE.Config.getPerspectives();@@ -69,7 +69,7 @@ var initViewSwitcher = function() {if(value.ID == extensions[i].id) {curPers = value;}- })+ });$("#viewSwitcher").append($("<button>", {"viewid": curPers.ID,@@ -78,13 +78,13 @@ var initViewSwitcher = function() {"text": " "+curPers.Title}).prepend($("<i>", {"class": curPers.Icon- })))+ })));// Adding event listener & icon to the radio button$( "#"+curPers.ID+"Button" ).click(function() {changeView($(this).attr("viewid"));- })- }+ });+ };if(perspectives.length > 0) {TSCORE.currentView = perspectives[0].ID;@@ -92,7 +92,7 @@ var initViewSwitcher = function() {$("#viewSwitcher").find("button").first().addClass("active");changeView($("#viewSwitcher").find("button").first().attr("viewid"));}-}+};var getNextFile = function (filePath) {for (var i=0; i < perspectives.length; i++) {@@ -104,7 +104,7 @@ var getNextFile = function (filePath) {}}}-}+};var getPrevFile = function (filePath) {for (var i=0; i < perspectives.length; i++) {@@ -116,7 +116,7 @@ var getPrevFile = function (filePath) {}}}-}+};var updateTreeData = function (treeData) {for (var i=0; i < perspectives.length; i++) {@@ -126,7 +126,7 @@ var updateTreeData = function (treeData) {console.log("Error while executing 'updateTreeData' on "+perspectives[i].ID+" "+e);}}-}+};var updateFileBrowserData = function(dirList) {console.log("Updating the file browser data...");@@ -140,7 +140,7 @@ var updateFileBrowserData = function(dirList) {var path = undefined;var filename = undefined;for (var i=0; i < dirList.length; i++) {- if (dirList[i].type == "file"){+ if (dirList[i].isFile){// Considering Unix HiddenEntries (. in the beginning of the filename)if (TSCORE.Config.getShowUnixHiddenEntries() ||(!TSCORE.Config.getShowUnixHiddenEntries() && (dirList[i].name.indexOf(".") != 0))) {@@ -148,7 +148,7 @@ var updateFileBrowserData = function(dirList) {path = dirList[i].path;tags = TSCORE.TagUtils.extractTags(path);title = TSCORE.TagUtils.extractTitle(path);- ext = TSCORE.TagUtils.extractFileExtension(path)+ ext = TSCORE.TagUtils.extractFileExtension(path);fileSize = dirList[i].size;fileLMDT = dirList[i].lmdt;@@ -160,13 +160,13 @@ var updateFileBrowserData = function(dirList) {}}changeView(TSCORE.currentView);-}+};var refreshFileListContainer = function() {// TODO consider search viewTSCORE.startTime = new Date().getTime();TSCORE.IO.listDirectory(TSCORE.currentPath);-}+};var changeView = function (viewType) {console.log("Change to "+viewType+" view.");@@ -203,7 +203,7 @@ var changeView = function (viewType) {TSCORE.PerspectiveManager.clearSelectedFiles();TSCORE.hideLoadingAnimation();-}+};var clearSelectedFiles = function () {// Clear selected files@@ -212,10 +212,10 @@ var clearSelectedFiles = function () {try {perspectives[i].clearSelectedFiles();} catch(e) {- console.log("Error while executing 'clearSelectedFiles' on "+perspectives[i].ID)+ console.log("Error while executing 'clearSelectedFiles' on "+perspectives[i].ID);}}-}+};var setFileFilter = function (filter) {for (var i=0; i < perspectives.length; i++) {@@ -224,12 +224,12 @@ var setFileFilter = function (filter) {perspectives[i].setFileFilter(filter);}} catch(e) {- console.log("Error while executing 'setFileFilter' on "+perspectives[i].ID)+ console.log("Error while executing 'setFileFilter' on "+perspectives[i].ID);}}-}+};-exports.initViews = initViews+exports.initViews = initViews;exports.getNextFile = getNextFile;exports.getPrevFile = getPrevFile;exports.updateTreeData = updateTreeData;diff --git a/data/js/postioapi.js b/data/js/postioapi.jsindex a59a2d9b5..137bf2140 100644--- a/data/js/postioapi.js+++ b/data/js/postioapi.js@@ -44,9 +44,6 @@ define(function(require, exports, module) {exports.listDirectory = function(anotatedDirList) {TSCORE.PerspectiveManager.updateFileBrowserData(anotatedDirList);- };-- exports.getSubdirs = function(anotatedDirList) {TSCORE.updateSubDirs(anotatedDirList);};diff --git a/data/js/settings.api.js b/data/js/settings.api.jsindex eb57d341b..7a3aa5e45 100644--- a/data/js/settings.api.js+++ b/data/js/settings.api.js@@ -6,7 +6,6 @@ define(function(require, exports, module) {console.log("Loading settings.api.js..");- var IOAPI = require("tsioapi");var TSCORE = require("tscore");exports.DefaultSettings = require("tssettingsdefault").defaultSettings;@@ -665,7 +664,7 @@ define(function(require, exports, module) {// Storing settings in firefox native preferencesif(isFirefox) {- IOAPI.saveSettings(JSON.stringify(exports.Settings));+ TSCORE.IO.saveSettings(JSON.stringify(exports.Settings));}console.log('Tagspace Settings Saved!');diff --git a/data/js/tagutils.js b/data/js/tagutils.jsindex 05f071190..8bdb60788 100644--- a/data/js/tagutils.js+++ b/data/js/tagutils.js@@ -6,7 +6,7 @@ define(function(require, exports, module) {console.log("Loading tagutils.js ...");- var IOAPI = require("tsioapi");+ var TSCORE = require("tscore");var BEGIN_TAG_CONTAINER = "[",END_TAG_CONTAINER = "]",@@ -269,7 +269,7 @@ define(function(require, exports, module) {var newFileName = generateFileName(fileName, extractedTags);- IOAPI.renameFile(filePath, containingDirectoryPath+DIR_SEPARATOR+newFileName);+ TSCORE.IO.renameFile(filePath, containingDirectoryPath+DIR_SEPARATOR+newFileName);}function addTag(filePathArray, tagArray) {@@ -315,7 +315,7 @@ define(function(require, exports, module) {var newFileName = generateFileName(fileName, extractedTags);- IOAPI.renameFile(filePath, containingDirectoryPath+DIR_SEPARATOR+newFileName);+ TSCORE.IO.renameFile(filePath, containingDirectoryPath+DIR_SEPARATOR+newFileName);}@@ -338,7 +338,7 @@ define(function(require, exports, module) {var newFileName = generateFileName(fileName, extractedTags);- IOAPI.renameFile(filePath, containingDirectoryPath+DIR_SEPARATOR+newFileName);+ TSCORE.IO.renameFile(filePath, containingDirectoryPath+DIR_SEPARATOR+newFileName);}@@ -357,7 +357,7 @@ define(function(require, exports, module) {// TODO generalize generateFileName to support fileTitle & fileExtensionvar newFileName = generateFileName(newTitle, extractedTags);- IOAPI.renameFile(filePath, containingDirectoryPath+DIR_SEPARATOR+newFileName+fileExt);+ TSCORE.IO.renameFile(filePath, containingDirectoryPath+DIR_SEPARATOR+newFileName+fileExt);return true;}@@ -381,7 +381,7 @@ define(function(require, exports, module) {var newFileName = generateFileName(fileName, newTags);- IOAPI.renameFile(filePath, containingDirectoryPath+DIR_SEPARATOR+newFileName);+ TSCORE.IO.renameFile(filePath, containingDirectoryPath+DIR_SEPARATOR+newFileName);}// Public API definitiondiff --git a/data/loader.js b/data/loader.jsindex 0c13a5222..82773e86e 100644--- a/data/loader.js+++ b/data/loader.js@@ -99,6 +99,7 @@ requirejs.config({tscoreui: 'js/core.ui',tspostioapi: 'js/postioapi',tsioapi: IO_JS,+ tsioapidropbox: 'js/ioapi.dropbox',},shim: {'underscore': { exports: '_' },diff --git a/lib/ioutils.js b/lib/ioutils.jsindex f9a8ff7f7..2da6f3810 100644--- a/lib/ioutils.js+++ b/lib/ioutils.js@@ -107,9 +107,8 @@ function directoryTree(dirPath) {var dirList = filesIO.list(dirPath);var directory = Cc['@mozilla.org/file/local;1'].createInstance(Ci.nsIFile);directory.initWithPath(dirPath);- //console.log("Directory "+JSON.stringify(directory));tree["name"] = directory.leafName;- tree["type"] = "directory";+ tree["isFile"] = false;tree["lmdt"] = directory.lastModifiedTime;tree["path"] = dirPath;tree["children"] = [];@@ -121,11 +120,11 @@ function directoryTree(dirPath) {file.initWithPath(path);if (file.isFile()) {tree["children"].push({- "name": file.leafName,- "type": "file",- "size": file.fileSize,- "lmdt": file.lastModifiedTime,- "path": path+ "name": file.leafName,+ "isFile": true,+ "size": file.fileSize,+ "lmdt": file.lastModifiedTime,+ "path": path});} else {tree["children"].push( directoryTree(path) );@@ -150,11 +149,11 @@ function scanDirectory(dirPath, index) {var file = Cc['@mozilla.org/file/local;1'].createInstance(Ci.nsIFile);file.initWithPath(path);index.push({- "name": file.leafName,- "type": file.isFile()?"file":"directory",- "size": file.fileSize,- "lmdt": file.lastModifiedTime,- "path": path+ "name": file.leafName,+ "isFile": file.isFile(),+ "size": file.fileSize,+ "lmdt": file.lastModifiedTime,+ "path": path});if (!file.isFile()) {scanDirectory(path, index);@@ -169,7 +168,6 @@ function scanDirectory(dirPath, index) {}}-// TODO use scanDirectoryexports.listDirectory = function listDirectory(dirPath, worker) {console.log("Listing directory: "+dirPath);try {@@ -181,11 +179,11 @@ exports.listDirectory = function listDirectory(dirPath, worker) {var file = Cc['@mozilla.org/file/local;1'].createInstance(Ci.nsIFile);file.initWithPath(filesIO.join(dirPath,dirList[i]));anotatedDirList.push({- "name": file.leafName,- "type": file.isFile()?"file":"directory",- "size": file.fileSize,- "lmdt": file.lastModifiedTime,- "path": path+ "name": file.leafName,+ "isFile": file.isFile(),+ "size": file.fileSize,+ "lmdt": file.lastModifiedTime,+ "path": path});} catch(ex) {console.error("Filepath has a invalid encoding "+ex);@@ -243,44 +241,6 @@ exports.loadTextFile = function loadTextFile(filePath, worker) {}};-exports.getSubdirs = function getSubdirs(dirPath, worker) {- console.log("Getting subdirectories: "+dirPath);- try {- var dirList = filesIO.list(dirPath);- var anotatedDirList = [];- for (var i=0; i < dirList.length; i++) {- try {- var fullPath = filesIO.join(dirPath,dirList[i]);- var file = Cc['@mozilla.org/file/local;1'].createInstance(Ci.nsIFile);- file.initWithPath(fullPath);- console.log("File: "+file);- if(file.isFile() == false) {- anotatedDirList.push({- "title": file.leafName,- "isFolder": true,- "isLazy": true,- "key": fullPath- });- }- } catch(ex) {- console.error("Filepath has a invalid encoding "+ex);- }- }- worker.postMessage({- "command": "getSubdirs",- "success": true,- "content": anotatedDirList- });- console.log("Getting subdirectories successful!");- } catch(ex) {- console.error("Getting subdirectories failed "+ex);- worker.postMessage({- "command": "getSubdirs",- "success": false- });- }-};-exports.deleteElement = function deleteElement(path, worker) {console.log("Deleting: "+path);try {diff --git a/lib/main.js b/lib/main.jsindex 65605df2e..ba405b8b5 100644--- a/lib/main.js+++ b/lib/main.js@@ -196,9 +196,6 @@ function handleMessage(msg, worker) {case "listDirectory":ioutils.listDirectory(msg.detail.path,worker);break;- case "getSubdirs":- ioutils.getSubdirs(msg.detail.path,worker);- break;case "delete":ioutils.deleteElement(msg.detail.path,worker);break;