B2G/gecko/browser/components/places/content/places.js
/**
   * Populates the restore menu with the dates of the backups available.
   */
Populates the restore menu with the dates of the backups available.
Populates the restore menu with the dates of the backups available .
function PO_populateRestoreMenu() {
    let restorePopup = document.getElementById("fileRestorePopup");
    let dateSvc = Cc["@mozilla.org/intl/scriptabledateformat;1"].
                  getService(Ci.nsIScriptableDateFormat);
    while (restorePopup.childNodes.length > 1)
      restorePopup.removeChild(restorePopup.firstChild);
    let backupFiles = PlacesUtils.backups.entries;
    if (backupFiles.length == 0)
      return;
    for (let i = 0; i < backupFiles.length; i++) {
      let backupDate = PlacesUtils.backups.getDateForFile(backupFiles[i]);
      let m = restorePopup.insertBefore(document.createElement("menuitem"),
                                        document.getElementById("restoreFromFile"));
      m.setAttribute("label",
                     dateSvc.FormatDate("",
                                        Ci.nsIScriptableDateFormat.dateFormatLong,
                                        backupDate.getFullYear(),
                                        backupDate.getMonth() + 1,
                                        backupDate.getDate()));
      m.setAttribute("value", backupFiles[i].leafName);
      m.setAttribute("oncommand",
                     "PlacesOrganizer.onRestoreMenuItemClick(this);");
    }
    restorePopup.insertBefore(document.createElement("menuseparator"),
                              document.getElementById("restoreFromFile"));
  }
function PO_populateRestoreMenu ( ) { let restorePopup = document . getElementById ( "fileRestorePopup" ) ; let dateSvc = Cc [ "@mozilla.org/intl/scriptabledateformat;1" ] . getService ( Ci . nsIScriptableDateFormat ) ; while ( restorePopup . childNodes . length > 1 ) restorePopup . removeChild ( restorePopup . firstChild ) ; let backupFiles = PlacesUtils . backups . entries ; if ( backupFiles . length == 0 ) return ; for ( let i = 0 ; i < backupFiles . length ; i ++ ) { let backupDate = PlacesUtils . backups . getDateForFile ( backupFiles [ i ] ) ; let m = restorePopup . insertBefore ( document . createElement ( "menuitem" ) , document . getElementById ( "restoreFromFile" ) ) ; m . setAttribute ( "label" , dateSvc . FormatDate ( "" , Ci . nsIScriptableDateFormat . dateFormatLong , backupDate . getFullYear ( ) , backupDate . getMonth ( ) + 1 , backupDate . getDate ( ) ) ) ; m . setAttribute ( "value" , backupFiles [ i ] . leafName ) ; m . setAttribute ( "oncommand" , "PlacesOrganizer.onRestoreMenuItemClick(this);" ) ; } restorePopup . insertBefore ( document . createElement ( "menuseparator" ) , document . getElementById ( "restoreFromFile" ) ) ; }
Populates the restore menu with the dates of the backups available.
Populates the restore menu with the dates of the backups available .
// Remove existing menu items.  Last item is the restoreFromFile item. // Populate menu with backups. // Add the restoreFromFile item.