Example #1
0
 nwwin.on('unmaximize', function() {
   TSCORE.Config.setIsWindowMaximized(false);
   TSCORE.Config.saveSettings();      
 }); 
Example #2
0
  var initUI = function() {
    // Search UI
    $('#searchBox')
      .keyup(function(e) {
        if (e.keyCode === 13) { // Start the search on ENTER
          startSearch();
        } else if (e.keyCode == 27) { // Hide search on ESC
          cancelSearch();
        } else {
          TSCORE.Search.nextQuery = this.value;
        }
        if (this.value.length === 0) {
          TSCORE.Search.nextQuery = this.value;
          TSCORE.PerspectiveManager.redrawCurrentPerspective();
        }
      })
      .focus(function(e) {
        $("#searchOptions").hide();
      });

    $('#showSearchButton').on('click', function() {
      // Showing the expanded search area
      TSCORE.showSearchArea();
    });

    $('#searchButton').on("click", function(e) {
      startSearch();
    });

    $('#startSearchButton').on("click", function(e) {
      e.preventDefault();
      updateQuery();
      startSearch();
    });

    $('#showSearchOptionsButton').on("click", function() {
      showSearchOptions();
    });

    $('#searchOptions').on('click', '.close', function() {
      $('#searchOptions').hide();
    });

    $('#resetSearchButton').on('click', function(e) {
      e.preventDefault();
      resetSearchOptions();
      $('#searchBox').val("");
    });

    $('#clearSearchButton').on('click', function(e) {
      e.preventDefault();
      $('#searchOptions').hide();
      cancelSearch();
    });

    $('#searchRecursive').attr('checked', TSCORE.Config.getUseSearchInSubfolders());

    $('#searchRecursive').on('click', function(e) {
      updateQuery();
    });

    $('#searchTerms').on('blur', function(e) {
      updateQuery();
    });

    $('#searchTags').on('blur', function(e) {
      updateQuery();
    });

    $('#searchFileType').on('change', function(e) {
      updateQuery();
    });

    if (TSCORE.PRO) {
      $('#searchFileType').prop('disabled', false);
      $('#searchHistory').prop('disabled', false);
      $('#searchFileType').attr('title', '');
      $('#searchHistory').attr('title', '');
      $('#searchFileType').removeClass('disabled');
      $('#searchHistory').removeClass('disabled');
    }
  };
Example #3
0
 tags.forEach(function (value) {
 	TSCORE.Config.createTag(TSCORE.selectedTagData, value );            	
 });
Example #4
0
 $( "#tagGroupMenuMoveDown" ).click( function() {
     TSCORE.Config.moveTagGroup(TSCORE.selectedTagData, "down");
     generateTagGroups(); 
 });                
Example #5
0
 "start":     function() {
     console.log("Start dragging..........");
     TSCORE.selectedTagData = TSCORE.Config.getTagData($(this).attr("tag"), $(this).attr("parentKey"));
     TSCORE.selectedTag = generateTagValue(TSCORE.selectedTagData);
     TSCORE.selectedTagData.parentKey = $(this).attr("parentKey");
 }
  function initMainMenu() {
    if (isOSX) {
      rootMenu.createMacBuiltin("TagSpaces");
    }
    if (TSCORE.Config.getShowMainMenu() && !menuInitialuzed) {
      aboutMenu.append(new gui.MenuItem({
        type: 'normal',
        label: $.i18n.t("ns.common:aboutTagSpaces"),
        click: function() {
          TSCORE.UI.showAboutDialog();
        }
      }));

      viewMenu.append(new gui.MenuItem({
        type: 'normal',
        label: $.i18n.t("ns.common:showTagLibraryTooltip") + " (" + TSCORE.Config.getShowTagLibraryKeyBinding() + ")",
        click: function() {
          TSCORE.UI.showTagsPanel();
        }
      }));

      viewMenu.append(new gui.MenuItem({
        type: 'normal',
        label: $.i18n.t("ns.common:showLocationNavigatorTooltip") + " (" + TSCORE.Config.getShowFolderNavigatorBinding() + ")",
        click: function() {
          TSCORE.UI.showLocationsPanel();
        }
      }));

      viewMenu.append(new gui.MenuItem({
        type: 'separator'
      }));

      viewMenu.append(new gui.MenuItem({
        type: 'normal',
        label: $.i18n.t("ns.common:toggleFullScreen") + " (" + TSCORE.Config.getToggleFullScreenKeyBinding().toUpperCase() + ")",
        click: function() {
          win.toggleFullscreen();
        }
      }));

      viewMenu.append(new gui.MenuItem({
        type: 'normal',
        label: $.i18n.t("ns.common:showDevTools") + " (" + TSCORE.Config.getOpenDevToolsScreenKeyBinding().toUpperCase() + ")",
        click: function() {
          win.showDevTools();
        }
      }));

      viewMenu.append(new gui.MenuItem({
        type: 'separator'
      }));

      viewMenu.append(new gui.MenuItem({
        type: 'normal',
        label: $.i18n.t("ns.common:settings"),
        click: function() {
          TSCORE.UI.showOptionsDialog();
        }
      }));

      rootMenu.append(new gui.MenuItem({
        type: 'normal',
        label: $.i18n.t("ns.common:view"),
        submenu: viewMenu
      }));

      rootMenu.append(new gui.MenuItem({
        type: 'normal',
        label: $.i18n.t("ns.common:help"),
        submenu: aboutMenu
      }));
      win.menu = rootMenu;

      menuInitialuzed = true;
    } else {
      if (isOSX) {
        win.menu = rootMenu;
      }
    }
  }
Example #7
0
define(function(require, exports, module) {
  "use strict";

  var extensionID = "viewerEPUB"; // ID should be equal to the directory name where the ext. is located
  var extensionSupportedFileTypes = ["epub"];

  console.log("Loading " + extensionID);

  var TSCORE = require("tscore");
  var extensionDirectory = TSCORE.Config.getExtensionPath() + "/" + extensionID;
  var reader = require("ext/viewerEPUB/epubreader");
  require([
    'css!' + extensionDirectory + '/extension.css',
  ], function() {});

  function initViewerUI(elementID, renderID) {
    var $prev = $("<div class='viewerEPUBNaviButton'>‹</div>").click(reader.prevPage);

    var $next = $("<div class='viewerEPUBNaviButton'>›</div>").click(reader.nextPage);

    var $area = $("<div>")
      .attr('id', renderID)
      .addClass("flexMaxWidth")
      .addClass("flexLayoutVertical")
      .css({"margin": "5% auto"});

    var $main = $("<div>")
      .attr('id', 'viewerEPUBMain')
      .addClass("flexLayout")
      .css({"width": "100%"})
      .append($prev)
      .append($area)
      .append($next);

    $('#' + elementID).append($main);
  }

  function init(filePath, elementID) {
    console.log("Initalization EPUB Viewer...");

    var renderID = getRandomID("epub");
    initViewerUI(elementID, renderID);
    if (!isCordova) {
      filePath = "file://" + filePath;
    }
    reader.loadBook(filePath, renderID);
  }

  function viewerMode() {

    console.log("viewerMode not supported on this extension");
  }

  function setContent() {

    console.log("setContent not supported on this extension");
  }

  function getContent() {

    console.log("getContent not supported on this extension");
  }

  function getRandomID(prefix, length) {
    var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
    var string_length = length || 8;
    var randomstring = '';
    for (var i = 0; i < string_length; i++) {
      var rnum = Math.floor(Math.random() * chars.length);
      randomstring += chars.substring(rnum, rnum + 1);
    }
    return prefix ? prefix + "-" + randomstring : randomstring;
  }

  exports.init = init;
  exports.getContent = getContent;
  exports.setContent = setContent;
  exports.viewerMode = viewerMode;
});
Example #8
0
    var initMainMenu = function() {

        if(win.menu === undefined) {
            win.menu = rootMenu;

            // TODO Clear the menu on reload
            if(TSCORE.Config.getShowMainMenu()) {
                aboutMenu.append(new gui.MenuItem({
                    type: 'normal',
                    label: $.i18n.t("ns.common:aboutTagSpaces"),
                    click: function (){
                        TSCORE.UI.showAboutDialog();
                    } }));

                viewMenu.append(new gui.MenuItem({
                    type: 'normal',
                    label: $.i18n.t("ns.common:showTagLibraryTooltip")+" ("+TSCORE.Config.getShowTagLibraryKeyBinding()+")",
                    click: function (){
                        TSCORE.UI.showTagsPanel();
                    } }));

                viewMenu.append(new gui.MenuItem({
                    type: 'normal',
                    label: $.i18n.t("ns.common:showLocationNavigatorTooltip")+" ("+TSCORE.Config.getShowFolderNavigatorBinding()+")",
                    click: function (){
                        TSCORE.UI.showLocationsPanel();
                    } }));

                viewMenu.append(new gui.MenuItem({ type: 'separator' }));

                viewMenu.append(new gui.MenuItem({
                    type: 'normal',
                    label: $.i18n.t("ns.common:toggleFullScreen")+" ("+TSCORE.Config.getToggleFullScreenKeyBinding().toUpperCase()+")",
                    click: function (){
                        win.toggleFullscreen();
                    } }));

                viewMenu.append(new gui.MenuItem({
                    type: 'normal',
                    label: $.i18n.t("ns.common:showDevTools")+" ("+TSCORE.Config.getOpenDevToolsScreenKeyBinding().toUpperCase()+")",
                    click: function (){
                        win.showDevTools();
                    } }));

                viewMenu.append(new gui.MenuItem({ type: 'separator' }));

                viewMenu.append(new gui.MenuItem({
                    type: 'normal',
                    label: 'Settings',
                    click: function (){
                        TSCORE.UI.showOptionsDialog();
                    } }));

                rootMenu.append(new gui.MenuItem({
                    label: 'View',
                    submenu: viewMenu
                }));

                rootMenu.append(new gui.MenuItem({
                    label: 'Help',
                    submenu: aboutMenu
                }));
            }
        }
    };
