コード例 #1
0
ファイル: extension.js プロジェクト: shafiahmed/tagspaces
	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": "",
	        	})
	        );
	    }
	};
コード例 #2
0
ファイル: extension.js プロジェクト: keepcleargas/tagspaces
    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);
//        }
    };
コード例 #3
0
ファイル: extension.js プロジェクト: 2050utopia/tagspaces
    ], function(uiTPL) {
      var uiTemplate = Handlebars.compile(uiTPL);
      viewerToolbar = uiTemplate({
        id: extensionID
      });

      TSCORE.IO.loadTextFile(filePath);
    });
コード例 #4
0
ファイル: extension.js プロジェクト: DrJawadAhmed/tagspaces
		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());
		        })       
		    }
		});
コード例 #5
0
ファイル: extension.js プロジェクト: 2050utopia/tagspaces
  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": ""
      }));
    }
  };
コード例 #6
0
ファイル: extension.js プロジェクト: Fizcus/tagspaces
 require([extensionDirectory+'/marked/marked.js'], function(marked) {
     md2htmlConverter = marked;
     md2htmlConverter.setOptions({
         renderer: new marked.Renderer(),
         //highlight: function (code) {
         //    //return require([extensionDirectory+'/highlightjs/highlight.js']).highlightAuto(code).value;
         //},
         gfm: true,
         tables: true,
         breaks: false,
         pedantic: false,
         smartLists: true,
         smartypants: false
     });
     TSCORE.IO.loadTextFile(filePath);
 });
コード例 #7
0
ファイル: extension.js プロジェクト: DrJawadAhmed/tagspaces
	exports.init = function(filePath, containerElementID) {
	    console.log("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");
	    TSCORE.IO.loadTextFile(filePath);
	    if (filetype[fileExt] != null) {
	        require(["./ace/mode/" + filetype[fileExt]], function(acemode) {
	        	var syntaxMode = acemode.Mode;
	        	aceEditor.getSession().setMode(new syntaxMode());
	        })       
	    }
	
	}
コード例 #8
0
ファイル: extension.js プロジェクト: alisiddique/tagspaces
            ], 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);
            });
コード例 #9
0
ファイル: extension.js プロジェクト: DrJawadAhmed/tagspaces
		require([extensionDirectory+'/showdown/showdown.js'], function() {
			md2htmlConverter = new Showdown.converter();
			TSCORE.IO.loadTextFile(filePath);
		});
コード例 #10
0
ファイル: extension.js プロジェクト: ecneladis/tagspaces
		 	], function() {
				$("#"+containerElementID).append('<div id="htmlEditor"></div>');	 	
				TSCORE.IO.loadTextFile(filePath);
		});
コード例 #11
0
 contentIFrame.onload = function() {
   //console.log("IFrame Loaded: ");
   TSCORE.IO.loadTextFile(currentFilePath);
 };