Skip to content

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

Refactoring for unifiing of requiejs modules

uggrock0b3543a8b39f
diff --git a/data/ext/editorHTML/extension.js b/data/ext/editorHTML/extension.js
index 70b435842..335dea9b2 100644
--- a/data/ext/editorHTML/extension.js
+++ b/data/ext/editorHTML/extension.js
@@ -5,114 +5,117 @@
define(function(require, exports, module) {
"use strict";
-exports.id = "editorHTML"; // ID should be equal to the directory name where the ext. is located
-exports.title = "HTML Editor";
-exports.type = "editor";
-exports.supportedFileTypes = [ "htm", "html" ];
-
-var htmlEditor = undefined;
-var extensionDirectory = TSSETTINGS.getExtensionPath()+"/"+exports.id;
-
-exports.init1 = function(filePath, containerElementID) {
- console.debug("Initalization HTML Text Editor...");
- require([
- extensionDirectory+'/wysihtml5/advanced.js',
- extensionDirectory+'/wysihtml5/wysihtml5-0.4.0pre.min.js',
- 'css!'+extensionDirectory+'/wysihtml5/stylesheet.css'
- ], function() {
- generateUI(containerElementID);
- htmlEditor = new wysihtml5.Editor("htmlEditor", {
- toolbar : "toolbar",
- parserRules : wysihtml5ParserRules
+ console.debug("Loading editorHTML");
+ exports.id = "editorHTML"; // ID should be equal to the directory name where the ext. is located
+ exports.title = "HTML Editor";
+ exports.type = "editor";
+ exports.supportedFileTypes = [ "htm", "html" ];
+
+ var TSCORE = require("tscore");
+
+ var htmlEditor = undefined;
+ var extensionDirectory = TSCORE.Config.getExtensionPath()+"/"+exports.id;
+
+ exports.init1 = function(filePath, containerElementID) {
+ console.debug("Initalization HTML Text Editor...");
+ require([
+ extensionDirectory+'/wysihtml5/advanced.js',
+ extensionDirectory+'/wysihtml5/wysihtml5-0.4.0pre.min.js',
+ 'css!'+extensionDirectory+'/wysihtml5/stylesheet.css'
+ ], function() {
+ generateUI(containerElementID);
+ htmlEditor = new wysihtml5.Editor("htmlEditor", {
+ toolbar : "toolbar",
+ parserRules : wysihtml5ParserRules
+ });
+ TSCORE.IO.loadTextFile(filePath);
});
- IOAPI.loadTextFile(filePath);
- });
-}
-
-exports.init2 = function(filePath, containerElementID) {
- console.debug("Initalization HTML Text Editor...");
- require([
- extensionDirectory+'/jwysiwyg/jquery.wysiwyg.js',
- 'css!'+extensionDirectory+'/jwysiwyg/jquery.wysiwyg.css'
- ], function() {
- $("#"+containerElementID).append('<textarea id="htmlEditor" style="border-width: 0px; width: 100%; height: 100%"></textarea>');
- $('#htmlEditor').wysiwyg();
- IOAPI.loadTextFile(filePath);
- });
-}
-
-exports.init = function(filePath, containerElementID) {
- console.debug("Initalization HTML Text Editor...");
- require([
- extensionDirectory+'/cleditor/jquery.cleditor.min.js',
- ], function() {
+ }
+
+ exports.init2 = function(filePath, containerElementID) {
+ console.debug("Initalization HTML Text Editor...");
+ require([
+ extensionDirectory+'/jwysiwyg/jquery.wysiwyg.js',
+ 'css!'+extensionDirectory+'/jwysiwyg/jquery.wysiwyg.css'
+ ], function() {
$("#"+containerElementID).append('<textarea id="htmlEditor" style="border-width: 0px; width: 100%; height: 100%"></textarea>');
- $("#"+containerElementID).append('<link rel="stylesheet" type="text/css" href="'+extensionDirectory+"/"+'cleditor'+"/"+'jquery.cleditor.css">');
- $.cleditor.defaultOptions.width = '100%';
- $.cleditor.defaultOptions.height = '100%';
- IOAPI.loadTextFile(filePath);
- });
-}
-
-exports.setFileType = function(fileType) {
- console.debug("setFileType not supported on this extension");
-}
-
-exports.viewerMode = function(isViewerMode) {
- // set readonly
-}
-
-exports.setContent = function(content) {
-// htmlEditor.setValue(content);
-// $("#htmlEditor").wysiwyg("setContent", content);
-
- $('#htmlEditor').val(content);
- $('#htmlEditor').cleditor();
- //$('#htmlEditor').html(content);
- //$('#htmlEditor').cleditor().updateFrame()
-}
-
-exports.getContent = function() {
-// return htmlEditor.getValue();
- return $('#htmlEditor').val();
-}
-
-var generateUI = function(containerElementID) {
- $("#"+containerElementID).append(''+
- '<div id="toolbar" >'+
- '<a data-wysihtml5-command="bold" title="CTRL+B">bold</a> |'+
- '<a data-wysihtml5-command="italic" title="CTRL+I">italic</a> |'+
- '<a data-wysihtml5-command="createLink">insert link</a> |'+
- '<a data-wysihtml5-command="insertImage">insert image</a> |'+
- '<a data-wysihtml5-command="formatBlock" data-wysihtml5-command-value="h1">h1</a> |'+
- '<a data-wysihtml5-command="formatBlock" data-wysihtml5-command-value="h2">h2</a> |'+
- '<a data-wysihtml5-command="insertUnorderedList">insertUnorderedList</a> |'+
- '<a data-wysihtml5-command="insertOrderedList">insertOrderedList</a> |'+
- '<a data-wysihtml5-command="foreColor" data-wysihtml5-command-value="red">red</a> |'+
- '<a data-wysihtml5-command="foreColor" data-wysihtml5-command-value="green">green</a> |'+
- '<a data-wysihtml5-command="foreColor" data-wysihtml5-command-value="blue">blue</a> |'+
- '<a data-wysihtml5-command="undo">undo</a> |'+
- '<a data-wysihtml5-command="redo">redo</a> |'+
- '<a data-wysihtml5-command="insertSpeech">speech</a>'+
- '<a data-wysihtml5-action="change_view">switch to html view</a>'+
- '<div data-wysihtml5-dialog="createLink" style="display: none;">'+
- '<label>Link:<input data-wysihtml5-dialog-field="href" value="http://"></label>'+
- '<a data-wysihtml5-dialog-action="save">OK</a>&nbsp;<a data-wysihtml5-dialog-action="cancel">Cancel</a>'+
- '</div> '+
- '<div data-wysihtml5-dialog="insertImage" style="display: none;">'+
- '<label>Image:<input data-wysihtml5-dialog-field="src" value="http://"></label>'+
- '<label>Align:'+
- '<select data-wysihtml5-dialog-field="className">'+
- '<option value="">default</option>'+
- '<option value="wysiwyg-float-left">left</option>'+
- '<option value="wysiwyg-float-right">right</option>'+
- '</select>'+
- '</label>'+
- '<a data-wysihtml5-dialog-action="save">OK</a>&nbsp;<a data-wysihtml5-dialog-action="cancel">Cancel</a>'+
- '</div>'+
- '</div>'+
- '');
- $("#"+containerElementID).append('<textarea id="wysihtml5Editor" style="border-width: 0px; width: 100%; height: 100%"></textarea>');
-}
+ $('#htmlEditor').wysiwyg();
+ TSCORE.IO.loadTextFile(filePath);
+ });
+ }
+
+ exports.init = function(filePath, containerElementID) {
+ console.debug("Initalization HTML Text Editor...");
+ require([
+ extensionDirectory+'/cleditor/jquery.cleditor.min.js',
+ ], function() {
+ $("#"+containerElementID).append('<textarea id="htmlEditor" style="border-width: 0px; width: 100%; height: 100%"></textarea>');
+ $("#"+containerElementID).append('<link rel="stylesheet" type="text/css" href="'+extensionDirectory+"/"+'cleditor'+"/"+'jquery.cleditor.css">');
+ $.cleditor.defaultOptions.width = '100%';
+ $.cleditor.defaultOptions.height = '100%';
+ TSCORE.IO.loadTextFile(filePath);
+ });
+ }
+
+ exports.setFileType = function(fileType) {
+ console.debug("setFileType not supported on this extension");
+ }
+
+ exports.viewerMode = function(isViewerMode) {
+ // set readonly
+ }
+
+ exports.setContent = function(content) {
+ // htmlEditor.setValue(content);
+ // $("#htmlEditor").wysiwyg("setContent", content);
+
+ $('#htmlEditor').val(content);
+ $('#htmlEditor').cleditor();
+ //$('#htmlEditor').html(content);
+ //$('#htmlEditor').cleditor().updateFrame()
+ }
+
+ exports.getContent = function() {
+ // return htmlEditor.getValue();
+ return $('#htmlEditor').val();
+ }
+
+ var generateUI = function(containerElementID) {
+ $("#"+containerElementID).append(''+
+ '<div id="toolbar" >'+
+ '<a data-wysihtml5-command="bold" title="CTRL+B">bold</a> |'+
+ '<a data-wysihtml5-command="italic" title="CTRL+I">italic</a> |'+
+ '<a data-wysihtml5-command="createLink">insert link</a> |'+
+ '<a data-wysihtml5-command="insertImage">insert image</a> |'+
+ '<a data-wysihtml5-command="formatBlock" data-wysihtml5-command-value="h1">h1</a> |'+
+ '<a data-wysihtml5-command="formatBlock" data-wysihtml5-command-value="h2">h2</a> |'+
+ '<a data-wysihtml5-command="insertUnorderedList">insertUnorderedList</a> |'+
+ '<a data-wysihtml5-command="insertOrderedList">insertOrderedList</a> |'+
+ '<a data-wysihtml5-command="foreColor" data-wysihtml5-command-value="red">red</a> |'+
+ '<a data-wysihtml5-command="foreColor" data-wysihtml5-command-value="green">green</a> |'+
+ '<a data-wysihtml5-command="foreColor" data-wysihtml5-command-value="blue">blue</a> |'+
+ '<a data-wysihtml5-command="undo">undo</a> |'+
+ '<a data-wysihtml5-command="redo">redo</a> |'+
+ '<a data-wysihtml5-command="insertSpeech">speech</a>'+
+ '<a data-wysihtml5-action="change_view">switch to html view</a>'+
+ '<div data-wysihtml5-dialog="createLink" style="display: none;">'+
+ '<label>Link:<input data-wysihtml5-dialog-field="href" value="http://"></label>'+
+ '<a data-wysihtml5-dialog-action="save">OK</a>&nbsp;<a data-wysihtml5-dialog-action="cancel">Cancel</a>'+
+ '</div> '+
+ '<div data-wysihtml5-dialog="insertImage" style="display: none;">'+
+ '<label>Image:<input data-wysihtml5-dialog-field="src" value="http://"></label>'+
+ '<label>Align:'+
+ '<select data-wysihtml5-dialog-field="className">'+
+ '<option value="">default</option>'+
+ '<option value="wysiwyg-float-left">left</option>'+
+ '<option value="wysiwyg-float-right">right</option>'+
+ '</select>'+
+ '</label>'+
+ '<a data-wysihtml5-dialog-action="save">OK</a>&nbsp;<a data-wysihtml5-dialog-action="cancel">Cancel</a>'+
+ '</div>'+
+ '</div>'+
+ '');
+ $("#"+containerElementID).append('<textarea id="wysihtml5Editor" style="border-width: 0px; width: 100%; height: 100%"></textarea>');
+ }
});
\ No newline at end of file
diff --git a/data/ext/editorText/extension.js b/data/ext/editorText/extension.js
index 347b633b6..fce984f01 100644
--- a/data/ext/editorText/extension.js
+++ b/data/ext/editorText/extension.js
@@ -5,120 +5,124 @@
define(function(require, exports, module) {
"use strict";
-exports.id = "editorText"; // ID should be equal to the directory name where the ext. is located
-exports.title = "Text Editor";
-exports.type = "editor";
-exports.supportedFileTypes = [
- "h", "c", "clj", "coffee", "coldfusion", "cpp",
- "cs", "css", "groovy", "haxe", "htm", "html",
- "java", "js", "jsm", "json", "latex", "less",
- "ly", "ily", "lua", "markdown", "md", "mdown",
- "mdwn", "mkd", "ml", "mli", "pl", "php",
- "powershell", "py", "rb", "scad", "scala",
- "scss", "sh", "sql", "svg", "textile", "txt", "xml"
- ] ;
+ console.debug("Loading editorText");
-var aceEditor = undefined;
-var extensionDirectory = TSSETTINGS.getExtensionPath()+"/"+exports.id;
-
-var generateUI = function(containerElementID) {
- $("#"+containerElementID).append('<div id="aceEditor" style="width: 100%; height: 100%"></div>');
-}
-
-/* require.config({
- baseUrl: 'file:///Z://TagSpaces//repository//data//ext//editorText'
-}); */
-
-exports.init = function(filePath, containerElementID) {
- console.debug("Initalization ACE Text Editor...");
- var fileExt = filePath.substring(filePath.lastIndexOf(".")+1,filePath.length).toLowerCase();
- generateUI(containerElementID);
-
- aceEditor = require('./ace/ace').edit('aceEditor');
-// aceEditor.setTheme("./ace/theme/monokai");
- IOAPI.loadTextFile(filePath);
- if (filetype[fileExt] != null) {
- require(["./ace/mode/" + filetype[fileExt]], function(acemode) {
- var syntaxMode = acemode.Mode;
- aceEditor.getSession().setMode(new syntaxMode());
- })
- }
-
-}
-
-exports.init2 = function(filePath, containerElementID) {
- console.debug("Initalization ACE Text Editor...");
- var fileExt = filePath.substring(filePath.lastIndexOf(".")+1,filePath.length).toLowerCase();
- generateUI(containerElementID);
+ exports.id = "editorText"; // ID should be equal to the directory name where the ext. is located
+ exports.title = "Text Editor";
+ exports.type = "editor";
+ exports.supportedFileTypes = [
+ "h", "c", "clj", "coffee", "coldfusion", "cpp",
+ "cs", "css", "groovy", "haxe", "htm", "html",
+ "java", "js", "jsm", "json", "latex", "less",
+ "ly", "ily", "lua", "markdown", "md", "mdown",
+ "mdwn", "mkd", "ml", "mli", "pl", "php",
+ "powershell", "py", "rb", "scad", "scala",
+ "scss", "sh", "sql", "svg", "textile", "txt", "xml"
+ ] ;
+
+ var TSCORE = require("tscore");
- require([extensionDirectory+'/ace/ace.js'], function(acemodule) { //"file:///Z:/TagSpaces/repository/data/ext/editorText/ace/ace.js" extensionDirectory+'/ace/ace.js'
- aceEditor = acemodule.edit('aceEditor');
+ var aceEditor = undefined;
+ var extensionDirectory = TSCORE.Config.getExtensionPath()+"/"+exports.id;
+
+ var generateUI = function(containerElementID) {
+ $("#"+containerElementID).append('<div id="aceEditor" style="width: 100%; height: 100%"></div>');
+ }
+
+ /* require.config({
+ baseUrl: 'file:///Z://TagSpaces//repository//data//ext//editorText'
+ }); */
+
+ exports.init = function(filePath, containerElementID) {
+ console.debug("Initalization ACE Text Editor...");
+ var fileExt = filePath.substring(filePath.lastIndexOf(".")+1,filePath.length).toLowerCase();
+ generateUI(containerElementID);
+
+ aceEditor = require('./ace/ace').edit('aceEditor');
// aceEditor.setTheme("./ace/theme/monokai");
- IOAPI.loadTextFile(filePath);
+ TSCORE.IO.loadTextFile(filePath);
if (filetype[fileExt] != null) {
require(["./ace/mode/" + filetype[fileExt]], function(acemode) {
var syntaxMode = acemode.Mode;
aceEditor.getSession().setMode(new syntaxMode());
})
}
- });
-}
-
-exports.viewerMode = function(isViewerMode) {
- aceEditor.setReadOnly(isViewerMode);
-}
-
-exports.setContent = function(content) {
- aceEditor.setValue(content);
- aceEditor.clearSelection();
-}
-
-exports.getContent = function() {
- return aceEditor.getValue();
-}
-
-var filetype = new Array();
-filetype["h"] = "c_cpp";
-filetype["c"] = "c_cpp";
-filetype["clj"] = "clojure";
-filetype["coffee"] = "coffee";
-filetype["coldfusion"] = "cfc";
-filetype["cpp"] = "c_cpp";
-filetype["cs"] = "csharp";
-filetype["css"] = "css";
-filetype["groovy"] = "groovy";
-filetype["haxe"] = "hx";
-filetype["htm"] = "html";
-filetype["html"] = "html";
-filetype["java"] = "java";
-filetype["js"] = "javascript";
-filetype["jsm"] = "javascript";
-filetype["json"] = "json";
-filetype["latex"] = "latex";
-filetype["less"] = "less";
-filetype["ly"] = "latex";
-filetype["ily"] = "latex";
-filetype["lua"] = "lua";
-filetype["markdown"] = "markdown";
-filetype["md"] = "markdown";
-filetype["mdown"] = "markdown";
-filetype["mdwn"] = "markdown";
-filetype["mkd"] = "markdown";
-filetype["ml"] = "ocaml";
-filetype["mli"] = "ocaml";
-filetype["pl"] = "perl";
-filetype["php"] = "php";
-filetype["powershell"] = "ps1";
-filetype["py"] = "python";
-filetype["rb"] = "ruby";
-filetype["scad"] = "scad";
-filetype["scala"] = "scala";
-filetype["scss"] = "scss";
-filetype["sh"] = "sh";
-filetype["sql"] = "sql";
-filetype["svg"] = "svg";
-filetype["textile"] = "textile";
-filetype["txt"] = "textile";
-filetype["xml"] = "xml";
+
+ }
+
+ exports.init2 = function(filePath, containerElementID) {
+ console.debug("Initalization ACE Text Editor...");
+ var fileExt = filePath.substring(filePath.lastIndexOf(".")+1,filePath.length).toLowerCase();
+ generateUI(containerElementID);
+
+ require([extensionDirectory+'/ace/ace.js'], function(acemodule) { //"file:///Z:/TagSpaces/repository/data/ext/editorText/ace/ace.js" extensionDirectory+'/ace/ace.js'
+ aceEditor = acemodule.edit('aceEditor');
+ // aceEditor.setTheme("./ace/theme/monokai");
+ TSCORE.IO.loadTextFile(filePath);
+ if (filetype[fileExt] != null) {
+ require(["./ace/mode/" + filetype[fileExt]], function(acemode) {
+ var syntaxMode = acemode.Mode;
+ aceEditor.getSession().setMode(new syntaxMode());
+ })
+ }
+ });
+ }
+
+ exports.viewerMode = function(isViewerMode) {
+ aceEditor.setReadOnly(isViewerMode);
+ }
+
+ exports.setContent = function(content) {
+ aceEditor.setValue(content);
+ aceEditor.clearSelection();
+ }
+
+ exports.getContent = function() {
+ return aceEditor.getValue();
+ }
+
+ var filetype = new Array();
+ filetype["h"] = "c_cpp";
+ filetype["c"] = "c_cpp";
+ filetype["clj"] = "clojure";
+ filetype["coffee"] = "coffee";
+ filetype["coldfusion"] = "cfc";
+ filetype["cpp"] = "c_cpp";
+ filetype["cs"] = "csharp";
+ filetype["css"] = "css";
+ filetype["groovy"] = "groovy";
+ filetype["haxe"] = "hx";
+ filetype["htm"] = "html";
+ filetype["html"] = "html";
+ filetype["java"] = "java";
+ filetype["js"] = "javascript";
+ filetype["jsm"] = "javascript";
+ filetype["json"] = "json";
+ filetype["latex"] = "latex";
+ filetype["less"] = "less";
+ filetype["ly"] = "latex";
+ filetype["ily"] = "latex";
+ filetype["lua"] = "lua";
+ filetype["markdown"] = "markdown";
+ filetype["md"] = "markdown";
+ filetype["mdown"] = "markdown";
+ filetype["mdwn"] = "markdown";
+ filetype["mkd"] = "markdown";
+ filetype["ml"] = "ocaml";
+ filetype["mli"] = "ocaml";
+ filetype["pl"] = "perl";
+ filetype["php"] = "php";
+ filetype["powershell"] = "ps1";
+ filetype["py"] = "python";
+ filetype["rb"] = "ruby";
+ filetype["scad"] = "scad";
+ filetype["scala"] = "scala";
+ filetype["scss"] = "scss";
+ filetype["sh"] = "sh";
+ filetype["sql"] = "sql";
+ filetype["svg"] = "svg";
+ filetype["textile"] = "textile";
+ filetype["txt"] = "textile";
+ filetype["xml"] = "xml";
});
\ No newline at end of file
diff --git a/data/ext/perspectiveBasic/extension.js b/data/ext/perspectiveBasic/extension.js
index e4d6159aa..545d7837b 100644
--- a/data/ext/perspectiveBasic/extension.js
+++ b/data/ext/perspectiveBasic/extension.js
@@ -2,395 +2,390 @@
* Use of this source code is governed by a AGPL3 license that
* can be found in the LICENSE file. */
-define([
- 'require',
- 'exports',
- 'module',
- 'datatables',
- 'jqueryuidraggable',
-// 'css!datatablescss'
-],function(require, exports, module) {
+define(function(require, exports, module) {
"use strict";
+
+ console.debug("Loading perspectiveBasic");
-exports.Title = "List"
-exports.ID = "perspectiveBasic"; // ID should be equal to the directory name where the ext. is located
-exports.Type = "view";
-exports.Icon = "ui-icon-note";
-
-console.debug("Loading view.basic.js");
-
-var TagsUI = require("tstagsui");
-
-var viewContainer = undefined;
-var viewToolbar = undefined;
-var viewFooter = undefined;
-
-var fileTable = undefined;
-var viewMode = "tags" // tags | files
-
-exports.init = function init() {
- console.debug("Initializing View "+exports.ID);
+ exports.Title = "List"
+ exports.ID = "perspectiveBasic"; // ID should be equal to the directory name where the ext. is located
+ exports.Type = "view";
+ exports.Icon = "ui-icon-note";
- viewContainer = $("#"+exports.ID+"Container");
- viewToolbar = $("#"+exports.ID+"Toolbar");
- viewFooter = $("#"+exports.ID+"Footer");
+ var TSCORE = require("tscore");
+ require('datatables');
+ // 'jqueryuidraggable',
- viewContainer.empty();
- viewToolbar.empty();
- viewFooter.empty();
+ var viewContainer = undefined;
+ var viewToolbar = undefined;
+ var viewFooter = undefined;
+
+ var fileTable = undefined;
+ var viewMode = "tags" // tags | files
+
+ exports.init = function init() {
+ console.debug("Initializing View "+exports.ID);
- viewToolbar.append($("<button>", {
- text: "New",
- disabled: true,
- title: "Create new file",
- id: exports.ID+"CreateFileButton",
- }));
-
- viewToolbar.append($("<span>", {
- id: exports.ID+"ModeSwitcher",
- }));
-
- var modeSwitcher = $("#"+exports.ID+"ModeSwitcher");
-
- modeSwitcher.append($("<input>", {
- type: "radio",
- name: "modeSwitcher",
- checked: "checked",
- id: exports.ID+"TagsMode",
- }));
-
- modeSwitcher.append($("<label>", {
- for: exports.ID+"TagsMode",
- text: "Tags",
- }));
-
- modeSwitcher.append($("<input>", {
- type: "radio",
- name: "modeSwitcher",
- id: exports.ID+"FilesMode",
- }));
-
- modeSwitcher.append($("<label>", {
- for: exports.ID+"FilesMode",
- text: "Files",
- }));
-
- modeSwitcher.buttonset();
-
- // Adding event listener & icon to the radio button
- $( "#"+exports.ID+"TagsMode" ).button({
+ viewContainer = $("#"+exports.ID+"Container");
+ viewToolbar = $("#"+exports.ID+"Toolbar");
+ viewFooter = $("#"+exports.ID+"Footer");
+
+ viewContainer.empty();
+ viewToolbar.empty();
+ viewFooter.empty();
+
+ viewToolbar.append($("<button>", {
+ text: "New",
+ disabled: true,
+ title: "Create new file",
+ id: exports.ID+"CreateFileButton",
+ }));
+
+ viewToolbar.append($("<span>", {
+ id: exports.ID+"ModeSwitcher",
+ }));
+
+ var modeSwitcher = $("#"+exports.ID+"ModeSwitcher");
+
+ modeSwitcher.append($("<input>", {
+ type: "radio",
+ name: "modeSwitcher",
+ checked: "checked",
+ id: exports.ID+"TagsMode",
+ }));
+
+ modeSwitcher.append($("<label>", {
+ for: exports.ID+"TagsMode",
+ text: "Tags",
+ }));
+
+ modeSwitcher.append($("<input>", {
+ type: "radio",
+ name: "modeSwitcher",
+ id: exports.ID+"FilesMode",
+ }));
+
+ modeSwitcher.append($("<label>", {
+ for: exports.ID+"FilesMode",
+ text: "Files",
+ }));
+
+ modeSwitcher.buttonset();
+
+ // Adding event listener & icon to the radio button
+ $( "#"+exports.ID+"TagsMode" ).button({
+ text: true,
+ icons: {
+ primary: "ui-icon-tag"
+ }
+ })
+ .click(function() {
+ viewMode = "tags"
+ exports.load();
+ })
+
+ $( "#"+exports.ID+"FilesMode" ).button({
+ text: true,
+ icons: {
+ primary: "ui-icon-document-b"
+ }
+ })
+ .click(function() {
+ viewMode = "files"
+ exports.load();
+ })
+
+ viewToolbar.append($("<button>", {
+ text: "Tag",
+ disabled: true,
+ title: "TagSelectedFiles",
+ id: exports.ID+"TagButton",
+ }));
+
+ viewToolbar.append($("<span>", {
+ style: "float: right; margin: 0px; padding: 0px;",
+ }).append($("<input>", {
+ type: "filter",
+ // autocomplete: "off", // Error: cannot call methods on autocomplete prior to initialization; attempted to call method 'off'
+ title: "This filter applies to current directory without subdirectories.",
+ id: exports.ID+"FilterBox",
+ })));
+
+ viewContainer.append($("<table>", {
+ cellpadding: "0",
+ cellspacing: "0",
+ border: "0",
+ style: "width: 100%",
+ id: exports.ID+"FileTable",
+ }));
+
+ fileTable = $('#'+exports.ID+"FileTable").dataTable( {
+ "bJQueryUI": false,
+ "bPaginate": false,
+ "bLengthChange": false,
+ "bFilter": true,
+ "bSort": true,
+ "bInfo": false,
+ "bAutoWidth": false,
+ "aoColumns": [
+ { "sTitle": "Filename", "sClass": "right" },
+ { "sTitle": "Size(bytes)" },
+ { "sTitle": "Date Modified" },
+ { "sTitle": "Title" },
+ { "sTitle": "Tags" },
+ { "sTitle": "Ext" },
+ // { "sTitle": "Selection", "mData": null }
+ ],
+ "aoColumnDefs": [
+ { // Filename column
+ "mRender": function ( data, type, row ) { return TSCORE.buttonizeFileName(data) },
+ "aTargets": [ 0 ]
+ },
+ { // Title column
+ "mRender": function ( data, type, row ) { return TSCORE.buttonizeTitle(data,row[0]) },
+ "aTargets": [ 3 ]
+ },
+ { // Tags column
+ "mRender": function ( data, type, row ) { return TSCORE.generateTagButtons(data,row[5],row[0]) },
+ "aTargets": [ 4 ]
+ },
+ { // Last changed date column
+ "mRender": function ( data, type, row ) { return TSCORE.TagUtils.formatDateTime(data, true) },
+ "aTargets": [ 2 ]
+ },
+ { "bVisible": false, "aTargets": [ 5 ] },
+ // { "bSearchable": false, "aTargets": [ 0 ] },
+ // { "sClass": "center", "aTargets": [ 0 ] }
+ ]
+ } );
+
+ // Disable alerts in datatable
+ fileTable.dataTableExt.sErrMode = 'throw';
+
+ // Makes the body of the fileTable selectable
+ $("tbody", $(fileTable)).selectable({
+ filter: 'tr',
+ start: function() {
+ console.debug("Start selecting");
+
+ //Hiding all dropdown menus
+ $('BODY')
+ .find('.dropdown-menu').hide().end()
+ .find('[data-dropdown]').removeClass('dropdown-open');
+
+ exports.clearSelectedFiles();
+ },
+ stop: function(){
+ $(".ui-selected", this).each(function(){
+ var rowData = fileTable.fnGetData( this );
+ // Add the filename which is located in the first column to the list of selected filenames
+ TSCORE.selectedFiles.push(TSCORE.currentPath + TSCORE.TagUtils.DIR_SEPARATOR + rowData[0]);
+ handleElementActivation();
+ });
+ console.debug("Selected files: "+TSCORE.selectedFiles);
+ }
+ })
+
+ // Filter functionality
+ $("#"+exports.ID+"FilterBox").keyup(function() {
+ fileTable.fnFilter(this.value);
+ console.debug("Filter to value: "+this.value);
+ });
+
+ $('#'+exports.ID+"FilterBox").wrap('<span id="resetFilter" />').after($('<span/>').click(function() {
+ $(this).prev('input').val('').focus();
+ fileTable.fnFilter( "" );
+ }));
+
+ initButtons();
+ }
+
+ exports.load = function load() {
+ console.debug("Loading View "+exports.ID);
+
+ $('#'+exports.ID+"FileTable_wrapper").hide();
+
+ // Purging file table
+ fileTable.fnClearTable();
+
+ fileTable.fnAddData( TSCORE.fileList );
+
+ fileTable.fnSetColumnVis(0, true);
+ fileTable.fnSetColumnVis(1, true);
+ fileTable.fnSetColumnVis(2, true);
+ fileTable.fnSetColumnVis(3, true);
+ fileTable.fnSetColumnVis(4, true);
+
+ fileTable.$('tr')
+ .droppable({
+ accept: ".tagButton",
+ hoverClass: "activeRow",
+ drop: function( event, ui ) {
+ var tagName = ui.draggable.attr("tag");
+ var targetFile = fileTable.fnGetData( this )[0];
+ console.log("Tagging file: "+tagName+" to "+targetFile);
+
+ $(this).toggleClass("ui-selected");
+
+ var targetFilePath = TSCORE.currentPath + TSCORE.TagUtils.DIR_SEPARATOR + targetFile;
+
+ exports.clearSelectedFiles();
+ TSCORE.selectedFiles.push(targetFilePath);
+ handleElementActivation();
+
+ TSCORE.TagUtils.addTag(TSCORE.selectedFiles, [tagName]);
+ }
+ })
+ .dblclick( function() {
+ console.debug("Opening file...");
+ var rowData = fileTable.fnGetData( this );
+
+ TSCORE.openFile(TSCORE.currentPath+TSCORE.TagUtils.DIR_SEPARATOR+rowData[0]);
+ } );
+
+ fileTable.$('.fileButton')
+ .draggable({
+ cancel:false,
+ appendTo: "body",
+ helper: "clone",
+ revert: true,
+ start: function() {
+ selectFile(this, $(this).attr("filepath"));
+ }
+ })
+ .click( function() {
+ selectFile(this, $(this).attr("filepath"));
+ } )
+ .dropdown( 'attach' , '#fileMenu' );
+
+ fileTable.$('.fileTitleButton')
+ .draggable({
+ cancel:false,
+ appendTo: "body",
+ helper: "clone",
+ revert: true,
+ start: function() {
+ selectFile(this, $(this).attr("filepath"));
+ }
+ })
+ .click( function() {
+ selectFile(this, $(this).attr("filepath"));
+ } )
+ .dropdown( 'attach' , '#fileMenu' );
+
+ fileTable.$('.extTagButton')
+ .click( function() {
+ selectFile(this, $(this).attr("filepath"));
+ TSCORE.openTagMenu(this, $(this).attr("tag"), $(this).attr("filepath"));
+ } )
+ .dropdown( 'attach' , '#extensionMenu' );
+
+ fileTable.$('.tagButton')
+ .draggable({
+ cancel:false,
+ appendTo: "body",
+ helper: "clone",
+ revert: true,
+ start: function() {
+ selectFile(this, $(this).attr("filepath"));
+ }
+ })
+ .click( function() {
+ selectFile(this, $(this).attr("filepath"));
+ TSCORE.openTagMenu(this, $(this).attr("tag"), $(this).attr("filepath"));
+ } )
+ .dropdown( 'attach' , '#tagMenu' );
+
+ if(viewMode == "files") {
+ console.debug("Change to FileView");
+ fileTable.fnSetColumnVis(0, true);
+ fileTable.fnSetColumnVis(1, true);
+ fileTable.fnSetColumnVis(2, true);
+ fileTable.fnSetColumnVis(3, false);
+ fileTable.fnSetColumnVis(4, false);
+ } else if (viewMode == "tags") {
+ console.debug("Change to TagView");
+ fileTable.fnSetColumnVis(0, false);
+ fileTable.fnSetColumnVis(1, false);
+ fileTable.fnSetColumnVis(2, false);
+ fileTable.fnSetColumnVis(3, true);
+ fileTable.fnSetColumnVis(4, true);
+ }
+
+ $('#'+exports.ID+"FileTable_wrapper").show();
+
+ $( "#"+exports.ID+"CreateFileButton" ).button( "enable" );
+
+ $( "#"+exports.ID+"TagButton" ).button( "disable" );
+
+ TSCORE.hideLoadingAnimation();
+ }
+
+ exports.setFileFilter = function setFileFilter(filter) {
+ $( "#"+exports.ID+"FilterBox").val(filter);
+ fileTable.fnFilter(filter);
+ }
+
+ exports.clearSelectedFiles = function() {
+ TSCORE.selectedFiles = [];
+ $('#'+exports.ID+'FileTable tbody tr').each(function(){
+ $(this).removeClass('ui-selected');
+ });
+ }
+
+ var selectFile = function(tagButton, filePath) {
+ exports.clearSelectedFiles();
+ $(tagButton).parent().parent().toggleClass("ui-selected");
+ TSCORE.selectedFiles.push(filePath);
+ handleElementActivation();
+ }
+
+ var initButtons = function() {
+
+ // Initialize file buttons
+ $( "#"+exports.ID+"CreateFileButton" ).button({
text: true,
icons: {
- primary: "ui-icon-tag"
+ primary: "ui-icon-document"
}
- })
- .click(function() {
- viewMode = "tags"
- exports.load();
- })
+ })
+ .click(function() {
+ $( "#dialog-filecreate" ).dialog( "open" );
+ });
- $( "#"+exports.ID+"FilesMode" ).button({
+ $( "#"+exports.ID+"TagButton" ).button({
text: true,
icons: {
- primary: "ui-icon-document-b"
+ primary: "ui-icon-document"
}
- })
- .click(function() {
- viewMode = "files"
- exports.load();
- })
-
- viewToolbar.append($("<button>", {
- text: "Tag",
- disabled: true,
- title: "TagSelectedFiles",
- id: exports.ID+"TagButton",
- }));
-
- viewToolbar.append($("<span>", {
- style: "float: right; margin: 0px; padding: 0px;",
- }).append($("<input>", {
- type: "filter",
- // autocomplete: "off", // Error: cannot call methods on autocomplete prior to initialization; attempted to call method 'off'
- title: "This filter applies to current directory without subdirectories.",
- id: exports.ID+"FilterBox",
- })));
-
- viewContainer.append($("<table>", {
- cellpadding: "0",
- cellspacing: "0",
- border: "0",
- style: "width: 100%",
- id: exports.ID+"FileTable",
- }));
-
- fileTable = $('#'+exports.ID+"FileTable").dataTable( {
- "bJQueryUI": false,
- "bPaginate": false,
- "bLengthChange": false,
- "bFilter": true,
- "bSort": true,
- "bInfo": false,
- "bAutoWidth": false,
- "aoColumns": [
- { "sTitle": "Filename", "sClass": "right" },
- { "sTitle": "Size(bytes)" },
- { "sTitle": "Date Modified" },
- { "sTitle": "Title" },
- { "sTitle": "Tags" },
- { "sTitle": "Ext" },
- // { "sTitle": "Selection", "mData": null }
- ],
- "aoColumnDefs": [
- { // Filename column
- "mRender": function ( data, type, row ) { return TagsUI.buttonizeFileName(data) },
- "aTargets": [ 0 ]
- },
- { // Title column
- "mRender": function ( data, type, row ) { return TagsUI.buttonizeTitle(data,row[0]) },
- "aTargets": [ 3 ]
- },
- { // Tags column
- "mRender": function ( data, type, row ) { return TagsUI.generateTagButtons(data,row[5],row[0]) },
- "aTargets": [ 4 ]
- },
- { // Last changed date column
- "mRender": function ( data, type, row ) { return UIAPI.TagUtils.formatDateTime(data, true) },
- "aTargets": [ 2 ]
- },
- { "bVisible": false, "aTargets": [ 5 ] },
-// { "bSearchable": false, "aTargets": [ 0 ] },
-// { "sClass": "center", "aTargets": [ 0 ] }
- ]
- } );
-
- // Disable alerts in datatable
- fileTable.dataTableExt.sErrMode = 'throw';
-
- // Makes the body of the fileTable selectable
- $("tbody", $(fileTable)).selectable({
- filter: 'tr',
- start: function() {
- console.debug("Start selecting");
-
- //Hiding all dropdown menus
- $('BODY')
- .find('.dropdown-menu').hide().end()
- .find('[data-dropdown]').removeClass('dropdown-open');
-
- exports.clearSelectedFiles();
- },
- stop: function(){
- $(".ui-selected", this).each(function(){
- var rowData = fileTable.fnGetData( this );
- // Add the filename which is located in the first column to the list of selected filenames
- UIAPI.selectedFiles.push(UIAPI.currentPath + UIAPI.TagUtils.DIR_SEPARATOR + rowData[0]);
- handleElementActivation();
- });
- console.debug("Selected files: "+UIAPI.selectedFiles);
- }
- })
-
- // Filter functionality
- $("#"+exports.ID+"FilterBox").keyup(function() {
- fileTable.fnFilter(this.value);
- console.debug("Filter to value: "+this.value);
- });
-
- $('#'+exports.ID+"FilterBox").wrap('<span id="resetFilter" />').after($('<span/>').click(function() {
- $(this).prev('input').val('').focus();
- fileTable.fnFilter( "" );
- }));
-
- initButtons();
-}
-
-exports.load = function load() {
- console.debug("Loading View "+exports.ID);
-
- $('#'+exports.ID+"FileTable_wrapper").hide();
-
- // Purging file table
- fileTable.fnClearTable();
-
- fileTable.fnAddData( UIAPI.fileList );
-
- fileTable.fnSetColumnVis(0, true);
- fileTable.fnSetColumnVis(1, true);
- fileTable.fnSetColumnVis(2, true);
- fileTable.fnSetColumnVis(3, true);
- fileTable.fnSetColumnVis(4, true);
-
- fileTable.$('tr')
- .droppable({
- accept: ".tagButton",
- hoverClass: "activeRow",
- drop: function( event, ui ) {
- var tagName = ui.draggable.attr("tag");
- var targetFile = fileTable.fnGetData( this )[0];
- console.log("Tagging file: "+tagName+" to "+targetFile);
-
- $(this).toggleClass("ui-selected");
-
- var targetFilePath = UIAPI.currentPath + UIAPI.TagUtils.DIR_SEPARATOR + targetFile;
-
- exports.clearSelectedFiles();
- UIAPI.selectedFiles.push(targetFilePath);
- handleElementActivation();
-
- UIAPI.TagUtils.addTag(UIAPI.selectedFiles, [tagName]);
- }
- })
- .dblclick( function() {
- console.debug("Opening file...");
- var rowData = fileTable.fnGetData( this );
-
- UIAPI.openFile(UIAPI.currentPath+UIAPI.TagUtils.DIR_SEPARATOR+rowData[0]);
- } );
-
- fileTable.$('.fileButton')
- .draggable({
- cancel:false,
- appendTo: "body",
- helper: "clone",
- revert: true,
- start: function() {
- selectFile(this, $(this).attr("filepath"));
- }
- })
- .click( function() {
- selectFile(this, $(this).attr("filepath"));
- } )
- .dropdown( 'attach' , '#fileMenu' );
-
- fileTable.$('.fileTitleButton')
- .draggable({
- cancel:false,
- appendTo: "body",
- helper: "clone",
- revert: true,
- start: function() {
- selectFile(this, $(this).attr("filepath"));
- }
- })
- .click( function() {
- selectFile(this, $(this).attr("filepath"));
- } )
- .dropdown( 'attach' , '#fileMenu' );
-
- fileTable.$('.extTagButton')
- .click( function() {
- selectFile(this, $(this).attr("filepath"));
- TagsUI.openTagMenu(this, $(this).attr("tag"), $(this).attr("filepath"));
- } )
- .dropdown( 'attach' , '#extensionMenu' );
-
- fileTable.$('.tagButton')
- .draggable({
- cancel:false,
- appendTo: "body",
- helper: "clone",
- revert: true,
- start: function() {
- selectFile(this, $(this).attr("filepath"));
- }
- })
- .click( function() {
- selectFile(this, $(this).attr("filepath"));
- TagsUI.openTagMenu(this, $(this).attr("tag"), $(this).attr("filepath"));
- } )
- .dropdown( 'attach' , '#tagMenu' );
-
- if(viewMode == "files") {
- console.debug("Change to FileView");
- fileTable.fnSetColumnVis(0, true);
- fileTable.fnSetColumnVis(1, true);
- fileTable.fnSetColumnVis(2, true);
- fileTable.fnSetColumnVis(3, false);
- fileTable.fnSetColumnVis(4, false);
- } else if (viewMode == "tags") {
- console.debug("Change to TagView");
- fileTable.fnSetColumnVis(0, false);
- fileTable.fnSetColumnVis(1, false);
- fileTable.fnSetColumnVis(2, false);
- fileTable.fnSetColumnVis(3, true);
- fileTable.fnSetColumnVis(4, true);
- }
-
- $('#'+exports.ID+"FileTable_wrapper").show();
-
- $( "#"+exports.ID+"CreateFileButton" ).button( "enable" );
-
- $( "#"+exports.ID+"TagButton" ).button( "disable" );
-
- UIAPI.hideLoadingAnimation();
-}
-
-exports.setFileFilter = function setFileFilter(filter) {
- $( "#"+exports.ID+"FilterBox").val(filter);
- fileTable.fnFilter(filter);
-}
-
-exports.clearSelectedFiles = function() {
- UIAPI.selectedFiles = [];
- $('#'+exports.ID+'FileTable tbody tr').each(function(){
- $(this).removeClass('ui-selected');
- });
-}
-
-var selectFile = function(tagButton, filePath) {
- exports.clearSelectedFiles();
- $(tagButton).parent().parent().toggleClass("ui-selected");
- UIAPI.selectedFiles.push(filePath);
- handleElementActivation();
-}
-
-var initButtons = function() {
-
-// Initialize file buttons
- $( "#"+exports.ID+"CreateFileButton" ).button({
- text: true,
- icons: {
- primary: "ui-icon-document"
- }
- })
- .click(function() {
- $( "#dialog-filecreate" ).dialog( "open" );
- });
-
- $( "#"+exports.ID+"TagButton" ).button({
- text: true,
- icons: {
- primary: "ui-icon-document"
- }
- })
- .click(function() {
- $( "#dialogAddTags" ).dialog( "open" );
- });
-
- $( "#clearFilterButton" ).button({
- text: false,
- disabled: false,
- icons: {
- primary: "ui-icon-close"
- }
- })
- .click(function() {
- $( "#filterBox" ).val( "" );
- fileTable.fnFilter( "" );
- });
-}
-
-var handleElementActivation = function() {
- console.debug("Entering element activation handler...");
-
- if (UIAPI.selectedFiles.length > 1) {
- $( "#"+exports.ID+"TagButton" ).button( "enable" );
- } else if (UIAPI.selectedFiles.length == 1) {
- $( "#"+exports.ID+"TagButton" ).button( "enable" );
- } else {
- $( "#"+exports.ID+"TagButton" ).button( "disable" );
- }
-}
+ })
+ .click(function() {
+ $( "#dialogAddTags" ).dialog( "open" );
+ });
+
+ $( "#clearFilterButton" ).button({
+ text: false,
+ disabled: false,
+ icons: {
+ primary: "ui-icon-close"
+ }
+ })
+ .click(function() {
+ $( "#filterBox" ).val( "" );
+ fileTable.fnFilter( "" );
+ });
+ }
+
+ var handleElementActivation = function() {
+ console.debug("Entering element activation handler...");
+
+ if (TSCORE.selectedFiles.length > 1) {
+ $( "#"+exports.ID+"TagButton" ).button( "enable" );
+ } else if (TSCORE.selectedFiles.length == 1) {
+ $( "#"+exports.ID+"TagButton" ).button( "enable" );
+ } else {
+ $( "#"+exports.ID+"TagButton" ).button( "disable" );
+ }
+ }
});
\ No newline at end of file
diff --git a/data/ext/perspectiveGraph/extension.js b/data/ext/perspectiveGraph/extension.js
index ec9b9a6e7..6a0d3541f 100644
--- a/data/ext/perspectiveGraph/extension.js
+++ b/data/ext/perspectiveGraph/extension.js
@@ -2,532 +2,530 @@
* Use of this source code is governed by a AGPL3 license that
* can be found in the LICENSE file. */
-define([
- 'require',
- 'exports',
- 'module',
-],function(require, exports, module) {
+define(function(require, exports, module) {
"use strict";
-
-exports.Title = "Graph"
-exports.ID = "perspectiveGraph"; // ID should be equal to the directory name where the ext. is located
-exports.Type = "view";
-exports.Icon = "ui-icon-shuffle";
-exports.Version = "1.0";
-exports.ManifestVersion = 1;
-exports.License = "AGPL";
-
-console.debug("Loading viewGraph/extension.js... ");
-
-var viewContainer = undefined;
-var viewToolbar = undefined;
-var viewFooter = undefined;
-
-var viewMode = "files" // tags
-
-var extensionDirectory = TSSETTINGS.getExtensionPath()+"/"+exports.ID;
-
-var graphMode = "treeMap" // tree
-
-var width = undefined;
-var height = undefined;
-var svg = undefined;
-
-var treeData = undefined;
-
-var treeTestData = {
- "name": "flare",
- "children": [
- {
- "name": "analytics",
- "children": [
- {
- "name": "cluster",
- "children": [
- {"name": "AgglomerativeCluster", "size": 3938},
- {"name": "CommunityStructure", "size": 3812},
- {"name": "HierarchicalCluster", "size": 6714},
- {"name": "MergeEdge", "size": 743}
- ]
- },
- {
- "name": "graph",
- "children": [
- {"name": "BetweennessCentrality", "size": 3534},
- {"name": "LinkDistance", "size": 5731},
- {"name": "MaxFlowMinCut", "size": 7840},
- {"name": "ShortestPaths", "size": 5914},
- {"name": "SpanningTree", "size": 3416}
- ]
- },
- {
- "name": "optimization",
- "children": [
- {"name": "AspectRatioBanker", "size": 7074}
- ]
- }
- ]
- },
- {
- "name": "data",
- "children": [
- {
- "name": "converters",
- "children": [
- {"name": "Converters", "size": 721},
- {"name": "DelimitedTextConverter", "size": 4294},
- {"name": "JSONConverter", "size": 2220}
- ]
- },
- {"name": "DataField", "size": 1759},
- {"name": "DataSchema", "size": 2165},
- {"name": "DataUtil", "size": 3322}
- ]
- },
- {
- "name": "display",
- "children": [
- {"name": "DirtySprite", "size": 8833},
- {"name": "LineSprite", "size": 1732},
- {"name": "RectSprite", "size": 3623},
- {"name": "TextSprite", "size": 10066}
- ]
- },
- {
- "name": "flex",
- "children": [
- {"name": "FlareVis", "size": 4116}
- ]
- },
- {
- "name": "physics",
- "children": [
- {"name": "DragForce", "size": 1082},
- {"name": "SpringForce", "size": 1681}
- ]
- },
- {
- "name": "scale",
- "children": [
- {"name": "IScaleMap", "size": 2105},
- {"name": "LinearScale", "size": 1316},
- {"name": "ScaleType", "size": 1821},
- {"name": "TimeScale", "size": 5833}
- ]
- },
- {
- "name": "util",
- "children": [
- {"name": "Arrays", "size": 8258},
- {"name": "Colors", "size": 10001},
- {"name": "Dates", "size": 8217},
- {"name": "Displays", "size": 12555},
- {"name": "Filter", "size": 2324},
- {"name": "Geometry", "size": 10993},
- {
- "name": "heap",
- "children": [
- {"name": "FibonacciHeap", "size": 9354},
- {"name": "HeapNode", "size": 1233}
- ]
- },
- {
- "name": "data",
- "children": [
- {"name": "Data", "size": 20544},
- {"name": "DataList", "size": 19788},
- {"name": "DataSprite", "size": 10349},
- {"name": "EdgeSprite", "size": 3301},
- {"name": "NodeSprite", "size": 19382},
- {
- "name": "render",
- "children": [
- {"name": "ArrowType", "size": 698},
- {"name": "EdgeRenderer", "size": 5569},
- {"name": "IRenderer", "size": 353},
- {"name": "ShapeRenderer", "size": 2247}
- ]
- },
- {"name": "ScaleBinding", "size": 11275},
- {"name": "Tree", "size": 7147},
- {"name": "TreeBuilder", "size": 9930}
- ]
- },
- {
- "name": "operator",
- "children": [
- {
- "name": "distortion",
- "children": [
- {"name": "BifocalDistortion", "size": 4461},
- {"name": "Distortion", "size": 6314},
- {"name": "FisheyeDistortion", "size": 3444}
- ]
- },
- {"name": "Operator", "size": 2490},
- {"name": "OperatorList", "size": 5248},
- {"name": "OperatorSequence", "size": 4190},
- {"name": "OperatorSwitch", "size": 2581},
- {"name": "SortOperator", "size": 2023}
- ]
- },
- {"name": "Visualization", "size": 16540}
- ]
- }
- ]
-};
-
-exports.init = function init() {
- console.debug("Initializing View "+exports.ID);
- viewContainer = $("#"+exports.ID+"Container");
- viewToolbar = $("#"+exports.ID+"Toolbar");
- viewFooter = $("#"+exports.ID+"Footer");
-
- viewContainer.empty();
- viewToolbar.empty();
- viewFooter.empty();
-
- initContextMenus();
- initButtons();
-
- require([
- extensionDirectory+'/d3/d3.js',
- ], function() {
- viewContainer.append('<link rel="stylesheet" type="text/css" href="'+extensionDirectory+"/"+'styles.css">');
- });
-}
-
-exports.load = function load() {
- console.debug("Loading View "+exports.ID);
-
- $( "#"+exports.ID+"ReIndexButton" ).button( "enable" );
- UIAPI.hideLoadingAnimation();
-}
-
-var reDraw = function() {
- d3.select("svg").remove();
+ console.debug("Loading perspectiveGraph");
- width = viewContainer.width();
- height = viewContainer.height();
+ exports.Title = "Graph"
+ exports.ID = "perspectiveGraph"; // ID should be equal to the directory name where the ext. is located
+ exports.Type = "view";
+ exports.Icon = "ui-icon-shuffle";
+ exports.Version = "1.0";
+ exports.ManifestVersion = 1;
+ exports.License = "AGPL";
- svg = d3.select("#"+exports.ID+"Container")
- .append("svg")
- .attr("width", width)
- .attr("height", height)
-
- switch (graphMode) {
- case "treeMap":
- drawTreeMap();
- break;
- case "tree":
- drawTree();
- break;
- default:
- break;
- }
-}
-
-var drawTree2 = function() {
- var diameter = height;
+ var TSCORE = require("tscore");
- var tree = d3.layout.tree()
- .size([360, diameter / 2 - 120])
- .separation(function(a, b) { return (a.parent == b.parent ? 1 : 2) / a.depth; });
+ var viewContainer = undefined;
+ var viewToolbar = undefined;
+ var viewFooter = undefined;
- var diagonal = d3.svg.diagonal.radial()
- .projection(function(d) { return [d.y, d.x / 180 * Math.PI]; });
+ var viewMode = "files" // tags
- svg.append("g").attr("transform", "translate(" + diameter / 2 + "," + diameter / 2 + ")");
+ var extensionDirectory = TSCORE.Config.getExtensionPath()+"/"+exports.ID;
- var nodes = tree.nodes(treeData),
- links = tree.links(nodes);
+ var graphMode = "treeMap" // tree
- var link = svg.selectAll(".link")
- .data(links)
- .enter().append("path")
- .attr("class", "link")
- .attr("d", diagonal);
+ var width = undefined;
+ var height = undefined;
+ var svg = undefined;
- var node = svg.selectAll(".node")
- .data(nodes)
- .enter().append("g")
- .attr("class", "node")
- .attr("transform", function(d) { return "rotate(" + (d.x - 90) + ")translate(" + d.y + ")"; })
+ var treeData = undefined;
- node.append("circle")
- .attr("r", 4.5);
+ var treeTestData = {
+ "name": "flare",
+ "children": [
+ {
+ "name": "analytics",
+ "children": [
+ {
+ "name": "cluster",
+ "children": [
+ {"name": "AgglomerativeCluster", "size": 3938},
+ {"name": "CommunityStructure", "size": 3812},
+ {"name": "HierarchicalCluster", "size": 6714},
+ {"name": "MergeEdge", "size": 743}
+ ]
+ },
+ {
+ "name": "graph",
+ "children": [
+ {"name": "BetweennessCentrality", "size": 3534},
+ {"name": "LinkDistance", "size": 5731},
+ {"name": "MaxFlowMinCut", "size": 7840},
+ {"name": "ShortestPaths", "size": 5914},
+ {"name": "SpanningTree", "size": 3416}
+ ]
+ },
+ {
+ "name": "optimization",
+ "children": [
+ {"name": "AspectRatioBanker", "size": 7074}
+ ]
+ }
+ ]
+ },
+ {
+ "name": "data",
+ "children": [
+ {
+ "name": "converters",
+ "children": [
+ {"name": "Converters", "size": 721},
+ {"name": "DelimitedTextConverter", "size": 4294},
+ {"name": "JSONConverter", "size": 2220}
+ ]
+ },
+ {"name": "DataField", "size": 1759},
+ {"name": "DataSchema", "size": 2165},
+ {"name": "DataUtil", "size": 3322}
+ ]
+ },
+ {
+ "name": "display",
+ "children": [
+ {"name": "DirtySprite", "size": 8833},
+ {"name": "LineSprite", "size": 1732},
+ {"name": "RectSprite", "size": 3623},
+ {"name": "TextSprite", "size": 10066}
+ ]
+ },
+ {
+ "name": "flex",
+ "children": [
+ {"name": "FlareVis", "size": 4116}
+ ]
+ },
+ {
+ "name": "physics",
+ "children": [
+ {"name": "DragForce", "size": 1082},
+ {"name": "SpringForce", "size": 1681}
+ ]
+ },
+ {
+ "name": "scale",
+ "children": [
+ {"name": "IScaleMap", "size": 2105},
+ {"name": "LinearScale", "size": 1316},
+ {"name": "ScaleType", "size": 1821},
+ {"name": "TimeScale", "size": 5833}
+ ]
+ },
+ {
+ "name": "util",
+ "children": [
+ {"name": "Arrays", "size": 8258},
+ {"name": "Colors", "size": 10001},
+ {"name": "Dates", "size": 8217},
+ {"name": "Displays", "size": 12555},
+ {"name": "Filter", "size": 2324},
+ {"name": "Geometry", "size": 10993},
+ {
+ "name": "heap",
+ "children": [
+ {"name": "FibonacciHeap", "size": 9354},
+ {"name": "HeapNode", "size": 1233}
+ ]
+ },
+ {
+ "name": "data",
+ "children": [
+ {"name": "Data", "size": 20544},
+ {"name": "DataList", "size": 19788},
+ {"name": "DataSprite", "size": 10349},
+ {"name": "EdgeSprite", "size": 3301},
+ {"name": "NodeSprite", "size": 19382},
+ {
+ "name": "render",
+ "children": [
+ {"name": "ArrowType", "size": 698},
+ {"name": "EdgeRenderer", "size": 5569},
+ {"name": "IRenderer", "size": 353},
+ {"name": "ShapeRenderer", "size": 2247}
+ ]
+ },
+ {"name": "ScaleBinding", "size": 11275},
+ {"name": "Tree", "size": 7147},
+ {"name": "TreeBuilder", "size": 9930}
+ ]
+ },
+ {
+ "name": "operator",
+ "children": [
+ {
+ "name": "distortion",
+ "children": [
+ {"name": "BifocalDistortion", "size": 4461},
+ {"name": "Distortion", "size": 6314},
+ {"name": "FisheyeDistortion", "size": 3444}
+ ]
+ },
+ {"name": "Operator", "size": 2490},
+ {"name": "OperatorList", "size": 5248},
+ {"name": "OperatorSequence", "size": 4190},
+ {"name": "OperatorSwitch", "size": 2581},
+ {"name": "SortOperator", "size": 2023}
+ ]
+ },
+ {"name": "Visualization", "size": 16540}
+ ]
+ }
+ ]
+ };
- node.append("text")
- .attr("dy", ".31em")
- .attr("text-anchor", function(d) { return d.x < 180 ? "start" : "end"; })
- .attr("transform", function(d) { return d.x < 180 ? "translate(8)" : "rotate(180)translate(-8)"; })
- .text(function(d) { return d.name; });
+ exports.init = function init() {
+ console.debug("Initializing View "+exports.ID);
+
+ viewContainer = $("#"+exports.ID+"Container");
+ viewToolbar = $("#"+exports.ID+"Toolbar");
+ viewFooter = $("#"+exports.ID+"Footer");
+
+ viewContainer.empty();
+ viewToolbar.empty();
+ viewFooter.empty();
- d3.select(self.frameElement).style("height", diameter - 150 + "px");
+ initContextMenus();
+ initButtons();
+
+ require([
+ extensionDirectory+'/d3/d3.js',
+ ], function() {
+ viewContainer.append('<link rel="stylesheet" type="text/css" href="'+extensionDirectory+"/"+'styles.css">');
+ });
+ }
-}
-
-var drawTree = function() {
- svg.append("g").attr("transform", "translate(40,0)");
-
- var cluster = d3.layout.cluster()
- .size([height, width - 160]);
-
- var diagonal = d3.svg.diagonal()
- .projection(function(d) { return [d.y, d.x]; });
+ exports.load = function load() {
+ console.debug("Loading View "+exports.ID);
- // Setting the json data
- var nodes = cluster.nodes(treeData);
-
- var links = cluster.links(nodes);
+ $( "#"+exports.ID+"ReIndexButton" ).button( "enable" );
+ TSCORE.hideLoadingAnimation();
+ }
- var link = svg.selectAll(".link")
- .data(links)
- .enter().append("path")
- .attr("class", "link")
- .attr("d", diagonal);
+ var reDraw = function() {
+ d3.select("svg").remove();
- var node = svg.selectAll(".node")
- .data(nodes)
- .enter().append("g")
- .attr("class", "node")
- .attr("transform", function(d) { return "translate(" + d.y + "," + d.x + ")"; })
+ width = viewContainer.width();
+ height = viewContainer.height();
- node.append("circle")
- .attr("r", 4.5);
+ svg = d3.select("#"+exports.ID+"Container")
+ .append("svg")
+ .attr("width", width)
+ .attr("height", height)
+
+ switch (graphMode) {
+ case "treeMap":
+ drawTreeMap();
+ break;
+ case "tree":
+ drawTree();
+ break;
+ default:
+ break;
+ }
+ }
- node.append("text")
- .attr("dx", function(d) { return d.children ? -8 : 8; })
- .attr("dy", 3)
- .style("text-anchor", function(d) { return d.children ? "end" : "start"; })
- .text(function(d) { return d.name; });
+ var drawTree2 = function() {
+ var diameter = height;
+
+ var tree = d3.layout.tree()
+ .size([360, diameter / 2 - 120])
+ .separation(function(a, b) { return (a.parent == b.parent ? 1 : 2) / a.depth; });
+
+ var diagonal = d3.svg.diagonal.radial()
+ .projection(function(d) { return [d.y, d.x / 180 * Math.PI]; });
+
+ svg.append("g").attr("transform", "translate(" + diameter / 2 + "," + diameter / 2 + ")");
+
+ var nodes = tree.nodes(treeData),
+ links = tree.links(nodes);
+
+ var link = svg.selectAll(".link")
+ .data(links)
+ .enter().append("path")
+ .attr("class", "link")
+ .attr("d", diagonal);
+
+ var node = svg.selectAll(".node")
+ .data(nodes)
+ .enter().append("g")
+ .attr("class", "node")
+ .attr("transform", function(d) { return "rotate(" + (d.x - 90) + ")translate(" + d.y + ")"; })
+
+ node.append("circle")
+ .attr("r", 4.5);
+
+ node.append("text")
+ .attr("dy", ".31em")
+ .attr("text-anchor", function(d) { return d.x < 180 ? "start" : "end"; })
+ .attr("transform", function(d) { return d.x < 180 ? "translate(8)" : "rotate(180)translate(-8)"; })
+ .text(function(d) { return d.name; });
+
+ d3.select(self.frameElement).style("height", diameter - 150 + "px");
+
+ }
+
+ var drawTree = function() {
+ svg.append("g").attr("transform", "translate(40,0)");
- d3.select(self.frameElement).style("height", height + "px");
-}
-
-var drawTreeMap2 = function() {
- var margin = {top: 40, right: 10, bottom: 10, left: 10},
- width = 960 - margin.left - margin.right,
- height = 500 - margin.top - margin.bottom;
+ var cluster = d3.layout.cluster()
+ .size([height, width - 160]);
+
+ var diagonal = d3.svg.diagonal()
+ .projection(function(d) { return [d.y, d.x]; });
+
+ // Setting the json data
+ var nodes = cluster.nodes(treeData);
+
+ var links = cluster.links(nodes);
+
+ var link = svg.selectAll(".link")
+ .data(links)
+ .enter().append("path")
+ .attr("class", "link")
+ .attr("d", diagonal);
+
+ var node = svg.selectAll(".node")
+ .data(nodes)
+ .enter().append("g")
+ .attr("class", "node")
+ .attr("transform", function(d) { return "translate(" + d.y + "," + d.x + ")"; })
+
+ node.append("circle")
+ .attr("r", 4.5);
+
+ node.append("text")
+ .attr("dx", function(d) { return d.children ? -8 : 8; })
+ .attr("dy", 3)
+ .style("text-anchor", function(d) { return d.children ? "end" : "start"; })
+ .text(function(d) { return d.name; });
+
+ d3.select(self.frameElement).style("height", height + "px");
+ }
- var color = d3.scale.category20c();
+ var drawTreeMap2 = function() {
+ var margin = {top: 40, right: 10, bottom: 10, left: 10},
+ width = 960 - margin.left - margin.right,
+ height = 500 - margin.top - margin.bottom;
+
+ var color = d3.scale.category20c();
+
+ var treemap = d3.layout.treemap()
+ .size([width, height])
+ .sticky(true)
+ .value(function(d) { return d.size; });
+
+ var div = d3.select("body").append("div")
+ .style("position", "relative")
+ .style("width", (width + margin.left + margin.right) + "px")
+ .style("height", (height + margin.top + margin.bottom) + "px")
+ .style("left", margin.left + "px")
+ .style("top", margin.top + "px");
- var treemap = d3.layout.treemap()
- .size([width, height])
- .sticky(true)
- .value(function(d) { return d.size; });
+ var node = div.datum(treeData).selectAll(".node")
+ .data(treemap.nodes)
+ .enter().append("div")
+ .attr("class", "node")
+ .call(position)
+ .style("background", function(d) { return d.children ? color(d.name) : null; })
+ .text(function(d) { return d.children ? null : d.name; });
+
+ d3.selectAll("input").on("change", function change() {
+ var value = this.value === "count"
+ ? function() { return 1; }
+ : function(d) { return d.size; };
+
+ node
+ .data(treemap.value(value).nodes)
+ .transition()
+ .duration(1500)
+ .call(position);
+ });
- var div = d3.select("body").append("div")
- .style("position", "relative")
- .style("width", (width + margin.left + margin.right) + "px")
- .style("height", (height + margin.top + margin.bottom) + "px")
- .style("left", margin.left + "px")
- .style("top", margin.top + "px");
-
- var node = div.datum(treeData).selectAll(".node")
- .data(treemap.nodes)
- .enter().append("div")
- .attr("class", "node")
- .call(position)
- .style("background", function(d) { return d.children ? color(d.name) : null; })
- .text(function(d) { return d.children ? null : d.name; });
+
+ var position = function () {
+ this.style("left", function(d) { return d.x + "px"; })
+ .style("top", function(d) { return d.y + "px"; })
+ .style("width", function(d) { return Math.max(0, d.dx - 1) + "px"; })
+ .style("height", function(d) { return Math.max(0, d.dy - 1) + "px"; });
+ }
+ }
- d3.selectAll("input").on("change", function change() {
- var value = this.value === "count"
- ? function() { return 1; }
- : function(d) { return d.size; };
+ var drawTreeMap = function() {
+ svg.append("g");
+
+ var partition = d3.layout.partition()
+ .size([width, height])
+ .value(function(d) { return d.size; }); // d.size;
- node
- .data(treemap.value(value).nodes)
- .transition()
- .duration(1500)
- .call(position);
- });
-
+ //Setting the data
+ var nodes = partition.nodes(treeData); // treeData
- var position = function () {
- this.style("left", function(d) { return d.x + "px"; })
- .style("top", function(d) { return d.y + "px"; })
- .style("width", function(d) { return Math.max(0, d.dx - 1) + "px"; })
- .style("height", function(d) { return Math.max(0, d.dy - 1) + "px"; });
+ var color = d3.scale.category20();
+
+ svg.selectAll(".node")
+ .data(nodes)
+ .enter().append("rect")
+ .attr("class", "node")
+ .attr("x", function(d) { return d.x; })
+ .attr("y", function(d) { return d.y; })
+ .attr("width", function(d) { return d.dx; })
+ .attr("height", function(d) { return d.dy; })
+ .style("fill", function(d) { return color((d.children ? d : d.parent).name); });
+
+ svg.selectAll(".label")
+ .data(nodes.filter(function(d) { return d.dx > 6; }))
+ .enter().append("text")
+ .attr("class", "label")
+ .attr("dy", ".35em")
+ .attr("transform", function(d) { return "translate(" + (d.x + d.dx / 2) + "," + (d.y + d.dy / 2) + ")rotate(90)"; })
+ .text(function(d) { return d.name; });
}
-}
-
-var drawTreeMap = function() {
- svg.append("g");
+
+ exports.updateTreeData = function updateIndexData(fsTreeData) {
+ console.debug("Updating tree data, Rendering graph...");
- var partition = d3.layout.partition()
- .size([width, height])
- .value(function(d) { return d.size; }); // d.size;
-
- //Setting the data
- var nodes = partition.nodes(treeData); // treeData
-
- var color = d3.scale.category20();
+ treeData = fsTreeData;
+
+ reDraw();
+
+ $( "#"+exports.ID+"ReIndexButton" ).button( "enable" );
+ TSCORE.hideLoadingAnimation();
+ }
+
+ exports.setFileFilter = function setFileFilter(filter) {
+ $( "#"+exports.ID+"FilterBox").val(filter);
+ fileTable.fnFilter(filter);
+ }
- svg.selectAll(".node")
- .data(nodes)
- .enter().append("rect")
- .attr("class", "node")
- .attr("x", function(d) { return d.x; })
- .attr("y", function(d) { return d.y; })
- .attr("width", function(d) { return d.dx; })
- .attr("height", function(d) { return d.dy; })
- .style("fill", function(d) { return color((d.children ? d : d.parent).name); });
+ exports.clearSelectedFiles = function() {
+ // Deselect all
+ $(".selectedRow", $(fileTable)).each(function(){
+ $(this).toggleClass('selectedRow');
+ });
+ }
- svg.selectAll(".label")
- .data(nodes.filter(function(d) { return d.dx > 6; }))
- .enter().append("text")
- .attr("class", "label")
- .attr("dy", ".35em")
- .attr("transform", function(d) { return "translate(" + (d.x + d.dx / 2) + "," + (d.y + d.dy / 2) + ")rotate(90)"; })
- .text(function(d) { return d.name; });
-}
-
-exports.updateTreeData = function updateIndexData(fsTreeData) {
- console.debug("Updating tree data, Rendering graph...");
+ var initButtons = function() {
+ viewToolbar.append($("<span>", {
+ style: "float: right; margin: 0px; padding: 0px;",
+ }).append($("<input>", {
+ type: "filter",
+ // autocomplete: "off", // Error: cannot call methods on autocomplete prior to initialization; attempted to call method 'off'
+ title: "This filter applies to current directory without subdirectories.",
+ id: exports.ID+"FilterBox",
+ })));
+
+ // Filter functionality
+ $("#"+exports.ID+"FilterBox").keyup(function() {
+ // TODO filter action here
+ console.debug("Filter to value: "+this.value);
+ });
+
+ $('#'+exports.ID+"FilterBox").wrap('<span id="resetFilter" />').after($('<span/>').click(function() {
+ $(this).prev('input').val('').focus();
+ // TODO filter action here
+ }));
- treeData = fsTreeData;
+ $( "#clearFilterButton" ).button({
+ text: false,
+ disabled: false,
+ icons: {
+ primary: "ui-icon-close"
+ }
+ })
+ .click(function() {
+ $( "#filterBox" ).val( "" );
+ fileTable.fnFilter( "" );
+ });
+
+ viewToolbar.append($("<button>", {
+ text: "Scan Directory",
+ disabled: true,
+ title: "Generate File System Tree",
+ id: exports.ID+"ReIndexButton",
+ }));
- reDraw();
-
- $( "#"+exports.ID+"ReIndexButton" ).button( "enable" );
- UIAPI.hideLoadingAnimation();
-}
-
-exports.setFileFilter = function setFileFilter(filter) {
- $( "#"+exports.ID+"FilterBox").val(filter);
- fileTable.fnFilter(filter);
-}
-
-exports.clearSelectedFiles = function() {
- // Deselect all
- $(".selectedRow", $(fileTable)).each(function(){
- $(this).toggleClass('selectedRow');
- });
-}
-
-var initButtons = function() {
- viewToolbar.append($("<span>", {
- style: "float: right; margin: 0px; padding: 0px;",
- }).append($("<input>", {
- type: "filter",
- // autocomplete: "off", // Error: cannot call methods on autocomplete prior to initialization; attempted to call method 'off'
- title: "This filter applies to current directory without subdirectories.",
- id: exports.ID+"FilterBox",
- })));
-
- // Filter functionality
- $("#"+exports.ID+"FilterBox").keyup(function() {
- // TODO filter action here
- console.debug("Filter to value: "+this.value);
- });
-
- $('#'+exports.ID+"FilterBox").wrap('<span id="resetFilter" />').after($('<span/>').click(function() {
- $(this).prev('input').val('').focus();
- // TODO filter action here
- }));
-
- $( "#clearFilterButton" ).button({
- text: false,
- disabled: false,
- icons: {
- primary: "ui-icon-close"
- }
- })
- .click(function() {
- $( "#filterBox" ).val( "" );
- fileTable.fnFilter( "" );
- });
-
- viewToolbar.append($("<button>", {
- text: "Scan Directory",
- disabled: true,
- title: "Generate File System Tree",
- id: exports.ID+"ReIndexButton",
- }));
-
- $( "#"+exports.ID+"ReIndexButton" ).button({
- text: true,
- icons: {
- primary: "ui-icon-refresh"
- }
- })
- .click(function() {
- $( "#"+exports.ID+"ReIndexButton" ).button( "disable" );
- IOAPI.createDirectoryTree(UIAPI.currentPath);
- });
-
-/* viewToolbar.append($("<label>", {
- for: exports.ID+"ModeSwitcher",
- text: "Mode",
- }));*/
-
- var modeSwitcher = viewToolbar.append($("<span>", {
- id: exports.ID+"ModeSwitcher",
- }));
-
- modeSwitcher.append($("<input>", {
- type: "radio",
- name: "modeSwitcher",
- checked: true,
- id: exports.ID+"TreeMapMode",
- }));
-
- modeSwitcher.append($("<label>", {
- for: exports.ID+"TreeMapMode",
- text: "TreeMap",
- }));
-
- modeSwitcher.append($("<input>", {
- type: "radio",
- name: "modeSwitcher",
- id: exports.ID+"TreeMode",
- }));
-
- modeSwitcher.append($("<label>", {
- for: exports.ID+"TreeMode",
- text: "Tree",
- }));
-
- $( "#"+exports.ID+"TreeMapMode" ).button({
+ $( "#"+exports.ID+"ReIndexButton" ).button({
text: true,
- })
- .click(function() {
- graphMode = "treeMap"
- reDraw();
- })
+ icons: {
+ primary: "ui-icon-refresh"
+ }
+ })
+ .click(function() {
+ $( "#"+exports.ID+"ReIndexButton" ).button( "disable" );
+ TSCORE.IO.createDirectoryTree(TSCORE.currentPath);
+ });
+
+ /* viewToolbar.append($("<label>", {
+ for: exports.ID+"ModeSwitcher",
+ text: "Mode",
+ }));*/
+
+ var modeSwitcher = viewToolbar.append($("<span>", {
+ id: exports.ID+"ModeSwitcher",
+ }));
+
+ modeSwitcher.append($("<input>", {
+ type: "radio",
+ name: "modeSwitcher",
+ checked: true,
+ id: exports.ID+"TreeMapMode",
+ }));
- $( "#"+exports.ID+"TreeMode" ).button({
- text: true,
- })
- .click(function() {
- graphMode = "tree"
- reDraw();
- })
+ modeSwitcher.append($("<label>", {
+ for: exports.ID+"TreeMapMode",
+ text: "TreeMap",
+ }));
+
+ modeSwitcher.append($("<input>", {
+ type: "radio",
+ name: "modeSwitcher",
+ id: exports.ID+"TreeMode",
+ }));
- modeSwitcher.buttonset();
-}
-
-var initContextMenus = function() {
- $( "#fileTitleMenu" ).menu({
- select: function( event, ui ) {
- var commandName = ui.item.attr( "action" );
- switch (commandName) {
- case "openFile":
- UIAPI.openFile(UIAPI.selectedFiles[0]);
- break;
- case "addTag":
- console.debug("Adding tag...");
- $("#tags").val("");
- $( "#dialogAddTags" ).dialog( "open" );
- break;
- default:
- break;
- }
- }
- });
-}
+ modeSwitcher.append($("<label>", {
+ for: exports.ID+"TreeMode",
+ text: "Tree",
+ }));
+
+ $( "#"+exports.ID+"TreeMapMode" ).button({
+ text: true,
+ })
+ .click(function() {
+ graphMode = "treeMap"
+ reDraw();
+ })
+
+ $( "#"+exports.ID+"TreeMode" ).button({
+ text: true,
+ })
+ .click(function() {
+ graphMode = "tree"
+ reDraw();
+ })
+
+ modeSwitcher.buttonset();
+ }
+
+ var initContextMenus = function() {
+ $( "#fileTitleMenu" ).menu({
+ select: function( event, ui ) {
+ var commandName = ui.item.attr( "action" );
+ switch (commandName) {
+ case "openFile":
+ TSCORE.openFile(TSCORE.selectedFiles[0]);
+ break;
+ case "addTag":
+ console.debug("Adding tag...");
+ $("#tags").val("");
+ $( "#dialogAddTags" ).dialog( "open" );
+ break;
+ default:
+ break;
+ }
+ }
+ });
+ }
});
\ No newline at end of file
diff --git a/data/ext/perspectiveRiver/extension.js b/data/ext/perspectiveRiver/extension.js
index 04d955c14..16a6e6e99 100644
--- a/data/ext/perspectiveRiver/extension.js
+++ b/data/ext/perspectiveRiver/extension.js
@@ -2,88 +2,86 @@
* Use of this source code is governed by a AGPL3 license that
* can be found in the LICENSE file. */
-define([
- 'require',
- 'exports',
- 'module',
-],function(require, exports, module) {
+define(function(require, exports, module) {
"use strict";
+
+ console.debug("Loading perspectiveRiver");
+
+ exports.Title = "River View"
+ exports.ID = "perspectiveRiver"; // ID should be equal to the directory name where the ext. is located
+ exports.Type = "view";
+ exports.Icon = "ui-icon-video";
-console.debug("Loading: viewThumb/extension.js");
-
-exports.Title = "River View"
-exports.ID = "perspectiveRiver"; // ID should be equal to the directory name where the ext. is located
-exports.Type = "view";
-exports.Icon = "ui-icon-video";
-
-var viewContainer = undefined;
-var viewToolbar = undefined;
-var viewFooter = undefined;
-
-exports.init = function init() {
- console.debug("Initializing View "+exports.ID);
+ var TSCORE = require("tscore");
- viewContainer = $("#"+exports.ID+"Container");
- viewToolbar = $("#"+exports.ID+"Toolbar");
- viewFooter = $("#"+exports.ID+"Footer");
+ var viewContainer = undefined;
+ var viewToolbar = undefined;
+ var viewFooter = undefined;
- viewContainer.empty();
- viewToolbar.empty();
- viewFooter.empty();
+ exports.init = function init() {
+ console.debug("Initializing View "+exports.ID);
+
+ viewContainer = $("#"+exports.ID+"Container");
+ viewToolbar = $("#"+exports.ID+"Toolbar");
+ viewFooter = $("#"+exports.ID+"Footer");
+
+ viewContainer.empty();
+ viewToolbar.empty();
+ viewFooter.empty();
+
+ viewToolbar.append($("<button>", {
+ text: "New",
+ disabled: true,
+ title: "Create new file",
+ id: exports.ID+"CreateFileButton",
+ }));
- viewToolbar.append($("<button>", {
- text: "New",
- disabled: true,
- title: "Create new file",
- id: exports.ID+"CreateFileButton",
- }));
-
- viewContainer.append($("<div>", {
- style: "width: 100%",
- id: exports.ID+"RV",
- }));
+ viewContainer.append($("<div>", {
+ style: "width: 100%",
+ id: exports.ID+"RV",
+ }));
+
+ initButtons();
+ }
- initButtons();
-}
-
-exports.load = function load() {
- console.debug("Showing View "+exports.ID);
-
- // Purging the thumbnail view, avoiding memory leak
- // document.getElementById(exports.ID+"SelectableFiles").innerHTML = "";
-
- $("#"+exports.ID+"RV").empty();
- var tagsHTML = undefined;
- for (var i=0; i < UIAPI.fileList.length; i++) {
- if(i > 10) break;
- tagsHTML = "";
- var fileName = UIAPI.fileList[i][0];
- var filePath = UIAPI.currentPath+"/"+fileName;
- tagsHTML += '<iframe id="idFrameViewer" style="width: 100%; height: 150px;" src="'+'file:///'+filePath+'" />';
- $("#"+exports.ID+"RV").append(tagsHTML);
- }
-
- UIAPI.hideLoadingAnimation();
-}
-
-exports.setFileFilter = function setFileFilter(filter) {
- console.debug("setFileFilter not implemented in "+exports.ID);
-}
-
-exports.clearSelectedFiles = function() {
- // TODO Deselect all
-}
-
-var initButtons = function() {
- $( "#"+exports.ID+"CreateFileButton" ).button({
- text: true,
- icons: {
- primary: "ui-icon-document"
- }
- })
- .click(function() {
- $( "#dialog-filecreate" ).dialog( "open" );
- });
-}
+ exports.load = function load() {
+ console.debug("Showing View "+exports.ID);
+
+ // Purging the thumbnail view, avoiding memory leak
+ // document.getElementById(exports.ID+"SelectableFiles").innerHTML = "";
+
+ $("#"+exports.ID+"RV").empty();
+ var tagsHTML = undefined;
+ for (var i=0; i < TSCORE.fileList.length; i++) {
+ if(i > 10) break;
+ tagsHTML = "";
+ var fileName = TSCORE.fileList[i][0];
+ var filePath = TSCORE.currentPath+"/"+fileName;
+ tagsHTML += '<iframe id="idFrameViewer" style="width: 100%; height: 150px;" src="'+'file:///'+filePath+'" />';
+ $("#"+exports.ID+"RV").append(tagsHTML);
+ }
+
+ TSCORE.hideLoadingAnimation();
+ }
+
+ exports.setFileFilter = function setFileFilter(filter) {
+ console.debug("setFileFilter not implemented in "+exports.ID);
+ }
+
+ exports.clearSelectedFiles = function() {
+ // TODO Deselect all
+ }
+
+ var initButtons = function() {
+ $( "#"+exports.ID+"CreateFileButton" ).button({
+ text: true,
+ icons: {
+ primary: "ui-icon-document"
+ }
+ })
+ .click(function() {
+ $( "#dialog-filecreate" ).dialog( "open" );
+ });
+ }
});
\ No newline at end of file
diff --git a/data/ext/perspectiveSearch/extension.js b/data/ext/perspectiveSearch/extension.js
index 70567ff88..fecc18e18 100644
--- a/data/ext/perspectiveSearch/extension.js
+++ b/data/ext/perspectiveSearch/extension.js
@@ -2,341 +2,337 @@
* Use of this source code is governed by a AGPL3 license that
* can be found in the LICENSE file. */
-define([
- 'require',
- 'exports',
- 'module',
- 'datatables',
-// 'css!datatablescss'
-],function(require, exports, module) {
+define(function(require, exports, module) {
"use strict";
-
-exports.Title = "Search"
-exports.ID = "perspectiveSearch"; // ID should be equal to the directory name where the ext. is located
-exports.Type = "view";
-exports.Icon = "ui-icon-search";
-exports.Version = "1.0";
-exports.ManifestVersion = 1;
-exports.License = "AGPL";
-
-console.debug("Loading view.search.js");
-
-var TagsUI = require("tstagsui");
-
-var viewContainer = undefined;
-var viewToolbar = undefined;
-var viewFooter = undefined;
-
-var fileTable = undefined;
-var viewMode = "files" // tags
-
-exports.init = function init() {
- console.debug("Initializing View "+exports.ID);
- viewContainer = $("#"+exports.ID+"Container");
- viewToolbar = $("#"+exports.ID+"Toolbar");
- viewFooter = $("#"+exports.ID+"Footer");
+ console.debug("Loading perspectiveSearch");
+
+ exports.Title = "Search"
+ exports.ID = "perspectiveSearch"; // ID should be equal to the directory name where the ext. is located
+ exports.Type = "view";
+ exports.Icon = "ui-icon-search";
+ exports.Version = "1.0";
+ exports.ManifestVersion = 1;
+ exports.License = "AGPL";
+
+ var TSCORE = require("tscore");
+ require('datatables');
+ //require('css!datatablescss');
- viewContainer.empty();
- viewToolbar.empty();
- viewFooter.empty();
+ var viewContainer = undefined;
+ var viewToolbar = undefined;
+ var viewFooter = undefined;
+
+ var fileTable = undefined;
+ var viewMode = "files" // tags
+
+ exports.init = function init() {
+ console.debug("Initializing View "+exports.ID);
- viewToolbar.append($("<button>", {
- text: "ReIndex",
- disabled: true,
- title: "Reindex current favorite folder.",
- id: exports.ID+"ReIndexButton",
- }));
-
- viewToolbar.append($("<button>", {
- text: "Tag",
- disabled: true,
- title: "TagSelectedFiles",
- id: exports.ID+"TagButton",
- }));
-
- viewToolbar.append($("<span>", {
- style: "float: right; margin: 0px; padding: 0px;",
- }).append($("<input>", {
- type: "filter",
- // autocomplete: "off", // Error: cannot call methods on autocomplete prior to initialization; attempted to call method 'off'
- title: "This filter applies to current directory without subdirectories.",
- id: exports.ID+"FilterBox",
- })));
-
- viewContainer.append($("<table>", {
- cellpadding: "0",
- cellspacing: "0",
- border: "0",
- style: "width: 100%",
- id: exports.ID+"FileTable",
- }));
-
-
- // Column order in json [title(0),tags(1),fileSize(2),fileLMDT(3),path(4),filename(5),extension(6)];
- fileTable = $('#'+exports.ID+"FileTable").dataTable( {
- "bJQueryUI": false,
- "bPaginate": false,
- "bLengthChange": false,
- "bFilter": true,
- "bSort": true,
- "bInfo": false,
- "bAutoWidth": false,
- "aoColumns": [
- { "sTitle": "Title", "sClass": "right" },
- { "sTitle": "Tags" },
- { "sTitle": "Size(bytes)" },
- { "sTitle": "Date Modified" },
- { "sTitle": "Path" },
- ],
- "aoColumnDefs": [
- { // Title column
- "mRender": function ( data, type, row ) { return TagsUI.buttonizeTitle(data,row[0],row[4]) },
- "aTargets": [ 0 ]
- },
- { // Tags column
- "mRender": function ( data, type, row ) { return TagsUI.generateTagButtons(data,row[6],row[5],row[4]) },
- "aTargets": [ 1 ]
- },
- { // Filesize column
- "mRender": function ( data, type, row ) { return UIAPI.TagUtils.formatFileSize(data) },
- "aTargets": [ 2 ]
- },
- { // Last changed date column
- "mRender": function ( data, type, row ) { return UIAPI.TagUtils.formatDateTime(data, true) },
- "aTargets": [ 3 ]
- },
-// { "bVisible": false, "aTargets": [ 5 ] },
-// { "bSearchable": false, "aTargets": [ 0 ] },
-// { "sClass": "center", "aTargets": [ 0 ] }
- ]
- } );
-
-
- // Disable alerts in datatable
- fileTable.dataTableExt.sErrMode = 'throw';
-
- // Makes the body of the fileTable selectable
- $("tbody", $(fileTable)).selectable({
- filter: 'tr',
- start: function() {
- console.debug("Start selecting");
-
- //Hiding all dropdown menus
- $('BODY')
- .find('.dropdown-menu').hide().end()
- .find('[data-dropdown]').removeClass('dropdown-open');
-
- exports.clearSelectedFiles();
- },
- stop: function(){
- $(".ui-selected", this).each(function(){
- var rowData = fileTable.fnGetData( this );
- // Add the filename which is located in the first column to the list of selected filenames
- UIAPI.selectedFiles.push(rowData[4]);
- handleElementActivation();
- });
- console.debug("Selected files: "+UIAPI.selectedFiles);
- }
- })
-
- // Filter functionality
- $("#"+exports.ID+"FilterBox").keyup(function() {
- fileTable.fnFilter(this.value);
- console.debug("Filter to value: "+this.value);
- });
-
- $('#'+exports.ID+"FilterBox").wrap('<span id="resetFilter" />').after($('<span/>').click(function() {
- $(this).prev('input').val('').focus();
- fileTable.fnFilter( "" );
- }));
-
- initButtons();
-}
-
-exports.load = function load() {
- console.debug("Loading View "+exports.ID);
-
- $('#'+exports.ID+"FileTable_wrapper").hide();
-
- // Purging file table
- fileTable.fnClearTable();
+ viewContainer = $("#"+exports.ID+"Container");
+ viewToolbar = $("#"+exports.ID+"Toolbar");
+ viewFooter = $("#"+exports.ID+"Footer");
+
+ viewContainer.empty();
+ viewToolbar.empty();
+ viewFooter.empty();
+
+ viewToolbar.append($("<button>", {
+ text: "ReIndex",
+ disabled: true,
+ title: "Reindex current favorite folder.",
+ id: exports.ID+"ReIndexButton",
+ }));
+
+ viewToolbar.append($("<button>", {
+ text: "Tag",
+ disabled: true,
+ title: "TagSelectedFiles",
+ id: exports.ID+"TagButton",
+ }));
+
+ viewToolbar.append($("<span>", {
+ style: "float: right; margin: 0px; padding: 0px;",
+ }).append($("<input>", {
+ type: "filter",
+ // autocomplete: "off", // Error: cannot call methods on autocomplete prior to initialization; attempted to call method 'off'
+ title: "This filter applies to current directory without subdirectories.",
+ id: exports.ID+"FilterBox",
+ })));
- $( "#"+exports.ID+"ReIndexButton" ).button( "enable" );
- UIAPI.hideLoadingAnimation();
-// $( "#"+exports.ID+"ReIndexButton" ).button( "disable" );
-// IOAPI.createDirectoryIndex(UIAPI.currentPath);
-}
-
-var enhanceIndexData = function(index) {
- console.debug("Enhancing directory index...");
- var enhancedIndex = [];
- var tags = undefined;
- var ext = undefined;
- var title = undefined;
- var fileSize = undefined;
- var fileLMDT = undefined;
- var path = undefined;
- var filename = undefined;
- for (var i=0; i < index.length; i++) {
- if (index[i].type == "file"){
- // Considering Unix HiddenEntries (. in the beginning of the filename)
- if (TSSETTINGS.Settings["showUnixHiddenEntries"] ||
- (!TSSETTINGS.Settings["showUnixHiddenEntries"] && (index[i].name.indexOf(".") != 0))) {
- filename = index[i].name;
- path = index[i].path;
- tags = UIAPI.TagUtils.extractTags(path);
- title = UIAPI.TagUtils.extractTitle(path);
- ext = UIAPI.TagUtils.extractFileExtension(path)
- fileSize = index[i].size;
- fileLMDT = index[i].lmdt;
-
- if(fileSize == undefined) fileSize = "";
- if(fileLMDT == undefined) fileLMDT = "";
- var entry = [title,tags,fileSize,fileLMDT,path,filename,ext];
- enhancedIndex.push(entry);
- }
- }
- }
- return enhancedIndex;
-}
-
-exports.updateIndexData = function updateIndexData(index) {
- console.debug("Updating index data.");
-
- // Clearing the old data
- fileTable.fnClearTable();
-
- fileTable.fnAddData( enhanceIndexData(index) );
-
- fileTable.$('tr')
- .droppable({
- accept: ".tagButton",
- hoverClass: "activeRow",
- drop: function( event, ui ) {
- var tagName = ui.draggable.attr("tag");
- var targetFilePath = fileTable.fnGetData( this )[4];
- console.log("Tagging file: "+tagName+" to "+targetFilePath);
+ viewContainer.append($("<table>", {
+ cellpadding: "0",
+ cellspacing: "0",
+ border: "0",
+ style: "width: 100%",
+ id: exports.ID+"FileTable",
+ }));
+
+
+ // Column order in json [title(0),tags(1),fileSize(2),fileLMDT(3),path(4),filename(5),extension(6)];
+ fileTable = $('#'+exports.ID+"FileTable").dataTable( {
+ "bJQueryUI": false,
+ "bPaginate": false,
+ "bLengthChange": false,
+ "bFilter": true,
+ "bSort": true,
+ "bInfo": false,
+ "bAutoWidth": false,
+ "aoColumns": [
+ { "sTitle": "Title", "sClass": "right" },
+ { "sTitle": "Tags" },
+ { "sTitle": "Size(bytes)" },
+ { "sTitle": "Date Modified" },
+ { "sTitle": "Path" },
+ ],
+ "aoColumnDefs": [
+ { // Title column
+ "mRender": function ( data, type, row ) { return TSCORE.buttonizeTitle(data,row[0],row[4]) },
+ "aTargets": [ 0 ]
+ },
+ { // Tags column
+ "mRender": function ( data, type, row ) { return TSCORE.generateTagButtons(data,row[6],row[5],row[4]) },
+ "aTargets": [ 1 ]
+ },
+ { // Filesize column
+ "mRender": function ( data, type, row ) { return TSCORE.TagUtils.formatFileSize(data) },
+ "aTargets": [ 2 ]
+ },
+ { // Last changed date column
+ "mRender": function ( data, type, row ) { return TSCORE.TagUtils.formatDateTime(data, true) },
+ "aTargets": [ 3 ]
+ },
+ // { "bVisible": false, "aTargets": [ 5 ] },
+ // { "bSearchable": false, "aTargets": [ 0 ] },
+ // { "sClass": "center", "aTargets": [ 0 ] }
+ ]
+ } );
+
+
+ // Disable alerts in datatable
+ fileTable.dataTableExt.sErrMode = 'throw';
+
+ // Makes the body of the fileTable selectable
+ $("tbody", $(fileTable)).selectable({
+ filter: 'tr',
+ start: function() {
+ console.debug("Start selecting");
+
+ //Hiding all dropdown menus
+ $('BODY')
+ .find('.dropdown-menu').hide().end()
+ .find('[data-dropdown]').removeClass('dropdown-open');
+
+ exports.clearSelectedFiles();
+ },
+ stop: function(){
+ $(".ui-selected", this).each(function(){
+ var rowData = fileTable.fnGetData( this );
+ // Add the filename which is located in the first column to the list of selected filenames
+ TSCORE.selectedFiles.push(rowData[4]);
+ handleElementActivation();
+ });
+ console.debug("Selected files: "+TSCORE.selectedFiles);
+ }
+ })
- $(this).toggleClass("ui-selected");
-
- exports.clearSelectedFiles();
- UIAPI.selectedFiles.push(targetFilePath);
- handleElementActivation();
-
- UIAPI.TagUtils.addTag(UIAPI.selectedFiles, [tagName]);
- }
- })
- .dblclick( function() {
- console.debug("Opening file...");
- var rowData = fileTable.fnGetData( this );
-
- UIAPI.openFile(rowData[4]); // 4 is the filePath
- } );
-
- fileTable.$('.fileTitleButton')
- .draggable({
- cancel:false,
- appendTo: "body",
- helper: "clone",
- revert: true,
- start: function() {
- selectFile(this, $(this).attr("filepath"));
- }
- })
- .click( function() {
- selectFile(this, $(this).attr("filepath"));
- } )
- .dropdown( 'attach' , '#fileMenu' );
-
- fileTable.$('.extTagButton')
- .click( function() {
- selectFile(this, $(this).attr("fileName"));
- TagsUI.openTagMenu(this, $(this).attr("tag"), $(this).attr("filepath"));
- } )
- .dropdown( 'attach' , '#extensionMenu' );
-
- fileTable.$('.tagButton')
- .click( function() {
- selectFile(this, $(this).attr("fileName"));
- TagsUI.openTagMenu(this, $(this).attr("tag"), $(this).attr("filepath"));
- } )
- .dropdown( 'attach' , '#tagMenu' );
-
- $('#'+exports.ID+"FileTable_wrapper").show();
-
- $( "#"+exports.ID+"ReIndexButton" ).button( "enable" );
-
- UIAPI.hideLoadingAnimation();
-}
-
-exports.setFileFilter = function setFileFilter(filter) {
- $( "#"+exports.ID+"FilterBox").val(filter);
- fileTable.fnFilter(filter);
-}
-
-exports.clearSelectedFiles = function() {
- UIAPI.selectedFiles = [];
- $('#'+exports.ID+'FileTable tbody tr').each(function(){
- $(this).removeClass('ui-selected');
- });
-}
-
-var selectFile = function(tagButton, filePath) {
- exports.clearSelectedFiles();
- $(tagButton).parent().parent().toggleClass("ui-selected");
- UIAPI.selectedFiles.push(filePath);
- handleElementActivation();
-}
-
-var initButtons = function() {
-
-// Initialize file buttons
- $( "#"+exports.ID+"ReIndexButton" ).button({
- text: true,
- icons: {
- primary: "ui-icon-refresh"
- }
- })
- .click(function() {
- $( "#"+exports.ID+"ReIndexButton" ).button( "disable" );
- IOAPI.createDirectoryIndex(UIAPI.currentPath);
- });
-
- $( "#"+exports.ID+"TagButton" ).button({
- text: true,
- icons: {
- primary: "ui-icon-document"
- }
- })
- .click(function() {
- $( "#dialogAddTags" ).dialog( "open" );
- });
-
-
- $( "#clearFilterButton" ).button({
- text: false,
- disabled: false,
- icons: {
- primary: "ui-icon-close"
- }
- })
- .click(function() {
- $( "#filterBox" ).val( "" );
- fileTable.fnFilter( "" );
- });
-}
-
-var handleElementActivation = function() {
- console.debug("Entering element activation handler...");
-
- if (UIAPI.selectedFiles.length > 1) {
- $( "#"+exports.ID+"TagButton" ).button( "enable" );
- } else if (UIAPI.selectedFiles.length == 1) {
- $( "#"+exports.ID+"TagButton" ).button( "enable" );
- } else {
- $( "#"+exports.ID+"TagButton" ).button( "disable" );
- }
-}
+ // Filter functionality
+ $("#"+exports.ID+"FilterBox").keyup(function() {
+ fileTable.fnFilter(this.value);
+ console.debug("Filter to value: "+this.value);
+ });
+
+ $('#'+exports.ID+"FilterBox").wrap('<span id="resetFilter" />').after($('<span/>').click(function() {
+ $(this).prev('input').val('').focus();
+ fileTable.fnFilter( "" );
+ }));
+
+ initButtons();
+ }
+
+ exports.load = function load() {
+ console.debug("Loading View "+exports.ID);
+
+ $('#'+exports.ID+"FileTable_wrapper").hide();
+
+ // Purging file table
+ fileTable.fnClearTable();
+
+ $( "#"+exports.ID+"ReIndexButton" ).button( "enable" );
+ TSCORE.hideLoadingAnimation();
+ // $( "#"+exports.ID+"ReIndexButton" ).button( "disable" );
+ // TSCORE.IO.createDirectoryIndex(TSCORE.currentPath);
+ }
+
+ var enhanceIndexData = function(index) {
+ console.debug("Enhancing directory index...");
+ var enhancedIndex = [];
+ var tags = undefined;
+ var ext = undefined;
+ var title = undefined;
+ var fileSize = undefined;
+ var fileLMDT = undefined;
+ var path = undefined;
+ var filename = undefined;
+ for (var i=0; i < index.length; i++) {
+ if (index[i].type == "file"){
+ // Considering Unix HiddenEntries (. in the beginning of the filename)
+ if (TSCORE.Config.Settings["showUnixHiddenEntries"] ||
+ (!TSCORE.Config.Settings["showUnixHiddenEntries"] && (index[i].name.indexOf(".") != 0))) {
+ filename = index[i].name;
+ path = index[i].path;
+ tags = TSCORE.TagUtils.extractTags(path);
+ title = TSCORE.TagUtils.extractTitle(path);
+ ext = TSCORE.TagUtils.extractFileExtension(path)
+ fileSize = index[i].size;
+ fileLMDT = index[i].lmdt;
+
+ if(fileSize == undefined) fileSize = "";
+ if(fileLMDT == undefined) fileLMDT = "";
+ var entry = [title,tags,fileSize,fileLMDT,path,filename,ext];
+ enhancedIndex.push(entry);
+ }
+ }
+ }
+ return enhancedIndex;
+ }
+
+ exports.updateIndexData = function updateIndexData(index) {
+ console.debug("Updating index data.");
+
+ // Clearing the old data
+ fileTable.fnClearTable();
+
+ fileTable.fnAddData( enhanceIndexData(index) );
+
+ fileTable.$('tr')
+ .droppable({
+ accept: ".tagButton",
+ hoverClass: "activeRow",
+ drop: function( event, ui ) {
+ var tagName = ui.draggable.attr("tag");
+ var targetFilePath = fileTable.fnGetData( this )[4];
+ console.log("Tagging file: "+tagName+" to "+targetFilePath);
+
+ $(this).toggleClass("ui-selected");
+
+ exports.clearSelectedFiles();
+ TSCORE.selectedFiles.push(targetFilePath);
+ handleElementActivation();
+
+ TSCORE.TagUtils.addTag(TSCORE.selectedFiles, [tagName]);
+ }
+ })
+ .dblclick( function() {
+ console.debug("Opening file...");
+ var rowData = fileTable.fnGetData( this );
+
+ TSCORE.openFile(rowData[4]); // 4 is the filePath
+ } );
+
+ fileTable.$('.fileTitleButton')
+ .draggable({
+ cancel:false,
+ appendTo: "body",
+ helper: "clone",
+ revert: true,
+ start: function() {
+ selectFile(this, $(this).attr("filepath"));
+ }
+ })
+ .click( function() {
+ selectFile(this, $(this).attr("filepath"));
+ } )
+ .dropdown( 'attach' , '#fileMenu' );
+
+ fileTable.$('.extTagButton')
+ .click( function() {
+ selectFile(this, $(this).attr("fileName"));
+ TSCORE.openTagMenu(this, $(this).attr("tag"), $(this).attr("filepath"));
+ } )
+ .dropdown( 'attach' , '#extensionMenu' );
+
+ fileTable.$('.tagButton')
+ .click( function() {
+ selectFile(this, $(this).attr("fileName"));
+ TSCORE.openTagMenu(this, $(this).attr("tag"), $(this).attr("filepath"));
+ } )
+ .dropdown( 'attach' , '#tagMenu' );
+
+ $('#'+exports.ID+"FileTable_wrapper").show();
+
+ $( "#"+exports.ID+"ReIndexButton" ).button( "enable" );
+
+ TSCORE.hideLoadingAnimation();
+ }
+
+ exports.setFileFilter = function setFileFilter(filter) {
+ $( "#"+exports.ID+"FilterBox").val(filter);
+ fileTable.fnFilter(filter);
+ }
+
+ exports.clearSelectedFiles = function() {
+ TSCORE.selectedFiles = [];
+ $('#'+exports.ID+'FileTable tbody tr').each(function(){
+ $(this).removeClass('ui-selected');
+ });
+ }
+
+ var selectFile = function(tagButton, filePath) {
+ exports.clearSelectedFiles();
+ $(tagButton).parent().parent().toggleClass("ui-selected");
+ TSCORE.selectedFiles.push(filePath);
+ handleElementActivation();
+ }
+
+ var initButtons = function() {
+
+ // Initialize file buttons
+ $( "#"+exports.ID+"ReIndexButton" ).button({
+ text: true,
+ icons: {
+ primary: "ui-icon-refresh"
+ }
+ })
+ .click(function() {
+ $( "#"+exports.ID+"ReIndexButton" ).button( "disable" );
+ TSCORE.IO.createDirectoryIndex(TSCORE.currentPath);
+ });
+
+ $( "#"+exports.ID+"TagButton" ).button({
+ text: true,
+ icons: {
+ primary: "ui-icon-document"
+ }
+ })
+ .click(function() {
+ $( "#dialogAddTags" ).dialog( "open" );
+ });
+
+
+ $( "#clearFilterButton" ).button({
+ text: false,
+ disabled: false,
+ icons: {
+ primary: "ui-icon-close"
+ }
+ })
+ .click(function() {
+ $( "#filterBox" ).val( "" );
+ fileTable.fnFilter( "" );
+ });
+ }
+
+ var handleElementActivation = function() {
+ console.debug("Entering element activation handler...");
+
+ if (TSCORE.selectedFiles.length > 1) {
+ $( "#"+exports.ID+"TagButton" ).button( "enable" );
+ } else if (TSCORE.selectedFiles.length == 1) {
+ $( "#"+exports.ID+"TagButton" ).button( "enable" );
+ } else {
+ $( "#"+exports.ID+"TagButton" ).button( "disable" );
+ }
+ }
});
\ No newline at end of file
diff --git a/data/ext/perspectiveThumb/extension.js b/data/ext/perspectiveThumb/extension.js
index 4d5cdf268..3a2abfd52 100644
--- a/data/ext/perspectiveThumb/extension.js
+++ b/data/ext/perspectiveThumb/extension.js
@@ -2,143 +2,139 @@
* Use of this source code is governed by a AGPL3 license that
* can be found in the LICENSE file. */
-define([
- 'require',
- 'exports',
- 'module',
-],function(require, exports, module) {
+define(function(require, exports, module) {
"use strict";
+
+ console.debug("Loading perspectiveThumb");
-console.debug("Loading: viewThumb/extension.js");
-
-exports.Title = "Thumbs"
-exports.ID = "perspectiveThumb"; // ID should be equal to the directory name where the ext. is located
-exports.Type = "view";
-exports.Icon = "ui-icon-image";
-
-var viewContainer = undefined;
-var viewToolbar = undefined;
-var viewFooter = undefined;
-
-var supportedFileTypeThumnailing = ['jpg','jpeg','png','gif'];
-
-exports.init = function init() {
- console.debug("Initializing View "+exports.ID);
+ exports.Title = "Thumbs"
+ exports.ID = "perspectiveThumb"; // ID should be equal to the directory name where the ext. is located
+ exports.Type = "view";
+ exports.Icon = "ui-icon-image";
- viewContainer = $("#"+exports.ID+"Container");
- viewToolbar = $("#"+exports.ID+"Toolbar");
- viewFooter = $("#"+exports.ID+"Footer");
+ var viewContainer = undefined;
+ var viewToolbar = undefined;
+ var viewFooter = undefined;
- viewContainer.empty();
- viewToolbar.empty();
- viewFooter.empty();
+ var supportedFileTypeThumnailing = ['jpg','jpeg','png','gif'];
- viewToolbar.append($("<button>", {
- text: "New",
- disabled: true,
- title: "Create new file",
- id: exports.ID+"CreateFileButton",
- }));
+ exports.init = function init() {
+ console.debug("Initializing View "+exports.ID);
+
+ viewContainer = $("#"+exports.ID+"Container");
+ viewToolbar = $("#"+exports.ID+"Toolbar");
+ viewFooter = $("#"+exports.ID+"Footer");
+
+ viewContainer.empty();
+ viewToolbar.empty();
+ viewFooter.empty();
+
+ viewToolbar.append($("<button>", {
+ text: "New",
+ disabled: true,
+ title: "Create new file",
+ id: exports.ID+"CreateFileButton",
+ }));
+
+ viewContainer.append($("<ol>", {
+ style: "overflow: visible;",
+ class: "selectableFiles",
+ id: exports.ID+"SelectableFiles",
+ text: "Empty viewer."
+ }));
+
+ $( "#"+exports.ID+"SelectableFiles" ).selectable({
+ stop: function() {
+ TSCORE.selectedFiles = [];
+ $( ".ui-selected", this ).each(function() {
+ TSCORE.selectedFiles.push($(this).attr("filepath"));
+ });
+ console.debug("Selected files: "+TSCORE.selectedFiles);
+ // TSCORE.handleElementActivation();
+
+ // On selecting only one file opens it in the viewer
+ if(TSCORE.selectedFiles.length == 1) {
+ TSCORE.openFile(TSCORE.selectedFiles[0]);
+ }
+ }
+ });
+
+ initButtons();
+ initContextMenus();
+ }
- viewContainer.append($("<ol>", {
- style: "overflow: visible;",
- class: "selectableFiles",
- id: exports.ID+"SelectableFiles",
- text: "Empty viewer."
- }));
+ exports.load = function load() {
+ console.debug("Showing View "+exports.ID);
+
+ // Purging the thumbnail view, avoiding memory leak
+ document.getElementById(exports.ID+"SelectableFiles").innerHTML = "";
- $( "#"+exports.ID+"SelectableFiles" ).selectable({
- stop: function() {
- UIAPI.selectedFiles = [];
- $( ".ui-selected", this ).each(function() {
- UIAPI.selectedFiles.push($(this).attr("filepath"));
- });
- console.debug("Selected files: "+UIAPI.selectedFiles);
- // UIAPI.handleElementActivation();
-
- // On selecting only one file opens it in the viewer
- if(UIAPI.selectedFiles.length == 1) {
- UIAPI.openFile(UIAPI.selectedFiles[0]);
- }
- }
- });
-
- initButtons();
- initContextMenus();
-}
-
-exports.load = function load() {
- console.debug("Showing View "+exports.ID);
-
- // Purging the thumbnail view, avoiding memory leak
- document.getElementById(exports.ID+"SelectableFiles").innerHTML = "";
-
- $("#"+exports.ID+"SelectableFiles").empty();
-
- for (var i=0; i < UIAPI.fileList.length; i++) {
- var fileName = UIAPI.fileList[i][0];
- var fileExt = UIAPI.TagUtils.extractFileExtension(fileName);
- var filePath = UIAPI.currentPath+UIAPI.TagUtils.DIR_SEPARATOR+fileName;
- if(supportedFileTypeThumnailing.indexOf(fileExt) >= 0) {
- $("#"+exports.ID+"SelectableFiles").append(
- $('<li>', { title: fileName, filepath: filePath, class: 'ui-widget-content' }).append(
- $('<img>', { title: fileName, class: "thumbImg", src: 'file:///'+filePath })));
- } else {
- $("#"+exports.ID+"SelectableFiles").append(
- $('<li>', { title: fileName, filepath: filePath, class: 'ui-widget-content' }).append(
- $('<span>', { class: "fileExtension", text: fileExt})));
- }
- }
-
- $( exports.ID+"CreateFileButton" ).button( "enable" );
- UIAPI.hideLoadingAnimation();
-}
-
-exports.setFileFilter = function setFileFilter(filter) {
- console.debug("setFileFilter not implemented in "+exports.ID);
-}
-
-exports.clearSelectedFiles = function() {
- // TODO Deselect all
- //$("#"+exports.ID+"SelectableFiles").
-}
-
-var initButtons = function() {
- $( "#"+exports.ID+"CreateFileButton" ).button({
- text: true,
- icons: {
- primary: "ui-icon-document"
- }
- })
- .click(function() {
- $( "#dialog-filecreate" ).dialog( "open" );
- });
-}
-
-var initContextMenus = function() {
- $( "#fileMenu1" ).menu({
- select: function( event, ui ) {
- var commandName = ui.item.attr( "action" );
- switch (commandName) {
- case "renameFile":
- $( this ).hide();
- console.debug("Renaming file...");
- $( "#dialog-filerename" ).dialog( "open" );
- break;
- case "deleteFile":
- $( this ).hide();
- console.debug("Deleting file...");
- $( "#dialog-confirmdelete" ).dialog( "open" );
- break;
- case "closeMenu":
- $( this ).hide();
- break;
- default:
- break;
- }
- $( this ).hide();
- }
- });
-}
+ $("#"+exports.ID+"SelectableFiles").empty();
+
+ for (var i=0; i < TSCORE.fileList.length; i++) {
+ var fileName = TSCORE.fileList[i][0];
+ var fileExt = TSCORE.TagUtils.extractFileExtension(fileName);
+ var filePath = TSCORE.currentPath+TSCORE.TagUtils.DIR_SEPARATOR+fileName;
+ if(supportedFileTypeThumnailing.indexOf(fileExt) >= 0) {
+ $("#"+exports.ID+"SelectableFiles").append(
+ $('<li>', { title: fileName, filepath: filePath, class: 'ui-widget-content' }).append(
+ $('<img>', { title: fileName, class: "thumbImg", src: 'file:///'+filePath })));
+ } else {
+ $("#"+exports.ID+"SelectableFiles").append(
+ $('<li>', { title: fileName, filepath: filePath, class: 'ui-widget-content' }).append(
+ $('<span>', { class: "fileExtension", text: fileExt})));
+ }
+ }
+
+ $( exports.ID+"CreateFileButton" ).button( "enable" );
+ TSCORE.hideLoadingAnimation();
+ }
+
+ exports.setFileFilter = function setFileFilter(filter) {
+ console.debug("setFileFilter not implemented in "+exports.ID);
+ }
+
+ exports.clearSelectedFiles = function() {
+ // TODO Deselect all
+ //$("#"+exports.ID+"SelectableFiles").
+ }
+
+ var initButtons = function() {
+ $( "#"+exports.ID+"CreateFileButton" ).button({
+ text: true,
+ icons: {
+ primary: "ui-icon-document"
+ }
+ })
+ .click(function() {
+ $( "#dialog-filecreate" ).dialog( "open" );
+ });
+ }
+
+ var initContextMenus = function() {
+ $( "#fileMenu1" ).menu({
+ select: function( event, ui ) {
+ var commandName = ui.item.attr( "action" );
+ switch (commandName) {
+ case "renameFile":
+ $( this ).hide();
+ console.debug("Renaming file...");
+ $( "#dialog-filerename" ).dialog( "open" );
+ break;
+ case "deleteFile":
+ $( this ).hide();
+ console.debug("Deleting file...");
+ $( "#dialog-confirmdelete" ).dialog( "open" );
+ break;
+ case "closeMenu":
+ $( this ).hide();
+ break;
+ default:
+ break;
+ }
+ $( this ).hide();
+ }
+ });
+ }
});
\ No newline at end of file
diff --git a/data/ext/viewerImage/extension.js b/data/ext/viewerImage/extension.js
index cefedfb4c..11dae6790 100644
--- a/data/ext/viewerImage/extension.js
+++ b/data/ext/viewerImage/extension.js
@@ -5,38 +5,42 @@
define(function(require, exports, module) {
"use strict";
-exports.id = "viewerImage"; // ID should be equal to the directory name where the ext. is located
-exports.title = "Image Viewer";
-exports.type = "viewer";
-exports.supportedFileTypes = [ "jpeg", "jpg", "png", "gif", "bmp" ];
-
-var extensionDirectory = TSSETTINGS.getExtensionPath()+"/"+exports.id;
-
-exports.init = function(filePath, elementID) {
- console.debug("Initalization Browser Image Viewer...");
- filePath = "file:///"+filePath;
-
- $('#'+elementID).append($('<img>', {
- id: "imgViewer",
- src: filePath
- }));
-
-// TODO croppr integration
-// require([extensionDirectory+'/croppr.js'], function() {
-//
-// });
-}
-
-exports.viewerMode = function(isViewerMode) {
- console.debug("viewerMode not supported on this extension");
-}
-
-exports.setContent = function(content) {
- console.debug("setContent not supported on this extension");
-}
-
-exports.getContent = function() {
- console.debug("getContent not supported on this extension");
-}
+ console.debug("Loading viewerImage");
+
+ exports.id = "viewerImage"; // ID should be equal to the directory name where the ext. is located
+ exports.title = "Image Viewer";
+ exports.type = "viewer";
+ exports.supportedFileTypes = [ "jpeg", "jpg", "png", "gif", "bmp" ];
+
+ var TSCORE = require("tscore");
+
+ var extensionDirectory = TSCORE.Config.getExtensionPath()+"/"+exports.id;
+
+ exports.init = function(filePath, elementID) {
+ console.debug("Initalization Browser Image Viewer...");
+ filePath = "file:///"+filePath;
+
+ $('#'+elementID).append($('<img>', {
+ id: "imgViewer",
+ src: filePath
+ }));
+
+ // TODO croppr integration
+ // require([extensionDirectory+'/croppr.js'], function() {
+ //
+ // });
+ }
+
+ exports.viewerMode = function(isViewerMode) {
+ console.debug("viewerMode not supported on this extension");
+ }
+
+ exports.setContent = function(content) {
+ console.debug("setContent not supported on this extension");
+ }
+
+ exports.getContent = function() {
+ console.debug("getContent not supported on this extension");
+ }
});
\ No newline at end of file
diff --git a/data/ext/viewerMD/extension.js b/data/ext/viewerMD/extension.js
index 62d9c622a..e608d5863 100644
--- a/data/ext/viewerMD/extension.js
+++ b/data/ext/viewerMD/extension.js
@@ -5,42 +5,46 @@
define(function(require, exports, module) {
"use strict";
-exports.id = "viewerMD"; // ID should be equal to the directory name where the ext. is located
-exports.title = "MD Viewer";
-exports.type = "editor";
-exports.supportedFileTypes = [ "md", "markdown", "mdown" ];
-
-var md2htmlConverter = undefined;
-var containerElID = undefined;
-
-var extensionDirectory = TSSETTINGS.getExtensionPath()+"/"+exports.id;
-
-exports.init = function(filePath, containerElementID) {
- console.debug("Initalization MD Viewer...");
- containerElID = containerElementID;
- // TODO create a css namespace for the specific styles
-// require(['css!'+extensionDirectory+'/bootstrapLite.css']);
- require([extensionDirectory+'/showdown/showdown.js'], function() {
- md2htmlConverter = new Showdown.converter();
- IOAPI.loadTextFile(filePath);
- });
-}
-
-exports.setFileType = function(fileType) {
- console.debug("setFileType not supported on this extension");
-}
-
-exports.viewerMode = function(isViewerMode) {
- // set readonly
-}
-
-exports.setContent = function(content) {
- var html = md2htmlConverter.makeHtml(content);
- $('#'+containerElID).append(html);
-}
-
-exports.getContent = function() {
- $('#'+containerElID).html();
-}
+ console.debug("Loading viewerMD");
+
+ exports.id = "viewerMD"; // ID should be equal to the directory name where the ext. is located
+ exports.title = "MD Viewer";
+ exports.type = "editor";
+ exports.supportedFileTypes = [ "md", "markdown", "mdown" ];
+
+ var TSCORE = require("tscore");
+
+ var md2htmlConverter = undefined;
+ var containerElID = undefined;
+
+ var extensionDirectory = TSCORE.Config.getExtensionPath()+"/"+exports.id;
+
+ exports.init = function(filePath, containerElementID) {
+ console.debug("Initalization MD Viewer...");
+ containerElID = containerElementID;
+ // TODO create a css namespace for the specific styles
+ // require(['css!'+extensionDirectory+'/bootstrapLite.css']);
+ require([extensionDirectory+'/showdown/showdown.js'], function() {
+ md2htmlConverter = new Showdown.converter();
+ TSCORE.IO.loadTextFile(filePath);
+ });
+ }
+
+ exports.setFileType = function(fileType) {
+ console.debug("setFileType not supported on this extension");
+ }
+
+ exports.viewerMode = function(isViewerMode) {
+ // set readonly
+ }
+
+ exports.setContent = function(content) {
+ var html = md2htmlConverter.makeHtml(content);
+ $('#'+containerElID).append(html);
+ }
+
+ exports.getContent = function() {
+ $('#'+containerElID).html();
+ }
});
\ No newline at end of file
diff --git a/data/js/core.api.js b/data/js/core.api.js
index 766f3077b..a9c028332 100644
--- a/data/js/core.api.js
+++ b/data/js/core.api.js
@@ -1,47 +1,59 @@
/* Copyright (c) 2012 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([
- 'require',
- 'exports',
- 'module',
-],function(require, exports, module) {
+define(function(require, exports, module) {
"use strict";
-console.debug("Loading core.api.js ...");
-
-var UIAPI = (typeof UIAPI == 'object' && UIAPI != null) ? UIAPI : {};
-
-var TSSETTINGS = require("tssetting");
-
-var layoutContainer = undefined;
-
-UIAPI.updateSubDirs = undefined;
-UIAPI.initFavorites = undefined;
-UIAPI.generateTagGroups = undefined;
+ console.debug("Loading core.api.js ...");
+
+ var TSSETTINGS = require("tssetting");
+ var IOAPI = require("tsioapi");
+
+ var tsPersManager = require("tspersmanager");
+ var tsTagUtils = require("tstagutils");
+ var tsFileOpener = require("tsfileopener");
+ var tsTagsUI = require("tstagsui");
+ var tsDirectoriesUI = require("tsdirectoriesui");
+ var tsCoreUI = require("tscoreui")
+
+ var layoutContainer = undefined;
+
+ exports.updateSubDirs = undefined;
+ exports.initFavorites = undefined;
+ exports.generateTagGroups = undefined;
+
+ var currentPath = "";
+
+ var currentView = undefined;
+
+ // Current selected files
+ var selectedFiles = [];
+
+ // True if a file is opened in the viewer
+ var isFileOpened = false;
+
+ // Current directory list of files
+ var fileList = [];
+
+ // Last clicked button for removing a tag
+ var selectedTag = "";
+
+ var selectedTagData = "";
-UIAPI.initApp = function() {
- console.debug("InitApplication");
+ function initApp() {
+ console.debug("Init application");
+
+ exports.ViewManager = tsPersManager;
+ exports.TagUtils = tsTagUtils;
+ exports.FileOpener = tsFileOpener;
- require([
- "tstagsui",
- "tsdirectoriesui",
- "tspersmanager",
- "tstagutils",
- "tsfileopener",
- "tscoreui"
- ],
- function(
- tsTagsUI,
- tsDirectoriesUI,
- tsPersManager,
- tsTagUtils,
- tsFileOpener,
- tsCoreUI
- ) {
- UIAPI.ViewManager = tsPersManager;
- UIAPI.TagUtils = tsTagUtils;
- UIAPI.FileOpener = tsFileOpener;
+ exports.Config = TSSETTINGS;
+ exports.IO = IOAPI;
+
+ // Proxy for tsTagsUI
+ exports.generateTagButtons = tsTagsUI.generateTagButtons
+ exports.buttonizeTitle = tsTagsUI.buttonizeTitle
+ exports.openTagMenu = tsTagsUI.openTagMenu
tsCoreUI.initButtons();
tsCoreUI.initDialogs();
@@ -54,9 +66,9 @@ UIAPI.initApp = function() {
tsDirectoriesUI.initContextMenus();
// Proxying directoriesUI and tagsUI
- UIAPI.updateSubDirs = tsDirectoriesUI.updateSubDirs;
- UIAPI.initFavorites = tsDirectoriesUI.initFavorites;
- UIAPI.generateTagGroups = tsTagsUI.generateTagGroups;
+ exports.updateSubDirs = tsDirectoriesUI.updateSubDirs;
+ exports.initFavorites = tsDirectoriesUI.initFavorites;
+ exports.generateTagGroups = tsTagsUI.generateTagGroups;
TSSETTINGS.loadSettingsLocalStorage();
@@ -75,7 +87,7 @@ UIAPI.initApp = function() {
TSSETTINGS.upgradeSettings();
// Init views
- UIAPI.ViewManager.initViews();
+ exports.ViewManager.initViews();
$("#appVersion").text("["+TSSETTINGS.DefaultSettings["appVersion"]+"]");
$("#appVersion").attr("title","["+TSSETTINGS.DefaultSettings["appBuild"]+"]");
@@ -87,272 +99,271 @@ UIAPI.initApp = function() {
$( "#loading" ).hide();
$( "#container" ).show();
- UIAPI.hideLoadingAnimation();
+ hideLoadingAnimation();
// TODO check if document.ready is really needed
$(document).ready(function() {
- UIAPI.initLayout();
+ initLayout();
console.debug("Layout initialized");
});
// Show start hint
$( "#selectTagSpace" ).tooltip( "open" );
-
- });
-
-}
-
-// ONE_DIR_UP
-UIAPI.parentDir = "..";
-
-UIAPI.currentPath = "";
-
-UIAPI.currentView = undefined;
-
-// Current selected files
-UIAPI.selectedFiles = [];
-
-// True if a file is opened in the viewer
-UIAPI.isFileOpened = false;
-
-// Current directory list of files
-UIAPI.fileList = [];
-
-// Last clicked button for removing a tag
-UIAPI.selectedTag = "";
-
-UIAPI.selectedTagData = "";
-
-UIAPI.IO = undefined;
-
-UIAPI.setCurrentPath = function(path) {
- console.debug("Setting current path to: "+path);
- UIAPI.currentPath = path;
+ }
- // List preselected dir automatically
- IOAPI.listDirectory(UIAPI.currentPath);
-}
-
-UIAPI.updateLogger = function(message) {
- console.debug("Updating logger...");
- $("#footer").attr("value",message);
-}
-
-UIAPI.showLoadingAnimation = function(message) {
- $("#loadingAnimation").css('visibility', "visible");
-}
-
-UIAPI.hideLoadingAnimation = function(message) {
- $("#loadingAnimation").css('visibility', "hidden");
-}
-
-UIAPI.fileExists = function(fileName) {
- console.debug("Check if filename: "+fileName+" already exists.");
- for (var i=0; i < UIAPI.fileList.length; i++) {
- if(UIAPI.fileList[i].name == fileName) {
- return true;
- }
- }
- return false;
-}
-
-UIAPI.refreshFileListContainer = function() {
- // TODO what happens with search view
- IOAPI.listDirectory(UIAPI.currentPath);
-}
-
-UIAPI.updateFileBrowserData = function(dirList) {
- console.debug("Updating the file browser data...");
-
- UIAPI.fileList = [];
- var tags = undefined;
- var ext = undefined;
- var title = undefined;
- var fileSize = undefined;
- var fileLMDT = undefined;
- var path = undefined;
- // Sort the dir list alphabetically before displaying
- // TODO sorting files not working correctly
- dirList.sort(function(a,b) { return a.name.localeCompare(b.name); });
- for (var i=0; i < dirList.length; i++) {
- if (dirList[i].type == "file"){
- // Considering Unix HiddenEntries (. in the beginning)
- if (TSSETTINGS.Settings["showUnixHiddenEntries"] ||
- (!TSSETTINGS.Settings["showUnixHiddenEntries"] && (dirList[i].name.indexOf(".") != 0))) {
- path = UIAPI.currentPath + UIAPI.TagUtils.DIR_SEPARATOR + dirList[i].name;
- tags = UIAPI.TagUtils.extractTags(path);
- title = UIAPI.TagUtils.extractTitle(path);
- if(dirList[i].name.lastIndexOf(".") > 0) {
- // title = dirList[i].name.substring(0, dirList[i].name.lastIndexOf("."));
- ext = dirList[i].name.substring(dirList[i].name.lastIndexOf(".")+1,dirList[i].name.length);
- } else {
- // title = dirList[i].name;
- ext = "";
- }
- fileSize = dirList[i].size;
- fileLMDT = dirList[i].lmdt;
- if(fileSize == undefined) fileSize = "";
- if(fileLMDT == undefined) fileLMDT = "";
- var entry = [dirList[i].name,fileSize,fileLMDT,title,tags,ext];
- UIAPI.fileList.push(entry);
- }
- }
- }
-
- UIAPI.ViewManager.changeView(UIAPI.currentView);
-}
-
-UIAPI.changeDirectory = function(newDir) {
- console.debug("Change direcotory to: "+newDir);
- var newPath = UIAPI.currentPath;
- if(UIAPI.TagUtils.isWindows()) {
- // Cutting trailig \\ or \\\\ .
- if(UIAPI.currentPath.lastIndexOf("\\")+1 == UIAPI.currentPath.length) {
- newPath = UIAPI.currentPath.substring(0,UIAPI.currentPath.length-1);
- } else if(UIAPI.currentPath.lastIndexOf("\\\\")+2 == UIAPI.currentPath.length) {
- newPath = UIAPI.currentPath.substring(0,UIAPI.currentPath.length-2);
- }
- if(newDir == UIAPI.parentDir) {
- newPath = newPath.substring(0,newPath.lastIndexOf("\\"));
- UIAPI.currentPath = newPath;
- } else if(newDir.length > 0) {
- UIAPI.currentPath = newPath+"\\"+newDir+"\\";
- }
- } else {
- // Cutting trailing /
- if(UIAPI.currentPath.lastIndexOf("/")+1 == UIAPI.currentPath.length) {
- newPath = UIAPI.currentPath.substring(0,UIAPI.currentPath.length-1);
- }
- if(newDir == UIAPI.parentDir) {
- newPath = newPath.substring(0,newPath.lastIndexOf("/"));
- UIAPI.currentPath = newPath;
- } else if(newDir.length > 0) {
- UIAPI.currentPath = newPath+"/"+newDir+"/";
- }
- }
- console.debug("New path: "+UIAPI.currentPath);
- IOAPI.listDirectory(UIAPI.currentPath);
- UIAPI.selectedTag = "";
-}
-
-UIAPI.reloadUI = function() {
- location.reload();
-}
-
-UIAPI.openFile = function(filePath) {
-// console.debug("Opening file...");
- UIAPI.FileOpener.openFile(filePath);
-}
-
-UIAPI.openFileViewer = function() {
- UIAPI.isFileOpened = true;
- layoutContainer.open("east");
-}
-
-UIAPI.closeFileViewer = function() {
- UIAPI.isFileOpened = false;
- layoutContainer.close("east");
-}
-
-UIAPI.toggleLeftPanel = function() {
- layoutContainer.toggle("west");
-}
-
-UIAPI.initLayout = function(){
- console.debug("Initializing Layout...");
-
- layoutContainer = $('#container').layout(
- {
- fxName: "none"
-
- // some resizing/toggling settings
- , north__resizable: false // OVERRIDE the pane-default of 'slidable=true'
- , north__spacing_open: 0 // no resizer-bar when open (zero height)
- // , north__togglerLength_closed: '100%' // toggle-button is full-width of resizer-bar
- // , north__spacing_closed: 20 // big resizer-bar when open (zero height)
- , north__size: 33
-
- , south__resizable: false // OVERRIDE the pane-default of 'resizable=true'
- , south__spacing_open: 0 // no resizer-bar when open (zero height)
- // , south__spacing_closed: 20 // big resizer-bar when open (zero height)
-
- // west settings
- , west__resizable: true
- , west__minSize: .1
-// , west__maxSize: .4
- , west__size: 200
- , west__spacing_open: 5
-
- // east settings
- , east__resizable: true
- , east__size: .45
- , east__minSize: .2
-// , east__maxSize: .8 // 80% of layout width
- , east__spacing_open: 5
-
- // center settings
- , center__resizable: true
- , center__minSize: 0.5
-
- // enable showOverflow on west-pane so CSS popups will overlap north pane
- , west__showOverflowOnHover: true
-
- // enable state management
- , stateManagement__enabled: false // automatic cookie load & save enabled by default
-
- , showDebugMessages: true // log and/or display messages from debugging & testing code
- }
-
- );
-
- // Directories and Tags
- var westLayout = $('div.ui-layout-west').layout({
- minSize: 50 // ALL panes
- , center__paneSelector: ".west-center"
- , south__paneSelector: ".west-south"
- , south__resizable: true
- , south__size: .5
- , south__spacing_open: 5
- });
-
- var centerLayout = $('div.ui-layout-center').layout({
- name: "middle"
- , north__paneSelector: ".middle-north"
- , center__paneSelector: ".middle-center"
- , south__paneSelector: ".middle-south"
- , minSize: 0 // ALL panes
- , center__minSize: 300
- , north__size: 32
- , north__resizable: false
- , north__spacing_open: 0
- , south__spacing_open: 0
- , south__size: 1
- });
-
- // File Viewer / Editor
- var eastLayout = $('div.ui-layout-east').layout({
- minSize: 30 // ALL panes
- , north__paneSelector: ".east-north"
- , center__paneSelector: ".east-center"
- , south__paneSelector: ".east-south"
- , north__size: 80
- , north__resizable: false
- , north__spacing_open: 0
- , south__size: 25
- , south__spacing_open: 0
- });
-
- var dirNavigationLayout = $('#directoryNavigator').layout({
- minSize: 30 // ALL panes
- , north__paneSelector: "#directoryNavigatorNorth"
- , center__paneSelector: "#dirTree"
- , north__size: 30
- , north__resizable: false
- , north__spacing_open: 0
- });
-
- // Closes the viewer area by init
- layoutContainer.close("east");
-}
-
-return UIAPI;
+ function setCurrentPath(path) {
+ console.debug("Setting current path to: "+path);
+ currentPath = path;
+
+ // List preselected dir automatically
+ IOAPI.listDirectory(currentPath);
+ }
+
+ function updateLogger(message) {
+ // TODO reactivate
+ console.debug("Updating logger...");
+ // $("#footer").attr("value",message);
+ }
+
+ function showLoadingAnimation(message) {
+ $("#loadingAnimation").css('visibility', "visible");
+ }
+
+ function hideLoadingAnimation(message) {
+ $("#loadingAnimation").css('visibility', "hidden");
+ }
+
+ function fileExists(fileName) {
+ console.debug("Check if filename: "+fileName+" already exists.");
+ for (var i=0; i < fileList.length; i++) {
+ if(fileList[i].name == fileName) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ function refreshFileListContainer() {
+ // TODO what happens with search view
+ IOAPI.listDirectory(currentPath);
+ }
+
+ function updateFileBrowserData(dirList) {
+ console.debug("Updating the file browser data...");
+
+ fileList = [];
+ var tags = undefined;
+ var ext = undefined;
+ var title = undefined;
+ var fileSize = undefined;
+ var fileLMDT = undefined;
+ var path = undefined;
+ // Sort the dir list alphabetically before displaying
+ // TODO sorting files not working correctly
+ dirList.sort(function(a,b) { return a.name.localeCompare(b.name); });
+ for (var i=0; i < dirList.length; i++) {
+ if (dirList[i].type == "file"){
+ // Considering Unix HiddenEntries (. in the beginning)
+ if (TSSETTINGS.Settings["showUnixHiddenEntries"] ||
+ (!TSSETTINGS.Settings["showUnixHiddenEntries"] && (dirList[i].name.indexOf(".") != 0))) {
+ path = currentPath + exports.TagUtils.DIR_SEPARATOR + dirList[i].name;
+ tags = exports.TagUtils.extractTags(path);
+ title = exports.TagUtils.extractTitle(path);
+ if(dirList[i].name.lastIndexOf(".") > 0) {
+ ext = dirList[i].name.substring(dirList[i].name.lastIndexOf(".")+1,dirList[i].name.length);
+ } else {
+ ext = "";
+ }
+ fileSize = dirList[i].size;
+ fileLMDT = dirList[i].lmdt;
+ if(fileSize == undefined) fileSize = "";
+ if(fileLMDT == undefined) fileLMDT = "";
+ var entry = [dirList[i].name,fileSize,fileLMDT,title,tags,ext];
+ fileList.push(entry);
+ }
+ }
+ }
+
+ exports.ViewManager.changeView(currentView);
+ }
+
+ /** Depricated
+ // ONE_DIR_UP
+ var parentDir = "..";
+
+ function changeDirectory(newDir) {
+ console.debug("Change direcotory to: "+newDir);
+ var newPath = currentPath;
+ if(exports.TagUtils.isWindows()) {
+ // Cutting trailig \\ or \\\\ .
+ if(currentPath.lastIndexOf("\\")+1 == currentPath.length) {
+ newPath = currentPath.substring(0,currentPath.length-1);
+ } else if(currentPath.lastIndexOf("\\\\")+2 == currentPath.length) {
+ newPath = currentPath.substring(0,currentPath.length-2);
+ }
+ if(newDir == parentDir) {
+ newPath = newPath.substring(0,newPath.lastIndexOf("\\"));
+ currentPath = newPath;
+ } else if(newDir.length > 0) {
+ currentPath = newPath+"\\"+newDir+"\\";
+ }
+ } else {
+ // Cutting trailing /
+ if(currentPath.lastIndexOf("/")+1 == currentPath.length) {
+ newPath = currentPath.substring(0,currentPath.length-1);
+ }
+ if(newDir == parentDir) {
+ newPath = newPath.substring(0,newPath.lastIndexOf("/"));
+ currentPath = newPath;
+ } else if(newDir.length > 0) {
+ currentPath = newPath+"/"+newDir+"/";
+ }
+ }
+ console.debug("New path: "+currentPath);
+ IOAPI.listDirectory(currentPath);
+ selectedTag = "";
+ } */
+
+ function reloadUI() {
+ location.reload();
+ }
+
+ function openFile(filePath) {
+ // console.debug("Opening file...");
+ exports.FileOpener.openFile(filePath);
+ }
+
+ function openFileViewer() {
+ isFileOpened = true;
+ layoutContainer.open("east");
+ }
+
+ function closeFileViewer() {
+ isFileOpened = false;
+ layoutContainer.close("east");
+ }
+
+ function toggleLeftPanel() {
+ layoutContainer.toggle("west");
+ }
+
+ function initLayout (){
+ console.debug("Initializing Layout...");
+
+ layoutContainer = $('#container').layout(
+ {
+ fxName: "none"
+
+ // some resizing/toggling settings
+ , north__resizable: false // OVERRIDE the pane-default of 'slidable=true'
+ , north__spacing_open: 0 // no resizer-bar when open (zero height)
+ // , north__togglerLength_closed: '100%' // toggle-button is full-width of resizer-bar
+ // , north__spacing_closed: 20 // big resizer-bar when open (zero height)
+ , north__size: 33
+
+ , south__resizable: false // OVERRIDE the pane-default of 'resizable=true'
+ , south__spacing_open: 0 // no resizer-bar when open (zero height)
+ // , south__spacing_closed: 20 // big resizer-bar when open (zero height)
+
+ // west settings
+ , west__resizable: true
+ , west__minSize: .1
+ // , west__maxSize: .4
+ , west__size: 200
+ , west__spacing_open: 5
+
+ // east settings
+ , east__resizable: true
+ , east__size: .45
+ , east__minSize: .2
+ // , east__maxSize: .8 // 80% of layout width
+ , east__spacing_open: 5
+
+ // center settings
+ , center__resizable: true
+ , center__minSize: 0.5
+
+ // enable showOverflow on west-pane so CSS popups will overlap north pane
+ , west__showOverflowOnHover: true
+
+ // enable state management
+ , stateManagement__enabled: false // automatic cookie load & save enabled by default
+
+ , showDebugMessages: true // log and/or display messages from debugging & testing code
+ }
+
+ );
+
+ // Directories and Tags
+ var westLayout = $('div.ui-layout-west').layout({
+ minSize: 50 // ALL panes
+ , center__paneSelector: ".west-center"
+ , south__paneSelector: ".west-south"
+ , south__resizable: true
+ , south__size: .5
+ , south__spacing_open: 5
+ });
+
+ var centerLayout = $('div.ui-layout-center').layout({
+ name: "middle"
+ , north__paneSelector: ".middle-north"
+ , center__paneSelector: ".middle-center"
+ , south__paneSelector: ".middle-south"
+ , minSize: 0 // ALL panes
+ , center__minSize: 300
+ , north__size: 32
+ , north__resizable: false
+ , north__spacing_open: 0
+ , south__spacing_open: 0
+ , south__size: 1
+ });
+
+ // File Viewer / Editor
+ var eastLayout = $('div.ui-layout-east').layout({
+ minSize: 30 // ALL panes
+ , north__paneSelector: ".east-north"
+ , center__paneSelector: ".east-center"
+ , south__paneSelector: ".east-south"
+ , north__size: 80
+ , north__resizable: false
+ , north__spacing_open: 0
+ , south__size: 25
+ , south__spacing_open: 0
+ });
+
+ var dirNavigationLayout = $('#directoryNavigator').layout({
+ minSize: 30 // ALL panes
+ , north__paneSelector: "#directoryNavigatorNorth"
+ , center__paneSelector: "#dirTree"
+ , north__size: 30
+ , north__resizable: false
+ , north__spacing_open: 0
+ });
+
+ // Closes the viewer area by init
+ layoutContainer.close("east");
+ }
+
+ // Public API definition
+ exports.initApp = initApp;
+ exports.setCurrentPath = setCurrentPath;
+ exports.updateLogger = updateLogger;
+ exports.showLoadingAnimation = showLoadingAnimation;
+ exports.hideLoadingAnimation = hideLoadingAnimation;
+ exports.fileExists = fileExists;
+ exports.refreshFileListContainer = refreshFileListContainer;
+ exports.updateFileBrowserData = updateFileBrowserData;
+ exports.reloadUI = reloadUI;
+ exports.openFile = openFile;
+ exports.openFileViewer = openFileViewer;
+ exports.closeFileViewer = closeFileViewer;
+ exports.toggleLeftPanel = toggleLeftPanel;
+
+ exports.currentPath = currentPath;
+ exports.currentView = currentView;
+ exports.selectedFiles = selectedFiles;
+ exports.isFileOpened = isFileOpened;
+ exports.fileList = fileList;
+ exports.selectedTag = selectedTag;
+ exports.selectedTagData = selectedTagData;
+
});
\ No newline at end of file
diff --git a/data/js/core.ui.js b/data/js/core.ui.js
index 33967fab5..fe1686ea5 100644
--- a/data/js/core.ui.js
+++ b/data/js/core.ui.js
@@ -1,16 +1,13 @@
/* Copyright (c) 2012 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([
- 'require',
- 'exports',
- 'module',
- 'jsoneditor',
-// 'css!jsoneditorcss'
-],function(require, exports, module) {
+define(function(require, exports, module) {
"use strict";
-console.debug("Loading core.ui.js ...");
+ console.debug("Loading core.ui.js ...");
+
+ require('jsoneditor');
+ var TSCORE = require("tscore");
var editor = undefined; // Needed for JSON Editor
var formatter = undefined;
@@ -52,7 +49,7 @@ console.debug("Loading core.ui.js ...");
}
})
.click(function() {
- UIAPI.toggleLeftPanel();
+ TSCORE.toggleLeftPanel();
});
}
@@ -102,7 +99,7 @@ console.debug("Loading core.ui.js ...");
$( "#txtFileTypeButton" ).click(function() {
// TODO Add to config options
- fileContent = TSSETTINGS.getNewTextFileContent();
+ fileContent = TSCORE.Config.getNewTextFileContent();
//Leave the filename as it is by no extension
if(newFileName.val().lastIndexOf(".")>=0) {
newFileName.val(newFileName.val().substring(0,newFileName.val().lastIndexOf("."))+".txt");
@@ -111,7 +108,7 @@ console.debug("Loading core.ui.js ...");
$( "#htmlFileTypeButton" ).click(function() {
// TODO Add to config options
- fileContent = TSSETTINGS.getNewHTMLFileContent();
+ fileContent = TSCORE.Config.getNewHTMLFileContent();
//Leave the filename as it is by no extension
if(newFileName.val().lastIndexOf(".")>=0) {
newFileName.val(newFileName.val().substring(0,newFileName.val().lastIndexOf("."))+".html");
@@ -120,7 +117,7 @@ console.debug("Loading core.ui.js ...");
$( "#mdFileTypeButton" ).click(function() {
// TODO Add to config options
- fileContent = TSSETTINGS.getNewMDFileContent();
+ fileContent = TSCORE.Config.getNewMDFileContent();
//Leave the filename as it is by no extension
if(newFileName.val().lastIndexOf(".")>=0) {
newFileName.val(newFileName.val().substring(0,newFileName.val().lastIndexOf("."))+".md");
@@ -139,14 +136,14 @@ console.debug("Loading core.ui.js ...");
bValid = bValid && checkLength( newFileName, "filename", 4, 200 );
// bValid = bValid && checkRegexp( renamedFileName, /^[a-z]([0-9a-z_.])+$/i, "Filename may consist of a-z, 0-9, underscores, begin with a letter." );
- if(UIAPI.fileExists(newFileName.val())) {
+ if(TSCORE.fileExists(newFileName.val())) {
updateTips("File already exists.");
bValid = false;
}
if ( bValid ) {
- IOAPI.saveTextFile(UIAPI.currentPath+UIAPI.TagUtils.DIR_SEPARATOR+$( "#newFileName" ).val(),fileContent);
+ TSCORE.IO.saveTextFile(TSCORE.currentPath+TSCORE.TagUtils.DIR_SEPARATOR+$( "#newFileName" ).val(),fileContent);
$( this ).dialog( "close" );
- IOAPI.listDirectory(UIAPI.currentPath);
+ TSCORE.IO.listDirectory(TSCORE.currentPath);
}
},
Cancel: function() {
@@ -157,7 +154,7 @@ console.debug("Loading core.ui.js ...");
allFields.val( "" ).removeClass( "ui-state-error" );
},
open: function() {
- fileContent = TSSETTINGS.getNewTextFileContent(); // Default new file in text file
+ fileContent = TSCORE.Config.getNewTextFileContent(); // Default new file in text file
$( "#newFileName" ).val(".txt");
}
});
@@ -175,10 +172,10 @@ console.debug("Loading core.ui.js ...");
bValid = bValid && checkLength( renamedFileName, "filename", 3, 200 );
// bValid = bValid && checkRegexp( renamedFileName, /^[a-z]([0-9a-z_.])+$/i, "Filename may consist of a-z, 0-9, underscores, begin with a letter." );
if ( bValid ) {
- var containingDir = UIAPI.TagUtils.extractContainingDirectoryPath(UIAPI.selectedFiles[0]);
- IOAPI.renameFile(
- UIAPI.selectedFiles[0],
- containingDir+UIAPI.TagUtils.DIR_SEPARATOR+renamedFileName.val()
+ var containingDir = TSCORE.TagUtils.extractContainingDirectoryPath(TSCORE.selectedFiles[0]);
+ TSCORE.IO.renameFile(
+ TSCORE.selectedFiles[0],
+ containingDir+TSCORE.TagUtils.DIR_SEPARATOR+renamedFileName.val()
);
$( this ).dialog( "close" );
}
@@ -191,7 +188,7 @@ console.debug("Loading core.ui.js ...");
allFields.val( "" ).removeClass( "ui-state-error" );
},
open: function() {
- $( "#renamedFileName" ).val(UIAPI.TagUtils.extractFileName(UIAPI.selectedFiles[0]));
+ $( "#renamedFileName" ).val(TSCORE.TagUtils.extractFileName(TSCORE.selectedFiles[0]));
}
});
@@ -202,9 +199,9 @@ console.debug("Loading core.ui.js ...");
modal: true,
buttons: {
"Delete all items": function() {
- IOAPI.deleteElement(UIAPI.selectedFiles[0]);
+ TSCORE.IO.deleteElement(TSCORE.selectedFiles[0]);
$( this ).dialog( "close" );
- IOAPI.listDirectory(UIAPI.currentPath);
+ TSCORE.IO.listDirectory(TSCORE.currentPath);
},
Cancel: function() {
$( this ).dialog( "close" );
@@ -220,7 +217,7 @@ console.debug("Loading core.ui.js ...");
buttons: {
"Add tags": function() {
var tags = $("#tags").val().split(",");
- UIAPI.TagUtils.addTag(UIAPI.selectedFiles, tags);
+ TSCORE.TagUtils.addTag(TSCORE.selectedFiles, tags);
$( this ).dialog( "close" );
},
Cancel: function() {
@@ -249,7 +246,7 @@ console.debug("Loading core.ui.js ...");
source: function( request, response ) {
// delegate back to autocomplete, but extract the last term
response( $.ui.autocomplete.filter(
- TSSETTINGS.getAllTags(), extractLast( request.term ) ) );
+ TSCORE.Config.getAllTags(), extractLast( request.term ) ) );
},
focus: function() {
// prevent value inserted on focus
@@ -273,11 +270,11 @@ console.debug("Loading core.ui.js ...");
$( "#tagTypeRadio" ).buttonset();
$( "#plainTagTypeButton" ).click(function() {
- UIAPI.selectedTag, $( "#newTag" ).datepicker( "destroy" ).val("");
+ TSCORE.selectedTag, $( "#newTag" ).datepicker( "destroy" ).val("");
});
$( "#dateTagTypeButton" ).click(function() {
- UIAPI.selectedTag, $( "#newTag" ).datepicker({
+ TSCORE.selectedTag, $( "#newTag" ).datepicker({
showWeek: true,
firstDay: 1,
dateFormat: "yymmdd"
@@ -285,7 +282,7 @@ console.debug("Loading core.ui.js ...");
});
$( "#currencyTagTypeButton" ).click(function() {
- UIAPI.selectedTag, $( "#newTag" ).datepicker( "destroy" ).val("XEUR")
+ TSCORE.selectedTag, $( "#newTag" ).datepicker( "destroy" ).val("XEUR")
});
$( "#dialogEditTag" ).dialog({
@@ -295,8 +292,8 @@ console.debug("Loading core.ui.js ...");
modal: true,
buttons: {
"Save": function() {
- UIAPI.TagUtils.renameTag(UIAPI.selectedFiles[0], UIAPI.selectedTag, $( "#newTag" ).val());
- IOAPI.listDirectory(UIAPI.currentPath);
+ TSCORE.TagUtils.renameTag(TSCORE.selectedFiles[0], TSCORE.selectedTag, $( "#newTag" ).val());
+ TSCORE.IO.listDirectory(TSCORE.currentPath);
$( this ).dialog( "close" );
},
Cancel: function() {
@@ -332,7 +329,7 @@ console.debug("Loading core.ui.js ...");
modal: true,
buttons: {
// "Ext. Folder": function() {
- // IOAPI.openExtensionsDirectory()
+ // TSCORE.IO.openExtensionsDirectory()
// },
"Editor": function() {
if($("#settingsEditor").is(":hidden") ) {
@@ -350,16 +347,16 @@ console.debug("Loading core.ui.js ...");
},
"Default Settings": function() {
if(confirm("Are you sure you want to restore the default application settings?\nAll manually made changes such as tags and taggroups will be lost.")) {
- TSSETTINGS.Settings = TSSETTINGS.DefaultSettings;
- TSSETTINGS.saveSettings();
- UIAPI.reloadUI();
+ TSCORE.Config.Settings = TSCORE.Config.DefaultSettings;
+ TSCORE.Config.saveSettings();
+ TSCORE.reloadUI();
console.debug("Default settings loaded.");
}
},
"Save": function() {
- TSSETTINGS.Settings = editor.get();
- TSSETTINGS.saveSettings();
- UIAPI.reloadUI();
+ TSCORE.Config.Settings = editor.get();
+ TSCORE.Config.saveSettings();
+ TSCORE.reloadUI();
console.debug("Settings saved and UI reloaded.");
$( this ).dialog( "close" );
},
@@ -369,7 +366,7 @@ console.debug("Loading core.ui.js ...");
},
open: function() {
$("#settingsPlainJSON").hide();
- editor.set(TSSETTINGS.Settings);
+ editor.set(TSCORE.Config.Settings);
}
});
}
diff --git a/data/js/directories.ui.js b/data/js/directories.ui.js
index cf700f51c..e1e014b37 100644
--- a/data/js/directories.ui.js
+++ b/data/js/directories.ui.js
@@ -1,14 +1,12 @@
/* Copyright (c) 2012 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([
- 'require',
- 'exports',
- 'module',
-],function(require, exports, module) {
+define(function(require, exports, module) {
"use strict";
console.debug("Loading DirectoriesUI...");
+
+ var TSCORE = require("tscore");
var directoryHistory = [];
@@ -19,7 +17,7 @@ define([
function openFavorite(path, title) {
console.debug("Opening favorite in : "+path+" title: "+title);
- document.title = title + " | " + TSSETTINGS.DefaultSettings.appName;
+ document.title = title + " | " + TSCORE.Config.DefaultSettings.appName;
$( "#reloadTagSpace" ).button({
label: title
@@ -33,13 +31,13 @@ define([
// Updates the directory subtree
function updateSubDirs(dirList) {
- console.debug("Updating subdirs(UIAPI)..."+JSON.stringify(dirList));
+ console.debug("Updating subdirs(TSCORE)..."+JSON.stringify(dirList));
// Sort the dirList alphabetically
dirList.sort(function(a,b) { return a.title.localeCompare(b.title); });
for(var i=0; i < directoryHistory.length; i++) {
- if(directoryHistory[i].key == UIAPI.currentPath) {
+ if(directoryHistory[i].key == TSCORE.currentPath) {
directoryHistory[i]["children"] = new Array();
for(var j=0; j < dirList.length; j++) {
directoryHistory[i]["children"].push(dirList[j]);
@@ -87,10 +85,10 @@ define([
hoverClass: "dirButtonActive",
drop: function( event, ui ) {
var filePath = ui.draggable.attr("filepath");
- var fileName = UIAPI.TagUtils.extractFileName(filePath);
+ var fileName = TSCORE.TagUtils.extractFileName(filePath);
var targetDir = $(this).attr("key");
console.log("Moving file: "+filePath+" to "+targetDir);
- IOAPI.renameFile(filePath, targetDir+UIAPI.TagUtils.DIR_SEPARATOR+fileName);
+ TSCORE.IO.renameFile(filePath, targetDir+TSCORE.TagUtils.DIR_SEPARATOR+fileName);
}
})
.click(function() {
@@ -130,10 +128,10 @@ define([
hoverClass: "dirButtonActive",
drop: function( event, ui ) {
var filePath = ui.draggable.attr("filepath");
- var fileName = UIAPI.TagUtils.extractFileName(filePath);
+ var fileName = TSCORE.TagUtils.extractFileName(filePath);
var targetDir = $(this).attr("key");
console.log("Moving file: "+filePath+" to "+targetDir);
- IOAPI.renameFile(filePath, targetDir+UIAPI.TagUtils.DIR_SEPARATOR+fileName);
+ TSCORE.IO.renameFile(filePath, targetDir+TSCORE.TagUtils.DIR_SEPARATOR+fileName);
}
})
.click( function() {
@@ -203,7 +201,7 @@ define([
// If directory path not in history then add it to the history
if(directoryFoundOn < 0) {
- var parentLocation = directoryPath.substring(0, directoryPath.lastIndexOf(UIAPI.TagUtils.DIR_SEPARATOR));
+ 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) {
@@ -217,7 +215,7 @@ define([
}
}
- var locationTitle = directoryPath.substring(directoryPath.lastIndexOf(UIAPI.TagUtils.DIR_SEPARATOR)+1,directoryPath.length);
+ var locationTitle = directoryPath.substring(directoryPath.lastIndexOf(TSCORE.TagUtils.DIR_SEPARATOR)+1,directoryPath.length);
directoryHistory.push({
"title": locationTitle,
"key" : directoryPath,
@@ -225,9 +223,9 @@ define([
});
}
- UIAPI.currentPath = directoryPath;
- IOAPI.getSubdirs(directoryPath);
- IOAPI.listDirectory(directoryPath);
+ TSCORE.currentPath = directoryPath;
+ TSCORE.IO.getSubdirs(directoryPath);
+ TSCORE.IO.listDirectory(directoryPath);
}
function initButtons() {
@@ -281,7 +279,7 @@ define([
}
})
.click(function() {
- IOAPI.selectDirectory();
+ TSCORE.IO.selectDirectory();
return false;
})
}
@@ -299,7 +297,7 @@ define([
$( "#dialog-dircreate" ).dialog("open");
break;
case "openDirectory":
- IOAPI.openDirectory(dir4ContextMenu);
+ TSCORE.IO.openDirectory(dir4ContextMenu);
break;
}
}
@@ -361,7 +359,7 @@ define([
// bValid = bValid && checkRegexp( email, /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, "eg. [email protected]" );
// bValid = bValid && checkRegexp( password, /^([0-9a-zA-Z])+$/, "Password field only allow : a-z 0-9" );
if ( bValid ) {
- IOAPI.createDirectory(dir4ContextMenu+UIAPI.TagUtils.DIR_SEPARATOR+newDirName.val());
+ TSCORE.IO.createDirectory(dir4ContextMenu+TSCORE.TagUtils.DIR_SEPARATOR+newDirName.val());
navigateToDirectory(dir4ContextMenu);
$( this ).dialog( "close" );
}
@@ -382,9 +380,9 @@ define([
modal: true,
buttons: {
"Delete": function() {
- TSSETTINGS.deleteFavorite(nameCurrentFavorite);
+ TSCORE.Config.deleteFavorite(nameCurrentFavorite);
initFavorites();
- openFavorite(TSSETTINGS.Settings["tagspacesList"][0].path, TSSETTINGS.Settings["tagspacesList"][0].name);
+ openFavorite(TSCORE.Config.Settings["tagspacesList"][0].path, TSCORE.Config.Settings["tagspacesList"][0].name);
$( this ).dialog( "close" );
},
Cancel: function() {
@@ -400,9 +398,9 @@ define([
modal: true,
buttons: {
"Create": function() {
- TSSETTINGS.createFavorite($("#favoriteName").val(), $("#favoriteLocation").val());
+ TSCORE.Config.createFavorite($("#favoriteName").val(), $("#favoriteLocation").val());
initFavorites();
- openFavorite(TSSETTINGS.Settings["tagspacesList"][0].path, TSSETTINGS.Settings["tagspacesList"][0].name);
+ openFavorite(TSCORE.Config.Settings["tagspacesList"][0].path, TSCORE.Config.Settings["tagspacesList"][0].name);
$( this ).dialog( "close" );
},
Cancel: function() {
@@ -419,7 +417,7 @@ define([
$( "#favoritesList" ).menu("disable");
$( "#favoritesList" ).empty();
- var favoritesList = TSSETTINGS.Settings["tagspacesList"]
+ var favoritesList = TSCORE.Config.Settings["tagspacesList"]
for (var i=0; i < favoritesList.length; i++) {
$( "#favoritesList" ).append(
$('<li>', { title: favoritesList[i].path, name: favoritesList[i].name}).append(
diff --git a/data/js/fileopener.js b/data/js/fileopener.js
index 6f5cac0c8..091ba5629 100644
--- a/data/js/fileopener.js
+++ b/data/js/fileopener.js
@@ -4,7 +4,9 @@
define(function(require, exports, module) {
"use strict";
-console.debug("Loading FileViewer...");
+ console.debug("Loading fileOpener...");
+
+ var TSCORE = require("tscore");
function openFile(filePath) {
console.debug("Opening file: "+filePath);
@@ -14,15 +16,15 @@ console.debug("Loading FileViewer...");
var openedFilePath = filePath;
$("#selectedFilePath").val(openedFilePath.replace("\\\\","\\"));
- var fileExt = UIAPI.TagUtils.extractFileExtension(filePath);
+ var fileExt = TSCORE.TagUtils.extractFileExtension(filePath);
constructFileViewerUI(filePath);
// Getting the viewer for the file extension/type
- var viewerExt = TSSETTINGS.getFileTypeViewer(fileExt);
+ var viewerExt = TSCORE.Config.getFileTypeViewer(fileExt);
console.debug("File Viewer: "+viewerExt);
- UIAPI.openFileViewer();
+ TSCORE.openFileViewer();
initTagSuggestionMenu(filePath);
@@ -37,7 +39,7 @@ console.debug("Loading FileViewer...");
src: filePath
}));
} else {
- require([TSSETTINGS.getExtensionPath()+"/"+viewerExt+"/"+"extension.js"], function(viewer) {
+ require([TSCORE.Config.getExtensionPath()+"/"+viewerExt+"/"+"extension.js"], function(viewer) {
tsEditor = viewer;
tsEditor.init(filePath, "viewer");
tsEditor.viewerMode(true);
@@ -57,10 +59,10 @@ console.debug("Loading FileViewer...");
// Should return false if no editor found
function getFileEditor(filePath) {
- var fileExt = UIAPI.TagUtils.extractFileExtension(filePath);
+ var fileExt = TSCORE.TagUtils.extractFileExtension(filePath);
// Getting the editor for the file extension/type
- var editorExt = TSSETTINGS.getFileTypeEditor(fileExt);
+ var editorExt = TSCORE.Config.getFileTypeEditor(fileExt);
console.debug("File Editor: "+editorExt);
return editorExt;
}
@@ -76,7 +78,7 @@ console.debug("Loading FileViewer...");
return;
} else {
try {
- require([TSSETTINGS.getExtensionPath()+"/"+editorExt+"/extension.js"], function(editr) {
+ require([TSCORE.Config.getExtensionPath()+"/"+editorExt+"/extension.js"], function(editr) {
tsEditor = editr;
tsEditor.init(filePath, "viewer");
});
@@ -90,12 +92,12 @@ console.debug("Loading FileViewer...");
function saveFile(filePath) {
console.debug("Save current file: "+filePath);
var content = tsEditor.getContent();
- IOAPI.saveTextFile(filePath, content);
+ TSCORE.IO.saveTextFile(filePath, content);
}
function constructFileViewerUI(filePath) {
// Adding tag buttons to the filetoolbox
- var tags = UIAPI.TagUtils.extractTags(filePath);
+ var tags = TSCORE.TagUtils.extractTags(filePath);
$( "#fileTitle" ).text();
@@ -117,7 +119,7 @@ console.debug("Loading FileViewer...");
drop: function( event, ui ) {
var tagName = ui.draggable.attr("tag");
console.log("Tagging file: "+tagName+" to "+filePath);
- UIAPI.TagUtils.addTag([filePath], [tagName]);
+ TSCORE.TagUtils.addTag([filePath], [tagName]);
}
})
@@ -143,9 +145,9 @@ console.debug("Loading FileViewer...");
}
function initTagSuggestionMenu(filePath) {
- var tags = UIAPI.TagUtils.extractTags(filePath);
+ var tags = TSCORE.TagUtils.extractTags(filePath);
- var suggTags = UIAPI.TagUtils.suggestTags(filePath);
+ var suggTags = TSCORE.TagUtils.suggestTags(filePath);
var tsMenu = $( "#tagSuggestionsMenu" );
@@ -168,7 +170,7 @@ console.debug("Loading FileViewer...");
var tagName = $(this).attr( "tagname" );
var filePath = $(this).attr( "filepath" );
console.debug("Tag suggestion clicked: "+tagName);
- UIAPI.TagUtils.writeTagsToFile(filePath, [tagName]);
+ TSCORE.TagUtils.writeTagsToFile(filePath, [tagName]);
return false;
})
));
@@ -229,7 +231,7 @@ console.debug("Loading FileViewer...");
}
};
saveFile(filePath);
- UIAPI.openFile(filePath);
+ TSCORE.openFile(filePath);
}
}
$( this ).button( "option", options );
@@ -264,14 +266,14 @@ console.debug("Loading FileViewer...");
if(confirm("If you confirm, all made changes will be lost.")){
// Cleaning the viewer/editor
document.getElementById("viewer").innerHTML = "";
- UIAPI.closeFileViewer();
+ TSCORE.closeFileViewer();
isEditMode = false;
}
} else {
// Cleaning the viewer/editor
document.getElementById("viewer").innerHTML = "";
- UIAPI.isFileOpened = false;
- UIAPI.closeFileViewer();
+ TSCORE.isFileOpened = false;
+ TSCORE.closeFileViewer();
isEditMode = false;
}
});
diff --git a/data/js/ioapi.chrome.js b/data/js/ioapi.chrome.js
index e7c8f22ae..5847b93fe 100644
--- a/data/js/ioapi.chrome.js
+++ b/data/js/ioapi.chrome.js
@@ -4,181 +4,186 @@
// TODO use eventually this http://developer.chrome.com/extensions/fileBrowserHandler.html
-// Activating browser specific IOAPI modul
-console.debug("Loading IOapiChrome.js..");
-
-IOAPI = (typeof IOAPI == 'object' && IOAPI != null) ? IOAPI : {};
-
-/**
- Interface of npapi-file-io
- getPlatform() : string
- fileExists(filename : string) : bool
- isDirectory(filename : string) : bool
- getTextFile(filename : string) : string
- getBinaryFile(filename : string) : array<byte>
- removeFile(filename : string) : void
- listFiles(filename : string) : array<object>
-
- bool getFile(const char *filename, char *&value, size_t &len, const bool issBinary);
- bool createDirectory(const char *filename);
- bool saveText(const char *filename, const char *value, size_t len);
- saveTextFile
- bool saveBinaryFile(const char *filename, const char *bytes, const size_t len);
- bool getTempPath(char *&value, size_t &len);
- getTmpPath
-*/
-
-IOAPI.plugin = document.createElement("embed");
-IOAPI.plugin.setAttribute("type", "application/x-npapi-file-io");
-IOAPI.plugin.style.position = "absolute";
-IOAPI.plugin.style.left = "-9999px";
-
-// Add plugin to document if the browser is chrome or chromium
-if(navigator.userAgent.indexOf("Chrom") > 0) {
- document.documentElement.appendChild(IOAPI.plugin);
-}
-
-// Determine the directory separator
-IOAPI.pathSeparator = IOAPI.plugin.getPlatform() == 'windows' ? "\\" : '/';
-
-// Test if plugin works
-console.debug("Current platform: "+IOAPI.plugin.getPlatform()+" with path separator: "+IOAPI.pathSeparator);
-
-IOAPI.createDirectory = function(dirPath) {
- console.debug("Creating directory: "+dirPath);
- if(IOAPI.plugin.isDirectory(dirPath)) {
- console.error("Directory already exists...");
- } else {
- if(IOAPI.plugin.createDirectory(dirPath)) {
- console.debug("Directory: "+dirPath+" created.");
+define(function(require, exports, module) {
+"use strict";
+
+ // Activating browser specific exports modul
+ console.debug("Loading ioapi.chrome.js..");
+
+ var TSCORE = require("tscore");
+
+ /**
+ Interface of npapi-file-io
+ getPlatform() : string
+ fileExists(filename : string) : bool
+ isDirectory(filename : string) : bool
+ getTextFile(filename : string) : string
+ getBinaryFile(filename : string) : array<byte>
+ removeFile(filename : string) : void
+ listFiles(filename : string) : array<object>
+
+ bool getFile(const char *filename, char *&value, size_t &len, const bool issBinary);
+ bool createDirectory(const char *filename);
+ bool saveText(const char *filename, const char *value, size_t len);
+ saveTextFile
+ bool saveBinaryFile(const char *filename, const char *bytes, const size_t len);
+ bool getTempPath(char *&value, size_t &len);
+ getTmpPath
+ */
+
+ var plugin = document.createElement("embed");
+ plugin.setAttribute("type", "application/x-npapi-file-io");
+ plugin.style.position = "absolute";
+ plugin.style.left = "-9999px";
+
+ // Add plugin to document if the browser is chrome or chromium
+ if(navigator.userAgent.indexOf("Chrom") > 0) {
+ document.documentElement.appendChild(plugin);
+ }
+
+ // Determine the directory separator
+ exports.pathSeparator = plugin.getPlatform() == 'windows' ? "\\" : '/';
+
+ // Test if plugin works
+ console.debug("Current platform: "+plugin.getPlatform()+" with path separator: "+exports.pathSeparator);
+
+ exports.createDirectory = function(dirPath) {
+ console.debug("Creating directory: "+dirPath);
+ if(plugin.isDirectory(dirPath)) {
+ console.error("Directory already exists...");
} else {
- console.error("Directory creation failed");
+ if(plugin.createDirectory(dirPath)) {
+ console.debug("Directory: "+dirPath+" created.");
+ } else {
+ console.error("Directory creation failed");
+ }
}
}
-}
-
-IOAPI.loadTextFile = function(filePath) {
- console.debug("Loading file: "+filePath);
- if(IOAPI.plugin.fileExists(filePath)) {
- var fileContent = IOAPI.plugin.getTextFile(filePath);
- UIAPI.FileOpener.updateEditorContent(fileContent);
- } else {
- console.error("File does not exists...");
- }
-}
-
-// TODO Renaming very slow, due the copy implementation
-IOAPI.renameFile = function(filePath, newFilePath) {
- console.debug("Renaming file: "+filePath+" to "+newFilePath);
- if(IOAPI.plugin.fileExists(newFilePath)) {
- console.error("Target file already exists: "+newFilePath);
- } else {
- if(IOAPI.plugin.fileExists(filePath)) {
- IOAPI.plugin.saveBinaryFile(newFilePath,IOAPI.plugin.getBinaryFile(filePath));
- IOAPI.plugin.removeFile(filePath);
-
- if(UIAPI.isFileOpened) {
- UIAPI.openFile(newFilePath);
- }
- UIAPI.refreshFileListContainer();
-
- console.debug("File renamed to: "+newFilePath);
- } else {
- console.error("Original file does not exists: "+filePath);
+
+ exports.loadTextFile = function(filePath) {
+ console.debug("Loading file: "+filePath);
+ if(plugin.fileExists(filePath)) {
+ var fileContent = plugin.getTextFile(filePath);
+ TSCORE.FileOpener.updateEditorContent(fileContent);
+ } else {
+ console.error("File does not exists...");
+ }
+ }
+
+ // TODO Renaming very slow, due the copy implementation
+ exports.renameFile = function(filePath, newFilePath) {
+ console.debug("Renaming file: "+filePath+" to "+newFilePath);
+ if(plugin.fileExists(newFilePath)) {
+ console.error("Target file already exists: "+newFilePath);
+ } else {
+ if(plugin.fileExists(filePath)) {
+ plugin.saveBinaryFile(newFilePath,plugin.getBinaryFile(filePath));
+ plugin.removeFile(filePath);
+
+ if(TSCORE.isFileOpened) {
+ TSCORE.openFile(newFilePath);
+ }
+ TSCORE.refreshFileListContainer();
+
+ console.debug("File renamed to: "+newFilePath);
+ } else {
+ console.error("Original file does not exists: "+filePath);
+ }
}
}
-}
-
-IOAPI.saveTextFile = function(filePath,content) {
- console.debug("Saving file: "+filePath);
- if(IOAPI.plugin.fileExists(filePath)) {
- IOAPI.plugin.removeFile(filePath);
- }
- IOAPI.plugin.saveTextFile(filePath,content);
-}
-
-IOAPI.listDirectory = function(dirPath) {
- console.debug("Listing directory: "+dirPath);
- if(IOAPI.plugin.isDirectory(dirPath)) {
- try {
- var dirList = IOAPI.plugin.listFiles(dirPath);
- console.debug("Dir content: "+JSON.stringify(dirList));
- UIAPI.updateFileBrowserData(dirList);
- } catch(ex) {
- console.error("Directory listing failed "+ex);
- }
- } else {
- console.error("Directory does not exists.");
- }
-}
-
-IOAPI.getSubdirs = function(dirPath) {
- console.debug("Getting subdirs: "+dirPath);
- if(IOAPI.plugin.isDirectory(dirPath)) {
- try {
- var dirList = IOAPI.plugin.listFiles(dirPath);
- var anotatedDirList = [];
- for (var i=0; i < dirList.length; i++) {
- if(dirList[i].type == "directory") {
- anotatedDirList.push({
- "title": dirList[i].name,
- "isFolder": true,
- "isLazy": true,
- "key": dirPath+IOAPI.pathSeparator+dirList[i].name
- });
- }
- }
- // TODO JSON functions are a workarround for a bug....
- UIAPI.updateSubDirs(JSON.parse( JSON.stringify(anotatedDirList)));
- } catch(ex) {
- console.error("Directory listing failed "+ex);
- }
- } else {
- console.error("Directory does not exists.");
- }
-}
-
-IOAPI.deleteElement = function(path) {
- console.debug("Deleting: "+path);
- IOAPI.plugin.removeFile(path)
-}
-
-IOAPI.selectDirectory = function() {
- // TODO implement selectDirectory
- console.debug("Select directory functionality not implemented on chrome yet!");
- alert("Select directory functionality not implemented on chrome yet!")
-}
-
-IOAPI.selectFile = function() {
- // TODO implement selectFile
- console.debug("Select file functionality not implemented on chrome yet!");
- alert("Select file functionality not implemented on chrome yet!")
-}
-
-IOAPI.openDirectory = function(dirPath) {
- // TODO implement openDirectory
- console.debug("Open directory functionality not implemented on chrome yet!");
- alert("Open directory functionality not implemented on chrome yet!");
-}
-
-IOAPI.openExtensionsDirectory = function() {
- // TODO implement openExtensionsDirectory
- console.debug("Open extensions directory functionality not implemented on chrome yet!");
- alert("Open extensions directory functionality not implemented on chrome yet!");
-}
-
-IOAPI.createDirectoryIndex = function(dirPath) {
- // TODO implement createDirectoryIndex
- console.debug("Directory indexing functionality not implemented on chrome yet!");
- alert("Directory indexing functionality not implemented on chrome yet!");
-}
+
+ exports.saveTextFile = function(filePath,content) {
+ console.debug("Saving file: "+filePath);
+ if(plugin.fileExists(filePath)) {
+ plugin.removeFile(filePath);
+ }
+ plugin.saveTextFile(filePath,content);
+ }
+
+ exports.listDirectory = function(dirPath) {
+ console.debug("Listing directory: "+dirPath);
+ if(plugin.isDirectory(dirPath)) {
+ try {
+ var dirList = plugin.listFiles(dirPath);
+ console.debug("Dir content: "+JSON.stringify(dirList));
+ TSCORE.updateFileBrowserData(dirList);
+ } catch(ex) {
+ console.error("Directory listing failed "+ex);
+ }
+ } else {
+ console.error("Directory does not exists.");
+ }
+ }
+
+ exports.getSubdirs = function(dirPath) {
+ console.debug("Getting subdirs: "+dirPath);
+ if(plugin.isDirectory(dirPath)) {
+ try {
+ var dirList = plugin.listFiles(dirPath);
+ var anotatedDirList = [];
+ for (var i=0; i < dirList.length; i++) {
+ if(dirList[i].type == "directory") {
+ anotatedDirList.push({
+ "title": dirList[i].name,
+ "isFolder": true,
+ "isLazy": true,
+ "key": dirPath+exports.pathSeparator+dirList[i].name
+ });
+ }
+ }
+ // TODO JSON functions are a workarround for a bug....
+ TSCORE.updateSubDirs(JSON.parse( JSON.stringify(anotatedDirList)));
+ } catch(ex) {
+ console.error("Directory listing failed "+ex);
+ }
+ } else {
+ console.error("Directory does not exists.");
+ }
+ }
+
+ exports.deleteElement = function(path) {
+ console.debug("Deleting: "+path);
+ plugin.removeFile(path)
+ }
+
+ exports.selectDirectory = function() {
+ // TODO implement selectDirectory
+ console.debug("Select directory functionality not implemented on chrome yet!");
+ alert("Select directory functionality not implemented on chrome yet!")
+ }
+
+ exports.selectFile = function() {
+ // TODO implement selectFile
+ console.debug("Select file functionality not implemented on chrome yet!");
+ alert("Select file functionality not implemented on chrome yet!")
+ }
+
+ exports.openDirectory = function(dirPath) {
+ // TODO implement openDirectory
+ console.debug("Open directory functionality not implemented on chrome yet!");
+ alert("Open directory functionality not implemented on chrome yet!");
+ }
+
+ exports.openExtensionsDirectory = function() {
+ // TODO implement openExtensionsDirectory
+ console.debug("Open extensions directory functionality not implemented on chrome yet!");
+ alert("Open extensions directory functionality not implemented on chrome yet!");
+ }
+
+ exports.createDirectoryIndex = function(dirPath) {
+ // TODO implement createDirectoryIndex
+ console.debug("Directory indexing functionality not implemented on chrome yet!");
+ alert("Directory indexing functionality not implemented on chrome yet!");
+ }
+
+ exports.createDirectoryTree = function(dirPath) {
+ console.debug("Creating directory index for: "+dirPath);
+ console.debug("Creating Directory Tree functionality not implemented on chrome yet!");
+ // TODO implement createDirectoryTree
+ TSCORE.ViewManager.updateTreeData();
+ }
-IOAPI.createDirectoryTree = function(dirPath) {
- console.debug("Creating directory index for: "+dirPath);
- console.debug("Creating Directory Tree functionality not implemented on chrome yet!");
- // TODO implement createDirectoryTree
- UIAPI.ViewManager.updateTreeData();
-}
+});
/* Needed for createDirectoryTree
function directoryTree(dirPath) {
diff --git a/data/js/ioapi.mozilla.js b/data/js/ioapi.mozilla.js
index fe12f9201..2062bbaf8 100644
--- a/data/js/ioapi.mozilla.js
+++ b/data/js/ioapi.mozilla.js
@@ -1,18 +1,18 @@
/* Copyright (c) 2012 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. */
-// Activating browser specific IOAPI modul
-
-console.debug("Loading IOapiMozilla.js..");
// The mozilla implementation of the IOAPI "class"
-IOAPI = (typeof IOAPI == 'object' && IOAPI != null) ? IOAPI : {
-
-};
+define(function(require, exports, module) {
+"use strict";
+
+console.debug("Loading ioapi.mozilla.js..");
-IOAPI.saveSettings = function(content) {
+var TSCORE = require("tscore");
+
+exports.saveSettings = function(content) {
console.debug("Saving setting...");
- UIAPI.showLoadingAnimation();
+ TSCORE.showLoadingAnimation();
var event = document.createEvent('CustomEvent');
event.initCustomEvent("addon-message", true, true, {"detail":{
"command": "saveSettings",
@@ -21,9 +21,9 @@ IOAPI.saveSettings = function(content) {
document.documentElement.dispatchEvent(event);
}
-IOAPI.loadSettings = function() {
+exports.loadSettings = function() {
console.debug("Loading setting from firefox preferences...");
- UIAPI.showLoadingAnimation();
+ TSCORE.showLoadingAnimation();
var event = document.createEvent('CustomEvent');
event.initCustomEvent("addon-message", true, true, {"detail":{
"command": "loadSettings"
@@ -31,9 +31,9 @@ IOAPI.loadSettings = function() {
document.documentElement.dispatchEvent(event);
}
-IOAPI.createDirectory = function(dirPath) {
+exports.createDirectory = function(dirPath) {
console.debug("Directory "+dirPath+" created.");
- UIAPI.showLoadingAnimation();
+ TSCORE.showLoadingAnimation();
var event = document.createEvent('CustomEvent');
event.initCustomEvent("addon-message", true, true, {"detail":{
"command": "createDirectory",
@@ -42,9 +42,9 @@ IOAPI.createDirectory = function(dirPath) {
document.documentElement.dispatchEvent(event);
}
-IOAPI.loadTextFile = function(filePath) {
+exports.loadTextFile = function(filePath) {
console.debug("Loading file: "+filePath);
- UIAPI.showLoadingAnimation();
+ TSCORE.showLoadingAnimation();
var event = document.createEvent('CustomEvent');
event.initCustomEvent("addon-message", true, true, {"detail":{
"command": "loadTextFile",
@@ -53,9 +53,9 @@ IOAPI.loadTextFile = function(filePath) {
document.documentElement.dispatchEvent(event);
}
-IOAPI.renameFile = function(filePath, newFilePath) {
+exports.renameFile = function(filePath, newFilePath) {
console.debug("Renaming "+filePath+" to "+newFilePath);
- UIAPI.showLoadingAnimation();
+ TSCORE.showLoadingAnimation();
var event = document.createEvent('CustomEvent');
event.initCustomEvent("addon-message", true, true, {"detail":{
"command": "rename",
@@ -65,9 +65,9 @@ IOAPI.renameFile = function(filePath, newFilePath) {
document.documentElement.dispatchEvent(event);
}
-IOAPI.saveTextFile = function(filePath,content) {
+exports.saveTextFile = function(filePath,content) {
console.debug("Saving file: "+filePath);
- UIAPI.showLoadingAnimation();
+ TSCORE.showLoadingAnimation();
var event = document.createEvent('CustomEvent');
event.initCustomEvent("addon-message", true, true, {"detail":{
"command": "saveTextFile",
@@ -77,9 +77,9 @@ IOAPI.saveTextFile = function(filePath,content) {
document.documentElement.dispatchEvent(event);
}
-IOAPI.listDirectory = function(dirPath) {
+exports.listDirectory = function(dirPath) {
console.debug("Listing directory: "+dirPath);
- UIAPI.showLoadingAnimation();
+ TSCORE.showLoadingAnimation();
var event = document.createEvent('CustomEvent');
event.initCustomEvent("addon-message", true, true, {"detail":{
"command": "listDirectory",
@@ -88,9 +88,9 @@ IOAPI.listDirectory = function(dirPath) {
document.documentElement.dispatchEvent(event);
}
-IOAPI.getSubdirs = function(dirPath) {
+exports.getSubdirs = function(dirPath) {
console.debug("Getting subdirs: "+dirPath);
- UIAPI.showLoadingAnimation();
+ TSCORE.showLoadingAnimation();
var event = document.createEvent('CustomEvent');
event.initCustomEvent("addon-message", true, true, {"detail":{
"command": "getSubdirs",
@@ -99,9 +99,9 @@ IOAPI.getSubdirs = function(dirPath) {
document.documentElement.dispatchEvent(event);
}
-IOAPI.deleteElement = function(path) {
+exports.deleteElement = function(path) {
console.debug("Deleting: "+path);
- UIAPI.showLoadingAnimation();
+ TSCORE.showLoadingAnimation();
var event = document.createEvent('CustomEvent');
event.initCustomEvent("addon-message", true, true, {"detail":{
"command": "delete",
@@ -110,7 +110,7 @@ IOAPI.deleteElement = function(path) {
document.documentElement.dispatchEvent(event);
}
-IOAPI.selectDirectory = function() {
+exports.selectDirectory = function() {
console.debug("Selecting directory...");
var event = document.createEvent('CustomEvent');
event.initCustomEvent("addon-message", true, true, {"detail":{
@@ -119,7 +119,7 @@ IOAPI.selectDirectory = function() {
document.documentElement.dispatchEvent(event);
}
-IOAPI.selectFile = function() {
+exports.selectFile = function() {
console.debug("Selecting file...");
var event = document.createEvent('CustomEvent');
event.initCustomEvent("addon-message", true, true, {"detail":{
@@ -128,7 +128,7 @@ IOAPI.selectFile = function() {
document.documentElement.dispatchEvent(event);
}
-IOAPI.openDirectory = function(dirPath) {
+exports.openDirectory = function(dirPath) {
console.debug("Opening directory: "+dirPath);
var event = document.createEvent('CustomEvent');
event.initCustomEvent("addon-message", true, true, {"detail":{
@@ -138,7 +138,7 @@ IOAPI.openDirectory = function(dirPath) {
document.documentElement.dispatchEvent(event);
}
-IOAPI.openExtensionsDirectory = function() {
+exports.openExtensionsDirectory = function() {
console.debug("Opening extensions directory...");
var event = document.createEvent('CustomEvent');
event.initCustomEvent("addon-message", true, true, {"detail":{
@@ -147,9 +147,9 @@ IOAPI.openExtensionsDirectory = function() {
document.documentElement.dispatchEvent(event);
}
-IOAPI.createDirectoryIndex = function(dirPath) {
+exports.createDirectoryIndex = function(dirPath) {
console.debug("Creating directory index for: "+dirPath);
- UIAPI.showLoadingAnimation();
+ TSCORE.showLoadingAnimation();
var event = document.createEvent('CustomEvent');
event.initCustomEvent("addon-message", true, true, {"detail":{
"command": "createDirectoryIndex",
@@ -158,13 +158,15 @@ IOAPI.createDirectoryIndex = function(dirPath) {
document.documentElement.dispatchEvent(event);
}
-IOAPI.createDirectoryTree = function(dirPath) {
+exports.createDirectoryTree = function(dirPath) {
console.debug("Creating directory tree for: "+dirPath);
- UIAPI.showLoadingAnimation();
+ TSCORE.showLoadingAnimation();
var event = document.createEvent('CustomEvent');
event.initCustomEvent("addon-message", true, true, {"detail":{
"command": "createDirectoryTree",
"path": dirPath
}});
document.documentElement.dispatchEvent(event);
-}
\ No newline at end of file
+}
+
+});
diff --git a/data/js/ioapi.mozilla.receiver.js b/data/js/ioapi.mozilla.receiver.js
new file mode 100644
index 000000000..eb19bc0d4
--- /dev/null
+++ b/data/js/ioapi.mozilla.receiver.js
@@ -0,0 +1,135 @@
+/* Copyright (c) 2012 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. */
+// Activating browser specific IOAPI modul
+define(function(require, exports, module) {
+"use strict";
+
+console.debug("Loading messaging.mozilla.js..");
+
+ var TSCORE = require("tscore");
+
+ document.documentElement.addEventListener("addon-message1", function(event) {
+ console.debug("Message received in page script from content script: "); //+JSON.stringify(event.detail));
+ TSCORE.hideLoadingAnimation();
+ var message = event.detail;
+ switch (message.command) {
+ case "loadSettings":
+ if(message.success) {
+ try {
+ console.debug("Loading settings...: "+JSON.stringify(message.content));
+ TSCORE.Config.updateSettingMozillaPreferences(message.content);
+
+ TSCORE.initFavorites();
+ TSCORE.generateTagGroups();
+
+ } catch (ex) {
+ console.debug("Exception while getting setting from firefox failed "+ex)
+ }
+ } else {
+ console.debug("Getting setting from firefox failed")
+ }
+ break;
+ case "saveSettings":
+ if(message.success) {
+ console.debug("Saving setting as native mozilla preference successfull!")
+ } else {
+ console.debug("Saving setting as native mozilla preference failed!")
+ }
+ break;
+ case "updateDefaultPath":
+ if(message.content.length > 1) {
+ TSCORE.setCurrentPath(message.content);
+ }
+ break;
+ case "rename":
+ if(message.success){
+ TSCORE.updateLogger("Rename success");
+ // message.content contains the name of the file after the rename
+ TSCORE.selectedFiles[0] = message.content;
+ if(TSCORE.isFileOpened) {
+ TSCORE.openFile(TSCORE.selectedFiles[0]);
+ }
+ TSCORE.refreshFileListContainer();
+ } else {
+ TSCORE.updateLogger("Rename failed");
+ }
+ break;
+ case "saveTextFile":
+ if(message.success){
+ TSCORE.updateLogger("Save success");
+ } else {
+ TSCORE.updateLogger("Save failed");
+ }
+ break;
+ case "createDirectory":
+ if(message.success){
+ TSCORE.updateLogger("Create dir success");
+ TSCORE.openFavorite(TSCORE.Config.Settings["tagspacesList"][0].path, TSCORE.Config.Settings["tagspacesList"][0].name);
+ } else {
+ TSCORE.updateLogger("Create dir failed");
+ }
+ break;
+ case "loadTextFile":
+ if(message.success){
+ TSCORE.FileOpener.updateEditorContent(message.content);
+ } else {
+ TSCORE.updateLogger("File loading failed");
+ }
+ break;
+ case "listDirectory":
+ if(message.success){
+ TSCORE.updateFileBrowserData(message.content);
+ } else {
+ TSCORE.updateLogger("List directory failed");
+ }
+ break;
+ case "indexDirectory":
+ if(message.success){
+ //console.debug("Directory Index: "+JSON.stringify(message.content));
+ TSCORE.ViewManager.updateIndexData(message.content);
+ } else {
+ TSCORE.updateLogger("Indexing directory failed");
+ }
+ break;
+ case "createDirectoryTree":
+ if(message.success){
+ //console.debug("Directory tree: "+JSON.stringify(message.content));
+ TSCORE.ViewManager.updateTreeData(message.content);
+ } else {
+ 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....
+ TSCORE.updateSubDirs(JSON.parse( JSON.stringify(dirListing)));
+ } else {
+ TSCORE.updateLogger("Getting subdirs failed");
+ }
+ break;
+ case "delete":
+ if(message.success){
+ TSCORE.updateLogger("Delete success");
+ } else {
+ TSCORE.updateLogger("Delete failed");
+ }
+ break;
+ case "selectDirectory":
+ if(message.success){
+ // TODO make the use of this function more general
+ $("#favoriteLocation").val(message.content);
+ } else {
+ TSCORE.updateLogger("Selecting directory failed.");
+ }
+ break;
+ default:
+ break;
+ }
+ }, false);
+
+});
\ No newline at end of file
diff --git a/data/js/messaging.mozilla.js b/data/js/messaging.mozilla.js
deleted file mode 100644
index 5862b8ab8..000000000
--- a/data/js/messaging.mozilla.js
+++ /dev/null
@@ -1,131 +0,0 @@
-/* Copyright (c) 2012 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. */
-// Activating browser specific IOAPI modul
-define(function(require, exports, module) {
-"use strict";
-
-console.debug("Loading messaging.mozilla.js..");
-document.documentElement.addEventListener("addon-message1", function(event) {
- console.debug("Message received in page script from content script: "); //+JSON.stringify(event.detail));
- UIAPI.hideLoadingAnimation();
- var message = event.detail;
- switch (message.command) {
- case "loadSettings":
- if(message.success) {
- try {
- console.debug("Loading settings...: "+JSON.stringify(message.content));
- TSSETTINGS.updateSettingMozillaPreferences(message.content);
-
- UIAPI.initFavorites();
- UIAPI.generateTagGroups();
-
- } catch (ex) {
- console.debug("Exception while getting setting from firefox failed "+ex)
- }
- } else {
- console.debug("Getting setting from firefox failed")
- }
- break;
- case "saveSettings":
- if(message.success) {
- console.debug("Saving setting as native mozilla preference successfull!")
- } else {
- console.debug("Saving setting as native mozilla preference failed!")
- }
- break;
- case "updateDefaultPath":
- if(message.content.length > 1) {
- UIAPI.setCurrentPath(message.content);
- }
- break;
- case "rename":
- if(message.success){
- UIAPI.updateLogger("Rename success");
- // message.content contains the name of the file after the rename
- UIAPI.selectedFiles[0] = message.content;
- if(UIAPI.isFileOpened) {
- UIAPI.openFile(UIAPI.selectedFiles[0]);
- }
- UIAPI.refreshFileListContainer();
- } else {
- UIAPI.updateLogger("Rename failed");
- }
- break;
- case "saveTextFile":
- if(message.success){
- UIAPI.updateLogger("Save success");
- } else {
- UIAPI.updateLogger("Save failed");
- }
- break;
- case "createDirectory":
- if(message.success){
- UIAPI.updateLogger("Create dir success");
- UIAPI.openFavorite(TSSETTINGS.Settings["tagspacesList"][0].path, TSSETTINGS.Settings["tagspacesList"][0].name);
- } else {
- UIAPI.updateLogger("Create dir failed");
- }
- break;
- case "loadTextFile":
- if(message.success){
- UIAPI.FileOpener.updateEditorContent(message.content);
- } else {
- UIAPI.updateLogger("File loading failed");
- }
- break;
- case "listDirectory":
- if(message.success){
- UIAPI.updateFileBrowserData(message.content);
- } else {
- UIAPI.updateLogger("List directory failed");
- }
- break;
- case "indexDirectory":
- if(message.success){
- //console.debug("Directory Index: "+JSON.stringify(message.content));
- UIAPI.ViewManager.updateIndexData(message.content);
- } else {
- UIAPI.updateLogger("Indexing directory failed");
- }
- break;
- case "createDirectoryTree":
- if(message.success){
- //console.debug("Directory tree: "+JSON.stringify(message.content));
- UIAPI.ViewManager.updateTreeData(message.content);
- } else {
- UIAPI.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....
- UIAPI.updateSubDirs(JSON.parse( JSON.stringify(dirListing)));
- } else {
- UIAPI.updateLogger("Getting subdirs failed");
- }
- break;
- case "delete":
- if(message.success){
- UIAPI.updateLogger("Delete success");
- } else {
- UIAPI.updateLogger("Delete failed");
- }
- break;
- case "selectDirectory":
- if(message.success){
- // TODO make the use of this function more general
- $("#favoriteLocation").val(message.content);
- } else {
- UIAPI.updateLogger("Selecting directory failed.");
- }
- break;
- default:
- break;
- }
-}, false);
-});
\ No newline at end of file
diff --git a/data/js/perspective.manager.js b/data/js/perspective.manager.js
index f8dca60a2..2803d8d2f 100644
--- a/data/js/perspective.manager.js
+++ b/data/js/perspective.manager.js
@@ -1,21 +1,15 @@
/* Copyright (c) 2012 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([
- 'require',
- 'exports',
- 'module',
- 'tscore'
-],function(require, exports, module) {
+define(function(require, exports, module) {
"use strict";
-console.debug("Loading view.manager.js");
+console.debug("Loading perspective.manager.js");
var views = undefined;
var searchViewer = undefined;
-var TSSETTINGS = require("tssetting");
-var UIAPI = require("tscore");
+var TSCORE = require("tscore");
exports.initViews = function initViews() {
views = [];
@@ -32,7 +26,7 @@ exports.initViews = function initViews() {
initViewsUI(viewer);
viewer.init();
- UIAPI.currentView = viewer.ID;
+ TSCORE.currentView = viewer.ID;
viewer.load();
$( "#"+viewer.ID+"Button" ).attr("checked","checked");
$( "#"+viewer.ID+"Button" ).button("refresh");
@@ -48,12 +42,12 @@ exports.initViews = function initViews() {
searchViewer = viewer;
});
- var extensions = TSSETTINGS.getExtensions();
+ var extensions = TSCORE.Config.getExtensions();
for (var i=0; i < extensions.length; i++) {
if(extensions[i].enabled && (extensions[i].type == "view") ) {
// TODO Some extension sucha ace editor are not working using paths like this "file:///C:/blabal/extension.js"
- var extPath = TSSETTINGS.getExtensionPath()+"/"+extensions[i].id+"/"+"extension.js";
+ var extPath = TSCORE.Config.getExtensionPath()+"/"+extensions[i].id+"/"+"extension.js";
require([extPath], function(viewer) {
views.push(viewer);
@@ -137,10 +131,10 @@ exports.updateTreeData = function updateTreeData(treeData) {
exports.changeView = function changeView(viewType) {
console.debug("Change to "+viewType+" view.");
- UIAPI.showLoadingAnimation();
+ TSCORE.showLoadingAnimation();
//Setting the current view
- UIAPI.currentView = viewType;
+ TSCORE.currentView = viewType;
for (var i=0; i < views.length; i++) {
$( "#"+views[i].ID+"Container" ).hide();
@@ -161,22 +155,22 @@ exports.changeView = function changeView(viewType) {
}
// Clear the list with the selected files
- UIAPI.selectedFiles = [];
+ TSCORE.selectedFiles = [];
// Reset the filter by a view change
exports.setFileFilter("");
-// UIAPI.hideLoadingAnimation();
+// TSCORE.hideLoadingAnimation();
}
exports.clearSelectedFiles = function clearSelectedFiles() {
// Clear selected files
- UIAPI.selectedFiles = [];
+ TSCORE.selectedFiles = [];
for (var i=0; i < views.length; i++) {
try {
views[i].clearSelectedFiles();
} catch(e) {
- console.debug("Erro while executing 'clearSelectedFiles' on "+views[i].ID)
+ console.debug("Error while executing 'clearSelectedFiles' on "+views[i].ID)
}
}
}
@@ -186,7 +180,7 @@ exports.setFileFilter = function setFileFilter(filter) {
try {
views[i].setFileFilter(filter);
} catch(e) {
- console.debug("Erro while executing 'setFileFilter' on "+views[i].ID)
+ console.debug("Error while executing 'setFileFilter' on "+views[i].ID)
}
}
}
diff --git a/data/js/settings.api.js b/data/js/settings.api.js
index d01f5662b..cb8943d49 100644
--- a/data/js/settings.api.js
+++ b/data/js/settings.api.js
@@ -1,397 +1,388 @@
/* Copyright (c) 2012 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([
- 'require',
- 'exports',
- 'module',
-],function(require, exports, module) {
+define(function(require, exports, module) {
"use strict";
-console.debug("Loading settings.api.js..");
-
-var TSSETTINGS = (typeof TSSETTINGS == "object" && TSSETTINGS != null) ? TSSETTINGS : {};
-
-TSSETTINGS.TagTemplate = {
- "title" : undefined,
- "type" : "plain",
- /* ,
- "pattern":"yyyymmddhhmmss-yyyymmddhhmmss",
- "example":"20120114123456-20120823231235",
- "regex":"",
- "maxlength":17,
- "chainedTags":[
- "isbn","autor"
- ],
- "url": "http://example.com",
- "action":"showDatePicker",
- "prefixes":[
- "EUR", "USD", "BGN"
- ]
- */
-}
-
-TSSETTINGS.FavoriteTemplate = {
- "name": undefined,
- "path": undefined
- }
-
-TSSETTINGS.TagGroupTemplate = {
- "title": undefined,
- "isFolder": true,
- "key": undefined,
- "expand": true,
- "noLink": false,
- "children": []
- }
-
-TSSETTINGS.DefaultSettings = {
- "appName": "@APPNAME@",
- "appVersion": "@VERSION@beta",
- "appBuild": "@VERSION@.@BUILD@",
- "settingsVersion": 1,
- "newTextFileContent": "Text file created with tagspaces!",
- "newHTMLFileContent": "<html><head><meta http-equiv='content-type' content='text/html; charset=utf-8'><title>Tagspaces File</title></head><body>File created with tagspaces!</body></html>",
- "newMDFileContent": '#File created with tagspaces!',
- "showUnixHiddenEntries": false,
- "lastOpenedTSID": 0,
- "lastOpenedDirectory": "",
- "tagspacesList": [
- {
- "name":'Windows Location',
- "path":'Z:\\'
- },
- {
- "name":'Unix Location',
- "path":'/media'
- },
- ],
- "extensionsPath": "file:///C:/TagSpaces/extensions",
- "extensions": [
- {
- "id": "perspectiveRiver", // ID should be equal to the directory name where the ext. is located
- "enabled": false,
- "type": "view",
- },
- {
- "id": "perspectiveThumb", // ID should be equal to the directory name where the ext. is located
- "enabled": true,
- "type": "view",
- },
- ],
- "supportedFileTypes": [
- { "type": "jpg", "viewer": "viewerBrowser", "editor": false },
- { "type": "jpeg", "viewer": "viewerBrowser", "editor": false },
- { "type": "gif", "viewer": "viewerBrowser", "editor": false },
- { "type": "png", "viewer": "viewerBrowser", "editor": false },
- { "type": "svg", "viewer": "viewerBrowser", "editor": false },
- { "type": "pdf", "viewer": "viewerBrowser", "editor": false },
- { "type": "html", "viewer": "viewerBrowser", "editor": "editorHTML" },
- { "type": "htm", "viewer": "viewerBrowser", "editor": "editorHTML" },
- { "type": "mht", "viewer": "viewerBrowser", "editor": false },
- { "type": "mhtml", "viewer": "viewerBrowser", "editor": false },
- { "type": "maff", "viewer": "viewerBrowser", "editor": false },
- { "type": "txt", "viewer": "viewerBrowser", "editor": "editorText" },
- { "type": "xml", "viewer": "editorText", "editor": "editorText" },
- { "type": "js", "viewer": "editorText", "editor": "editorText" },
- { "type": "css", "viewer": "editorText", "editor": "editorText" },
- { "type": "mdown", "viewer": "viewerMD", "editor": "editorText" },
- { "type": "md", "viewer": "viewerMD", "editor": "editorText" }
- ],
- "tagGroups": [
- {
- "title":"Common Tags",
- "isFolder": true,
- "key":"OTB",
- "expand": true,
- "children":[
- {
- "title":"book",
- "type":"plain",
- },
- {
- "title":"paper",
- "type":"plain",
- },
- {
- "title":"XEUR",
- "type":"plain",
- },
- {
- "title":"201XMMDD",
- "type":"plain",
- }
- ]
- }
- ]
-}
-
-TSSETTINGS.Settings = undefined;
-
-//TSSETTINGS.DummyDirlistTree = [
-//{"title":"2009","isFolder":true,"isLazy":true,"key":"z:\\Chronique\\2009"},
-//{"title":"2010","isFolder":true,"isLazy":true,"key":"z:\\Chronique\\2010"},
-//];
-
-TSSETTINGS.upgradeSettings = function() {
- if(TSSETTINGS.Settings["appBuild"].localeCompare(TSSETTINGS.DefaultSettings["appBuild"]) < 0) {
- console.debug("Upgrading settings");
- TSSETTINGS.Settings["extensions"] = TSSETTINGS.DefaultSettings["extensions"];
- TSSETTINGS.Settings["appVersion"] = TSSETTINGS.DefaultSettings["appVersion"];
- TSSETTINGS.Settings["appBuild"] = TSSETTINGS.DefaultSettings["appBuild"];
- TSSETTINGS.getExtensions();
- TSSETTINGS.getExtensionPath();
- TSSETTINGS.saveSettings();
+ console.debug("Loading settings.api.js..");
+
+ var IOAPI = require("tsioapi");
+
+ exports.TagTemplate = {
+ "title" : undefined,
+ "type" : "plain",
+ /* ,
+ "pattern":"yyyymmddhhmmss-yyyymmddhhmmss",
+ "example":"20120114123456-20120823231235",
+ "regex":"",
+ "maxlength":17,
+ "chainedTags":[
+ "isbn","autor"
+ ],
+ "url": "http://example.com",
+ "action":"showDatePicker",
+ "prefixes":[
+ "EUR", "USD", "BGN"
+ ]
+ */
}
-}
-
-TSSETTINGS.getExtensions = function() {
- if(TSSETTINGS.Settings["extensions"] == null) {
- TSSETTINGS.Settings["extensions"] = TSSETTINGS.DefaultSettings["extensions"];
+
+ exports.FavoriteTemplate = {
+ "name": undefined,
+ "path": undefined
+ }
+
+ exports.TagGroupTemplate = {
+ "title": undefined,
+ "isFolder": true,
+ "key": undefined,
+ "expand": true,
+ "noLink": false,
+ "children": []
+ }
+
+ exports.DefaultSettings = {
+ "appName": "@APPNAME@",
+ "appVersion": "@VERSION@beta",
+ "appBuild": "@VERSION@.@BUILD@",
+ "settingsVersion": 1,
+ "newTextFileContent": "Text file created with tagspaces!",
+ "newHTMLFileContent": "<html><head><meta http-equiv='content-type' content='text/html; charset=utf-8'><title>Tagspaces File</title></head><body>File created with tagspaces!</body></html>",
+ "newMDFileContent": '#File created with tagspaces!',
+ "showUnixHiddenEntries": false,
+ "lastOpenedTSID": 0,
+ "lastOpenedDirectory": "",
+ "tagspacesList": [
+ {
+ "name":'Windows Location',
+ "path":'Z:\\'
+ },
+ {
+ "name":'Unix Location',
+ "path":'/media'
+ },
+ ],
+ "extensionsPath": "file:///C:/TagSpaces/extensions",
+ "extensions": [
+ {
+ "id": "perspectiveRiver", // ID should be equal to the directory name where the ext. is located
+ "enabled": false,
+ "type": "view",
+ },
+ {
+ "id": "perspectiveThumb", // ID should be equal to the directory name where the ext. is located
+ "enabled": true,
+ "type": "view",
+ },
+ ],
+ "supportedFileTypes": [
+ { "type": "jpg", "viewer": "viewerBrowser", "editor": false },
+ { "type": "jpeg", "viewer": "viewerBrowser", "editor": false },
+ { "type": "gif", "viewer": "viewerBrowser", "editor": false },
+ { "type": "png", "viewer": "viewerBrowser", "editor": false },
+ { "type": "svg", "viewer": "viewerBrowser", "editor": false },
+ { "type": "pdf", "viewer": "viewerBrowser", "editor": false },
+ { "type": "html", "viewer": "viewerBrowser", "editor": "editorHTML" },
+ { "type": "htm", "viewer": "viewerBrowser", "editor": "editorHTML" },
+ { "type": "mht", "viewer": "viewerBrowser", "editor": false },
+ { "type": "mhtml", "viewer": "viewerBrowser", "editor": false },
+ { "type": "maff", "viewer": "viewerBrowser", "editor": false },
+ { "type": "txt", "viewer": "viewerBrowser", "editor": "editorText" },
+ { "type": "xml", "viewer": "editorText", "editor": "editorText" },
+ { "type": "js", "viewer": "editorText", "editor": "editorText" },
+ { "type": "css", "viewer": "editorText", "editor": "editorText" },
+ { "type": "mdown", "viewer": "viewerMD", "editor": "editorText" },
+ { "type": "md", "viewer": "viewerMD", "editor": "editorText" }
+ ],
+ "tagGroups": [
+ {
+ "title":"Common Tags",
+ "isFolder": true,
+ "key":"OTB",
+ "expand": true,
+ "children":[
+ {
+ "title":"book",
+ "type":"plain",
+ },
+ {
+ "title":"paper",
+ "type":"plain",
+ },
+ {
+ "title":"XEUR",
+ "type":"plain",
+ },
+ {
+ "title":"201XMMDD",
+ "type":"plain",
+ }
+ ]
+ }
+ ]
}
- return TSSETTINGS.Settings["extensions"];
-}
-
-TSSETTINGS.getExtensionPath = function() {
- if(TSSETTINGS.Settings["extensionsPath"] == null) {
- TSSETTINGS.Settings["extensionsPath"] = TSSETTINGS.DefaultSettings["extensionsPath"];
+
+ exports.Setting = undefined;
+
+ exports.upgradeSettings = function() {
+ if(exports.Settings["appBuild"].localeCompare(exports.DefaultSettings["appBuild"]) < 0) {
+ console.debug("Upgrading settings");
+ exports.Settings["extensions"] = exports.DefaultSettings["extensions"];
+ exports.Settings["appVersion"] = exports.DefaultSettings["appVersion"];
+ exports.Settings["appBuild"] = exports.DefaultSettings["appBuild"];
+ exports.getExtensions();
+ exports.getExtensionPath();
+ exports.saveSettings();
+ }
}
- return TSSETTINGS.Settings["extensionsPath"];
-}
-
-TSSETTINGS.getNewTextFileContent = function() {
- return TSSETTINGS.Settings["newTextFileContent"];
-}
-
-TSSETTINGS.getNewHTMLFileContent = function() {
- return TSSETTINGS.Settings["newHTMLFileContent"];
-}
-
-TSSETTINGS.getNewMDFileContent = function() {
- return TSSETTINGS.Settings["newMDFileContent"];
-}
-
-TSSETTINGS.getFileTypeEditor = function(fileTypeExt) {
- for(var i=0; i < TSSETTINGS.Settings["supportedFileTypes"].length; i++) {
- if(TSSETTINGS.Settings["supportedFileTypes"][i].type == fileTypeExt) {
- return TSSETTINGS.Settings["supportedFileTypes"][i].editor;
- }
- }
- return false;
-}
-
-TSSETTINGS.getFileTypeViewer = function(fileTypeExt) {
- for(var i=0; i < TSSETTINGS.Settings["supportedFileTypes"].length; i++) {
- if(TSSETTINGS.Settings["supportedFileTypes"][i].type == fileTypeExt) {
- return TSSETTINGS.Settings["supportedFileTypes"][i].viewer;
- }
- }
- return false;
-}
-
-TSSETTINGS.findTag = function(tagName, tagGroupKey) {
- for(var i=0; i < TSSETTINGS.Settings["tagGroups"].length; i++) {
- if(TSSETTINGS.Settings["tagGroups"][i].key == tagGroupKey) {
- // console.debug("Current taggroup "+TSSETTINGS.Settings["tagGroups"][i].key);
- for(var j=0; j < TSSETTINGS.Settings["tagGroups"][i]["children"].length; j++) {
- // console.debug("Current tagname "+TSSETTINGS.Settings["tagGroups"][i]["children"][j].title);
- if(TSSETTINGS.Settings["tagGroups"][i]["children"][j].title == tagName) {
- return TSSETTINGS.Settings["tagGroups"][i]["children"][j];
- }
- }
- }
- }
- return false;
-}
-
-TSSETTINGS.getAllTags = function() {
- var allTags = [];
- for(var i=0; i < TSSETTINGS.Settings["tagGroups"].length; i++) {
- // console.debug("Current taggroup "+TSSETTINGS.Settings["tagGroups"][i].key);
- for(var j=0; j < TSSETTINGS.Settings["tagGroups"][i]["children"].length; j++) {
- // console.debug("Current tagname "+TSSETTINGS.Settings["tagGroups"][i]["children"][j].title);
- if(TSSETTINGS.Settings["tagGroups"][i]["children"][j].type == "plain") {
- allTags.push(TSSETTINGS.Settings["tagGroups"][i]["children"][j].title);
- }
- }
- }
- return allTags;
-}
-
-TSSETTINGS.setLastOpenedDir = function(directory) {
- TSSETTINGS.Settings["lastOpenedDirectory"] = directory;
- TSSETTINGS.saveSettings();
-}
-
-TSSETTINGS.getLastOpenedDir = function() {
- return TSSETTINGS.Settings["lastOpenedDirectory"];
-}
-
-TSSETTINGS.deleteTag = function(tagData) {
- for(var i=0; i < TSSETTINGS.Settings["tagGroups"].length; i++) {
- if(TSSETTINGS.Settings["tagGroups"][i].key == tagData.parentKey) {
- for(var j=0; j < TSSETTINGS.Settings["tagGroups"][i]["children"].length; j++) {
- if(TSSETTINGS.Settings["tagGroups"][i]["children"][j].title == tagData.title) {
- TSSETTINGS.Settings["tagGroups"][i]["children"].splice(j, 1);
- break;
- }
- }
- }
- }
- TSSETTINGS.saveSettings();
-}
-
-TSSETTINGS.getTagData = function(tagTitle, parentKey) {
- for(var i=0; i < TSSETTINGS.Settings["tagGroups"].length; i++) {
- if(TSSETTINGS.Settings["tagGroups"][i].key == parentKey) {
- for(var j=0; j < TSSETTINGS.Settings["tagGroups"][i]["children"].length; j++) {
- if(TSSETTINGS.Settings["tagGroups"][i]["children"][j].title == tagTitle) {
- return TSSETTINGS.Settings["tagGroups"][i]["children"][j];
- break;
- }
- }
- }
- }
-}
-
-TSSETTINGS.getTagGroupData = function(tagGroupKey) {
- for(var i=0; i < TSSETTINGS.Settings["tagGroups"].length; i++) {
- if(TSSETTINGS.Settings["tagGroups"][i].key == tagGroupKey) {
- return TSSETTINGS.Settings["tagGroups"][i];
- break;
- }
- }
-}
-
-TSSETTINGS.deleteTagGroup = function(tagData) {
- for(var i=0; i < TSSETTINGS.Settings["tagGroups"].length; i++) {
- if(TSSETTINGS.Settings["tagGroups"][i].key == tagData.key) {
- console.debug("Deleting taggroup "+TSSETTINGS.Settings["tagGroups"][i].key);
- TSSETTINGS.Settings["tagGroups"].splice(i, 1);
- break;
- }
- }
- TSSETTINGS.saveSettings();
-}
-
-TSSETTINGS.editTag = function(tagData, newTagName) {
- for(var i=0; i < TSSETTINGS.Settings["tagGroups"].length; i++) {
- if(TSSETTINGS.Settings["tagGroups"][i].key == tagData.parentKey) {
- for(var j=0; j < TSSETTINGS.Settings["tagGroups"][i]["children"].length; j++) {
- if(TSSETTINGS.Settings["tagGroups"][i]["children"][j].title == tagData.title) {
- TSSETTINGS.Settings["tagGroups"][i]["children"][j].title = newTagName;
- break;
- }
- }
- }
- }
- TSSETTINGS.saveSettings();
-}
-
-TSSETTINGS.createTag = function(tagData, newTagName) {
- var newTagModel = JSON.parse( JSON.stringify(TSSETTINGS.TagTemplate));
- newTagModel.title = newTagName;
- for(var i=0; i < TSSETTINGS.Settings["tagGroups"].length; i++) {
- if(TSSETTINGS.Settings["tagGroups"][i].key == tagData.key) {
- console.debug("Creating tag: "+JSON.stringify(newTagModel)+" with parent: "+tagData.key);
- TSSETTINGS.Settings["tagGroups"][i]["children"].push(newTagModel);
- break;
- }
- }
- TSSETTINGS.saveSettings();
-}
-
-TSSETTINGS.editTagGroup = function(tagData, tagGroupName) {
- for(var i=0; i < TSSETTINGS.Settings["tagGroups"].length; i++) {
- if(TSSETTINGS.Settings["tagGroups"][i].key == tagData.key) {
- TSSETTINGS.Settings["tagGroups"][i].title = tagGroupName;
- break;
- }
- }
- TSSETTINGS.saveSettings();
-}
-
-
-TSSETTINGS.duplicateTagGroup = function(tagData, tagGroupName, tagGroupKey) {
- var newTagGroupModel = undefined;
- for(var i=0; i < TSSETTINGS.Settings["tagGroups"].length; i++) {
- if(TSSETTINGS.Settings["tagGroups"][i].key == tagData.key) {
- newTagGroupModel = JSON.parse( JSON.stringify(TSSETTINGS.Settings["tagGroups"][i]));
- break;
- }
- }
- newTagGroupModel.title = tagGroupName;
- newTagGroupModel.key = tagGroupKey;
- console.debug("Creating taggroup: "+JSON.stringify(newTagGroupModel)+" with key: "+tagGroupKey);
- TSSETTINGS.Settings["tagGroups"].push(newTagGroupModel);
- TSSETTINGS.saveSettings();
-}
-
-TSSETTINGS.createFavorite = function(name, location) {
- var newFavoriteModel = JSON.parse( JSON.stringify(TSSETTINGS.FavoriteTemplate));
- name = name.replace("\\", "\\\\");
- name = name.replace("\\\\\\", "\\\\");
- name = name.replace("\\\\\\\\", "\\\\");
- newFavoriteModel.name = name;
- newFavoriteModel.path = location;
- TSSETTINGS.Settings["tagspacesList"].push(newFavoriteModel);
- TSSETTINGS.saveSettings();
-}
-
-TSSETTINGS.deleteFavorite = function(name) {
- for(var i=0; i < TSSETTINGS.Settings["tagspacesList"].length; i++) {
- console.debug("Traversing favorite "+TSSETTINGS.Settings["tagspacesList"][i].name+" searching for "+name);
- if(TSSETTINGS.Settings["tagspacesList"][i].name == name) {
- console.debug("Deleting favorite "+TSSETTINGS.Settings["tagspacesList"][i].name);
- TSSETTINGS.Settings["tagspacesList"].splice(i, 1);
- break;
- }
- }
- TSSETTINGS.saveSettings();
-}
-
-TSSETTINGS.updateSettingMozillaPreferences = function(settings) {
- var tmpSettings = JSON.parse(settings);
- if(tmpSettings != null) {
- TSSETTINGS.Settings = tmpSettings;
- console.debug("Settings loaded from firefox preferences: "+tmpSettings);
- } else {
- TSSETTINGS.Settings = TSSETTINGS.DefaultSettings;
- console.debug('Default settings loaded(Firefox)!');
- }
- TSSETTINGS.saveSettings();
-}
-
-TSSETTINGS.firstRun = false;
-
-TSSETTINGS.loadSettingsLocalStorage = function() {
- try {
- var tmpSettings = JSON.parse(localStorage.getItem('tsSettings'));
- console.debug("Settings: "+JSON.stringify(tmpSettings));
- if(tmpSettings!=null) {
- TSSETTINGS.Settings = tmpSettings;
- } else {
- // If no settings found in the local storage,
- // the application runs for the first time.
- TSSETTINGS.firstRun = true;
- }
- } catch(ex) {
- console.debug("Loading settings from local storage failed due exception: "+ex);
- }
-}
-
-// Save setting and Reloads the app
-TSSETTINGS.saveSettings = function() {
- // Storing setting in the local storage for mozilla and chorme
- localStorage.setItem('tsSettings', JSON.stringify(TSSETTINGS.Settings));
-
- // Storing settings in mozilla native preferences
- if($.browser.mozilla) {
- IOAPI.saveSettings(JSON.stringify(TSSETTINGS.Settings));
+
+ exports.getExtensions = function() {
+ if(exports.Settings["extensions"] == null) {
+ exports.Settings["extensions"] = exports.DefaultSettings["extensions"];
+ }
+ return exports.Settings["extensions"];
+ }
+
+ exports.getExtensionPath = function() {
+ if(exports.Settings["extensionsPath"] == null) {
+ exports.Settings["extensionsPath"] = exports.DefaultSettings["extensionsPath"];
+ }
+ return exports.Settings["extensionsPath"];
+ }
+
+ exports.getNewTextFileContent = function() {
+ return exports.Settings["newTextFileContent"];
}
- console.debug('Tagspace Settings Saved!');
-}
+ exports.getNewHTMLFileContent = function() {
+ return exports.Settings["newHTMLFileContent"];
+ }
+
+ exports.getNewMDFileContent = function() {
+ return exports.Settings["newMDFileContent"];
+ }
+
+ exports.getFileTypeEditor = function(fileTypeExt) {
+ for(var i=0; i < exports.Settings["supportedFileTypes"].length; i++) {
+ if(exports.Settings["supportedFileTypes"][i].type == fileTypeExt) {
+ return exports.Settings["supportedFileTypes"][i].editor;
+ }
+ }
+ return false;
+ }
+
+ exports.getFileTypeViewer = function(fileTypeExt) {
+ for(var i=0; i < exports.Settings["supportedFileTypes"].length; i++) {
+ if(exports.Settings["supportedFileTypes"][i].type == fileTypeExt) {
+ return exports.Settings["supportedFileTypes"][i].viewer;
+ }
+ }
+ return false;
+ }
+
+ exports.findTag = function(tagName, tagGroupKey) {
+ for(var i=0; i < exports.Settings["tagGroups"].length; i++) {
+ if(exports.Settings["tagGroups"][i].key == tagGroupKey) {
+ // console.debug("Current taggroup "+exports.Settings["tagGroups"][i].key);
+ for(var j=0; j < exports.Settings["tagGroups"][i]["children"].length; j++) {
+ // console.debug("Current tagname "+exports.Settings["tagGroups"][i]["children"][j].title);
+ if(exports.Settings["tagGroups"][i]["children"][j].title == tagName) {
+ return exports.Settings["tagGroups"][i]["children"][j];
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ exports.getAllTags = function() {
+ var allTags = [];
+ for(var i=0; i < exports.Settings["tagGroups"].length; i++) {
+ // console.debug("Current taggroup "+exports.Settings["tagGroups"][i].key);
+ for(var j=0; j < exports.Settings["tagGroups"][i]["children"].length; j++) {
+ // console.debug("Current tagname "+exports.Settings["tagGroups"][i]["children"][j].title);
+ if(exports.Settings["tagGroups"][i]["children"][j].type == "plain") {
+ allTags.push(exports.Settings["tagGroups"][i]["children"][j].title);
+ }
+ }
+ }
+ return allTags;
+ }
+
+ exports.setLastOpenedDir = function(directory) {
+ exports.Settings["lastOpenedDirectory"] = directory;
+ exports.saveSettings();
+ }
+
+ exports.getLastOpenedDir = function() {
+ return exports.Settings["lastOpenedDirectory"];
+ }
+
+ exports.deleteTag = function(tagData) {
+ for(var i=0; i < exports.Settings["tagGroups"].length; i++) {
+ if(exports.Settings["tagGroups"][i].key == tagData.parentKey) {
+ for(var j=0; j < exports.Settings["tagGroups"][i]["children"].length; j++) {
+ if(exports.Settings["tagGroups"][i]["children"][j].title == tagData.title) {
+ exports.Settings["tagGroups"][i]["children"].splice(j, 1);
+ break;
+ }
+ }
+ }
+ }
+ exports.saveSettings();
+ }
+
+ exports.getTagData = function(tagTitle, parentKey) {
+ for(var i=0; i < exports.Settings["tagGroups"].length; i++) {
+ if(exports.Settings["tagGroups"][i].key == parentKey) {
+ for(var j=0; j < exports.Settings["tagGroups"][i]["children"].length; j++) {
+ if(exports.Settings["tagGroups"][i]["children"][j].title == tagTitle) {
+ return exports.Settings["tagGroups"][i]["children"][j];
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ exports.getTagGroupData = function(tagGroupKey) {
+ for(var i=0; i < exports.Settings["tagGroups"].length; i++) {
+ if(exports.Settings["tagGroups"][i].key == tagGroupKey) {
+ return exports.Settings["tagGroups"][i];
+ break;
+ }
+ }
+ }
+
+ exports.deleteTagGroup = function(tagData) {
+ for(var i=0; i < exports.Settings["tagGroups"].length; i++) {
+ if(exports.Settings["tagGroups"][i].key == tagData.key) {
+ console.debug("Deleting taggroup "+exports.Settings["tagGroups"][i].key);
+ exports.Settings["tagGroups"].splice(i, 1);
+ break;
+ }
+ }
+ exports.saveSettings();
+ }
+
+ exports.editTag = function(tagData, newTagName) {
+ for(var i=0; i < exports.Settings["tagGroups"].length; i++) {
+ if(exports.Settings["tagGroups"][i].key == tagData.parentKey) {
+ for(var j=0; j < exports.Settings["tagGroups"][i]["children"].length; j++) {
+ if(exports.Settings["tagGroups"][i]["children"][j].title == tagData.title) {
+ exports.Settings["tagGroups"][i]["children"][j].title = newTagName;
+ break;
+ }
+ }
+ }
+ }
+ exports.saveSettings();
+ }
+
+ exports.createTag = function(tagData, newTagName) {
+ var newTagModel = JSON.parse( JSON.stringify(exports.TagTemplate));
+ newTagModel.title = newTagName;
+ for(var i=0; i < exports.Settings["tagGroups"].length; i++) {
+ if(exports.Settings["tagGroups"][i].key == tagData.key) {
+ console.debug("Creating tag: "+JSON.stringify(newTagModel)+" with parent: "+tagData.key);
+ exports.Settings["tagGroups"][i]["children"].push(newTagModel);
+ break;
+ }
+ }
+ exports.saveSettings();
+ }
+
+ exports.editTagGroup = function(tagData, tagGroupName) {
+ for(var i=0; i < exports.Settings["tagGroups"].length; i++) {
+ if(exports.Settings["tagGroups"][i].key == tagData.key) {
+ exports.Settings["tagGroups"][i].title = tagGroupName;
+ break;
+ }
+ }
+ exports.saveSettings();
+ }
+
+
+ exports.duplicateTagGroup = function(tagData, tagGroupName, tagGroupKey) {
+ var newTagGroupModel = undefined;
+ for(var i=0; i < exports.Settings["tagGroups"].length; i++) {
+ if(exports.Settings["tagGroups"][i].key == tagData.key) {
+ newTagGroupModel = JSON.parse( JSON.stringify(exports.Settings["tagGroups"][i]));
+ break;
+ }
+ }
+ newTagGroupModel.title = tagGroupName;
+ newTagGroupModel.key = tagGroupKey;
+ console.debug("Creating taggroup: "+JSON.stringify(newTagGroupModel)+" with key: "+tagGroupKey);
+ exports.Settings["tagGroups"].push(newTagGroupModel);
+ exports.saveSettings();
+ }
+
+ exports.createFavorite = function(name, location) {
+ var newFavoriteModel = JSON.parse( JSON.stringify(exports.FavoriteTemplate));
+ name = name.replace("\\", "\\\\");
+ name = name.replace("\\\\\\", "\\\\");
+ name = name.replace("\\\\\\\\", "\\\\");
+ newFavoriteModel.name = name;
+ newFavoriteModel.path = location;
+ exports.Settings["tagspacesList"].push(newFavoriteModel);
+ exports.saveSettings();
+ }
+
+ exports.deleteFavorite = function(name) {
+ for(var i=0; i < exports.Settings["tagspacesList"].length; i++) {
+ console.debug("Traversing favorite "+exports.Settings["tagspacesList"][i].name+" searching for "+name);
+ if(exports.Settings["tagspacesList"][i].name == name) {
+ console.debug("Deleting favorite "+exports.Settings["tagspacesList"][i].name);
+ exports.Settings["tagspacesList"].splice(i, 1);
+ break;
+ }
+ }
+ exports.saveSettings();
+ }
+
+ exports.updateSettingMozillaPreferences = function(settings) {
+ var tmpSettings = JSON.parse(settings);
+ if(tmpSettings != null) {
+ exports.Settings = tmpSettings;
+ console.debug("Settings loaded from firefox preferences: "+tmpSettings);
+ } else {
+ exports.Settings = exports.DefaultSettings;
+ console.debug('Default settings loaded(Firefox)!');
+ }
+ exports.saveSettings();
+ }
+
+ exports.firstRun = false;
+
+ exports.loadSettingsLocalStorage = function() {
+ try {
+ var tmpSettings = JSON.parse(localStorage.getItem('exports'));
+ console.debug("Settings: "+JSON.stringify(tmpSettings));
+ if(tmpSettings!=null) {
+ exports.Settings = tmpSettings;
+ } else {
+ // If no settings found in the local storage,
+ // the application runs for the first time.
+ exports.firstRun = true;
+ }
+ } catch(ex) {
+ console.debug("Loading settings from local storage failed due exception: "+ex);
+ }
+ }
+
+ // Save setting and Reloads the app
+ exports.saveSettings = function() {
+ // Storing setting in the local storage for mozilla and chorme
+ localStorage.setItem('exports', JSON.stringify(exports.Settings));
+
+ // Storing settings in mozilla native preferences
+ if($.browser.mozilla) {
+ IOAPI.saveSettings(JSON.stringify(exports.Settings));
+ }
+
+ console.debug('Tagspace Settings Saved!');
+ }
+
-return TSSETTINGS;
});
\ No newline at end of file
diff --git a/data/js/tags.ui.js b/data/js/tags.ui.js
index 92038648e..9081590f4 100644
--- a/data/js/tags.ui.js
+++ b/data/js/tags.ui.js
@@ -1,30 +1,28 @@
/* Copyright (c) 2012 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([
- 'require',
- 'exports',
- 'module',
-],function(require, exports, module) {
+define(function(require, exports, module) {
"use strict";
-console.debug("Loading TagsUI...");
+ console.debug("Loading tags.ui.js...");
+
+ var TSCORE = require("tscore");
function initContextMenus() {
$( "#tagSuggestionsMenu" ).menu({
select: function( event, ui ) {
- console.debug("Tag suggestion "+ui.item.attr( "action" )+" for tag: "+UIAPI.selectedTag);
+ console.debug("Tag suggestion "+ui.item.attr( "action" )+" for tag: "+TSCORE.selectedTag);
}
});
$( "#extensionMenu" ).menu({
select: function( event, ui ) {
- console.debug("Tag menu action: "+ui.item.attr( "action" )+" for tag: "+UIAPI.selectedTag);
+ console.debug("Tag menu action: "+ui.item.attr( "action" )+" for tag: "+TSCORE.selectedTag);
switch (ui.item.attr( "action" )) {
case "addTagAsFilter":
$( this ).hide();
- $("#filterBox").val(UIAPI.selectedTag);
- UIAPI.ViewManager.setFileFilter(UIAPI.selectedTag);
+ $("#filterBox").val(TSCORE.selectedTag);
+ TSCORE.ViewManager.setFileFilter(TSCORE.selectedTag);
break;
}
}
@@ -33,12 +31,12 @@ console.debug("Loading TagsUI...");
// Context menu for the tags in the file table and the file viewer
$( "#tagMenu" ).menu({
select: function( event, ui ) {
- console.debug("Tag menu action: "+ui.item.attr( "action" )+" for tag: "+UIAPI.selectedTag);
+ console.debug("Tag menu action: "+ui.item.attr( "action" )+" for tag: "+TSCORE.selectedTag);
switch (ui.item.attr( "action" )) {
case "addTagAsFilter":
$( this ).hide();
- $("#filterBox").val(UIAPI.selectedTag);
- UIAPI.ViewManager.setFileFilter(UIAPI.selectedTag);
+ $("#filterBox").val(TSCORE.selectedTag);
+ TSCORE.ViewManager.setFileFilter(TSCORE.selectedTag);
break;
case "addTagInTagGroup":
$( this ).hide();
@@ -46,12 +44,12 @@ console.debug("Loading TagsUI...");
break;
case "editTag":
$( this ).hide();
- $( "#newTag" ).val(UIAPI.selectedTag);
+ $( "#newTag" ).val(TSCORE.selectedTag);
$( "#dialogEditTag" ).dialog( "open" );
break;
case "removeTag":
$( this ).hide();
- UIAPI.TagUtils.removeTag(UIAPI.selectedFiles[0],UIAPI.selectedTag);
+ TSCORE.TagUtils.removeTag(TSCORE.selectedFiles[0],TSCORE.selectedTag);
break;
}
}
@@ -60,17 +58,17 @@ console.debug("Loading TagsUI...");
// Context menu for the tags in the tag tree
$( "#tagTreeMenu" ).menu({
select: function( event, ui ) {
- console.debug("Tag menu action: "+ui.item.attr( "action" )+" for tag: "+UIAPI.selectedTag);
+ console.debug("Tag menu action: "+ui.item.attr( "action" )+" for tag: "+TSCORE.selectedTag);
switch (ui.item.attr( "action" )) {
case "addTagToFile":
- UIAPI.TagUtils.addTag(UIAPI.selectedFiles, [UIAPI.selectedTag]);
+ TSCORE.TagUtils.addTag(TSCORE.selectedFiles, [TSCORE.selectedTag]);
break;
case "addTagAsFilter":
- $("#filterBox").val(UIAPI.selectedTag);
- UIAPI.ViewManager.setFileFilter(UIAPI.selectedTag);
+ $("#filterBox").val(TSCORE.selectedTag);
+ TSCORE.ViewManager.setFileFilter(TSCORE.selectedTag);
break;
case "editTag":
- $( "#tagName" ).val(UIAPI.selectedTag);
+ $( "#tagName" ).val(TSCORE.selectedTag);
$( "#dialog-tagedit" ).dialog( "open" );
break;
case "deleteTag":
@@ -83,7 +81,7 @@ console.debug("Loading TagsUI...");
// Context menu for the tags groups
$( "#tagGroupMenu" ).menu({
select: function( event, ui ) {
- console.debug("TagGroup menu action: "+ui.item.attr( "action" )+" for tag: "+UIAPI.selectedTag);
+ console.debug("TagGroup menu action: "+ui.item.attr( "action" )+" for tag: "+TSCORE.selectedTag);
switch (ui.item.attr( "action" )) {
case "createNewTag":
$( "#newTagName" ).val("");
@@ -96,7 +94,7 @@ console.debug("Loading TagsUI...");
$( "#dialog-taggroupDupicate" ).dialog( "open" );
break;
case "editTagGroup":
- $( "#tagGroupName" ).val(UIAPI.selectedTagData.title);
+ $( "#tagGroupName" ).val(TSCORE.selectedTagData.title);
$( "#dialog-taggroupEdit" ).dialog( "open" );
break;
}
@@ -114,11 +112,11 @@ console.debug("Loading TagsUI...");
break;
case "openFile":
console.debug("Opening file...");
- UIAPI.openFile(UIAPI.selectedFiles[0]);
+ TSCORE.openFile(TSCORE.selectedFiles[0]);
break;
case "openDirectory":
console.debug("Opening parent directory...");
- IOAPI.openDirectory(UIAPI.currentPath);
+ IOAPI.openDirectory(TSCORE.currentPath);
break;
case "renameFile":
console.debug("Renaming file...");
@@ -191,11 +189,11 @@ console.debug("Loading TagsUI...");
bValid = bValid && checkLength( smartTag, "tagname", 2, 40 );
if ( bValid ) {
- for (var i=0; i < UIAPI.selectedFiles.length; i++) {
- UIAPI.TagUtils.writeTagsToFile(UIAPI.selectedFiles[i], [smartTag.val()]);
+ for (var i=0; i < TSCORE.selectedFiles.length; i++) {
+ TSCORE.TagUtils.writeTagsToFile(TSCORE.selectedFiles[i], [smartTag.val()]);
};
$( this ).dialog( "close" );
- IOAPI.listDirectory(UIAPI.currentPath);
+ IOAPI.listDirectory(TSCORE.currentPath);
}
},
Cancel: function() {
@@ -206,7 +204,7 @@ console.debug("Loading TagsUI...");
allFields.val( "" ).removeClass( "ui-state-error" );
},
open: function() {
- $( "#renamedFileName" ).val(UIAPI.selectedFiles[0]);
+ $( "#renamedFileName" ).val(TSCORE.selectedFiles[0]);
}
});
@@ -218,9 +216,9 @@ console.debug("Loading TagsUI...");
modal: true,
buttons: {
"Remove": function() {
- UIAPI.TagUtils.removeTag(UIAPI.selectedTag);
+ TSCORE.TagUtils.removeTag(TSCORE.selectedTag);
$( this ).dialog( "close" );
- IOAPI.listDirectory(UIAPI.currentPath);
+ IOAPI.listDirectory(TSCORE.currentPath);
},
Cancel: function() {
$( this ).dialog( "close" );
@@ -235,7 +233,7 @@ console.debug("Loading TagsUI...");
modal: true,
buttons: {
"Delete": function() {
- TSSETTINGS.deleteTag(UIAPI.selectedTagData);
+ TSCORE.Config.deleteTag(TSCORE.selectedTagData);
TagsUI.generateTagGroups();
$( this ).dialog( "close" );
},
@@ -252,7 +250,7 @@ console.debug("Loading TagsUI...");
modal: true,
buttons: {
"Delete": function() {
- TSSETTINGS.deleteTagGroup(UIAPI.selectedTagData);
+ TSCORE.Config.deleteTagGroup(TSCORE.selectedTagData);
TagsUI.generateTagGroups();
$( this ).dialog( "close" );
},
@@ -269,7 +267,7 @@ console.debug("Loading TagsUI...");
modal: true,
buttons: {
"Save": function() {
- TSSETTINGS.editTag(UIAPI.selectedTagData, $( "#tagName" ).val() )
+ TSCORE.Config.editTag(TSCORE.selectedTagData, $( "#tagName" ).val() )
TagsUI.generateTagGroups();
$( this ).dialog( "close" );
},
@@ -286,7 +284,7 @@ console.debug("Loading TagsUI...");
modal: true,
buttons: {
"Create Tag": function() {
- TSSETTINGS.createTag(UIAPI.selectedTagData, $( "#newTagName" ).val() )
+ TSCORE.Config.createTag(TSCORE.selectedTagData, $( "#newTagName" ).val() )
TagsUI.generateTagGroups();
$( this ).dialog( "close" );
},
@@ -303,7 +301,7 @@ console.debug("Loading TagsUI...");
modal: true,
buttons: {
"Duplicate Taggroup": function() {
- TSSETTINGS.duplicateTagGroup(UIAPI.selectedTagData, $( "#newTagGroupName" ).val(), $( "#newTagGroupKey" ).val() )
+ TSCORE.Config.duplicateTagGroup(TSCORE.selectedTagData, $( "#newTagGroupName" ).val(), $( "#newTagGroupKey" ).val() )
TagsUI.generateTagGroups();
$( this ).dialog( "close" );
},
@@ -320,7 +318,7 @@ console.debug("Loading TagsUI...");
modal: true,
buttons: {
"Save": function() {
- TSSETTINGS.editTagGroup(UIAPI.selectedTagData, $( "#tagGroupName" ).val() )
+ TSCORE.Config.editTagGroup(TSCORE.selectedTagData, $( "#tagGroupName" ).val() )
TagsUI.generateTagGroups();
$( this ).dialog( "close" );
},
@@ -335,7 +333,7 @@ console.debug("Loading TagsUI...");
console.debug("Generating TagGroups...");
$("#tagGroups").empty();
$("#tagGroups").addClass("ui-accordion ui-accordion-icons ui-widget ui-helper-reset")
- for(var i=0; i < TSSETTINGS.Settings["tagGroups"].length; i++) {
+ for(var i=0; i < TSCORE.Config.Settings["tagGroups"].length; i++) {
// Code based on http://jsbin.com/eqape/1/edit
$("#tagGroups").append($("<h3>", {
class: "ui-accordion-header ui-helper-reset ui-state-default ui-corner-top ui-corner-bottom"
@@ -345,15 +343,15 @@ console.debug("Loading TagsUI...");
hoverClass: "activeRow",
drop: function( event, ui ) {
var tagName = ui.draggable.attr("tag");
- TSSETTINGS.createTag(UIAPI.selectedTagData, tagName );
- TSSETTINGS.deleteTag(UIAPI.selectedTagData);
+ TSCORE.Config.createTag(TSCORE.selectedTagData, tagName );
+ TSCORE.Config.deleteTag(TSCORE.selectedTagData);
TagsUI.generateTagGroups();
}
}) */
.hover(function() { $(this).toggleClass("ui-state-hover"); })
.append($("<span>", {
class: "tagGroupTitle",
- text: TSSETTINGS.Settings["tagGroups"][i].title,
+ text: TSCORE.Config.Settings["tagGroups"][i].title,
})
.click(function() {
$(this)
@@ -365,16 +363,16 @@ console.debug("Loading TagsUI...");
.append($("<span>", {
class: "ui-icon ui-icon-gear",
style: "float: right!important; position:relative!important; vertical-align: middle; display:inline-block;",
- tag: TSSETTINGS.Settings["tagGroups"][i].title,
- key: TSSETTINGS.Settings["tagGroups"][i].key,
+ tag: TSCORE.Config.Settings["tagGroups"][i].title,
+ key: TSCORE.Config.Settings["tagGroups"][i].key,
title: "Taggroup options",
})
.dropdown( 'attach' , '#tagGroupMenu' )
.click( function(event) {
//console.debug("Clicked in taggroup setting");
- UIAPI.selectedTag = $(this).attr("tag");
- UIAPI.selectedTagData = TSSETTINGS.getTagGroupData($(this).attr("key"));
- UIAPI.selectedTagData.parentKey = undefined;
+ TSCORE.selectedTag = $(this).attr("tag");
+ TSCORE.selectedTagData = TSCORE.Config.getTagGroupData($(this).attr("key"));
+ TSCORE.selectedTagData.parentKey = undefined;
})
)
);
@@ -383,13 +381,13 @@ console.debug("Loading TagsUI...");
tagButtons.attr("style","margin: 0px; padding: 5px;");
tagButtons.addClass("ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom")
tagButtons.hide();
- for(var j=0; j < TSSETTINGS.Settings["tagGroups"][i]["children"].length; j++) {
+ for(var j=0; j < TSCORE.Config.Settings["tagGroups"][i]["children"].length; j++) {
tagButtons.append($("<button>", {
class: "tagButton",
- tag: TSSETTINGS.Settings["tagGroups"][i]["children"][j].title,
- parentKey: TSSETTINGS.Settings["tagGroups"][i].key,
- title: "Opens context menu for "+TSSETTINGS.Settings["tagGroups"][i]["children"][j].title,
- text: TSSETTINGS.Settings["tagGroups"][i]["children"][j].title,
+ tag: TSCORE.Config.Settings["tagGroups"][i]["children"][j].title,
+ parentKey: TSCORE.Config.Settings["tagGroups"][i].key,
+ title: "Opens context menu for "+TSCORE.Config.Settings["tagGroups"][i]["children"][j].title,
+ text: TSCORE.Config.Settings["tagGroups"][i]["children"][j].title,
})
.draggable({
cancel:false,
@@ -398,9 +396,9 @@ console.debug("Loading TagsUI...");
revert: true,
})
.click( function() {
- UIAPI.selectedTag = $(this).attr("tag");
- UIAPI.selectedTagData = TSSETTINGS.getTagData($(this).attr("tag"), $(this).attr("parentKey"));
- UIAPI.selectedTagData.parentKey = $(this).attr("parentKey");
+ TSCORE.selectedTag = $(this).attr("tag");
+ TSCORE.selectedTagData = TSCORE.Config.getTagData($(this).attr("tag"), $(this).attr("parentKey"));
+ TSCORE.selectedTagData.parentKey = $(this).attr("parentKey");
})
.dropdown( 'attach' , '#tagTreeMenu' )
);
@@ -416,8 +414,8 @@ console.debug("Loading TagsUI...");
}
function openTagMenu(tagButton, tag, filePath) {
- UIAPI.selectedFiles.push(filePath);
- UIAPI.selectedTag = tag;
+ TSCORE.selectedFiles.push(filePath);
+ TSCORE.selectedTag = tag;
}
// Helper function user by basic and search views
@@ -426,7 +424,7 @@ console.debug("Loading TagsUI...");
var tagString = ""+commaSeparatedTags;
var wrapper = $('<span>');
if(filePath == undefined) {
- filePath = UIAPI.currentPath+UIAPI.TagUtils.DIR_SEPARATOR+fileName;
+ filePath = TSCORE.currentPath+TSCORE.TagUtils.DIR_SEPARATOR+fileName;
}
if(fileExtension.length > 0) {
wrapper.append($('<button>', {
@@ -460,7 +458,7 @@ console.debug("Loading TagsUI...");
title = "n/a";
}
if(filePath == undefined) {
- filePath = UIAPI.currentPath+UIAPI.TagUtils.DIR_SEPARATOR+fileName;
+ filePath = TSCORE.currentPath+TSCORE.TagUtils.DIR_SEPARATOR+fileName;
}
return $('<span>').append($('<button>', {
title: fileName,
@@ -473,7 +471,7 @@ console.debug("Loading TagsUI...");
// Helper function user by basic and search views
function buttonizeFileName(fileName, filePath) {
if(filePath == undefined) {
- filePath = UIAPI.currentPath+UIAPI.TagUtils.DIR_SEPARATOR+fileName;
+ filePath = TSCORE.currentPath+TSCORE.TagUtils.DIR_SEPARATOR+fileName;
}
return $('<span>').append($('<button>', {
title: fileName,
diff --git a/data/js/tagutils.js b/data/js/tagutils.js
index fe99cfe76..bbb5973b4 100644
--- a/data/js/tagutils.js
+++ b/data/js/tagutils.js
@@ -1,17 +1,12 @@
/* Copyright (c) 2012 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([
- 'require',
- 'exports',
- 'module'
-], function (require, exports, module) {
- "use strict";
-
- // TODO Workarround
- var ioAPI = IOAPI;
-
+define(function(require, exports, module) {
+"use strict";
+
console.debug("Loading tagutils.js ...");
+
+ var IOAPI = require("tsioapi");
var BEGIN_TAG_CONTAINER = "[",
END_TAG_CONTAINER = "]",
@@ -194,7 +189,7 @@ define([
var newFileName = generateFileName(fileName, extractedTags);
- ioAPI.renameFile(filePath, containingDirectoryPath+DIR_SEPARATOR+newFileName);
+ IOAPI.renameFile(filePath, containingDirectoryPath+DIR_SEPARATOR+newFileName);
}
function addTag(filePathArray, tagArray) {
@@ -223,7 +218,7 @@ define([
var newFileName = generateFileName(fileName, extractedTags);
- ioAPI.renameFile(filePath, containingDirectoryPath+DIR_SEPARATOR+newFileName);
+ IOAPI.renameFile(filePath, containingDirectoryPath+DIR_SEPARATOR+newFileName);
}
@@ -246,7 +241,7 @@ define([
var newFileName = generateFileName(fileName, newTags);
- ioAPI.renameFile(filePath, containingDirectoryPath+DIR_SEPARATOR+newFileName);
+ IOAPI.renameFile(filePath, containingDirectoryPath+DIR_SEPARATOR+newFileName);
}
// Public API definition
diff --git a/data/loader.js b/data/loader.js
index db2a66e34..0fb66306a 100644
--- a/data/loader.js
+++ b/data/loader.js
@@ -1,7 +1,32 @@
/* Copyright (c) 2012 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. */
-console.debug("Loading Loader...");
+
+//var LOG = debug ? console.log : function () {};
+var PRODUCTION = "@PRODUCTION@";// "true" | "@PRODUCTION@"
+
+// Disabling all output to console in production mode
+if (PRODUCTION == "true") {
+ console = console || {};
+ console.log = function(){};
+ console.error = function(){};
+ console.debug = function(){};
+}
+
+// Temporal hacks
+var isFirefox = 'MozBoxSizing' in document.documentElement.style;
+var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
+var isChrome = !isSafari && 'WebkitTransform' in document.documentElement.style;
+
+console.debug("Loading Loader 4 Firefox: "+isFirefox+" | Chrome: "+isChrome);
+
+// Setting up the IO functionality according to the plattform
+var IO_JS = undefined;
+if( isFirefox ) {
+ IO_JS = "js/ioapi.mozilla";
+} else if ( isChrome ) {
+ IO_JS = "js/ioapi.chrome";
+}
require.config({
map: {
@@ -31,6 +56,7 @@ require.config({
jqueryuitabs: 'libs/jqueryui/jquery.ui.tabs',
jqueryuitooltips: 'libs/jqueryui/jquery.ui.tooltip',
jqueryuicss: 'libs/jqueryui/custom-theme/jquery-ui-1.9.2.custom',
+
datatables: 'libs/datatables/js/jquery.dataTables.min',
datatablescss: 'libs/datatables/css/jquery.dataTables',
jsoneditor: 'libs/jsoneditor/jsoneditor',
@@ -49,7 +75,8 @@ require.config({
tstagsui: "js/tags.ui",
tsdirectoriesui: "js/directories.ui",
tscoreui: "js/core.ui",
-
+ tsioapi: IO_JS,
+ tsiomozrec: "js/ioapi.mozilla.receiver",
},
shim: {
'jquerylayout': {
@@ -115,62 +142,33 @@ require.config({
'jquery'
]
},
-
- 'tscore': {
- deps: [
- 'tssetting',
- ]
- },
-
-/* less: {
- deps: [
- 'css!jquerylayoutcss',
- 'css!jqueryuicss',
- 'css!dynatreecss',
- 'css!datatablescss',
- 'css!jsoneditorcss'
- ]
- },*/
- }
+ }
});
-// Init Application
-require([
- 'jquery',
- 'jqueryui',
- 'datatables',
- 'jsoneditor',
- 'jquerylayout',
- 'jquerydropdown',
- 'jqueryuitooltips',
- 'jqueryuidroppable',
- 'less',
-],
-function() {
- console.debug("Loading Application...");
-
- UIAPI = undefined;
- TSSETTINGS = undefined;
+define(function (require, exports, module) {
+"use strict";
- // Setting up the IO functionality according to the plattform
- if( $.browser.mozilla ) {
- require([
- "js/messaging.mozilla",
- "js/ioapi.mozilla"
- ]);
- } else if ( $.browser.chrome ) {
- require([
- "js/ioapi.chrome"
- ]);
- } else { // TODO a more sophisticated check is required for cordova
- require([
- "js/ioapi.cordova"
- ]);
- }
+ console.debug("Loading Application...");
+
+ // Load dependent non-module scripts
+ require("jquery");
+ require("jqueryui");
+ require("datatables");
+ require("jsoneditor");
+ require("jquerylayout");
+ require("jquerydropdown");
+ require("jqueryuitooltips");
+ require("jqueryuidroppable");
+ require("less");
+ if( isFirefox ) {
+ require("tsiomozrec");
+ }
+
+ var TSCORE = require("tscore");
- require(["tscore","tssetting"], function(tsCore, tsSettings) {
- UIAPI = tsCore;
- TSSETTINGS = tsSettings;
- tsCore.initApp();
- });
+ function onReady() {
+ TSCORE.initApp();
+ }
+
+ $(window.document).ready(onReady);
});
\ No newline at end of file