Example #9
0
define(function(require, exports, module) {
"use strict";

	console.log("Loading viewerText");

    var extensionTitle = "IFrame Viewer";
    var extensionID = "viewerBrowser";  // ID should be equal to the directory name where the ext. is located   
    var extensionType =  "viewer";
    var extensionIcon = "icon-list";
    var extensionVersion = "1.0";
    var extensionManifestVersion = 1;
    var extensionLicense = "AGPL";
    var extensionSupportedFileTypes = [ "*" ];
	
	var TSCORE = require("tscore");	
	
	var containerElID = undefined;
	
	var extensionDirectory = TSCORE.Config.getExtensionPath()+"/"+extensionID;
	
	exports.init = function(filePath, containerElementID) {
	    console.log("Initalization Text Viewer...");
	    containerElID = containerElementID;

        var filePathURI = undefined;
        if(isCordova) {
            filePathURI = filePath;            
        } else {
            filePathURI = "file:///"+filePath;  
        }
        
        var fileExt = TSCORE.TagUtils.extractFileExtension(filePath);

        $('#'+containerElID).empty();        
        
        if((fileExt.indexOf("htm") == 0 || fileExt.indexOf("xhtm") == 0 || fileExt.indexOf("txt") == 0) && !isFirefox) {
	        $("#"+containerElID).append($('<iframe>', {
			    	id: "iframeViewer",
					"nwdisable": "",
					"nwfaketop": "",
	        	})
	        );
	     	TSCORE.IO.loadTextFile(filePath);	    	 
        } else {
        	$("#"+containerElID).append($('<iframe>', {
			    	id: "iframeViewer",
					src: filePathURI,
					"nwdisable": "",
					"nwfaketop": "",
	        	})
	        );
	    }
	};
	
	exports.setFileType = function(fileType) {
	    console.log("setFileType not supported on this extension");      
	};
	
	exports.viewerMode = function(isViewerMode) {
	    // set readonly      
	};
	
	exports.setContent = function(content) {
	    // removing the script tags from the content 
        var cleanedContent = content.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,""); 	    
	    var viewerIframe = $("#iframeViewer").get(0);
	    if(viewerIframe != undefined) {
	    	viewerIframe.contentWindow.document.write(cleanedContent);

	    	// disabling the links
	    	$(viewerIframe.contentWindow.document).find( "a" ).bind('click', function(e){
	            e.preventDefault();
	    	})
	    }         
    };
	
	exports.getContent = function() {
        console.log("Not implemented");
	};
	
    // Extension Vars
    exports.Title                   = extensionTitle;
    exports.ID                      = extensionID;   
    exports.Type                    = extensionType;
    exports.Icon                    = extensionIcon;
    exports.Version                 = extensionVersion;
    exports.ManifestVersion         = extensionManifestVersion;
    exports.License                 = extensionLicense; 
    exports.SupportedFileTypes      = extensionSupportedFileTypes;	

});
Example #10
0
define(function(require, exports, module) {
"use strict";

	console.log("Loading editorText extension");

	exports.id = "editorText"; // ID should be equal to the directory name where the ext. is located   
	exports.title = "Text Editor based on codemirror";
	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");

    var cmEditor = undefined;
    var extensionDirectory = TSCORE.Config.getExtensionPath()+"/"+exports.id;

	
	exports.init = function(filePath, containerElementID, isViewerMode) {
        console.log("Initalization Text Editor...");
        var fileExt = filePath.substring(filePath.lastIndexOf(".")+1,filePath.length).toLowerCase();

        $("#"+containerElementID).append('<div id="code" name="code" style="width: 100%; height: 100%">');
        var mode = filetype[fileExt];
        if (mode == null) {
            mode = "properties";
        }
        require([
            extensionDirectory+'/codemirror/codemirror.js',
            'css!'+extensionDirectory+'/codemirror/codemirror.css',
            'css!'+extensionDirectory+'/extension.css'
        ], function() {
            require([
                extensionDirectory+"/codemirror/mode/" + mode + "/" + mode + ".js"
            ], function() {
                cmEditor = CodeMirror(document.getElementById("code"), {
                    fixedGutter: false,
                    mode: mode,
                    lineNumbers: true,
                    lineWrapping: true,
                    tabSize: 2,
                    collapseRange: true,
                    matchBrackets: true,
                    readOnly: isViewerMode,
                    //theme: "lesser-dark",
                     extraKeys: {
                      "Cmd-S": function() { TSCORE.FileOpener.saveFile(); },
                      "Ctrl-S": function() { TSCORE.FileOpener.saveFile(); },
                      "Esc": function() { TSCORE.FileOpener.closeFile(); },
                      "Ctrl-Space": "autocomplete"
                    }
                });

                //cmEditor.readOnly = isViewerMode;
                cmEditor.setSize("100%","100%");
                TSCORE.IO.loadTextFile(filePath);
            });
        });
    };
	
    exports.viewerMode = function(isViewerMode) {
        cmEditor.readOnly = isViewerMode;
    };
	
	exports.setContent = function(content) {
        //console.log("Content: "+content);
        var UTF8_BOM = "\ufeff";
        if(content.indexOf(UTF8_BOM) === 0) {
            content = content.substring(1, content.length);
        }
        cmEditor.setValue(content);
        cmEditor.clearHistory();
    };

    exports.getContent = function() {
        return cmEditor.getValue();
    };
	
	var filetype = new Array();
	filetype["h"] = "clike";
	filetype["c"] = "clike";
	filetype["clj"] = "clojure";
	filetype["coffee"] = "coffeescript";
	filetype["cpp"] = "clike";
	filetype["cs"] = "clike";
	filetype["css"] = "css";
	filetype["groovy"] = "groovy";
	filetype["haxe"] = "haxe";
	filetype["htm"] = "xml";
	filetype["html"] = "xml";
	filetype["java"] = "clike";
	filetype["js"] = "javascript";
	filetype["jsm"] = "javascript";
	filetype["json"] = "javascript";
	filetype["less"] = "less";
	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["py"] = "python";
	filetype["rb"] = "ruby";
	filetype["sh"] = "shell";
	filetype["sql"] = "sql";
	filetype["svg"] = "xml";
	filetype["xml"] = "xml";

});
Example #11
0
define(function(require, exports, module) {
"use strict";

    console.log("Loading editorHTML");

    var extensionTitle = "HTML Editor";
    var extensionID = "editorHTML";  // ID should be equal to the directory name where the ext. is located
    var extensionType =  "editor";
    var extensionIcon = "icon-list";
    var extensionVersion = "1.0";
    var extensionManifestVersion = 1;
    var extensionLicense = "AGPL";
    var extensionSupportedFileTypes = [ "html", "htm" ];

    var TSCORE = require("tscore");

    var extensionsPath = TSCORE.Config.getExtensionPath();

    var extensionDirectory = extensionsPath+"/"+extensionID;

    var currentContent,
        currentFilePath,
        $containerElement;

    exports.init = function(filePath, containerElementID) {
        console.log("Initalization HTML Editor...");

        $containerElement = $('#'+containerElementID);

        currentFilePath = filePath;

        //var fileExt = TSCORE.TagUtils.extractFileExtension(filePath);

        $containerElement.empty();
        $containerElement.css("background-color","white");

        var extPath = extensionDirectory+"/index.html";
        $containerElement.append($('<iframe>', {
            id: "iframeViewer",
            sandbox: "allow-same-origin allow-scripts",
            scrolling: "no",
            style: "background-color: white; overflow: hidden;",
            src: extPath+"?cp="+filePath,
            "nwdisable": "",
            "nwfaketop": ""
        }));
        TSCORE.IO.loadTextFile(filePath);

//        if (!window.addEventListener) {
//            window.attachEvent('onmessage', function(e) {alert(e.origin);alert(e.data);});
//        } else {
//            window.addEventListener('message', function(e) {alert(e.origin);alert(e.data);}, false);
//        }
    };

    exports.setFileType = function(fileType) {
        console.log("setFileType not supported on this extension");
    };

    exports.viewerMode = function(isViewerMode) {
        // set readonly
        console.log("viewerMode not supported on this extension");
    };

    exports.setContent = function(content) {
        currentContent = content;

        var bodyRegex = /\<body[^>]*\>([^]*)\<\/body/m;
        var bodyContent = undefined;

        try {
            bodyContent = content.match( bodyRegex )[1];
        } catch(e) {
            console.log("Error parsing HTML document. "+e);
            TSCORE.FileOpener.closeFile(true);
            TSCORE.showAlertDialog("Probably a body tag was not found in the document. Document will be closed.","Error parsing HTML document");
        }

//        var titleRegex = /\<title[^>]*\>([^]*)\<\/title/m;
//        var titleContent = content.match( titleRegex )[1];

        // removing all scripts from the document
        var cleanedBodyContent = bodyContent.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"");

        document.getElementById("iframeViewer").contentWindow.setContent(cleanedBodyContent);
    };

    var contentVersion = 0;

    function resetContentVersion() {
        contentVersion = 0;
        document.getElementById("iframeViewer").contentWindow.resetContentVersion();
    }

    function checkContentChanged() {
        var newContentVersion;
        //try {
            newContentVersion = document.getElementById("iframeViewer").contentWindow.getContentVersion();
        //} catch(e) { }
        if(newContentVersion > contentVersion) {
            contentVersion = newContentVersion;
            TSCORE.FileOpener.setFileChanged(true);
            // autosave
            //TSCORE.FileOpener.saveFile();
        }
        window.setTimeout(checkContentChanged, 1000);
    }

    window.setTimeout(checkContentChanged, 1000);

    exports.getContent = function() {
        var content = $("#iframeViewer").contents().find(".note-editable").html();

        // removing all scripts from the document
        var cleanedContent = content.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"");

        // saving all images as png in base64 format
        var match,
            urls = [],
            imgUrl = "",
            rex = /<img.*?src="([^">]*\/([^">]*?))".*?>/g;;

        while ( match = rex.exec( cleanedContent ) ) {
            imgUrl = match[1];
            console.log("URLs: "+imgUrl);
            urls.push([imgUrl, getBase64Image(imgUrl)]);
        }

        urls.forEach(function(dataURLObject) {
            cleanedContent = cleanedContent.split(dataURLObject[0]).join(dataURLObject[1]);
            //console.log(dataURLObject[0]+" - "+dataURLObject[1]);
        });
        // end saving all images

        cleanedContent = "<body>"+cleanedContent+"</body>";

        var htmlContent = currentContent.replace(/\<body[^>]*\>([^]*)\<\/body>/m,cleanedContent);
        //console.log("Final html "+htmlContent);
        resetContentVersion();
        return htmlContent;
    };

    function getBase64Image(imgURL) {
        var canvas = document.createElement("canvas");
        var img = new Image();
        img.src = imgURL;
        canvas.width = img.width;
        canvas.height = img.height;
        var ctx = canvas.getContext("2d");
        ctx.drawImage(img, 0, 0);
        return canvas.toDataURL("image/png");
    }

    // Extension Vars
    exports.Title                   = extensionTitle;
    exports.ID                      = extensionID;
    exports.Type                    = extensionType;
    exports.Icon                    = extensionIcon;
    exports.Version                 = extensionVersion;
    exports.ManifestVersion         = extensionManifestVersion;
    exports.License                 = extensionLicense;
    exports.SupportedFileTypes      = extensionSupportedFileTypes;

});
  var updateFileBrowserData = function(dirList, isSearchResult) {
    console.log('Updating the file browser data...');
    TSCORE.fileList = [];
    TSCORE.showLoadingAnimation();
    if (!isSearchResult) { // TODO tmp solution for not hiding the loading dialog on search
      TSCORE.showWaitingDialog("Loading metadata and thumbnails");
    }

    var metaDataLoadingPromises = [];
    var tags, ext, title, fileSize, fileLMDT, path, filename, entry, thumbPath, metaObj;

    for (var i = 0; i < dirList.length; i++) {
      // Considering Unix HiddenEntries (. in the beginning of the filename)
      if (TSCORE.Config.getShowUnixHiddenEntries() || !TSCORE.Config.getShowUnixHiddenEntries() && dirList[i].path.indexOf(TSCORE.dirSeparator + '.') < 0) {
        filename = dirList[i].name.replace(/(<([^>]+)>)/gi, ''); // sanitizing filename
        path = dirList[i].path.replace(/(<([^>]+)>)/gi, ''); // sanitizing filepath
        title = TSCORE.TagUtils.extractTitle(path);

        if (dirList[i].isFile) {
          ext = TSCORE.TagUtils.extractFileExtension(path);
          tags = TSCORE.TagUtils.extractTags(path);

          if (dirList[i].size) {
            fileSize = dirList[i].size;
          } else {
            fileSize = "";
          }

          if (dirList[i].lmdt) {
            fileLMDT = dirList[i].lmdt;
          } else {
            fileLMDT = '';
          }

          if (dirList[i].thumbPath) {
            thumbPath = dirList[i].thumbPath;
          } else {
            thumbPath = '';
          }

          metaObj = {
            thumbnailPath: thumbPath,
            metaData: null
          };

          entry = [
            ext,
            title,
            tags,
            fileSize,
            fileLMDT,
            path,
            filename,
            metaObj
          ];
          TSCORE.fileList.push(entry);
          metaDataLoadingPromises.push(TSCORE.Meta.loadMetaFileJsonPromise(entry));
        } else {
          entry = [
            path,
            filename
          ];
          TSCORE.subDirsList.push(entry);
        }
      }
    }

    var loadAllHandler = function() {
      TSCORE.hideLoadingAnimation();
      TSCORE.hideWaitingDialog();
      changePerspective(TSCORE.currentPerspectiveID);
      if (TSCORE.PRO && !isSearchResult && TSCORE.Config.getUseTextExtraction()) {
        TSCORE.showLoadingAnimation();
        //TSCORE.showWaitingDialog("Extracting text content");
        TSCORE.PRO.extractTextContentFromFilesPromise(TSCORE.fileList).then(function() {
          console.log("Text extraction completed!");
          TSCORE.hideLoadingAnimation();
          TSCORE.hideWaitingDialog();
        }).catch(function(e) {
          console.log("Text extraction failed!");
          TSCORE.hideLoadingAnimation();
          TSCORE.hideWaitingDialog();
        });
      }
    };

    Promise.all(metaDataLoadingPromises).then(function(result) {
      console.log("MetaData loaded / Creating thumbs finished!");
      loadAllHandler();
    }).catch(function(e) {
      console.warn("MetaData loading / Creating thumbs failed: " + e);
      loadAllHandler();
    });

  };
