178227 - code cleanup

patch by mconnor@rogers.com, r=me
This commit is contained in:
dean_tessman%hotmail.com 2003-07-23 02:43:05 +00:00
parent beb51bc227
commit 8153c47262
2 changed files with 14 additions and 8 deletions

View File

@ -102,23 +102,26 @@ function onOK() {
// check download directory is valid
function checkDownloadDirectory() {
var dloadDir = Components.classes["@mozilla.org/file/local;1"]
.createInstance(Components.interfaces.nsILocalFile);
if (!dloadDir) return false;
.createInstance(Components.interfaces.nsILocalFile);
if (!dloadDir)
return false;
var givenValue = document.getElementById("defaultDir");
var downloadDir = document.getElementById("downloadDir");
if (downloadDir.selectedItem == document.getElementById("alwaysAskRadio")) { return; }
if (downloadDir.selectedItem == document.getElementById("alwaysAskRadio"))
return;
try {
dloadDir.initWithPath(givenValue.value);
dloadDir.isDirectory();
}
catch(ex) {
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
.getService(Components.interfaces.nsIPromptService);
var prefbundle = document.getElementById("bundle_prefutilities");
if ( givenValue.value == "" ) { // no directory, reset back to Always Ask
if (givenValue.value == "") {
// no directory, reset back to Always Ask
downloadDir.selectedItem = document.getElementById("alwaysAskRadio");
} else {
var checkValue = {value:false};
@ -136,9 +139,11 @@ function checkDownloadDirectory() {
return;
}
try {
dloadDir.create(1,0777);
dloadDir.create(nsIFile.DIRECTORY_TYPE, 0755);
} catch(ex) {
alert( prefbundle.getFormattedString("invalidDir", [givenValue.value]) );
title = prefbundle.getString("invalidDirPopupTitle");
description = prefbundle.getFormattedString("invalidDir", [givenValue.value])
promptService.alert(parent, title, description);
}
}
}

View File

@ -30,6 +30,7 @@ prefRemovePasswdsMsg=Remove all saved passwords?
prefRemovePasswdsTitle=Remove All Passwords
prefRemovePasswdsRemoveButton=Remove All Passwords
invalidDirPopupTitle=Error Creating %s
invalidDirPopup=The directory %S does not exist. Do you wish to create it?
downloadDirTitle=Select Download Directory
invalidDir=Unable to create directory %S. This is not a valid directory name.