ryanackley avatar ryanackley committed 42c45c2

Added a configuration for an http server that maps directly to a local file. Removed all inline javascript.

Comments (0)

Files changed (9)

SimpleWebServerConfig.js

+ProjectTypes.push(
+    {
+        name: 'Http Web Server',
+        key: 'web.server',
+        locationType : 'local',
+        createProject : function(root, url, callback){  
+            var routes = [{from: url, to: root.fullPath}];
+            var project = new UrlToDirectoryMappedProject(routes);
+            callback(project);
+        } 
+    }
+);
 <html>
   <head>
     <title>Background Page</title>
-    	<script>
-    		ProjectTypes = [];
-    		var projectsByTab= {};
-    		var watchersByTab={};
-    	</script>
+    	<script src="backgroundInit.js"></script>
     	<script src="file_utils.js"></script>
     	<script src="ConfigFileBasedProject.js"></script>
 		<script src="RubyOnRailsProject.js"></script>
 		<script src="ConfigFileBasedProjectLoader.js"></script>
 		<script src="ProjectManager.js"></script>
     	<embed type="application/x-npapifileioforchrome" id="pluginId" style="position:absolute; top:0px;left:-10000px;width:5px;height:5px;">
-
-		<script>
-		  window.nativeFileSupport = document.getElementById("pluginId");
-		</script>
+		<script src="nativeSupport.js"></script>
 		<script src="FauxFilesystem.js"></script>
-		<script>
-		  var projectManager = new ProjectManager();
-		  chrome.extension.onRequest.addListener(function(request, sender, sendResponse) {
-		  		
-				if (request.key == 'ProjectTypes'){
-					//var cleanResponse = [];
-					//for (var i = 0; i < ProjectTypes.length){
-					//	cleanResponse.push({name: ProjectTypes[i].name, locationType: ProjectTypes[i].locationType});
-					//}
-					sendResponse(ProjectTypes);
-				}
-				else if (request.key == 'launchFileSelect'){
-					projectManager.launchFileSelect(sender.tab.id, request.url, request.index, sendResponse);
-				}
-				else if (request.key == 'checkResources'){
-					projectManager.checkResources(sender.tab.id, request.resources, sendResponse);
-				}
-				else if (request.key == 'checkResourceContent'){
-					projectManager.checkResourceContent(sender.tab.id, request.url, request.content, sendResponse);
-				}
-				else if (request.key == 'updateResource'){
-				    projectManager.updateResource(sender.tab.id, request.url, request.content, sendResponse);
-				}
-				else if (request.key == 'pageChanged'){
-					projectManager.resetProject(sender.tab.id, sendResponse);
-				}
-				else if (request.key == 'loadProject'){
-					projectManager.loadProject(sender.tab.id, request.type, request.path, request.url, sendResponse);
-				}
-				else if (request.key == 'unwatchDirectory'){
-					projectManager.unwatchDirectory(sender.tab.id, sendResponse);
-				}
-				else{
-					sendResponse({});
-				}
-				
-		  });
-		  chrome.extension.onConnect.addListener(function(port){
-		  	projectManager.watchDirectory(port);
-		  });
-		  chrome.tabs.onRemoved.addListener(function(tabId, removeInfo) {
-		  		projectManager.cleanUp(tabId);
-		  });
-		</script>
-
+		<script src="background.js"></script>
   </head>
   <body>
   </body>
+var projectManager = new ProjectManager();
+chrome.extension.onRequest.addListener(function(request, sender, sendResponse) {
+    
+    if (request.key == 'ProjectTypes'){
+        //var cleanResponse = [];
+        //for (var i = 0; i < ProjectTypes.length){
+        //  cleanResponse.push({name: ProjectTypes[i].name, locationType: ProjectTypes[i].locationType});
+        //}
+        sendResponse(ProjectTypes);
+    }
+    else if (request.key == 'launchFileSelect'){
+        projectManager.launchFileSelect(sender.tab.id, request.url, request.index, sendResponse);
+    }
+    else if (request.key == 'checkResources'){
+        projectManager.checkResources(sender.tab.id, request.resources, sendResponse);
+    }
+    else if (request.key == 'checkResourceContent'){
+        projectManager.checkResourceContent(sender.tab.id, request.url, request.content, sendResponse);
+    }
+    else if (request.key == 'updateResource'){
+        projectManager.updateResource(sender.tab.id, request.url, request.content, sendResponse);
+    }
+    else if (request.key == 'pageChanged'){
+        projectManager.resetProject(sender.tab.id, sendResponse);
+    }
+    else if (request.key == 'loadProject'){
+        projectManager.loadProject(sender.tab.id, request.type, request.path, request.url, sendResponse);
+    }
+    else if (request.key == 'unwatchDirectory'){
+        projectManager.unwatchDirectory(sender.tab.id, sendResponse);
+    }
+    else{
+        sendResponse({});
+    }
+    
+});
+chrome.extension.onConnect.addListener(function(port){
+projectManager.watchDirectory(port);
+});
+chrome.tabs.onRemoved.addListener(function(tabId, removeInfo) {
+    projectManager.cleanUp(tabId);
+});