Example #13
0
    ExtUI.prototype.createFileTile = function(title, filePath, fileExt, fileTags) {
        var self = this;
        
        //TODO minimize platform specific calls     
        var tmbPath = undefined;
        if(isCordova) {
            tmbPath = filePath;            
        } else {
            tmbPath = "file:///"+filePath;  
        }       
        
        var thumbHTML = "";     
        if(supportedFileTypeThumnailing.indexOf(fileExt) >= 0) {
            thumbHTML = $('<span>').append( $('<img>', { 
                class: "thumbImgTile",
                filepath: tmbPath, 
                style: "width: 0px; height: 0px; border: 0px" 
            }));
        }       
        
        var titleHTML = $('<p>', { 
                text: title, 
                class: "titleInFileTile",
            });

        var tagsHTML = $('<span>', {
            class: "tagsInFileTile"
        });
        if(fileTags.length > 0) {
            var tagString = ""+fileTags ;
            var tags = tagString.split(",");

            var tagCounter = 0;
            if (tags.length > PREVIEW_TAGS_CNT) {
                tagCounter = PREVIEW_TAGS_CNT+1;
                tags[PREVIEW_TAGS_CNT] = "...";
            } else {
                tagCounter = tags.length;                
            }
            for (var i=0; i < tagCounter; i++) { 
                tagsHTML.append($('<button>', {
                    "class":  "btn btn-sm tagButton fileTagsTile", 
                    text:     tags[i]+" ",
                    tag:      tags[i],   
                    filepath: filePath,                
                    style:    TSCORE.generateTagStyle(TSCORE.Config.findTag(tags[i]))
                    })
                    .click( function() {
                        self.selectFile($(this).attr("filepath"));
                        TSCORE.openTagMenu(this, $(this).attr("tag"), $(this).attr("filepath"));
                    } )
                    .append("<span class='caret'/>")                    
                    /* .draggable({
                        "cancel":   false,
                        "appendTo": "body",
                        "helper":   "clone",
                        "revert":   true,
                        "start":    function(e) {
                            self.selectFile($(this).attr("filepath")); 
                        }         
                    }) */                   
                );   
            }   
        };
          
        var extHTML = "";
        if(fileExt.length > 0) {
            extHTML = $('<span>', {
                "class":  "fileExtTile",                
                text: fileExt
               });
        };
        
        var fileSelectorHTML = $('<button>', {
                "class":     "btn btn-link fileTileSelector",
                "filepath":  filePath               
             })
             .append( "<i class='fa fa-square-o'>" )
             .click( function(e) {
                  e.preventDefault();
                  var fpath = $(this).attr("filepath");
                  var stateTag = $(this).find("i");
                  if(stateTag.hasClass("fa-square-o")) {                    
                      stateTag.removeClass("fa-square-o").addClass("fa fa-check-square");
                      $(this).parent().parent().addClass("ui-selected");
                      TSCORE.selectedFiles.push(fpath);  
                  } else {
                      stateTag.removeClass("fa-check-square").addClass("fa-square-o");                      
                      $(this).parent().parent().removeClass("ui-selected");
                      TSCORE.selectedFiles.splice(TSCORE.selectedFiles.indexOf(fpath), 1);
                  }                  
                  self.handleElementActivation();
                  return false; 
              });              
            
        var tileHTML = $('<p>', {})        
        .append(thumbHTML)
        .append(titleHTML)        
        .append(tagsHTML)
        .append(extHTML)
        .append(fileSelectorHTML);
                        
        return tileHTML;        
    };    
