Bug 389061 - Settings page won't load
diff --git a/bundles/org.eclipse.orion.client.core/web/orion/widgets/settings/LabeledRepositoryLink.js b/bundles/org.eclipse.orion.client.core/web/orion/widgets/settings/LabeledRepositoryLink.js
index b7b75f2..cb1f420 100644
--- a/bundles/org.eclipse.orion.client.core/web/orion/widgets/settings/LabeledRepositoryLink.js
+++ b/bundles/org.eclipse.orion.client.core/web/orion/widgets/settings/LabeledRepositoryLink.js
@@ -14,7 +14,7 @@
 /* This SettingsContainer widget is a dojo border container with a left and right side. The left is for choosing a 

    category, the right shows the resulting HTML for that category. */

 

-define(['i18n!orion/settings/nls/messages', 'require', 'dojo', 'dijit', 'orion/util', 'orion/commands', 'orion/git/GitCredentialsStorage'], function(messages, require, dojo, dijit, mUtil, mCommands, mGitCredentialsStorage) {

+define(['i18n!orion/settings/nls/messages', 'require', 'dojo', 'dijit', 'orion/util', 'orion/commands', 'orion/git/GitCredentialsStorage'], function(messages, require, dojo, dijit, mUtil, mCommands, GitCredentialsStorage) {

 

 	dojo.declare("orion.widgets.settings.LabeledRepositoryLink",[dijit._Widget, dijit._Templated],{ //$NON-NLS-0$

 		

@@ -30,7 +30,7 @@
 		},

         

         change: function(){

-        	var gitCredentialsStorage = new mGitCredentialsStorage.GitCredentialsStorage();

+        	var gitCredentialsStorage = new GitCredentialsStorage();

         	if(gitCredentialsStorage.isBrowserEnabled()){

         		gitCredentialsStorage.erasePrompt(this.mylabel.innerHTML);

         	}

diff --git a/bundles/org.eclipse.orion.client.core/web/orion/widgets/settings/UserSettings.js b/bundles/org.eclipse.orion.client.core/web/orion/widgets/settings/UserSettings.js
index 0960707..e130921 100644
--- a/bundles/org.eclipse.orion.client.core/web/orion/widgets/settings/UserSettings.js
+++ b/bundles/org.eclipse.orion.client.core/web/orion/widgets/settings/UserSettings.js
@@ -14,7 +14,7 @@
 /* This SettingsContainer widget is a dojo border container with a left and right side. The left is for choosing a 

    category, the right shows the resulting HTML for that category. */

 

-define(['i18n!orion/settings/nls/messages', 'require', 'dojo', 'dijit', 'orion/util', 'orion/commands', 'orion/section', 'orion/git/GitCredentialsStorage', 'orion/widgets/settings/LabeledTextfield', 'orion/widgets/settings/LabeledCheckbox', 'orion/widgets/settings/LabeledRepositoryLink', 'orion/widgets/settings/LabeledToggle', 'profile/UsersService', 'orion/widgets/settings/Section' ], function(messages, require, dojo, dijit, mUtil, mCommands, mSection, mGitCredentialsStorage) {

+define(['i18n!orion/settings/nls/messages', 'require', 'dojo', 'dijit', 'orion/util', 'orion/commands', 'orion/section', 'orion/git/GitCredentialsStorage', 'orion/widgets/settings/LabeledTextfield', 'orion/widgets/settings/LabeledCheckbox', 'orion/widgets/settings/LabeledRepositoryLink', 'orion/widgets/settings/LabeledToggle', 'profile/UsersService', 'orion/widgets/settings/Section' ], function(messages, require, dojo, dijit, mUtil, mCommands, mSection, GitCredentialsStorage) {

 

 	dojo.declare("orion.widgets.settings.UserSettings", [dijit._Widget, dijit._Templated], { //$NON-NLS-0$

 	

@@ -59,7 +59,7 @@
 		},

 		

 		refreshGitCredentials : function(){

-			var gitCredentialsStorage = new mGitCredentialsStorage.GitCredentialsStorage();

+			var gitCredentialsStorage = new GitCredentialsStorage();

 			if(gitCredentialsStorage.isBrowserEnabled()){

 				this.gitCredentialsFields[0].setChecked(gitCredentialsStorage.isUserEnabled());

 			}

@@ -142,7 +142,7 @@
 			

 			this.gitCredentialsFields.push( new orion.widgets.settings.LabeledCheckbox( {fieldlabel:messages["Enable Key Storage"]} ) );

 			

-			var gitCredentialsStorage = new mGitCredentialsStorage.GitCredentialsStorage();

+			var gitCredentialsStorage = new GitCredentialsStorage();

 			if(gitCredentialsStorage.isBrowserEnabled()){

 				var repositories = gitCredentialsStorage.getRepositories();

 				

@@ -160,7 +160,7 @@
 				tooltip: messages["Reset Git Credentials"],

 				id: "orion.clearGitCredentials",

 				callback: dojo.hitch(this, function(data){

-					var gitCredentialsStorage = new mGitCredentialsStorage.GitCredentialsStorage();

+					var gitCredentialsStorage = new GitCredentialsStorage();

 					if(gitCredentialsStorage.isBrowserEnabled()){

 						gitCredentialsStorage.clearCredentials();

 						

@@ -290,7 +290,7 @@
 			var messageService = this.registry.getService("orion.page.message"); //$NON-NLS-0$

 			

 			// git authentication update

-			var gitCredentialsStorage = new mGitCredentialsStorage.GitCredentialsStorage();

+			var gitCredentialsStorage = new GitCredentialsStorage();

 			if(gitCredentialsStorage.isBrowserEnabled()){

 				if( this.gitCredentialsFields[0].isChecked() ){

 					if(window.confirm(messages["Please be aware that your credentials will be stored persistently in the browser."] + '\n' + messages["Do you wish to enable the Key Storage?"])){

diff --git a/bundles/org.eclipse.orion.client.git/web/orion/git/gitCredentialsStorage.js b/bundles/org.eclipse.orion.client.git/web/orion/git/GitCredentialsStorage.js
similarity index 97%
rename from bundles/org.eclipse.orion.client.git/web/orion/git/gitCredentialsStorage.js
rename to bundles/org.eclipse.orion.client.git/web/orion/git/GitCredentialsStorage.js
index b202010..24bfcfa 100644
--- a/bundles/org.eclipse.orion.client.git/web/orion/git/gitCredentialsStorage.js
+++ b/bundles/org.eclipse.orion.client.git/web/orion/git/GitCredentialsStorage.js
@@ -10,7 +10,7 @@
  *******************************************************************************/

  /*global define console window document navigator */

  

- define(['dojo'], function(dojo){

+ define(function(){

  

 	/**

 	 * Local storage support class.

@@ -227,7 +227,9 @@
 			for(var i=0; i<keys.length; ++i){

 				if(keys[i] !== "isUserEnabled"){

 					var repository = keys[i].substring(0, keys[i].indexOf("::"));

-					if(dojo.indexOf(result, repository) < 0){ result.push(repository); }

+					if(result.indexOf(repository) === -1){

+						result.push(repository);

+					}

 				}

 			}

 			

@@ -237,7 +239,5 @@
 	

 	GitCredentialsStorage.prototype.constructor = GitCredentialsStorage;

  

-	return {

-		GitCredentialsStorage : GitCredentialsStorage

-	};

+	return GitCredentialsStorage;

  });
\ No newline at end of file
diff --git a/bundles/org.eclipse.orion.client.git/web/orion/git/gitCommands.js b/bundles/org.eclipse.orion.client.git/web/orion/git/gitCommands.js
index f134d68..3a2d793 100644
--- a/bundles/org.eclipse.orion.client.git/web/orion/git/gitCommands.js
+++ b/bundles/org.eclipse.orion.client.git/web/orion/git/gitCommands.js
@@ -15,7 +15,7 @@
         'orion/git/widgets/AddRemoteDialog', 'orion/git/widgets/GitCredentialsDialog', 'orion/widgets/NewItemDialog', 
         'orion/git/widgets/RemotePrompterDialog', 'orion/git/widgets/ApplyPatchDialog', 'orion/git/widgets/OpenCommitDialog', 'orion/git/widgets/ConfirmPushDialog', 'orion/git/widgets/ReviewRequestDialog', 
         'orion/git/widgets/ContentDialog', 'orion/git/widgets/CommitDialog'], 
-        function(messages, require, dojo, mCommands, mUtil, mGitUtil, mCompareUtils, mGitCredentialsStorage) {
+        function(messages, require, dojo, mCommands, mUtil, mGitUtil, mCompareUtils, GitCredentialsStorage) {
 
 /**
  * @namespace The global container for eclipse APIs.
@@ -95,7 +95,7 @@
 				onDone(name);
 			}
 		}
-	}
+	};
 
 	exports.handleKnownHostsError = function(serviceRegistry, errorData, options, func){
 		if(confirm(dojo.string.substitute(messages["Would you like to add ${0} key for host ${1} to continue operation? Key fingerpt is ${2}."],
@@ -116,7 +116,7 @@
 
 	exports.handleSshAuthenticationError = function(serviceRegistry, errorData, options, func, title){
 		var repository = errorData.Url;
-		var gitCredentialsStorage = new mGitCredentialsStorage.GitCredentialsStorage();
+		var gitCredentialsStorage = new GitCredentialsStorage();
 		var loadedPrivateKey = "", loadedPassphrase = "";
 						
 		if(gitCredentialsStorage.isEnabled() && !gitCredentialsStorage.getPrompt(repository)){
@@ -220,8 +220,8 @@
 			
 			try {
 				display.Message = jsonData.DetailedMessage ? jsonData.DetailedMessage : jsonData.Message;
-			} catch (Exception) {
-				display.Message = error.message;
+			} catch (e) {
+				display.Message = e.message;
 			}
 			
 			serviceRegistry.getService("orion.page.message").setProgressResult(display); //$NON-NLS-0$
@@ -260,7 +260,7 @@
 				var sshService = serviceRegistry.getService("orion.net.ssh"); //$NON-NLS-0$
 				sshService.addKnownHosts(errorData.Host + " " + errorData.KeyType + " " + errorData.HostKey).then( //$NON-NLS-1$ //$NON-NLS-0$
 					function(){
-						var gitCredentialsStorage = new mGitCredentialsStorage.GitCredentialsStorage();
+						var gitCredentialsStorage = new GitCredentialsStorage();
 						var loadedPrivateKey = "", loadedPassphrase = "";
 						
 						if(gitCredentialsStorage.isEnabled() && !gitCredentialsStorage.getPrompt(repository)){
@@ -275,7 +275,7 @@
 			return def;
 		}
 		
-		var gitCredentialsStorage = new mGitCredentialsStorage.GitCredentialsStorage();
+		var gitCredentialsStorage = new GitCredentialsStorage();
 		if(gitCredentialsStorage.isEnabled() && !gitCredentialsStorage.getPrompt(repository)){
 			var loadedPrivateKey = gitCredentialsStorage.getPrivateKey(repository);
 			var loadedPassphrase = gitCredentialsStorage.getPassphrase(repository);
@@ -327,7 +327,7 @@
 		if(jsonData.HttpCode == 500 || jsonData.HttpCode == 400){
 			var repository = jsonData.JsonData.Url;
 			
-			var gitCredentialsStorage = new mGitCredentialsStorage.GitCredentialsStorage();
+			var gitCredentialsStorage = new GitCredentialsStorage();
 			if(gitCredentialsStorage.isEnabled()){
 				gitCredentialsStorage.erasePrivateKey(repository);
 				gitCredentialsStorage.erasePassphrase(repository);
@@ -366,8 +366,8 @@
 			
 			try {
 				display.Message = jsonData.DetailedMessage ? jsonData.DetailedMessage : jsonData.Message;
-			} catch (Exception) {
-				display.Message = error.message;
+			} catch (e) {
+				display.Message = e.message;
 			}
 			
 			serviceRegistry.getService("orion.page.message").setProgressResult(display); //$NON-NLS-0$
@@ -1512,7 +1512,7 @@
 					var deferred = gitService.doPush(location, ref, true, force, //$NON-NLS-0$
 							options.gitSshUsername, options.gitSshPassword, options.knownHosts,
 							options.gitPrivateKey, options.gitPassphrase);
-					progressService.createProgressMonitor(deferred, messages['Pushing remote: '] + name)
+					progressService.createProgressMonitor(deferred, messages['Pushing remote: '] + name);
 					deferred.then(
 						function(jsonData){
 							exports.handleProgressServiceResponse2(jsonData, serviceRegistry, 
@@ -2516,7 +2516,7 @@
 					var deferred = serviceRegistry.getService("orion.git.provider").stage(items[0].indexURI); //$NON-NLS-0$ 
 					progressService.createProgressMonitor(
 						deferred,
-						messages["Staging changes"])
+						messages["Staging changes"]);
 					deferred.then(
 						function(jsonData){
 							dojo.hitch(explorer, explorer.changedItem)(items);
@@ -2874,7 +2874,7 @@
 					
 				}, displayErrorOnStatus
 			);
-		};
+		}
 	};
 
 }());
diff --git a/bundles/org.eclipse.orion.client.git/web/orion/git/widgets/GitCredentialsDialog.js b/bundles/org.eclipse.orion.client.git/web/orion/git/widgets/GitCredentialsDialog.js
index 2fd2457..a34004c 100644
--- a/bundles/org.eclipse.orion.client.git/web/orion/git/widgets/GitCredentialsDialog.js
+++ b/bundles/org.eclipse.orion.client.git/web/orion/git/widgets/GitCredentialsDialog.js
@@ -9,9 +9,9 @@
  * Contributors: IBM Corporation - initial API and implementation
  ******************************************************************************/
 
-/*global dojo dijit widgets FileReader*/
+/*global dojo dijit widgets FileReader define orion*/
 /*jslint browser:true*/
-define(['i18n!git/nls/gitmessages', 'dojo', 'dijit', 'dijit/Tooltip', 'orion/git/GitCredentialsStorage', 'dijit/Dialog', 'orion/widgets/_OrionDialogMixin', 'text!orion/git/widgets/templates/GitCredentialsDialog.html'], function(messages, dojo, dijit, Tooltip, mGitCredentialsStorage) {
+define(['i18n!git/nls/gitmessages', 'dojo', 'dijit', 'dijit/Tooltip', 'orion/git/GitCredentialsStorage', 'dijit/Dialog', 'orion/widgets/_OrionDialogMixin', 'text!orion/git/widgets/templates/GitCredentialsDialog.html'], function(messages, dojo, dijit, Tooltip, GitCredentialsStorage) {
 
 
 /**
@@ -155,7 +155,7 @@
 					loadedPrivateKey = e.target.result;
 					
 					//save key
-					var gitCredentialsStorage = new mGitCredentialsStorage.GitCredentialsStorage();
+					var gitCredentialsStorage = new GitCredentialsStorage();
 					if(gitCredentialsStorage.isEnabled() && self.gitSavePrivateKey.checked){
 						gitCredentialsStorage.setPrivateKey(repository, loadedPrivateKey);
 						gitCredentialsStorage.setPassphrase(repository, self.gitPassphrase.value);
@@ -169,7 +169,7 @@
 			reader.readAsText(this.privateKeyFile);
 		} else if(loadedPrivateKey){
 				//save key
-				var gitCredentialsStorage = new mGitCredentialsStorage.GitCredentialsStorage();
+				var gitCredentialsStorage = new GitCredentialsStorage();
 				if(gitCredentialsStorage.isEnabled() && self.gitSavePrivateKey.checked){
 					gitCredentialsStorage.setPrivateKey(repository, loadedPrivateKey);
 					gitCredentialsStorage.setPassphrase(repository, self.gitPassphrase.value);