backgroundInit.js

+ProjectTypes = [];
+var projectsByTab= {};
+var watchersByTab={};
+/*
+* Copyright 2012 Ryan Ackley (ryanackley@gmail.com)
+*
+* This file is part of Tincr.
+*
+* Tincr is free software: you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+* 
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+* 
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+*/
 	<script src="zepto1.0rc1.js"></script>
 	<script src="BackgroundMsgSupport.js"></script>
 	<script src="Logger.js"></script>
-	<script>
-		
-		var projectTypes;
-		
-		var checkProjectState = function(){
-			var projectState = window.devtoolsWindow.projectState;
-				
-			if (projectState.type == 'fileUrl'){
-				$('#project-type').attr('disabled', 'true');
-				$('#native-browse').attr('disabled', 'true');
-				
-				$('#file-select').hide();
-				$('#auto-refresh').hide();
-				$('#auto-save').hide();
-			}
-			else if (projectState.type){
-				var typeSelect = document.getElementById('project-type');
-				$('#project-type').removeAttr('disabled');
-				$('#native-browse').removeAttr('disabled');
-				
-				for (var i = 0; i < projectTypes.length; i++){
-					if (projectTypes[i].key === projectState.type){
-						typeSelect.value = String(i);
-						break;
-					}
-				}
-				$('#local-file-path').text(projectState.path).show();
-				$('#toggle-watch')[0].checked = projectState.watchFiles;
-				$('#toggle-autosave')[0].checked = projectState.autosave;
-				
-				$('#file-select').show();
-				$('#auto-refresh').show();
-				$('#auto-save').show();
-				
-				$('#load-error').hide();
-				$('#error-img').hide();
-				$('#success-img').show();
-				$('#load-success').show();
-			}
-			
-			var loggingEnabled = devtoolsWindow.localStorage['logging'] === 'true';
-			toggleLogging(loggingEnabled);
-			$('#toggle-logging')[0].checked = loggingEnabled;
-			
-		}
-		
-		var initUI = function(){
-		
-			var typeSelect = document.getElementById('project-type');
-			
-			backgroundMsgSupport.getProjectTypes(function(types){
-				projectTypes = types;
-				for (var i = 0; i < projectTypes.length; ++i) {
-					var projectType = projectTypes[i];
-					typeSelect.add(new Option(projectType.name, i));
-				}
-				checkProjectState();
-			});
-			$(typeSelect).on('change', function(e){
-				var index = Number(typeSelect.value);
-				var projectType = projectTypes[index];
-				if (projectType.locationType == 'local'){
-					$('#file-select').show();
-				}
-			});
-			$('#native-browse').on('click', function(e){
-				var index = Number(typeSelect.value);
-				backgroundMsgSupport.launchFileSelect(index, window.devtoolsWindow.inspectedLocation.origin, function(result){
-					if (result.path && result.path.length){
-						$('#local-file-path').text(result.path).show();
-						if (result.error){
-							logError(result.error);
-							$('#load-error').text(result.error).show();
-							$('#error-img').show();
-							$('#success-img').hide();
-							$('#load-success').hide();
-						}
-						else{
-							var projectType = projectTypes[index];
-							window.devtoolsWindow.loadProject(projectType.key, result.path, true, true);
-							$('#toggle-autosave')[0].checked = true;
-							$('#toggle-watch')[0].checked = true;
-							$('#auto-refresh').show();
-				            $('#auto-save').show();
-				            
-				            $('#load-error').hide();
-							$('#error-img').hide();
-							$('#success-img').show();
-							$('#load-success').show();
-						}
-					}
-				});
-				return false;
-			});
-			$('#toggle-watch').on('change', function(e){
-				var path = $('#local-file-path').text();
-				if (path && path.length){
-					this.disabled=true;
-					var self = this;
-					window.devtoolsWindow.toggleWatchingFiles(this.checked, path, function(){
-						self.disabled = false;
-						window.devtoolsWindow.saveProjectState();
-					});
-				}
-			});
-			$('#toggle-autosave').on('change', function(e){
-				if (window.devtoolsWindow.projectState){
-					window.devtoolsWindow.projectState.autosave = this.checked;
-				}
-				window.devtoolsWindow.saveProjectState();
-			});
-			$('#toggle-logging').on('change', function(e){
-				devtoolsWindow.localStorage['logging'] = '' + this.checked;
-				toggleLogging(this.checked);
-				devtoolsWindow.toggleLogging(this.checked);
-			});
-			
-		};
-	</script>
+	<script src="editorpanel.js"></script>
 </head>
 <body>
 	<div id="project-select-form">