Example #14
0
define(function(require, exports, module) {
"use strict";

	console.log("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 extensionsPath = TSCORE.Config.getExtensionPath();
	
	var extensionDirectory = extensionsPath+"/"+exports.id;
	
	var content = undefined;
	
	exports.init = function(filePath, containerElementID) {
	    console.log("Initalization HTML Text Editor...");
		require([
			extensionDirectory+'/summernote/summernote.js',
            'css!'+extensionDirectory+'/summernote/summernote.css',     
            'css!'+extensionDirectory+'/extension.css',
		 	], function() {
				$("#"+containerElementID).append('<div id="htmlEditor"></div>');	 	
				TSCORE.IO.loadTextFile(filePath);
		});
	};
	
	exports.setFileType = function(fileType) {
	    console.log("setFileType not supported on this extension");      
	};
	
	exports.viewerMode = function(isViewerMode) {
	    // set readonly      
	};
	
	exports.setContent = function(cont) {
		content = cont;
		
        var reg = /\<body[^>]*\>([^]*)\<\/body/m;
        
        var bodyContent = undefined;
        
        // TODO try this 
        try {
            bodyContent = content.match( reg )[1];                  
        } catch(e) {
            console.log("Error parsing HTML document. "+e);
            $('#htmlEditor').append("<p style='font-size: 15px'><br/>  Error parsing HTML document. Probably a body tag was not found in the document.</p>");
            return false;
        }

		//console.log("body content: "+bodyContent);

        var cleanedBodyContent = bodyContent.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"");         

		$('#htmlEditor').append(cleanedBodyContent);
		$('#htmlEditor').summernote({
          focus: true, 		
          toolbar: [
            ['style', ['style']], 
            ['style', ['bold', 'italic', 'underline', 'clear']],
            ['fontsize', ['fontsize']],
            ['color', ['color']],
            ['para', ['ul', 'ol', 'paragraph']],
            ['height', ['height']],
            ['insert', ['picture', 'link']], 
            ['table', ['table']], 
            ['view', ['codeview']], 
            //['help', ['help']] //no help button
          ]		    
		});
       // $("#"+containerElementID).find('.note-image-dialog').css("position","static");   

	};
	
	exports.getContent = function() {
		var code = "<body>"+$('#htmlEditor').code()+"</body>";
        
        var htmlContent = content.replace(/\<body[^>]*\>([^]*)\<\/body>/m,code);
        console.log("Final html "+htmlContent);
		return htmlContent;
	};	

});
Example #15
0
    function generateDirPath() {
        console.log("Generating Directory Path...");
        $("#locationContent").empty();
        $("#locationContent").addClass("accordion");
        for(var i=0; i < directoryHistory.length; i++) {
            $("#locationContent").append($("<div>", { 
                "class":        "accordion-group disableTextSelection",   
                "style":        "width: 99%; border: 0px #aaa solid;"
            })
            
            .append($("<div>", { 
                    "class":    "accordion-heading btn-group",
                    "key":      directoryHistory[i].path, 
                    "style":    "width:100%; margin: 0px; "
                }
            )

            .append($("<button>", { // Dir toggle button
                        "class":        "btn btn-link btn-lg directoryIcon",
                        "data-toggle":  "collapse",
                        "data-target":  "#dirButtons"+i,                        
                        "key":          directoryHistory[i].path,
                        "title":        "Toggle Directory"
                    }  
                )
                .html("<i class='fa fa-folder-open'></i>")   
            )// End dir toggle button  
            
            .append($("<button>", { // Dir main button
                        "class":        "btn btn-link directoryTitle",
                        "key":          directoryHistory[i].path,
                        "title":        "Change Direoctory to: "+directoryHistory[i].path,
                        "text":         directoryHistory[i].name
                    }  
                )
                .click(function() {
                        navigateToDirectory($(this).attr("key"));
                    }
                )                                
                .droppable({
                        greedy: "true",                    
                        accept: '.fileTitleButton,.fileTile',
                        hoverClass: "dropOnFolder",
                        drop: function( event, ui ) {
                                ui.draggable.detach();
                                var filePath = ui.draggable.attr("filepath");
                                var fileName = TSCORE.TagUtils.extractFileName(filePath);
                                var targetDir = $(this).attr("key");
                                console.log("Moving file: "+filePath+" to "+targetDir);
                                TSCORE.IO.renameFile(filePath, targetDir+TSCORE.dirSeparator+fileName);
                                $(ui.helper).remove();                                 
                        }                  
                    }
                )
            )// End dir main button  
            
            .append($("<button>", {
                    "class":        "btn btn-link btn-lg directoryActions",
                    "key":          directoryHistory[i].path, 
                    "title":        "Directory Options"
            })                       
            //.dropdown( 'attach' , '#directoryMenu' )
            .append("<b class='fa fa-ellipsis-v'>")
            ) // end gear    
                    
            ) // end heading
            
            .append($("<div>", { 
                "class":    "accordion-body collapse in",
                "id":       "dirButtons"+i,
                "style":    "margin: 0px 0px 0px 3px; border: 0px;"
            })          
            .append($("<div>", { 
                "class":    "accordion-inner",
                "id":       "dirButtonsContent"+i,
                "style":    "padding: 2px; border: 0px;"
            })
            ) // end accordion-inner    
            ) // end accordion button        

            ); // end group

            var dirButtons = $("<div>").appendTo( "#dirButtonsContent"+i );  
            if(directoryHistory[i]["children"].length <= 0) {
                    dirButtons.append("<div class='alert'><strong> No subfolders found</strong></div>");          
            } else {
                for(var j=0; j < directoryHistory[i]["children"].length; j++) {                    
                    if (TSCORE.Config.getShowUnixHiddenEntries() || 
                            (!TSCORE.Config.getShowUnixHiddenEntries() && (directoryHistory[i]["children"][j].name.indexOf(".") != 0))) {
                        dirButtons.append($("<button>", { 
                            "class":    "btn btn-sm dirButton", 
                            "key":      directoryHistory[i]["children"][j].path,
                            "title":    directoryHistory[i]["children"][j].path,
                            "style":    "margin: 1px;",
                            "text":     " "+directoryHistory[i]["children"][j].name
                        })
                        .droppable({
                            greedy: "true",
                            accept: ".fileTitleButton,.fileTile",
                            hoverClass: "dropOnFolder",
                            drop: function( event, ui ) {
                                ui.draggable.detach();
                                // Fixing issue with dropping on stacked/overlapped directories
                                if( $(this).parent().parent().parent().hasClass("in") ) {
                                    var filePath = ui.draggable.attr("filepath");
                                    var fileName = TSCORE.TagUtils.extractFileName(filePath);
                                    var targetDir = $(this).attr("key");
                                    console.log("Moving file: "+filePath+" to "+targetDir);
                                    TSCORE.IO.renameFile(filePath, targetDir+TSCORE.dirSeparator+fileName);
                                    $(ui.helper).remove();  
                                }                              
                            }                   
                        }) 
                        .prepend("<i class='fa fa-folder-o'></i>")            
                        .click( function() {
                            navigateToDirectory($(this).attr("key"));
                        })                   
                        );
                    }
               }        
           }
        }
    }
Example #16
0
define(function(require, exports, module) {
  "use strict";

  console.log("Loading viewerText");

  var extensionTitle = "IFrame Viewer";
  var extensionID = "viewerBrowser"; // ID should be equal to the directory name where the ext. is located   
  var extensionType = "viewer";
  var extensionIcon = "icon-list";
  var extensionVersion = "1.0";
  var extensionManifestVersion = 1;
  var extensionLicense = "AGPL";
  var extensionSupportedFileTypes = ["*"];

  var TSCORE = require("tscore");

  var containerElID,
    $containerElement,
    currentFilePath;

  var extensionDirectory = TSCORE.Config.getExtensionPath() + "/" + extensionID;

  exports.init = function(filePath, containerElementID) {
    console.log("Initalization Text Viewer...");
    containerElID = containerElementID;
    $containerElement = $('#' + containerElID);

    currentFilePath = filePath;

    var filePathURI;
    if (isCordova || isWeb) {
      filePathURI = filePath;
    } else {
      filePathURI = "file:///" + filePath;
    }

    var fileExt = TSCORE.TagUtils.extractFileExtension(filePath);

    $containerElement.empty();
    $containerElement.css("background-color", "white");

    if ((fileExt.indexOf("htm") === 0 || fileExt.indexOf("xhtm") === 0 || fileExt.indexOf("txt") === 0) && !isFirefox) {
      $containerElement.append($('<iframe>', {
        sandbox: "allow-same-origin allow-scripts",
        id: "iframeViewer",
        "nwdisable": "",
        "nwfaketop": ""
      }));
      TSCORE.IO.loadTextFile(filePath);
    } else if (fileExt.indexOf("mht") === 0 && (isChrome || isNode)) {
      $containerElement.append($('<button>', {
        class: "btn btn-primary",
        style: "margin: 5px;",
        text: "Open in new window"
      }).click(function() {
        // if(isNode) {
        window.open(filePathURI, '_blank');
        // }
      }));
      $containerElement.append($('<div>', {
        class: "alert alert-info",
        style: "margin: 5px; font-size: 14px;",
        text: "For security reasons, opening of MHT files in iframes has been disabled in Chrome, so to open this MHT file, press the button above. This issue will be solved soon, with a custom MHT viewer."
      }));
    } else {
      $containerElement.append($('<iframe>', {
        // sandbox: "allow-same-origin allow-scripts", // comment out due not loading pdfs in chrome ext
        id: "iframeViewer",
        src: filePathURI,
        "nwdisable": "",
        "nwfaketop": ""
      }));
    }
  };

  exports.setFileType = function(fileType) {
    console.log("setFileType not supported on this extension");
  };

  exports.viewerMode = function(isViewerMode) {
    // set readonly      
  };

  exports.setContent = function(content) {
    // removing the script tags from the content 
    var cleanedContent = content.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "");
    var viewerIframe = $("#iframeViewer").get(0);

    var fileDirectory = TSCORE.TagUtils.extractContainingDirectoryPath(currentFilePath);

    if (viewerIframe !== undefined) {
      viewerIframe.contentWindow.document.write(cleanedContent);

      // making all links open in the user default browser
      $(viewerIframe.contentWindow.document).find("a").bind('click', function(e) {
        e.preventDefault();
        TSCORE.openLinkExternally($(this).attr("href"));
      });

      // fixing embedding of local images
      $(viewerIframe.contentWindow.document).find("img[src]").each(function() {
        var currentSrc = $(this).attr("src");
        if (currentSrc.indexOf("http://") === 0 || currentSrc.indexOf("https://") === 0 || currentSrc.indexOf("data:") === 0) {
          // do nothing if src begins with http(s):// or data:
        } else {
          $(this).attr("src", "file://" + fileDirectory + TSCORE.dirSeparator + currentSrc);
        }
      });
    }
  };

  exports.getContent = function() {
    console.log("Not implemented");
  };

  // Extension Vars
  exports.Title = extensionTitle;
  exports.ID = extensionID;
  exports.Type = extensionType;
  exports.Icon = extensionIcon;
  exports.Version = extensionVersion;
  exports.ManifestVersion = extensionManifestVersion;
  exports.License = extensionLicense;
  exports.SupportedFileTypes = extensionSupportedFileTypes;

});
Example #17
0
 function generateAlternativeDirPath() {
     console.log("Generating Alternative Directory Path...");
     var subfolders, 
         homeIcon,
         i;
         
     $("#alternativeNavigator").empty();
     for(i=0; i < directoryHistory.length; i++) {
         homeIcon = "";
         if(i==0) {
             homeIcon = "<i class='fa fa-home'></i>&nbsp;";
         }
         
         subfolders = $("<ul>", {
                "style":      "overflow-y: auto; max-height: 430px; width: 250px; padding: 5px;",                
                "class":      "dropdown-menu"
         })
         .append($("<li>", { "text": 'Actions for \"'+directoryHistory[i].name+'\"', "class": 'dropdown-header' })
             .append($('<button type="button" class="close">×</button>'))
         )
         //.append('<li class="divider"></li>')
         .append($("<li>", {} )
             .append($("<button>", {
                     "class":    "btn btn-link",
                     "path":      directoryHistory[i].path,
                     "title":    "Open or Reload "+directoryHistory[i].name,
                     "text":     " Open or Reload Directory"
                 })
                 .prepend("<i class='fa fa-refresh fa-lg fa-fw'></i>")
                 .click( function() {
                     navigateToDirectory($(this).attr("path"));
                 })
                 )
          )
         .append($("<li>", {} )                     
             .append($("<button>", {
                     "class":    "btn btn-link",
                     "path":      directoryHistory[i].path,
                     "title":    "Create Subdirectory",
                     "text":     " Create New Directory"
                 })
                 .prepend("<i class='fa fa-folder fa-lg fa-fw'></i>")
                 .click( function() {
                     showCreateDirectoryDialog($(this).attr("path"));
                 })
             )
         )
         .append('<li class="divider"></li>')
         .append($("<li>", { "text": 'Subfolders of \"'+directoryHistory[i].name+'\"', "class": 'dropdown-header' })
         );
                       
         if(directoryHistory[i]["children"].length <= 0) {
                 subfolders.append("<div class='alert alert-warning'>No subfolders found</div>");          
         } else {
             for(var j=0; j < directoryHistory[i]["children"].length; j++) {                    
                 if (TSCORE.Config.getShowUnixHiddenEntries() || 
                         (!TSCORE.Config.getShowUnixHiddenEntries() 
                           && (directoryHistory[i]["children"][j].name.indexOf(".") != 0)
                          )
                     ) {
                     subfolders.append($("<button>", {
                         "class":    "btn dirButton",
                         "key":      directoryHistory[i]["children"][j].path,
                         "title":    directoryHistory[i]["children"][j].path,
                         "style":    "margin: 1px;",
                         "text":     " "+directoryHistory[i]["children"][j].name
                     })
                     .prepend("<i class='fa fa-folder-o'></i>")            
                     .click( function() {
                         navigateToDirectory($(this).attr("key"));
                     })                   
                     );
                 }
            }        
        }            
         
         $("#alternativeNavigator")
             .append($("<div>", {
                     "class":      "btn-group dropup"
                 })
                 .append($("<button>", {
                     "class":       "btn btn-link dropdown-toggle",
                     "text":        directoryHistory[i].name,
                     "key":         directoryHistory[i].path,
                     "data-toggle": "dropdown"
                 })
                     .prepend(homeIcon)
                     .append("&nbsp;&nbsp;<i class='fa fa-caret-right'></i>&nbsp;")
                 )
                 .append(subfolders)
             );
     } // FOR End
 }
