TagSpaces is an offline, open source, document manager with tagging support
jshinting
Ilianc82f6402613d
diff --git a/data/mozilla/ioutils.js b/data/mozilla/ioutils.jsindex a72121aa2..4b6348c8b 100644--- a/data/mozilla/ioutils.js+++ b/data/mozilla/ioutils.js@@ -1,7 +1,9 @@/* Copyright (c) 2012-2014 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. */-/* jshint moz: true, */+/* jshint moz: true, strict: false */+/* global exports */+const {components, Cc, Ci, Cr, Cu} = require("chrome");var filesIO = require("sdk/io/file"); // filevar runtime = require("sdk/system/runtime"); // runtimediff --git a/data/mozilla/main.js b/data/mozilla/main.jsindex bcfd75ea1..5f5a23fe5 100644--- a/data/mozilla/main.js+++ b/data/mozilla/main.js@@ -1,8 +1,10 @@-/* Copyright (c) 2012-2013 The Tagspaces Authors. All rights reserved.+/* Copyright (c) 2012-2014 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. */+/* jshint moz: true, strict: false */+/* global exports */-// the value of this var is replaced to "true" by the build script+// the value of this var is replaced to "true" by the build scriptvar PRODUCTION = "@@PRODUCTION";var VERSION = "@@VERSION";@@ -11,7 +13,6 @@ if (PRODUCTION == "true") {console = console || {};console.log = function(){};console.error = function(){};- console.log = function(){};}// Import the needed APIs@@ -31,8 +32,8 @@ var toolbarButton;var toolbarButtonDestroyed = false;exports.main = function(options, callbacks) {- console.log("Load reason: "+options.loadReason);-+ console.log("Load reason: "+options.loadReason);+var mainUIMod = require("sdk/page-mod"); // page-modmainUIMod.PageMod({include: data.url("index.html"),@@ -52,63 +53,63 @@ exports.main = function(options, callbacks) {onAttach: function onAttach(worker) {console.log("Attaching worker on tab with title: "+worker.tab.title);- workers.push(worker);- worker.on('message', function(data) {- handleMessage(data, this);+ workers.push(worker);+ worker.on('message', function(data) {+ handleMessage(data, this);});worker.on('detach', function () {- detachWorker(this);+ detachWorker(this);});}});// A basic click-able image widget.widgets.Widget({- id: "TagSpaces",- label: "TagSpaces",- contentURL: data.url("assets/icon16.png"),- onClick: function() {- // Opens the main ui in a new pinned tab- require("sdk/tabs").open({ // tabs- url: data.url("index.html"),- // isPinned: true,- });- },+ id: "TagSpaces",+ label: "TagSpaces",+ contentURL: data.url("assets/icon16.png"),+ onClick: function() {+ // Opens the main ui in a new pinned tab+ require("sdk/tabs").open({ // tabs+ url: data.url("index.html")+ // isPinned: true,+ });+ },onMouseover: function() {- this.contentURL = data.url("assets/icon16color.png");+ this.contentURL = data.url("assets/icon16color.png");},onMouseout: function() {- this.contentURL = data.url("assets/icon16.png");+ this.contentURL = data.url("assets/icon16.png");}});// Adding menuitem to the tools menuvar menuitem = require("menuitems").Menuitem({- id: "TagSpacesMenuItem",- menuid: "menu_ToolsPopup",- label: "TagSpaces",- image: data.url("assets/icon16.png"),- onCommand: function() {- // Opens the main ui in a new pinned tab- require("sdk/tabs").open({ // tabs- url: data.url("index.html"),- // isPinned: true,- });- },- insertbefore: "menu_pageInfo"+ id: "TagSpacesMenuItem",+ menuid: "menu_ToolsPopup",+ label: "TagSpaces",+ image: data.url("assets/icon16.png"),+ onCommand: function () {+ // Opens the main ui in a new pinned tab+ require("sdk/tabs").open({ // tabs+ url: data.url("index.html")+ //isPinned: true,+ });+ },+ insertbefore: "menu_pageInfo"});// Adding toolbar buttoninitToobarButton();installToolbarButton();- //if (options.loadReason == "install" || options.loadReason == "enable") {}-+ //if (options.loadReason == "install" || options.loadReason == "enable") {}+};function installToolbarButton () {toolbarButton.moveTo({- toolbarID: "nav-bar",- forceMove: false+ toolbarID: "nav-bar",+ forceMove: false});}@@ -121,7 +122,7 @@ function initToobarButton() {require("sdk/tabs").open({ // tabsurl: data.url("index.html"),//isPinned: true,- isPrivate : true,+ isPrivate : true});}});@@ -147,19 +148,19 @@ var checkForNewVersion = request.Request({function checkNewVersion(worker) {try {- var content = undefined;+ var content;var versionReq = request.Request({- url: "http://tagspaces.org/releases/version.json?fVer="+VERSION,- onComplete: function (response) {- console.log("Result: " + response.text + " " + response.status);- response.text;- worker.postMessage({+ url: "http://tagspaces.org/releases/version.json?fVer=" + VERSION,+ onComplete: function (response) {+ console.log("Result: " + response.text + " " + response.status);+ response.text;+ worker.postMessage({"command": "checkNewVersion","content": response.text,"success": true- });- console.log("Loading settings successful!");- }+ });+ console.log("Loading settings successful!");+ }}).get();} catch(ex) {worker.postMessage({@@ -171,58 +172,58 @@ function checkNewVersion(worker) {}function handleMessage(msg, worker) {- console.log("Message in main.js: "+JSON.stringify(msg)+" from tab "+worker.tab.title);- //console.log("Thumbnail: "+worker.tab.getThumbnail());- switch (msg.detail.command) {- case "loadSettings":- settings.loadSettings(worker);- break;- case "checkNewVersion":- checkNewVersion(worker);- break;- case "saveSettings":- settings.saveSettings(msg.detail.content,worker);- break;- case "rename":- ioutils.rename(msg.detail.path,msg.detail.newPath,worker);- break;- case "saveTextFile":- ioutils.saveTextFile(msg.detail.path,msg.detail.content,worker);- break;- case "createDirectory":- ioutils.createDirectory(msg.detail.path,worker);- break;- case "loadTextFile":- ioutils.loadTextFile(msg.detail.path,worker);- break;- case "listDirectory":- ioutils.listDirectory(msg.detail.path,worker);- break;- case "delete":- ioutils.deleteElement(msg.detail.path,worker);- break;- case "selectFile":- ioutils.promptFileOpenPicker(worker);- break;- case "selectDirectory":- ioutils.promptDirectorySelector(worker);- break;- case "openDirectory":- ioutils.openDirectory(msg.detail.path,worker);- break;- case "openExtensionsDirectory":- ioutils.openExtensionsDirectory(worker);- break;- case "createDirectoryIndex":- ioutils.createDirectoryIndex(msg.detail.path,worker);- break;- case "createDirectoryTree":- ioutils.createDirectoryTree(msg.detail.path,worker);- break;- case "getFileProperties":- ioutils.getFileProperties(msg.detail.path,worker);- break;- default:- break;- }+ console.log("Message in main.js: " + JSON.stringify(msg) + " from tab " + worker.tab.title);+ //console.log("Thumbnail: "+worker.tab.getThumbnail());+ switch (msg.detail.command) {+ case "loadSettings":+ settings.loadSettings(worker);+ break;+ case "checkNewVersion":+ checkNewVersion(worker);+ break;+ case "saveSettings":+ settings.saveSettings(msg.detail.content, worker);+ break;+ case "rename":+ ioutils.rename(msg.detail.path, msg.detail.newPath, worker);+ break;+ case "saveTextFile":+ ioutils.saveTextFile(msg.detail.path, msg.detail.content, worker);+ break;+ case "createDirectory":+ ioutils.createDirectory(msg.detail.path, worker);+ break;+ case "loadTextFile":+ ioutils.loadTextFile(msg.detail.path, worker);+ break;+ case "listDirectory":+ ioutils.listDirectory(msg.detail.path, worker);+ break;+ case "delete":+ ioutils.deleteElement(msg.detail.path, worker);+ break;+ case "selectFile":+ ioutils.promptFileOpenPicker(worker);+ break;+ case "selectDirectory":+ ioutils.promptDirectorySelector(worker);+ break;+ case "openDirectory":+ ioutils.openDirectory(msg.detail.path, worker);+ break;+ case "openExtensionsDirectory":+ ioutils.openExtensionsDirectory(worker);+ break;+ case "createDirectoryIndex":+ ioutils.createDirectoryIndex(msg.detail.path, worker);+ break;+ case "createDirectoryTree":+ ioutils.createDirectoryTree(msg.detail.path, worker);+ break;+ case "getFileProperties":+ ioutils.getFileProperties(msg.detail.path, worker);+ break;+ default:+ break;+ }}\ No newline at end of filediff --git a/data/mozilla/mozilla.api.js b/data/mozilla/mozilla.api.jsindex 7be8789b7..695975ed7 100644--- a/data/mozilla/mozilla.api.js+++ b/data/mozilla/mozilla.api.js@@ -1,6 +1,8 @@/* Copyright (c) 2012-2014 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. */+/* global define */+define(function(require, exports, module) {"use strict";@@ -41,28 +43,28 @@ define(function(require, exports, module) {if(message.success){TSPOSTIO.renameFile(message.content[0],message.content[1]);} else {- TSCORE.updateLogger("Rename failed");+ console.error("Rename failed");}break;case "saveTextFile":if(message.success){TSPOSTIO.saveTextFile(message.content);} else {- TSCORE.updateLogger("Save failed");+ console.error("Save failed");}break;case "createDirectory":if(message.success){TSPOSTIO.createDirectory(message.content);} else {- TSCORE.updateLogger("Create dir failed");+ console.error("Create dir failed");}break;case "loadTextFile":if(message.success){TSPOSTIO.loadTextFile(message.content);} else {- TSCORE.updateLogger("File loading failed");+ console.error("File loading failed");}break;case "listDirectory":@@ -76,7 +78,7 @@ define(function(require, exports, module) {if(message.success){TSPOSTIO.createDirectoryIndex(message.content);} else {- TSCORE.updateLogger("Indexing directory failed");+ console.error("Indexing directory failed");}break;case "createDirectoryTree":@@ -84,35 +86,35 @@ define(function(require, exports, module) {console.log("Directory tree: "+JSON.stringify(message.content));TSPOSTIO.createDirectoryTree(message.content);} else {- TSCORE.updateLogger("Indexing directory failed");+ console.error("Indexing directory failed");}break;case "delete":if(message.success){TSPOSTIO.deleteElement(message.content);} else {- TSCORE.updateLogger("Delete failed");+ console.error("Delete failed");}break;case "selectDirectory":if(message.success){TSPOSTIO.selectDirectory(message.content);} else {- TSCORE.updateLogger("Selecting directory failed.");+ console.error("Selecting directory failed.");}break;case "checkNewVersion":if(message.success){TSPOSTIO.checkNewVersion(message.content);} else {- TSCORE.updateLogger("Checking for new version failed.");+ console.error("Checking for new version failed.");}break;case "getFileProperties":if(message.success){TSPOSTIO.getFileProperties(message.content);} else {- TSCORE.updateLogger("Getting file properties failed.");+ console.error("Getting file properties failed.");}break;default:@@ -294,9 +296,9 @@ define(function(require, exports, module) {};var openFile = function(filePath) {- // TODO implement openFile- console.log("Open file functionality not implemented in firefox yet!");- TSCORE.showAlertDialog("Open files natively is not implemented on chrome yet!");+ // TODO implement openFile for firefox+ console.log("Open file functionality not implemented in Firefox yet!");+ TSCORE.showAlertDialog($.i18n.t("ns.dialogs:openFileNativelyAlert"));};exports.saveSettings = saveSettings;diff --git a/data/mozilla/settings.js b/data/mozilla/settings.jsindex 409fdcacd..1f28cbd3f 100644--- a/data/mozilla/settings.js+++ b/data/mozilla/settings.js@@ -1,6 +1,8 @@/* Copyright (c) 2012-2014 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. */+/* jshint moz: true, strict: false */+/* global exports */const prefs = require('sdk/preferences/service'); // preferences-service