rem: parentDir = tempLocalFile.parent; 
add: { if (!aSaveAs) parentDir = null; else {    var oldLocation = GetDocumentURI(editorDoc); var oldLocationLastSlash = oldLocation.lastIndexOf("\/"); if (oldLocationLastSlash != -1) oldLocation = oldLocation.slice(0, oldLocationLastSlash);  var curParentString = urlstring; var newLocationLastSlash = curParentString.lastIndexOf("\/"); if (newLocationLastSlash != -1) curParentString = curParentString.slice(0, newLocationLastSlash); if (oldLocation == curParentString) parentDir = null; else parentDir = tempLocalFile.parent; } } 
context: function SaveDocument(aSaveAs, aSaveCopy, aMimeType){  if (!aMimeType || aMimeType == "" || !window.editorShell)    throw NS_ERROR_NOT_INITIALIZED;  var editorDoc = window.editorShell.editorDocument;  if (!editorDoc)    throw NS_ERROR_NOT_INITIALIZED;  // if we don't have the right editor type bail (we handle text and html)  var editorType = window.editorShell.editorType;//  var isMailType = (editorType == "textmail" || editorType == "htmlmail")  if (editorType != "text" && editorType != "html" && editorType != "htmlmail")    throw NS_ERROR_NOT_IMPLEMENTED;  var saveAsTextFile = window.editorShell.isSupportedTextType(aMimeType);  // check if the file is to be saved in a format we don't understand; if so, bail  if (aMimeType != "text/html" && !saveAsTextFile)    throw NS_ERROR_NOT_IMPLEMENTED;  if (saveAsTextFile)    aMimeType = "text/plain";  var urlstring = GetDocumentURI(editorDoc);  var mustShowFileDialog = (aSaveAs || IsUrlAboutBlank(urlstring) || (urlstring == ""));  var replacing = !aSaveAs;  var titleChanged = false;  var doUpdateURL = false;  var tempLocalFile = null;  if (mustShowFileDialog)  {	  try {	    var domhtmldoc = editorDoc.QueryInterface(Components.interfaces.nsIDOMHTMLDocument);	    // Prompt for title if we are saving to HTML	    if (!saveAsTextFile && (editorType == "html"))	    {	      var userContinuing = PromptAndSetTitleIfNone(domhtmldoc); // not cancel	      if (!userContinuing)	        return false;	    }	    var dialogResult = PromptForSaveLocation(saveAsTextFile, editorType, aMimeType, domhtmldoc, urlstring);	    if (dialogResult.filepickerClick == nsIFilePicker.returnCancel)	      return false;	    replacing = (dialogResult.filepickerClick == nsIFilePicker.returnReplace);	    urlstring = dialogResult.resultingURIString;	    tempLocalFile = dialogResult.resultingLocalFile;       // update the new URL for the webshell unless we are saving a copy      if (!aSaveCopy)        doUpdateURL = true;   } catch (e) {  return false; }  } // mustShowFileDialog  var success = true;  try {    // if somehow we didn't get a local file but we did get a uri,     // attempt to create the localfile if it's a "file" url    var docURI;    if (!tempLocalFile)    {      docURI = Components.classes["@mozilla.org/network/standard-url;1"].createInstance(Components.interfaces.nsIURI);      docURI.spec = urlstring;            if (docURI.schemeIs("file"))      {        tempLocalFile = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);        var ioService = GetIOService();        ioService.initFileFromURLSpec(tempLocalFile, urlstring);      }    }    // this is the location where the related files will go    var parentDir;    try {      if (tempLocalFile)        parentDir = tempLocalFile.parent;      else      {        var lastSlash = urlstring.lastIndexOf("\/");        if (lastSlash != -1)        {          var parentDirString = urlstring.slice(0, lastSlash + 1);  // include last slash          parentDir = Components.classes["@mozilla.org/network/standard-url;1"].createInstance(Components.interfaces.nsIURI);          parentDir.spec = parentDirString;        }        else          parentDir = null;      }    } catch(e) { parentDir = null; }    var destinationLocation;    if (tempLocalFile)      destinationLocation = tempLocalFile;    else      destinationLocation = docURI;    success = OutputFileWithPersistAPI(editorDoc, destinationLocation, parentDir, aMimeType);  }  catch (e)  {    // XXX we need to change these strings if we are publishing!!!    var saveDocStr = GetString("SaveDocument");    var failedStr = GetString("SaveFileFailed");    AlertWithTitle(saveDocStr, failedStr);    success = false;  }  try {    window.editorShell.doAfterSave(doUpdateURL, urlstring);  // we need to update the url before notifying listeners    if (!aSaveCopy && success)      window.editorShell.editor.ResetModificationCount();  // this should cause notification to listeners that document has changed  } catch (e) {}  return success;}
meta: 8395	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/8395/4d1a0b7bc5500b74ec7669685b678185b0c2e943/ComposerCommands.js/clean/editor/ui/composer/content/ComposerCommands.js