Example #18
0
 }).on("dblclick", function() {
     TSCORE.selectedTagData = TSCORE.Config.getTagData($(this).attr("tag"), $(this).attr("parentKey"));
     TSCORE.selectedTag = generateTagValue(TSCORE.selectedTagData);
     TSCORE.TagUtils.addTag(TSCORE.selectedFiles, [TSCORE.selectedTag]);
 })
Example #19
0
 function () {
     TSCORE.Config.setShowWarningRecursiveScan($("#confirmDialog").find("#showThisDialogAgain").prop('checked'));
     //console.log("Shownextime : "+$("#confirmDialog").find("#showThisDialogAgain").prop('checked'));
     $("#" + self.extensionID + "IncludeSubDirsButton").prop('disabled', true);
     TSCORE.IO.createDirectoryIndex(TSCORE.currentPath);
 },
Example #20
0
	function generateTagGroups() {
	    console.log("Generating TagGroups...");
	    $("#tagGroupsContent").empty();
	    $("#tagGroupsContent").addClass("accordion");

        // Show TagGroup create button if no taggroup exist
	    if(TSCORE.Config.Settings["tagGroups"].length < 1) {
            $("#tagGroupsContent").append($("<button>", { 
                "class": "btn",
                text: "Create New Taggroup"
            })
            .click( function(event) {
                TSCORE.showDialogTagGroupCreate();
            })            
            );	        
	        return true;
	    }
	    
	    if(TSCORE.Config.getCalculateTags()) {
    	    // Adding tags to the calculated tag group 
            //console.log("Calculated tags: "+JSON.stringify(exports.calculatedTags));
            for(var i=0; i < TSCORE.Config.Settings["tagGroups"].length; i++) {
                var tagGroupExist = false;
                if(TSCORE.Config.Settings["tagGroups"][i].key == "CTG") {
                    TSCORE.Config.Settings["tagGroups"][i].children = exports.calculatedTags;
                    tagGroupExist = true;
                    break;
                }        
            }
            // Adding the calculated tag group if it not exists
            if(!tagGroupExist) {
                TSCORE.Config.Settings["tagGroups"].push({ 
                        "title": "Tags in Perspective", 
                        "key": "CTG", 
                        "expanded": true,
                        "children": exports.calculatedTags
                    });
            } 
        }
    	    
	    for(var i=0; i < TSCORE.Config.Settings["tagGroups"].length; i++) {
	        $("#tagGroupsContent").append($("<div>", { 
	            "class": "accordion-group disableTextSelection",    
                "style": "width: 99%; border: 0px #aaa solid;",	            
	        })
	        .append($("<div>", { 
	            "class":        "accordion-heading  btn-group",
	            "style":        "width:100%; margin: 0px;",
                "key":          TSCORE.Config.Settings["tagGroups"][i].key,	            
	        })
	        
            .append($("<button>", { // Taggroup toggle button
                        "class":        "btn btn-link tagGroupIcon",
                        "data-toggle":  "collapse",
                        "data-target":  "#tagButtons"+i,
                        "title":        "Toggle TagGroup",
                    }  
                )
                .html("<i class='fa fa-tags'></i>")   
            )// End taggroup toggle button  
                        	        
	        .append($("<button>", {
				"class":        "btn btn-link btn-sm tagGroupTitle",
	            "text":         TSCORE.Config.Settings["tagGroups"][i].title, 
                "key":          TSCORE.Config.Settings["tagGroups"][i].key, 	      
	        })  
	        )
	        .droppable({
                accept: '.tagButton',
                hoverClass: "dirButtonActive",
                drop: function( event, ui ) {
                    //ui.draggable.detach();
                    var tagGroupData = TSCORE.Config.getTagData(ui.draggable.attr("tag"), ui.draggable.attr("parentKey"));
                    tagGroupData.parentKey = ui.draggable.attr("parentKey");
                    var targetTagGroupKey = $(this).attr("key");
                    console.log("Moving tag: "+tagGroupData.title+" to "+targetTagGroupKey);
                    TSCORE.Config.moveTag(tagGroupData, targetTagGroupKey);
                    generateTagGroups();
                    $(ui.helper).remove();
                }                   
            })  
	        
	        .append($("<button>", {
	                "class": "btn btn-link tagGroupActions",
	                "tag": TSCORE.Config.Settings["tagGroups"][i].title, 
	                "key": TSCORE.Config.Settings["tagGroups"][i].key, 
	                "title": "Taggroup options",
 	        })              
	        .append("<b class='fa fa-ellipsis-v'></b>")
	        ) // end gear
	        
	        ) // end heading
	        
	        .append($("<div>", { 
	            "class":   "accordion-body collapse in",
	            "id":      "tagButtons"+i,
	            "style":   "margin: 0px 0px 0px 3px; border: 0px;",
	        })	        
	        .append($("<div>", { 
	            "class":   "accordion-inner",
	            "id":      "tagButtonsContent"+i,
	            "style":   "padding: 2px; border: 0px;",
	        })
	        ) // end accordion-inner	
	        ) // end accordion button        

  	        ); // end group

	        var tagButtons = $("<div>").appendTo( "#tagButtonsContent"+i );  
	        for(var j=0; j < TSCORE.Config.Settings["tagGroups"][i]["children"].length; j++) {
	            var tagTitle = undefined;
	            if(TSCORE.Config.Settings["tagGroups"][i]["children"][j].description != undefined) {
	                tagTitle = TSCORE.Config.Settings["tagGroups"][i]["children"][j].description;
	            } else {
                    tagTitle = "Opens context menu for "+TSCORE.Config.Settings["tagGroups"][i]["children"][j].title;	                
	            }
	            var tagIcon = "";
                if(TSCORE.Config.Settings["tagGroups"][i]["children"][j].type == "smart"){
                    tagIcon = "<span class='fa fa-flask'/> ";
                }
                var tagCount = "";
                if(TSCORE.Config.Settings["tagGroups"][i]["children"][j].count != undefined) {
                    tagCount = " ("+TSCORE.Config.Settings["tagGroups"][i]["children"][j].count+")"; 
                }                
	            tagButtons.append($("<a>", { 
	                "class":         "btn btn-sm tagButton", 
	                "tag":           TSCORE.Config.Settings["tagGroups"][i]["children"][j].title, 
	                "parentKey":     TSCORE.Config.Settings["tagGroups"][i].key,
	                "title":         tagTitle,
	                "text":          TSCORE.Config.Settings["tagGroups"][i]["children"][j].title+tagCount+" ",
	                "style":         generateTagStyle(TSCORE.Config.Settings["tagGroups"][i]["children"][j]), 
	            })            
                .draggable({
                    "appendTo":   "body",
                    "helper":     "clone",
                    "revert":     'invalid',
                    "start":     function(e, ui) {
                        TSCORE.selectedTagData = TSCORE.Config.getTagData($(this).attr("tag"), $(this).attr("parentKey"));
                        TSCORE.selectedTag = generateTagValue(TSCORE.selectedTagData);
                        TSCORE.selectedTagData.parentKey = $(this).attr("parentKey");                         
                    }                     
                }) 
                .prepend(tagIcon)
                .append("<span class='caret'/>")
                );
	       } 
	    }
        
        $("#tagGroupsContent").on("contextmenu click", ".tagGroupActions", function (e) {
            TSCORE.hideAllDropDownMenus();
            TSCORE.selectedTag = $(this).attr("tag");
            TSCORE.selectedTagData = TSCORE.Config.getTagGroupData($(this).attr("key"));
            TSCORE.selectedTagData.parentKey = undefined;  

            TSCORE.showContextMenu("#tagGroupMenu", $(this));

            return false;
        });

        $("#tagGroupsContent").on("contextmenu click", ".tagButton", function (e) {
            TSCORE.hideAllDropDownMenus();
            TSCORE.selectedTagData = TSCORE.Config.getTagData($(this).attr("tag"), $(this).attr("parentKey"));
            TSCORE.selectedTag = generateTagValue(TSCORE.selectedTagData);
            TSCORE.selectedTagData.parentKey = $(this).attr("parentKey");

            TSCORE.showContextMenu("#tagTreeMenu", $(this));

            return false;
        });               

	}