+var projectTypes;
+        
+var checkProjectState = function(){
+    var projectState = window.devtoolsWindow.projectState;
+        
+    if (projectState.type == 'fileUrl'){
+        $('#project-type').attr('disabled', 'true');
+        $('#native-browse').attr('disabled', 'true');
+        
+        $('#file-select').hide();
+        $('#auto-refresh').hide();
+        $('#auto-save').hide();
+    }
+    else if (projectState.type){
+        var typeSelect = document.getElementById('project-type');
+        $('#project-type').removeAttr('disabled');
+        $('#native-browse').removeAttr('disabled');
+        
+        for (var i = 0; i < projectTypes.length; i++){
+            if (projectTypes[i].key === projectState.type){
+                typeSelect.value = String(i);
+                break;
+            }
+        }
+        $('#local-file-path').text(projectState.path).show();
+        $('#toggle-watch')[0].checked = projectState.watchFiles;
+        $('#toggle-autosave')[0].checked = projectState.autosave;
+        
+        $('#file-select').show();
+        $('#auto-refresh').show();
+        $('#auto-save').show();
+        
+        $('#load-error').hide();
+        $('#error-img').hide();
+        $('#success-img').show();
+        $('#load-success').show();
+    }
+    
+    var loggingEnabled = devtoolsWindow.localStorage['logging'] === 'true';
+    toggleLogging(loggingEnabled);
+    $('#toggle-logging')[0].checked = loggingEnabled;
+    
+}
+
+var initUI = function(){
+
+    var typeSelect = document.getElementById('project-type');
+    
+    backgroundMsgSupport.getProjectTypes(function(types){
+        projectTypes = types;
+        for (var i = 0; i < projectTypes.length; ++i) {
+            var projectType = projectTypes[i];
+            typeSelect.add(new Option(projectType.name, i));
+        }
+        checkProjectState();
+    });
+    $(typeSelect).on('change', function(e){
+        var index = Number(typeSelect.value);
+        var projectType = projectTypes[index];
+        if (projectType.locationType == 'local'){
+            $('#file-select').show();
+        }
+    });
+    $('#native-browse').on('click', function(e){
+        var index = Number(typeSelect.value);
+        backgroundMsgSupport.launchFileSelect(index, window.devtoolsWindow.inspectedLocation.origin, function(result){
+            if (result.path && result.path.length){
+                $('#local-file-path').text(result.path).show();
+                if (result.error){
+                    logError(result.error);
+                    $('#load-error').text(result.error).show();
+                    $('#error-img').show();
+                    $('#success-img').hide();
+                    $('#load-success').hide();
+                }
+                else{
+                    var projectType = projectTypes[index];
+                    window.devtoolsWindow.loadProject(projectType.key, result.path, true, true);
+                    $('#toggle-autosave')[0].checked = true;
+                    $('#toggle-watch')[0].checked = true;
+                    $('#auto-refresh').show();
+                    $('#auto-save').show();
+                    
+                    $('#load-error').hide();
+                    $('#error-img').hide();
+                    $('#success-img').show();
+                    $('#load-success').show();
+                }
+            }
+        });
+        return false;
+    });
+    $('#toggle-watch').on('change', function(e){
+        var path = $('#local-file-path').text();
+        if (path && path.length){
+            this.disabled=true;
+            var self = this;
+            window.devtoolsWindow.toggleWatchingFiles(this.checked, path, function(){
+                self.disabled = false;
+                window.devtoolsWindow.saveProjectState();
+            });
+        }
+    });
+    $('#toggle-autosave').on('change', function(e){
+        if (window.devtoolsWindow.projectState){
+            window.devtoolsWindow.projectState.autosave = this.checked;
+        }
+        window.devtoolsWindow.saveProjectState();
+    });
+    $('#toggle-logging').on('change', function(e){
+        devtoolsWindow.localStorage['logging'] = '' + this.checked;
+        toggleLogging(this.checked);
+        devtoolsWindow.toggleLogging(this.checked);
+    });
+    
+};
 {
   "name": "Tincr",
+  "manifest_version": 2,
   "description": "Extension to allow editing and fast reloading of local files from Chrome developer tools",
-  "version": "1",
+  "version": "1.1",
   "devtools_page": "devtools.html",
-  "background_page": "background.html",
+  "background": {"page" :"background.html"},
   "icons": {"48": "tools_small.png",
             "128": "tools.png" },
   "permissions": ["http://*/", "https://*/"],
+window.nativeFileSupport = document.getElementById("pluginId");
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.