B2G/gecko/browser/devtools/scratchpad/scratchpad.js
/**
   * Save the textbox content to a new file.
   *
   * @param function aCallback
   *        Optional function you want to call when file is saved
   */
Save the textbox content to a new file.
@param function aCallback
Optional function you want to call when file is saved
Save the textbox content to a new file . @param function aCallback Optional function you want to call when file is saved
function SP_saveFileAs(aCallback)
  {
    let fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
    let fpCallback = function fpCallback_done(aResult) {
      if (aResult != Ci.nsIFilePicker.returnCancel) {
        this.setFilename(fp.file.path);
        this.exportToFile(fp.file, true, false, function(aStatus) {
          if (Components.isSuccessCode(aStatus)) {
            this.editor.dirty = false;
            this.setRecentFile(fp.file);
          }
          if (aCallback) {
            aCallback(aStatus);
          }
        });
      }
    }.bind(this);
    fp.init(window, this.strings.GetStringFromName("saveFileAs"),
            Ci.nsIFilePicker.modeSave);
    fp.defaultString = "scratchpad.js";
    fp.open(fpCallback);
  }
function SP_saveFileAs ( aCallback ) { let fp = Cc [ "@mozilla.org/filepicker;1" ] . createInstance ( Ci . nsIFilePicker ) ; let fpCallback = function fpCallback_done ( aResult ) { if ( aResult != Ci . nsIFilePicker . returnCancel ) { this . setFilename ( fp . file . path ) ; this . exportToFile ( fp . file , true , false , function ( aStatus ) { if ( Components . isSuccessCode ( aStatus ) ) { this . editor . dirty = false ; this . setRecentFile ( fp . file ) ; } if ( aCallback ) { aCallback ( aStatus ) ; } } ) ; } } . bind ( this ) ; fp . init ( window , this . strings . GetStringFromName ( "saveFileAs" ) , Ci . nsIFilePicker . modeSave ) ; fp . defaultString = "scratchpad.js" ; fp . open ( fpCallback ) ; }
Save the textbox content to a new file.
Save the textbox content to a new file .