Example #21
0
 $( "#tagGroupSort" ).click( function() {
     TSCORE.Config.sortTagGroup(TSCORE.selectedTagData);
     generateTagGroups();
 });
Example #22
0
 "start":     function(e, ui) {
     TSCORE.selectedTagData = TSCORE.Config.getTagData($(this).attr("tag"), $(this).attr("parentKey"));
     TSCORE.selectedTag = generateTagValue(TSCORE.selectedTagData);
     TSCORE.selectedTagData.parentKey = $(this).attr("parentKey");                         
 }                     
Example #23
0
    function generateTagGroups() {
        console.log("Generating TagGroups...");
        var $tagGroupsContent = $("#tagGroupsContent");
        $tagGroupsContent.children().remove();
        $tagGroupsContent.addClass("accordion");

        // Show TagGroup create button if no taggroup exist
        if(TSCORE.Config.Settings.tagGroups.length < 1) {
            $tagGroupsContent.append($("<button>", {
                "class":        "btn",
                "text":         $.i18n.t("ns.common:createTagGroup"),
                "data-i18n":    "ns.common:createTagGroup"
            })
            .click( function() {
                TSCORE.showDialogTagGroupCreate();
            })            
            );
            return true; // quit the taggroup generation
        }

        var tagGroups = TSCORE.Config.Settings.tagGroups;
        var tag;

        // Cleaning Special TagGroups
        for(var k=0; k < tagGroups.length; k++) {
            if(tagGroups[k].key === locationTagGroupKey || tagGroups[k].key === calculatedTagGroupKey) {
                console.log("Deleting:"+tagGroups[k].key+" "+k);
                tagGroups.splice(k, 1);
                k--;
            }
        }

        // Adding tags to the calculated tag group
        if(TSCORE.Config.getCalculateTags() && TSCORE.calculatedTags !== null) {
            tagGroups.push({
                "title": $.i18n.t("ns.common:tagsFromCurrentFolder"),
                "key": calculatedTagGroupKey,
                "expanded": true,
                "children": TSCORE.calculatedTags
            });
        }

        // Adding the locataion tag groups
        if(TSCORE.Config.getLoadLocationMeta() && TSCORE.locationTags !== null) {
            for (var i=0;i<TSCORE.locationTags.length;i++) {
                tagGroups.push(TSCORE.locationTags[i]);
            }
        }

        // ehnances the taggroups with addition styling information
        for(var i=0; i < tagGroups.length; i++) {
            for(var j=0; j < tagGroups[i].children.length; j++) {
                tag = tagGroups[i].children[j];

                if(tag.description !== undefined) {
                    tag.titleUI = tag.description;
                } else {
                    tag.titleUI = tag.title;
                }

                tag.icon = "";
                if(tag.type === "smart"){
                    tag.icon = "fa fa-flask";
                }

                // Add keybinding to tags
                if(tag.keyBinding !== undefined && tag.keyBinding.length > 0) {
                    tag.icon = "fa fa-keyboard-o";
                    tag.titleUI = tag.titleUI + " [" +tag.keyBinding+ "]";
                    Mousetrap.unbind(tag.keyBinding);
                    Mousetrap.bind(
                        tag.keyBinding,
                        (function(innerTag) {
                            return function( e ) {
                                TSCORE.TagUtils.addTag(TSCORE.selectedFiles, [innerTag]);
                            };
                        })(tag.title)
                    );
                }
                tag.style = generateTagStyle(tag);
            }
        }

        $tagGroupsContent.html(tagGroupsTmpl({
             "tagGroups":           tagGroups,
             "toggleTagGroup":      $.i18n.t("ns.common:toggleTagGroup"),
             "tagGroupOperations":  $.i18n.t("ns.common:tagGroupOperations")
         }));

        $tagGroupsContent.find(".tagButton").each(function() {
            $(this).draggable({
                    "appendTo":   "body",
                    "helper":     "clone",
                    "revert":     'invalid',
                    "start":     function() {
                        console.log("Start dragging..........");
                        TSCORE.selectedTagData = TSCORE.Config.getTagData($(this).attr("tag"), $(this).attr("parentKey"));
                        TSCORE.selectedTag = generateTagValue(TSCORE.selectedTagData);
                        TSCORE.selectedTagData.parentKey = $(this).attr("parentKey");
                    }
                })
        });

        $tagGroupsContent.find(".tagGroupTitle").each(function() {
            $(this)
                .droppable({
                    accept: '.tagButton',
                    hoverClass: "dirButtonActive",
                    drop: function( event, ui ) {
                        //ui.draggable.detach();
                        var tagGroupData = TSCORE.Config.getTagData(ui.draggable.attr("tag"), ui.draggable.attr("parentKey"));
                        tagGroupData.parentKey = ui.draggable.attr("parentKey");
                        var targetTagGroupKey = $(this).attr("key");
                        console.log("Moving tag: "+tagGroupData.title+" to "+targetTagGroupKey);
                        TSCORE.Config.moveTag(tagGroupData, targetTagGroupKey);
                        generateTagGroups();
                        $(ui.helper).remove();
                    }
                })
        });

        $tagGroupsContent.on("contextmenu click", ".tagGroupActions", function () {
            TSCORE.hideAllDropDownMenus();
            TSCORE.selectedTag = $(this).attr("tag");
            TSCORE.selectedTagData = TSCORE.Config.getTagGroupData($(this).attr("key"));
            TSCORE.selectedTagData.parentKey = undefined;
            TSCORE.showContextMenu("#tagGroupMenu", $(this));
            return false;
        });

        $tagGroupsContent.on("contextmenu click", ".tagButton", function () {
            TSCORE.hideAllDropDownMenus();
            TSCORE.selectedTagData = TSCORE.Config.getTagData($(this).attr("tag"), $(this).attr("parentKey"));
            TSCORE.selectedTag = generateTagValue(TSCORE.selectedTagData);
            TSCORE.selectedTagData.parentKey = $(this).attr("parentKey");
            TSCORE.showContextMenu("#tagTreeMenu", $(this));
            return false;
        });
    }
Example #24
0
 document.documentElement.addEventListener("tsMessage", function(event) {
     console.log("Message received in page script from content script: "); //+JSON.stringify(event.detail));
     var message = event.detail;
     switch (message.command) {
       case "loadSettings":
         if(message.success) {
             try {
                 console.log("Loading settings...: "+JSON.stringify(message.content));
                 TSCORE.Config.updateSettingMozillaPreferences(message.content);
 
                 TSCORE.initLocations();
                 TSCORE.generateTagGroups();
                   
             } catch (ex) {
                 console.log("Exception while getting setting from firefox failed "+ex);
             }
         } else {
             console.log("Getting setting from firefox failed");
         }
         break;
       case "saveSettings":
         if(message.success) {
             console.log("Saving setting as native mozilla preference successfull!");
         } else {
             console.log("Saving setting as native mozilla preference failed!");            
         }
         break;        
       case "rename":
         if(message.success){
             TSPOSTIO.renameFile(message.content[0],message.content[1]);
         } else {
             TSCORE.updateLogger("Rename failed");        
         }
         break;
       case "saveTextFile":
         if(message.success){
             TSPOSTIO.saveTextFile(message.content);
         } else {
             TSCORE.updateLogger("Save failed");      
         }
         break;
       case "createDirectory":
         if(message.success){
             TSPOSTIO.createDirectory(message.content);
         } else {
             TSCORE.updateLogger("Create dir failed");        
         }
         break;
       case "loadTextFile":
         if(message.success){
             TSPOSTIO.loadTextFile(message.content);
         } else {                
             TSCORE.updateLogger("File loading failed");      
         }
         break;
       case "listDirectory":
         if(message.success){
             TSPOSTIO.listDirectory(message.content);       
         } else {
             TSPOSTIO.errorOpeningPath();
         }
         break;      
       case "indexDirectory":
         if(message.success){
             TSPOSTIO.createDirectoryIndex(message.content);
         } else {
             TSCORE.updateLogger("Indexing directory failed");        
         }
         break;  
       case "createDirectoryTree":
         if(message.success){
             console.log("Directory tree: "+JSON.stringify(message.content));
             TSPOSTIO.createDirectoryTree(message.content);            
         } else {
             TSCORE.updateLogger("Indexing directory failed");        
         }
         break;  
       case "delete":
         if(message.success){
             TSPOSTIO.deleteElement(message.content);         
         } else {
             TSCORE.updateLogger("Delete failed");        
         }
         break;          
       case "selectDirectory":
         if(message.success){
             TSPOSTIO.selectDirectory(message.content);
         } else {
             TSCORE.updateLogger("Selecting directory failed.");        
         }
         break;  
       case "checkNewVersion":
         if(message.success){
             TSPOSTIO.checkNewVersion(message.content);
         } else {
             TSCORE.updateLogger("Checking for new version failed.");        
         }
       case "getFileProperties":
         if(message.success){
             TSPOSTIO.getFileProperties(message.content);
         } else {
             TSCORE.updateLogger("Getting file properties failed.");        
         }
         break;                  
       default:
         break;
     }   
 }, false);
