TagSpaces is an offline, open source, document manager with tagging support
handling opening of files on startup
uggrockedc122ea35bb
diff --git a/data/chromium/chrome.api.js b/data/chromium/chrome.api.jsindex 03b6d2ed9..72994ade8 100644--- a/data/chromium/chrome.api.js+++ b/data/chromium/chrome.api.js@@ -29,18 +29,6 @@ define(function(require, exports, module) {var dataDir = '",1,"';- function getURLParameter(variable) {- var query = window.location.search.substring(1);- var vars = query.split("&");- for (var i = 0; i < vars.length; i++) {- var pair = vars[i].split("=");- if (pair[0] == variable) {- return pair[1];- }- }- return (false);- }-function checkAccessFileURLAllowed() {chrome.extension.isAllowedFileSchemeAccess(function(isAllowedAccess) {if (!isAllowedAccess) {@@ -50,13 +38,12 @@ define(function(require, exports, module) {}function handleStartParameters() {- var openFile = getURLParameter("openFile");- if (openFile !== undefined && (openFile.length > 0)) { // && openFile.indexOf("file://") === 0+ var filePath = TSCORE.Utils.getURLParameter("open");+ filePath = decodeURIComponent(filePath);+ if (filePath && (filePath.length > 0)) {console.log("Opening file in browser: " + openFile);- openFile = openFile.split("file://")[1];- //var dirPath = TSCORE.TagUtils.extractContainingDirectoryPath(filePath);- //TSCORE.IO.listDirectory(dirPath);- TSCORE.FileOpener.openFileOnStartup(openFile);+ filePath = filePath.split("file://")[1];+ TSCORE.FileOpener.openFileOnStartup(filePath);}}diff --git a/data/js/fileopener.js b/data/js/fileopener.jsindex 9a1f6171c..79ae28329 100644--- a/data/js/fileopener.js+++ b/data/js/fileopener.js@@ -197,10 +197,18 @@ define(function(require, exports, module) {function openFileOnStartup(filePath) {TSCORE.Config.setLastOpenedLocation(undefined);+// quick and dirty solution, should use flag laterTSCORE.toggleFullWidth();TSCORE.FileOpener.openFile(filePath);- TSCORE.openLocation(TSCORE.TagUtils.extractContainingDirectoryPath(filePath));++ /*var parentFolderPath = TSCORE.TagUtils.extractContainingDirectoryPath(filePath);+ TSCORE.IO.listDirectoryPromise(parentFolderPath).then(function(entries) {+ TSPOSTIO.listDirectory(entries);+ }).catch(function(err) {+ TSPOSTIO.errorOpeningPath();+ });*/+}function openFile(filePath, editMode) {@@ -226,7 +234,7 @@ define(function(require, exports, module) {_openedFilePath = filePath;//$("#selectedFilePath").val(_openedFilePath.replace("\\\\","\\"));if (isWeb) {- window.history.pushState("", "TagSpaces", "/index.html?p=" + encodeURIComponent(filePath));+ window.history.pushState("", "TagSpaces", "/index.html?open=" + encodeURIComponent(filePath));console.log("Link to file for sharing: " + window.location.href);var downloadLink;if (location.port === '') {diff --git a/data/js/utils.js b/data/js/utils.jsindex 5c2a563d4..89cecbfb6 100644--- a/data/js/utils.js+++ b/data/js/utils.js@@ -78,6 +78,17 @@ define(function(require, exports, module) {return (ext === fileURL) ? "" : ext;}+ function getURLParameter(variable) {+ var query = window.location.search.substring(1);+ var vars = query.split("&");+ for (var i = 0; i < vars.length; i++) {+ var pair = vars[i].split("=");+ if (pair[0] == variable) {+ return pair[1];+ }+ }+ return (false);+ }exports.arrayBufferToDataURL = arrayBufferToDataURL;exports.base64ToArrayBuffer = base64ToArrayBuffer;@@ -88,5 +99,6 @@ define(function(require, exports, module) {exports.dirName = dirName;exports.getFileExt = getFileExt;exports.arrayBufferToBuffer = arrayBufferToBuffer;+ exports.getURLParameter = getURLParameter;});