B2G/gecko/browser/devtools/scratchpad/scratchpad.js
/**
   * Save a recent file in a JSON parsable string.
   *
   * @param nsILocalFile aFile
   *        The nsILocalFile we want to save as a recent file.
   */
Save a recent file in a JSON parsable string.
@param nsILocalFile aFile
The nsILocalFile we want to save as a recent file.
Save a recent file in a JSON parsable string . @param nsILocalFile aFile The nsILocalFile we want to save as a recent file .
function SP_setRecentFile(aFile)
  {
    let maxRecent = Services.prefs.getIntPref(PREF_RECENT_FILES_MAX);
    if (maxRecent < 1) {
      return;
    }
    let filePaths = this.getRecentFiles();
    let filesCount = filePaths.length;
    let pathIndex = filePaths.indexOf(aFile.path);
    if (pathIndex > -1) {
      if (pathIndex === (filesCount - 1)) {
        this.populateRecentFilesMenu();
        return;
      }
      filePaths.splice(pathIndex, 1);
    }
    else if (filesCount === maxRecent) {
      filePaths.shift();
    }
    filePaths.push(aFile.path);
    let branch = Services.prefs.
                 getBranch("devtools.scratchpad.");
    branch.setCharPref("recentFilePaths", JSON.stringify(filePaths));
    return;
  }
function SP_setRecentFile ( aFile ) { let maxRecent = Services . prefs . getIntPref ( PREF_RECENT_FILES_MAX ) ; if ( maxRecent < 1 ) { return ; } let filePaths = this . getRecentFiles ( ) ; let filesCount = filePaths . length ; let pathIndex = filePaths . indexOf ( aFile . path ) ; if ( pathIndex > - 1 ) { if ( pathIndex === ( filesCount - 1 ) ) { this . populateRecentFilesMenu ( ) ; return ; } filePaths . splice ( pathIndex , 1 ) ; } else if ( filesCount === maxRecent ) { filePaths . shift ( ) ; } filePaths . push ( aFile . path ) ; let branch = Services . prefs . getBranch ( "devtools.scratchpad." ) ; branch . setCharPref ( "recentFilePaths" , JSON . stringify ( filePaths ) ) ; return ; }
Save a recent file in a JSON parsable string.
Save a recent file in a JSON parsable string .
// We are already storing this file in the list of recent files. // If it's already the most recent file, we don't have to do anything. // Updating the menu to clear the disabled state from the wrong menuitem // in rare cases when two or more Scratchpad windows are open and the // same file has been opened in two or more windows. // It is not the most recent file. Remove it from the list, we add it as // the most recent farther down. // If we are not storing the file and the 'recent files'-list is full, // remove the oldest file from the list.