Example #25
0
 function() {
     TSCORE.Config.deleteTag(TSCORE.selectedTagData);
     generateTagGroups();                              
 }
Example #26
0
define(function(require, exports, module) {
"use strict";

	console.log("Loading viewerImage");

    var extensionTitle = "Image Viewer";
    var extensionID = "viewerImage";  // ID should be equal to the directory name where the ext. is located   
    var extensionType =  "viewer";
    var extensionIcon = "icon-list";
    var extensionVersion = "1.0";
    var extensionManifestVersion = 1;
    var extensionLicense = "AGPL";
    var extensionSupportedFileTypes = [ "jpeg", "jpg", "png",  "gif", "bmp" ];
	
	var TSCORE = require("tscore");
	
	var extensionDirectory = TSCORE.Config.getExtensionPath()+"/"+extensionID;
	var UI;
	   
	   
	exports.init = function(filePath, elementID) {
	    console.log("Initalization Browser Image Viewer...");

		require([
              extensionDirectory+'/viewerUI.js',
              "text!"+extensionDirectory+'/mainUI.html',
              'css!'+extensionDirectory+'/extension.css',
              //extensionDirectory+'/loadimage/canvas-to-blob.js',
              extensionDirectory+'/jquery.panzoom/jquery.panzoom.min.js',              
              extensionDirectory+'/jquery.mousewheel/jquery.mousewheel.js'
              ], function(extUI, uiTPL) {
			//extensionDirectory+'/pixastic/pixastic.custom.js',
				var uiTemplate = Handlebars.compile( uiTPL );
                UI = new extUI.ExtUI(extensionID, elementID, filePath, uiTemplate);

                // TODO remove tmp solution for memory leak prevention
                UI = null;

                /*
                loadImage(
                	    filePath,
                	    function (img) {
                	        img.toBlob(
            	                function (blob) {
            	                    loadImage.parseMetaData(blob, function (data) {
            	                    	console.log("EXIF: "+data.exif);
            	                    	if (data.exif) {
            	                            options.orientation = data.exif.get('Orientation');
            	                            displayExifData(data.exif);
            	                        }
            	                    });                                 	                	
            	                },
            	                'image/jpeg'
            	            );                	        
                	    },
                	    {
                	        maxWidth: 600,
                	        maxHeight: 300,
                	        minWidth: 100,
                	        minHeight: 50,
                	        canvas: true
                	    }
                	); */
		});
	};
	
	exports.viewerMode = function(isViewerMode) {
		console.log("viewerMode not supported on this extension");  
	};
	
	exports.setContent = function(content) {
		console.log("setContent not supported on this extension"); 	
	};
	
	exports.getContent = function() {
		console.log("getContent not supported on this extension"); 	
	};
	
    // Extension Vars
    exports.Title                   = extensionTitle;
    exports.ID                      = extensionID;   
    exports.Type                    = extensionType;
    exports.Icon                    = extensionIcon;
    exports.Version                 = extensionVersion;
    exports.ManifestVersion         = extensionManifestVersion;
    exports.License                 = extensionLicense;	
    exports.SupportedFileTypes      = extensionSupportedFileTypes;

});
Example #27
0
define(function(require, exports, module) {
  "use strict";

  console.log("Loading viewerHTML");

  var extensionTitle = "HTML Viewer";
  var extensionID = "viewerHTML"; // ID should be equal to the directory name where the ext. is located
  var extensionType = "viewer";
  var extensionIcon = "icon-list";
  var extensionVersion = "1.0";
  var extensionManifestVersion = 1;
  var extensionLicense = "AGPL";
  var extensionSupportedFileTypes = ["html", "htm"];

  var TSCORE = require("tscore");

  var containerElID,
    $containerElement,
    currentFilePath,
    viewerToolbar,
    $iframeViewer;

  var extensionDirectory = TSCORE.Config.getExtensionPath() + "/" + extensionID;

  exports.init = function(filePath, containerElementID) {
    console.log("Initalization HTML Viewer...");
    containerElID = containerElementID;
    $containerElement = $('#' + containerElID);

    currentFilePath = filePath;

    //var fileExt = TSCORE.TagUtils.extractFileExtension(filePath);

    $containerElement.empty();
    $containerElement.css("background-color", "white");

    $containerElement.append($('<iframe>', {
      sandbox: "allow-same-origin allow-scripts",
      id: "iframeViewer",
      "nwdisable": "",
      "nwfaketop": ""
    }));

    require([
      "text!" + extensionDirectory + '/mainUI.html'
    ], function(uiTPL) {
      var uiTemplate = Handlebars.compile(uiTPL);
      viewerToolbar = uiTemplate({
        id: extensionID
      });

      TSCORE.IO.loadTextFile(filePath);
    });
  };

  // set readonly
  exports.setFileType = function(fileType) {
    console.log("setFileType not supported on this extension");
  };

  exports.viewerMode = function(isViewerMode) {};

  exports.setContent = function(content) {
    var cleanedContent = content.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "");
    $iframeViewer = $("#iframeViewer");

    var fileDirectory = TSCORE.TagUtils.extractContainingDirectoryPath(currentFilePath);

    if ($iframeViewer !== undefined) {
      var $iframeViewerHead = $iframeViewer.contents().find('head');
      $iframeViewerHead.append($('<link/>', {
        rel: 'stylesheet',
        href: extensionDirectory + '/extension.css'
      }));
      $iframeViewerHead.append($('<link/>', {
        rel: 'stylesheet',
        href: extensionDirectory + '/../../libs/bootstrap/css/bootstrap.css'
      }));
      $iframeViewerHead.append($('<link/>', {
        rel: 'stylesheet',
        href: extensionDirectory + '/../../libs/font-awesome/css/font-awesome.css'
      }));
      $iframeViewerHead.append($('<link/>', {
        rel: 'stylesheet',
        href: extensionDirectory + '/css/markdown.css'
      }));
      $iframeViewerHead.append($('<link/>', {
        rel: 'stylesheet',
        href: extensionDirectory + '/css/github.css'
      }));
      //$iframeViewerHead.append($('<link/>', { rel: 'stylesheet', href: extensionDirectory+'/css/haroopad.css' }));
      $iframeViewerHead.append($('<link/>', {
        rel: 'stylesheet',
        href: extensionDirectory + '/css/metro-vibes.css'
      }));
      $iframeViewerHead.append($('<link/>', {
        rel: 'stylesheet',
        href: extensionDirectory + '/css/solarized-dark.css'
      }));
      $iframeViewerHead.append($('<link/>', {
        rel: 'stylesheet',
        href: extensionDirectory + '/css/clearness.css'
      }));
      $iframeViewerHead.append($('<link/>', {
        rel: 'stylesheet',
        href: extensionDirectory + '/css/clearness-dark.css'
      }));
      //$iframeViewerHead.append($('<link/>', { rel: 'stylesheet', href: extensionDirectory+'/readability/readability.css' }));
      //$iframeViewerHead.append($('<script>', { type: 'text/javascript', src: extensionDirectory+'/readability/readability.js' }));
    }

    var styles = ['', 'solarized-dark', 'github', 'metro-vibes', 'clearness', 'clearness-dark'];
    var currentStyleIndex = 0;

    var zoomSteps = ['zoomSmallest', 'zoomSmaller', 'zoomSmall', 'zoomDefault', 'zoomLarge', 'zoomLarger', 'zoomLargest'];
    var currentZoomState = 3;

    if ($iframeViewer !== undefined) {
      var $iframeViewerBody = $iframeViewer.contents().find('body');
      $iframeViewerBody.children().remove();
      $iframeViewerBody.append($('<div/>', {
        id: 'htmlContent'
      }).append(cleanedContent));
      $iframeViewerBody.append(viewerToolbar);

      if (isCordova) {
        $iframeViewerBody.find("#printButton").hide();
      }

      var $iframeHTMLContent = $iframeViewer.contents().find('#htmlContent');

      $iframeViewerBody.find("#changeStyleButton").bind('click', function() {
        currentStyleIndex = currentStyleIndex + 1;
        if (currentStyleIndex >= styles.length) {
          currentStyleIndex = 0;
        }
        $iframeViewerBody.css("padding", "0");
        $iframeViewerBody.css("margin", "0");
        $iframeHTMLContent.removeClass();
        $iframeHTMLContent.addClass('markdown');
        $iframeHTMLContent.addClass(styles[currentStyleIndex]);
      });

      $iframeViewerBody.find("#zoomInButton").bind('click', function() {
        currentZoomState++;
        if (currentZoomState >= zoomSteps.length) {
          currentZoomState = 6;
        }
        $iframeHTMLContent.removeClass();
        $iframeHTMLContent.addClass('markdown ' + styles[currentStyleIndex] + " " + zoomSteps[currentZoomState]);
      });

      $iframeViewerBody.find("#zoomOutButton").bind('click', function() {
        currentZoomState--;
        if (currentZoomState < 0) {
          currentZoomState = 0;
        }
        $iframeHTMLContent.removeClass();
        $iframeHTMLContent.addClass('markdown ' + styles[currentStyleIndex] + " " + zoomSteps[currentZoomState]);
      });

      $iframeViewerBody.find("#printButton").bind('click', function() {
        document.getElementById("iframeViewer").contentWindow.print();
      });

      // making all links open in the user default browser
      $iframeViewerBody.find("a").bind('click', function(e) {
        e.preventDefault();
        TSCORE.openLinkExternally($(this).attr("href"));
      });

      // fixing embedding of local images
      $iframeViewerBody.find("img[src]").each(function() {
        var currentSrc = $(this).attr("src");
        if (currentSrc.indexOf("http://") === 0 || currentSrc.indexOf("https://") === 0 || currentSrc.indexOf("data:") === 0) {
          // do nothing if src begins with http(s):// or data:
        } else {
          $(this).attr("src", "file://" + fileDirectory + TSCORE.dirSeparator + currentSrc);
        }
      });
    }
  };

  exports.getContent = function() {
    console.log("Not implemented");
  };

  // Extension Vars
  exports.Title = extensionTitle;
  exports.ID = extensionID;
  exports.Type = extensionType;
  exports.Icon = extensionIcon;
  exports.Version = extensionVersion;
  exports.ManifestVersion = extensionManifestVersion;
  exports.License = extensionLicense;
  exports.SupportedFileTypes = extensionSupportedFileTypes;

});
Example #28
0
	function openFile(filePath) {
	    console.log("Opening file: "+filePath);
		
		if(filePath == undefined) {
		    return false;
		}
		
		if(TSCORE.FileOpener.isFileEdited()) {
		    // TODO use closeFile method
            if(confirm("Any unsaved changes will be lost! Do you want to continue?")) {
                 $("#saveDocument").hide();
                _isEditMode = false;               
            } else {
                return false;   
            }
		}
                 		
	    _isEditMode = false;
	
	    _openedFilePath = filePath;    
	    $("#selectedFilePath").val(_openedFilePath.replace("\\\\","\\")); 
	    
	    var fileExt = TSCORE.TagUtils.extractFileExtension(filePath);       
	
	    // Getting the viewer for the file extension/type
	    var viewerExt = TSCORE.Config.getFileTypeViewer(fileExt);  
        var editorExt = TSCORE.Config.getFileTypeEditor(fileExt);  
	    console.log("File Viewer: "+viewerExt+" File Editor: "+editorExt);

        // Handling the edit button depending on existense of an editor
        if(editorExt == false || editorExt == "false" || editorExt == "") {
            $( "#editDocument" ).hide();        
        } else {
            $( "#editDocument" ).show();                
        }
     
	    $( "#viewer" ).empty();
	    
	    TSCORE.IO.checkAccessFileURLAllowed();
	    
	    TSCORE.IO.getFileProperties(filePath.replace("\\\\","\\"));
        
        if(!viewerExt) {
            require([TSCORE.Config.getExtensionPath()+"/viewerText/extension.js"], function(viewer) {
                _tsEditor = viewer;
                _tsEditor.init(filePath, "viewer", true);
            });
	        //$( "#viewer" ).html("<div class='alert alert-info'><strong>Info</strong> File type not supported for viewing.</div>");        
	    } else if (viewerExt == "viewerBrowser") {
            var filePathURI = undefined;
            if(isCordova) {
                filePathURI = filePath;            
            } else {
                filePathURI = "file:///"+filePath;  
            }
            
		    $('#viewer').append($('<iframe>', {
		    	id: "iframeViewer",
				src: filePathURI
		    })); 
	    } else {
	        require([TSCORE.Config.getExtensionPath()+"/"+viewerExt+"/extension.js"], function(viewer) {
	            _tsEditor = viewer;
	            _tsEditor.init(filePath, "viewer", true);
	        });
	    }

        updateUI();  
        initTagSuggestionMenu(filePath);
	    
        // Clearing file selection on file load and adding the current file path to the selection
        TSCORE.PerspectiveManager.clearSelectedFiles();
        TSCORE.selectedFiles.push(filePath); 	     
	    
	    TSCORE.FileOpener.setFileOpened(true); 
		TSCORE.openFileViewer();
	} 
Example #29
0
 $( "#editTagGroupButton" ).click( function() {
     TSCORE.Config.editTagGroup(TSCORE.selectedTagData, $( "#tagGroupName" ).val() );
     generateTagGroups();                    
 });           
Example #30
0
 function openFile(filePath, editMode) {
   console.log('Opening file: ' + filePath);
   if (filePath === undefined) {
     return false;
   }
   if (TSCORE.FileOpener.isFileChanged()) {
     // TODO use closeFile method
     if (confirm($.i18n.t('ns.dialogs:closingEditedFileConfirm'))) {
       $('#saveDocument').hide();
       _isEditMode = false;
     } else {
       return false;
     }
   }
   _isEditMode = false;
   _isFileChanged = false;
   _openedFilePath = filePath;
   //$("#selectedFilePath").val(_openedFilePath.replace("\\\\","\\"));
   if (isWeb) {
     var downloadLink;
     if (location.port === '') {
       downloadLink = location.protocol + '//' + location.hostname + _openedFilePath;
     } else {
       downloadLink = location.protocol + '//' + location.hostname + ':' + location.port + _openedFilePath;
     }
     $('#downloadFile').attr('href', downloadLink).attr('download', TSCORE.TagUtils.extractFileName(_openedFilePath));
   } else {
     $('#downloadFile').attr('href', 'file:///' + _openedFilePath).attr('download', TSCORE.TagUtils.extractFileName(_openedFilePath));
   }
   var fileExt = TSCORE.TagUtils.extractFileExtension(filePath);
   // Getting the viewer for the file extension/type
   var viewerExt = TSCORE.Config.getFileTypeViewer(fileExt);
   var editorExt = TSCORE.Config.getFileTypeEditor(fileExt);
   console.log('File Viewer: ' + viewerExt + ' File Editor: ' + editorExt);
   // Handling the edit button depending on existense of an editor
   if (editorExt === false || editorExt === 'false' || editorExt === '') {
     $('#editDocument').hide();
   } else {
     $('#editDocument').show();
   }
   var $viewer = $('#viewer');
   $viewer.find('*').off();
   $viewer.find('*').unbind();
   $viewer.find('*').remove();
   TSCORE.IO.checkAccessFileURLAllowed();
   TSCORE.IO.getFileProperties(filePath.replace('\\\\', '\\'));
   updateUI();
   if (editMode) {
     // opening file for editing
     editFile(filePath);
   } else {
     // opening file for viewing
     if (!viewerExt) {
       require([TSCORE.Config.getExtensionPath() + '/viewerText/extension.js'], function(viewer) {
         _tsEditor = viewer;
         _tsEditor.init(filePath, 'viewer', true);
       });
     } else {
       require([TSCORE.Config.getExtensionPath() + '/' + viewerExt + '/extension.js'], function(viewer) {
         _tsEditor = viewer;
         _tsEditor.init(filePath, 'viewer', true);
       });
     }
   }
   initTagSuggestionMenu(filePath);
   // Clearing file selection on file load and adding the current file path to the selection
   TSCORE.PerspectiveManager.clearSelectedFiles();
   TSCORE.selectedFiles.push(filePath);
   _isFileOpened = true;
   TSCORE.openFileViewer();
   // Handling the keybindings
   Mousetrap.unbind(TSCORE.Config.getSaveDocumentKeyBinding());
   Mousetrap.bindGlobal(TSCORE.Config.getSaveDocumentKeyBinding(), function() {
     saveFile();
     return false;
   });
   Mousetrap.unbind(TSCORE.Config.getCloseViewerKeyBinding());
   Mousetrap.bindGlobal(TSCORE.Config.getCloseViewerKeyBinding(), function() {
     closeFile();
     return false;
   });
   Mousetrap.unbind(TSCORE.Config.getReloadDocumentKeyBinding());
   Mousetrap.bindGlobal(TSCORE.Config.getReloadDocumentKeyBinding(), function() {
     reloadFile();
     return false;
   });
   /*Mousetrap.unbind(TSCORE.Config.getDeleteDocumentKeyBinding());
       Mousetrap.bind(TSCORE.Config.getDeleteDocumentKeyBinding(), function() {
           TSCORE.showFileDeleteDialog(_openedFilePath);
           return false;
       });*/
   Mousetrap.unbind(TSCORE.Config.getPropertiesDocumentKeyBinding());
   Mousetrap.bindGlobal(TSCORE.Config.getPropertiesDocumentKeyBinding(), function() {
     showFilePropertiesDialog();
     return false;
   });
   Mousetrap.unbind(TSCORE.Config.getPrevDocumentKeyBinding());
   Mousetrap.bind(TSCORE.Config.getPrevDocumentKeyBinding(), function() {
     TSCORE.FileOpener.openFile(TSCORE.PerspectiveManager.getPrevFile(_openedFilePath));
     return false;
   });
   Mousetrap.unbind(TSCORE.Config.getNextDocumentKeyBinding());
   Mousetrap.bind(TSCORE.Config.getNextDocumentKeyBinding(), function() {
     TSCORE.FileOpener.openFile(TSCORE.PerspectiveManager.getNextFile(_openedFilePath));
     return false;
   });
   Mousetrap.unbind(TSCORE.Config.getEditDocumentKeyBinding());
   Mousetrap.bindGlobal(TSCORE.Config.getEditDocumentKeyBinding(), function() {
     editFile(_openedFilePath);
     return false;
   });
 }