rem:  var source; 
context: function SetEditMode(mode){  if (gIsHTMLEditor)  {    var bodyNode = editorShell.editorDocument.getElementsByTagName("body").item(0);    if (!bodyNode)    {      dump("SetEditMode: We don't have a body node!\n");      return;    }    // Switch the UI mode before inserting contents    //   so user can't type in source window while new window is being filled    var previousMode = gEditorDisplayMode;    if (!SetDisplayMode(mode))      return;    var source;    if (mode == DisplayModeSource)    {      // Display the DOCTYPE as a non-editable string above edit area      var domdoc;      try { domdoc = window.editorShell.editorDocument; } catch (e) { dump( e + "\n");}      if (domdoc)      {        var doctypeNode = document.getElementById("doctype-text");        var dt = domdoc.doctype;        if (doctypeNode)        {          if (dt)          {            doctypeNode.removeAttribute("collapsed");            var doctypeText = "<!DOCTYPE " + domdoc.doctype.name;            if (dt.publicId)              doctypeText += " PUBLIC \"" + domdoc.doctype.publicId;            if (dt.systemId)              doctypeText += " "+"\"" + dt.systemId;            doctypeText += "\">"            doctypeNode.setAttribute("value", doctypeText);          }          else            doctypeNode.setAttribute("collapsed", "true");        }      }      // We can't monitor changes while in HTML Source,      //   so the nsSaveCommand::isCommandEnabled() will always return true      //   when in HTML Source mode      goUpdateCommand("cmd_save");      // Get the entire document's source string      var flags = gOutputEncodeEntities;      //      var prettyPrint = gPrefs.GetBoolPref("editor.prettyprint");      if (prettyPrint)        flags |= gOutputFormatted;      source = editorShell.GetContentsAs("text/html", flags);      var start = source.search(/<html/i);      if (start == -1) start = 0;      gSourceContentWindow.value = source.slice(start);      gSourceContentWindow.focus();    }    else if (previousMode == DisplayModeSource)    {      // We are comming from edit source mode,      //   so transfer that back into the document      source = gSourceContentWindow.value;      editorShell.RebuildDocumentFromSource(source);      // Get the text for the <title> from the newly-parsed document      // (must do this for proper conversion of "escaped" characters)      var title = "";      var titlenodelist = window.editorShell.editorDocument.getElementsByTagName("title");      if (titlenodelist)      {        var titleNode = titlenodelist.item(0);        if (titleNode && titleNode.firstChild && titleNode.firstChild.data)          title = titleNode.firstChild.data;      }      window.editorShell.editorDocument.title = title;      // Clear out the string buffers      source = null;      gSourceContentWindow.value = null;      // reset selection to top of doc (wish we could preserve it!)      if (bodyNode)        editorShell.editorSelection.collapse(bodyNode, 0);      gContentWindow.focus();    }    ResetWindowTitleWithFilename();  }}
meta: 5459	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/5459/84722f7afb6e50132f1ca0ebae84a54b02be857f/editor.js/clean/editor/ui/composer/content/editor.js