TagSpaces is an offline, open source, document manager with tagging support
jshinting
Ilian9c9e501dc26d
diff --git a/data/node-webkit/node-webkit.api.js b/data/node-webkit/node-webkit.api.jsindex 3d3ed7538..c6255e5cd 100644--- a/data/node-webkit/node-webkit.api.js+++ b/data/node-webkit/node-webkit.api.js@@ -1,6 +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. */++/* global define, fs, process, gui */+/* undef: true, unused: true */+define(function(require, exports, module) {"use strict";@@ -20,7 +24,7 @@ define(function(require, exports, module) {function scanDirectory(dirPath, index) {try {var dirList = fs.readdirSync(dirPath);- var path, stats = undefined;+ var path, stats;for (var i=0; i < dirList.length; i++) {path = dirPath+TSCORE.dirSeparator+dirList[i];stats = fs.statSync(path);@@ -46,17 +50,17 @@ define(function(require, exports, module) {try {var tree = {};var dstats = fs.statSync(dirPath);- tree["name"] = pathUtils.basename(dirPath);- tree["isFile"] = false;- tree["lmdt"] = dstats.mtime;- tree["path"] = dirPath;- tree["children"] = [];+ tree.name = pathUtils.basename(dirPath);+ tree.isFile = false;+ tree.lmdt = dstats.mtime;+ tree.path = dirPath;+ tree.children = [];var dirList = fs.readdirSync(dirPath);for (var i=0; i < dirList.length; i++) {var path = dirPath+TSCORE.dirSeparator+dirList[i];var stats = fs.statSync(path);if (stats.isFile()) {- tree["children"].push({+ tree.children.push({"name": pathUtils.basename(path),"isFile": true,"size": stats.size,@@ -64,7 +68,7 @@ define(function(require, exports, module) {"path": path});} else {- tree["children"].push( generateDirectoryTree(path) );+ tree.children.push( generateDirectoryTree(path) );}}return tree;@@ -114,7 +118,7 @@ define(function(require, exports, module) {console.log("Renaming file: "+filePath+" to "+newFilePath);TSCORE.showLoadingAnimation();- if(filePath.toLowerCase() == newFilePath.toLowerCase()) {+ if(filePath.toLowerCase() === newFilePath.toLowerCase()) {console.log("Initial and target filenames are the same...");return false;}@@ -136,17 +140,16 @@ define(function(require, exports, module) {TSCORE.showLoadingAnimation();if(isPreview) {- var stream = fs.createReadStream(filePath, {start: 0, end: 10000})-- stream.on('error', function(err){- console.log("Loading file "+filePath+" failed "+error);+ var stream = fs.createReadStream(filePath, {start: 0, end: 10000});+ stream.on('error', function(err){+ console.log("Loading file "+filePath+" failed "+err);return;- });+ });- stream.on('data', function(content) {- console.log("Stream: "+content);- TSPOSTIO.loadTextFile(content);- });+ stream.on('data', function(content) {+ console.log("Stream: "+content);+ TSPOSTIO.loadTextFile(content);+ });} else {fs.readFile(filePath, 'utf8', function(error, content) {@@ -155,7 +158,7 @@ define(function(require, exports, module) {return;}TSPOSTIO.loadTextFile(content);- });+ });}};@@ -164,9 +167,9 @@ define(function(require, exports, module) {TSCORE.showLoadingAnimation();var buf = fs.readFileSync(filePath);- exif.parseTags(new BufferStream(buf, 24, 23960), function(ifdSection, tagType, value, format) {- console.log("EXIF: "+ifdSection+" "+tagType+" "+value+" "+format);- });+ exif.parseTags(new BufferStream(buf, 24, 23960), function(ifdSection, tagType, value, format) {+ console.log("EXIF: "+ifdSection+" "+tagType+" "+value+" "+format);+ });}; */var saveTextFile = function(filePath,content,overWrite) {@@ -186,8 +189,8 @@ define(function(require, exports, module) {// Handling the UTF8 support for text filesvar UTF8_BOM = "\ufeff";- if(content.indexOf(UTF8_BOM) == 0) {- // already has a UTF8 bom+ if(content.indexOf(UTF8_BOM) === 0) {+ console.log("Content beging with a UTF8 bom");} else {content = UTF8_BOM+content;}@@ -202,38 +205,38 @@ define(function(require, exports, module) {TSPOSTIO.saveTextFile(filePath, isNewFile);});};-- var listDirectory = function(dirPath) {- console.log("Listing directory: "+dirPath);- TSCORE.showLoadingAnimation();-- try {- fs.readdir(dirPath, function(error, dirList) {- if (error) {- TSPOSTIO.errorOpeningPath();- console.log("Listing directory: "+dirPath+" failed "+error);- return;- }-- var anotatedDirList = [];- for (var i=0; i < dirList.length; i++) {- var path = dirPath+TSCORE.dirSeparator+dirList[i];- var stats = fs.statSync(path);- //console.log('stats: ' + JSON.stringify(stats));- anotatedDirList.push({- "name": dirList[i],- "isFile": !stats.isDirectory(),- "size": stats.size,- "lmdt": stats.mtime,- "path": path- });- }- TSPOSTIO.listDirectory(anotatedDirList);- });- } catch(ex) {- TSPOSTIO.errorOpeningPath();- console.error("Listing directory "+dirPath+" failed "+ex);- }++ var listDirectory = function (dirPath) {+ console.log("Listing directory: " + dirPath);+ TSCORE.showLoadingAnimation();++ try {+ fs.readdir(dirPath, function (error, dirList) {+ if (error) {+ TSPOSTIO.errorOpeningPath();+ console.log("Listing directory: " + dirPath + " failed " + error);+ return;+ }++ var anotatedDirList = [];+ for (var i = 0; i < dirList.length; i++) {+ var path = dirPath + TSCORE.dirSeparator + dirList[i];+ var stats = fs.statSync(path);+ //console.log('stats: ' + JSON.stringify(stats));+ anotatedDirList.push({+ "name": dirList[i],+ "isFile": !stats.isDirectory(),+ "size": stats.size,+ "lmdt": stats.mtime,+ "path": path+ });+ }+ TSPOSTIO.listDirectory(anotatedDirList);+ });+ } catch (ex) {+ TSPOSTIO.errorOpeningPath();+ console.error("Listing directory " + dirPath + " failed " + ex);+ }};var deleteElement = function(path) {@@ -255,10 +258,10 @@ define(function(require, exports, module) {var checkNewVersion = function() {console.log("Checking for new version...");- var cVer = TSCORE.Config.DefaultSettings["appVersion"]+"."+TSCORE.Config.DefaultSettings["appBuild"];+ var cVer = TSCORE.Config.DefaultSettings.appVersion+"."+TSCORE.Config.DefaultSettings.appBuild;$.ajax({url: 'http://tagspaces.org/releases/version.json?nVer='+cVer,- type: 'GET',+ type: 'GET'}).done(function(data) {TSPOSTIO.checkNewVersion(data);@@ -270,11 +273,11 @@ define(function(require, exports, module) {};var selectDirectory = function() {- if(document.getElementById('folderDialog') == null) {+ if(document.getElementById('folderDialog') === null) {$("#folderLocation").after('<input style="display:none;" id="folderDialog" type="file" nwdirectory />');}var chooser = $('#folderDialog');- chooser.change(function(evt) {+ chooser.change(function() {TSPOSTIO.selectDirectory($(this).val());});chooser.trigger('click');@@ -291,11 +294,11 @@ define(function(require, exports, module) {};var selectFile = function() {- if(document.getElementById('fileDialog') == null) {+ if(document.getElementById('fileDialog') === null) {$("#folderLocation").after('<input style="display:none;" id="fileDialog" type="file" />');}var chooser = $('#fileDialog');- chooser.change(function(evt) {+ chooser.change(function() {console.log("File selected: "+$(this).val());});chooser.trigger('click');@@ -305,7 +308,7 @@ define(function(require, exports, module) {// 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!");+ TSCORE.showAlertDialog("Open extensions directory functionality not implemented yet!");};/* stats for file: